diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-07-26 15:51:34 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-07-26 15:51:34 +0700 |
| commit | e1c3b8cd1b4d90db4de42a5a58ba17b5f4d6c293 (patch) | |
| tree | e0a82a07f79588b061a433e9431604088a785cc4 | |
| parent | 525072694a3544d65a1075d6087600edbe173f18 (diff) | |
fix bug user cart
| -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): |
