[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:
Lucas Lefèvre
2019-07-12 09:05:54 +00:00
parent 20fb024a33
commit afa4c09129
+2 -1
View File
@@ -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: