Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits: 498d55bc by Cédric Krier at 2023-05-04T14:40:42+02:00 Permit to customize field to skip for company rules - - - - - ec1e1175 by Cédric Krier at 2023-05-04T14:42:40+02:00 Test account consolidation with company tests - - - - - 2 changed files: - modules/account_consolidation/tests/test_module.py - modules/company/tests/test_module.py Changes: ===================================== modules/account_consolidation/tests/test_module.py ===================================== @@ -1,5 +1,6 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. +from trytond.modules.company.tests import CompanyTestMixin from trytond.tests.test_tryton import ModuleTestCase @@ -3,7 +4,18 @@ from trytond.tests.test_tryton import ModuleTestCase -class AccountConsolidationTestCase(ModuleTestCase): +class CompanyAcountConsolidationTestMixin(CompanyTestMixin): + + @property + def _skip_company_rule(self): + return super()._skip_company_rule | { + ('account.move', 'consolidation_company'), + ('account.invoice', 'consolidation_company'), + } + + +class AccountConsolidationTestCase( + CompanyAcountConsolidationTestMixin, ModuleTestCase): "Test Account Consolidation module" module = 'account_consolidation' extras = ['account_invoice'] ===================================== modules/company/tests/test_module.py ===================================== @@ -97,9 +97,18 @@ 'in "%s"."%s" context' % ( company, mname, fname)) + @property + def _skip_company_rule(self): + """Return a set of couple field name and model name + for which no company rules are needed.""" + return { + ('company.employee', 'company'), + ('res.user', 'company'), + } + @with_transaction() def test_company_rule(self): "Test missing company rule" pool = Pool() Rule = pool.get('ir.rule') Company = pool.get('company.company') @@ -100,14 +109,12 @@ @with_transaction() def test_company_rule(self): "Test missing company rule" pool = Pool() Rule = pool.get('ir.rule') Company = pool.get('company.company') - Employee = pool.get('company.employee') - User = pool.get('res.user') to_check = defaultdict(set) for mname, model in pool.iterobject(): if (not isregisteredby(model, self.module) or model.__access__ or not (issubclass(model, ModelView) @@ -108,10 +115,9 @@ to_check = defaultdict(set) for mname, model in pool.iterobject(): if (not isregisteredby(model, self.module) or model.__access__ or not (issubclass(model, ModelView) - and issubclass(model, ModelStorage)) - or issubclass(model, (Company, Employee, User))): + and issubclass(model, ModelStorage))): continue for fname, field in model._fields.items(): @@ -116,5 +122,7 @@ continue for fname, field in model._fields.items(): + if (mname, fname) in self._skip_company_rule: + continue if (field._type == 'many2one' and issubclass(field.get_target(), Company)): to_check[fname].add(mname) @@ -131,5 +139,5 @@ ]) with_rules = {r.rule_group.model.model for r in rules} self.assertGreaterEqual(with_rules, models, - msg='Models "%(models)s" are missing a global rule ' + msg='Models %(models)s are missing a global rule ' 'for field "%(field)s"' % { @@ -135,5 +143,6 @@ 'for field "%(field)s"' % { - 'models': ', '.join(models - with_rules), + 'models': ', '.join( + f'"{m}"' for m in (models - with_rules)), 'field': fname, }) View it on Heptapod: https://foss.heptapod.net/tryton/tryton/-/compare/d0f41f64e65a783ffb824dbf33ee9e6e399502c6...ec1e1175a6c5fe33ccc896702893a07f51eaabcd -- View it on Heptapod: https://foss.heptapod.net/tryton/tryton/-/compare/d0f41f64e65a783ffb824dbf33ee9e6e399502c6...ec1e1175a6c5fe33ccc896702893a07f51eaabcd You're receiving this email because of your account on foss.heptapod.net.