mirror of
https://github.com/NaN-tic/trytond-account_invoice_consecutive.git
synced 2023-12-13 20:50:10 +01:00
Make date readonly when the number is already set
Is should not be possible to modify the invoice_date when a number is set, otherwise it should be possible to make an invoice which is not consecutive because we only check it when creating the number.
This commit is contained in:
parent
d9cf25e165
commit
c92fc53cba
1 changed files with 10 additions and 0 deletions
10
invoice.py
10
invoice.py
|
@ -2,6 +2,7 @@
|
|||
# the full copyright notices and license terms.
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Bool, Eval
|
||||
|
||||
__all__ = ['Invoice']
|
||||
|
||||
|
@ -24,6 +25,15 @@ class Invoice:
|
|||
'permitted, because of invoice number and date '
|
||||
'correlation.',
|
||||
})
|
||||
if 'number' not in cls.invoice_date.depends:
|
||||
new_readonly = Bool(Eval('number'))
|
||||
readonly = cls.invoice_date.states.get('readonly')
|
||||
if readonly:
|
||||
new_readonly |= readonly
|
||||
cls.invoice_date.states.update({
|
||||
'readonly': new_readonly,
|
||||
})
|
||||
cls.invoice_date.depends.append('number')
|
||||
|
||||
@classmethod
|
||||
def validate(cls, invoices):
|
||||
|
|
Loading…
Reference in a new issue