Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
3 Vastaukset
3934 Näkymät

Hi everyone,

Im trying to override a method that was already overridden in other own model. What happens is that i set a breaking point in my method but it does not in into the method.

The code in the model A:

@api.multi
def action_state_approve(self):
for state in self:
state.state = 'approved'

So in my other Model is where Im trying to override the above method:

class ClassB(models.Model):
_inherit = 'sale.order'

@api.multi
def action_state_approve(self):
super(ClassB, self).action_state_approve()
Avatar
Hylkää
Paras vastaus

Hi.

Do you have set the inheritted function model in your __openerp__.py file?

You have to declare it in the depends key.

Kind regards.

Avatar
Hylkää
Paras vastaus

return super(ClassB, self).action_state_approve()

Avatar
Hylkää
Paras vastaus

Dear Osmani

Try to override by using Super Class Like This:

   @api.multi
def action_state_approve(self):
res= super(ClassB,self).action_state_approve()
...........
return res

I hope I helped you ...
Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
kesäk. 15
3818
0
huhtik. 24
1852
4
marrask. 23
5936
0
lokak. 23
1707
2
kesäk. 23
2237