Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Is it possible to have writable related field ? I tried by adding a 'reverse' parameter in my field definition and having the reverse method writing the value in related field. However, in the view, the field is always readonly. Here is my code:
gift_instructions = fields.Char( related='invoice_line_id.gift_instructions', store=True, inverse='_set_gift_instructions')
@api.one def _set_gift_instructions(self): self.invoice_line_id.gift_instructions = self.gift_instructions
How about a computed field instead ?
You already have your setter function, you just need to create your getter function:
self.gift_instructions = self.invoice_line_id.gift_instructions
and link it:
gift_instructions = fields.Char( compute='_get_gift_instructions', store=True, inverse='_set_gift_instructions'
For a related field, when we change the field at form view, it automatically changes the relational model too
i.e. No need to use reverse to write at gift_instructions and it will be automatically done by the Object-relational mapping(ORM).
Check whether you have set the gift_instructions field as readonly at XML form view.
For more info check the odoo documentation here.
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 8/5/15, 5:46 AM|
|Seen: 997 times|
|Last updated: 8/5/15, 6:29 AM|