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

How know which dependency call a compute method if they are more than one? 

f1 = fields.Char()
f2 = fields.Char()
my_field = fields.Datetime(compute='_compute_my_field', store=True)
@api.multi
@api.depends
('f1','f2')
def _compute_my_field(self):
    # How know who called the method?
    pass
Avatar
Hylkää
Tekijä

@Sushma thank for your answer, but how know in the method _compute_my_field if the method has been called by the modification of f1 or f2?

Hi,

you can define some print statement in side method _compute_my_field or can run you're odoo server with debugging mode trace method _compute_my_field.

example:

@api.multi

@api.depends('f1','f2')

def _compute_my_field(self):

print "method _compute_my_field run"

pass

Note: For python 3, print( "method _compute_my_field run" )

You can check this print if you're running you're server using terminal not script.

Else you can enable debug mode to trace.

Tekijä

This not answer to my question... I always don't know if the method as been called because f1 has been altered OR f2.

Paras vastaus

Hi,

@api.depends decorator will trigger the call to the decorated function if any of the fields specified in the decorator is altered by ORM or changed in the form, to track you can use python print or debug tools to check it's behaviour.

 

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
lokak. 17
6791
2
heinäk. 24
1469
2
maalisk. 24
2035
2
syysk. 21
4846
4
huhtik. 20
9155