Skip to content

Commit

Permalink
[17.0][MIG] product_configurator_mrp
Browse files Browse the repository at this point in the history
  • Loading branch information
Murtaza-OSI committed Feb 16, 2024
1 parent 2a42117 commit a4f6b67
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 31 deletions.
24 changes: 12 additions & 12 deletions product_configurator_mrp/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@

{
"name": "Product Configurator Manufacturing",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Manufacturing",
"summary": "BOM Support for configurable products",
"author": "Pledra, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/product-configurator",
"depends": ["mrp", "product_configurator"],
"depends": ["mrp_account", "product_configurator"],
"data": [
"data/menu_product.xml",
"views/mrp_view.xml",
"security/configurator_security.xml",
"security/ir.model.access.csv",
],
"assets": {
"web.assets_backend": [
"/product_configurator_mrp/static/src/js/list_controller.js",
"/product_configurator_mrp/static/src/js/kanban_controller.js",
"/product_configurator_mrp/static/src/js/form_controller.js",
"/product_configurator_mrp/static/src/scss/mrp_config.scss",
"/product_configurator_mrp/static/src/xml/mrp_production_views.xml",
],
},
# "assets": {
# "web.assets_backend": [
# "/product_configurator_mrp/static/src/js/list_controller.js",
# "/product_configurator_mrp/static/src/js/kanban_controller.js",
# "/product_configurator_mrp/static/src/js/form_controller.js",
# "/product_configurator_mrp/static/src/scss/mrp_config.scss",
# "/product_configurator_mrp/static/src/xml/mrp_production_views.xml",
# ],
# },
"demo": ["demo/product_template.xml"],
"qweb": ["static/src/xml/mrp_production_views.xml"],
# "qweb": ["static/src/xml/mrp_production_views.xml"],
"installable": True,
"auto_install": False,
"development_status": "Beta",
Expand Down
26 changes: 15 additions & 11 deletions product_configurator_mrp/models/product_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class ProductConfigSession(models.Model):
_inherit = "product.config.session"

def create_get_bom(self, variant, product_tmpl_id=None, values=None):

# default_type is set as 'product' when the user navigates
# through menu item "Products". This conflicts
# with the type for mrp.bom when mrpBom.onchange() is executed.
Expand Down Expand Up @@ -94,6 +93,10 @@ def create_get_bom(self, variant, product_tmpl_id=None, values=None):
"product_qty": parent_bom_line.product_qty,
}
specs = self.get_onchange_specifications(model="mrp.bom.line")
for key, val in specs.items():
if val is None:
specs[key] = {}

updates = mrpBomLine.onchange(
parent_bom_line_vals, ["product_id", "product_qty"], specs
)
Expand All @@ -110,23 +113,24 @@ def create_get_bom(self, variant, product_tmpl_id=None, values=None):
"bom_line_ids": bom_lines,
}
specs = self.get_onchange_specifications(model="mrp.bom")
updates = mrpBom.onchange(
bom_values,
["product_id", "product_tmpl_id", "bom_line_ids"],
specs,
)
values = updates.get("value", {})
values = self.get_vals_to_write(values=values, model="mrp.bom")
values.update(bom_values)
mrp_bom_id = mrpBom.create(values)

# updates = mrpBom.onchange(
# bom_values,
# ["product_id", "product_tmpl_id", "bom_line_ids"],
# specs,
# )
# values = updates.get("value", {})
# values = self.get_vals_to_write(values=values, model="mrp.bom")
# values.update(bom_values)
mrp_bom_id = mrpBom.create(bom_values)
if mrp_bom_id and parent_bom:
for operation_line in parent_bom.operation_ids:
operation_line.copy(default={"bom_id": mrp_bom_id.id})
return mrp_bom_id
return False

def create_get_variant(self, value_ids=None, custom_vals=None):
variant = super(ProductConfigSession, self).create_get_variant(
variant = super().create_get_variant(
value_ids=value_ids, custom_vals=custom_vals
)
self.create_get_bom(variant=variant, product_tmpl_id=self.product_tmpl_id)
Expand Down
13 changes: 6 additions & 7 deletions product_configurator_mrp/views/mrp_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class="oe_highlight"
type="object"
string="Reconfigure"
attrs="{'invisible': ['|', ('config_ok','=',False), ('state', '!=', 'draft')]}"
invisible="not config_ok or state != 'draft'"
/>
</div>
</xpath>
Expand Down Expand Up @@ -80,9 +80,7 @@
</xpath>

<xpath expr="//field[@name='product_id']" position="attributes">
<attribute
name="attrs"
>{'readonly': [('config_ok', '=', True)]}</attribute>
<attribute name="readonly">"config_ok"</attribute>
<attribute name="force_save">True</attribute>
</xpath>

Expand All @@ -91,8 +89,9 @@
position="attributes"
>
<attribute
name="attrs"
>{'column_invisible': [('parent.type','not in', ('normal', 'phantom'))], 'readonly': [('parent.config_ok', '=', True)]}</attribute>
name="column_invisible"
>parent.type not in ('normal', 'phantom')</attribute>
<attribute name="readonly">parent.config_ok</attribute>
</xpath>

<xpath
Expand All @@ -101,7 +100,7 @@
>
<field
name="config_set_id"
attrs="{'readonly': [('parent.config_ok', '=', False)]}"
readonly="not parent.config_ok"
options="{'create_edit': True, 'open': 'True'}"
/>
</xpath>
Expand Down
18 changes: 17 additions & 1 deletion product_configurator_mrp/wizard/product_configurator_mrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ class ProductConfiguratorMrp(models.TransientModel):
comodel_name="mrp.production", string="Manufacturing Order"
)

domain_attr_ids = fields.Many2many(
"product.attribute.value",
"domain_attrs_mrp_configurator_rel",
"wiz_id",
"attribute_id",
string="Domain",
)

domain_attr_2_ids = fields.Many2many(
"product.attribute.value",
"domain_attrs_mrp_configurator_2_rel",
"wiz_id",
"attribute_id",
string="Domain 2",
)

def get_mrp_production_action(self):
mrp_action = self.env.ref("mrp.mrp_production_action").read()
if mrp_action:
Expand Down Expand Up @@ -57,7 +73,7 @@ def _get_order_vals(self, product_id):

def action_config_done(self):
"""Parse values and execute final code before closing the wizard"""
res = super(ProductConfiguratorMrp, self).action_config_done()
res = super().action_config_done()
if res.get("res_model") == self._name:
return res
model_name = "mrp.production"
Expand Down

0 comments on commit a4f6b67

Please sign in to comment.