Merge lp:~therp-nl/openupgrade-addons/7.0-fix_move_line_currency into lp:openupgrade-addons

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 8142
Proposed branch: lp:~therp-nl/openupgrade-addons/7.0-fix_move_line_currency
Merge into: lp:openupgrade-addons
Diff against target: 29 lines (+18/-0)
1 file modified
account/migrations/7.0.1.1/pre-migration.py (+18/-0)
To merge this branch: bzr merge lp:~therp-nl/openupgrade-addons/7.0-fix_move_line_currency
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Review via email: mp+186742@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sylvain LE GAL (GRAP) (sylvain-legal) wrote :

It's OK for me.

However, when testing (rapid test), I didn't have the case with account_move_line with currency defined in 6.1. (The old values was Null).
What is the user case to have account_move_line with currency_id set ?

@Reviewers : the new constraints is _check_currency_company in account/account_move_line.py

review: Needs Information (code review & test)
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

> What is the user case to have account_move_line with currency_id set ?

Confirming a bank statement with currency set to the company currency
(using banking addons, but the code that set the move line currency was
native)

Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/migrations/7.0.1.1/pre-migration.py'
2--- account/migrations/7.0.1.1/pre-migration.py 2013-09-09 20:56:30 +0000
3+++ account/migrations/7.0.1.1/pre-migration.py 2013-09-20 10:30:53 +0000
4@@ -45,7 +45,25 @@
5 ('account.account_payment_term_15days', 'account.account_payment_term'),
6 ]
7
8+def fix_move_line_currency(cr):
9+ """
10+ In OpenERP 7.0, there is a new constraint on move lines
11+ having their currency set to the company currency.
12+ These would be happily created in OpenERP 6.1, specifically
13+ from bank statements.
14+ """
15+ openupgrade.logged_query(
16+ cr,
17+ """
18+ UPDATE account_move_line l
19+ SET currency_id = NULL
20+ FROM res_company c
21+ WHERE l.company_id = c.id
22+ AND l.currency_id = c.currency_id;
23+ """)
24+
25 @openupgrade.migrate()
26 def migrate(cr, version):
27 openupgrade.rename_columns(cr, column_renames)
28 openupgrade.rename_xmlids(cr, xmlid_renames)
29+ fix_move_line_currency(cr)

Subscribers

People subscribed via source and target branches