Hi.
I have the following modell.:
class mrp_process_params(osv.osv):
_name = 'mrp.process.params'
_description = 'Workstation process parameters'
_columns = {
'name':fields.char('Paraméter neve', size=64, required=False, readonly=False),
'value':fields.char('Paraméter értéke', size=32, required=False, readonly=False),
'rout_workcent_id':fields.many2one('mrp.routing.workcenter', 'Routing Workcenter id', required=False),
}
mrp_process_params()
I want to copy some parameters when I create the automatically the routing of the imported products. like this:
if p_params_ids:
for p_id in p_params_ids:
self.pool.get('mrp.process.params').copy(cr, uid, p_id,{'rout_wokcent_id': cr_id})
Everithing run by fine, (p_params_id has a value and this value is good) without trouble, but in the database the rout_workcenter_id is always the original. I checked the value of the cr_id what i define the following.
cr_id = workc.create(cr, uid, vals_rout_wc, context = context) so this is a new id of the created workcenter. This value is also ok.
Why not change the rout_workcenter_id according the copy default vals??? So the problem is somewhere the copy default handling or in my brain....?
Note: I try the following also, but not works (rout_workcenter_id also in original..)
if p_params_ids:
for p_id in p_params_ids:
copy_id = self.pool.get('mrp.process.params').copy(cr, uid, p_id,{'rout_wokcent_id': cr_id})
print copy_id
vals = {
'rout_wokcent_id': cr_id
}
self.pool.get('mrp.process.params').write(cr,uid,copy_id,vals)
if I use direct sql injection this is work...
if p_params_ids:
for p_id in p_params_ids:
copy_id = self.pool.get('mrp.process.params').copy(cr, uid, p_id,{'rout_wokcent_id': cr_id})
sql = "update mrp_process_params set rout_workcent_id = %s where id = %s;" % ( str(cr_id),str(copy_id) )
cr.execute(sql)
But I want to avoid this....