From 972a7b1e6a4d0ec33f183b7a194f1592fb3c3031 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 3 Oct 2023 11:52:59 +0700 Subject: Update get product price for website --- indoteknik_custom/models/product_pricelist.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py index 026977f8..384d1353 100644 --- a/indoteknik_custom/models/product_pricelist.py +++ b/indoteknik_custom/models/product_pricelist.py @@ -24,17 +24,22 @@ 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' -- cgit v1.2.3 From b2c16c315455f5f1f7cc60c474435c6b9e965e40 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 4 Oct 2023 13:56:18 +0700 Subject: Remove locale for currency format --- indoteknik_custom/models/voucher.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom') 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': -- cgit v1.2.3 From c452ac57ec1266452d04bbf4c38191aaa6630186 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 5 Oct 2023 10:07:40 +0700 Subject: Add price context for get product price API --- indoteknik_custom/models/solr/product_product.py | 2 +- indoteknik_custom/models/solr/product_template.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 16135e5e..20a68b47 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -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..30c3b3c5 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -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 = [] -- cgit v1.2.3 From 5614f5f0fa0322089f17feeeeeb56af93bf76670 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 5 Oct 2023 11:08:16 +0700 Subject: mandatory email --- indoteknik_custom/models/sale_order.py | 8 +++++--- indoteknik_custom/views/sale_order.xml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index e201496a..93c63d56 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -392,9 +392,11 @@ class SaleOrder(models.Model): def _set_sppkp_npwp_contact(self): partner = self.partner_id.parent_id or self.partner_id - partner.customer_type = self.customer_type - partner.npwp = self.npwp - partner.sppkp = self.sppkp + if not partner.sppkp or not partner.npwp or not partner.email or partner.customer_type: + partner.customer_type = self.customer_type + partner.npwp = self.npwp + partner.sppkp = self.sppkp + partner.email = self.email def _compute_total_margin(self): for order in self: diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 0d972ec1..e0e9ac54 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -48,7 +48,7 @@ - + -- cgit v1.2.3 From 7f9971a4c838b84fb1223845ccdb8256eb08b72d Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 5 Oct 2023 14:08:02 +0700 Subject: Fix bug apply voucher on create sale order API --- indoteknik_custom/models/sale_order.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index e201496a..728c0bba 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -421,8 +421,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 @@ -472,8 +472,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 -- cgit v1.2.3 From c6c1e26d35327b61a88b247ef94cfff9257b492a Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 5 Oct 2023 16:48:43 +0700 Subject: Add computed_price field on product pricelist --- indoteknik_custom/models/product_pricelist.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py index 026977f8..144b8689 100644 --- a/indoteknik_custom/models/product_pricelist.py +++ b/indoteknik_custom/models/product_pricelist.py @@ -40,5 +40,4 @@ 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 -- cgit v1.2.3 From 8737ffba70651633d06f5185659f4429b26bd18b Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 6 Oct 2023 13:36:09 +0700 Subject: Update pricelist domain on voucher xml --- indoteknik_custom/views/voucher.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom') 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 @@ - + -- cgit v1.2.3 From 7a23a18a45fbd38fabc33f4e1a74d9f31e86cd60 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 6 Oct 2023 14:11:15 +0700 Subject: Fix get flash sale price on sync to solr --- indoteknik_custom/models/solr/product_product.py | 2 +- indoteknik_custom/models/solr/product_template.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 20a68b47..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() diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 30c3b3c5..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) -- cgit v1.2.3 From bb3c3c6cac4382220ae8a521e8c2162a5fe3d3e9 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 6 Oct 2023 14:21:38 +0700 Subject: add note to sale monitoring --- indoteknik_custom/models/sale_monitoring.py | 1 + indoteknik_custom/views/sale_monitoring.xml | 2 ++ 2 files changed, 3 insertions(+) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index e79ff9ab..587be436 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -21,6 +21,7 @@ class SaleMonitoring(models.Model): status = fields.Char(string="Status") po_number = fields.Char(string="PO Number") qty_reserved = fields.Integer(string="Qty Reserved") + note = fields.Char(string="Note", related='sale_order_id.order_line.note_procurement') def init(self): tools.drop_view_if_exists(self.env.cr, self._table) diff --git a/indoteknik_custom/views/sale_monitoring.xml b/indoteknik_custom/views/sale_monitoring.xml index 0a9a5aa5..641eb8fb 100755 --- a/indoteknik_custom/views/sale_monitoring.xml +++ b/indoteknik_custom/views/sale_monitoring.xml @@ -25,6 +25,7 @@ decoration-success="status == 'Siap kirim'" decoration-info="status == 'Delivered' or status == 'Invoiced'" /> + @@ -48,6 +49,7 @@ decoration-info="status == 'Delivered' or status == 'Invoiced'" /> + -- cgit v1.2.3 From 32d8b6e9655dcd19eb368333aadb565f29a9079b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 6 Oct 2023 14:47:45 +0700 Subject: compute note sale monitoring --- indoteknik_custom/models/sale_monitoring.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index 587be436..ad15e0c2 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -21,7 +21,18 @@ class SaleMonitoring(models.Model): status = fields.Char(string="Status") po_number = fields.Char(string="PO Number") qty_reserved = fields.Integer(string="Qty Reserved") - note = fields.Char(string="Note", related='sale_order_id.order_line.note_procurement') + note = fields.Char(string="Note", compute='compute_note') + + def compute_note(self): + for sale in self: + lines = self.env['sale.order.line'].search([ + ('order_id', '=', sale.sale_order_id.id), + ('note_procurement', '!=', False) + ]) + + note_procurement = ', '.join(lines.mapped('note_procurement') or ['']) + + sale.note = note_procurement def init(self): tools.drop_view_if_exists(self.env.cr, self._table) -- cgit v1.2.3 From a48ae105c865e710227e12b666fa601a326d12a7 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 9 Oct 2023 08:46:08 +0700 Subject: add filter search sale_order_id to rfq po --- indoteknik_custom/views/purchase_order.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 0ad76ae5..e0ec86f9 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -137,4 +137,16 @@ + + + purchase.order.select.inherit + purchase.order + + + + + + + + \ No newline at end of file -- cgit v1.2.3