Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Inhereting Sales Order form view in custom model

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
2 Răspunsuri
5718 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Falguni Tank
Cel mai bun răspuns

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
Imagine profil
Abandonează
Kai Brossmann
Autor

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.

Imagine profil
Kai Brossmann
Autor Cel mai bun răspuns

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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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