From d20467bb6a2e1e6b07a2db86ee4be199eeeed0e2 Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Tue, 21 Apr 2020 08:35:30 +0000 Subject: [PATCH] [IMP] delivery, stock: group delivery slip packages This commit makes it so if a delivery slip contains 1 or more packages then move lines will be split by package (and non-package) groups with a "section line" between them. This only applies to when a stock.picking is 'State=Done'. In order to accomodate complexity of splitting by package + grouping by product unless printing serial numbers/lots + template inheritance, reoccurring parts of the template are split into their own templates and called. Relevant inheritance has been updated to match. Additionally, picking.shipping_weight calculation has been updated so if a pack.weight = 0 then calculation will default to the calculated product weight. This prevents inconsistency between the "Total Weight" at the top of the Delivery Slip and the package sections' displayed weights. To distinguish which value is being used, package sections that use the total product weight rather than the pack.weight have "(estimated)" after it. This completes subsection 3 of overall Improve delivery slip task. Task: 2039720 --- addons/delivery/models/stock_picking.py | 8 +- addons/delivery/views/report_deliveryslip.xml | 46 +++++- addons/stock/report/report_deliveryslip.xml | 131 +++++++++++++----- 3 files changed, 142 insertions(+), 43 deletions(-) diff --git a/addons/delivery/models/stock_picking.py b/addons/delivery/models/stock_picking.py index d4c90d77d55..20ad15160f2 100644 --- a/addons/delivery/models/stock_picking.py +++ b/addons/delivery/models/stock_picking.py @@ -66,7 +66,8 @@ class StockPicking(models.Model): @api.depends('move_line_ids.result_package_id', 'move_line_ids.result_package_id.shipping_weight', 'weight_bulk') def _compute_shipping_weight(self): for picking in self: - picking.shipping_weight = picking.weight_bulk + sum([pack.shipping_weight for pack in picking.package_ids]) + # if shipping weight is not assigned => default to calculated product weight + picking.shipping_weight = picking.weight_bulk + sum([pack.shipping_weight or pack.weight for pack in picking.package_ids]) def _get_default_weight_uom(self): return self.env['product.template']._get_weight_uom_name_from_ir_config_parameter() @@ -83,8 +84,9 @@ class StockPicking(models.Model): carrier_tracking_url = fields.Char(string='Tracking URL', compute='_compute_carrier_tracking_url') weight_uom_name = fields.Char(string='Weight unit of measure label', compute='_compute_weight_uom_name', readonly=True, default=_get_default_weight_uom) package_ids = fields.Many2many('stock.quant.package', compute='_compute_packages', string='Packages') - weight_bulk = fields.Float('Bulk Weight', compute='_compute_bulk_weight') - shipping_weight = fields.Float("Weight for Shipping", compute='_compute_shipping_weight', help="Total weight of the packages and products which are not in a package. That's the weight used to compute the cost of the shipping.") + weight_bulk = fields.Float('Bulk Weight', compute='_compute_bulk_weight', help="Total weight of products which are not in a package.") + shipping_weight = fields.Float("Weight for Shipping", compute='_compute_shipping_weight', + help="Total weight of packages and products not in a package. Packages with no shipping weight specified will default to their products' total weight. This is the weight used to compute the cost of the shipping.") is_return_picking = fields.Boolean(compute='_compute_return_picking') return_label_ids = fields.One2many('ir.attachment', compute='_compute_return_label') diff --git a/addons/delivery/views/report_deliveryslip.xml b/addons/delivery/views/report_deliveryslip.xml index 0da77776e76..4bf0057dd3b 100644 --- a/addons/delivery/views/report_deliveryslip.xml +++ b/addons/delivery/views/report_deliveryslip.xml @@ -6,7 +6,7 @@

- Weight: + Total Weight:
@@ -22,19 +22,51 @@ HS Code - - - - HS Code - + + + + + + + + diff --git a/addons/stock/report/report_deliveryslip.xml b/addons/stock/report/report_deliveryslip.xml index 598360e51a9..09d0e66674c 100644 --- a/addons/stock/report/report_deliveryslip.xml +++ b/addons/stock/report/report_deliveryslip.xml @@ -1,6 +1,5 @@ - + + + + + + + + + -