Odoo Help


OpenERP create & write methods at once [Closed]

on 4/26/13, 4:23 AM 10,580 views

The Question has been closed

on 04/30/2013 10:26:06

Here is my error when i'm going to create records.please advice me where is the missing point.?

  File "/home/bellvantage/Documents/openerp-7.0/openerp-7/openerp/addons/bpl/bpl.py", line 394, in create
    self.write(cr, uid, [id], {'name': name}, context)
  File "/usr/lib/python2.7/dist-packages/psycopg2/extensions.py", line 129, in getquoted
    pobjs = [adapt(o) for o in self._seq]
ProgrammingError: can't adapt type 'builtin_function_or_method'
2013-04-26 06:14:07,719 5739 INFO demo werkzeug: - - [26/Apr/2013 06:14:07] "POST /web/dataset/call_kw HTTP/1.1" 200 -

relevant line in my code is like this

def create(self, cr, uid, values, context=None):
    name = 'CheckRoll No : ' + str(values['checkroll_no']) + ' & Gang No : ' + str(values['gang_no'])
    self.write(cr, uid, [id], {'name': name}, context)
    return True

error comes and shows that my write method is incorrect.seems some parameter missing by me. needs your advices to implement module thanks..




| 5 4 7
Baarn, Netherlands
On 4/26/13, 4:52 AM

Given your code, it might be that [id] is not defined. So you try to use a non-existing value/field to write.

It might be better to call the super(model.name, self).create(cr, uid, values, context=context) instead of self.write. Because create will make a new record, while write requires a record to exist (and the ID of the record is id).

In order for create to store the name as well, you have to add/modify the value of name in context:

context['name'] = name

return super(model.name, self).create(cr, uid, values, context=context)

thanks Patrick.thatswhat my missing point

on 4/26/13, 5:02 AM

Hi Guys I Want To Just Update Field From Module To Another For Example I Have Two Modules Assets And My Module I Want To Update Field In Asset Module From My Module How Can I Do It

Ali Abdelmonem Mustafa Amer
on 2/24/14, 8:43 AM



| 5 5 6
Colombo, Sri Lanka
Java Developer ORACLE Python J2EE Spring Hibernate Struts & Jquery............. :-)
On 4/26/13, 5:01 AM

Actually you are doing wrong. You are trying to write to a record that is not created.Also I dont think you need to use write in this case.

def create(self, cr, uid, values, context=None):
    name = 'CheckRoll No : ' + str(values['checkroll_no']) + ' & Gang No : ' + str(values['gang_no'])
    values.update({'name': name})
    res = super('your_class_name',self).create(cr,uid,values,context=context)
    return res

Please keep in mind that create function in openerp always return an id of the newly created record.

[credits need to go for AnomA @ Stackoverflow]

About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 4/26/13, 4:23 AM
Seen: 10580 times
Last updated: 10/5/16, 5:27 AM