[FIX] delivery: weight computation without quant
The weight computation was not working anymore on packages that don't have any quant, because they are fresh ones. We fix this by setting back the behaviour with the picking id in context and adapt the function to find the corresponding move lines. closes odoo/odoo#30071
This commit is contained in:
@@ -16,8 +16,13 @@ class StockQuantPackage(models.Model):
|
||||
@api.depends('quant_ids')
|
||||
def _compute_weight(self):
|
||||
weight = 0.0
|
||||
for quant in self.quant_ids:
|
||||
weight += quant.quantity * quant.product_id.weight
|
||||
if self.env.context.get('picking_id'):
|
||||
current_picking_move_line_ids = self.env['stock.move.line'].search([('result_package_id', '=', self.id), ('picking_id', '=', self.env.context['picking_id'])])
|
||||
for ml in current_picking_move_line_ids:
|
||||
weight += ml.product_uom_id._compute_quantity(ml.qty_done,ml.product_id.uom_id) * ml.product_id.weight
|
||||
else:
|
||||
for quant in self.quant_ids:
|
||||
weight += quant.quantity * quant.product_id.weight
|
||||
self.weight = weight
|
||||
|
||||
weight = fields.Float(compute='_compute_weight', help="Weight computed based on the sum of the weights of the products.")
|
||||
|
||||
Reference in New Issue
Block a user