Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
1975 Переглядів

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
1345
0
бер. 15
4922
0
лип. 25
261
1
лип. 25
5033
0
лип. 25
589