Skip to Content
Menu
This question has been flagged
30565 Views

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
Avatar
Discard

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 Replies Views Activity
1
Sep 19
7534
9
Mar 20
40582
1
May 19
2835
2
Oct 18
2652
1
Oct 17
2866