Я добавил эту python функцию к модели 'hr.holidays'
class InheritHrHolidays(models.Model):
_inherit = 'hr.holidays'
def _get_holiday_status_id_domain(self):
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
allocate_type = self.env['hr.holidays.status'].search([('name', '=', 'Compensatory Days')], limit=1)
return [('id', '=', allocate_type.id)]
elif self.env.user.has_group('hr_holidays.group_hr_holidays_user') and not self.env.user.has_group(
'hr_holidays.group_hr_holidays_manager'):
allocation_types = self.env['hr.holidays.status'].search([('name', '!=', 'Unpaid')])
return [('id', 'in', allocation_types.mapped('id'))]
Я хочу вызвать эту функцию в действии id = "hr_holidays.open_allocation_holidays", чтобы все еще выполняться во время выполнения действия ..
<record id="open_allocation_holidays" model="ir.actions.act_window">
<field name="name">Allocation Request</field>
<field name="res_model">hr.holidays</field>
<field name="view_type">form</field>
<field name="view_mode">tree,kanban,form</field>
<field name="context">{
'default_type':'add',
'search_default_my_leaves': 1,
'needaction_menu_ref':
[
'hr_holidays.menu_open_company_allocation',
]
}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click here to create a new leave allocation request.
</p>
</field>
<field name="domain">[('type','=','add')]</field>
<field name="view_id" ref="edit_holiday_new"/>
<field name="search_view_id" ref="view_hr_holidays_filter"/>
</record>