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

Proposed by Vincent Renaville@camptocamp
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
Alexandre Fayolle - camptocamp code review, no test Approve
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

[FIX] set return value for _set_company_currency and syntax cleaning

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

LGTM

review: Approve (code review, tests)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'analytic_multicurrency/analytic.py'
--- analytic_multicurrency/analytic.py 2013-05-13 13:00:41 +0000
+++ analytic_multicurrency/analytic.py 2013-09-25 14:06:24 +0000
@@ -79,6 +79,26 @@
79 'balance', 'quantity'],79 'balance', 'quantity'],
80 context)80 context)
8181
82 def _set_company_currency(self, cr, uid, ids, name, value, arg, context=None):
83 if isinstance(ids, (int, long)):
84 ids = [ids]
85 if value:
86 return cr.execute("""update account_analytic_account set currency_id=%s
87 where id in %s""",
88 (value, tuple(ids), ))
89 else:
90 return False
91
92 def _currency(self, cr, uid, ids, field_name, arg, context=None):
93 result = {}
94 for rec in self.browse(cr, uid, ids, context=context):
95 result[rec.id] = rec.currency_id.id
96 return result
97
98 def _get_analytic_account(self, cr, uid, ids, context=None):
99 return super(account_analytic_account, self)._get_analytic_account(
100 cr, uid, ids, context=context)
101
82 _columns = {102 _columns = {
83 'balance': fields.function(_debit_credit_bal_qtty,103 'balance': fields.function(_debit_credit_bal_qtty,
84 type='float',104 type='float',
@@ -99,6 +119,13 @@
99 type='float',119 type='float',
100 string='Quantity',120 string='Quantity',
101 multi='debit_credit_bal_qtty'),121 multi='debit_credit_bal_qtty'),
122 # We overwrite function field currency_id to set a currency different
123 # from the one specified in the company
124 'currency_id': fields.function(_currency, fnct_inv=_set_company_currency,
125 store={
126 'res.company': (_get_analytic_account, ['currency_id'], 10),
127 }, string='Currency', type='many2one', relation='res.currency'),
128
102 }129 }
103130
104 # We remove the currency constraint cause we want to let the user131 # We remove the currency constraint cause we want to let the user

Subscribers

People subscribed via source and target branches

to status/vote changes: