TypeError: create() got multiple values for keywor

2019-05-26 11:06发布

问题:

I got an error like this:

TypeError: create () got multiple values ​​for keyword argument 'context'

This is the code:

mov_id = self.create(cr, uid, ids, {'so_ids':so, 'product_ids':product},context=context)

What's the problem?

回答1:

To create a record, the parameters are cursor, user_id, dictionary of values and context. for example

mov_id = self.create(cr, uid, {'so_ids': so, 'product_ids': product},context=context)

create doesnt take any ids, if you are trying to use copy, then use

mov_id = self.copy(cr, uid, ids, {'so_ids':so, 'product_ids':product},context=context)


回答2:

self.create(cr, uid, {'so_ids':"Test"}, context=context)

This is the syntax for create method.

If you want to add 'write_uid' just add {'write_uid': ur_id} in dictionary in create method. In create method no 'id' or 'list of ids' is required.