Merge lp:~jfb-tempo-consulting/unifield-server/us-1766 into lp:unifield-server
- us-1766
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Dev Team | Pending | ||
Review via email: mp+307794@code.launchpad.net |
Commit message
Description of the change
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 | 282 | 282 | ||
6 | 283 | # US-533: date of JI reconciliation for total reconciliation linked | 283 | # US-533: date of JI reconciliation for total reconciliation linked |
7 | 284 | # with above (4, 0) | 284 | # with above (4, 0) |
12 | 285 | # US-1682: trigger FXA computation | 285 | # bypass orm methods: for specific lines: |
13 | 286 | self.pool.get('account.move.line').write(cr, uid, ids, { | 286 | # - US-1766 FXA AJI should not be recomputed |
14 | 287 | 'reconcile_date': time.strftime('%Y-%m-%d'), | 287 | # - US-1682 yealry REV JI have a dedicated rate |
15 | 288 | }, context=context) | 288 | cr.execute('update account_move_line set reconcile_date=%s where id in %s', |
16 | 289 | (time.strftime('%Y-%m-%d'), tuple(ids)) | ||
17 | 290 | ) | ||
18 | 289 | 291 | ||
19 | 290 | # UF-2011: synchronize move lines (not "marked" after reconcile creation) | 292 | # UF-2011: synchronize move lines (not "marked" after reconcile creation) |
20 | 291 | if self.pool.get('sync.client.orm_extended'): | 293 | if self.pool.get('sync.client.orm_extended'): |
21 | 292 | 294 | ||
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 | 146 | 'is_revaluated_ok', | 146 | 'is_revaluated_ok', |
27 | 147 | 'debit', | 147 | 'debit', |
28 | 148 | 'credit', | 148 | 'credit', |
29 | 149 | 'is_addendum_line', | ||
30 | 149 | ] | 150 | ] |
31 | 150 | 151 | ||
32 | 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): |
33 | @@ -203,11 +204,19 @@ | |||
34 | 203 | aji_greater_amount['is'] = True | 204 | aji_greater_amount['is'] = True |
35 | 204 | else: | 205 | else: |
36 | 205 | aji_greater_amount['is'] = False | 206 | aji_greater_amount['is'] = False |
37 | 207 | analytic_currency_id = obj_line.get('currency_id', [False])[0] | ||
38 | 208 | amount_aji_book = -1 * anal_amount_rounded | ||
39 | 206 | # functional amount | 209 | # functional amount |
40 | 207 | if obj_line.get('is_revaluated_ok'): | 210 | if obj_line.get('is_revaluated_ok'): |
41 | 208 | # (US-1682) if it's a revaluation line get the functional amount directly from the JI | 211 | # (US-1682) if it's a revaluation line get the functional amount directly from the JI |
42 | 209 | # to avoid slight differences between JI and AJI amounts caused by computation | 212 | # to avoid slight differences between JI and AJI amounts caused by computation |
43 | 210 | amount_aji_fctal = -1 * distrib_line.percentage * amount_ji_fctal / 100 | 213 | amount_aji_fctal = -1 * distrib_line.percentage * amount_ji_fctal / 100 |
44 | 214 | elif obj_line.get('is_addendum_line'): | ||
45 | 215 | # US-1766: AJIs linked to FXA entry should have fct amount = booking amount | ||
46 | 216 | # and book currency = fct currency | ||
47 | 217 | analytic_currency_id = company_currency | ||
48 | 218 | amount_aji_fctal = -1 * distrib_line.percentage * amount_ji_fctal / 100 | ||
49 | 219 | amount_aji_book = -1 * distrib_line.percentage * amount_ji_fctal / 100 | ||
50 | 211 | else: | 220 | else: |
51 | 212 | amount_aji_fctal = -1 * self.pool.get('res.currency').compute( | 221 | amount_aji_fctal = -1 * self.pool.get('res.currency').compute( |
52 | 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, |
53 | @@ -218,13 +227,13 @@ | |||
54 | 218 | 'ref': obj_line.get('ref', False), | 227 | 'ref': obj_line.get('ref', False), |
55 | 219 | 'journal_id': journal.get('analytic_journal_id', [False])[0], | 228 | 'journal_id': journal.get('analytic_journal_id', [False])[0], |
56 | 220 | 'amount': amount_aji_fctal, | 229 | 'amount': amount_aji_fctal, |
58 | 221 | 'amount_currency': -1 * anal_amount_rounded, # booking amount | 230 | 'amount_currency': amount_aji_book, # booking amount |
59 | 222 | 'account_id': distrib_line.analytic_id.id, | 231 | 'account_id': distrib_line.analytic_id.id, |
60 | 223 | 'general_account_id': account.get('id'), | 232 | 'general_account_id': account.get('id'), |
61 | 224 | 'move_id': obj_line.get('id'), | 233 | 'move_id': obj_line.get('id'), |
62 | 225 | 'distribution_id': distrib_obj.id, | 234 | 'distribution_id': distrib_obj.id, |
63 | 226 | 'user_id': uid, | 235 | 'user_id': uid, |
65 | 227 | 'currency_id': obj_line.get('currency_id', [False])[0], | 236 | 'currency_id': analytic_currency_id, |
66 | 228 | 'distrib_line_id': '%s,%s'%(distrib_line._name, distrib_line.id), | 237 | 'distrib_line_id': '%s,%s'%(distrib_line._name, distrib_line.id), |
67 | 229 | 'document_date': obj_line.get('document_date', False), | 238 | 'document_date': obj_line.get('document_date', False), |
68 | 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) |
69 | 231 | 240 | ||
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 | 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) |
75 | 130 | return cr.fetchall() | 130 | return cr.fetchall() |
76 | 131 | 131 | ||
77 | 132 | def get_company_currency_id(self, cr, uid): | ||
78 | 133 | user = self.browse(cr, uid, uid, fields_to_fetch=['company_id']) | ||
79 | 134 | return user.company_id and user.company_id.currency_id and user.company_id.currency_id.id or False | ||
80 | 135 | |||
81 | 132 | def send_welcome_email(self, cr, uid, id, context=None): | 136 | def send_welcome_email(self, cr, uid, id, context=None): |
82 | 133 | logger= netsvc.Logger() | 137 | logger= netsvc.Logger() |
83 | 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) |
84 | 135 | 139 | ||
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 | 262 | 262 | ||
90 | 263 | def create(self, cr, uid, vals, context=None): | 263 | def create(self, cr, uid, vals, context=None): |
91 | 264 | if 'journal_id' in vals: | 264 | if 'journal_id' in vals: |
93 | 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) |
94 | 266 | vals['instance_id'] = journal.get('instance_id')[0] | 266 | vals['instance_id'] = journal.get('instance_id')[0] |
95 | 267 | # US-1766: in pipe FXA sync update: force currency | ||
96 | 268 | if journal['type'] == 'cur_adj': | ||
97 | 269 | currency = self.pool.get('res.users').get_company_currency_id(cr, uid) | ||
98 | 270 | if currency: | ||
99 | 271 | vals['currency_id'] = currency | ||
100 | 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) |
101 | 268 | 273 | ||
102 | 269 | def write(self, cr, uid, ids, vals, context=None): | 274 | def write(self, cr, uid, ids, vals, context=None): |
103 | 270 | if not ids: | 275 | if not ids: |
104 | 271 | return True | 276 | return True |
105 | 272 | if 'journal_id' in vals: | 277 | if 'journal_id' in vals: |
107 | 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) |
108 | 274 | vals['instance_id'] = journal.get('instance_id')[0] | 279 | vals['instance_id'] = journal.get('instance_id')[0] |
109 | 280 | # US-1766: in pipe FXA sync update: force currency | ||
110 | 281 | if journal['type'] == 'cur_adj': | ||
111 | 282 | currency = self.pool.get('res.users').get_company_currency_id(cr, uid) | ||
112 | 283 | if currency: | ||
113 | 284 | vals['currency_id'] = currency | ||
114 | 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) |
115 | 276 | 286 | ||
116 | 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): |
117 | 278 | 288 | ||
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 | 107 | <field name="method">us_1732_sync_state_ud</field> | 107 | <field name="method">us_1732_sync_state_ud</field> |
123 | 108 | </record> | 108 | </record> |
124 | 109 | 109 | ||
125 | 110 | <record id="us_1766_fix_fxa_aji_curr" model="patch.scripts"> | ||
126 | 111 | <field name="method">us_1766_fix_fxa_aji_curr</field> | ||
127 | 112 | </record> | ||
128 | 110 | </data> | 113 | </data> |
129 | 111 | </openerp> | 114 | </openerp> |
130 | 112 | 115 | ||
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 | 865 | SELECT id FROM product_product WHERE state_ud IS NOT NULL | 865 | SELECT id FROM product_product WHERE state_ud IS NOT NULL |
136 | 866 | )""") | 866 | )""") |
137 | 867 | 867 | ||
138 | 868 | def us_1766_fix_fxa_aji_curr(self, cr, uid, *a, **b): | ||
139 | 869 | """ | ||
140 | 870 | Fix FXA AJIs: | ||
141 | 871 | - set book currency = fct currency | ||
142 | 872 | - set book amount = fct amount | ||
143 | 873 | """ | ||
144 | 874 | context = {} | ||
145 | 875 | logger = logging.getLogger('fix_us_1766') | ||
146 | 876 | user = self.pool.get('res.users').browse(cr, uid, uid, context=context) | ||
147 | 877 | currency_id = user.company_id.currency_id and user.company_id.currency_id.id or False | ||
148 | 878 | |||
149 | 879 | if currency_id: | ||
150 | 880 | journal_ids = self.pool.get('account.analytic.journal').search(cr, uid, [('type', '=', 'cur_adj'), ('active', 'in', ['t', 'f'])]) | ||
151 | 881 | if journal_ids: | ||
152 | 882 | cr.execute("""select entry_sequence from account_analytic_line | ||
153 | 883 | where journal_id in %s and | ||
154 | 884 | currency_id != %s """, (tuple(journal_ids), currency_id)) | ||
155 | 885 | all_seq = [x[0] for x in cr.fetchall()] | ||
156 | 886 | logger.warn('Fix %d FXA AJIs: %s' % (len(all_seq), ','.join(all_seq))) | ||
157 | 887 | cr.execute("""update account_analytic_line set | ||
158 | 888 | currency_id = %s, | ||
159 | 889 | amount = amount_currency | ||
160 | 890 | where journal_id in %s and | ||
161 | 891 | currency_id != %s""", (currency_id, tuple(journal_ids), currency_id)) | ||
162 | 892 | |||
163 | 893 | |||
164 | 868 | patch_scripts() | 894 | patch_scripts() |
165 | 869 | 895 | ||
166 | 870 | 896 | ||
167 | 871 | 897 | ||
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 | 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])]) |
173 | 331 | # Update analytic lines | 331 | # Update analytic lines |
174 | 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) |
176 | 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) |
177 | 334 | # Update Addendum line that's not reconciled | 334 | # Update Addendum line that's not reconciled |
178 | 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)]) |
179 | 336 | if not addendum_counterpart_ids: | 336 | if not addendum_counterpart_ids: |
180 | @@ -367,8 +367,20 @@ | |||
181 | 367 | from_another_instance = True | 367 | from_another_instance = True |
182 | 368 | if multi_instance and (from_sync or from_another_instance): | 368 | if multi_instance and (from_sync or from_another_instance): |
183 | 369 | continue | 369 | continue |
184 | 370 | |||
185 | 371 | |||
186 | 372 | # create_addendum_line: we need a context (if currency_table is used by yearly reval US-1682) | ||
187 | 373 | # but this context should not contain any sync value or FXA JI/AJI is not well created in some use case | ||
188 | 374 | # for example: create func. unbalanced entries at proj, sync to coordo and reconcile at coordo | ||
189 | 375 | # when reconcilation is received at project, FXA entries should be created (UF-2501) | ||
190 | 376 | new_ctx = context.copy() | ||
191 | 377 | for sync_context_key in ('sync_update_execution', 'do_not_create_analytic_line', 'update_mode'): | ||
192 | 378 | if new_ctx.get(sync_context_key): | ||
193 | 379 | del new_ctx[sync_context_key] | ||
194 | 380 | |||
195 | 381 | |||
196 | 370 | # If no exception, do main process about new addendum lines | 382 | # If no exception, do main process about new addendum lines |
198 | 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) |
199 | 372 | if partner_line_id: | 384 | if partner_line_id: |
200 | 373 | # Add it to reconciliation (same that other lines) | 385 | # Add it to reconciliation (same that other lines) |
201 | 374 | reconcile_txt = '' | 386 | reconcile_txt = '' |
202 | 375 | 387 | ||
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 | 311 | 'editable' : fields.boolean("Set editable"), | 311 | 'editable' : fields.boolean("Set editable"), |
208 | 312 | } | 312 | } |
209 | 313 | 313 | ||
210 | 314 | _defaults = { | ||
211 | 315 | 'log_first_notrun': '', | ||
212 | 316 | } | ||
213 | 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) |
214 | 318 | 315 | ||
215 | 319 | _logger = logging.getLogger('sync.client') | 316 | _logger = logging.getLogger('sync.client') |