Skip to Content
Menu
This question has been flagged
2 Replies
3806 Views

Hello everybody!!!

I want to inherit the popup that is open in creation of a new variant of article in a purchase order.

I want to add an event in sale.ProductConfiguratorMixin.

I have tried this but still need your help please.

odoo.define('test.SProductConfiguratorMixin', function (require) {
'use strict';

var ProductConfiguratorMixin = require('sale.ProductConfiguratorMixin');

var SProductConfiguratorMixin = ProductConfiguratorMixin.include({

events: {
'change .totalAmt': 'onChangePriceUnit',
},
Avatar
Discard
Best Answer

ProductConfiguratorMixin is not inherited from odoo class so it's could not change it using .extend or .include
it's a plain javascript object so you extend it using javascript a prototype.
comment here if you need more help

Avatar
Discard
Best Answer

Hello Ravi, 

I have the same problem, so if you want, i would need your help for extend one method of this class. Thanks :)

Avatar
Discard

var ProductConfiguratorMixin = require('sale.ProductConfiguratorMixin');

var original = ProductConfiguratorMixin.onChangeAddQuantity;

ProductConfiguratorMixin.onChangeAddQuantity = function () {

original.apply(this, arguments);

console.log('My Overriden method ');

};

Oh Thank you !

But I have this error : TypeError: Cannot read property 'find' of undefined

Why ?

I'm beginner, so I'm lost, sorry :(

Thanks for your time.

it seems TypeError came from the other part of the code. it's not due to the above changes

thank you Ravi. I used an another method.

Thanks ;)

I originally thought monkey patching would work, just like Ravi Gadhia suggested, but it seems it does not(at least on Odoo 12.0). I also needed to extend ProductConfiguratorMixin, just a different method. But when I try to use it, it still calls original method, ignoring my patch.

It seems, it just generates object from original implementation. So monkey patch acts like `extend`, instead of `include`.

i also had an idea to then redefine `sale.ProductConfiguratorMixin`, but Odoo does not allow that, saying such service is already defined.

Anyone know if there is workaround?

Related Posts Replies Views Activity
6
May 19
5405
4
Aug 24
9045
0
May 22
1606
4
Sep 21
10730
0
Apr 20
2691