I extend module for employees in odoo 9. Every employee has children. Here my models:
class Employee(models.Model):
_name = 'hr.employee'
_inherit = 'hr.employee'
children_ids = fields.One2many('my_module', 'employee_id', string="Children")
class Child(models.Model):
_name = 'my_module'
name = fields.Char(required=True, string='Name')
birthday = fields.Date(required=True, string='Birthday')
employee_id = fields.Many2one('hr.employee', ondelete='cascade', string="Employee")
How can I configure search by birthday? For example, I want to set in search date of birthday(or interval of dates) and the system must show me all employees which have children with birthday from search.
Here my search view(this works by name of child):
<record id="view_urspectr_employee_filter" model="ir.ui.view">
<field name="name">Employees</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_filter" />
<field name="arch" type="xml">
<search position="inside">
<field name="children_ids"/>
</search>
</field>
</record>
I found the similar situation in module account(../addons/account/views/account_view.xml):
<record id="view_account_move_filter" model="ir.ui.view">
<field name="name">account.move.select</field>
<field name="model">account.move</field>
<field name="arch" type="xml">
<search string="Search Move">
<field name="name" filter_domain="['|', ('name','ilike',self), ('ref','ilike',self)]" string="Move"/>
<field name="date"/>
Search by date works is good. But in this case date field used without relation One2Many.
Can you help with solution? I can't find example with search by One2Many. Thank you in advance.