Merge lp:~unifield-team/unifield-wm/us-649 into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 2709
Proposed branch: lp:~unifield-team/unifield-wm/us-649
Merge into: lp:unifield-wm
Diff against target: 145 lines (+42/-26)
4 files modified
account_mcdb/account_period_state.py (+27/-24)
account_mcdb/account_period_state_view.xml (+1/-2)
msf_profile/data/patches.xml (+4/-0)
msf_profile/msf_profile.py (+10/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/us-649
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+283297@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 'account_mcdb/account_period_state.py' (properties changed: -x to +x)
2--- account_mcdb/account_period_state.py 2015-10-12 14:58:29 +0000
3+++ account_mcdb/account_period_state.py 2016-01-20 14:09:57 +0000
4@@ -30,34 +30,23 @@
5 class account_period_state(osv.osv):
6 _name = "account.period.state"
7
8- def _get_instance_name(self, cr, uid, ids, name, args, context=None):
9- res = {}
10- if not ids:
11- return res
12- obj_ids = self.browse(cr, uid, ids, context=context)
13- for obj in obj_ids:
14- res[obj.id] = obj.instance_id and obj.instance_id.name or ""
15-
16- return res
17-
18- def _get_search_by_instance(self, cr, uid, obj, name, args,
19- context=None):
20- inst_obj = self.pool.get('msf.instance')
21- args = [('name', args[0][1], args[0][2])]
22- inst_ids = inst_obj.search(cr, uid, args, context=context)
23- return [('instance_id', 'in', inst_ids)]
24-
25 _columns = {
26 'period_id': fields.many2one('account.period', 'Period', required=1, ondelete='cascade'),
27 'instance_id': fields.many2one('msf.instance', 'Proprietary Instance'),
28 'state': fields.selection(ACCOUNT_PERIOD_STATE_SELECTION, 'State',
29 readonly=True),
30- 'instance_name': fields.function(_get_instance_name, type='char',
31- fnct_search=_get_search_by_instance,
32- method=True,
33- string="Proprietary Instance"),
34 }
35
36+ def create(self, cr, uid, vals, context=None):
37+ if context is None:
38+ context = {}
39+ if context.get('sync_update_execution') and not vals.get('period_id'):
40+ # US-841: period is required but we got
41+ # an update related to non existant period: ignore it
42+ return False
43+
44+ return super(account_period_state, self).create(cr, uid, vals, context=context)
45+
46 def get_period(self, cr, uid, ids, context=None):
47 mod_obj = self.pool.get('ir.model.data')
48 view_id = mod_obj.get_object_reference(cr, uid, 'account_mcdb',
49@@ -87,10 +76,12 @@
50 if isinstance(period_ids, (int, long)):
51 period_ids = [period_ids]
52
53+ user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
54+ model_data = self.pool.get('ir.model.data')
55+ period_state = self.pool.get('account.period.state')
56+ parent = user.company_id.instance_id.id
57+ ids_to_write = []
58 for period_id in period_ids:
59- user = self.pool.get('res.users').browse(cr, uid, uid,
60- context=context)
61- parent = user.company_id.instance_id.id
62 period = self.pool.get('account.period').read(cr, uid, period_id,
63 ['id', 'state'],
64 context=context)
65@@ -105,11 +96,23 @@
66 'state': period['state']
67 }
68 self.write(cr, uid, ids, vals, context=context)
69+ for period_state_id in ids:
70+ period_state_xml_id = period_state.get_sd_ref(cr, uid, period_state_id)
71+ ids_to_write.append(model_data._get_id(cr, uid, 'sd',
72+ period_state_xml_id))
73+
74 else:
75 vals = {
76 'period_id': period['id'],
77 'instance_id': parent,
78 'state': period['state']}
79 self.create(cr, uid, vals, context=context)
80+
81+ # US-649 : in context of synchro last_modification date must be updated
82+ # on account.period.state because they are created with synchro and
83+ # they need to be sync down to other instances
84+ if ids_to_write:
85+ model_data.write(cr, uid, ids_to_write, {'last_modification':fields.datetime.now()})
86+
87 return True
88 account_period_state()
89
90=== modified file 'account_mcdb/account_period_state_view.xml' (properties changed: -x to +x)
91--- account_mcdb/account_period_state_view.xml 2015-08-28 14:16:07 +0000
92+++ account_mcdb/account_period_state_view.xml 2016-01-20 14:09:57 +0000
93@@ -25,7 +25,6 @@
94 <field name="arch" type="xml">
95 <data >
96 <field name="instance_id" />
97- <field name="instance_name" invisible="True" />
98 <field name="period_id" />
99 <field name="state" />
100 </data>
101@@ -39,7 +38,7 @@
102 <field name="priority" eval="5"/>
103 <field name="arch" type="xml">
104 <search string="Register Lines">
105- <field name="instance_name"/>
106+ <field name="instance_id"/>
107 <field name="period_id" />
108 <field name="state" />
109 </search>
110
111=== modified file 'msf_profile/data/patches.xml'
112--- msf_profile/data/patches.xml 2015-11-30 13:53:32 +0000
113+++ msf_profile/data/patches.xml 2016-01-20 14:09:57 +0000
114@@ -24,6 +24,10 @@
115 <field name="method">us_332_patch</field>
116 </record>
117
118+ <record id="us_841_patch" model="patch.scripts">
119+ <field name="method">us_841_patch</field>
120+ </record>
121+
122 <record id="bar_action_patch" model="patch.scripts">
123 <field name="method">bar_action_patch</field>
124 </record>
125
126=== modified file 'msf_profile/msf_profile.py'
127--- msf_profile/msf_profile.py 2015-12-01 16:28:43 +0000
128+++ msf_profile/msf_profile.py 2016-01-20 14:09:57 +0000
129@@ -51,6 +51,16 @@
130 getattr(model_obj, method)(cr, uid, *a, **b)
131 self.write(cr, uid, [ps['id']], {'run': True})
132
133+ def us_841_patch(self, cr, uid, *a, **b):
134+ # fix incorrect period state on upper level by re-sending state
135+ p_ids = self.pool.get('account.period').search(cr, uid, [])
136+ if p_ids:
137+ cr.execute("""update ir_model_data
138+ set last_modification=NOW(),
139+ touched='[''state'']'
140+ where model='account.period.state' and res_id in %s
141+ """, (tuple(p_ids), ))
142+
143 def us_332_patch(self, cr, uid, *a, **b):
144 context = {}
145 user_obj = self.pool.get('res.users')

Subscribers

People subscribed via source and target branches