Prevent deletion of payment terms in use

Closes #12085
This commit is contained in:
Maxime Richez
2023-02-21 12:55:12 +01:00
parent 16883f9579
commit 10466a9936
7 changed files with 14 additions and 11 deletions
+3 -2
View File
@@ -169,8 +169,9 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
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,
+3 -2
View File
@@ -92,8 +92,9 @@ class Purchase(
'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,
+1 -1
View File
@@ -196,7 +196,7 @@ class AmendmentLine(ModelSQL, ModelView):
})
payment_term = fields.Many2One(
'account.invoice.payment_term', "Payment Term",
'account.invoice.payment_term', "Payment Term", ondelete='RESTRICT',
states={
'invisible': Eval('action') != 'payment_term',
})
+2 -2
View File
@@ -89,8 +89,8 @@ class Sale(
'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',
})
+1 -1
View File
@@ -212,7 +212,7 @@ class AmendmentLine(ModelSQL, ModelView):
})
payment_term = fields.Many2One(
'account.invoice.payment_term', "Payment Term",
'account.invoice.payment_term', "Payment Term", ondelete='RESTRICT',
states={
'invisible': Eval('action') != 'payment_term',
})
+3 -2
View File
@@ -75,8 +75,9 @@ class SaleOpportunity(
"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']),
})
+1 -1
View File
@@ -92,7 +92,7 @@ class Subscription(Workflow, ModelSQL, ModelView):
'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',
})