Skip to Content
Odoo Menu
  • Prijavi
  • 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
    • Approvals
    • 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
    • Estate 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

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Error Context - field does not exist

Naroči se

Get notified when there's activity on this post

This question has been flagged
errorinheritancefieldcontext
2 Odgovori
18904 Prikazi
Avatar
Carlos DuAl

I'm trying to modify a module's behaviour using another module, but I keep getting the same error message.

Traceback (most recent call last):
File "/home/carlos/dbTest/codigo/OCB/openerp/http.py", line 537, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/carlos/dbTest/codigo/OCB/openerp/http.py", line 574, in dispatch
result = self._call_function(**self.params)
File "/home/carlos/dbTest/codigo/OCB/openerp/http.py", line 310, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/carlos/dbTest/codigo/OCB/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/home/carlos/dbTest/codigo/OCB/openerp/http.py", line 307, in checked_call
return self.endpoint(*a, **kw)
File "/home/carlos/dbTest/codigo/OCB/openerp/http.py", line 803, in __call__
return self.method(*args, **kw)
File "/home/carlos/dbTest/codigo/OCB/openerp/http.py", line 403, in response_wrap
response = f(*args, **kw)
File "/home/carlos/dbTest/codigo/OCB/addons/web/controllers/main.py", line 944, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/home/carlos/dbTest/codigo/OCB/addons/web/controllers/main.py", line 936, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/home/carlos/dbTest/codigo/OCB/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/home/carlos/dbTest/codigo/OCB/addons/mail/mail_thread.py", line 348, in fields_view_get
res = super(mail_thread, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
File "/home/carlos/dbTest/codigo/OCB/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/home/carlos/dbTest/codigo/OCB/openerp/models.py", line 1545, in fields_view_get
xarch, xfields = View.postprocess_and_fields(cr, uid, self._name, etree.fromstring(result['arch']), view_id, context=ctx)
File "/home/carlos/dbTest/codigo/OCB/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/home/carlos/dbTest/codigo/OCB/openerp/addons/base/ir/ir_ui_view.py", line 837, in postprocess_and_fields
self.raise_view_error(cr, user, message, view_id, context)
File "/home/carlos/dbTest/codigo/OCB/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/home/carlos/dbTest/codigo/OCB/openerp/addons/base/ir/ir_ui_view.py", line 360, in raise_view_error
raise AttributeError(message)
AttributeError: Field `code` does not exist
Error context:
View `CRM - Claims Tree`
[view_id: 1015, xml_id: crm_claim.crm_case_claims_tree_view, model: crm.claim, parent_id: n/a]

This is the module I'm trying to modify. This module modifies the behaviour of crm.claim, and it works fine

        from openerp import models, fields, api
class CrmClaim(models.Model):
_name = "crm.claim.code"
_inherit = "crm.claim"
code = fields.Char(
string='Claim Number', required=True, default="/", readonly=True)
_sql_constraints = [
('crm_claim_unique_code', 'UNIQUE (code)',
'The code must be unique!'),
]
@api.model
def create(self, vals):
if vals.get('code', '/') == '/':
vals['code'] = self.env['ir.sequence'].get('crm.claim')
#vals['stage_id'] = '1' #Set stage to "New" automatically
return super(CrmClaim, self).create(vals)

This is the previou's module's XML view

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="crm_claim_add_seq_form_view_inh">
<field name="name">crm.claim.add.seq.form.view.inh</field>
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim.crm_case_claims_form_view" />
<field name="arch" type="xml">
<field name="name" position="before">
<field name="code" />
</field>
</field>
</record>
<record model="ir.ui.view" id="crm_claim_add_seq_tree_view_inh">
<field name="name">crm.claim.add.seq.tree.view.inh</field>
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim.crm_case_claims_tree_view" />
<field name="arch" type="xml">
<field name="name" position="before">
<field name="code" />
</field>
</field>
</record>
<record model="ir.ui.view" id="view_crm_case_claims_filter_inh_claimseq">
<field name="name">view.crm.case.claims.filter.inh.claimseq</field>
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim.view_crm_case_claims_filter" />
<field name="arch" type="xml">
<field name="name" position="attributes">
<attribute name="filter_domain">['|', ('name', 'ilike', self), ('code', 'ilike', self)]</attribute>
</field>
</field>
</record>
</data>
</openerp>

This is my module, I'm just trying to force the stage set to 1 (New) after a claim is created.

        from openerp import models, fields, api
class CrmClaim(models.Model):
_name = "crm.claim.code"
_inherit = "crm.claim"
code = fields.Char(
string='Claim Number', required=True, default="/", readonly=True)
_sql_constraints = [
('crm_claim_unique_code', 'UNIQUE (code)',
'The code must be unique!'),
]
@api.model
def create(self, vals):
if vals.get('code', '/') == '/':
vals['code'] = self.env['ir.sequence'].get('crm.claim')
#vals['stage_id'] = '1' #Set stage to "New" automatically
return super(CrmClaim, self).create(vals)

And this is my directory's structure

odoo

    |[...]
|Upgrade (This is mine)
| |crm_claim_create
| |crmClaimCreate.py
|
|crm (This is the one I'm trying to modify)
| |crm_claim_code
| |models
| | |crm_claim.py
| |views
| |crm_claim_view.xml
|OCB (Odoo's base one)
|addons
|crm_claim
|crm_claim.py

Any idea what's happening?

Thank you

1
Avatar
Opusti
Baiju KS

if it works, please mark it as correct

Avatar
Baiju KS
Best Answer

Hi,

The problem is with your inheritance,  you are using prototype inheritance instead of class inheritance. To extend the existing class you have to use class inheritance.

ie. if you want to extend the existing class you have to use _name attribute with same name as object or you don't have to give _name.

Please make the following change:

class CrmClaim(models.Model): 
    _name = "crm.claim"  
    _inherit = "crm.claim"

or

class CrmClaim(models.Model):  
 
   _inherit = "crm.claim"



Hope this helps.


1
Avatar
Opusti
Carlos DuAl
Avtor

Thank you! It works now

Avatar
ayman mohammed adam
Best Answer

Hi ,

you must use inherits to add new model name

    class CrmClaim(models.Model):        
    _name = "crm.claim.code"
    _inherits = "crm.claim"
or
class new_class_name(models.Model):
     _inherit = "crm.claim"
1
Avatar
Opusti
Carlos DuAl
Avtor

Thank you!

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
odoo server error
error field
Avatar
Avatar
1
maj 23
3836
Inherited field is not exist Error
error inheritance field odoo v15
Avatar
Avatar
Avatar
Avatar
Avatar
4
jan. 23
5458
Field not found in 'product.template.product.form' Solved
error field
Avatar
Avatar
2
mar. 18
5607
Attribute error in mail_thread and res_partner
error inheritance
Avatar
1
mar. 15
5815
move a field using inheritance
inheritance field
Avatar
Avatar
1
mar. 15
10075
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 ภาษาไทย 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