mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] mrp_bom_attribute_match: make private methods, private
These methods shouldn't be exposed to xmlrpc.
This commit is contained in:
@@ -39,11 +39,11 @@ class MrpBomLine(models.Model):
|
||||
|
||||
@api.onchange("component_template_id")
|
||||
def _onchange_component_template_id(self):
|
||||
self.update_component_attributes()
|
||||
self._update_component_attributes()
|
||||
|
||||
def update_component_attributes(self):
|
||||
def _update_component_attributes(self):
|
||||
if self.component_template_id:
|
||||
self.check_component_attributes()
|
||||
self._check_component_attributes()
|
||||
self.product_backup_id = self.product_id.id
|
||||
self.match_on_attribute_ids = (
|
||||
self.component_template_id.attribute_line_ids.mapped("attribute_id")
|
||||
@@ -51,14 +51,14 @@ class MrpBomLine(models.Model):
|
||||
.ids
|
||||
)
|
||||
self.product_id = False
|
||||
self.check_variants_validity()
|
||||
self._check_variants_validity()
|
||||
else:
|
||||
self.match_on_attribute_ids = False
|
||||
if self.product_backup_id and not self.product_id:
|
||||
self.product_id = self.product_backup_id.id
|
||||
self.product_backup_id = False
|
||||
|
||||
def check_component_attributes(self):
|
||||
def _check_component_attributes(self):
|
||||
comp_attr_ids = (
|
||||
self.component_template_id.valid_product_template_attribute_line_ids.attribute_id.ids
|
||||
)
|
||||
@@ -84,9 +84,9 @@ class MrpBomLine(models.Model):
|
||||
@api.onchange("bom_product_template_attribute_value_ids")
|
||||
def _onchange_attribute_value_ids(self):
|
||||
if self.bom_product_template_attribute_value_ids:
|
||||
self.check_variants_validity()
|
||||
self._check_variants_validity()
|
||||
|
||||
def check_variants_validity(self):
|
||||
def _check_variants_validity(self):
|
||||
if (
|
||||
not self.bom_product_template_attribute_value_ids
|
||||
or not self.component_template_id
|
||||
@@ -195,7 +195,7 @@ class MrpBom(models.Model):
|
||||
update_product_boms()
|
||||
product_ids.clear()
|
||||
# upd start
|
||||
component_template_product = self.get_component_template_product(
|
||||
component_template_product = self._get_component_template_product(
|
||||
current_line, product, current_line.product_id
|
||||
)
|
||||
if component_template_product:
|
||||
@@ -271,7 +271,9 @@ class MrpBom(models.Model):
|
||||
)
|
||||
return boms_done, lines_done
|
||||
|
||||
def get_component_template_product(self, bom_line, bom_product_id, line_product_id):
|
||||
def _get_component_template_product(
|
||||
self, bom_line, bom_product_id, line_product_id
|
||||
):
|
||||
if bom_line.component_template_id:
|
||||
comp = bom_line.component_template_id
|
||||
comp_attr_ids = (
|
||||
@@ -313,5 +315,5 @@ class MrpBom(models.Model):
|
||||
def write(self, vals):
|
||||
res = super(MrpBom, self).write(vals)
|
||||
for line in self.bom_line_ids:
|
||||
line.update_component_attributes()
|
||||
line._update_component_attributes()
|
||||
return res
|
||||
|
||||
@@ -5,8 +5,7 @@ class MrpProduction(models.Model):
|
||||
_inherit = "mrp.production"
|
||||
|
||||
def action_confirm(self):
|
||||
res = super(MrpProduction, self).action_confirm()
|
||||
if self and self.bom_id:
|
||||
res = super().action_confirm()
|
||||
for bom_line in self.bom_id.bom_line_ids:
|
||||
if bom_line.component_template_id:
|
||||
# product_id was set in mrp.bom.explode for correct flow. Need to remove it.
|
||||
@@ -14,6 +13,6 @@ class MrpProduction(models.Model):
|
||||
return res
|
||||
|
||||
def write(self, vals):
|
||||
for bl in self.bom_id.bom_line_ids.filtered(lambda x: x.component_template_id):
|
||||
bl.check_component_attributes()
|
||||
return super(MrpProduction, self).write(vals)
|
||||
for bl in self.bom_id.bom_line_ids.filtered("component_template_id"):
|
||||
bl._check_component_attributes()
|
||||
return super().write(vals)
|
||||
|
||||
@@ -8,11 +8,11 @@ class ProductTemplate(models.Model):
|
||||
def write(self, vals):
|
||||
res = super().write(vals)
|
||||
for rec in self:
|
||||
rec.check_product_with_component_change_allowed()
|
||||
rec.check_component_change_allowed()
|
||||
rec._check_product_with_component_change_allowed()
|
||||
rec._check_component_change_allowed()
|
||||
return res
|
||||
|
||||
def check_product_with_component_change_allowed(self):
|
||||
def _check_product_with_component_change_allowed(self):
|
||||
self.ensure_one()
|
||||
if len(self.attribute_line_ids) > 0 and len(self.bom_ids) > 0:
|
||||
for bom in self.bom_ids:
|
||||
@@ -38,10 +38,10 @@ class ProductTemplate(models.Model):
|
||||
)
|
||||
)
|
||||
|
||||
def check_component_change_allowed(self):
|
||||
def _check_component_change_allowed(self):
|
||||
self.ensure_one()
|
||||
if len(self.attribute_line_ids) > 0:
|
||||
boms = self.get_component_boms()
|
||||
boms = self._get_component_boms()
|
||||
if boms:
|
||||
for bom in boms:
|
||||
vpa = bom.product_tmpl_id.valid_product_template_attribute_line_ids
|
||||
@@ -61,7 +61,7 @@ class ProductTemplate(models.Model):
|
||||
)
|
||||
)
|
||||
|
||||
def get_component_boms(self):
|
||||
def _get_component_boms(self):
|
||||
self.ensure_one()
|
||||
bom_lines = self.env["mrp.bom.line"].search(
|
||||
[("component_template_id", "=", self._origin.id)]
|
||||
|
||||
Reference in New Issue
Block a user