diff --git a/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import.py b/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import.py index f54f1e9..928c544 100644 --- a/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import.py +++ b/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import.py @@ -25,12 +25,7 @@ class AccountBankStatementImport(models.TransientModel): ): return statement_id, notifications reconcile_rules = statement.journal_id\ - .statement_import_auto_reconcile_rule_ids.mapped( - lambda x: self.env[x.rule_type].new({ - 'wizard_id': self.id, - 'options': x.options - }) - ) + .statement_import_auto_reconcile_rule_ids.get_rules() auto_reconciled_ids = [] for line in statement.line_ids: for rule in reconcile_rules: 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 790bcbf..314e112 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 @@ -137,3 +137,17 @@ class AccountBankStatementImportAutoReconcileRule(models.Model): if field_name in values: options[field_name] = values.pop(field_name) values['options'] = options + + @api.multi + 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 + }) + if x else None + ) + for rule in rules: + rule.update(rule.options) + return rules diff --git a/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_reapply_rules.py b/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_reapply_rules.py index 0ab88a4..e620fac 100644 --- a/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_reapply_rules.py +++ b/account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_reapply_rules.py @@ -25,10 +25,7 @@ class AccountBankStatementImportReapplyRules(models.TransientModel): self.write({'journal_id': journal.id}) reconcile_rules = journal.statement_import_auto_reconcile_rule_ids\ - .mapped(lambda x: self.env[x.rule_type].new({ - 'wizard_id': self.id, - 'options': x.options - })) + .get_rules() for line in self.env['account.bank.statement.line'].search([ ('statement_id', 'in', statements.ids),