Browse Source

[FIX] correctly initialize options

pull/99/head
Holger Brunn 8 years ago
parent
commit
e7a69f02f5
No known key found for this signature in database GPG Key ID: 1C9760FECA3AE18
  1. 7
      account_bank_statement_import_auto_reconcile/models/account_bank_statement_import.py
  2. 14
      account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_auto_reconcile_rule.py
  3. 5
      account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_reapply_rules.py

7
account_bank_statement_import_auto_reconcile/models/account_bank_statement_import.py

@ -25,12 +25,7 @@ class AccountBankStatementImport(models.TransientModel):
): ):
return statement_id, notifications return statement_id, notifications
reconcile_rules = statement.journal_id\ 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 = [] auto_reconciled_ids = []
for line in statement.line_ids: for line in statement.line_ids:
for rule in reconcile_rules: for rule in reconcile_rules:

14
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: if field_name in values:
options[field_name] = values.pop(field_name) options[field_name] = values.pop(field_name)
values['options'] = options 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

5
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}) self.write({'journal_id': journal.id})
reconcile_rules = journal.statement_import_auto_reconcile_rule_ids\ 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([ for line in self.env['account.bank.statement.line'].search([
('statement_id', 'in', statements.ids), ('statement_id', 'in', statements.ids),

Loading…
Cancel
Save