Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

stock.picking weight confusion

By
Mathieu Laflamme
on 1/28/16, 5:13 PM 527 views

With delivery module, two new fields were added for weight to stock.picking: weight and weight_bulk.

weight = fields.Float(compute='_cal_weight', digits=dp.get_precision('Stock Weight'), store=True)
weight_bulk = fields.Float('Bulk Weight', compute='_compute_bulk_weight')

Here is how both are calculated:

@api.depends('product_id', 'move_lines')
def _cal_weight(self):
for picking in self:
picking.weight = sum(move.weight for move in picking.move_lines if move.state != 'cancel')


@api.one
@api.depends('pack_operation_ids')
def _compute_bulk_weight(self):
weight = 0.0
uom_obj = self.env['product.uom']
for packop in self.pack_operation_ids:
if packop.product_id and not packop.result_package_id:
weight += uom_obj._compute_qty_obj(packop.product_uom_id , packop.product_qty, packop.product_id.uom_id) * packop.product_id.weight
self.weight_bulk = weight

First there is issues with _cal_weight witch doesn't take care of the UoM at all. And after looking in the code from different carriers in the enterprise modules, I realized delivery_ups and delivery_dhl use weight_bulk but the other simply use the weight field.

Anyone making since of this?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/28/16, 5:13 PM
Seen: 527 times
Last updated: 1/28/16, 5:18 PM