Hello
I did a module to convert some picking product weight into some other product sell by pound
everything work fine, I did had the same kind of field to the picking and the pack_operation (maple_weight)
so when someone add to a pack_op a pack_ops_lot, the total weight of the pack_op is transert as qty_done of an other product in the same picking. Everything work fine except qty on screen does get strange refresh.
The total weight of the picking and the pack_op update on screen after every change to pack_op_lot but the weight transfer to qty seam to show the previous state and not the last.
If I add a 415 pounds product, qty_done still show 0 and both total_weight show 415, if I add an other of 416 the both total show 831 and qty show 415. If I remove from the lot the 415, totals goes down to 416 and qty goes up to 831.
Looking at the database, the qty_done is always good.
there is the most important part of the code
@api.one
@api.depends('pack_lot_ids')
def _compute_pack_ops_weight(self):
weight = 0
if self.product_id.maple_container:
for lot in self.pack_lot_ids:
for quant in lot.lot_id.quant_ids:
weight += quant.maple_net_weight * lot.qty
if self.picking_id:
related_op = self.picking_id.pack_operation_ids.filtered(lambda r: r.product_id.default_code == self.product_id.default_code[1:] )
if not related_op:
# faut créée un pack ops
ops_val = {
'date' : self.date,
}
related_op.write({
'qty_done' : weight
})
related_op.save()
self.maple_weight= weight