summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-09-25 16:14:58 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-09-25 16:14:58 +0700
commitce4715289f52a5a1b39fdecc8bda40fbf88308a9 (patch)
treed66ac9281c6ba83de391cc5972f0f1e1b06293b8
parent6c7c80b9cf3f4146af1fcfc4c9b24881a7b29b3c (diff)
program line cr
-rw-r--r--indoteknik_custom/models/promotion/promotion_program_line.py17
-rw-r--r--indoteknik_custom/views/promotion/promotion_program_line.xml2
2 files changed, 10 insertions, 9 deletions
diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py
index 903e95cf..7a15ad11 100644
--- a/indoteknik_custom/models/promotion/promotion_program_line.py
+++ b/indoteknik_custom/models/promotion/promotion_program_line.py
@@ -41,22 +41,23 @@ class PromotionProgramLine(models.Model):
price_tier_5 = fields.Float('Price Tier 5')
def get_price_tier(self, product_id, qty):
- product = self.env['product.product'].browse(product_id.id) # Get the product record
+ product = self.env['product.product'].browse(product_id.id)
tiers = ['1_v2', '2_v2', '3_v2', '4_v2', '5_v2']
- for index, tier in enumerate(tiers, start=1): # Automatically count from 1 to 5
- # Call the function _get_pricelist_tier from product.product model
+ for index, tier in enumerate(tiers, start=1):
+
price_tier_data = product._get_pricelist_tier(tier)
- # Use the index as the tier number (1, 2, 3, etc.)
- price_field = f'price_tier_{index}' # 'price_tier_1', 'price_tier_2', etc.
+ price_field = f'price_tier_{index}'
- # Update the corresponding price_tier_X field
- if price_field in self._fields: # Ensure the field exists in the model
- price = price_tier_data.get(f'price_tier{tier}', 0) * qty # Multiply by qty
+ if price_field in self._fields:
+ price = price_tier_data.get(f'price_tier{tier}', 0) * qty
self[price_field] = price
+ if index == 1:
+ self.price = price
+
def get_active_promotions(self, product_id):
current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
return self.search([
diff --git a/indoteknik_custom/views/promotion/promotion_program_line.xml b/indoteknik_custom/views/promotion/promotion_program_line.xml
index b4dd2254..9cda67a8 100644
--- a/indoteknik_custom/views/promotion/promotion_program_line.xml
+++ b/indoteknik_custom/views/promotion/promotion_program_line.xml
@@ -32,7 +32,7 @@
<field name="package_limit_user" />
<field name="package_limit_trx" />
<field name="price" attrs="{'invisible': [('promotion_type', '=', 'special_price')]}" />
- <field name="price_tier_1" invisible="1"/>
+ <field name="price_tier_1"/>
<field name="price_tier_2" invisible="1"/>
<field name="price_tier_3" invisible="1"/>
<field name="price_tier_4" invisible="1"/>