diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-10-06 14:22:12 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-10-06 14:22:12 +0700 |
| commit | 5f9c6e2837c8201ca8132f3d3d71627bf799fb6d (patch) | |
| tree | df2b9d4d0b52a6cf8d45d153dff977e04785abb2 /indoteknik_custom | |
| parent | bb3c3c6cac4382220ae8a521e8c2162a5fe3d3e9 (diff) | |
| parent | 7a23a18a45fbd38fabc33f4e1a74d9f31e86cd60 (diff) | |
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
Diffstat (limited to 'indoteknik_custom')
| -rw-r--r-- | indoteknik_custom/models/product_pricelist.py | 26 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 10 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_product.py | 4 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 4 | ||||
| -rw-r--r-- | indoteknik_custom/models/voucher.py | 6 | ||||
| -rwxr-xr-x | indoteknik_custom/views/voucher.xml | 2 |
6 files changed, 28 insertions, 24 deletions
diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py index 026977f8..b7a6d77e 100644 --- a/indoteknik_custom/models/product_pricelist.py +++ b/indoteknik_custom/models/product_pricelist.py @@ -24,21 +24,25 @@ class ProductPricelist(models.Model): remaining_time = round(remaining_time) return max(remaining_time, 0) - def get_tier_name(self): + def get_tier_level(self): config = self.env['ir.config_parameter'] - product_pricelist_tier1 = int(config.get_param('product.pricelist.tier1', 0)) - product_pricelist_tier2 = int(config.get_param('product.pricelist.tier2', 0)) - product_pricelist_tier3 = int(config.get_param('product.pricelist.tier3', 0)) + tier_keys = ['1', '2', '3', '1_v2', '2_v2', '3_v2', '4_v2', '5_v2'] + + for tier in tier_keys: + tier_id = config.get_param('product.pricelist.tier' + tier, 0) + if self.id == int(tier_id): + return tier - price_tier = None - if self.id == product_pricelist_tier1: price_tier = 'tier1' - if self.id == product_pricelist_tier2: price_tier = 'tier2' - if self.id == product_pricelist_tier3: price_tier = 'tier3' - return price_tier + return None + + def get_tier_name(self): + tier_level = self.get_tier_level() + tier_name = f'tier{tier_level}' if tier_level else None + + return tier_name class ProductPricelistItem(models.Model): _inherit = 'product.pricelist.item' manufacture_id = fields.Many2one('x_manufactures', string='Manufacture') - -
\ No newline at end of file + computed_price = fields.Float(string='Computed Price')
\ No newline at end of file diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 93c63d56..9324930e 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -423,8 +423,8 @@ class SaleOrder(models.Model): order.grand_total = order.amount_total def action_apply_voucher(self): - for order in self.order_line: - if order.program_line_id: + for line in self.order_line: + if line.order_promotion_id: raise UserError('Voucher tidak dapat digabung dengan promotion program') voucher = self.voucher_id @@ -474,8 +474,10 @@ class SaleOrder(models.Model): line_contribution = line.price_subtotal / used_total line_voucher = used_discount * line_contribution line_voucher_item = line_voucher / line.product_uom_qty - line_discount_item = line.price_unit * line.discount / 100 + line_voucher_item - line_voucher_item = line_discount_item / line.price_unit * 100 + + line_price_unit = line.price_unit / 1.11 if any(tax.id == 23 for tax in line.tax_id) else line.price_unit + line_discount_item = line_price_unit * line.discount / 100 + line_voucher_item + line_voucher_item = line_discount_item / line_price_unit * 100 line.amount_voucher_disc = line_voucher line.discount = line_voucher_item diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 16135e5e..31a0026d 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -84,7 +84,7 @@ class ProductProduct(models.Model): price_excl_after_disc = variant._get_website_price_after_disc_and_tax() tax = variant._get_website_tax() discount = variant._get_website_disc(0) - flashsale_data = variant._get_flashsale_price() + flashsale_data = variant.with_context(price_for="web")._get_flashsale_price() price_excl_v2 = variant._v2_get_website_price_exclude_tax() price_excl_after_disc_v2 = variant._v2_get_website_price_after_disc_and_tax() @@ -134,7 +134,7 @@ class ProductProduct(models.Model): def solr_results(self): solr_model = self.env['apache.solr'] - pricelist = self.env.user_pricelist + pricelist = self.env.context.get('user_pricelist') price_tier = pricelist.get_tier_name() results = [] diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index e39530a7..d7439bcb 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -103,7 +103,7 @@ class ProductTemplate(models.Model): tier_data = {} for variant in template.product_variant_ids: - variant_flashsale = variant._get_flashsale_price() + variant_flashsale = variant.with_context(price_for="web")._get_flashsale_price() variant_flashsale_price = variant_flashsale.get('flashsale_price', 0) flashsale_data_price = flashsale_data.get('flashsale_price', 0) @@ -157,7 +157,7 @@ class ProductTemplate(models.Model): def solr_results(self, detail=False): solr_model = self.env['apache.solr'] - pricelist = self.env.user_pricelist + pricelist = self.env.context.get('user_pricelist') price_tier = pricelist.get_tier_name() results = [] diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 8486fca0..a40f8c42 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -1,7 +1,6 @@ from odoo import models, fields, api from datetime import datetime, timedelta from odoo.exceptions import ValidationError -import locale class Voucher(models.Model): @@ -229,9 +228,8 @@ class Voucher(models.Model): def generate_detail_tnc(self): def format_currency(amount): - locale.setlocale(locale.LC_ALL, 'id_ID') - formatted_amount = locale.format("%d", amount, grouping=True) - return f'Rp{formatted_amount}' + formatted_number = '{:,.0f}'.format(amount).replace(',', '.') + return f'Rp{formatted_number}' tnc = [] if self.apply_type == 'all': diff --git a/indoteknik_custom/views/voucher.xml b/indoteknik_custom/views/voucher.xml index a2f5557a..b8489942 100755 --- a/indoteknik_custom/views/voucher.xml +++ b/indoteknik_custom/views/voucher.xml @@ -35,7 +35,7 @@ <field name="limit" required="1"/> <field name="limit_user" required="1"/> <field name="apply_type" required="1" /> - <field name="excl_pricelist_ids" widget="many2many_tags" domain="[('id', 'in', [4, 15037, 15038, 15039])]"/> + <field name="excl_pricelist_ids" widget="many2many_tags" domain="[('id', 'in', [4, 15037, 15038, 15039, 17023, 17024, 17025, 17026,17027])]"/> </group> <group string="Discount Settings" attrs="{'invisible': [('apply_type', '!=', 'all')]}"> <field name="min_purchase_amount" widget="monetary" required="1" /> |
