forked from elmau/empresa-libre
Replace save for update in invoice
This commit is contained in:
parent
229be3b415
commit
4aad1a94eb
|
@ -5123,8 +5123,7 @@ class Facturas(BaseModel):
|
||||||
values['forma_pago'] = ''
|
values['forma_pago'] = ''
|
||||||
|
|
||||||
with database_proxy.atomic() as txn:
|
with database_proxy.atomic() as txn:
|
||||||
print('VALUES\n\n', values)
|
# ~ print('VALUES\n\n', values)
|
||||||
print(type(values['tipo_cambio']))
|
|
||||||
obj = Facturas.create(**values)
|
obj = Facturas.create(**values)
|
||||||
totals = cls._calculate_totals(cls, obj, productos, tipo_comprobante)
|
totals = cls._calculate_totals(cls, obj, productos, tipo_comprobante)
|
||||||
cls._guardar_relacionados(cls, obj, relacionados)
|
cls._guardar_relacionados(cls, obj, relacionados)
|
||||||
|
@ -5527,25 +5526,46 @@ class Facturas(BaseModel):
|
||||||
|
|
||||||
rfc = Emisor.select()[0].rfc
|
rfc = Emisor.select()[0].rfc
|
||||||
obj = Facturas.get(Facturas.id == id)
|
obj = Facturas.get(Facturas.id == id)
|
||||||
obj.xml = cls._make_xml(cls, obj)
|
# ~ obj.xml = cls._make_xml(cls, obj)
|
||||||
obj.estatus = 'Generada'
|
xml = cls._make_xml(cls, obj)
|
||||||
obj.save()
|
# ~ obj.estatus = 'Generada'
|
||||||
|
# ~ obj.save()
|
||||||
|
q = (Facturas
|
||||||
|
.update(xml=xml, estatus='Generada')
|
||||||
|
.where(Facturas.id == id)
|
||||||
|
)
|
||||||
|
q.execute()
|
||||||
|
|
||||||
enviar_correo = util.get_bool(Configuracion.get_('correo_directo'))
|
enviar_correo = util.get_bool(Configuracion.get_('correo_directo'))
|
||||||
auth = Configuracion.get_({'fields': 'pac_auth'})
|
auth = Configuracion.get_({'fields': 'pac_auth'})
|
||||||
|
|
||||||
anticipo = False
|
anticipo = False
|
||||||
msg = 'Factura timbrada correctamente'
|
msg = 'Factura timbrada correctamente'
|
||||||
result = utils.xml_stamp(obj.xml, auth)
|
# ~ result = utils.xml_stamp(obj.xml, auth)
|
||||||
|
result = utils.xml_stamp(xml, auth)
|
||||||
|
|
||||||
if result['ok']:
|
if result['ok']:
|
||||||
obj.xml = result['xml']
|
cfdi_uuid = result['uuid']
|
||||||
obj.uuid = result['uuid']
|
values = dict(
|
||||||
obj.fecha_timbrado = result['date']
|
xml = result['xml'],
|
||||||
obj.estatus = 'Timbrada'
|
uuid = cfdi_uuid,
|
||||||
obj.error = ''
|
fecha_timbrado = result['date'],
|
||||||
obj.save()
|
estatus = 'Timbrada',
|
||||||
row = {'uuid': obj.uuid, 'estatus': 'Timbrada'}
|
error = '',
|
||||||
|
)
|
||||||
|
q = (Facturas
|
||||||
|
.update(**values)
|
||||||
|
.where(Facturas.id == id)
|
||||||
|
)
|
||||||
|
q.execute()
|
||||||
|
|
||||||
|
# ~ obj.xml = result['xml']
|
||||||
|
# ~ obj.uuid = result['uuid']
|
||||||
|
# ~ obj.fecha_timbrado = result['date']
|
||||||
|
# ~ obj.estatus = 'Timbrada'
|
||||||
|
# ~ obj.error = ''
|
||||||
|
# ~ obj.save()
|
||||||
|
row = {'uuid': cfdi_uuid, 'estatus': 'Timbrada'}
|
||||||
if enviar_correo:
|
if enviar_correo:
|
||||||
cls._send(cls, id, rfc)
|
cls._send(cls, id, rfc)
|
||||||
if obj.tipo_comprobante == 'I' and obj.tipo_relacion == '07':
|
if obj.tipo_comprobante == 'I' and obj.tipo_relacion == '07':
|
||||||
|
@ -5857,6 +5877,7 @@ class Facturas(BaseModel):
|
||||||
WareHouseProduct.warehouse==warehouse,
|
WareHouseProduct.warehouse==warehouse,
|
||||||
WareHouseProduct.product==p.producto,
|
WareHouseProduct.product==p.producto,
|
||||||
)
|
)
|
||||||
|
|
||||||
obj = WareHouseProduct.get(*fields)
|
obj = WareHouseProduct.get(*fields)
|
||||||
obj.exists -= cant
|
obj.exists -= cant
|
||||||
obj.save()
|
obj.save()
|
||||||
|
@ -9772,10 +9793,14 @@ class InventoryEntries(BaseModel):
|
||||||
|
|
||||||
WareHouseProduct.update_exists(values)
|
WareHouseProduct.update_exists(values)
|
||||||
|
|
||||||
product.existencia += cant
|
new_cant = product.existencia + cant
|
||||||
product.save()
|
q = (Productos
|
||||||
|
.update(existencia=Productos.existencia + cant)
|
||||||
|
.where(Productos.id==product.id)
|
||||||
|
)
|
||||||
|
q.execute()
|
||||||
|
|
||||||
result = {'ok': True, 'row': {'existencia': product.existencia}}
|
result = {'ok': True, 'row': {'existencia': new_cant}}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue