From 0c3abd74ac9aa0b3f1b6fe4e2435698922387b0b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 27 Jun 2023 16:44:25 +0700 Subject: add new field subtotal_vendot to so line --- indoteknik_custom/models/sale_order.py | 19 ++++++++++++++++++- indoteknik_custom/views/sale_order.xml | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 0a794f6d..d980e1fe 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -462,7 +462,7 @@ class SaleOrderLine(models.Model): 'res.partner', string='Vendor', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, change_default=True, index=True, tracking=1, - domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", ) + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",) purchase_price = fields.Float('Purchase', required=True, digits='Product Price', default=0.0) purchase_tax_id = fields.Many2one('account.tax', string='Tax', domain=['|', ('active', '=', False), ('active', '=', True)]) @@ -470,6 +470,23 @@ class SaleOrderLine(models.Model): fee_third_party_line = fields.Float('FeeThirdPartyLine', compute='compute_fee_third_party_line', default=0) line_no = fields.Integer('No', default=0, copy=False) note_procurement = fields.Char(string='Note', help="Harap diisi jika ada keterangan tambahan dari Procurement, agar dapat dimonitoring") + vendor_subtotal = fields.Float( + string='Vendor Subtotal', compute="compute_vendor_subtotal") + + def compute_vendor_subtotal(self): + # self.vendor_subtotal = 1 + for line in self: + if line.vendor_id: + product = line.product_id + + if product: + vendor_price = line.purchase_price + if line.purchase_tax_id.price_include: + vendor_price = line.purchase_price + else: + vendor_price = line.purchase_price + (line.purchase_price*11/100) + + line.vendor_subtotal = vendor_price * line.product_uom_qty def compute_item_margin(self): for line in self: diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 85f687c1..ef72c10f 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -63,6 +63,7 @@ + -- cgit v1.2.3 From e4f968ba874b899aa4af89b06abe83674ced938b Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 28 Jun 2023 10:34:32 +0700 Subject: change id of produk sementara --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 0a794f6d..2fc1055b 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -324,7 +324,7 @@ class SaleOrder(models.Model): # must add product can sell validation if not line.product_id.product_tmpl_id.sale_ok: raise UserError('Product %s belum bisa dijual, harap hubungi finance' % line.product_id.display_name) - if line.product_id.id == 232383: + if line.product_id.id == 224484: raise UserError(_('Tidak bisa Confirm menggunakan Produk Sementara')) if not line.vendor_id or not line.purchase_price: raise UserError(_('Isi Vendor dan Harga Beli sebelum Request Approval')) -- cgit v1.2.3 From ecf9d25de623c5cef7f051b650c065c054a08a14 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 28 Jun 2023 12:09:45 +0700 Subject: fix error vendor subtotal --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 09ee88fa..a15a2572 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -476,7 +476,7 @@ class SaleOrderLine(models.Model): def compute_vendor_subtotal(self): # self.vendor_subtotal = 1 for line in self: - if line.vendor_id: + if line.purchase_price: product = line.product_id if product: -- cgit v1.2.3 From 4501a0a17ae56ca822827a7aa500ce269391ee78 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 28 Jun 2023 12:17:53 +0700 Subject: bug fix --- indoteknik_custom/models/sale_order.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index a15a2572..3b3ce13a 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -476,17 +476,17 @@ class SaleOrderLine(models.Model): def compute_vendor_subtotal(self): # self.vendor_subtotal = 1 for line in self: - if line.purchase_price: - product = line.product_id + if line.purchase_price > 0: + # product = line.product_id - if product: - vendor_price = line.purchase_price - if line.purchase_tax_id.price_include: - vendor_price = line.purchase_price - else: - vendor_price = line.purchase_price + (line.purchase_price*11/100) + # if product: + # vendor_price = line.purchase_price + # if line.purchase_tax_id.price_include: + # vendor_price = line.purchase_price + # else: + # vendor_price = line.purchase_price + (line.purchase_price*11/100) - line.vendor_subtotal = vendor_price * line.product_uom_qty + line.vendor_subtotal = line.purchase_price * line.product_uom_qty def compute_item_margin(self): for line in self: -- cgit v1.2.3 From ff7390468fb11915b35c9f522379132dde19a54d Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 28 Jun 2023 12:29:12 +0700 Subject: bug fix vendor subtotal --- indoteknik_custom/models/sale_order.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 3b3ce13a..5f37e3b2 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -470,13 +470,11 @@ class SaleOrderLine(models.Model): fee_third_party_line = fields.Float('FeeThirdPartyLine', compute='compute_fee_third_party_line', default=0) line_no = fields.Integer('No', default=0, copy=False) note_procurement = fields.Char(string='Note', help="Harap diisi jika ada keterangan tambahan dari Procurement, agar dapat dimonitoring") - vendor_subtotal = fields.Float( - string='Vendor Subtotal', compute="compute_vendor_subtotal") + vendor_subtotal = fields.Float(string='Vendor Subtotal', compute="_compute_vendor_subtotal") - def compute_vendor_subtotal(self): - # self.vendor_subtotal = 1 + def _compute_vendor_subtotal(self): for line in self: - if line.purchase_price > 0: + if line.purchase_price > 0 and line.product_uom_qty > 0: # product = line.product_id # if product: @@ -485,8 +483,10 @@ class SaleOrderLine(models.Model): # vendor_price = line.purchase_price # else: # vendor_price = line.purchase_price + (line.purchase_price*11/100) - - line.vendor_subtotal = line.purchase_price * line.product_uom_qty + subtotal = line.purchase_price * line.product_uom_qty + line.vendor_subtotal = subtotal + else: + line.vendor_subtotal = 0 def compute_item_margin(self): for line in self: -- cgit v1.2.3