Merge lp:~unifield-team/unifield-server/us-1214b into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 3709
Proposed branch: lp:~unifield-team/unifield-server/us-1214b
Merge into: lp:unifield-server
Diff against target: 119 lines (+69/-7)
2 files modified
bin/addons/account/account_move_line.py (+15/-6)
bin/addons/sync_client/special_handling.py (+54/-1)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-1214b
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+291886@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/account_move_line.py'
--- bin/addons/account/account_move_line.py 2016-03-23 14:52:23 +0000
+++ bin/addons/account/account_move_line.py 2016-04-14 13:11:13 +0000
@@ -1240,24 +1240,32 @@
1240 move_obj.write(cr, uid, [line.move_id.id], {'date': todo_date}, context=context)1240 move_obj.write(cr, uid, [line.move_id.id], {'date': todo_date}, context=context)
1241 return result1241 return result
12421242
1243 def _hook_check_period_state(self, cr, uid, result=False, context=None, *args, **kargs):1243 def _hook_check_period_state(self, cr, uid, result=False, context=None, raise_hq_closed=True, *args, **kargs):
1244 """1244 """
1245 Check period state1245 Check period state
1246 """1246 """
1247 if not result:1247 if not result:
1248 return False1248 return False
1249 res = True
1249 for (state,) in result:1250 for (state,) in result:
1250 if state == 'done':1251 if state == 'done':
1251 raise osv.except_osv(_('Error !'), _('You can not add/modify entries in a closed journal.'))1252 if raise_hq_closed:
1253 raise osv.except_osv(_('Error !'), _('You can not add/modify entries in a closed journal.'))
1254 res = False
1255 break
1256 return res
12521257
1253 def _update_journal_check(self, cr, uid, journal_id, period_id, context=None):1258 def _update_journal_check(self, cr, uid, journal_id, period_id,
1259 context=None, raise_hq_closed=True):
1254 journal_obj = self.pool.get('account.journal')1260 journal_obj = self.pool.get('account.journal')
1255 period_obj = self.pool.get('account.period')1261 period_obj = self.pool.get('account.period')
1256 jour_period_obj = self.pool.get('account.journal.period')1262 jour_period_obj = self.pool.get('account.journal.period')
1257 cr.execute('SELECT state FROM account_journal_period WHERE journal_id = %s AND period_id = %s', (journal_id, period_id))1263 cr.execute('SELECT state FROM account_journal_period WHERE journal_id = %s AND period_id = %s', (journal_id, period_id))
1258 result = cr.fetchall()1264 result = cr.fetchall()
1259 self._hook_check_period_state(cr, uid, result, context=context)1265 if result:
1260 if not result:1266 res = self._hook_check_period_state(cr, uid, result,
1267 context=context, raise_hq_closed=raise_hq_closed)
1268 else:
1261 journal = journal_obj.browse(cr, uid, journal_id, context=context)1269 journal = journal_obj.browse(cr, uid, journal_id, context=context)
1262 period = period_obj.browse(cr, uid, period_id, context=context)1270 period = period_obj.browse(cr, uid, period_id, context=context)
1263 jour_period_obj.create(cr, uid, {1271 jour_period_obj.create(cr, uid, {
@@ -1265,7 +1273,8 @@
1265 'journal_id': journal.id,1273 'journal_id': journal.id,
1266 'period_id': period.id1274 'period_id': period.id
1267 })1275 })
1268 return True1276 res = True
1277 return res
12691278
1270 def _update_check(self, cr, uid, ids, context=None):1279 def _update_check(self, cr, uid, ids, context=None):
1271 done = {}1280 done = {}
12721281
=== modified file 'bin/addons/sync_client/special_handling.py'
--- bin/addons/sync_client/special_handling.py 2015-08-28 14:34:57 +0000
+++ bin/addons/sync_client/special_handling.py 2016-04-14 13:11:13 +0000
@@ -149,9 +149,62 @@
149 raise osv.except_osv(_('Error !'), _('You can not do this modification on a reconciled entry ! Please note that you can just change some non important fields !'))149 raise osv.except_osv(_('Error !'), _('You can not do this modification on a reconciled entry ! Please note that you can just change some non important fields !'))
150 t = (l.journal_id.id, l.period_id.id)150 t = (l.journal_id.id, l.period_id.id)
151 if t not in done:151 if t not in done:
152 self._update_journal_check(cr, uid, l.journal_id.id, l.period_id.id, context)152 if not self._update_journal_check(cr, uid, l.journal_id.id,
153 l.period_id.id, context=context, raise_hq_closed=False):
154 # US 1214: HQ closed check more field not updated
155 self._hook_call_update_check_hq_closed_rec(cr, uid, l,
156 vals, context=context)
153 done[t] = True157 done[t] = True
154158
159 def _hook_call_update_check_hq_closed_rec(self, cr, uid, ji_rec, vals,
160 context=None):
161 # US 1214: HQ closed tolerate update under certains conditions only
162 # Enable the sync on account.move.line field only if they are not : Dates / Journal / Sequence / Description / Reference / all field amounts / Third party / Currency / State
163 # http://jira.unifield.org/browse/US-1214?focusedCommentId=47237&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-47237
164
165 # => get field by field diff
166 fields_to_check = [
167 ('credit', 'float'),
168 ('credit_currency', 'float'),
169 ('currency_id', 'id'),
170 ('date', False),
171 ('debit', 'float'),
172 ('debit_currency', 'float'),
173 ('document_date', False),
174 ('employee_id', 'id'),
175 ('journal_id', 'id'),
176 ('move_id', 'id'),
177 ('partner_id', 'id'),
178 ('partner_txt', False),
179 ('period_id', 'id'),
180 ('ref', False),
181 ('state', False),
182 ('transfer_journal_id', 'id'),
183 ('transfer_amount', 'float'),
184 ]
185
186 for f, t in fields_to_check:
187 has_diff = False
188 if f in vals:
189 if not hasattr(ji_rec, f):
190 continue
191 rec_val = getattr(ji_rec, f)
192 val = vals[f]
193
194 if t == 'id':
195 if rec_val:
196 has_diff = not val or val != rec_val.id
197 else:
198 has_diff = True if val else False
199 elif t == 'float':
200 has_diff = abs((val or 0.) - (rec_val or 0.)) > 10**-4
201 else:
202 has_diff = val != rec_val
203
204 if has_diff:
205 raise osv.except_osv(_('Error !'),
206 _('You can not modify entries in a HQ closed journal'))
207
155account_move_line()208account_move_line()
156209
157class ir_model_data(osv.osv):210class ir_model_data(osv.osv):

Subscribers

People subscribed via source and target branches

to all changes: