summaryrefslogtreecommitdiff
path: root/indoteknik_api/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-03-24 15:54:47 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-03-24 15:54:47 +0700
commit8787033026f974b0664e8fe24c87f1db480f7959 (patch)
tree12750028c77fc7b365b078f1a575c751cea1adc3 /indoteknik_api/models
parent05c2c86f0f82ab42f9eb23b0aaaf838eb52da435 (diff)
parenta9fd6502729bbd337c0ba762d2cc88fcd8f60900 (diff)
Merge branch 'floating-price-website' into release
Diffstat (limited to 'indoteknik_api/models')
-rw-r--r--indoteknik_api/models/product_product.py66
1 files changed, 65 insertions, 1 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py
index 2e84b9f4..f83ede27 100644
--- a/indoteknik_api/models/product_product.py
+++ b/indoteknik_api/models/product_product.py
@@ -1,4 +1,5 @@
from odoo import models
+import math
class ProductProduct(models.Model):
@@ -34,4 +35,67 @@ class ProductProduct(models.Model):
'image_promotion_1': self.env['ir.attachment'].api_image('x_manufactures', 'image_promotion_1', manufacture.id),
'image_promotion_2': self.env['ir.attachment'].api_image('x_manufactures', 'image_promotion_2', manufacture.id),
}
- return {} \ No newline at end of file
+ return {}
+
+ def _get_website_price_include_tax(self):
+ default_pricelist_id = int(1)
+
+ query = [
+ ('pricelist_id.id', '=', default_pricelist_id),
+ ('product_id.id', '=', self.id)
+ ]
+ pl_item1 = self.env['product.pricelist.item'].search(query, limit=1)
+
+ retValue = pl_item1.fixed_price
+ retValue = math.floor(retValue)
+ return retValue
+
+ def _get_website_price_exclude_tax(self):
+ default_divide_tax = float(1.11)
+ price_incl = self._get_website_price_include_tax()
+ res = price_incl / default_divide_tax
+ return math.floor(res)
+
+ def _get_website_disc(self, partner_id):
+ default_discount_id = int(4)
+
+ # compile partner
+ partner = self.env['res.partner'].search([('id', '=', partner_id)], limit=1)
+
+ if partner:
+ if not partner.parent_id: # it means this is a parent
+ default_discount_id = partner.custom_pricelist_id
+ else: # it means this is NOT parent
+ default_discount_id = partner.parent_id.custom_pricelist_id
+ query = [
+ ('pricelist_id.id', '=', default_discount_id),
+ ('product_id.id', '=', self.id)
+ ]
+
+ pl_item2 = self.env['product.pricelist.item'].search(query, limit=1)
+
+ retValue = pl_item2.price_discount
+ return retValue
+
+ def _get_website_price_after_disc_and_tax(self):
+ default_divide_tax = float(1.11)
+ price_after_disc = self._get_website_price_after_disc()
+ res = price_after_disc / default_divide_tax
+ res = math.floor(res)
+ return res
+
+ def _get_website_price_after_disc(self):
+ discount = self._get_website_disc(0)
+ price_incl = self._get_website_price_include_tax()
+ res = 0
+ if discount > 0:
+ res = price_incl - (price_incl * discount / 100)
+ else:
+ res = price_incl
+ return math.floor(res)
+
+ def _get_website_tax(self):
+ default_percent_tax = float(11)
+ price_after_disc = self._get_website_price_after_disc_and_tax()
+ res = price_after_disc * default_percent_tax / 100
+ return math.floor(res)