From eeea51a3ba88623437774b3c568d78c487f7ca5d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 1 Oct 2024 11:36:09 +0700 Subject: cr website user cart add price, phone and promotion product --- indoteknik_custom/models/website_user_cart.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/website_user_cart.py') diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index b0cf47f7..0e245748 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import fields, models, api from datetime import datetime, timedelta class WebsiteUserCart(models.Model): @@ -16,6 +16,26 @@ class WebsiteUserCart(models.Model): ], 'Source', default='add_to_cart') user_other_carts = fields.One2many('website.user.cart', 'id', 'Other Products', compute='_compute_user_other_carts') is_reminder = fields.Boolean(string='Reminder?') + phone_user = fields.Char(string='Phone', related='user_id.mobile') + price = fields.Float(string='Price', compute='_compute_price') + program_product_id = fields.Many2one('product.product', string='Program Products', compute='_compute_program_product_ids') + + @api.depends('program_line_id') + def _compute_program_product_ids(self): + for record in self: + if record.program_line_id and record.program_line_id.product_ids: + product = record.program_line_id.product_ids[0] + record.program_product_id = product.product_id + record.product_id = product.product_id + else: + # Handle case where there are no product_ids + record.program_product_id = False + + def _compute_price(self): + for record in self: + record.price = record.product_id.v2_api_single_response(record.product_id)['price']['price_discount'] + if record.program_line_id: + record.price = record.get_price_coret(record.program_line_id.id) def _compute_user_other_carts(self): for record in self: -- cgit v1.2.3 From 9da8f3d5b2bd966bf873d8d760b179ba41f26542 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 1 Oct 2024 14:59:28 +0700 Subject: fix bug user cart --- indoteknik_custom/models/website_user_cart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/website_user_cart.py') diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index 0e245748..169f4a6b 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -33,7 +33,7 @@ class WebsiteUserCart(models.Model): def _compute_price(self): for record in self: - record.price = record.product_id.v2_api_single_response(record.product_id)['price']['price_discount'] + record.price = record.get_price_website(record.product_id.id)['price'] if record.program_line_id: record.price = record.get_price_coret(record.program_line_id.id) -- cgit v1.2.3