تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
30704 أدوات العرض

For compute a field does it require @api.depends decorator


الصورة الرمزية
إهمال
أفضل إجابة

Hi Bro,
It's not mandatory to use the depends decorator, the compute field is run when the form is loaded or tree is loaded, as same time the compute function use many other fields, that time we need to add this fields in depends decorator, then its work fine, otherwise or some cases its make some issues.
So the best option is give the depend fields in depends decoder. 

الصورة الرمزية
إهمال
أفضل إجابة

Hi Vineeth,

Yes, for compute field you must apply @api.depends decorator to specify the field dependencies; those dependencies are used to determine when to recompute the field.


Hope this helps.

الصورة الرمزية
إهمال

I prefer this answer : I found a solution which worked with @api.depends(...),

then I dropped the @api.depends(...) line in my code and the field was not updated dynamically anymore in the form (even if the field remained computed on form load)

so, I put the @api.depends(...) back !

أفضل إجابة

It's not mandatory use depends decorator, if computed fields isn't store True code should be like this:

@api.one

def _compute_fieldA

@api.depends must be used like a trigger, for example if you want to recompute some function field when other field change.

@api.multi

@api.depends('fieldB')

def _compute_fieldA(self)

الصورة الرمزية
إهمال