summaryrefslogtreecommitdiff
path: root/addons/delivery/models
diff options
context:
space:
mode:
authorTiffany Chang (tic) <tic@odoo.com>2020-04-21 08:35:30 +0000
committerTiffany Chang (tic) <tic@odoo.com>2020-07-03 11:54:08 +0000
commitd20467bb6a2e1e6b07a2db86ee4be199eeeed0e2 (patch)
tree0ab13c8e22f640f52d8f8949fb3a88f1be326aef /addons/delivery/models
parent0accbd6e69937011ea9bac141dd186c3757b1a8a (diff)
[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
Diffstat (limited to 'addons/delivery/models')
-rw-r--r--addons/delivery/models/stock_picking.py8
1 files changed, 5 insertions, 3 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')