[FIX] sale_loyalty: find sequence of a non-iterable

Steps to reproduce:
- go to e-commerce;
- add a product to the cart;
- add a gift card;
- remove the product from the cart.

Issue:
A traceback appears.

Cause:
We are trying to find the maximum of a non-iterable object.

Introduced by 7004b17ee5433e3b14561358348b42326f549261

opw-3114090

closes odoo/odoo#109635

X-original-commit: ae074117db7e7da1ba36a9151fae12bc16fb15ed
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
Thomas Lefebvre (thle)
2023-01-11 14:31:06 +01:00
parent 4ca947c092
commit a77f644fd2
+1 -1
View File
@@ -146,7 +146,7 @@ class SaleOrder(models.Model):
'points_cost': cost,
'reward_identifier_code': _generate_random_reward_code(),
'product_uom': product.uom_id.id,
'sequence': max(self.order_line.filtered(lambda x: not x.is_reward_line).mapped('sequence')) + 1,
'sequence': max(self.order_line.filtered(lambda x: not x.is_reward_line).mapped('sequence'), default=10) + 1,
'tax_id': [(Command.CLEAR, 0, 0)] + [(Command.LINK, tax.id, False) for tax in taxes]
}]