summaryrefslogtreecommitdiff
path: root/indoteknik_custom
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom')
-rw-r--r--indoteknik_custom/models/promotion_program_line.py12
-rw-r--r--indoteknik_custom/models/website_user_cart.py14
2 files changed, 19 insertions, 7 deletions
diff --git a/indoteknik_custom/models/promotion_program_line.py b/indoteknik_custom/models/promotion_program_line.py
index c888f01a..55331aea 100644
--- a/indoteknik_custom/models/promotion_program_line.py
+++ b/indoteknik_custom/models/promotion_program_line.py
@@ -126,9 +126,9 @@ class PromotionProgramLine(models.Model):
'label': dict(self._fields['promotion_type'].selection).get(self.promotion_type)
}
- def format(self, user = None, pricelist = False):
+ def format(self, user = None):
ir_attachment = self.env['ir.attachment']
- product_price = self.product_id.calculate_website_price(pricelist=pricelist)
+ product_price = self.product_id.calculate_website_price()
return {
'id': self.id,
'name': self.name,
@@ -142,7 +142,11 @@ class PromotionProgramLine(models.Model):
'price': self.calculate_price(price=product_price)
}
- def res_format(self, user, pricelist):
- data = [x.format(user, pricelist=pricelist) for x in self]
+ def res_format(self, user):
+ data = [x.format(user) for x in self]
+ return data
+
+ def res_format_cart(self, user):
+ data = self.format(user)
return data
diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py
index dcd9fa5a..388151ab 100644
--- a/indoteknik_custom/models/website_user_cart.py
+++ b/indoteknik_custom/models/website_user_cart.py
@@ -12,12 +12,22 @@ class WebsiteUserCart(models.Model):
is_selected = fields.Boolean(string='Selected?', digits='Is selected to process checkout')
def get_product(self):
+ user_data = {
+ 'partner_id': self.user_id.partner_id.id,
+ 'user_id': self.user_id.id
+ }
product_product = self.env['product.product']
product = product_product.v2_api_single_response(self.product_id)
product['quantity'] = self.qty
product['subtotal'] = self.qty * product['price']['price_discount']
product['selected'] = self.is_selected
+ product['program'] = None
+ if self.program_line_id:
+ product['program'] = self.program_line_id.res_format_cart(user_data)
return product
+
+ def get_products(self):
+ return [x.get_product() for x in self]
def get_product_by_user(self, user_id, selected = False):
user_id = int(user_id)
@@ -25,7 +35,5 @@ class WebsiteUserCart(models.Model):
if selected:
parameters.append(('is_selected', '=', True))
carts = self.search(parameters)
- products = []
- for cart in carts:
- products.append(cart.get_product())
+ products = carts.get_products()
return products \ No newline at end of file