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
=== modified file 'bin/addons/account_reconciliation/account_move_line.py'
--- bin/addons/account_reconciliation/account_move_line.py 2016-09-16 08:46:29 +0000
+++ bin/addons/account_reconciliation/account_move_line.py 2016-10-06 07:22:07 +0000
@@ -282,10 +282,12 @@
282282
283 # US-533: date of JI reconciliation for total reconciliation linked283 # US-533: date of JI reconciliation for total reconciliation linked
284 # with above (4, 0)284 # with above (4, 0)
285 # US-1682: trigger FXA computation285 # bypass orm methods: for specific lines:
286 self.pool.get('account.move.line').write(cr, uid, ids, {286 # - US-1766 FXA AJI should not be recomputed
287 'reconcile_date': time.strftime('%Y-%m-%d'),287 # - US-1682 yealry REV JI have a dedicated rate
288 }, context=context)288 cr.execute('update account_move_line set reconcile_date=%s where id in %s',
289 (time.strftime('%Y-%m-%d'), tuple(ids))
290 )
289291
290 # UF-2011: synchronize move lines (not "marked" after reconcile creation)292 # UF-2011: synchronize move lines (not "marked" after reconcile creation)
291 if self.pool.get('sync.client.orm_extended'):293 if self.pool.get('sync.client.orm_extended'):
292294
=== modified file 'bin/addons/analytic_distribution/account_move_line.py'
--- bin/addons/analytic_distribution/account_move_line.py 2016-09-21 15:55:54 +0000
+++ bin/addons/analytic_distribution/account_move_line.py 2016-10-06 07:22:07 +0000
@@ -146,6 +146,7 @@
146 'is_revaluated_ok',146 'is_revaluated_ok',
147 'debit',147 'debit',
148 'credit',148 'credit',
149 'is_addendum_line',
149 ]150 ]
150151
151 for obj_line in self.read(cr, uid, ids, obj_fields, context=context):152 for obj_line in self.read(cr, uid, ids, obj_fields, context=context):
@@ -203,11 +204,19 @@
203 aji_greater_amount['is'] = True204 aji_greater_amount['is'] = True
204 else:205 else:
205 aji_greater_amount['is'] = False206 aji_greater_amount['is'] = False
207 analytic_currency_id = obj_line.get('currency_id', [False])[0]
208 amount_aji_book = -1 * anal_amount_rounded
206 # functional amount209 # functional amount
207 if obj_line.get('is_revaluated_ok'):210 if obj_line.get('is_revaluated_ok'):
208 # (US-1682) if it's a revaluation line get the functional amount directly from the JI211 # (US-1682) if it's a revaluation line get the functional amount directly from the JI
209 # to avoid slight differences between JI and AJI amounts caused by computation212 # to avoid slight differences between JI and AJI amounts caused by computation
210 amount_aji_fctal = -1 * distrib_line.percentage * amount_ji_fctal / 100213 amount_aji_fctal = -1 * distrib_line.percentage * amount_ji_fctal / 100
214 elif obj_line.get('is_addendum_line'):
215 # US-1766: AJIs linked to FXA entry should have fct amount = booking amount
216 # and book currency = fct currency
217 analytic_currency_id = company_currency
218 amount_aji_fctal = -1 * distrib_line.percentage * amount_ji_fctal / 100
219 amount_aji_book = -1 * distrib_line.percentage * amount_ji_fctal / 100
211 else:220 else:
212 amount_aji_fctal = -1 * self.pool.get('res.currency').compute(221 amount_aji_fctal = -1 * self.pool.get('res.currency').compute(
213 cr, uid, obj_line.get('currency_id', [False])[0], company_currency, anal_amount,222 cr, uid, obj_line.get('currency_id', [False])[0], company_currency, anal_amount,
@@ -218,13 +227,13 @@
218 'ref': obj_line.get('ref', False),227 'ref': obj_line.get('ref', False),
219 'journal_id': journal.get('analytic_journal_id', [False])[0],228 'journal_id': journal.get('analytic_journal_id', [False])[0],
220 'amount': amount_aji_fctal,229 'amount': amount_aji_fctal,
221 'amount_currency': -1 * anal_amount_rounded, # booking amount230 'amount_currency': amount_aji_book, # booking amount
222 'account_id': distrib_line.analytic_id.id,231 'account_id': distrib_line.analytic_id.id,
223 'general_account_id': account.get('id'),232 'general_account_id': account.get('id'),
224 'move_id': obj_line.get('id'),233 'move_id': obj_line.get('id'),
225 'distribution_id': distrib_obj.id,234 'distribution_id': distrib_obj.id,
226 'user_id': uid,235 'user_id': uid,
227 'currency_id': obj_line.get('currency_id', [False])[0],236 'currency_id': analytic_currency_id,
228 'distrib_line_id': '%s,%s'%(distrib_line._name, distrib_line.id),237 'distrib_line_id': '%s,%s'%(distrib_line._name, distrib_line.id),
229 'document_date': obj_line.get('document_date', False),238 'document_date': obj_line.get('document_date', False),
230 '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)239 '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)
231240
=== modified file 'bin/addons/base/res/res_user.py'
--- bin/addons/base/res/res_user.py 2016-08-26 15:48:03 +0000
+++ bin/addons/base/res/res_user.py 2016-10-06 07:22:07 +0000
@@ -129,6 +129,10 @@
129 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)129 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)
130 return cr.fetchall()130 return cr.fetchall()
131131
132 def get_company_currency_id(self, cr, uid):
133 user = self.browse(cr, uid, uid, fields_to_fetch=['company_id'])
134 return user.company_id and user.company_id.currency_id and user.company_id.currency_id.id or False
135
132 def send_welcome_email(self, cr, uid, id, context=None):136 def send_welcome_email(self, cr, uid, id, context=None):
133 logger= netsvc.Logger()137 logger= netsvc.Logger()
134 user = self.pool.get('res.users').read(cr, uid, id, context=context)138 user = self.pool.get('res.users').read(cr, uid, id, context=context)
135139
=== modified file 'bin/addons/msf_instance/add_instance.py'
--- bin/addons/msf_instance/add_instance.py 2016-08-23 12:54:03 +0000
+++ bin/addons/msf_instance/add_instance.py 2016-10-06 07:22:07 +0000
@@ -262,16 +262,26 @@
262262
263 def create(self, cr, uid, vals, context=None):263 def create(self, cr, uid, vals, context=None):
264 if 'journal_id' in vals:264 if 'journal_id' in vals:
265 journal = self.pool.get('account.analytic.journal').read(cr, uid, vals['journal_id'], ['instance_id'], context=context)265 journal = self.pool.get('account.analytic.journal').read(cr, uid, vals['journal_id'], ['instance_id', 'type'], context=context)
266 vals['instance_id'] = journal.get('instance_id')[0]266 vals['instance_id'] = journal.get('instance_id')[0]
267 # US-1766: in pipe FXA sync update: force currency
268 if journal['type'] == 'cur_adj':
269 currency = self.pool.get('res.users').get_company_currency_id(cr, uid)
270 if currency:
271 vals['currency_id'] = currency
267 return super(account_analytic_line, self).create(cr, uid, vals, context=context)272 return super(account_analytic_line, self).create(cr, uid, vals, context=context)
268273
269 def write(self, cr, uid, ids, vals, context=None):274 def write(self, cr, uid, ids, vals, context=None):
270 if not ids:275 if not ids:
271 return True276 return True
272 if 'journal_id' in vals:277 if 'journal_id' in vals:
273 journal = self.pool.get('account.analytic.journal').read(cr, uid, vals['journal_id'], ['instance_id'], context=context)278 journal = self.pool.get('account.analytic.journal').read(cr, uid, vals['journal_id'], ['instance_id', 'type'], context=context)
274 vals['instance_id'] = journal.get('instance_id')[0]279 vals['instance_id'] = journal.get('instance_id')[0]
280 # US-1766: in pipe FXA sync update: force currency
281 if journal['type'] == 'cur_adj':
282 currency = self.pool.get('res.users').get_company_currency_id(cr, uid)
283 if currency:
284 vals['currency_id'] = currency
275 return super(account_analytic_line, self).write(cr, uid, ids, vals, context=context)285 return super(account_analytic_line, self).write(cr, uid, ids, vals, context=context)
276286
277 def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):287 def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
278288
=== modified file 'bin/addons/msf_profile/data/patches.xml'
--- bin/addons/msf_profile/data/patches.xml 2016-09-26 10:03:42 +0000
+++ bin/addons/msf_profile/data/patches.xml 2016-10-06 07:22:07 +0000
@@ -107,5 +107,8 @@
107 <field name="method">us_1732_sync_state_ud</field>107 <field name="method">us_1732_sync_state_ud</field>
108 </record>108 </record>
109109
110 <record id="us_1766_fix_fxa_aji_curr" model="patch.scripts">
111 <field name="method">us_1766_fix_fxa_aji_curr</field>
112 </record>
110 </data>113 </data>
111</openerp>114</openerp>
112115
=== modified file 'bin/addons/msf_profile/msf_profile.py'
--- bin/addons/msf_profile/msf_profile.py 2016-09-27 08:48:13 +0000
+++ bin/addons/msf_profile/msf_profile.py 2016-10-06 07:22:07 +0000
@@ -865,6 +865,32 @@
865 SELECT id FROM product_product WHERE state_ud IS NOT NULL865 SELECT id FROM product_product WHERE state_ud IS NOT NULL
866 )""")866 )""")
867867
868 def us_1766_fix_fxa_aji_curr(self, cr, uid, *a, **b):
869 """
870 Fix FXA AJIs:
871 - set book currency = fct currency
872 - set book amount = fct amount
873 """
874 context = {}
875 logger = logging.getLogger('fix_us_1766')
876 user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
877 currency_id = user.company_id.currency_id and user.company_id.currency_id.id or False
878
879 if currency_id:
880 journal_ids = self.pool.get('account.analytic.journal').search(cr, uid, [('type', '=', 'cur_adj'), ('active', 'in', ['t', 'f'])])
881 if journal_ids:
882 cr.execute("""select entry_sequence from account_analytic_line
883 where journal_id in %s and
884 currency_id != %s """, (tuple(journal_ids), currency_id))
885 all_seq = [x[0] for x in cr.fetchall()]
886 logger.warn('Fix %d FXA AJIs: %s' % (len(all_seq), ','.join(all_seq)))
887 cr.execute("""update account_analytic_line set
888 currency_id = %s,
889 amount = amount_currency
890 where journal_id in %s and
891 currency_id != %s""", (currency_id, tuple(journal_ids), currency_id))
892
893
868patch_scripts()894patch_scripts()
869895
870896
871897
=== modified file 'bin/addons/res_currency_functional/account_move_line_compute_currency.py'
--- bin/addons/res_currency_functional/account_move_line_compute_currency.py 2016-09-29 16:26:19 +0000
+++ bin/addons/res_currency_functional/account_move_line_compute_currency.py 2016-10-06 07:22:07 +0000
@@ -330,7 +330,7 @@
330 cr.execute(sql, [0.0, 0.0, 0.0, partner_db or 0.0, partner_cr or 0.0, tuple([o.id])])330 cr.execute(sql, [0.0, 0.0, 0.0, partner_db or 0.0, partner_cr or 0.0, tuple([o.id])])
331 # Update analytic lines331 # Update analytic lines
332 analytic_line_ids = al_obj.search(cr, uid, [('move_id', 'in', other_line_ids)], context=context)332 analytic_line_ids = al_obj.search(cr, uid, [('move_id', 'in', other_line_ids)], context=context)
333 al_obj.write(cr, uid, analytic_line_ids, {'amount': -1*total, 'amount_currency': -1*total,}, context=context)333 al_obj.write(cr, uid, analytic_line_ids, {'amount': -1*total, 'amount_currency': -1*total, 'currency_id': al.functional_currency_id.id}, context=context)
334 # Update Addendum line that's not reconciled334 # Update Addendum line that's not reconciled
335 addendum_counterpart_ids = self.search(cr, uid, [('move_id', '=', al.move_id.id), ('id', '!=', al.id), ('is_addendum_line', '=', True)])335 addendum_counterpart_ids = self.search(cr, uid, [('move_id', '=', al.move_id.id), ('id', '!=', al.id), ('is_addendum_line', '=', True)])
336 if not addendum_counterpart_ids:336 if not addendum_counterpart_ids:
@@ -367,8 +367,20 @@
367 from_another_instance = True367 from_another_instance = True
368 if multi_instance and (from_sync or from_another_instance):368 if multi_instance and (from_sync or from_another_instance):
369 continue369 continue
370
371
372 # create_addendum_line: we need a context (if currency_table is used by yearly reval US-1682)
373 # but this context should not contain any sync value or FXA JI/AJI is not well created in some use case
374 # for example: create func. unbalanced entries at proj, sync to coordo and reconcile at coordo
375 # when reconcilation is received at project, FXA entries should be created (UF-2501)
376 new_ctx = context.copy()
377 for sync_context_key in ('sync_update_execution', 'do_not_create_analytic_line', 'update_mode'):
378 if new_ctx.get(sync_context_key):
379 del new_ctx[sync_context_key]
380
381
370 # If no exception, do main process about new addendum lines382 # If no exception, do main process about new addendum lines
371 partner_line_id = self.create_addendum_line(cr, uid, reconciled_line_ids, total, context=context)383 partner_line_id = self.create_addendum_line(cr, uid, reconciled_line_ids, total, context=new_ctx)
372 if partner_line_id:384 if partner_line_id:
373 # Add it to reconciliation (same that other lines)385 # Add it to reconciliation (same that other lines)
374 reconcile_txt = ''386 reconcile_txt = ''
375387
=== modified file 'bin/addons/sync_client/update.py'
--- bin/addons/sync_client/update.py 2016-09-26 09:43:26 +0000
+++ bin/addons/sync_client/update.py 2016-10-06 07:22:07 +0000
@@ -311,9 +311,6 @@
311 'editable' : fields.boolean("Set editable"),311 'editable' : fields.boolean("Set editable"),
312 }312 }
313313
314 _defaults = {
315 'log_first_notrun': '',
316 }
317 line_error_re = re.compile(r"^Line\s+(\d+)\s*:\s*(.+)", re.S)314 line_error_re = re.compile(r"^Line\s+(\d+)\s*:\s*(.+)", re.S)
318315
319 _logger = logging.getLogger('sync.client')316 _logger = logging.getLogger('sync.client')

Subscribers

People subscribed via source and target branches