diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-05-23 09:23:09 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-05-23 09:23:09 +0700 |
| commit | 43313db30da73b87843425c01c723f66ee982886 (patch) | |
| tree | 1f6dc6e9518c27ac3a867c42f25f56eed6f8cae0 /indoteknik_custom/models/sale_order.py | |
| parent | f6f59e660af6c4229ada54f7313d68867df1ba15 (diff) | |
| parent | 46e4c80e1b530274c01cca5603f3e1be873820f6 (diff) | |
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup
# Conflicts:
# indoteknik_custom/models/sale_order.py
Diffstat (limited to 'indoteknik_custom/models/sale_order.py')
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 6028a1d0..db0e1227 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -332,9 +332,9 @@ class SaleOrder(models.Model): ('approve', 'Approve') ], tracking=True, string='State Cancel', copy=False) date_hold = fields.Datetime(string='Date Hold', tracking=True, readonly=True, help='Waktu ketika SO di Hold' - ) + ) date_unhold = fields.Datetime(string='Date Unhold', tracking=True, readonly=True, help='Waktu ketika SO di Unhold' - ) + ) ready_to_ship_status_detail = fields.Char( string='Status Shipping Detail', @@ -379,7 +379,7 @@ class SaleOrder(models.Model): } } - def hold_unhold_qty_outgoing_so(self): + def hold_unhold_qty_outgoing_so(self): if self.hold_outgoing == True: self.hold_outgoing = False self.date_unhold = fields.Datetime.now() @@ -393,7 +393,6 @@ class SaleOrder(models.Model): picking.do_unreserve() self.hold_outgoing = True self.date_hold = fields.Datetime.now() - def _validate_uniform_taxes(self): for order in self: @@ -411,8 +410,8 @@ class SaleOrder(models.Model): # 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 + # UPDATE sale_order + # SET total_margin_excl_third_party = %s # WHERE id = %s # """, (rec.total_percent_margin, rec.id)) # self.invalidate_cache() @@ -1232,10 +1231,12 @@ class SaleOrder(models.Model): for order in self: for line in order.order_line: if 'bom-it' in line.name.lower() or 'bom' in line.product_id.default_code.lower() if line.product_id.default_code else False: - search_bom = self.env['mrp.production'].search([('product_id', '=', line.product_id.id), ('sale_order', '=', order.id), ('state', '!=', 'cancel')], - order='name desc') + search_bom = self.env['mrp.production'].search( + [('product_id', '=', line.product_id.id), ('sale_order', '=', order.id), + ('state', '!=', 'cancel')], + order='name desc') if search_bom: - confirmed_bom = search_bom.filtered(lambda x: x.state == 'confirmed' or x.state == 'done') + confirmed_bom = search_bom.filtered(lambda x: x.state == 'confirmed' or x.state == 'done') if not confirmed_bom: raise UserError( "Product BOM belum dikonfirmasi di Manufacturing Orders. Silakan hubungi MD.") @@ -1533,7 +1534,7 @@ class SaleOrder(models.Model): if not order.real_shipping_id: UserError('Real Delivery Address harus di isi') - + if not self.env.context.get('due_approve', []): if order.validate_partner_invoice_due(): return self._create_notification_action('Notification', @@ -2015,6 +2016,7 @@ class SaleOrder(models.Model): <<<<<<< HEAD self._calculate_etrts_date() return res +<<<<<<< HEAD ======= self._calculate_etrts_date() return res @@ -2054,3 +2056,27 @@ class SaleOrder(models.Model): else: order.ready_to_ship_status_detail = 'On Track' >>>>>>> CR/form-merchant +======= + + def write(self, vals): + # Cek apakah payment_term_id diubah dan SO sedang dalam approval + if 'payment_term_id' in vals and any( + order.approval_status in ['pengajuan1', 'pengajuan2', 'approved'] for order in self): + raise UserError( + "Payment Term tidak dapat diubah karena Sales Order sedang dalam proses approval atau sudah diapprove.") + + if 'payment_term_id' in vals: + for order in self: + partner = order.partner_id.parent_id or order.partner_id + customer_payment_term = partner.property_payment_term_id + + # Jika payment term yang diinput berbeda dengan payment term customer + if vals['payment_term_id'] != customer_payment_term.id: + raise UserError( + f"Payment Term berbeda pada Master Data Customer. " + f"Harap ganti ke '{customer_payment_term.name}' " + f"sesuai dengan payment term yang terdaftar pada customer." + ) + + return super(SaleOrder, self).write(vals) +>>>>>>> 46e4c80e1b530274c01cca5603f3e1be873820f6 |
