[FIX] sale: Don't compare id and NewId
On runbot, edit SO131 and change the company => traceback An onchange is triggered (=> self.id is a NewId). But while recomputing the quantity delivered, a read_group is performed which gives real ids (int). The ids are then used to retrieve some so_lines in a dict where each key is an id (but actually NewId in onchange) of self. => the keys are NewIds but try to get the value with an (int) id => KeyError closes odoo/odoo#34818 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
@@ -1250,7 +1250,8 @@ class SaleOrderLine(models.Model):
|
||||
|
||||
# convert uom and sum all unit_amount of analytic lines to get the delivered qty of SO lines
|
||||
# browse so lines and product uoms here to make them share the same prefetch
|
||||
lines_map = {line.id: line for line in self}
|
||||
lines = self.browse([item['so_line'][0] for item in data])
|
||||
lines_map = {line.id: line for line in lines}
|
||||
product_uom_ids = [item['product_uom_id'][0] for item in data if item['product_uom_id']]
|
||||
product_uom_map = {uom.id: uom for uom in self.env['uom.uom'].browse(product_uom_ids)}
|
||||
for item in data:
|
||||
|
||||
Reference in New Issue
Block a user