Validate exists partner in edit

This commit is contained in:
Mauricio 2023-03-29 17:36:17 -06:00
parent 2c684ae6bd
commit 8e7aa23d1b
1 changed files with 10 additions and 0 deletions

View File

@ -2966,6 +2966,16 @@ class Socios(BaseModel):
fields.pop('accounts', '')
regimenes = fields.pop('regimenes', ())
w = (
(Socios.rfc==fields['rfc']) &
(Socios.slug==fields['slug']) &
(Socios.id!=id)
)
if Socios.select().where(w).exists():
msg = 'Ya existe otro emisor con este RFC y Razón Social'
data = {'ok': False, 'row': {}, 'new': True, 'msg': msg}
return data
try:
q = Socios.update(**fields).where(Socios.id==id)
q.execute()