[FIX] mrp_subcontracting: avoid byproduct

We cannot have byproduct in case of subcontracting,
raise a Error if we try (like operation). Also remove the
it from the subcontracted form (also clean empty space of it).

task-2486811

Part-of: odoo/odoo#75041
This commit is contained in:
Rémy Voet (ryv)
2021-09-03 10:37:47 +00:00
parent 7f068ef8ca
commit 2127ded2b1
2 changed files with 7 additions and 9 deletions
+3 -3
View File
@@ -21,7 +21,7 @@ class MrpBom(models.Model):
else:
return self.env['mrp.bom']
@api.constrains('operation_ids', 'type')
@api.constrains('operation_ids', 'byproduct_ids', 'type')
def _check_subcontracting_no_operation(self):
if self.filtered_domain([('type', '=', 'subcontract'), ('operation_ids', '!=', False)]):
raise ValidationError(_('You can not set a Bill of Material with operations as subcontracting.'))
if self.filtered_domain([('type', '=', 'subcontract'), '|', ('operation_ids', '!=', False), ('byproduct_ids', '!=', False)]):
raise ValidationError(_('You can not set a Bill of Material with operations or by-product line as subcontracting.'))
@@ -11,6 +11,7 @@
<field name="state" invisible="1"/>
</xpath>
<xpath expr="//div[@name='button_box']" position="replace"/>
<xpath expr="//div[hasclass('oe_title')]" position="replace"/>
<xpath expr="//group[@name='group_extra_info']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
@@ -23,15 +24,12 @@
<xpath expr="//page[@name='miscellaneous']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='name']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='priority']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='bom_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='move_byproduct_ids']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='action_generate_serial']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>