Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1090 Vistas

V16

Avatar
Descartar
Mejor respuesta

Hi,

1. In the XML Template, we have to inherit the point_of_sale.PaymentScreen, after inheriting the template, we can add the buttons

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-inherit="point_of_sale.PaymentScreen" t-inherit-mode="extension">
<xpath expr="//div[hasclass('payment-controls')]" position="inside">
              <div>
                  <div id="my_button" class="button js_invoice"
                      t-on-click="IsCustomButton">
                      <i class="fa fa-spinner fa-spin"/> Click me
                  </div>
              </div>
          </xpath>
  </t>
</templates>


2. In the JS
odoo.define('pos_button.CustomButtonPaymentScreen', function(require) {
'use strict';
  const { Gui } = require('point_of_sale.Gui');
  const PosComponent = require('point_of_sale.PosComponent');
  const { identifyError } = require('point_of_sale.utils');
  const ProductScreen = require('point_of_sale.ProductScreen');
  const { useListener } = require("@web/core/utils/hooks");
  const Registries = require('point_of_sale.Registries');
  const PaymentScreen = require('point_of_sale.PaymentScreen');
  const Chrome = require('point_of_sale.Chrome');

   const CustomButtonPaymentScreen = (PaymentScreen) =>
       class extends PaymentScreen {
           setup() {
               super.setup();
               useListener('click', this.IsCustomButton);
           }
           IsCustomButton() {
              // click_invoice
              Gui.showPopup("ConfirmPopup", {
                      title: this.env._t('Title'),
                      body: this.env._t('Welcome to OWL(body of popup)'),
                  });
          }
      };
   Registries.Component.extend(PaymentScreen, CustomButtonPaymentScreen);
   return CustomButtonPaymentScreen;
});

For more information, refer to the blog:
https://www.cybrosys.com/blog/how-to-add-a-custom-button-in-the-pos-screen-odoo-16#:~:text=To%20add%20a%20button%20in,Systray%20and%20payment%20screen.

Hope it helps

Avatar
Descartar
Mejor respuesta

Hi 

check this references

Custom Button in POS

Regards

Avatar
Descartar