Кнопки действий

`` Action Buttons`` - это следующие кнопки:

  • `` Note``
  • `` Transfer``
  • `` Guests``
  • `` Bill``
  • `` Split``
  • `` Order``
  • `` Discount``
  • и т.п.

которые расположены выше ** Numpad **.

  • Эти кнопки отображаются только после установки модуля ** pos_discount ** (кнопка `` Скидка``, позволяющая определить размер скидки на заказ) и модуля ** pos_restaurant ** (`` Split``, `` Гости`) `кнопки и т. д.)
  • Вы можете создавать свои собственные кнопки, назначая их действиям (например, ** open_popup **, ** screen ** и т. Д.).
  • Чтобы создать кнопку, вам нужно унаследовать ** ActionButtonWidget ** Class, выбрать ** define_action_button ** и выбрать необходимое действие после нажатия соответствующей кнопки.

Consider, for example, the way of creating a simple Button, which opens popup-window.

odoo.define('pos_popup_button', function (require){
  'use_strict';
  /*
  In order to use ActionButtonWidget, which specified in Screens
  please start with downloading the screens widget
  */

 var screens = require('point_of_sale.screens');

//declare a new variable and inherit ActionButtonWidget

var PopupButton = screens.ActionButtonWidget.extend({
  /*
  Thus PopupButton contains all methods from ActionButtonWidget.
  Now we need to define Template for our button,
  where the type of button you can find in Qweb (see below)
  */

template: 'PopupButton',
  /*
  We also need to choose the Action,
  which which will be executed after we click the button.
  For this purpose we define button_click method, where
  where name - Button name; widget - Button object;
  condition - Condition, which calls the button to show up
  (in our case, setting on show_popup_button option in POS config).
  */

button_click: function () {
  this.gui.show_popup('confirm', {
    'title': 'Popup',
    'body': 'Opening popup after clicking on the button',
    });
    }
  });

screens.define_action_button({
  'name': 'popup_button',
  'widget': PopupButton,
  'condition': function () {
  return this.pos.config.popup_button;
    },
    });
return PopupButton;
});

Определение `` template`` в `` Qweb``:

<t t-name="PopupButton">
  <div class="control-button">
    <i class="fa fa-list-alt" /> Popup Button
  </div>
</t>

Для конкретного примера проверьте модуль ** POS Orders History ** ` <https://github.com/it-projects-llc/pos-addons/blob/12.0/pos_orders_history/static/src/js/screens.js#L22>`__, где вы видите, что добавлена кнопка с надписью * История заказов *.