Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

how to inherit without affecting original/parent model database

Odebírat

Get notified when there's activity on this post

This question has been flagged
inheritance
1 Odpovědět
6012 Zobrazení
Avatar
David Yao

Hi all, I'm getting little bit confused on how to do inheritance.

The case is that I want inheritance model "exist_A" and use it on model "new_B", of course, I want add some new field in new_B. In terms of database, I would like store them into model new_B. In another words, without affecting exist_A database. Is there any way to achieve this?

What I have tried is following:

PY file:

Class new_B(models.Model):

    # _name = new_B # if I define "_name", it shows that field "new_cloumn" not in " exist_A "

    _inherit = 'exist_A' # also I tried _inherits = { 'hr.expense':'id' }, but not sure this is the case I should use "_inherits"

    new_cloumn = fields.Char()

XML file:

<record id="tree_view_inherit_new_B" model="ir.ui.view">

    <field name="name"> tree.view.inherit.new_B </field>

    <field name="model">exist_A</field>

    <field name="inherit_id" ref=" exist_A.tree_view"/>

    <field name="mode">primary</field> <!-- other similar question's solution, but it is not working for me -->

    <field name="arch" type="xml">

        <xpath expr="//field[@name='name']" position="after">

            <field name="new_cloumn"/>

        </xpath>

    </field>

</record>


Any help will be appreciated! Thanks!

0
Avatar
Zrušit
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Nejlepší odpověď

Hi David,

You should use _inherits / delegation  in your case which will not affect the parent table in the database.

Difference between _inherit and _inherits

Sudhir Arya
ERP Harbor Consulting Services
Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
2
Avatar
Zrušit
David Yao
Autor

Thanks for reply, for using _inherits, I still got error saying that it can't find field new_cloumn. This is how I do it.

PY file changed to:

_name = new_B

_inherits = { 'exist_A':'new_cloumn' }

new_cloumn = fields.Many2one('exist_A')

Sudhir Arya (ERP Harbor Consulting Services)

Remove / comment "_inherits" and add delegate=True in your field.

EX: new_cloumn = fields.Many2one('exist_A', delegate=True)

David Yao
Autor

This is how it looks like after edit it:

PY file:

_name='new_B'

new_cloumn = fields.Many2one('exist_A', delegate=True)

Result: Error remains the same...

In terms of XML: for where need to refer to a model, I use exist_A, not new_B, does it matter? E.g. action: <field name="res_model">exist_A</field> view: <field name="model">exist_A</field>

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

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Can't inherit base.view_partner_form of res.partner
inheritance
Avatar
Avatar
Avatar
Avatar
Avatar
4
úno 25
4238
Include in inherit from JS class
inheritance
Avatar
Avatar
1
srp 24
2991
How to Override a method in parent class in JS Vyřešeno
inheritance
Avatar
Avatar
2
lis 24
4447
How to add a simple field to partner?
inheritance
Avatar
Avatar
Avatar
Avatar
3
říj 23
15789
Do I have to create a new module to change the standard form view?
inheritance
Avatar
Avatar
2
úno 23
3205
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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