[FIX] mrp: support multi-operation type allocation report
Steps to reproduce: - toggle setting `mrp.group_mrp_reception_report = True` - create a new 'mrp_operation' operation type and activate `auto_show_reception_report` for this operation type - create a delivery of a product (qty > 1) - create 2 MOs for the product to deliver, one with the new operation type and one with the built in operation type - try to "Mark as Done" both MOs (from the list view) Expected result: MOs are marked as done, only 1 of the MOs shows up in the allocation report for the delivery Actual result: Singleton access issue Noticed during task: 3046178 Part-of: odoo/odoo#126791
This commit is contained in:
@@ -1979,11 +1979,12 @@ class MrpProduction(models.Model):
|
||||
'res_id': self.id,
|
||||
'target': 'main',
|
||||
}
|
||||
if self.user_has_groups('mrp.group_mrp_reception_report') and self.picking_type_id.auto_show_reception_report:
|
||||
lines = self.move_finished_ids.filtered(lambda m: m.product_id.type == 'product' and m.state != 'cancel' and m.quantity_done and not m.move_dest_ids)
|
||||
if self.user_has_groups('mrp.group_mrp_reception_report'):
|
||||
mos_to_show = self.filtered(lambda mo: mo.picking_type_id.auto_show_reception_report)
|
||||
lines = mos_to_show.move_finished_ids.filtered(lambda m: m.product_id.type == 'product' and m.state != 'cancel' and m.quantity_done and not m.move_dest_ids)
|
||||
if lines:
|
||||
if any(mo.show_allocation for mo in self):
|
||||
action = self.action_view_reception_report()
|
||||
if any(mo.show_allocation for mo in mos_to_show):
|
||||
action = mos_to_show.action_view_reception_report()
|
||||
return action
|
||||
return True
|
||||
context = self.env.context.copy()
|
||||
@@ -2059,7 +2060,10 @@ class MrpProduction(models.Model):
|
||||
return action
|
||||
|
||||
def action_view_reception_report(self):
|
||||
return self.env["ir.actions.actions"]._for_xml_id("mrp.mrp_reception_action")
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("mrp.mrp_reception_action")
|
||||
# default_production_ids needs to be first default_ key so the "print" button correctly works
|
||||
action['context'] = dict({'default_production_ids': self.ids}, **self.env.context)
|
||||
return action
|
||||
|
||||
def action_view_mrp_production_unbuilds(self):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -4,6 +4,5 @@
|
||||
<field name="name">MRP Reception Report</field>
|
||||
<field name="tag">reception_report</field>
|
||||
<field name="res_model">report.stock.report_reception</field>
|
||||
<field name="context">{'default_production_ids': active_ids}</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user