Many2many字段过滤问题,新人求助
-
表A
class ReleaseOrder(models.Model): _name = 'release.order' interview_ids = fields.One2many('maternity_matron.interview', 'order_interview_id', string=u'邀请面试')
表B
class InterviewMaternityMatron(models.Model): _name = 'maternity_matron.interview' order_interview_id = fields.Many2one('release.order') maternity_matron_ids = fields.Many2many('maternity_matron.filter', 'interview_id', string=u'选择月嫂')
表C
class FilterMaternityMatron(models.Model): _name = 'maternity_matron.filter' order_id = fields.Many2one('release.order') name = fields.Char(string=u'姓名') id_number = fields.Char(string=u'身份证号') phone_number = fields.Char(string=u'手机号') customer_feedback = fields.Selection([ ('wait', '观望'), ('not satisfied', '不满意'), ('signing', '已签约') ], string=u'客户反馈')
需求:
在maternity_matron.interview
表的maternity_matron_ids
字段中根据maternity_matron.filter
表中order_id
的值进行过滤,应该如何实现,新人求教注:
release.order
中有函数,将当前记录的id
值写入maternity_matron.filter
表的order_id
中 -
@api.model def name_search(self, name, args=None, operator='ilike', limit=100): args = args or [] domain = [] if name: domain = ['|', '|', '|', ('robot_type_id', operator, name), ('robot_part_location_id', operator, name), ('robot_part_category_id', operator, name), ('robot_lcm', operator, name)] multi_fields = self.search(domain + args, limit=limit) return multi_fields.name_get()