콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3146 화면

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.