Skip to Content
मेन्यू
This question has been flagged
1 Reply
3622 Views

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 

Avatar
Discard
Author Best Answer
@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"))


Avatar
Discard
Related Posts Replies Views Activity
2
अग॰ 25
3068
0
सित॰ 22
1822
1
जुल॰ 22
2052
1
अग॰ 15
8090
4
मार्च 15
11880