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

View extension and model inheritance

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
2 Replies
6860 Rodiniai
Portretas
Sebastián Seifert

Hi, 

I´m trying to create a base module with some other modules extending it, and adding more functionality to this base module.

In order to extend de base module, I´m using inheritance without changing the _name field, using only the field _inherit. (I´ll copy my code at the end).

To extend the views of the model I´m using extension inheritance.

Everything works fine the first time I install all modules, but when I try to update the base module, the server will throw and exception because it can´t find the fields from the subclases for the already extended view.

I´ve managed to make it work running an sql script that erase this views. But i would like not to do that, just get the base module updated clicking on the update button of the module. 

I´ll copy my code now.

class document(models.Model):
 
     _name = 'document_control_base.document'

       @api.model
     def _get_resources_list(self):
            model_obj = self.env['document_control_base.resource_type']
            return model_obj._get_resources_list()
        
       STATE_SELECTION = [('active', 'Vigente'),('to_expire', 'Proximo a vencer'),('expired', 'Vencido')]

      name = fields.Char("Nombre",readonly=True,store=True,compute='_compute_name')
  document_name_id = fields.Many2one("document_control_base.document_name","Nombre del documento")
document_condition_ids = fields.Many2many("document_control_base.document_condition", "document_condition_rel", "document_id", "condition_id", "Condiciones del documento")
res_partner_id = fields.Many2one("res.partner",string="Empresa/Recurso Externo")
...

class document(models.Model):
    _inherit = 'document_control_base.document'
    fleet_vehicle_id = fields.Many2one("fleet.vehicle",string="Vehiculo")

    @api.one
    @api.depends('file_name','res_partner_id','document_name_id','state','fleet_vehicle_id')
    def _compute_name(self):
        super(document, self)._compute_name()
    
    resid = self.fleet_vehicle_id.name if self.fleet_vehicle_id.name else ''
    self.name = resid.title() + self.name
...
<record id="document_control_base.document_form" model="ir.ui.view">
<field name="model">document_control_base.document</field>
<field name="arch" type="xml">
<form string="Documentos">
<sheet>
<label for="name" class="oe_edit_only" />
<h1>
<field name="name" class="oe_edit_only" />
</h1>
<group>
<field name="res_type" class="oe_edit_only oe_inline" widget="radio"/>
<field name="res_partner_id" domain="['|','&amp;','&amp;','&amp;',('is_company', '=', False),('parent_id', '!=', False),
('active', '=', True),('employee','=',False),'&amp;','&amp;','&amp;',('is_company', '=', True),('parent_id', '=', False),('active', '=', True),('employee','=',False)]"
attrs="{'invisible':[('res_type', '!=', 'res.partner')]}" class="oe_edit_only"/>
</group>
<group>
<group>
<field name="file_binary" filename="file_name" />
<field name="file_name" class="oe_inline oe_right" invisible="1" />
<field name="document_name_id" domain="[('res_type','=',res_type)]"/>
<field name="document_condition_ids" widget="many2many_tags" />
<field name="description" />
</group>
</group>
<group>
<field name="no_expiration" />
<field name="expiration_id"
attrs="{'invisible':[('no_expiration','=',True)]}"
context="{'form_view_ref': 'document_control_base.expiration_form','resources':'expirations','name':'Vencimiento:','res_partner_id':res_partner_id,'document_name_id':document_name_id}" />
<field name="in_renewal" />
<field name="state" readonly="1" class="oe_edit_only" />
</group>
</sheet>
</form>
</field>
</record>
....
<record model="ir.ui.view" id="document_control_base.document_form_fleet">
<field name="model">document_control_base.document</field>
<field name="inherit_id" ref="document_control_base.document_form" />
<field name="arch" type="xml">
<field name="res_partner_id" position="after">
<label for="fleet_vehicle_id" attrs="{'invisible':[('res_type', '!=', 'fleet.vehicle')]}" class="oe_edit_only" />
<field name="fleet_vehicle_id" attrs="{'invisible':[('res_type', '!=', 'fleet.vehicle')]}" class="oe_edit_only"/>
</field>
<field name="expiration_id" position="attributes">
<attribute name="context">{'form_view_ref': 'document_control_base.expiration_form','resources':'expirations','name':'Vencimiento:','res_partner_id':res_partner_id,'fleet_vehicle_id':fleet_vehicle_id,'document_name_id':document_name_id}</attribute><!-- <attribute name="context" add=" py.PY_setItem(py.evaluate(expr.first, context),'fleet_vehicle_id', fleet_vehicle_id)" separator=" "></attribute> -->
</field>
</field>
</record>
0
Portretas
Atmesti
Ameera PP

why using 2 classes here?

Sebastián Seifert
Autorius

The first is from the base module. The second is from the extending module, there are several modules extending the base class. Fleet is only one. And their are installed separately. I can´t erase the answer. Sorry.

Portretas
Sebastián Seifert
Autorius Best Answer

The first is from the base module. The second is from the extending module, there are several modules extending the base class. Fleet is only one. And their are installed separately. 

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

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

Registracija
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