I've got a problem in updating many resource in one, fast update.
I wrote simple module with workflow.
class wyn_wyn(osv.osv):
""" Wyn """
_name = 'wyn.wyn'
_columns = {
'title' : fields.char('Title', size=20, required=True),
'savings' : fields.float('Planned savings', digits=(12,2)),
'state': fields.selection([('draft', 'New'), ('accepted', 'Accepted'), ('refused', 'Refused')],
'Status', readonly=True, track_visibility='onchange')
}
Then I wrote a wizard, where I want to calculate savings (let's say now set on 123):
def calculate(self, cr, uid, ids, context=None):
wyn = self.pool.get("wyn.wyn");
ids = wyn.search(cr, uid, '')
wyn.write(cr, uid, ids, {'savings' : 123})
return {'type': 'ir.actions.act_window_close'}
The problem is in write() method. It make one, nice, fast update on "savings" field, but then check every "wyn.wyn" resource about its workflow, one by one, what takes really long time. In the end of the write() method, is called step_workflow(), which works on every resource individually.
select * from wkf_workitem where inst_id=8056
select * from wkf_activity where id=5
select * from wkf_transition where act_from=5
select wkf_id from wkf_instance where id=8056
select state,flow_stop from wkf_workitem w left join wkf_activity a on (a.id=w.act_id) where w.inst_id=8056
How to solve this problem in efficient way? (disable workflow, code it in the other way, ...)