diff --git a/sale.py b/sale.py index 9a6099715e..d209f7268f 100644 --- a/sale.py +++ b/sale.py @@ -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)