diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index eb4bdcf4964..f616ccf03cf 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -2640,6 +2640,16 @@ class MrpProduction(models.Model): clean_action(action, self.env) report_actions.append(action) if self.user_has_groups('mrp.group_mrp_reception_report'): + reception_reports_to_print = self.filtered( + lambda p: p.picking_type_id.auto_print_mrp_reception_report + and p.picking_type_id.code == 'mrp_operation' + and p.move_finished_ids.move_dest_ids + ) + if reception_reports_to_print: + action = self.env.ref('stock.stock_reception_report_action').report_action(reception_reports_to_print, config=False) + action['context'] = dict({'default_production_ids': reception_reports_to_print.ids}, **self.env.context) + clean_action(action, self.env) + report_actions.append(action) reception_labels_to_print = self.filtered(lambda p: p.picking_type_id.auto_print_mrp_reception_report_labels and p.picking_type_id.code == 'mrp_operation') if reception_labels_to_print: moves_to_print = reception_labels_to_print.move_finished_ids.move_dest_ids diff --git a/addons/mrp/models/stock_picking.py b/addons/mrp/models/stock_picking.py index 16329a3b57d..828e484b04c 100644 --- a/addons/mrp/models/stock_picking.py +++ b/addons/mrp/models/stock_picking.py @@ -41,6 +41,9 @@ class StockPickingType(models.Model): done_mrp_lot_label_to_print = fields.Selection( [('pdf', 'PDF'), ('zpl', 'ZPL')], "Lot/SN Label to Print", default='pdf') + auto_print_mrp_reception_report = fields.Boolean( + "Auto Print Allocation Report", + help="If this checkbox is ticked, Odoo will automatically print the allocation report of a MO when it is done and has assigned moves.") auto_print_mrp_reception_report_labels = fields.Boolean( "Auto Print Allocation Report Labels", help="If this checkbox is ticked, Odoo will automatically print the allocation report labels of a MO when it is done.") diff --git a/addons/mrp/views/stock_picking_views.xml b/addons/mrp/views/stock_picking_views.xml index b2eb8bc80ab..3985a8fe982 100644 --- a/addons/mrp/views/stock_picking_views.xml +++ b/addons/mrp/views/stock_picking_views.xml @@ -155,6 +155,7 @@