Check against credit limit unpaid amount of the sale
issue11229 review395461002
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user