python - 通过方法调用Odoo 10 python弹出窗口不会触发
问题描述
好的,这是我正在使用的代码。
@api.model
def _get_company(self):
return self.env.user.company_id
company_id = fields.Many2one('res.company', string='Company', required=True, default=_get_company,
help='The company this user is currently working for.', context={'user_preference': True})
company_ids = fields.Many2many('res.company', 'res_company_employees_rel', 'employee_id', 'cid',
string='Companies', default='_get_company')
@api.multi
def select_location(self):
return{
'name': 'Select Location',
'view_type': 'kanban',
'view_mode': 'kanban',
'target': 'new',
'res_model': 'employment.locations',
'type': 'ir.actions.act_window',
'context':{
'search_default_filter_company_id': self.company_ids,
}
}
@api.multi
def attendance_action_change(self):
""" Check In/Check Out action
Check In: create a new attendance record
Check Out: modify check_out field of appropriate attendance record
"""
if len(self) > 1:
raise exceptions.UserError(_('Cannot perform check in or check out on multiple employees.'))
action_date = fields.Datetime.now()
if self.attendance_state != 'checked_in':
location_id = select_location()
vals = {
'employee_id': self.id,
'check_in': action_date,
'location_id': location_id,
}
return self.env['hr.attendance'].create(vals)
else:
attendance = self.env['hr.attendance'].search([('employee_id', '=', self.id), ('check_out', '=', False)], limit=1)
if attendance:
attendance.check_out = action_date
else:
raise exceptions.UserError(_('Cannot perform check out on %(empl_name)s, could not find corresponding check in. '
'Your attendances have probably been modified manually by human resources.') % {'empl_name': self.name, })
return attendance
我试图让弹出 select_location() 在处理出席_action_change() 期间触发。有没有办法做到这一点,还是我在叫错树?
我在 xml 中创建了 ir.actions.act_window 和 ir.ui.view 记录,并创建了“employment.locations”模型并正常工作。
谢谢任何人的帮助。
解决方案
推荐阅读
- python-3.x - 即使有值,查询集也会返回空值
- spring - 缺少访问控制允许来源
- flutter - 如何在flutter中的某个事件后触发警报?
- c - memcmp 究竟返回了什么?
- regex - 如何在该行某处某行中的特定字符串之后从文本文件中获取一个数字?
- postgresql - 使用 pgcrypto (PostgresQL) 解密 AES GCM 256
- php - Laravel Eloquent - 关系和方法。何时使用 ->users() 与 ->users
- angular - 如何在 NGXS 中等待两个动作
- r - 使用 R 进行顶点连接计算
- python - python loops does not break even after successful while statement