0% found this document useful (0 votes)
94 views

JS Access and Inheritance - Odoo Development Master Documentation

This document discusses two methods for accessing and inheriting from POS screen and action button classes in JavaScript: 1) To inherit action button classes, access the instance of the class through the GUI and inherit from that since the class is not directly returned. 2) To inherit screen classes, get the target class either from the screens module if it is defined there, or by filtering the GUI screen classes property if not. This allows extending or modifying the screen class.

Uploaded by

Dena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views

JS Access and Inheritance - Odoo Development Master Documentation

This document discusses two methods for accessing and inheriting from POS screen and action button classes in JavaScript: 1) To inherit action button classes, access the instance of the class through the GUI and inherit from that since the class is not directly returned. 2) To inherit screen classes, get the target class either from the screens module if it is defined there, or by filtering the GUI screen classes property if not. This allows extending or modifying the screen class.

Uploaded by

Dena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

12/30/2018 JS access and inheritance — Odoo development master documentation

Docs » Module Development » Point of Sale (POS) » JS access and inheritance

JS access and inheritance

action_button
Here you will find explana on of how to get/inherit ac on_bu on POS objects.

For example we have defini on in this file:

odoo.define('pos_reprint.pos_reprint', function (require) {


...
screens.define_action_button({
'name': 'guests',
'widget': TableGuestsButton,
'condition': function()

This defeni on doesn’t return class ReprintBu on. So, we cannot inherit it in a usual way.

In order to reach that object we need get instance of it using gui . Then we can inherit it

To make clear what this is like look up example where guests number bu on renderings:

this.gui.screen_instances['products'].action_buttons['guests'].renderElement();

While you can make call and even replace func on with new one, you are not able to make
inheritance via extend or include func ons. It’s because we cannot reach Class and only get
access to instance of that class.

This kind of approach make sense only for those widgets:

DiscountButton
ReprintButton
TableGuestsButton
SubmitOrderButton
OrderlineNoteButton
PrintBillButton
SplitbillButton
set_fiscal_position_button

https://odoo-development.readthedocs.io/en/latest/dev/pos/gui.html 1/3
12/30/2018 JS access and inheritance — Odoo development master documentation

screen_classes
To create new screen widget (via the extend() method) or to modify exis ng screen widget (via
the include() method) you need the target class. Usually you can get this class using following
code:

odoo.define('module_name.file_name', function (require) {


"use strict";

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

screens.OrderWidget.include({
...

But it is available only for widgets that are returned by main func on in the file
“point_of_sale/sta c/src/js/screens.js”.

List of the screens:

ReceiptScreenWidget
Ac onBu onWidget
define_ac on_bu on
ScreenWidget
PaymentScreenWidget
OrderWidget
NumpadWidget
ProductScreenWidget
ProductListWidget

In other cases you can get targeted screen widget class using following code:

odoo.define('module_name.file_name', function (require) {


"use strict";

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

gui.Gui.prototype.screen_classes.filter(function(el) { return el.name == 'clientlist'})


[0].widget.include({
...

List of screens available via screen_classes :


https://odoo-development.readthedocs.io/en/latest/dev/pos/gui.html 2/3
12/30/2018 JS access and inheritance — Odoo development master documentation
gui.define_screen({name: 'scale', widget: ScaleScreenWidget});
gui.define_screen({name: 'products', widget: ProductScreenWidget});
gui.define_screen({name: 'clientlist', widget: ClientListScreenWidget});
gui.define_screen({name: 'receipt', widget: ReceiptScreenWidget});
gui.define_screen({name: 'payment', widget: PaymentScreenWidget});
gui.define_screen({name: 'bill', widget: BillScreenWidget});
gui.define_screen({'name': 'splitbill', 'widget': SplitbillScreenWidget,
gui.define_screen({'name': 'floors', 'widget': FloorScreenWidget,

https://odoo-development.readthedocs.io/en/latest/dev/pos/gui.html 3/3

You might also like