summaryrefslogtreecommitdiff
path: root/indoteknik_custom
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 /indoteknik_custom
parentce74fd588cb8bf7cca770e0ac9717321e6b70ebe (diff)
cr website user cart add price, phone and promotion product
Diffstat (limited to 'indoteknik_custom')
-rw-r--r--indoteknik_custom/models/website_user_cart.py22
-rwxr-xr-xindoteknik_custom/views/website_user_cart.xml6
2 files changed, 27 insertions, 1 deletions
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>