跳至内容
菜单
此问题已终结
1 回复
3618 查看

Hello,

i have 2 fields (partner_id, ref_ids(many2many)) i want to make sure that not a single ref_id can be repeated for each customer:

partner "test" ref "ref1" 

partner "test2" ref "ref1" (ok)

partner  "test" ref "ref1" (not accepted)


any help would be appreciated 

形象
丢弃
编写者 最佳答案
@api.constrains('ref_ids', 'partner_id')
def _check_ref(self):
for record in self:
for ref in record.ref_ids.ids:
bill = self.env['account.move'].search(
[('ref_ids', 'in', ref), ('partner_id', '=', self.partner_id.id)])
if len(bill) > 1:
raise ValidationError(_("You can't create 2 bills with the same vendor and reference"))


形象
丢弃
相关帖文 回复 查看 活动
2
8月 25
3059
0
9月 22
1817
1
7月 22
2043
1
8月 15
8080
4
3月 15
11870