Merge lp:~jfb-tempo-consulting/unifield-server/us-1766 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 3982
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/us-1766
Merge into: lp:unifield-server
Diff against target: 215 lines (+76/-13)
8 files modified
bin/addons/account_reconciliation/account_move_line.py (+6/-4)
bin/addons/analytic_distribution/account_move_line.py (+11/-2)
bin/addons/base/res/res_user.py (+4/-0)
bin/addons/msf_instance/add_instance.py (+12/-2)
bin/addons/msf_profile/data/patches.xml (+3/-0)
bin/addons/msf_profile/msf_profile.py (+26/-0)
bin/addons/res_currency_functional/account_move_line_compute_currency.py (+14/-2)
bin/addons/sync_client/update.py (+0/-3)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/us-1766
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+307794@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/account_reconciliation/account_move_line.py'
2--- bin/addons/account_reconciliation/account_move_line.py 2016-09-16 08:46:29 +0000
3+++ bin/addons/account_reconciliation/account_move_line.py 2016-10-06 07:22:07 +0000
4@@ -282,10 +282,12 @@
5
6 # US-533: date of JI reconciliation for total reconciliation linked
7 # with above (4, 0)
8- # US-1682: trigger FXA computation
9- self.pool.get('account.move.line').write(cr, uid, ids, {
10- 'reconcile_date': time.strftime('%Y-%m-%d'),
11- }, context=context)
12+ # bypass orm methods: for specific lines:
13+ # - US-1766 FXA AJI should not be recomputed
14+ # - US-1682 yealry REV JI have a dedicated rate
15+ cr.execute('update account_move_line set reconcile_date=%s where id in %s',
16+ (time.strftime('%Y-%m-%d'), tuple(ids))
17+ )
18
19 # UF-2011: synchronize move lines (not "marked" after reconcile creation)
20 if self.pool.get('sync.client.orm_extended'):
21
22=== modified file 'bin/addons/analytic_distribution/account_move_line.py'
23--- bin/addons/analytic_distribution/account_move_line.py 2016-09-21 15:55:54 +0000
24+++ bin/addons/analytic_distribution/account_move_line.py 2016-10-06 07:22:07 +0000
25@@ -146,6 +146,7 @@
26 'is_revaluated_ok',
27 'debit',
28 'credit',
29+ 'is_addendum_line',
30 ]
31
32 for obj_line in self.read(cr, uid, ids, obj_fields, context=context):
33@@ -203,11 +204,19 @@
34 aji_greater_amount['is'] = True
35 else:
36 aji_greater_amount['is'] = False
37+ analytic_currency_id = obj_line.get('currency_id', [False])[0]
38+ amount_aji_book = -1 * anal_amount_rounded
39 # functional amount
40 if obj_line.get('is_revaluated_ok'):
41 # (US-1682) if it's a revaluation line get the functional amount directly from the JI
42 # to avoid slight differences between JI and AJI amounts caused by computation
43 amount_aji_fctal = -1 * distrib_line.percentage * amount_ji_fctal / 100
44+ elif obj_line.get('is_addendum_line'):
45+ # US-1766: AJIs linked to FXA entry should have fct amount = booking amount
46+ # and book currency = fct currency
47+ analytic_currency_id = company_currency
48+ amount_aji_fctal = -1 * distrib_line.percentage * amount_ji_fctal / 100
49+ amount_aji_book = -1 * distrib_line.percentage * amount_ji_fctal / 100
50 else:
51 amount_aji_fctal = -1 * self.pool.get('res.currency').compute(
52 cr, uid, obj_line.get('currency_id', [False])[0], company_currency, anal_amount,
53@@ -218,13 +227,13 @@
54 'ref': obj_line.get('ref', False),
55 'journal_id': journal.get('analytic_journal_id', [False])[0],
56 'amount': amount_aji_fctal,
57- 'amount_currency': -1 * anal_amount_rounded, # booking amount
58+ 'amount_currency': amount_aji_book, # booking amount
59 'account_id': distrib_line.analytic_id.id,
60 'general_account_id': account.get('id'),
61 'move_id': obj_line.get('id'),
62 'distribution_id': distrib_obj.id,
63 'user_id': uid,
64- 'currency_id': obj_line.get('currency_id', [False])[0],
65+ 'currency_id': analytic_currency_id,
66 'distrib_line_id': '%s,%s'%(distrib_line._name, distrib_line.id),
67 'document_date': obj_line.get('document_date', False),
68 'source_date': obj_line.get('source_date', False) or obj_line.get('date', False), # UFTP-361 source_date from date if not any (posting date)
69
70=== modified file 'bin/addons/base/res/res_user.py'
71--- bin/addons/base/res/res_user.py 2016-08-26 15:48:03 +0000
72+++ bin/addons/base/res/res_user.py 2016-10-06 07:22:07 +0000
73@@ -129,6 +129,10 @@
74 cr.execute('select company_id, res_company.name from res_users left join res_company on res_company.id = company_id where res_users.id=%s' %uid)
75 return cr.fetchall()
76
77+ def get_company_currency_id(self, cr, uid):
78+ user = self.browse(cr, uid, uid, fields_to_fetch=['company_id'])
79+ return user.company_id and user.company_id.currency_id and user.company_id.currency_id.id or False
80+
81 def send_welcome_email(self, cr, uid, id, context=None):
82 logger= netsvc.Logger()
83 user = self.pool.get('res.users').read(cr, uid, id, context=context)
84
85=== modified file 'bin/addons/msf_instance/add_instance.py'
86--- bin/addons/msf_instance/add_instance.py 2016-08-23 12:54:03 +0000
87+++ bin/addons/msf_instance/add_instance.py 2016-10-06 07:22:07 +0000
88@@ -262,16 +262,26 @@
89
90 def create(self, cr, uid, vals, context=None):
91 if 'journal_id' in vals:
92- journal = self.pool.get('account.analytic.journal').read(cr, uid, vals['journal_id'], ['instance_id'], context=context)
93+ journal = self.pool.get('account.analytic.journal').read(cr, uid, vals['journal_id'], ['instance_id', 'type'], context=context)
94 vals['instance_id'] = journal.get('instance_id')[0]
95+ # US-1766: in pipe FXA sync update: force currency
96+ if journal['type'] == 'cur_adj':
97+ currency = self.pool.get('res.users').get_company_currency_id(cr, uid)
98+ if currency:
99+ vals['currency_id'] = currency
100 return super(account_analytic_line, self).create(cr, uid, vals, context=context)
101
102 def write(self, cr, uid, ids, vals, context=None):
103 if not ids:
104 return True
105 if 'journal_id' in vals:
106- journal = self.pool.get('account.analytic.journal').read(cr, uid, vals['journal_id'], ['instance_id'], context=context)
107+ journal = self.pool.get('account.analytic.journal').read(cr, uid, vals['journal_id'], ['instance_id', 'type'], context=context)
108 vals['instance_id'] = journal.get('instance_id')[0]
109+ # US-1766: in pipe FXA sync update: force currency
110+ if journal['type'] == 'cur_adj':
111+ currency = self.pool.get('res.users').get_company_currency_id(cr, uid)
112+ if currency:
113+ vals['currency_id'] = currency
114 return super(account_analytic_line, self).write(cr, uid, ids, vals, context=context)
115
116 def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
117
118=== modified file 'bin/addons/msf_profile/data/patches.xml'
119--- bin/addons/msf_profile/data/patches.xml 2016-09-26 10:03:42 +0000
120+++ bin/addons/msf_profile/data/patches.xml 2016-10-06 07:22:07 +0000
121@@ -107,5 +107,8 @@
122 <field name="method">us_1732_sync_state_ud</field>
123 </record>
124
125+ <record id="us_1766_fix_fxa_aji_curr" model="patch.scripts">
126+ <field name="method">us_1766_fix_fxa_aji_curr</field>
127+ </record>
128 </data>
129 </openerp>
130
131=== modified file 'bin/addons/msf_profile/msf_profile.py'
132--- bin/addons/msf_profile/msf_profile.py 2016-09-27 08:48:13 +0000
133+++ bin/addons/msf_profile/msf_profile.py 2016-10-06 07:22:07 +0000
134@@ -865,6 +865,32 @@
135 SELECT id FROM product_product WHERE state_ud IS NOT NULL
136 )""")
137
138+ def us_1766_fix_fxa_aji_curr(self, cr, uid, *a, **b):
139+ """
140+ Fix FXA AJIs:
141+ - set book currency = fct currency
142+ - set book amount = fct amount
143+ """
144+ context = {}
145+ logger = logging.getLogger('fix_us_1766')
146+ user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
147+ currency_id = user.company_id.currency_id and user.company_id.currency_id.id or False
148+
149+ if currency_id:
150+ journal_ids = self.pool.get('account.analytic.journal').search(cr, uid, [('type', '=', 'cur_adj'), ('active', 'in', ['t', 'f'])])
151+ if journal_ids:
152+ cr.execute("""select entry_sequence from account_analytic_line
153+ where journal_id in %s and
154+ currency_id != %s """, (tuple(journal_ids), currency_id))
155+ all_seq = [x[0] for x in cr.fetchall()]
156+ logger.warn('Fix %d FXA AJIs: %s' % (len(all_seq), ','.join(all_seq)))
157+ cr.execute("""update account_analytic_line set
158+ currency_id = %s,
159+ amount = amount_currency
160+ where journal_id in %s and
161+ currency_id != %s""", (currency_id, tuple(journal_ids), currency_id))
162+
163+
164 patch_scripts()
165
166
167
168=== modified file 'bin/addons/res_currency_functional/account_move_line_compute_currency.py'
169--- bin/addons/res_currency_functional/account_move_line_compute_currency.py 2016-09-29 16:26:19 +0000
170+++ bin/addons/res_currency_functional/account_move_line_compute_currency.py 2016-10-06 07:22:07 +0000
171@@ -330,7 +330,7 @@
172 cr.execute(sql, [0.0, 0.0, 0.0, partner_db or 0.0, partner_cr or 0.0, tuple([o.id])])
173 # Update analytic lines
174 analytic_line_ids = al_obj.search(cr, uid, [('move_id', 'in', other_line_ids)], context=context)
175- al_obj.write(cr, uid, analytic_line_ids, {'amount': -1*total, 'amount_currency': -1*total,}, context=context)
176+ al_obj.write(cr, uid, analytic_line_ids, {'amount': -1*total, 'amount_currency': -1*total, 'currency_id': al.functional_currency_id.id}, context=context)
177 # Update Addendum line that's not reconciled
178 addendum_counterpart_ids = self.search(cr, uid, [('move_id', '=', al.move_id.id), ('id', '!=', al.id), ('is_addendum_line', '=', True)])
179 if not addendum_counterpart_ids:
180@@ -367,8 +367,20 @@
181 from_another_instance = True
182 if multi_instance and (from_sync or from_another_instance):
183 continue
184+
185+
186+ # create_addendum_line: we need a context (if currency_table is used by yearly reval US-1682)
187+ # but this context should not contain any sync value or FXA JI/AJI is not well created in some use case
188+ # for example: create func. unbalanced entries at proj, sync to coordo and reconcile at coordo
189+ # when reconcilation is received at project, FXA entries should be created (UF-2501)
190+ new_ctx = context.copy()
191+ for sync_context_key in ('sync_update_execution', 'do_not_create_analytic_line', 'update_mode'):
192+ if new_ctx.get(sync_context_key):
193+ del new_ctx[sync_context_key]
194+
195+
196 # If no exception, do main process about new addendum lines
197- partner_line_id = self.create_addendum_line(cr, uid, reconciled_line_ids, total, context=context)
198+ partner_line_id = self.create_addendum_line(cr, uid, reconciled_line_ids, total, context=new_ctx)
199 if partner_line_id:
200 # Add it to reconciliation (same that other lines)
201 reconcile_txt = ''
202
203=== modified file 'bin/addons/sync_client/update.py'
204--- bin/addons/sync_client/update.py 2016-09-26 09:43:26 +0000
205+++ bin/addons/sync_client/update.py 2016-10-06 07:22:07 +0000
206@@ -311,9 +311,6 @@
207 'editable' : fields.boolean("Set editable"),
208 }
209
210- _defaults = {
211- 'log_first_notrun': '',
212- }
213 line_error_re = re.compile(r"^Line\s+(\d+)\s*:\s*(.+)", re.S)
214
215 _logger = logging.getLogger('sync.client')

Subscribers

People subscribed via source and target branches