From 1960ad26944768024fdce49dbc2d36e169307d4d Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Wed, 10 May 2017 09:41:05 +0200 Subject: [PATCH] [FIX] list -> iterable builtins Cf commit fffaf735f58f1ac57781c095eb552de6d1fcdc47 Closes #989 --- models/sale_coupon_program.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/models/sale_coupon_program.py b/models/sale_coupon_program.py index 0d565b48de3..c8a1c8ed646 100644 --- a/models/sale_coupon_program.py +++ b/models/sale_coupon_program.py @@ -3,6 +3,7 @@ from odoo import api, fields, models, _ from odoo.exceptions import UserError +from odoo.tools import pycompat class SaleCouponProgram(models.Model): @@ -198,7 +199,10 @@ class SaleCouponProgram(models.Model): products_qties[line.product_id.id] += line.product_uom_qty valid_programs = self.filtered(lambda program: not program.rule_product_ids) for program in self - valid_programs: - ordered_rule_products_qty = sum(map(lambda product_id, qty: product_id in program.rule_product_ids.ids and qty, products_qties, products_qties.values())) + ordered_rule_products_qty = sum( + qty for product, qty in pycompat.items(products_qties) + if product in program.rule_product_ids.ids + ) # Avoid program if 1 ordered foo on a program '1 foo, 1 free foo' if program.reward_product_id in program.rule_product_ids and program.reward_type == 'product': line = order.order_line.filtered(lambda line: line.product_id == program.reward_product_id)