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

Parent foreign key in inheritance by delegation

Odebírat

Get notified when there's activity on this post

This question has been flagged
inheritance
4333 Zobrazení
Avatar
Gregoire Huet

Can you help me understand how inheritance by delegation works ? I've implemented the following:

# Generic service base model
class business_services(osv.Model):
    _name = "business.services"
    _description = "Business Services"
    _inherit = ['mail.thread', 'ir.needaction_mixin']

    _columns = {
        'name': fields.char('Service name', size=64, required=True),
         ...
    }
business_services()

# Specific service model
class business_service_service1(osv.Model):
    _name = 'business.service.service1'
    _inherits = {'business.services': 'service_id'}

    _columns = {
         'service_id': fields.many2one('business.services', 'Service ID',required=False,ondelete='cascade'),
         ... (other specific service1 columns)
    }
business_service_service1()

class business_service_service2(osv.Model):
    _name = 'business.service.service2'
    _inherits = {'business.services': 'service_id'}

    _columns = {
         'service_id': fields.related('service_id','business_services_id',type="many2one",relation="business.services",string="Service ID",required=False,ondelete='cascade'),
         ... (other specific service2 columns)
    }
business_service_service2()

I'm instantiating a new service thanks to a wizard that opens the proper view :

def action_view_business_services_add(self, cr, uid, ids, context=None):
    switch...
        res = {
            'name': 'Services',
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'business.service.service1',
            'view_id': False,
            'type': 'ir.actions.act_window',
 #            'context': "{'service_id':active_id}",
        }
        return res

This works fine, except for the relation between the _inheritsed object and its parent. I read on the doc that when one _inheritS a model, the instantation process populates the parent's table. In my case, the 'service_id' field never gets populated automatically :

  • The field is turned to required=True by the system
  • If I don't place the field, a field is created with name "Automatically created field to link to parent"

My problem is that at the moment, the system asks me to populate the field 'service_id' by hand. I would like it to have its value automatically set.

I see that there is such an implementation in product_template with field 'product_tmpl_id' acting as the foreign key, but i don't understand how it gets populated.

As in service2 in my example, i've seen that some implementations use a 'related' field, but i get no luck this way either. What's the proper way to achieve this ?

Thank you

0
Avatar
Zrušit
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
4527
Include in inherit from JS class
inheritance
Avatar
Avatar
1
srp 24
3126
How to Override a method in parent class in JS Vyřešeno
inheritance
Avatar
Avatar
2
lis 24
4628
How to add a simple field to partner?
inheritance
Avatar
Avatar
Avatar
Avatar
3
říj 23
15919
Do I have to create a new module to change the standard form view?
inheritance
Avatar
Avatar
2
úno 23
3306
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