Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

Writing two models toghether, in the same module, shows me a key error "account.invoice" (inherited model)

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
developmentmodulesinheritancemodelsclass
12 Replies
9486 Rodiniai
Portretas
Ing. Daniel Blanco

I am writing this code:

class my_class_a(models.Model):

[....]

class my_class_b(models.Model):

    _inherit = "res.partner"

   field_ids = fields.Many2Many(........)


class my_class_c(models.Model):

    _inherit = "account.invoice"

    field_myfield = fields.Char(....)


In this case, I am getting a "key error: account.invoice", but if put my_class_b in a separate module, everything works fine. Even get key error if y separate my_class_b in another file, and import it from __init__.py


Why is this for? 


[....]


0
Portretas
Atmesti
Nicolas PIGANEAU

Are you sure that your module depends on 'account' module in the __openerp__.py manifest?

ABU K

what is the use and what is the purpose behind this

ABU K

what is the use and what is the purpose behind this

Ing. Daniel Blanco
Autorius

There is a typo in the example. The last class is class_c

Ing. Daniel Blanco
Autorius

Nicolas. This was the cause. Thanks! If you want to convert as an answer in order for me to vote it

OdooBot
Two components that should work together, that for some reason I tested they worked fine, only when created as separate modules.. but the  problem was that in the manifest definition, where I should have included account as a dependency, as you see the answer.


Atte:



Ing. Daniel Blanco
Director
Blanco Martín & Asociados
Móvil: +56 9 73880409 / +54 9 351 228-0893
Skype: hdanielb
Twitter: hdanielb
http://linkd.in/danielblanco


Argentina:
BMyA S.A.
Nicasio 6970. Córdoba
+54 351 5694621 / +54 351 5691933
Argüello - Córdoba
http://www.blancomartin.com.ar

Chile: 
Blanco Martín EIRL
Apoquindo 6410 Of 212
+56 2 2840 0990 / +56 2 2979 0208
Las Condes - Región Metropolitana
http://www.blancomartin.cl




2015-03-31 4:13 GMT-03:00 Dep <libukoshym-gmail.com@mail.odoo.com>:

what is the use and what is the purpose behind this

--
Dep
Sent by Odoo Inc. using Odoo about Forum Post Writing two models toghether, in the same module, shows me a key error "account.invoice" (inherited model)

Portretas
Ing. Daniel Blanco
Autorius Best Answer

@Nicolas PIGANEAU:  

you made the thing! This was the cause! THANKS!

("Are you sure that your module depends on 'account' module in the __openerp__.py manifest? ")

In the merged module there was an empty depends declaration. I assumed that depends declaration was to force the module installation only, and as it was one of the main modules.

Cannot convert your comment as an answer because of karma. But you deserve. Thank you.

1
Portretas
Atmesti
Portretas
Temur
Best Answer
  • you're using the same name ( my_class_b ) for the two classes, while you're inheriting from different ones.

0
Portretas
Atmesti
Ivan

I think the _name has nothing to do with the problem. In fact, defining an ORM class with an explicitly different name from the original ORM model has it's own meaning (see https://doc.odoo.com/v6.0/developer/2_5_Objects_Fields_Methods/object_inherit.html/). But, yes, you should not define both class with the same name in the same file as only one will be registered. If you put it in different file, it will have different namespace. A namespace in python is defined, among other things, by the folder and file/module (a module in python is defined as a file) name. See https://docs.python.org/2/tutorial/classes.html#python-scopes-and-namespaces for more on namespace.

Temur

thanks @ivan, I know about meaning of _name, etc... but there I don't see sense to use same _name in two classes while inheriting one from "res.partner" and another from "account.invoice", as there is used same class name for both then "_name" will be the same also. it's not problem that "_name" is different from it's parents one(while it may be, regarding requirements), but it's problem that it's not different between these two classes... so if it's absolutely necessary to use same name for both class, then explicitly using "_name" and make them different from each other by the "_name" may help (?)

Ivan

AFAIK, if _name is not stated, the inheritance will just take the _name attribute from the class which is _inherit-ed. You can check the create_instance method of orm for v7.0 or _build_model of BaseModel for v8.0 to get a clearer picture of how this work. So, it is not OK to use the same class name (my_class_b) because of the Python namespace. It is OK to not explicitly specify the _name attribute if _inherit has been specified (and it will be derived from the _inherit attribute, not the class name, first). It is somewhat OK to explicitly specify _name if all the repercussions has been considered even if _inherit is specified (I wouldn't do this, but you might be able to get away by specifying the same value _name attribute, which will translate to table name if _table_name attribute is not specified).

Temur

as noted in the question namespace problem was resolved by putting my_class_b (probably one of them) in the separated module. I mean using same name for the two class in this conditions (putting them in different modules), without violating namespace rules. I tried to give second option, using _name but I see it doesn't gave anything. so I'll remove second one and leave just first note in my answer, as we are agree that using the same name for the two classes in the above code is causing the problem. thanks for your comments @Ivan

Ing. Daniel Blanco
Autorius

It was a typo in the example. Corrected.. but the problem persists

Ing. Daniel Blanco
Autorius

the _name field "IS" in the real code.

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

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

Registracija
Related Posts Replies Rodiniai Veikla
How to inherit from a Python class that isn't a model and also inherit a model
modules inheritance models version14
Portretas
0
lapkr. 20
6283
how to inherit view in existing module. Solved
views modules fields inheritance models
Portretas
Portretas
Portretas
3
saus. 22
54675
Odoo 18 - Custom Module - Error on nested class view Solved
development modules
Portretas
Portretas
Portretas
2
liep. 25
3678
classical inheritance
development inheritance
Portretas
Portretas
1
spal. 24
2523
How to upgrade modules in a specific file?
development modules
Portretas
0
kov. 24
2512
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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