Falle 4560: Eindeutige ID - UID

develop
Roman Widmann 2018-01-26 09:31:46 +01:00
parent 6301e23338
commit 26127c96f4
1 changed files with 11 additions and 0 deletions

View File

@ -63,6 +63,17 @@ class Partner(models.Model):
('portal_id_uniq', 'unique(portal_id)', 'Die Portal-ID muss eindeutig sein') ('portal_id_uniq', 'unique(portal_id)', 'Die Portal-ID muss eindeutig sein')
] ]
@api.one
@api.constrains('is_company', 'vat')
def _check_unique_vat(self):
if not self.vat or (not self.is_company and self.parent_id):
return
partners = self.search([('is_company', '=', True),
('vat', '=', self.vat),
('id', '!=', self.id)])
if partners:
raise ValidationError(_("Es sind bereits folgende Unternehmen mit der selben USt. ID vorhanden: %s") % [p.name for p in partners])
@api.model @api.model
def portal_create_partner(self, vals): def portal_create_partner(self, vals):
vals = self.with_context(sst_1=True).remove_not_specified_fields(vals) vals = self.with_context(sst_1=True).remove_not_specified_fields(vals)