Merge lp:~camptocamp/account-analytic/analytic_multicurrency_different_currency_vre into lp:~account-core-editors/account-analytic/7.0

Proposed by Vincent Renaville@camptocamp on 2013-09-20
Status: Merged
Merged at revision: 16
Proposed branch: lp:~camptocamp/account-analytic/analytic_multicurrency_different_currency_vre
Merge into: lp:~account-core-editors/account-analytic/7.0
Diff against target: 44 lines (+27/-0)
1 file modified
analytic_multicurrency/analytic.py (+27/-0)
To merge this branch: bzr merge lp:~camptocamp/account-analytic/analytic_multicurrency_different_currency_vre
Reviewer Review Type Date Requested Status
Joël Grand-Guillaume @ camptocamp code review, tests Approve on 2013-10-15
Alexandre Fayolle - camptocamp code review, no test 2013-09-20 Approve on 2013-09-25
Review via email: mp+186734@code.launchpad.net

Description of the change

Hello

This fix allow to set an different currency from the one specified in the company.

Vincent

To post a comment you must log in.
17. By Vincent Renaville@camptocamp on 2013-09-25

[FIX] set return value for _set_company_currency and syntax cleaning

LGTM

review: Approve (code review, no test)

LGTM

review: Approve (code review, tests)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'analytic_multicurrency/analytic.py'
2--- analytic_multicurrency/analytic.py 2013-05-13 13:00:41 +0000
3+++ analytic_multicurrency/analytic.py 2013-09-25 14:06:24 +0000
4@@ -79,6 +79,26 @@
5 'balance', 'quantity'],
6 context)
7
8+ def _set_company_currency(self, cr, uid, ids, name, value, arg, context=None):
9+ if isinstance(ids, (int, long)):
10+ ids = [ids]
11+ if value:
12+ return cr.execute("""update account_analytic_account set currency_id=%s
13+ where id in %s""",
14+ (value, tuple(ids), ))
15+ else:
16+ return False
17+
18+ def _currency(self, cr, uid, ids, field_name, arg, context=None):
19+ result = {}
20+ for rec in self.browse(cr, uid, ids, context=context):
21+ result[rec.id] = rec.currency_id.id
22+ return result
23+
24+ def _get_analytic_account(self, cr, uid, ids, context=None):
25+ return super(account_analytic_account, self)._get_analytic_account(
26+ cr, uid, ids, context=context)
27+
28 _columns = {
29 'balance': fields.function(_debit_credit_bal_qtty,
30 type='float',
31@@ -99,6 +119,13 @@
32 type='float',
33 string='Quantity',
34 multi='debit_credit_bal_qtty'),
35+ # We overwrite function field currency_id to set a currency different
36+ # from the one specified in the company
37+ 'currency_id': fields.function(_currency, fnct_inv=_set_company_currency,
38+ store={
39+ 'res.company': (_get_analytic_account, ['currency_id'], 10),
40+ }, string='Currency', type='many2one', relation='res.currency'),
41+
42 }
43
44 # We remove the currency constraint cause we want to let the user

Subscribers

People subscribed via source and target branches

to status/vote changes: