Enforce same type for children account as their parent

issue11143
review384081002
This commit is contained in:
Cédric Krier
2022-02-13 01:33:15 +01:00
parent 63d3e70f3c
commit 83aa9e1d5f
3 changed files with 25 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
* Enforce same type for children account as their parent
* Show debit / credit columns in ledgers when they contain lines
* Count number of lines in Account and General Ledger
* Handle errors in move template expression
+23
View File
@@ -544,6 +544,29 @@ def AccountMixin(template=False):
depends=['type']),
'on_change_with_deferral', searcher='search_deferral')
@classmethod
def __setup__(cls):
super().__setup__()
if not cls.childs.domain:
cls.childs.domain = []
for type_ in ['type', 'debit_type']:
field = getattr(cls, type_)
field.domain = [
If(Eval('parent')
& Eval('_parent_parent.%s' % type_)
& Eval('_parent_parent.parent'),
('id', '=', Eval('_parent_parent.%s' % type_)),
()),
]
field.depends.append('parent')
cls.childs.domain.append(
If(Eval(type_),
(type_, '=', Eval(type_)),
()))
cls.childs.depends.append(type_)
@classmethod
def default_closed(cls):
return False
+1
View File
@@ -1539,6 +1539,7 @@ class AccountTestCase(
updated_account.code = 'REV'
updated_account.name = 'Updated Account'
updated_account.parent = new_account
updated_account.type = new_account.type
updated_account.reconcile = True
updated_account.end_date = datetime.date.today()
updated_account.taxes = [updated_tax]