[IMP] mrp: add print label button

task-3201527

Sub-task: 10
Part-of: odoo/odoo#127409
This commit is contained in:
Martin Maes
2023-10-26 13:41:01 +00:00
parent d811e1af5b
commit 86ec5b68c9
2 changed files with 29 additions and 0 deletions
+28
View File
@@ -2695,3 +2695,31 @@ class MrpProduction(models.Model):
action = self.env.ref("stock.label_lot_template").report_action(lot_id.id, config=False)
clean_action(action, self.env)
return action
def action_open_label_layout(self):
view = self.env.ref('stock.product_label_layout_form_picking')
return {
'name': _('Choose Labels Layout'),
'type': 'ir.actions.act_window',
'res_model': 'product.label.layout',
'views': [(view.id, 'form')],
'target': 'new',
'context': {
'default_product_ids': self.move_finished_ids.product_id.ids,
'default_move_ids': self.move_finished_ids.ids,
'default_picking_quantity': 'picking'},
}
def action_open_label_type(self):
move_line_ids = self.move_finished_ids.mapped('move_line_ids')
if self.user_has_groups('stock.group_production_lot') and move_line_ids.lot_id:
view = self.env.ref('stock.picking_label_type_form')
return {
'name': _('Choose Type of Labels To Print'),
'type': 'ir.actions.act_window',
'res_model': 'picking.label.type',
'views': [(view.id, 'form')],
'target': 'new',
'context': {'default_picking_ids': self.move_finished_ids},
}
return self.action_open_label_layout()
@@ -164,6 +164,7 @@
invisible="not id or state in ('done', 'cancel') or not confirm_cancel"
confirm="Some product moves have already been confirmed, this manufacturing order can't be completely cancelled. Are you still sure you want to process?"/>
<button name="button_unbuild" type="object" string="Unbuild" invisible="state != 'done'" data-hotkey="shift+v"/>
<button string="Print Labels" type="object" name="action_open_label_type"/>
</header>
<sheet>
<field name="reservation_state" invisible="1"/>