This question has been flagged
2 Replies
3752 Views

I inherited 'sale.order' and I want to add some fields to pivot view.


but i found out related fields are not added to the pivot view.


I don't know why, and need help about this.


below is my code for test

class SaleOrder(models.Model):
_inherit = 'sale.order'

A1 = fields.Char('AAAAA1')
A2 = fields.Many2one("res.currency", related='pricelist_id.currency_id', string="AAAAA2", readonly=True, required=False)
A3 = fields.Many2one("res.currency", related='pricelist_id.currency_id', string="AAAAA3", readonly=True, required=True)
A4 = fields.Many2one("res.currency", related='pricelist_id.currency_id', string="AAAAA4", readonly=False, required=False)
A5 = fields.Many2one("res.currency", related='pricelist_id.currency_id', string="AAAAA5", readonly=False, required=True)

A6 = fields.Char('AAAAA6')

B1 = fields.Char(related='pricelist_id.display_name', string="BBBBB1", readonly=True, required=False)
B2 = fields.Char(related='pricelist_id.display_name', string="BBBBB2", readonly=True, required=True)
B3 = fields.Char(related='pricelist_id.display_name', string="BBBBB3", readonly=False, required=False)
B4 = fields.Char(related='pricelist_id.display_name', string="BBBBB4", readonly=False, required=True)

A7 = fields.Char('AAAAA7')

A1, A6, A7 is added to pivot view but others are not.



Avatar
Discard
Best Answer

Hi:

The related field will need to be defined as a Stored field for it to show up in the list of fields in the Pivot view.

Avatar
Discard
Author

Thanks.

I made everything Stored now.

but still not show up.

Did you restart Odoo after the changes were made ? Go to Settings > Technical > Models and check whether these changes are reflected in Odoo.

You also need to go to Apps > Update Apps List and upgrade your custom module.

Author

thank you. I found typo in store. it show up now.

Author Best Answer

Thanks.

I made everything Stored now.

but still not show up.

class SaleOrder(models.Model):
_inherit = 'sale.order'

A1 = fields.Char('AAAAA10')
A2 = fields.Many2one("res.currency", related='pricelist_id.currency_id', string="AAAAA2", readonly=True, required=False, stored=True)
A3 = fields.Many2one("res.currency", related='pricelist_id.currency_id', string="AAAAA3", readonly=True, required=True, stored=True)
A4 = fields.Many2one("res.currency", related='pricelist_id.currency_id', string="AAAAA4", readonly=False, required=False, stored=True)
A5 = fields.Many2one("res.currency", related='pricelist_id.currency_id', string="AAAAA5", readonly=False, required=True, stored=True)

A6 = fields.Char('AAAAA60')

B1 = fields.Char(related='pricelist_id.display_name', string="BBBBB1", readonly=True, required=False, stored=True)
B2 = fields.Char(related='pricelist_id.display_name', string="BBBBB2", readonly=True, required=True, stored=True)
B3 = fields.Char(related='pricelist_id.display_name', string="BBBBB3", readonly=False, required=False, stored=True)
B4 = fields.Char(related='pricelist_id.display_name', string="BBBBB4", readonly=False, required=True, stored=True)

A7 = fields.Char('AAAAA70')

A10, A60, A70 is not related field


..



Avatar
Discard