I inherited a model with an existing field that has a docstring domain, to alter the domain and also add a new field which will be used in the altered domain
e.g
class ProjectTask(models.Model):
_inherit = "project.task"
customer_tree_ids = fields.Many2many(related="project_id.customer_tree_ids")
sale_line_id = fields.Many2one(
domain="""[
('is_service', '=', True),
('is_expense', '=', False),
('state', 'in', ['sale', 'done']),
('order_partner_id', 'in', customer_tree_ids), '|',
('company_id', '=', False), ('company_id', '=', company_id)]""",
)
and in my view
project.task.view.form
project.task
but I get the error
Error while validating view near:Field 'customer_tree_ids' used in domain of python field 'sale_line_id' ([ ('is_service', '=', True), ('is_expense', '=', False), ('state', 'in', ['sale', 'done']), ('order_partner_id', 'in', customer_tree_ids), '|', ('company_id', '=', False), ('company_id', '=', company_id)]) must be present in view but is missing.
This works well in odoo 16.0 but when installing the module in 17.0 then I get this error