I want to add some custom function or code in ProductScreen class in POS. But I didn't find any appropriate example. How can I extend odoo owl Component and override or add new function on it.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilità
- Magazzino
- PoS
- Project
- MRP
La domanda è stata contrassegnata
odoo.define('uni_pos.ProductScreen_PosLineDiscount', function(require) {
'use strict';
const Registries = require('point_of_sale.Registries');
const ProductScreen = require('point_of_sale.ProductScreen');
const PosLineDiscount = (ProductScreen) => class extends ProductScreen {
async _clickProduct(event) {
if (!this.currentOrder) {
this.env.pos.add_new_order();
}
const product = event.detail;
const options = await this._getAddProductOptions(product);
// Do not add product if options is undefined.
if (!options) return;
// Add the product after having the extra information.
this.currentOrder.add_product(product, options);
// this.currentOrder.get_selected_orderline().set_discount(5)
console.log('Product Add')
try {
NumberBuffer.reset();
}
catch(err) {
console.log(err)
}
}
};
Registries.Component.extend(ProductScreen, PosLineDiscount);
return ProductScreen;
});
Here is the answer, for extending a OWL class and adding and overriding a function.
You can use "patch"
/** @odoo-module **/
import { ClassYouWantToModify } from "path";
import { patch } from "@web/core/utils/patch";
patch(ClassYouWantToModify.prototype, "ModuleName.ClassYouWantToModify", {
/**
* @override the function or add new one
*/
});
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!
Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!
RegistratiPost correlati | Risposte | Visualizzazioni | Attività | |
---|---|---|---|---|
|
1
mag 23
|
3956 | ||
|
1
dic 22
|
3458 | ||
|
3
mar 25
|
7184 | ||
|
0
gen 24
|
1328 | ||
|
1
ott 23
|
3638 |