Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
1983 Widoki

Hello, 
I am trying to inherit Odoo 16 pos _getSearchFields js function and add a search field by the name Order Reference. It should appear as shown in the dropdown of the searchbar below.



How can I go about this?

Thanks in advance.

Here is my code.

oo.define('pos_customizations.TicketScreen', function (require) {
"use strict";
var TicketScreen = require("point_of_sale.TicketScreen");
TicketScreen.include({
/**
* @returns {Record string, displayName: string, modelField: string }>}
*/
_getSearchFields() {
const fields = {
RECEIPT_NUMBER: {
repr: (order) => order.name,
displayName: this.env._t('Receipt Number'),
modelField: 'pos_reference',
},
DATE: {
repr: (order) => moment(order.creation_date).format('YYYY-MM-DD hh:mm A'),
displayName: this.env._t('Date'),
modelField: 'date_order',
},
PARTNER: {
repr: (order) => order.get_partner_name(),
displayName: this.env._t('Customer'),
modelField: 'partner_id.display_name',
},
NAME: {
repr: (order) => order.name(),
displayName: this.env._t('Order Ref'),
modelField: 'name',
},
};
return fields;
}

})
return TicketScreen;
});


Awatar
Odrzuć
Autor Najlepsza odpowiedź

I found the solution to my question and here is the answer.

/** @odoo-module **/
odoo.define('pos_customizations.TicketScreen', function (require) {
'use strict';

const TicketScreen = require('point_of_sale.TicketScreen');
const Registries = require('point_of_sale.Registries');

const CustomTicketScreen = (TicketScreen) =>
class extends TicketScreen {
_getSearchFields() {
const fields = super._getSearchFields(name);
fields.ORDER_REF = {
repr: (order) => order.name,
displayName: this.env._t('Order Ref'),
modelField: 'name',
}
return fields;
}
};

Registries.Component.extend(TicketScreen, CustomTicketScreen);
return TicketScreen;
});


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lut 25
1747
1
mar 24
1846
2
cze 24
2781
1
lut 24
1556
0
lis 23
1420