Fix - Al obtener nueva clave en productos

This commit is contained in:
Mauricio Baeza 2018-01-16 20:52:37 -06:00
parent 741d0c506f
commit af0b2b6c56
1 changed files with 3 additions and 5 deletions

View File

@ -2126,13 +2126,11 @@ class Productos(BaseModel):
@classmethod
def next_key(cls):
value = (Productos
.select(fn.Max(Productos.id).alias('fm'))
.select(fn.Max(cast(Productos.clave, 'int')).alias('fm'))
.order_by(SQL('fm'))
.scalar())
if value is None:
value = 1
else:
value += 1
value = value or 0
value += 1
return {'value': value}
@classmethod