Check against credit limit unpaid amount of the sale

issue11229
review395461002
This commit is contained in:
Cédric Krier
2022-03-06 18:20:38 +01:00
parent 8e5d02554b
commit a4e4c74ac2
+11 -2
View File
@@ -7,12 +7,21 @@ from trytond.pool import PoolMeta
class Sale(metaclass=PoolMeta):
__name__ = 'sale.sale'
def must_check_credit_limit(self):
return self.shipment_method == 'order'
@property
def credit_limit_amount(self):
"Amount to check against credit limit"
return self.untaxed_amount
@classmethod
@ModelView.button
@Workflow.transition('confirmed')
def confirm(cls, sales):
for sale in sales:
if sale.shipment_method == 'order':
if sale.must_check_credit_limit():
party = sale.invoice_party or sale.party
party.check_credit_limit(sale.untaxed_amount, origin=str(sale))
party.check_credit_limit(
sale.credit_limit_amount, origin=str(sale))
super(Sale, cls).confirm(sales)