summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/website_user_cart.py
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-10-02 10:40:24 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-10-02 10:40:24 +0700
commit705f51eed8a817fe6ea3ef514402786d25f7c356 (patch)
treeb756a2ed1a1ef106739e935ce0ac47df12df473a /indoteknik_custom/models/website_user_cart.py
parent37ee561ff633776ef984d4d9e441981aecbca762 (diff)
parent1754a77d402af8c9fccb896e0b0745eb6e591c0b (diff)
Merge branch 'production' into iman/switch-account
Diffstat (limited to 'indoteknik_custom/models/website_user_cart.py')
-rw-r--r--indoteknik_custom/models/website_user_cart.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py
index b0cf47f7..169f4a6b 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.get_price_website(record.product_id.id)['price']
+ 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: