Hey Cyllo folks, is there a way to make a computed field editable? I'm trying to edit my compute field in my custom module and am stuck. Any tips?
Welcome!
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.
This question has been flagged
Here's how you can make a computed field editable in Odoo by defining an inverse method. This allows users to modify the computed field, and those changes will be reflected in the underlying fields. from odoo import api, fields, models class ProductTemplate(models.Model): _inherit = 'product.template' price_with_tax = fields.Float( compute="_compute_price_with_tax", inverse="_inverse_price_with_tax" ) @api.depends('list_price', 'taxes_id') def _compute_price_with_tax(self): for product in self: tax_rate = sum(product.taxes_id.mapped('amount')) / 100 product.price_with_tax = product.list_price * (1 + tax_rate) def _inverse_price_with_tax(self): for product in self: tax_rate = sum(product.taxes_id.mapped('amount')) / 100 product.list_price = product.price_with_tax / (1 + tax_rate)