diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-10-18 17:36:30 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-10-18 17:36:30 +0700 |
| commit | 7b0dd67379d3331785eb90cfbb13af52be9a6c78 (patch) | |
| tree | f8381ca9722f97c4bdc6433a789e158b3dcb58fe | |
| parent | 27eae18c2e57c98f466313e15f0644fcd4754966 (diff) | |
fix credit limit validation in sales order
| -rwxr-xr-x | base_accounting_kit/models/credit_limit.py | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/base_accounting_kit/models/credit_limit.py b/base_accounting_kit/models/credit_limit.py index 82029cc..9a5a4fd 100755 --- a/base_accounting_kit/models/credit_limit.py +++ b/base_accounting_kit/models/credit_limit.py @@ -110,6 +110,7 @@ class SaleOrder(models.Model): paid_invoice_amount += invoice.amount_total outstanding_amount = all_order_amount - paid_invoice_amount + print(outstanding_amount) rec.outstanding_amount = outstanding_amount has_due = fields.Boolean() @@ -127,36 +128,33 @@ class SaleOrder(models.Model): for rec in self: """To check the selected customers due amount is exceed than blocking stage""" - all_order_ids = [] - paid_invoice_ids = [] - all_order_amount = 0 - paid_invoice_amount = 0 - outstanding_amount = 0 - - all_order_ids = self.env['sale.order'].search([ - ('state', 'in', ['sale','done']), - ('partner_id', '=', rec.partner_id.id), - ('id', '!=', rec.id) - ]) - - paid_invoice_ids = self.env['account.move'].search([ - ('payment_state','=','paid'), - ('partner_id','=',rec.partner_id.id), - ('move_type','=','out_invoice') - ]) - - if all_order_ids: - for order in all_order_ids: - print ("SO ", order.name) - all_order_amount += order.amount_total - print ("All order amount ", all_order_amount) - - if paid_invoice_ids: - for invoice in paid_invoice_ids: - paid_invoice_amount += invoice.amount_total - print ("Paid invoice amount ", paid_invoice_amount) - - outstanding_amount = all_order_amount - paid_invoice_amount + # all_order_ids = [] + # paid_invoice_ids = [] + # all_order_amount = 0 + # paid_invoice_amount = 0 + # outstanding_amount = 0 + # + # all_order_ids = self.env['sale.order'].search([ + # ('state', 'in', ['sale','done']), + # ('partner_id', '=', rec.partner_id.id), + # ('id', '!=', rec.id) + # ]) + # + # paid_invoice_ids = self.env['account.move'].search([ + # ('payment_state','=','paid'), + # ('partner_id','=',rec.partner_id.id), + # ('move_type','=','out_invoice') + # ]) + # + # if all_order_ids: + # for order in all_order_ids: + # all_order_amount += order.amount_total + # + # if paid_invoice_ids: + # for invoice in paid_invoice_ids: + # paid_invoice_amount += invoice.amount_total + + outstanding_amount = rec.outstanding_amount ###### if rec.partner_id.active_limit \ @@ -166,6 +164,7 @@ class SaleOrder(models.Model): block_state = rec.partner_id.parent_id.blocking_stage else: block_stage = rec.partner_id.blocking_stage + print(block_state) if (outstanding_amount + rec.amount_total) >= block_stage: if block_stage != 0: |
