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

OpenERP create & write methods at once [Closed]

By
priyankahdp
on 4/26/13, 4:23 AM 8,212 views

The Question has been closed

by
priyankahdp
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: 127.0.0.1 - - [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..

3

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
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

priyankahdp
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
1

priyankahdp

--priyankahdp--
1089
| 5 5 6
Colombo, Sri Lanka
--priyankahdp--
Java Developer ORACLE Python J2EE Spring Hibernate Struts & Jquery............. :-)
priyankahdp
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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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