Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

copy orm method default

By
klacus
on 11/23/13, 12:19 AM 1,930 views

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....

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 11/23/13, 12:19 AM
Seen: 1930 times
Last updated: 3/16/15, 8:10 AM