From 16ddcb43b85c1deeda29bf6bb5db4ef73b8d20d2 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 2 Oct 2024 16:21:55 +0700 Subject: add suggested vendor by md, use later --- indoteknik_custom/models/sale_order_line.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indoteknik_custom/models/sale_order_line.py') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index d1dcd0af..14bb8c99 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -32,6 +32,7 @@ class SaleOrderLine(models.Model): reserved_from = fields.Char(string='Reserved From', copy=False) item_percent_margin_without_deduction = fields.Float('%Margin', compute='_compute_item_margin_without_deduction') weight = fields.Float(string='Weight') + md_vendor_id = fields.Many2one('res.partner', string='MD Vendor', readonly=True) @api.constrains('note_procurement') def note_procurement_to_apo(self): @@ -245,6 +246,7 @@ class SaleOrderLine(models.Model): # query, limit=1, order='count_trx_po desc, count_trx_po_vendor desc') price, taxes, vendor_id = self._get_purchase_price(line.product_id) line.vendor_id = vendor_id + line.md_vendor_id = vendor_id line.tax_id = line.order_id.sales_tax_id # price, taxes = line._get_valid_purchase_price(purchase_price) line.purchase_price = price -- cgit v1.2.3 From 4a69c71eab2d4ea3504a0cf6e3a9ca241be48594 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 3 Oct 2024 10:12:24 +0700 Subject: push --- indoteknik_custom/models/sale_order_line.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indoteknik_custom/models/sale_order_line.py') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index d1dcd0af..dca8534c 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -14,7 +14,12 @@ class SaleOrderLine(models.Model): states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]" ) + vendor_md_id = fields.Many2one( + 'res.partner', string='MD Vendor', readonly=True, + change_default=True, index=True, tracking=1 + ) purchase_price = fields.Float('Purchase', required=True, digits='Product Price', default=0.0) + purchase_price_md = fields.Float('MD Purchase', required=True, digits='Product Price', default=0.0) purchase_tax_id = fields.Many2one('account.tax', string='Tax', domain=['|', ('active', '=', False), ('active', '=', True)]) delivery_amt_line = fields.Float('DeliveryAmtLine', compute='compute_delivery_amt_line') fee_third_party_line = fields.Float('FeeThirdPartyLine', compute='compute_fee_third_party_line', default=0) @@ -245,9 +250,11 @@ class SaleOrderLine(models.Model): # query, limit=1, order='count_trx_po desc, count_trx_po_vendor desc') price, taxes, vendor_id = self._get_purchase_price(line.product_id) line.vendor_id = vendor_id + line.vendor_md_id = vendor_id line.tax_id = line.order_id.sales_tax_id # price, taxes = line._get_valid_purchase_price(purchase_price) line.purchase_price = price + line.purchase_price_md = price line.purchase_tax_id = taxes attribute_values = line.product_id.product_template_attribute_value_ids.mapped('name') -- cgit v1.2.3 From 7059f095dd09649f7c12f74ff29200f644bbc854 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 3 Oct 2024 11:55:16 +0700 Subject: push --- indoteknik_custom/models/sale_order_line.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indoteknik_custom/models/sale_order_line.py') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index dca8534c..06b0f53d 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -14,12 +14,9 @@ class SaleOrderLine(models.Model): states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]" ) - vendor_md_id = fields.Many2one( - 'res.partner', string='MD Vendor', readonly=True, - change_default=True, index=True, tracking=1 - ) + vendor_md_id = fields.Many2one('res.partner', string='MD Vendor') purchase_price = fields.Float('Purchase', required=True, digits='Product Price', default=0.0) - purchase_price_md = fields.Float('MD Purchase', required=True, digits='Product Price', default=0.0) + purchase_price_md = fields.Float('MD Purchase') purchase_tax_id = fields.Many2one('account.tax', string='Tax', domain=['|', ('active', '=', False), ('active', '=', True)]) delivery_amt_line = fields.Float('DeliveryAmtLine', compute='compute_delivery_amt_line') fee_third_party_line = fields.Float('FeeThirdPartyLine', compute='compute_fee_third_party_line', default=0) @@ -138,6 +135,7 @@ class SaleOrderLine(models.Model): elif self.product_id.categ_id.id == 34: # finish good / manufacturing only cost = self.product_id.standard_price self.purchase_price = cost + self.purchase_price_md = cost elif self.product_id.x_manufacture.override_vendor_id: # purchase_price = self.env['purchase.pricelist'].search( # [('vendor_id', '=', self.product_id.x_manufacture.override_vendor_id.id), @@ -145,6 +143,8 @@ class SaleOrderLine(models.Model): # limit=1, order='count_trx_po desc, count_trx_po_vendor desc') price, taxes, vendor_id = self._get_purchase_price_by_vendor(self.product_id, self.vendor_id) self.purchase_price = price + self.purchase_price_md = price + self.vendor_md_id = self.vendor_id self.purchase_tax_id = taxes # else: # purchase_price = self.env['purchase.pricelist'].search( -- cgit v1.2.3 From 48c220d1c38f435962b8b630c5209ba781ca30df Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 4 Oct 2024 14:23:59 +0700 Subject: push --- indoteknik_custom/models/sale_order_line.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models/sale_order_line.py') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 06b0f53d..98a6c759 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -34,6 +34,7 @@ class SaleOrderLine(models.Model): reserved_from = fields.Char(string='Reserved From', copy=False) item_percent_margin_without_deduction = fields.Float('%Margin', compute='_compute_item_margin_without_deduction') weight = fields.Float(string='Weight') + margin_md = fields.Float(string='Margin MD') @api.constrains('note_procurement') def note_procurement_to_apo(self): @@ -127,6 +128,9 @@ class SaleOrderLine(models.Model): else: line.item_percent_margin = 0 + if not line.margin_md: + line.margin_md = line.item_percent_margin + @api.onchange('vendor_id') def onchange_vendor_id(self): # TODO : need to change this logic @stephan @@ -135,7 +139,6 @@ class SaleOrderLine(models.Model): elif self.product_id.categ_id.id == 34: # finish good / manufacturing only cost = self.product_id.standard_price self.purchase_price = cost - self.purchase_price_md = cost elif self.product_id.x_manufacture.override_vendor_id: # purchase_price = self.env['purchase.pricelist'].search( # [('vendor_id', '=', self.product_id.x_manufacture.override_vendor_id.id), @@ -143,8 +146,6 @@ class SaleOrderLine(models.Model): # limit=1, order='count_trx_po desc, count_trx_po_vendor desc') price, taxes, vendor_id = self._get_purchase_price_by_vendor(self.product_id, self.vendor_id) self.purchase_price = price - self.purchase_price_md = price - self.vendor_md_id = self.vendor_id self.purchase_tax_id = taxes # else: # purchase_price = self.env['purchase.pricelist'].search( @@ -251,6 +252,7 @@ class SaleOrderLine(models.Model): price, taxes, vendor_id = self._get_purchase_price(line.product_id) line.vendor_id = vendor_id line.vendor_md_id = vendor_id + line.margin_md = line.item_percent_margin line.tax_id = line.order_id.sales_tax_id # price, taxes = line._get_valid_purchase_price(purchase_price) line.purchase_price = price -- cgit v1.2.3 From ce1c714c95f68b07f9b891600ba1e3b88288652c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 8 Oct 2024 15:17:53 +0700 Subject: fix bug --- indoteknik_custom/models/sale_order_line.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models/sale_order_line.py') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 6aaa4d53..59ac1ad4 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -257,6 +257,7 @@ class SaleOrderLine(models.Model): line.tax_id = line.order_id.sales_tax_id # price, taxes = line._get_valid_purchase_price(purchase_price) line.purchase_price_md = price + line.purchase_price = price line.purchase_tax_id = taxes attribute_values = line.product_id.product_template_attribute_value_ids.mapped('name') -- cgit v1.2.3 From 58892a2e250d317e03ceddfb9517988525fc1f64 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 11 Oct 2024 10:52:56 +0700 Subject: fix bug md vendor --- indoteknik_custom/models/sale_order_line.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models/sale_order_line.py') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 59ac1ad4..5e01067a 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -251,14 +251,14 @@ class SaleOrderLine(models.Model): # purchase_price = self.env['purchase.pricelist'].search( # query, limit=1, order='count_trx_po desc, count_trx_po_vendor desc') price, taxes, vendor_id = self._get_purchase_price(line.product_id) + line.vendor_md_id = vendor_id line.vendor_id = vendor_id - line.md_vendor_id = vendor_id line.margin_md = line.item_percent_margin line.tax_id = line.order_id.sales_tax_id # price, taxes = line._get_valid_purchase_price(purchase_price) line.purchase_price_md = price line.purchase_price = price - line.purchase_tax_id = taxes + line.purchase_tax_id = taxes attribute_values = line.product_id.product_template_attribute_value_ids.mapped('name') attribute_values_str = ', '.join(attribute_values) if attribute_values else '' -- cgit v1.2.3 From a3667d8e42b891192a3e86a00ebc3cd07da8877d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 16 Oct 2024 09:33:42 +0700 Subject: remove field md_vendor_id --- indoteknik_custom/models/sale_order_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_order_line.py') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 5e01067a..1b7b3ef2 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -34,7 +34,7 @@ class SaleOrderLine(models.Model): reserved_from = fields.Char(string='Reserved From', copy=False) item_percent_margin_without_deduction = fields.Float('%Margin', compute='_compute_item_margin_without_deduction') weight = fields.Float(string='Weight') - md_vendor_id = fields.Many2one('res.partner', string='MD Vendor', readonly=True) + # md_vendor_id = fields.Many2one('res.partner', string='MD Vendor', readonly=True) margin_md = fields.Float(string='Margin MD') @api.constrains('note_procurement') -- cgit v1.2.3 From 53e39ccf1780beda4f27ae2e67566d57ac915654 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 16 Oct 2024 09:39:32 +0700 Subject: fix error --- indoteknik_custom/models/sale_order_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_order_line.py') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 1b7b3ef2..5e01067a 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -34,7 +34,7 @@ class SaleOrderLine(models.Model): reserved_from = fields.Char(string='Reserved From', copy=False) item_percent_margin_without_deduction = fields.Float('%Margin', compute='_compute_item_margin_without_deduction') weight = fields.Float(string='Weight') - # md_vendor_id = fields.Many2one('res.partner', string='MD Vendor', readonly=True) + md_vendor_id = fields.Many2one('res.partner', string='MD Vendor', readonly=True) margin_md = fields.Float(string='Margin MD') @api.constrains('note_procurement') -- cgit v1.2.3