Odoo Help

2

0
2 Answers
0
Christian
2018/12/19 上午8:01

Hello,

How invalidate_all()  is supposed to be used ? In V11 CE, I am trying to call :

self.env.invalidate_all()

in write overload. It causes this error :

AttributeError: 'Environment' object has no attribute 'invalidate_all'
Thanks for any information.

Edit :
found another way to solve my problem. Record rules based on many2many relationship were not applied when many2many fields values were modified.

This override solved my problem, don't know if I'm doing right :
@api.multi 
def write(self, vals): 
ret = super(MyModel, self).write(vals)
if 'my_many2many_field' in vals:
    self.env['ir.rule'].clear_caches()
return ret

0
Pinnacle Promotions
2017/8/30 上午11:05

I assume you are talking about the ORM cache.

Clearing caches can be performed using the invalidate_all() method of the Environment object.

https://www.odoo.com/documentation/10.0/reference/orm.html#low-level-sql


Ask a Question
Writer
Tags
Keep Informed
5 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now