Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Odoo 16 - How to run an XML code only when "iself_pos_activated" field is true?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
xmlt-ifodoo16features
1 Respondre
4151 Vistes
Avatar
meriem

ODOO-16

I want that once the "iself_pos_activated" is True the Code under PaymentScreen.xml works :

In my self_pos/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml I used to have this :

    <t t-name="PaymentScreen" t-inherit="point_of_sale.PaymentScreen" t-inherit-mode="primary" owl="1"  >
        <xpath expr="//div[hasclass('right-content')]" position="replace" >
        xpath>
         <xpath expr="//div[hasclass('payment-buttons-container')]" position="replace" >
        xpath>
    t>

I declared "iself_pos_activated" under /self_pos/models/pos_config.py :

class PosConfig(models.Model):
    _inherit = 'pos.config'

    iself_pos_activated = fields.Boolean('Self POS',help="The self POS is available on this shop",default=False)

In the /selfpos/views/posconfig.xml I called the iself_pos_activated, so I can change it either True or False in my pos settings :

"1.0" encoding="utf-8"?>
<odoo>   

        <record id="view_pos_config_form" model="ir.ui.view">
        <field name="model">pos.configfield>
        <field name="priority" eval="95"/>
        <field name="inherit_id" ref="point_of_sale.pos_config_view_form" />
        <field name="arch" type="xml">
           <xpath expr="//div[@id='other_devices']" position="after"> 
             <div class="col-12 col-lg-6 o_setting_box" id="iself_pos_activated">
                <div class="o_setting_left_pane">
                    <field name="iself_pos_activated"/>
                div>
                <div class="o_setting_right_pane">
                    <label for="iself_pos_activated"/>
                    <div class="text-muted">
                    Enables the self POS for this shop ...
                    div>
                    <div class="content-group mt16" attrs="{'invisible' : [('iself_pos_activated', '=', False)]}">
                    div>
                div>
            div> 
           xpath>
        field>
    record>
odoo>

Now, I tried this in my PaymentScreen.xml file :

"1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">

    <t t-name="PaymentScreen" t-inherit="point_of_sale.PaymentScreen" t-inherit-mode="primary" owl="1"    >
        <xpath expr="//div[hasclass('right-content')]" position="replace" >
<t t-if=" iself_pos_activated"> t>
        xpath>
         <xpath expr="//div[hasclass('payment-buttons-container')]" position="replace" >
<t t-if=" iself_pos_activated"> t>
        xpath>
    t>
templates>

But the Code under PaymentScreen.xml is being run wrongly and even I change the "iself_pos_activated" state (False or True) it's not running good.
So how should I call "iself_pos_activated" under .xml ? So that I run the PaymentScreen.xml code only when iself_pos_activated is TRUE.

----------------------------------------

Otherwise if I try with this in my PaymentScreen.xml :

    <t t-name="PaymentScreen"  t-inherit="point_of_sale.PaymentScreen" t-inherit-mode="primary" owl="1" t-if=" iself_pos_activated"    >
        <xpath expr="//div[hasclass('right-content')]" position="replace" >
        xpath>
         <xpath expr="//div[hasclass('payment-buttons-container')]" position="replace" >
        xpath>
    t>    

I get this error fot both cases, either iself_pos_activated is True or False :

point_of_sale.assets.min.js:678 TypeError: Cannot read properties of null (reading 'addEventListener') at point_of_sale.pos_as…kend.min.js:1558:24 at ProductScreen. (web.assets_common.min.js:1929:145) at RootFiber.complete (web.assets_common.min.js:1331:196) at Scheduler.processFiber (web.assets_common.min.js:1898:43) at web.assets_common.min.js:1894:109 at Set.forEach () at web.assets_common.min.js:1894:87

0
Avatar
Descartar
meriem
Autor

Hello Sachin,
Thank you for your response.
But the same error is remaining.

Best,

Avatar
Savya Sachin
Best Answer

Hi,

Please try this way,


<t t-name="PaymentScreen" t-inherit="point_of_sale.PaymentScreen" t-inherit-mode="primary" owl="1" t-if="widget.pos.config.iself_pos_activated">
<YOUR XML CODE>
</t>


Thanks

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

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

Registrar-se
Related Posts Respostes Vistes Activitat
Use t-if in website module
t-if odoo16features
Avatar
Avatar
1
de juny 23
2304
warnings.warn(f"The <act_window> tag is deprecated, use a <record> for {xml_id!r}.", DeprecationWarning)
xml odoo16features
Avatar
Avatar
Avatar
2
de juny 23
5906
(Odoo 16) widget: many2many_checkboxes need more features
xml widget odoo16features
Avatar
Avatar
1
de maig 24
2815
Problem with an invisible condition in an XML template file
xml plugin odoo16features
Avatar
1
d’abr. 24
2756
How to make a field ReadOnly in Inherited View Based on Groups Using Xpath
xml groups odoo16features
Avatar
Avatar
1
de febr. 24
4072
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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