Reputation: 135
hello i want to give an record a domain but ican't access to the field related
this my code python :
class emmployee_e(models.Model):
_inherit = 'employee.departement'
employee_parent_id = fields.Many2one('res.partner', string="parent id",related="employee_id.parent_id",store=True)
this my xml code
<record model="ir.actions.act_window" id="parent_action">
<field name="name">name record</field>
<field name="res_model">employee.departement</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('employee_id','child_of', 'employee_parent_id')]
</field>
<field name="context">{'search_default_This_Week': 1}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Click here to add new message</p>
</field>
</record>
how to access to this field , i try with id of employee domain works but when i call the field related nothing happened
Upvotes: 1
Views: 292
Reputation: 2764
The error is because you cannot use model fields
in the right side of the domain tuple because there is no context available to provide the value of that variable to be replaced with a value in order to generate a working sql query.
This is a limitation of Odoo query domains that only works like you are expecting when you use it in a Form view or when you are manually triggering the domain search usage and in both cases the domain should be without quotes in the variable, like:
[('employee_id','child_of', employee_parent_id)]
And there will be an evaluation context that will provide the specific value of that variable employee_parent_id
. But it's not intended to work in Menu/View Action domains.
Upvotes: 0
Reputation: 11141
Here domain is wrong.
[('employee_id','child_of', 'employee_parent_id')]
employee_id refer to hr.employee table and you have declared employee_parent_id with res.partner table which may lead wrong domain. So we need to provide ids of hr.employee
Upvotes: 1