Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
1850 Prikazi

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.

Avatar
Opusti
Best Answer

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

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
0
nov. 24
1217
0
mar. 15
4838
0
jul. 25
150
0
jun. 25
431
1
jun. 25
686