I am developing a module in Odoo. I overload by delegation the class "project.task" form Project module of Odoo.
py file
class Intervention(models.Model):
_name = "module.intervention"
_inherits = {
"project.task": "task_id"
}
### Fields
task_id = fields.Many2one(
"project.task",
ondelete="cascade",
required=True
)
### Overlord
@api.model
def create(self, vals)
# do lot of thing
intervention = super(Intervention, self).create(vals)
# link the object with 0ne2one relation
intervention.task_id.intervention_id = intervention
xml file
<record id="module.intervention0" model="module.intervention">
<field name="type_id" ref="module.interventionTypeDirect"/>
<field name="project_id" ref="module.project0"/>
<field name="user_id" ref="module.user0"/>
</record>
<record id="module.activity0" model="accoanunt.alytic.line">
<field name="unit_amount">2.5</field>
<field name="task_id" eval="ref('module.intervention0').task_id"/>
<field name="account_id" ref="module.project0"/>
<field name="user_id" ref="module.user0"/>
</record>
I got below error when I try to access to a field
"ParseError: 'int' object has no attribute 'task_id'"
I also tried to use 'env' in eval.
<field name="task_id" eval="env['module.intervention'].browse([ref('module.intervention0')], limit=1).task_id"/>
ParseError: "name 'env' is not defined" while parsing demo.xml
My question is:
How I access to the fields of a object into eval expression during xml parsing ?