[IMP] mrp: auto-print MO product labels
Add in feature to allow auto-printing of product labels when MO is done. Part of task: 3046178 - MRP behavior auto-printing Part-of: odoo/odoo#126791
This commit is contained in:
@@ -2625,4 +2625,16 @@ class MrpProduction(models.Model):
|
||||
action = self.env.ref("mrp.action_report_production_order").report_action(productions_to_print.ids, config=False)
|
||||
clean_action(action, self.env)
|
||||
report_actions.append(action)
|
||||
productions_to_print = self.filtered(lambda p: p.picking_type_id.auto_print_done_mrp_product_labels)
|
||||
productions_by_print_formats = productions_to_print.grouped(lambda p: p.picking_type_id.mrp_product_label_to_print)
|
||||
for print_format in productions_to_print.picking_type_id.mapped('mrp_product_label_to_print'):
|
||||
labels_to_print = productions_by_print_formats.get(print_format)
|
||||
if print_format == 'pdf':
|
||||
action = self.env.ref("mrp.action_report_finished_product").report_action(labels_to_print.ids, config=False)
|
||||
clean_action(action, self.env)
|
||||
report_actions.append(action)
|
||||
elif print_format == 'zpl':
|
||||
action = self.env.ref("mrp.label_manufacture_template").report_action(labels_to_print.ids, config=False)
|
||||
clean_action(action, self.env)
|
||||
report_actions.append(action)
|
||||
return report_actions
|
||||
|
||||
@@ -29,6 +29,12 @@ class StockPickingType(models.Model):
|
||||
auto_print_done_production_order = fields.Boolean(
|
||||
"Auto Print Done Production Order",
|
||||
help="If this checkbox is ticked, Odoo will automatically print the production order of a MO when it is done.")
|
||||
auto_print_done_mrp_product_labels = fields.Boolean(
|
||||
"Auto Print Produced Product Labels",
|
||||
help="If this checkbox is ticked, Odoo will automatically print the product labels of a MO when it is done.")
|
||||
mrp_product_label_to_print = fields.Selection(
|
||||
[('pdf', 'PDF'), ('zpl', 'ZPL')],
|
||||
"Product Label to Print", default='pdf')
|
||||
|
||||
@api.depends('code')
|
||||
def _compute_use_create_lots(self):
|
||||
|
||||
@@ -143,6 +143,12 @@
|
||||
<group>
|
||||
<group string="Print when done">
|
||||
<field name="auto_print_done_production_order" string="Production Order"/>
|
||||
<label for="auto_print_done_mrp_product_labels" string="Product Labels"/>
|
||||
<div class="o_row">
|
||||
<field name="auto_print_done_mrp_product_labels" string="Product Labels"/>
|
||||
<label for="mrp_product_label_to_print" string="Print labels as:" invisible="not auto_print_done_mrp_product_labels" class="fw-bold"/>
|
||||
<field name="mrp_product_label_to_print" invisible="not auto_print_done_mrp_product_labels"/>
|
||||
</div>
|
||||
</group>
|
||||
<group string="">
|
||||
<div colspan="2">
|
||||
|
||||
Reference in New Issue
Block a user