Skip to Content
Menu
This question has been flagged
1 Reply
14508 Views

Working on Odoo 10 community.

If I create a computed field:

    quantity_ordered = fields.Float('Quantity Ordered')
    price = fields.Float('Price', help='Item Unit Net Price')
    price_total = fields.Float(string='Total Price', compute='_get_total_price')
       
    @api.one
    def _get_total_price(self):
        self.price_total = self.price * self.quantity_ordered

I can display the price_total value in a form or tree view, but I cannot display it on a pivot as this:

    <record id="dw_purchase_pivot" model="ir.ui.view">
        <field name="name">dw.purchase.pivot</field>
        <field name="model">dw.purchase</field>
        <field name="arch" type="xml">
            <pivot string="Purchase Orders">
                <field name="partner" type="row"/>
                <field name="delivery_date" type="col" />               
                <field name="price_total" type="measure" /> 
            </pivot>
        </field>
    </record>


While price and quantity_ordered are displayed regularly.

The store attribute is not set, but nothing changes if I set store=False

Cannot figure out where I am going wrong, or is there any turnaround for this?

Avatar
Discard
Best Answer

Hi,

By default i think the store=False, so there will not be any change if you try set store=False.

So try store=True.

Thanks

Avatar
Discard
Author

It works.

I cannot understand why it's working only with stored data. Thanks

Compute methods not stores values by default. If we want to store in postgres then we should give store = true in compute method.

Author

But I don't want to store values, simply display them. Cannot figure why I can do that in a tree view while not in a graph

I have the same question. Is there another way than storing the field?

Related Posts Replies Views Activity
3
Apr 25
4264
1
Jul 24
29
2
Jul 24
1541
1
Jan 24
1235
1
Nov 24
19491