From 75762a6c1fbcd1959a7d79941b724c5fdb5a0b98 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 3 Jul 2018 09:10:50 +0200 Subject: [PATCH] fixup! [FIX] correctly initialize options --- ..._bank_statement_import_auto_reconcile_rule.py | 11 +++++++---- ...count_bank_statement_import_auto_reconcile.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_auto_reconcile_rule.py b/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_auto_reconcile_rule.py index 314e112..b37aa19 100644 --- a/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_auto_reconcile_rule.py +++ b/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_auto_reconcile_rule.py @@ -142,10 +142,13 @@ class AccountBankStatementImportAutoReconcileRule(models.Model): def get_rules(self): """Return a NewId object for the configured rule""" rules = self.mapped( - lambda x: self.env[x.rule_type].new({ - 'wizard_id': self.id, - 'options': x.options - }) + lambda x: self.env[x.rule_type].new(dict( + self.env[x.rule_type].default_get( + self.env[x.rule_type]._fields.keys() + ), + wizard_id=self.id, + options=x.options, + )) if x else None ) for rule in rules: diff --git a/account_bank_statement_import_auto_reconcile/tests/test_account_bank_statement_import_auto_reconcile.py b/account_bank_statement_import_auto_reconcile/tests/test_account_bank_statement_import_auto_reconcile.py index 06994d8..b374f27 100644 --- a/account_bank_statement_import_auto_reconcile/tests/test_account_bank_statement_import_auto_reconcile.py +++ b/account_bank_statement_import_auto_reconcile/tests/test_account_bank_statement_import_auto_reconcile.py @@ -85,3 +85,19 @@ class TestAccountBankStatementImportAutoReconcile(TransactionCase): 'auto_reconcile': True, }).import_file() self.assertEqual(self.invoice.state, 'paid') + + def test_rule_options(self): + self.rule.unlink() + rule = self.env[ + 'account.bank.statement.import.auto.reconcile.rule' + ].create({ + 'journal_id': self.env.ref('account.bank_journal').id, + 'rule_type': + 'account.bank.statement.import.auto.reconcile.exact.amount', + 'match_st_name': False, + }) + rules = rule.get_rules() + # explicitly written + self.assertFalse(rules.match_st_name) + # defaults must be used here too + self.assertTrue(rules.match_st_ref)