[FIX] sale_coupon: performance issue with promotion programs
In case of large cart and promotion program with a discount reward of percentage type, we are rewriting the reward order lines multiple times while we can do all in one update. opw-2038791 closes odoo/enterprise#5086 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> X-port/Cherry-pick of odoo/enterprise@243e66663a
This commit is contained in:
committed by
Christophe Simonis
parent
20e69b3299
commit
60c438dfb7
@@ -305,14 +305,14 @@ class SaleOrder(models.Model):
|
||||
# Check commit 6bb42904a03 for next if/else
|
||||
# Remove reward line if price or qty equal to 0
|
||||
if values['product_uom_qty'] and values['price_unit']:
|
||||
order.write({'order_line': [(1, line.id, values) for line in lines]})
|
||||
lines.write(values)
|
||||
else:
|
||||
if program.reward_type != 'free_shipping':
|
||||
# Can't remove the lines directly as we might be in a recordset loop
|
||||
lines_to_remove += lines
|
||||
else:
|
||||
values.update(price_unit=0.0)
|
||||
order.write({'order_line': [(1, line.id, values) for line in lines]})
|
||||
lines.write(values)
|
||||
return lines_to_remove
|
||||
|
||||
self.ensure_one()
|
||||
|
||||
Reference in New Issue
Block a user