跳至內容
選單
此問題已被標幟
1 回覆
1855 瀏覽次數

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
11月 24
1219
0
3月 15
4839
0
7月 25
171
0
6月 25
433
1
6月 25
689