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

Inhereting Sales Order form view in custom model

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
2 Replies
5724 Rodiniai
Portretas
Kai Brossmann

I have some strange behavior when I inherit the sales order form view into my model/view.

I inherited the view into my model without changing the original view.

---

<record id="work_order_form" model="ir.ui.view">
        <field name="name">Extend the Sale Order</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="mode">primary</field>
        <field name="arch" type="xml">

            <field name="payment_term_id" position="after">
                <field name='my_field'/>
            </field>

        </field>
    </record>

---

Therefore I used the primary field (see my code) and I get what I want. Well...

My new view shows the extended field (my_field) and the sales order form view does not, as it should.


Within the sales module so, if I open a quotation, I can see that the quotation form also have the additional field (my_field). But if I am correct both (sales order & quotations use the same view i.e. sale.order.form)


For some reason quotations now also use the extended view.

Some of the code for completeness:

---

To open the view I added:

 <!-- Action to open the Workorder list -->
    <act_window id="action_yacht_service" name="Workorders"
                res_model="sale.order" view_mode="tree,form"/>

    <!-- Menu item to open the Workorder list -->
    <menuitem id="menu_yacht_service" name="Workorder"
              parent="menu_yachtservice" action="action_yacht_service" sequence="2"/>

---

code to inherit the model:

from odoo import fields, models


class YachtService(models.Model):
    _name = 'yacht.service'
    _description = 'Workorder Data'

    name = fields.Char(string="Name")
    description = fields.Text(string="Description")
    cost = fields.Float(string="Cost")



class WorkorderInheritSale(models.Model):
    _inherit = 'sale.order'

   my_field = fields.Boolean(string="Is Workorder")
   my_field_2 = fields.Boolean(string="Is Platzhalter 2")

Really confusing, pls help.


0
Portretas
Atmesti
Portretas
Falguni Tank
Best Answer

hello Kai Brossmann,
you need to give  proper xpath for inheriting base view of sale order and give the right external id (including right base module)

Hope this clarify your query..

0
Portretas
Atmesti
Kai Brossmann
Autorius

Thank you for your answer, is there any way to achieve this without xpath? I tried also a different attempt (see my 2nd post) but that seems to be a different issue altogether.

Portretas
Kai Brossmann
Autorius Best Answer

I think, I still haven't gotten my head around the view inheritance. I did more research and from what I can read inheritance delegation is used for what I have in mind. I.e. to create a new model based on an existing one, use the features it already has but also add some additional ones.  We use customized Workorders for our repairs but also the standard sales orders for retail etc.

So I tried _inherits and it looked very promising in the beginning.

class YachtService(models.Model):
    _name = 'yacht.service'
    _description = 'Workorder Data'
    _inherits = {'sale.order': 'partner_id'}
    partner_id = fields.Many2one(
        'sale.order',
        ondelete='cascade', required='false', string='Customer')

    my_field_2 = fields.Boolean(string="Is MyField 2")

My view looks like this:

<record id="work_order_form" model="ir.ui.view">
        <field name="name">workorder.form</field>
        <field name="model">yacht.service</field>
        <field name="inherit_id" ref="sale.view_order_form"/> 
        <field name="arch" type="xml">

            <field name="payment_term_id" position="after">
                <field name='my_field_2'/>
            </field>
        </field>
    </record>

Now when starting the model the form appears just like I want it to. The original sale.order.form is not modified, just like it should, sweet....

But the moment I enter data into the customer field (partner_id) I get the following error.

Error:
Odoo Server Error

Traceback (most recent call last):
>
>
>
    raise ValueError("Invalid field %r in leaf %r" % (left, str(leaf)))
ValueError: Invalid field 'customer' in leaf "<osv.ExtendedLeaf: ('customer', '=', True) on sale_order (ctx: )>"

I seem so close but now I have now idea where to pick up the tread..



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