From 4879da9ee50169812e0a16bd72cc107726f92885 Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Thu, 6 Jan 2022 13:25:58 +0000 Subject: [PATCH] [IMP] stock{_picking_batch}: print sn/lots from picking Before this commit we could print the product labels of a picking from a picking, but we couldn't print only the lots/sns. This commit adds in this ability. Because we want to be flexible with this label printing (i.e. have the option to choose between printing zpl or pdf + 1 per unit or per lot/sn), we include it in the general "Print Labels" button with additional wizards. Note that we assume: 1. If there are no lot_ids in the picking => default to only product labels wizard (i.e. this also means if a picking that only creates New Lots/SN, lots/sns will not be printable until picking is validated.) 2. Lots/SN PDF labels will only be in the 4x12 label format 3. Batch pickings can also print lot/sn labels Part of task: 2494740 Related ENT PR: odoo/enterprise#23323 closes odoo/odoo#82389 Related: odoo/upgrade#3202 Signed-off-by: Arnold Moyaux --- addons/stock/__manifest__.py | 2 + addons/stock/models/stock_picking.py | 13 ++++++ addons/stock/security/ir.model.access.csv | 2 + addons/stock/views/stock_picking_views.xml | 2 +- addons/stock/wizard/__init__.py | 2 + addons/stock/wizard/stock_label_type.py | 27 ++++++++++++ addons/stock/wizard/stock_label_type.xml | 20 +++++++++ addons/stock/wizard/stock_lot_label_layout.py | 42 +++++++++++++++++++ .../stock/wizard/stock_lot_label_layout.xml | 21 ++++++++++ .../models/stock_picking_batch.py | 10 +++++ 10 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 addons/stock/wizard/stock_label_type.py create mode 100644 addons/stock/wizard/stock_label_type.xml create mode 100644 addons/stock/wizard/stock_lot_label_layout.py create mode 100644 addons/stock/wizard/stock_lot_label_layout.xml diff --git a/addons/stock/__manifest__.py b/addons/stock/__manifest__.py index a5d8b3ff751..ca9d20b5306 100644 --- a/addons/stock/__manifest__.py +++ b/addons/stock/__manifest__.py @@ -65,6 +65,8 @@ 'wizard/stock_package_destination_views.xml', 'wizard/stock_inventory_adjustment_name.xml', 'wizard/stock_inventory_warning.xml', + 'wizard/stock_label_type.xml', + 'wizard/stock_lot_label_layout.xml', 'views/res_partner_views.xml', 'views/product_strategy_views.xml', diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 589792f7b2b..9ac69b8f43d 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -1496,6 +1496,19 @@ class Picking(models.Model): 'default_picking_quantity': 'picking'}, } + def action_open_label_type(self): + if self.user_has_groups('stock.group_production_lot') and self.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.ids}, + } + return self.action_open_label_layout() + def _attach_sign(self): """ Render the delivery report in pdf and attach it to the picking in `self`. """ self.ensure_one() diff --git a/addons/stock/security/ir.model.access.csv b/addons/stock/security/ir.model.access.csv index 5368089451a..98178bcf2ca 100644 --- a/addons/stock/security/ir.model.access.csv +++ b/addons/stock/security/ir.model.access.csv @@ -88,3 +88,5 @@ access_stock_inventory_warning,stock.inventory.warning,model_stock_inventory_war access_stock_inventory_adjustment_name,stock.inventory.adjustment.name,model_stock_inventory_adjustment_name,stock.group_stock_manager,1,1,1,0 access_stock_request_count,stock.request.count,model_stock_request_count,stock.group_stock_manager,1,1,1,0 access_stock_replenishment_info,stock.replenishment.info,model_stock_replenishment_info,stock.group_stock_manager,1,1,1,0 +access_stock_picking_label_type_user,picking.label.type.user,model_picking_label_type,stock.group_stock_user,1,1,1,0 +access_stock_lot_label_layout_user,lot.label.layout.user,model_lot_label_layout,stock.group_stock_user,1,1,1,0 diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index 99b02f1b2da..ef53efd6fec 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -253,7 +253,7 @@ attrs="{'invisible': ['|', '|', ('id', '=', False), ('picking_type_code', '!=', 'outgoing'), ('state', '=', 'done')]}" full_name="partner_id" groups="stock.group_stock_sign_delivery"/>