Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

[V11]Override everything in existing views

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
xmlviewbuttonoverride
3 Odpowiedzi
9045 Widoki
Awatar
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
Awatar
Odrzuć
Pujara Geet

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

Awatar
Zbik
Najlepsza odpowiedź


 

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

'depends': ['purchase'],

0
Awatar
Odrzuć
Awatar
Cayprol
Autor Najlepsza odpowiedź

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
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
[8.0] How to put a button at the label position? Rozwiązane
xml view button
Awatar
Awatar
1
kwi 17
4697
Dear Odoo, Can You Please Add "disabled" Attribute? Rozwiązane
attrs xml view button attributes
Awatar
Awatar
Awatar
2
wrz 24
5439
how shall I put a button in the center of its line? Rozwiązane
xml button
Awatar
Awatar
Awatar
2
lip 19
9876
How do I remove a button from the sale.order.form? Rozwiązane
xml view
Awatar
Awatar
Awatar
Awatar
Awatar
6
wrz 17
9423
display view if user is anonymous
xml view
Awatar
Awatar
1
mar 15
5180
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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