Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
33313 Vizualizări

i have pos_order_total field in contact tree view , and it's calculates perfecly if store=False , but if store=True it doesnt calculates if i make another pos order for client. how can i make this work with store=True. 
Maybe i need to add some depends fields. i tryed

from odoo import api, fields, models


class ResPartner(models.Model):
    _inherit = 'res.partner'
    
    order_id = fields.One2many('pos.order', 'amount_total') pos_order_total = fields.Monetary( string='POS Order Total', compute='_compute_pos_order_total', store=True)

    @api.depends('order_id') def _compute_pos_order_total(self): Order = self.env['pos.order'] for partner in self: total = 0.0 domain = [('partner_id', '=', partner.id)] for o in Order.search(domain): total += o.amount_total partner.pos_order_total = total
Imagine profil
Abandonează

When you keep store=True, your compute function will be only called when the depends field value is changed.

In your above code, if store=True

_compute_pos_order_total will only be called if order_id field is changed in partner.

Hope this helps.

Thank You

Related Posts Răspunsuri Vizualizări Activitate
1
sept. 19
8517
9
mar. 20
42101
1
mai 19
3828
2
oct. 18
4011
1
oct. 17
4251