Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • 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 Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and 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
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Error Context - field does not exist

Odoberať

Get notified when there's activity on this post

This question has been flagged
errorinheritancefieldcontext
2 Replies
18923 Zobrazenia
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
Zrušiť
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
Zrušiť
Carlos DuAl
Autor

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
Zrušiť
Carlos DuAl
Autor

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!

Registrácia
Related Posts Replies Zobrazenia Aktivita
odoo server error
error field
Avatar
Avatar
1
máj 23
3862
Inherited field is not exist Error
error inheritance field odoo v15
Avatar
Avatar
Avatar
Avatar
Avatar
4
jan 23
5497
Field not found in 'product.template.product.form' Solved
error field
Avatar
Avatar
2
mar 18
5609
Attribute error in mail_thread and res_partner
error inheritance
Avatar
1
mar 15
5834
move a field using inheritance
inheritance field
Avatar
Avatar
1
mar 15
10087
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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