Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
1874 Представления

Hi, i need to overwrite async apply_discount(pc) on pos_discount module. Can you guys help me how to properly overwrite this ?


Update: i have been following the answer given and when browser loading the page, i found that there are some error:

warning: Some modules could not be started

Missing dependencies: Array [ "point_of_sale.DiscountButton" ]

Non loaded modules: Array [ "custom_module.DiscountButton" ]

Is there any missing code that i need to apply ?


Thanks.

Аватар
Отменить
Лучший ответ

Hi,

To overwrite the 'apply_discount' function in the pos_discount module in Odoo 15, you can follow the code below:

odoo.define('Custom.DiscountButton', function (require) {

'use strict';

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

const DiscountButton = require('pos_discount.DiscountButton');


const CustomDiscountButton = DiscountButton =>

class extends DiscountButton {

async apply_discount(pc) {

// Add your custom code here

}

}

Registries.Component.extend(DiscountButton, CustomDiscountButton);

return DiscountButton;

});


Ensure to add the js file to the manifest under assets:

'assets': {

'point_of_sale.assets': ["path"]

}

Replace "path" with the actual path to your js file


Hope it helps

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
нояб. 24
1243
0
мар. 15
4850
0
июл. 25
262
0
июн. 25
490
1
июн. 25
711