Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Artificial Intelligence
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Property Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

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

Subscribe

Get notified when there's activity on this post

This question has been flagged
2 Replies
8328 Views
Avatar
Matt

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),
    }   
stock_picking_out2()


<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"/>
       </field>
   </field>
</record>

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?

1
Avatar
Discard
JG

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

Avatar
Anas Taji
Best Answer

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..%

3
Avatar
Discard
Matt
Author

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.)

Anas Taji

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)

Matt
Author

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'),

Avatar
Lithin T
Best Answer

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.

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now