Skip to Content
Menu
This question has been flagged
4 Replies
16193 Views

For example, In SO I have a compute field "invoice due local currency" in list view.

In normal list view total is visible, but when i group the list by Salesperson/Customer the total will be gone.

How can i show total in group by without setting store=True.

Avatar
Discard
Best Answer

You need to inherit the read_group method of the model/class:
For example your field name is invoice_due_local_currency

class your_class(models.Model):
    # ...        
    @api.model 
    def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
        res = super(your_class, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
        if 'invoice_due_local_currency' in fields:
            for line in res:
                if '__domain' in line:
                    lines = self.search(line['__domain'])
                    total_invoice_due = 0.0
                    for record in lines:
                        total_invoice_due += record.invoice_due_local_currency
                    line['invoice_due_local_currency'] = total_invoice_due

        return res

Avatar
Discard

verified to be working

Thanks, it was very useful, it saved me a lot of time!

Great answer!

Best Answer

Hi Pranav: You will need to set store=True for this. Any particular reason why that is not an option for you other than the storage cost involved ?

Avatar
Discard
Author

Invoiced amount will change.

Best Answer

You only can achieve that with set store=True

Avatar
Discard