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
1=== modified file 'bin/addons/account/account_move_line.py'
2--- bin/addons/account/account_move_line.py 2016-03-23 14:52:23 +0000
3+++ bin/addons/account/account_move_line.py 2016-04-14 13:11:13 +0000
4@@ -1240,24 +1240,32 @@
5 move_obj.write(cr, uid, [line.move_id.id], {'date': todo_date}, context=context)
6 return result
7
8- def _hook_check_period_state(self, cr, uid, result=False, context=None, *args, **kargs):
9+ def _hook_check_period_state(self, cr, uid, result=False, context=None, raise_hq_closed=True, *args, **kargs):
10 """
11 Check period state
12 """
13 if not result:
14 return False
15+ res = True
16 for (state,) in result:
17 if state == 'done':
18- raise osv.except_osv(_('Error !'), _('You can not add/modify entries in a closed journal.'))
19+ if raise_hq_closed:
20+ raise osv.except_osv(_('Error !'), _('You can not add/modify entries in a closed journal.'))
21+ res = False
22+ break
23+ return res
24
25- def _update_journal_check(self, cr, uid, journal_id, period_id, context=None):
26+ def _update_journal_check(self, cr, uid, journal_id, period_id,
27+ context=None, raise_hq_closed=True):
28 journal_obj = self.pool.get('account.journal')
29 period_obj = self.pool.get('account.period')
30 jour_period_obj = self.pool.get('account.journal.period')
31 cr.execute('SELECT state FROM account_journal_period WHERE journal_id = %s AND period_id = %s', (journal_id, period_id))
32 result = cr.fetchall()
33- self._hook_check_period_state(cr, uid, result, context=context)
34- if not result:
35+ if result:
36+ res = self._hook_check_period_state(cr, uid, result,
37+ context=context, raise_hq_closed=raise_hq_closed)
38+ else:
39 journal = journal_obj.browse(cr, uid, journal_id, context=context)
40 period = period_obj.browse(cr, uid, period_id, context=context)
41 jour_period_obj.create(cr, uid, {
42@@ -1265,7 +1273,8 @@
43 'journal_id': journal.id,
44 'period_id': period.id
45 })
46- return True
47+ res = True
48+ return res
49
50 def _update_check(self, cr, uid, ids, context=None):
51 done = {}
52
53=== modified file 'bin/addons/sync_client/special_handling.py'
54--- bin/addons/sync_client/special_handling.py 2015-08-28 14:34:57 +0000
55+++ bin/addons/sync_client/special_handling.py 2016-04-14 13:11:13 +0000
56@@ -149,9 +149,62 @@
57 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 !'))
58 t = (l.journal_id.id, l.period_id.id)
59 if t not in done:
60- self._update_journal_check(cr, uid, l.journal_id.id, l.period_id.id, context)
61+ if not self._update_journal_check(cr, uid, l.journal_id.id,
62+ l.period_id.id, context=context, raise_hq_closed=False):
63+ # US 1214: HQ closed check more field not updated
64+ self._hook_call_update_check_hq_closed_rec(cr, uid, l,
65+ vals, context=context)
66 done[t] = True
67
68+ def _hook_call_update_check_hq_closed_rec(self, cr, uid, ji_rec, vals,
69+ context=None):
70+ # US 1214: HQ closed tolerate update under certains conditions only
71+ # 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
72+ # http://jira.unifield.org/browse/US-1214?focusedCommentId=47237&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-47237
73+
74+ # => get field by field diff
75+ fields_to_check = [
76+ ('credit', 'float'),
77+ ('credit_currency', 'float'),
78+ ('currency_id', 'id'),
79+ ('date', False),
80+ ('debit', 'float'),
81+ ('debit_currency', 'float'),
82+ ('document_date', False),
83+ ('employee_id', 'id'),
84+ ('journal_id', 'id'),
85+ ('move_id', 'id'),
86+ ('partner_id', 'id'),
87+ ('partner_txt', False),
88+ ('period_id', 'id'),
89+ ('ref', False),
90+ ('state', False),
91+ ('transfer_journal_id', 'id'),
92+ ('transfer_amount', 'float'),
93+ ]
94+
95+ for f, t in fields_to_check:
96+ has_diff = False
97+ if f in vals:
98+ if not hasattr(ji_rec, f):
99+ continue
100+ rec_val = getattr(ji_rec, f)
101+ val = vals[f]
102+
103+ if t == 'id':
104+ if rec_val:
105+ has_diff = not val or val != rec_val.id
106+ else:
107+ has_diff = True if val else False
108+ elif t == 'float':
109+ has_diff = abs((val or 0.) - (rec_val or 0.)) > 10**-4
110+ else:
111+ has_diff = val != rec_val
112+
113+ if has_diff:
114+ raise osv.except_osv(_('Error !'),
115+ _('You can not modify entries in a HQ closed journal'))
116+
117 account_move_line()
118
119 class ir_model_data(osv.osv):

Subscribers

People subscribed via source and target branches

to all changes: