跳至内容
菜单
此问题已终结
1 回复
3120 查看

I want to add new order button in pos product screen with function.

形象
丢弃
最佳答案

Hi,

Try to add the Odoo version along with your question.

Using the below code you can add button in odoo 16.

Added JS files and XML files to the src folder. The manifest.py

'assets': {
'point_of_sale.assets': [
'module_name/static/src/js/filename.js',
'module_name/static/src/xml/filename.xml',
],
},

In .xml

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


<templates id="template" xml:space="preserve">


  <t t-name="CustomDemoButtons" owl="1">


      <div class="control-button" style="color:red">


          <i class="fa fa-eraser"> </i>


          <span> </span>


          <span>Click me</span>


      </div>


  </t>


</templates>


After adding the button, we have to add the JS file. And in the JS file we have to define the module using odoo.define and define the required screens.

odoo.define('pos_button.Custom', 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');
  class CustomDemoButtons extends PosComponent {
      setup() {
          super.setup();
          useListener('click', this.onClick);
      }
     async onClick() {
               const { confirmed} = await
this.showPopup("ConfirmPopup", {
                      title: this.env._t('Title of the Popup?'),
                      body: this.env._t('Body of the popup'),
                  });
                 }
  }

CustomDemoButtons.template = 'CustomDemoButtons';
  ProductScreen.addControlButton({
      component: CustomDemoButtons,
      condition: function() {
          return this.env.pos;
      },
  });
  Registries.Component.add(CustomDemoButtons);
  return CustomDemoButtons;
});

In this way you can add a button anywhere in the pos screen like systray, payment screen etc

Regards

形象
丢弃
编写者

Thanks For Your Answer. But I want to create one order save to draft to other order continue .How to do it? Plz Help Me.