diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-09-17 11:27:45 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-09-17 11:27:45 +0000 |
| commit | ef9daab07049de822b7137b4a9a5d3f1fba53992 (patch) | |
| tree | 8667f96ea9d6726f7bf0d20db67878552b4f3140 | |
| parent | 23d713fc686d56ef5b5e8004b91b3f4fe54117e6 (diff) | |
| parent | d7cb0787c9a107434c16f3d4a678511858fb6cd5 (diff) | |
Merged in cbd-apt (pull request #414)
Cbd apt
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index dd06f541..94c5f041 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -2413,17 +2413,22 @@ class SaleOrder(models.Model): # Ambil blocking stage dari partner block_stage = rec.partner_id.parent_id.blocking_stage if rec.partner_id.parent_id else rec.partner_id.blocking_stage or 0 is_cbd = rec.partner_id.parent_id.property_payment_term_id.id == 26 if rec.partner_id.parent_id else rec.partner_id.property_payment_term_id.id == 26 or False + partner_term = rec.partner_id.property_payment_term_id + partner_term_days_total = 0 + if partner_term: + partner_term_days_total = sum((line.days or 0) for line in partner_term.line_ids) + is_partner_cbd = (partner_term_days_total == 0) + is_so_cbd = bool(rec.payment_term_id.id == 26) - # Ambil jumlah nilai dari SO yang invoice_status masih 'to invoice' so_to_invoice = 0 for sale in rec.partner_id.sale_order_ids: if sale.invoice_status == 'to invoice': so_to_invoice = so_to_invoice + sale.amount_total - # Hitung remaining credit limit - remaining_credit_limit = block_stage - current_total - so_to_invoice + + remaining_credit_limit = block_stage - current_total - so_to_invoice if not is_cbd and not is_partner_cbd else 0 # Validasi limit - if remaining_credit_limit <= 0 and block_stage > 0 and not is_cbd: + if remaining_credit_limit <= 0 and block_stage > 0 and not is_cbd and not is_so_cbd and not is_partner_cbd: raise UserError( _("The credit limit for %s will exceed the Blocking Stage if the Sale Order is confirmed. The remaining credit limit is %s, from %s and the outstanding amount is %s.") % (rec.partner_id.name, block_stage - current_total, block_stage, outstanding_amount)) |
