在域 Many2one 字段中调用函数
Call function in domain Many2one field
是否可以在domain Many2one域中调用functin?
例如:
time = fields.Many2one('my.time', #call function here)
时间字段从数据库 table my_time 中填充。在 table 我有几行:
id name
1 10:00
2 11:00
3 12:00
4. 13:00
在其他 table my_booked_time 中,我从时间字段插入 id (1),现在我需要过滤器 Many2one "Select all available time (11:00,12:00,13:00)" 而不是 10:00,其中 user_id = self.user_id 和 partner_id = self.partner_id
有什么简单的解决办法吗?
在 many2one 上定义域 假设 my_booked_time
有 m2o 到 table my_time
命名为 time_id
:
m2o_field = fields.Many2one(....,
domain=lambda self: [("id", "not in", self.env['my.booked.time'].search([]).mapped("time_id").ids)])
是否可以在domain Many2one域中调用functin?
例如:
time = fields.Many2one('my.time', #call function here)
时间字段从数据库 table my_time 中填充。在 table 我有几行:
id name
1 10:00
2 11:00
3 12:00
4. 13:00
在其他 table my_booked_time 中,我从时间字段插入 id (1),现在我需要过滤器 Many2one "Select all available time (11:00,12:00,13:00)" 而不是 10:00,其中 user_id = self.user_id 和 partner_id = self.partner_id
有什么简单的解决办法吗?
在 many2one 上定义域 假设 my_booked_time
有 m2o 到 table my_time
命名为 time_id
:
m2o_field = fields.Many2one(....,
domain=lambda self: [("id", "not in", self.env['my.booked.time'].search([]).mapped("time_id").ids)])