Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits: a77c3f67 by Maxime Richez at 2023-02-21T12:55:12+01:00 Prevent deletion of payment terms in use Closes #12085 - - - - - 7 changed files: - modules/account_invoice/invoice.py - modules/purchase/purchase.py - modules/purchase_amendment/purchase.py - modules/sale/sale.py - modules/sale_amendment/sale.py - modules/sale_opportunity/opportunity.py - modules/sale_subscription/subscription.py Changes: ===================================== modules/account_invoice/invoice.py ===================================== @@ -169,8 +169,9 @@ Eval('accounting_date'), Eval('invoice_date')), }) - payment_term = fields.Many2One('account.invoice.payment_term', - 'Payment Term', states=_states) + payment_term = fields.Many2One( + 'account.invoice.payment_term', "Payment Term", + ondelete='RESTRICT', states=_states) alternative_payees = fields.Many2Many( 'account.invoice.alternative_payee', 'invoice', 'party', "Alternative Payee", states=_states, ===================================== modules/purchase/purchase.py ===================================== @@ -92,8 +92,9 @@ 'required': ~Eval('state').in_( ['draft', 'quotation', 'cancelled']), }) - payment_term = fields.Many2One('account.invoice.payment_term', - 'Payment Term', states={ + payment_term = fields.Many2One( + 'account.invoice.payment_term', "Payment Term", ondelete='RESTRICT', + states={ 'readonly': ~Eval('state').in_(['draft', 'quotation']), }) party = fields.Many2One('party.party', 'Party', required=True, ===================================== modules/purchase_amendment/purchase.py ===================================== @@ -196,7 +196,7 @@ }) payment_term = fields.Many2One( - 'account.invoice.payment_term', "Payment Term", + 'account.invoice.payment_term', "Payment Term", ondelete='RESTRICT', states={ 'invisible': Eval('action') != 'payment_term', }) ===================================== modules/sale/sale.py ===================================== @@ -89,8 +89,8 @@ 'required': ~Eval('state').in_( ['draft', 'quotation', 'cancelled']), }) - payment_term = fields.Many2One('account.invoice.payment_term', - 'Payment Term', + payment_term = fields.Many2One( + 'account.invoice.payment_term', "Payment Term", ondelete='RESTRICT', states={ 'readonly': Eval('state') != 'draft', }) ===================================== modules/sale_amendment/sale.py ===================================== @@ -212,7 +212,7 @@ }) payment_term = fields.Many2One( - 'account.invoice.payment_term', "Payment Term", + 'account.invoice.payment_term', "Payment Term", ondelete='RESTRICT', states={ 'invisible': Eval('action') != 'payment_term', }) ===================================== modules/sale_opportunity/opportunity.py ===================================== @@ -75,8 +75,9 @@ "Amount", currency='currency', digits='currency', states=_states_stop, help='Estimated revenue amount.') - payment_term = fields.Many2One('account.invoice.payment_term', - 'Payment Term', states={ + payment_term = fields.Many2One( + 'account.invoice.payment_term', "Payment Term", ondelete='RESTRICT', + states={ 'readonly': In(Eval('state'), ['converted', 'lost', 'cancelled']), }) ===================================== modules/sale_subscription/subscription.py ===================================== @@ -92,7 +92,7 @@ 'required': ~Eval('state').in_(['draft']), }) payment_term = fields.Many2One( - 'account.invoice.payment_term', "Payment Term", + 'account.invoice.payment_term', "Payment Term", ondelete='RESTRICT', states={ 'readonly': Eval('state') != 'draft', }) View it on Heptapod: https://foss.heptapod.net/tryton/tryton/-/commit/a77c3f67fbcbcbce21dd2ebce4b4d48ca4c17a42 -- View it on Heptapod: https://foss.heptapod.net/tryton/tryton/-/commit/a77c3f67fbcbcbce21dd2ebce4b4d48ca4c17a42 You're receiving this email because of your account on foss.heptapod.net.