block change account to kind view if account have been move
This commit is contained in:
parent
24787001ac
commit
2d7afb45ca
17
account.py
17
account.py
|
@ -159,6 +159,7 @@ class Account(metaclass=PoolMeta):
|
|||
super(Account, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'bad_operation': ('Operación No permitida.'),
|
||||
'dont_write_account': ('Dont write account "%(account)s" to kind view because have moves.'),
|
||||
})
|
||||
|
||||
@classmethod
|
||||
|
@ -166,6 +167,22 @@ class Account(metaclass=PoolMeta):
|
|||
cls.raise_user_error('bad_operation')
|
||||
return super(Account, cls).copy(records, default=default)
|
||||
|
||||
@classmethod
|
||||
def validate(cls, accounts):
|
||||
super(Account, cls).validate(accounts)
|
||||
cls.check_account_to_write(accounts)
|
||||
|
||||
@classmethod
|
||||
def check_account_to_write(cls, accounts):
|
||||
pool = Pool()
|
||||
Line = pool.get('account.move.line')
|
||||
for account in accounts:
|
||||
lines = Line.search([('account', '=', account.id)])
|
||||
if account.kind == 'view' and lines:
|
||||
cls.raise_user_error('dont_write_account', {
|
||||
'account': account.rec_name,
|
||||
})
|
||||
|
||||
|
||||
class AuxiliaryBookStart(ModelView):
|
||||
'Auxiliary Book Start'
|
||||
|
|
Loading…
Reference in New Issue