From 1c66e3c3951fdd4eb88e3fac49a195cff4d50c11 Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Mon, 16 Dec 2013 14:55:56 +0100 Subject: [PATCH 1/2] [fix] account_statement_ext: unwind related and stored field because it does not work in a constraint in YAML test, for some reason. This probably needs a more general solution. --- account_statement_ext/statement.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/account_statement_ext/statement.py b/account_statement_ext/statement.py index 4775362b..54857212 100644 --- a/account_statement_ext/statement.py +++ b/account_statement_ext/statement.py @@ -223,12 +223,21 @@ class AccountBankSatement(Model): move of period_id to the statement line """ for statement in self.browse(cr, uid, ids, context=context): - if (statement.period_id and - statement.company_id.id != statement.period_id.company_id.id): + # statement.company_id is a related store=True that for some + # reason doesn't work in YAML tests. As a workaround, I unwind it + # to statement.journal_id.company_id here. + if ( + statement.period_id + and statement.journal_id.company_id.id + != statement.period_id.company_id.id + ): return False for line in statement.line_ids: - if (line.period_id and - statement.company_id.id != line.period_id.company_id.id): + if ( + line.period_id + and statement.journal_id.company_id.id + != line.period_id.company_id.id + ): return False return True From 8a46f556f1f93590150a202d4e7e8fdb3c1d4aa8 Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Thu, 19 Dec 2013 11:13:30 +0100 Subject: [PATCH 2/2] [imp] pep8 --- account_statement_ext/statement.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/account_statement_ext/statement.py b/account_statement_ext/statement.py index 54857212..392e0b9d 100644 --- a/account_statement_ext/statement.py +++ b/account_statement_ext/statement.py @@ -226,18 +226,14 @@ class AccountBankSatement(Model): # statement.company_id is a related store=True that for some # reason doesn't work in YAML tests. As a workaround, I unwind it # to statement.journal_id.company_id here. - if ( - statement.period_id - and statement.journal_id.company_id.id - != statement.period_id.company_id.id - ): + if (statement.period_id and + statement.journal_id.company_id.id != + statement.period_id.company_id.id): return False for line in statement.line_ids: - if ( - line.period_id - and statement.journal_id.company_id.id - != line.period_id.company_id.id - ): + if (line.period_id and + statement.journal_id.company_id.id + != line.period_id.company_id.id): return False return True