[FIX] mrp_subcontracting: Allow to create backorder for tracked products

This commit fixes the 'You need to supply a Lot/Serial Number...' message
when validating a receipt with backorder for subcontracted tracked products.

closes odoo/odoo#79121

Task: 2604664
X-original-commit: 2ab8f5cc681d45323e540ca57f85168fd587cf02
Signed-off-by: Tiffany Chang <tic@odoo.com>
This commit is contained in:
JF Aubert
2021-10-28 10:05:37 +00:00
parent f51a53e6ee
commit aa2d0abb1b
3 changed files with 16 additions and 3 deletions
@@ -361,6 +361,12 @@ msgid ""
"subcontracting."
msgstr ""
#. module: mrp_subcontracting
#: code:addons/mrp_subcontracting/models/mrp_production.py:0
#, python-format
msgid "You must enter a serial number for %s"
msgstr ""
#. module: mrp_subcontracting
#: code:addons/mrp_subcontracting/models/mrp_production.py:0
#, python-format
@@ -41,6 +41,8 @@ class MrpProduction(models.Model):
raise UserError(_("This MO isn't related to a subcontracted move"))
if float_is_zero(self.qty_producing, precision_rounding=self.product_uom_id.rounding):
return {'type': 'ir.actions.act_window_close'}
if self.product_tracking != 'none' and not self.lot_producing_id:
raise UserError(_('You must enter a serial number for %s') % self.product_id.name)
for sml in self.move_raw_ids.move_line_ids:
if sml.tracking != 'none' and not sml.lot_id:
raise UserError(_('You must enter a serial number for each line of %s') % sml.product_id.name)
@@ -67,6 +69,11 @@ class MrpProduction(models.Model):
return action
return {'type': 'ir.actions.act_window_close'}
def action_subcontracting_discard_remaining_components(self):
self.ensure_one()
self.qty_producing = 0
return {'type': 'ir.actions.act_window_close'}
def _pre_button_mark_done(self):
if self._get_subcontract_move():
return True
@@ -141,7 +148,7 @@ class MrpProduction(models.Model):
return False
if not all(line.lot_id for line in mo.move_raw_ids.filtered(lambda sm: sm.has_tracking != 'none').move_line_ids):
return False
if mo.product_id.tracking != 'none' and not mo.lot_producing_id:
if mo.product_tracking != 'none' and not mo.lot_producing_id:
return False
return True
@@ -19,7 +19,7 @@
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='lot_producing_id']" position="attributes">
<attribute name="attrs">{'invisible': [('product_tracking', 'in', ('none', False))], 'required': [('product_tracking', 'not in', ('none', False))]}</attribute>
<attribute name="attrs">{'invisible': [('product_tracking', 'in', ('none', False))]}</attribute>
</xpath>
<xpath expr="//page[@name='miscellaneous']" position="attributes">
<attribute name="invisible">1</attribute>
@@ -46,7 +46,7 @@
<footer>
<button name="subcontracting_record_component" attrs="{'invisible': ['|', ('state', '=', 'to_close'), ('qty_producing', '&lt;', 0.001)]}" string="Continue" type="object" class="oe_highlight" data-hotkey="q"/>
<button name="subcontracting_record_component" attrs="{'invisible': [('state', '!=', 'to_close')]}" string="Record Production" type="object" class="oe_highlight" data-hotkey="q"/>
<button string="Discard" special="cancel" data-hotkey="z" />
<button name="action_subcontracting_discard_remaining_components" string="Discard" type="object" data-hotkey="z"/>
</footer>
</xpath>
</field>