Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Views affect back on inherited views.

Naroči se

Get notified when there's activity on this post

This question has been flagged
viewsinheritancesequencepriority
2 Odgovori
6421 Prikazi
Avatar
Kai Brossmann

I have created a model and a view that inherits the sale.order view and adds som custom field to it. I do not want to modify the original sale order view.

This code will (almost) do what I need:

    <record id="work_order_form" model="ir.ui.view">
        <field name="name">Workorder Form View</field>
        <field name="model">sale.order</field>
        <field name="priority" eval="10"/>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <!--<field name="mode">primary</field> -->
        <field name="arch" type="xml">
            <xpath expr="//field[@name='partner_id']" position="after">
                <field name="custom_field_1"/>
                <field name="custom_field_2"/>
            </xpath>
        </field>
    </record>


Now within my model it will open the work order view and display my custom fields.Good!

Going back to the sales model you have two options 1. Quotation and  2. Order.

When I open a Sales order it has not changed the original sale.order.form view. Good!

But, still within the sale model if you open or create a new quotation though, it will also add my custom fields.

Within developer mode I can see that somehow my model has chaged the original quotation view (sale.view_order_form) into my view (work_order_form).

Somehow the quotation view (usually the same view as sale.order) has changed to the workorder view

A Sale Order (choose Order from Menu) is not affected.

I played around with the priority (changed it to higher or lower priorities) but that didn't really get a better result.

Can someone help and explain this strange behavior? Thanks


1
Avatar
Opusti
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

If you inherit any view, basically the original view will have your changes as well and that is the use of inheritance.

In your case, you just don't want to show your custom fields to SO/Quotation menu and you can do it by hiding those custom fields from the original view/menu and just show them in your menu.

First, you should create a new action, add it in your menu and add something in the context of the action to show/hide the custom fields.

<record id="my_custom_action_orders" model="ir.actions.act_window">
<field name="name">Sales Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'show_custom': True}</field>
</record>

Now, use the context value to show/hide the custom fields in your view as follow:

<xpath expr="//field[@name='partner_id']" position="after">
<field name="custom_field_1" invisible="not context.get('show_custom', False)"/>
<field name="custom_field_2" invisible="not context.get('show_custom', False)"/>
</xpath>

This way, your custom fields will be visible in your new menu (because the action context has "show_custom": True) and will be hidden in original views/menus.

I hope this will solve your problem.

6
Avatar
Opusti
Kai Brossmann
Avtor

Works perfect, thanks a lot.

One last question: Do I have to do this for each custom field or is there a way to apply ('show_custom' , False) to all my custom fields (I have quite a few) within that view.

Anyhow, I am very happy!

Sudhir Arya (ERP Harbor Consulting Services)

Happy to know this worked.

Yes, use the context to hide all your fields from other menus/views.

Avatar
Niyas Raphy (Walnut Software Solutions)
Best Answer

Hi.

Either you can set the mode as primary and see, also give priority value greater than 16. See the below sample:

<record id="sale_onboarding_quotation_layout_form" model="ir.ui.view">
<field name="name">sale.onboarding.quotation.layout.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_document_template_form" />
<field name="mode">primary</field>
<field name="priority">1000</field>
<field name="arch" type="xml">
<xpath expr="//button[@special='save']" position="replace">
<button string="Apply" class="btn btn-primary" type="object" name="action_save_onboarding_quotation_layout" />
</xpath>
</field>
</record>

Thanks

1
Avatar
Opusti
Kai Brossmann
Avtor

Dear Niyas thank you for your answer. When I implement your solution I have two results. If I use eval="1000" non of the views (including my own) will display my custom fields. So I tried different priorities and found out that everything >20 will give me the same result. Only when I use eval="20" or smaller my custom fields will reappear. But, in this case, also in the Quotation view from the sale model. I also tend to think that the problem is somehow linked the action calling the wrong view. Why only the quotation action (and not also the Orders action) behaves like this?

Niyas Raphy (Walnut Software Solutions)

you can specify the views in corresponding menus, did you tried using mode primary ?

see this: https://www.youtube.com/watch?v=-2EAt9nN4o0

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
View inheritance hiding a field
views inheritance
Avatar
Avatar
1
nov. 24
2519
Change the Position of field in Xpath Solved
views inheritance
Avatar
Avatar
Avatar
Avatar
Avatar
5
jul. 24
95643
How to extend a base template for a specific page only, without affecting other pages that use the same base template?
views inheritance
Avatar
Avatar
1
dec. 23
3952
removing elements from an inherited view
views inheritance
Avatar
Avatar
1
maj 22
4957
I am building a custom module that has a dependent module that has extended the base view of res_partner. In my custom module I also have an inherited view of the base res_partner view. In it how do I hide the inherited view of my dependent module?
views inheritance
Avatar
0
jan. 20
3480
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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