how to override method in javascript class in odoo 16 ?
the class name : SaleOrderFetcher
method name : _getOrderIdsForCurrentPage(limit, offset)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
how to override method in javascript class in odoo 16 ?
the class name : SaleOrderFetcher
method name : _getOrderIdsForCurrentPage(limit, offset)
odoo.define('pos_product_label.SaleOrderFetcher', function (require) {
'use strict';
const SaleOrderFetcher = require('pos_sale.SaleOrderFetcher');
SaleOrderFetcher._getOrderIdsForCurrentPage = async function (limit, offset) {
if (!this.comp || !this.comp.env || !this.comp.env.pos) {
console.error("this.comp or its nested properties are null/undefined.");
return [];
}
let domain = [['currency_id', '=', this.comp.env.pos.config.id],
['state', '=', 'draft']
);
try {
const saleOrders = await this.rpc({
model: 'sale.order',
method: 'search_read',
args: [domain, ['name', 'partner_id', 'amount_total', 'date_order', 'state', 'user_id', 'amount_unpaid'], offset, limit],
context: this.comp.env.session.user_context,
});
return saleOrders;
} catch (error) {
console.error("Error fetching sale orders:", error);
return [];
}
};
});
Hi,
Patching is a standard method for extending or overriding functionality, so we can use this patch to do just that.
For instance, use the code below and insert your logic within the function:
/** @odoo-module */
import { patch } from '@web/core/utils/patch';
import { SaleOrderFetcher } from '@web/views/saleOrder/saleorderfetcher';
patch(SaleOrderFetcher.prototype, {
async setup() {
super.setup();
},
_getOrderIdsForCurrentPage(limit, offset){
// you can write your logic here
}
});
Hope it helps.
Hi Zakariya Mahmoud,
Use Odoo Owl patch,
https://www.odoo.com/forum/help-1/updating-odoo15-js-to-odoo16-owl-230361
Thanks.
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 9 24
|
1428 | ||
|
1
thg 8 24
|
1354 | ||
|
1
thg 3 22
|
6744 | ||
|
0
thg 10 24
|
830 | ||
|
2
thg 7 24
|
2548 |