Skip to content

Commit

Permalink
[MIG] website_product_configurator_mrp: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SirAionTech committed Nov 7, 2024
1 parent c752963 commit d2c3ddb
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 95 deletions.
19 changes: 13 additions & 6 deletions website_product_configurator_mrp/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Website Configurator Manufacturing
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2aa0a69c23cecee3bd79eabf576f012aad028d14e3abe8199ab53abc2d0a90c1
!! source digest: sha256:a55a561a34007075b92afb36e30a1da5a0833ecb47ce4503985816075c7cd57a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,13 +17,13 @@ Website Configurator Manufacturing
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--configurator-lightgray.png?logo=github
:target: https://github.com/OCA/product-configurator/tree/14.0/website_product_configurator_mrp
:target: https://github.com/OCA/product-configurator/tree/16.0/website_product_configurator_mrp
:alt: OCA/product-configurator
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-configurator-14-0/product-configurator-14-0-website_product_configurator_mrp
:target: https://translation.odoo-community.org/projects/product-configurator-16-0/product-configurator-16-0-website_product_configurator_mrp
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/product-configurator&target_branch=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/product-configurator&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -41,7 +41,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-configurator/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/product-configurator/issues/new?body=module:%20website_product_configurator_mrp%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/product-configurator/issues/new?body=module:%20website_product_configurator_mrp%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -53,6 +53,13 @@ Authors

* Pledra

Contributors
~~~~~~~~~~~~

* `Aion Tech <https://aiontech.company/>`_:

* Simone Rubino <simone.rubino@aion-tech.it>

Maintainers
~~~~~~~~~~~

Expand All @@ -74,6 +81,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-PCatinean|

This module is part of the `OCA/product-configurator <https://github.com/OCA/product-configurator/tree/14.0/website_product_configurator_mrp>`_ project on GitHub.
This module is part of the `OCA/product-configurator <https://github.com/OCA/product-configurator/tree/16.0/website_product_configurator_mrp>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
11 changes: 9 additions & 2 deletions website_product_configurator_mrp/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Website Configurator Manufacturing",
"version": "14.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Website",
"summary": "Website integration of MRP",
"author": "Pledra, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/product-configurator",
"depends": ["product_configurator_mrp", "website_product_configurator"],
"data": ["views/templates.xml", "views/assets.xml"],
"data": [
"views/templates.xml",
],
"assets": {
"web.assets_frontend": [
"website_product_configurator_mrp/static/src/js/website_sale.esm.js",
],
},
"application": True,
"installable": True,
"development_status": "Beta",
Expand Down
31 changes: 8 additions & 23 deletions website_product_configurator_mrp/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,23 @@
from odoo import http
from odoo.http import request

from odoo.addons.website_product_configurator.controllers.main import (
ProductConfigWebsiteSale,
)
from odoo.addons.website_sale.controllers.main import WebsiteSale


class WebsiteProductConfigMrp(ProductConfigWebsiteSale):
@http.route(
["/shop/cart/update"],
type="http",
auth="public",
methods=["POST"],
website=True,
csrf=False,
)
def cart_update(self, product_id, add_qty=1, set_qty=0, **kw):
class WebsiteProductConfigMrp(WebsiteSale):
@http.route()
def cart_update_json(self, product_id, **kw):
product = request.env["product.product"].browse(int(product_id))
if product.config_ok and kw.get("assembly") == "kit":
attr_value_ids = product.product_template_attribute_value_ids
attr_products = attr_value_ids.mapped(
"product_attribute_value_id.product_id"
)
if not attr_products:
return super(WebsiteProductConfigMrp, self).cart_update(
product_id=product_id, add_qty=add_qty, set_qty=set_qty, **kw
)
return super().cart_update_json(product_id, **kw)

for product_id in attr_products:
res = super(ProductConfigWebsiteSale, self).cart_update(
product_id=product_id, add_qty=add_qty, set_qty=set_qty, **kw
)
for attr_product in attr_products:
res = super().cart_update_json(attr_product.id, **kw)
return res
else:
return super(WebsiteProductConfigMrp, self).cart_update(
product_id=product_id, add_qty=add_qty, set_qty=set_qty, **kw
)
return super().cart_update_json(product_id, **kw)
3 changes: 3 additions & 0 deletions website_product_configurator_mrp/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Aion Tech <https://aiontech.company/>`_:

* Simone Rubino <simone.rubino@aion-tech.it>
23 changes: 16 additions & 7 deletions website_product_configurator_mrp/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -367,17 +366,18 @@ <h1 class="title">Website Configurator Manufacturing</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2aa0a69c23cecee3bd79eabf576f012aad028d14e3abe8199ab53abc2d0a90c1
!! source digest: sha256:a55a561a34007075b92afb36e30a1da5a0833ecb47ce4503985816075c7cd57a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/product-configurator/tree/14.0/website_product_configurator_mrp"><img alt="OCA/product-configurator" src="https://img.shields.io/badge/github-OCA%2Fproduct--configurator-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/product-configurator-14-0/product-configurator-14-0-website_product_configurator_mrp"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/product-configurator&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/product-configurator/tree/16.0/website_product_configurator_mrp"><img alt="OCA/product-configurator" src="https://img.shields.io/badge/github-OCA%2Fproduct--configurator-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/product-configurator-16-0/product-configurator-16-0-website_product_configurator_mrp"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/product-configurator&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Website Configurator Manufacturing module facility to display “Assembled” and “Kit” on the product page and based on the selected option added product into cart.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-4">Maintainers</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
</ul>
</li>
</ul>
Expand All @@ -387,7 +387,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/product-configurator/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/product-configurator/issues/new?body=module:%20website_product_configurator_mrp%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/product-configurator/issues/new?body=module:%20website_product_configurator_mrp%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -398,16 +398,25 @@ <h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<li>Pledra</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://aiontech.company/">Aion Tech</a>:<ul>
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;aion-tech.it">simone.rubino&#64;aion-tech.it</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-4">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/PCatinean"><img alt="PCatinean" src="https://github.com/PCatinean.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-configurator/tree/14.0/website_product_configurator_mrp">OCA/product-configurator</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-configurator/tree/16.0/website_product_configurator_mrp">OCA/product-configurator</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
17 changes: 17 additions & 0 deletions website_product_configurator_mrp/static/src/js/website_sale.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @odoo-module **/

import {WebsiteSale} from "website_sale.website_sale";

WebsiteSale.include({
/**
* Override to inject product assembly
*
* @override
*/
// eslint-disable-next-line no-unused-vars
_updateRootProduct($form, productId) {
this._super(...arguments);
const assembly = $form.find('select[name="assembly"]').val();
if (assembly) this.rootProduct.assembly = assembly;
},
});
18 changes: 0 additions & 18 deletions website_product_configurator_mrp/static/src/js/website_sale.js

This file was deleted.

19 changes: 0 additions & 19 deletions website_product_configurator_mrp/views/assets.xml

This file was deleted.

38 changes: 18 additions & 20 deletions website_product_configurator_mrp/views/templates.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<template
id="cfg_session"
inherit_id="website_product_configurator.cfg_product"
name="Configuration Session MRP"
>
<xpath expr="//a[@id='add_to_cart']" position="before">
<t
t-set="componant_products"
t-value="product_variant.product_template_attribute_value_ids.mapped('product_attribute_value_id.product_id')"
/>
<div class="input-group mt8" t-if="componant_products">
<select name="assembly" class='form-control'>
<option value="assembled">Assembled</option>
<option value="kit">Kit</option>
</select>
</div>
</xpath>
</template>
</data>
<template
id="cfg_session"
inherit_id="website_product_configurator.cfg_product"
name="Configuration Session MRP"
>
<xpath expr="//a[@id='add_to_cart']/.." position="before">
<t
t-set="component_products"
t-value="product_variant.product_template_attribute_value_ids.mapped('product_attribute_value_id.product_id')"
/>
<div class="input-group mt8" t-if="component_products">
<select name="assembly" class='form-control'>
<option value="assembled">Assembled</option>
<option value="kit">Kit</option>
</select>
</div>
</xpath>
</template>
</odoo>

0 comments on commit d2c3ddb

Please sign in to comment.