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
Hello Sachin,
Thank you for your response.
But the same error is remaining.
Best,