[IMP] mrp: auto-print MO reception report
Add in feature to auto-print reception (allocation) report when the MO is done. Note that only MOs with an allocation will be printed otherwise the form will only have the MO name/barcode and nothing else in it (i.e. not very useful). Part of task: 3046178 - general auto-print goal closes odoo/odoo#126791 Related: odoo/enterprise#43362 Related: odoo/upgrade#5298 Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.")
|
||||
|
||||
@@ -155,6 +155,7 @@
|
||||
<label for="done_mrp_lot_label_to_print" string="Print labels as:" invisible="not auto_print_done_mrp_lot" class="fw-bold"/>
|
||||
<field name="done_mrp_lot_label_to_print" invisible="not auto_print_done_mrp_lot"/>
|
||||
</div>
|
||||
<field name="auto_print_mrp_reception_report" string="Allocation Report" groups="mrp.group_mrp_reception_report"/>
|
||||
<field name="auto_print_mrp_reception_report_labels" string="Allocation Report Labels" groups="mrp.group_mrp_reception_report"/>
|
||||
</group>
|
||||
<group string="">
|
||||
|
||||
Reference in New Issue
Block a user