diff options
| -rw-r--r-- | indoteknik_custom/models/website_user_cart.py | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index b4eba476..7143f4ef 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -188,19 +188,33 @@ class WebsiteUserCart(models.Model): return self.format_currency(0.0) def get_data_promo(self, program_line_id): - criteria = [('program_line_id', '=', program_line_id)] - return ( - self.env['promotion.product'].search(criteria), - self.env['promotion.free_product'].search(criteria) - ) - + program_line_product = self.env['promotion.product'].search([ + ('program_line_id', '=', program_line_id) + ]) + + program_free_product = self.env['promotion.free_product'].search([ + ('program_line_id', '=', program_line_id) + ]) + return program_line_product, program_free_product + def get_weight_product(self, program_line_id): - products = self.env['promotion.product'].search([('program_line_id', '=', program_line_id)]) - free_products = self.env['promotion.free_product'].search([('program_line_id', '=', program_line_id)]) + program_line_product = self.env['promotion.product'].search([ + ('program_line_id', '=', program_line_id) + ]) - all_products = products + free_products - real_weight = sum(product.product_id.weight for product in all_products) + program_free_product = self.env['promotion.free_product'].search([ + ('program_line_id', '=', program_line_id) + ]) + real_weight = 0.0 + if program_line_product: + for product in program_line_product: + real_weight += product.product_id.weight + + if program_free_product: + for product in program_free_product: + real_weight += product.product_id.weight + return real_weight def get_price_website(self, product_id): |
