Merge lp:~unifield-team/unifield-wm/UF_2014 into lp:unifield-wm

Proposed by jftempo
Status: Needs review
Proposed branch: lp:~unifield-team/unifield-wm/UF_2014
Merge into: lp:unifield-wm
Diff against target: 71 lines (+36/-0)
2 files modified
account_override/account.py (+14/-0)
account_override/account_analytic_line.py (+22/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/UF_2014
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+184062@code.launchpad.net
To post a comment you must log in.
1727. By Matthieu Dietrich <mdietrich@chloups211>

UF-2014: [FIX] fixed the analytic line write()

Unmerged revisions

1727. By Matthieu Dietrich <mdietrich@chloups211>

UF-2014: [FIX] fixed the analytic line write()

1726. By Matthieu Dietrich @ camptocamp

UF-2014: [FIX] added period checks for account.move and account.analytic.line

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_override/account.py'
2--- account_override/account.py 2013-10-24 15:08:46 +0000
3+++ account_override/account.py 2013-10-29 16:58:11 +0000
4@@ -214,6 +214,13 @@
5 instance = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.instance_id
6 journal = self.pool.get('account.journal').browse(cr, uid, vals['journal_id'])
7 sequence_number = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
8+
9+ # UF-2014: add checks for sync creation on moves, move lines and analytic lines
10+ if vals.get('period_id', False):
11+ period = self.pool.get('account.period').browse(cr, uid, vals['period_id'], context=context)
12+ if period and period.state != 'draft':
13+ raise osv.except_osv(_('Error'), _('Period \'%s\' is not open!') % period.name)
14+
15 if instance and journal and sequence_number and ('name' not in vals or vals['name'] == '/'):
16 if not instance.move_prefix:
17 raise osv.except_osv(_('Warning'), _('No move prefix found for this instance! Please configure it on Company view.'))
18@@ -245,6 +252,13 @@
19 """
20 if not context:
21 context = {}
22+
23+ # UF-2014: add checks for sync creation on moves, move lines and analytic lines
24+ if vals.get('period_id', False):
25+ period = self.pool.get('account.period').browse(cr, uid, vals['period_id'], context=context)
26+ if period and period.state != 'draft':
27+ raise osv.except_osv(_('Error'), _('Period \'%s\' is not open!') % period.name)
28+
29 if context.get('from_web_menu', False) or context.get('sync_update_execution', False):
30 # by default, from synchro, we just need to update period_id and journal_id
31 fields = ['journal_id', 'period_id']
32
33=== modified file 'account_override/account_analytic_line.py'
34--- account_override/account_analytic_line.py 2013-07-18 13:43:58 +0000
35+++ account_override/account_analytic_line.py 2013-10-29 16:58:11 +0000
36@@ -110,6 +110,17 @@
37 """
38 if not context:
39 context = {}
40+
41+ # UF-2014: add checks for sync creation on moves, move lines and analytic lines
42+ if vals.get('date', False):
43+ period_ids = self.pool.get('account.period').search(cr, uid, [('date_start','<=',vals['date']),
44+ ('date_stop','>=',vals['date']),
45+ ('special', '=', False)], context=context)
46+ if len(period_ids) > 0:
47+ period = self.pool.get('account.period').browse(cr, uid, period_ids[0], context=context)
48+ if period and period.state != 'draft':
49+ raise osv.except_osv(_('Error'), _('Period \'%s\' is not open!') % period.name)
50+
51 # SP-50: If data is synchronized from another instance, just create it with the given document_date
52 if context.get('update_mode') in ['init', 'update']:
53 if not context.get('sync_update_execution', False) or not vals.get('document_date', False):
54@@ -125,6 +136,17 @@
55 """
56 if not context:
57 context = {}
58+
59+ # UF-2014: add checks for sync creation on moves, move lines and analytic lines
60+ if vals.get('date', False):
61+ period_ids = self.pool.get('account.period').search(cr, uid, [('date_start','<=',vals['date']),
62+ ('date_stop','>=',vals['date']),
63+ ('special', '=', False)], context=context)
64+ if len(period_ids) > 0:
65+ period = self.pool.get('account.period').browse(cr, uid, period_ids[0], context=context)
66+ if period and period.state != 'draft':
67+ raise osv.except_osv(_('Error'), _('Period \'%s\' is not open!') % period.name)
68+
69 res = super(account_analytic_line, self).write(cr, uid, ids, vals, context=context)
70 self._check_document_date(cr, uid, ids)
71 return res

Subscribers

People subscribed via source and target branches