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.

1

Error when i use function copy_data

By
hellequin
on 2/17/14, 5:51 AM 1,588 views

I try to use copy_data in other function

def test_mdel(self, cr, uid, id, ids, default=None, context=None):
default = {}
test = super(complement_sale_order, self).copy_data(cr, uid, id, default, context=context)
return test

But i have a error

key error : id

please help

1

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 2/17/14, 5:58 AM

In your code test_mdel method extra one parameter ids is added. so remove the extra parameter

The Below code copy_data method used in sale order

  def copy_data(self, cr, uid, id, default=None, context=None):
        if not default:
            default = {}
        default.update({'state': 'draft',  'invoice_lines': []})
        return super(sale_order_line, self).copy_data(cr, uid, id, default, context=context)

if you are override copy_data method then use super otherwise try the below code:-

def test_mdel(self, cr, uid, id, default=None, context=None):
        default={}
        test = self.copy(cr,uid, id[0], default=default, context=context)
       return test

or

def test_mdel(self, cr, uid, id, default=None, context=None):
            default={}
            test = self.copy_data(cr,uid, id[0], default=default, context=context)
           return self.create(cr, uid, test, context=context)

The above code after clicking the button create a new record with copy of same data. https://doc.openerp.com/6.0/developer/2_5_Objects_Fields_Methods/methods/

Ahh thanks ! it work !

hellequin
on 2/17/14, 9:14 AM
0
hellequin
On 2/17/14, 6:53 AM

Thanks for your help.

I try without ids parameter :

def test_mdel(self, cr, uid, id, default=None, context=None):

    default={}
    test = super(complement_sale_order, self).copy_data(cr,uid, id, default, context=context)

    return test

But i have other error :

TypeError: unhashable type: 'list'

for parameter id

Updated the code

Prakash
on 2/17/14, 8:15 AM

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

1 follower(s)

Stats

Asked: 2/17/14, 5:51 AM
Seen: 1588 times
Last updated: 4/17/15, 5:18 AM