summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-10-01 11:36:09 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-10-01 11:36:09 +0700
commiteeea51a3ba88623437774b3c568d78c487f7ca5d (patch)
tree771b2d959d68b49b9476349e5c1e87a46c32b3f7
parentce74fd588cb8bf7cca770e0ac9717321e6b70ebe (diff)
cr website user cart add price, phone and promotion product
-rw-r--r--indoteknik_api/models/product_product.py5
-rw-r--r--indoteknik_custom/models/website_user_cart.py22
-rwxr-xr-xindoteknik_custom/views/website_user_cart.xml6
3 files changed, 30 insertions, 3 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py
index 386ddb6a..9a602357 100644
--- a/indoteknik_api/models/product_product.py
+++ b/indoteknik_api/models/product_product.py
@@ -62,8 +62,9 @@ class ProductProduct(models.Model):
pricelist = pricelist or self.env.context.get('user_pricelist')
default_price_tier = '1_v2'
- price_tier = pricelist.get_tier_level()
- price_tier = price_tier if price_tier else default_price_tier
+ price_tier = default_price_tier
+ if pricelist:
+ price_tier = pricelist.get_tier_level()
pricelist = self._get_pricelist_tier(price_tier)
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:
diff --git a/indoteknik_custom/views/website_user_cart.xml b/indoteknik_custom/views/website_user_cart.xml
index 11573121..335c6fc6 100755
--- a/indoteknik_custom/views/website_user_cart.xml
+++ b/indoteknik_custom/views/website_user_cart.xml
@@ -18,6 +18,9 @@
<field name="is_selected"/>
<field name="is_reminder"/>
<field name="source"/>
+ <field name="phone_user"/>
+ <field name="price"/>
+ <field name="program_product_id" optional="hide"/>
</tree>
</field>
</record>
@@ -37,6 +40,9 @@
<field name="is_selected" />
<field name="is_reminder" />
<field name="source" />
+ <field name="phone_user"/>
+ <field name="program_product_id"/>
+ <field name="price"/>
</group>
<group></group>
</group>