Odoo Help


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.


How to solve AttributeError 'myField' in a simple module?

on 5/14/13, 4:33 PM 3,564 views

I have just made an addon that adds a field to the stock.picking.out form.

Here is my code :

from osv import fields,osv
class stock_picking_out2(osv.osv):
    _name = "stock.picking.out"
    _inherit = "stock.picking.out"

    _columns = {
        'statut_id2': fields.many2one('sale.statut', 'Statut', required=True),

<record id="view_livraison_move_picking2_form" model="ir.ui.view">
   <field name="name">stock.picking.out.form.inherit</field>
   <field name="model">stock.picking.out</field>
   <field eval="1" name="priority"/>
   <field name="inherit_id" ref="stock.view_picking_out_form" />
   <field name="arch" type="xml">                
       <field name="stock_journal_id" position="replace" >
          <field name="statut_id2"/>

Everything works perfectly on my local server, but when I install the addon on a remote server I have different errors :

  • I can't edit the field with the form : when I edit, the changes are not saved.

  • I got this error when I try to edit a field in another form like "SALE ORDER" form :

    Client Traceback (most recent call last): File "/home/openerp7/web/7.0/addons/web/http.py", line 204, in dispatch response["result"] = method(self, *self.params) File "/home/openerp7/web/7.0/addons/web/controllers/main.py", line 1129, in call_kw return self._call_kw(req, model, method, args, kwargs) File "/home/openerp7/web/7.0/addons/web/controllers/main.py", line 1121, in _call_kw return getattr(req.session.model(model), method)(args, **kwargs) File "/home/openerp7/web/7.0/addons/web/session.py", line 43, in proxy result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw) File "/home/openerp7/web/7.0/addons/web/session.py", line 31, in proxy_method result = self.session.send(self.service_name, method, *args) File "/home/openerp7/web/7.0/addons/web/session.py", line 104, in send raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)

    Server Traceback (most recent call last): File "/home/openerp7/web/7.0/addons/web/session.py", line 90, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/usr/local/lib/python2.6/dist-packages/openerp-7.0-py2.6.egg/openerp/netsvc.py", line 289, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/usr/local/lib/python2.6/dist-packages/openerp-7.0-py2.6.egg/openerp/service/web_services.py", line 614, in dispatch res = fn(db, uid, params) File "/usr/local/lib/python2.6/dist-packages/openerp-7.0-py2.6.egg/openerp/osv/osv.py", line 169, in execute_kw return self.execute(db, uid, obj, method, *args, *kw or {}) File "/usr/local/lib/python2.6/dist-packages/openerp-7.0-py2.6.egg/openerp/osv/osv.py", line 123, in wrapper return f(self, dbname, args, *kwargs) File "/usr/local/lib/python2.6/dist-packages/openerp-7.0-py2.6.egg/openerp/osv/osv.py", line 179, in execute res = self.execute_cr(cr, uid, obj, method, args, *kw) File "/usr/local/lib/python2.6/dist-packages/openerp-7.0-py2.6.egg/openerp/osv/osv.py", line 166, in execute_cr return getattr(object, method)(cr, uid, args, *kw) File "/home/openerp7/addons/7.0/sale_stock/sale_stock.py", line 67, in write return super(sale_order, self).write(cr, uid, ids, vals, context=context) File "/home/openerp7/addons/7.0/nan_product_pack/pack.py", line 115, in write result = super(sale_order,self).write(cr, uid, ids, vals, context) File "/home/openerp7/addons/7.0/mail/mail_thread.py", line 264, in write result = super(mail_thread, self).write(cr, uid, ids, values, context=context) File "/usr/local/lib/python2.6/dist-packages/openerp-7.0-py2.6.egg/openerp/osv/orm.py", line 4272, in write self.pool.get(object)._store_set_values(cr, user, todo, fields_to_recompute, context) File "/usr/local/lib/python2.6/dist-packages/openerp-7.0-py2.6.egg/openerp/osv/orm.py", line 4629, in _store_set_values result = self._columns[f].get(cr, self, ids, f, SUPERUSER_ID, context=context) File "/usr/local/lib/python2.6/dist-packages/openerp-7.0-py2.6.egg/openerp/osv/fields.py", line 1131, in get result = self._fnct(obj, cr, uid, ids, name, self._arg, context) File "/home/openerp7/addons/7.0/sale_order_dates/sale_order_dates.py", line 36, in _get_effective_date dates_list.append(pick.date) File "/usr/local/lib/python2.6/dist-packages/openerp-7.0-py2.6.egg/openerp/osv/orm.py", line 486, in __getattr__ raise AttributeError(e) AttributeError: 'statut_id2'

(The error occurs for any types of fields, I tried to replace by Integer, char, etc... So I don't think that I comes from the relational field !)

I have also tried to change stock.picking.out by stock.picking in the inheritance and it worked, but I can't modify the field I want in the XML code...

The module is very simple but I can't see where my error come from... Do you have any idea to solve it?

Were you able to fix this problem Matt? I am struggling with this one as well.

on 12/1/13, 9:34 AM

Anas Taji

--Anas Taji--
| 6 7 8
Amman, Jordan
--Anas Taji--

Skype: anas.taji-sw

Email: anas.taji@smartway-jo.com

Anas Taji
On 5/14/13, 8:18 PM

Try the following:

  1. append openerp. befre osv like this from openerp.osv import fields,osv
  2. remove this line _name = "stock.picking.out"
  3. in your many2one field, change the object from 'sale.statut' to 'stock.picking.out'
  4. restart openERP server & reinstall your module

Note: Your XML code should be surrounded with two tags <openerp><data>YOUR XML CODE</data></openerp>, just to remind you.. :)

Replay if you need more help..%

Thanks for you answer, but it didn't solve the problem. I have done parts 1, 2 and 4. I don't understand why you're telling me to change the object in part 3, I need to insert a field of type 'sale.statut' in the stock.picking.out form, so I think I'm doing it in the good way. Is it that you didn't understand what I wanted to do or am I doing it wrong?

(And I already had the <openerp><data> tags, I just didn't want to put the useless parts of the code in my question.)

on 5/15/13, 11:14 AM

Hmm, So i believe that you have defined this object somewhere in your module, something like _name = 'sale.statut'? (because, i cant see it in your posted code)

Smart Way LLC, Anas Taji
on 5/15/13, 12:49 PM

Yes it is defined in another module, and the problem doesn't come from that module because I used the same kind of field in another object without any problem... I got the same problem if I replace 'statut_id2': fields.many2one('sale.statut', 'Statut', required=True), by 'test': fields.integer('Test'),

on 5/15/13, 3:01 PM
Lithin T
On 7/27/13, 2:46 AM

u can create the same field in "stock.picking" and "stock.picking.out", then u can inherit the form/tree view stock.picking.out and then you will be able to add the fields in 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)


Asked: 5/14/13, 4:33 PM
Seen: 3564 times
Last updated: 5/25/15, 2:30 PM