32
32
_name = "account.period.state"
35
'period_id': fields.many2one('account.period', 'Period', required=1, ondelete='cascade'),
36
'instance_id': fields.many2one('msf.instance', 'Proprietary Instance'),
35
'period_id': fields.many2one('account.period', 'Period', required=1, ondelete='cascade', select=1),
36
'instance_id': fields.many2one('msf.instance', 'Proprietary Instance', select=1),
37
37
'state': fields.selection(ACCOUNT_PERIOD_STATE_SELECTION, 'State',
128
128
'fy_id': fields.many2one('account.fiscalyear', 'Fiscal Year',
129
required=True, ondelete='cascade'),
130
'instance_id': fields.many2one('msf.instance', 'Proprietary Instance'),
129
required=True, ondelete='cascade', select=1),
130
'instance_id': fields.many2one('msf.instance', 'Proprietary Instance', select=1),
131
131
'state': fields.selection(ACCOUNT_FY_STATE_SELECTION, 'State',
135
def create(self, cr, uid, vals, context=None):
138
if context.get('sync_update_execution') and not vals.get('fy_id'):
139
# US-841: period is required but we got
140
# an update related to non existant period: ignore it
143
return super(account_fiscalyear_state, self).create(cr, uid, vals, context=context)
135
145
def get_fy(self, cr, uid, ids, context=None):
136
146
mod_obj = self.pool.get('ir.model.data')
137
147
view_id = mod_obj.get_object_reference(cr, uid, 'account_mcdb',
166
176
fy_state_obj = self.pool.get('account.fiscalyear.state')
167
177
parent = user.company_id.instance_id.id
168
178
ids_to_write = []
169
180
for fy_id in fy_ids:
170
181
user = self.pool.get('res.users').browse(cr, uid, uid,
183
194
'state': fy['state']
185
196
self.write(cr, uid, ids, vals, context=context)
186
for fy_state_id in ids:
187
fy_state_xml_id = fy_state_obj.get_sd_ref(cr, uid,
189
ids_to_write.append(model_data._get_id(cr, uid, 'sd',
197
state_to_update = ids[:]
193
200
'fy_id': fy['id'],
194
201
'instance_id': parent,
195
202
'state': fy['state']
197
self.create(cr, uid, vals, context=context)
204
nid = self.create(cr, uid, vals, context=context)
205
state_to_update = [nid]
207
for fy_state_id in state_to_update:
208
fy_state_xml_id = fy_state_obj.get_sd_ref(cr, uid, fy_state_id)
209
ids_to_write.append(model_data._get_id(cr, uid, 'sd', fy_state_xml_id))
199
211
# like for US-649 period state: in context of synchro last_modification
200
212
# date must be updated on account.fisclayear.state because they are
201
213
# created with synchro and they need to be sync down to other instances
203
215
model_data.write(cr, uid, ids_to_write,
204
{'last_modification': fields.datetime.now()})
216
{'last_modification': fields.datetime.now(), 'touched': "['state']"})
207
219
account_fiscalyear_state()