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
    • 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 Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Producție
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and 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
  • 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

[V11]Override everything in existing views

Abonare

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

Această întrebare a fost marcată
xmlviewbuttonoverride
3 Răspunsuri
8960 Vizualizări
Imagine profil
Cayprol

Hi all,

I am trying to replace the position of smart button "Purchase" when viewing a product.

This smart button is injected by app "purchase" in the form view named "product.template.purchase.button.inherit"

Code is located in "purchase_views.xml" as below

<record id="view_product_template_purchase_buttons_from" model="ir.ui.view">

            <field name="name">product.template.purchase.button.inherit</field>
            <field name="model">product.template</field>
            <field name="inherit_id" ref="product.product_template_only_form_view"/>
            <field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]"/>
            <field name="arch" type="xml">
                <button name="toggle_active" position="before">
                   <button class="oe_stat_button" name="%(purchase.action_purchase_line_product_tree)d"
                       type="action" icon="fa-shopping-cart">
                       <field string="Purchases" name="purchase_count" widget="statinfo"/>
                   </button>
                </button>
            </field>
</record>

Most smart buttons are placed by view inheritance with """ <button name="toggle_active" position="before"> """ in another module/app

I'd like to override everything in this view record by creating and loading a new xml file in my custom module. My understanding is that I need to refer to the right record id to override it.

My xml code:

 <?xml version="1.0" encoding="utf-8" ?>

<odoo>
 <data>
      <record id="purchase.view_product_template_purchase_buttons_from" model="ir.ui.view">
         <field name="name">product.template.purchase.button.inherit</field>
         <field name="model">product.template</field>
         <field name="inherit_id" ref="product.product_template_only_form_view"/>
         <field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]"/>
         <field name="arch" type="xml">
            <button name="action_view_sales" position="after">
             <button class="oe_stat_button" name="%(purchase.action_purchase_line_product_tree)d" type="action" icon="fa-shopping-cart">
               <field string="Purchases" name="purchase_count" widget="statinfo"/>
             </button>
            </button>
         </field>
      </record>
 </data>
</odoo>

With my code, the error shows "purchase_count" is not found in model.

What is the correct way of replacing everything in existing view?

0
Imagine profil
Abandonează
Pujara Geet

Did You Taken Field "purchase_count" on .py File?.

Imagine profil
Zbik
Cel mai bun răspuns


 

In __manifest__.py (in your module), try this

'depends': ['purchase'],

0
Imagine profil
Abandonează
Imagine profil
Cayprol
Autor Cel mai bun răspuns

Hey guys, thank you for your help.

I did some testing today, though I am able to solve the problem by using Zbik's answer by including purchase module as dependency.
However, not every field needed to be addressed or CAN be addressed by adding module to dependencies.

I also tried to override record id "product_template_form_view_procurement_button" in the stock module(product.views.xml).
The button name to "Update Qty on Hand" cannot be found due to error shown as "Not being able to locate action_view_change_product_quantity", the original code:

<header position="inside">
    <button string="Update Qty On Hand"
            type="action" name="%(action_view_change_product_quantity)d"
            attrs="{'invisible': [('type', '!=', 'product')]}"/>
</header> 

In my override xml file, I solved the problem by changing this sector of code to:

<header position="inside">
    <button string="Update Qty On Hand"
            name="%(stock.action_view_change_product_quantity)d"             type="action"             attrs="{'invisible': [('type', '!=', 'product')]}"/>
</header>

With this, I don't need to include stock in 'depends' = ['stock'] in __manifest__.py

I am very curious why, but I suppose it has to do with the sequence of Odoo loading each module?


Here's all the override xml code

<?xml version="1.0" encoding="utf-8" ?>


<odoo>
 <data>

  <!-- Override view_product_template_purchase_buttons_from in purchase -->
        <record id="purchase.view_product_template_purchase_buttons_from" model="ir.ui.view">
         <field name="name">product.template.purchase.button.inherit</field>
         <field name="model">product.template</field>
         <field name="inherit_id" ref="product.product_template_only_form_view"/>
         <field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]"/>
         <field name="arch" type="xml">
    <button name="action_view_sales" position="after">
     <button class="oe_stat_button" name="%(purchase.action_purchase_line_product_tree)d" type="action" icon="fa-shopping-cart">
      <field string="Purchases" name="purchase_count" widget="statinfo"/>
     </button>
    </button>
   </field>
  </record>

  <!-- Override product_template_form_view_procurement_button in stock -->
  <record id="stock.product_template_form_view_procurement_button" model="ir.ui.view">
   <field name="name">product.template_procurement</field>
   <field name="model">product.template</field>
   <field name="inherit_id" ref="product.product_template_only_form_view"/>
   <field name="arch" type="xml">
    <data>

     <header position="inside">
      <button name="%(stock.action_view_change_product_quantity)d" string="Update Qty On Hand" type="action" attrs="{'invisible': [('type', '!=', 'product')]}"/>
     </header>

     <button name="toggle_active" position="before">

      <button type="object" name="action_open_quants" attrs="{'invisible':[('type', '!=', 'product')]}" class="oe_stat_button" icon="fa-building-o">
       <field name="qty_available" widget="statinfo" string="On Hand"/>
      </button>

      <button string="Product Moves" type="object" name= "action_view_stock_move_lines" attrs="{'invisible':[('type', 'not in', ['product', 'consu'])]}" class="oe_stat_button" icon="fa-arrows-v" groups="stock.group_stock_user"/>
      <button type="object"
                      name="action_view_orderpoints"
                      attrs="{'invisible':['|',('type', '!=', 'product'),('nbr_reordering_rules', '==', 1)]}"
                      class="oe_stat_button"
                      icon="fa-refresh">
       <field name="nbr_reordering_rules" widget="statinfo"/>
      </button>

      <button type="object" name="action_view_orderpoints" attrs="{'invisible':['|',('type', '!=', 'product'),('nbr_reordering_rules', '!=', 1)]}" class="oe_stat_button" icon="fa-refresh">
       <div class="o_field_widget o_stat_info mr4">
        <span class="o_stat_text">Min:</span>
        <span class="o_stat_text">Max:</span>
       </div>
       <div class="o_field_widget o_stat_info">
        <span class="o_stat_value"><field name="reordering_min_qty"/></span>
        <span class="o_stat_value"><field name="reordering_max_qty"/></span>
       </div>
      </button>

      <button string="Routes" type="object" name="action_view_routes" attrs="{'invisible':[('type', '!=', 'product')]}" class="oe_stat_button" icon="fa-cogs" groups="base.group_no_one"/>

      <button string="Lot/Serial Number" type="object" name="action_open_product_lot" attrs="{'invisible': [('tracking', '=', 'none')]}" class="oe_stat_button" icon="fa-bars" groups="stock.group_production_lot"/>

     </button>

     <button name="toggle_active" position="after">
      <button type="action" name="%(stock.action_stock_level_forecast_report_template)d" attrs="{'invisible':[('type', '!=', 'product')]}" class="oe_stat_button" icon="fa-building-o">
       <div class="o_field_widget o_stat_info">
        <span class="o_stat_value"><field name="virtual_available" widget="statinfo" nolabel="1"/>
         <span attrs="{'invisible':[('outgoing_qty', '=', 0),('incoming_qty','=',0)]}" groups="base.group_no_one">
                                  (-<field name="outgoing_qty" widget="statinfo" nolabel="1"/>+<field name="incoming_qty" widget="statinfo" nolabel="1"/>)
         </span>
        </span>
        <span class="o_stat_text">Forecasted</span>
       </div>
      </button>
     </button>


     <xpath expr="//group[@name='group_lots_and_weight']" position="attributes">
      <attribute name="attrs">{'invisible':['|', ('type', 'not in', ['product', 'consu']), ('product_variant_count', '&gt;', 1)]}</attribute>
     </xpath>

     <xpath expr="//group[@name='group_lots_and_weight']" position="inside">
      <field name="responsible_id"/>
     </xpath>

          </data>
      </field>
  </record>

 </data>
</odoo>
Link to final result screenshot: https://imgur.com/h19PeLI

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
Related Posts Răspunsuri Vizualizări Activitate
[8.0] How to put a button at the label position? Rezolvat
xml view button
Imagine profil
Imagine profil
1
apr. 17
4602
Dear Odoo, Can You Please Add "disabled" Attribute? Rezolvat
attrs xml view button attributes
Imagine profil
Imagine profil
Imagine profil
2
sept. 24
5314
how shall I put a button in the center of its line? Rezolvat
xml button
Imagine profil
Imagine profil
Imagine profil
2
iul. 19
9805
How do I remove a button from the sale.order.form? Rezolvat
xml view
Imagine profil
Imagine profil
Imagine profil
Imagine profil
Imagine profil
6
sept. 17
9300
display view if user is anonymous
xml view
Imagine profil
Imagine profil
1
mar. 15
5090
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