From 99b252edaefc372fcd4ef59e065284d8feeb669c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 19 Feb 2025 09:38:46 +0700 Subject: push --- indoteknik_custom/models/sale_order.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 7b2d9bf8..88c32fb6 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -11,6 +11,7 @@ _logger = logging.getLogger(__name__) class SaleOrder(models.Model): _inherit = "sale.order" + koli_lines = fields.One2many('sales.order.koli', 'sale_order_id', string='Sales Order Koli', auto_join=True) fulfillment_line_v2 = fields.One2many('sales.order.fulfillment.v2', 'sale_order_id', string='Fullfillment2') fullfillment_line = fields.One2many('sales.order.fullfillment', 'sales_order_id', string='Fullfillment') reject_line = fields.One2many('sales.order.reject', 'sale_order_id', string='Reject Lines') -- cgit v1.2.3 From aada0aa508549c9357cdee1a16cd7a23d6a38b22 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 26 Mar 2025 11:33:57 +0700 Subject: push --- indoteknik_custom/models/sale_order.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 01aefe7a..d8c1888f 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -71,6 +71,7 @@ class SaleOrder(models.Model): order_sales_match_line = fields.One2many('sales.order.purchase.match', 'sales_order_id', string='Purchase Match Lines', states={'cancel': [('readonly', True)], 'done': [('readonly', True)]}, copy=True) total_margin = fields.Float('Total Margin', compute='_compute_total_margin', help="Total Margin in Sales Order Header") total_percent_margin = fields.Float('Total Percent Margin', compute='_compute_total_percent_margin', help="Total % Margin in Sales Order Header") + total_margin_excl_third_party = fields.Float('Before Margin', help="Before Margin in Sales Order Header") approval_status = fields.Selection([ ('pengajuan1', 'Approval Manager'), ('pengajuan2', 'Approval Pimpinan'), @@ -102,6 +103,7 @@ class SaleOrder(models.Model): domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Dipakai untuk alamat tempel", tracking=True) fee_third_party = fields.Float('Fee Pihak Ketiga') + biaya_lain_lain = fields.Float('Biaya Lain Lain') so_status = fields.Selection([ ('terproses', 'Terproses'), ('sebagian', 'Sebagian Diproses'), @@ -232,6 +234,12 @@ class SaleOrder(models.Model): nomor_so_pengganti = fields.Char(string='Nomor SO Pengganti', copy=False, tracking=3) shipping_option_id = fields.Many2one("shipping.option", string="Selected Shipping Option", domain="['|', ('sale_order_id', '=', False), ('sale_order_id', '=', id)]") + @api.constrains('delivery_amt', 'biaya_lain_lain', 'fee_third_party') + def _check_margin_excl_third_party(self): + for rec in self: + if rec.fee_third_party == 0: + rec.total_margin_excl_third_party = rec.total_percent_margin + @api.constrains('shipping_option_id') def _check_shipping_option(self): for rec in self: @@ -243,7 +251,7 @@ class SaleOrder(models.Model): carrier_names = order.picking_ids.mapped('carrier_id.name') order.shipping_method_picking = ', '.join(filter(None, carrier_names)) else: - order.shipping_method_picking = False + order.shipping_method_picking = False @api.onchange('payment_status') def _is_continue_transaction(self): @@ -450,7 +458,7 @@ class SaleOrder(models.Model): delivery_amt = order.delivery_amt else: delivery_amt = 0 - order.percent_margin_after_delivery_purchase = round((order.margin_after_delivery_purchase / (order.amount_untaxed-delivery_amt-order.fee_third_party)) * 100, 2) + order.percent_margin_after_delivery_purchase = round((order.margin_after_delivery_purchase / (order.amount_untaxed-delivery_amt-order.fee_third_party-order.biaya_lain_lain)) * 100, 2) def _compute_date_kirim(self): for rec in self: @@ -1399,7 +1407,7 @@ class SaleOrder(models.Model): delivery_amt = order.delivery_amt else: delivery_amt = 0 - order.total_percent_margin = round((order.total_margin / (order.amount_untaxed-delivery_amt-order.fee_third_party)) * 100, 2) + order.total_percent_margin = round((order.total_margin / (order.amount_untaxed-delivery_amt-order.fee_third_party-order.biaya_lain_lain)) * 100, 2) # order.total_percent_margin = round((order.total_margin / (order.amount_untaxed)) * 100, 2) @api.onchange('sales_tax_id') -- cgit v1.2.3 From 44220214132f20202da9f225ed46ecfe14057e2c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 26 Mar 2025 13:16:13 +0700 Subject: push --- indoteknik_custom/models/sale_order.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index d8c1888f..f66da470 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -234,8 +234,8 @@ class SaleOrder(models.Model): nomor_so_pengganti = fields.Char(string='Nomor SO Pengganti', copy=False, tracking=3) shipping_option_id = fields.Many2one("shipping.option", string="Selected Shipping Option", domain="['|', ('sale_order_id', '=', False), ('sale_order_id', '=', id)]") - @api.constrains('delivery_amt', 'biaya_lain_lain', 'fee_third_party') - def _check_margin_excl_third_party(self): + @api.constrains('write_date') + def _check_total_margin_excl_third_party(self): for rec in self: if rec.fee_third_party == 0: rec.total_margin_excl_third_party = rec.total_percent_margin @@ -251,7 +251,7 @@ class SaleOrder(models.Model): carrier_names = order.picking_ids.mapped('carrier_id.name') order.shipping_method_picking = ', '.join(filter(None, carrier_names)) else: - order.shipping_method_picking = False + order.shipping_method_picking = False @api.onchange('payment_status') def _is_continue_transaction(self): -- cgit v1.2.3 From cefc6ec6de52f2c79c1760cf88db3375f4956a31 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 26 Mar 2025 13:48:25 +0700 Subject: PUSH --- indoteknik_custom/models/sale_order.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index f66da470..3b3aef6a 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -234,7 +234,7 @@ class SaleOrder(models.Model): nomor_so_pengganti = fields.Char(string='Nomor SO Pengganti', copy=False, tracking=3) shipping_option_id = fields.Many2one("shipping.option", string="Selected Shipping Option", domain="['|', ('sale_order_id', '=', False), ('sale_order_id', '=', id)]") - @api.constrains('write_date') + @api.constrains('fee_third_party', 'delivery_amt', 'biaya_lain_lain') def _check_total_margin_excl_third_party(self): for rec in self: if rec.fee_third_party == 0: @@ -1662,6 +1662,7 @@ class SaleOrder(models.Model): # Ensure partner details are updated when a sale order is created order = super(SaleOrder, self).create(vals) order._compute_etrts_date() + order._check_total_margin_excl_third_party() # order._update_partner_details() return order @@ -1704,5 +1705,6 @@ class SaleOrder(models.Model): "SO tidak dapat ditambahkan produk baru karena SO sudah menjadi sale order.") res = super(SaleOrder, self).write(vals) if 'order_line' in vals: + self._check_total_margin_excl_third_party() self._compute_etrts_date() return res \ No newline at end of file -- cgit v1.2.3 From 20cf871492e9de61669c577d31d2219d092796bf Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 26 Mar 2025 15:02:37 +0700 Subject: fix bug on stock picking --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index c7fcabbb..1778536b 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -656,7 +656,7 @@ class SaleOrder(models.Model): def _validate_delivery_amt(self): if self.delivery_amt < 1: - if(self.carrier_id.id == 1 or self.shipping_cost_covered == 'indoteknik'): + if(self.carrier_id.id == 1 or self.shipping_cost_covered == 'indoteknik') and not self.env.context.get('active_id', []): if(self.carrier_id.id == 1): raise UserError('Untuk Kurir Indoteknik Delivery, Estimasi Ongkos Kirim Harus di isi') else: -- cgit v1.2.3 From bf59882cd2554229cc20dc75d790686f641522c4 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Thu, 27 Mar 2025 09:05:51 +0700 Subject: bug fixing percent margin --- indoteknik_custom/models/sale_order.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index bee7d6a7..3bf6ba14 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -662,6 +662,7 @@ class SaleOrder(models.Model): if self.email and not re.match(pattern, self.email): raise UserError('Email yang anda input kurang valid') + @api.constrains('delivery_amt', 'carrier_id', 'shipping_cost_covered') def _validate_delivery_amt(self): if self.delivery_amt < 1: if(self.carrier_id.id == 1 or self.shipping_cost_covered == 'indoteknik') and not self.env.context.get('active_id', []): -- cgit v1.2.3 From a83022f278c3fbe6a8ed6ae92a2ffee2e4a7c992 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Thu, 27 Mar 2025 09:12:49 +0700 Subject: comment total margin excl third party --- indoteknik_custom/models/sale_order.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 3bf6ba14..4ebc5d34 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1693,7 +1693,7 @@ class SaleOrder(models.Model): order._compute_etrts_date() order._validate_expected_ready_ship_date() order._validate_delivery_amt() - order._check_total_margin_excl_third_party() + # order._check_total_margin_excl_third_party() # order._update_partner_details() return order @@ -1737,7 +1737,7 @@ class SaleOrder(models.Model): res = super(SaleOrder, self).write(vals) self._validate_delivery_amt() - self._check_total_margin_excl_third_party() + # self._check_total_margin_excl_third_party() if any(field in vals for field in ["order_line", "client_order_ref"]): self._calculate_etrts_date() if 'order_line' in vals: -- cgit v1.2.3 From 6a0664215fab4f63928092d98214acb7b68fdff5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 27 Mar 2025 09:21:16 +0700 Subject: fix bug so --- indoteknik_custom/models/sale_order.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index bee7d6a7..89ed0327 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -239,8 +239,14 @@ class SaleOrder(models.Model): @api.constrains('fee_third_party', 'delivery_amt', 'biaya_lain_lain') def _check_total_margin_excl_third_party(self): for rec in self: - if rec.fee_third_party == 0: - rec.total_margin_excl_third_party = rec.total_percent_margin + if rec.fee_third_party == 0 and rec.total_margin_excl_third_party != rec.total_percent_margin: + # Gunakan direct SQL atau flag context untuk menghindari rekursi + self.env.cr.execute(""" + UPDATE sale_order + SET total_margin_excl_third_party = %s + WHERE id = %s + """, (rec.total_percent_margin, rec.id)) + self.invalidate_cache() @api.constrains('shipping_option_id') def _check_shipping_option(self): @@ -1692,7 +1698,7 @@ class SaleOrder(models.Model): order._compute_etrts_date() order._validate_expected_ready_ship_date() order._validate_delivery_amt() - order._check_total_margin_excl_third_party() + # order._check_total_margin_excl_third_party() # order._update_partner_details() return order @@ -1736,7 +1742,7 @@ class SaleOrder(models.Model): res = super(SaleOrder, self).write(vals) self._validate_delivery_amt() - self._check_total_margin_excl_third_party() + # self._check_total_margin_excl_third_party() if any(field in vals for field in ["order_line", "client_order_ref"]): self._calculate_etrts_date() if 'order_line' in vals: -- cgit v1.2.3 From d34d5dfbf8ef449b57bca9031bd5a28a1bf1928d Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Thu, 27 Mar 2025 09:26:43 +0700 Subject: bug fix total percent margin edit --- indoteknik_custom/models/sale_order.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 4ebc5d34..993eaed1 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1736,10 +1736,9 @@ class SaleOrder(models.Model): "SO tidak dapat ditambahkan produk baru karena SO sudah menjadi sale order.") res = super(SaleOrder, self).write(vals) - self._validate_delivery_amt() # self._check_total_margin_excl_third_party() + if any(fields in vals for fields in ['delivery_amt', 'carrier_id', 'shipping_cost_covered']): + self._validate_delivery_amt() if any(field in vals for field in ["order_line", "client_order_ref"]): self._calculate_etrts_date() - if 'order_line' in vals: - self._compute_etrts_date() return res \ No newline at end of file -- cgit v1.2.3 From b9a81c1a9b495571a5cb30993a31eda7c5ab871f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 7 Apr 2025 10:42:33 +0700 Subject: cr validation delivery amt --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 6dd31d89..8d9af692 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -668,7 +668,7 @@ class SaleOrder(models.Model): if self.email and not re.match(pattern, self.email): raise UserError('Email yang anda input kurang valid') - @api.constrains('delivery_amt', 'carrier_id', 'shipping_cost_covered') + # @api.constrains('delivery_amt', 'carrier_id', 'shipping_cost_covered') def _validate_delivery_amt(self): if self.delivery_amt < 1: if(self.carrier_id.id == 1 or self.shipping_cost_covered == 'indoteknik') and not self.env.context.get('active_id', []): -- cgit v1.2.3 From e1edb44855ed2549f6f5a35773c5fdb81de9c0b4 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 10 Apr 2025 09:07:24 +0700 Subject: comment function check_product_bom on action confirm so --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 8d9af692..8d156943 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1257,7 +1257,7 @@ class SaleOrder(models.Model): def action_confirm(self): for order in self: - order.check_product_bom() + # order.check_product_bom() order.check_credit_limit() order.check_limit_so_to_invoice() if self.validate_different_vendor() and not self.vendor_approval: -- cgit v1.2.3 From 4cfda3f1511ba1e6f8226652cf1ff64a48efef92 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 10 Apr 2025 09:18:51 +0700 Subject: uncomment function check_product_bom on so --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 8d156943..8d9af692 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1257,7 +1257,7 @@ class SaleOrder(models.Model): def action_confirm(self): for order in self: - # order.check_product_bom() + order.check_product_bom() order.check_credit_limit() order.check_limit_so_to_invoice() if self.validate_different_vendor() and not self.vendor_approval: -- cgit v1.2.3