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

Hi all,

I have trouble understanding what is caching doing and Odoo and why in my case, a computed field computes the value for a lot of records, although I'm accessing the field for only one record. Here is some code example, where I have a One2many computed field:


invoice_ids = fields.Many2many(compute='_compute_invoices')

@api.model
def my_super_method(self):
    for record in self.search([('test', '=', True)]):
        if record.invoice_ids:
             print "yes!"

The problem is that the compute method '_compute_invoices' is called at each iteration with all records instead of just one record and it takes very long to recompute each time the value for all records. How can I compute only one record at a time ?

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يناير 25
788
1
سبتمبر 23
7222
compute issue تم الحل
1
مايو 21
3307
6
أكتوبر 18
6179
2
مايو 25
367