forked from elmau/empresa-libre
Merge branch 'develop'
Ejecutar LibreOffice como otra instancia
This commit is contained in:
commit
2f797af8b2
|
@ -607,6 +607,10 @@ class LIBO(object):
|
||||||
PORT = '8100'
|
PORT = '8100'
|
||||||
ARG = 'socket,host={},port={};urp;StarOffice.ComponentContext'.format(
|
ARG = 'socket,host={},port={};urp;StarOffice.ComponentContext'.format(
|
||||||
HOST, PORT)
|
HOST, PORT)
|
||||||
|
CMD = ['soffice',
|
||||||
|
'-env:SingleAppInstance=false',
|
||||||
|
'-env:UserInstallation=file:///tmp/LIBO_Process8100',
|
||||||
|
'--headless', '--norestore', '--nologo', '--accept={}'.format(ARG)]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._app = None
|
self._app = None
|
||||||
|
@ -647,15 +651,12 @@ class LIBO(object):
|
||||||
if self.is_running:
|
if self.is_running:
|
||||||
return
|
return
|
||||||
|
|
||||||
c = 1
|
for i in range(3):
|
||||||
while c < 4:
|
self.app = subprocess.Popen(self.CMD,
|
||||||
c += 1
|
|
||||||
self.app = subprocess.Popen([
|
|
||||||
'soffice', '--headless', '--accept={}'.format(self.ARG)],
|
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
if self.is_running:
|
if self.is_running:
|
||||||
return
|
break
|
||||||
return
|
return
|
||||||
|
|
||||||
def _set_properties(self, properties):
|
def _set_properties(self, properties):
|
||||||
|
@ -1109,7 +1110,7 @@ class LIBO(object):
|
||||||
|
|
||||||
def pdf(self, path, data, ods=False):
|
def pdf(self, path, data, ods=False):
|
||||||
options = {'AsTemplate': True, 'Hidden': True}
|
options = {'AsTemplate': True, 'Hidden': True}
|
||||||
log.info('Abrir plantilla...')
|
log.debug('Abrir plantilla...')
|
||||||
self._template = self._doc_open(path, options)
|
self._template = self._doc_open(path, options)
|
||||||
if self._template is None:
|
if self._template is None:
|
||||||
return b''
|
return b''
|
||||||
|
@ -1844,6 +1845,10 @@ def send_mail(data):
|
||||||
return {'ok': is_connect, 'msg': msg}
|
return {'ok': is_connect, 'msg': msg}
|
||||||
|
|
||||||
|
|
||||||
|
def exists(path):
|
||||||
|
return os.path.exists(path)
|
||||||
|
|
||||||
|
|
||||||
def get_path_info(path):
|
def get_path_info(path):
|
||||||
path, filename = os.path.split(path)
|
path, filename = os.path.split(path)
|
||||||
name, extension = os.path.splitext(filename)
|
name, extension = os.path.splitext(filename)
|
||||||
|
|
|
@ -372,7 +372,7 @@ class StorageEngine(object):
|
||||||
return main.PreFacturas.get_(values)
|
return main.PreFacturas.get_(values)
|
||||||
|
|
||||||
def _get_timbrar(self, values):
|
def _get_timbrar(self, values):
|
||||||
return main.Facturas.timbrar(int(values['id']))
|
return main.Facturas.timbrar(values)
|
||||||
|
|
||||||
def _get_anticipoegreso(self, values):
|
def _get_anticipoegreso(self, values):
|
||||||
return main.Facturas.anticipo_egreso(int(values['id']))
|
return main.Facturas.anticipo_egreso(int(values['id']))
|
||||||
|
|
|
@ -24,6 +24,7 @@ from settings import log, DEBUG, VERSION, PATH_CP, COMPANIES, PRE, CURRENT_CFDI,
|
||||||
FORMAT = '{0:.2f}'
|
FORMAT = '{0:.2f}'
|
||||||
FORMAT3 = '{0:.3f}'
|
FORMAT3 = '{0:.3f}'
|
||||||
FORMAT_TAX = '{0:.4f}'
|
FORMAT_TAX = '{0:.4f}'
|
||||||
|
RFC_PUBLICO = 'XAXX010101000'
|
||||||
|
|
||||||
|
|
||||||
database_proxy = Proxy()
|
database_proxy = Proxy()
|
||||||
|
@ -3090,6 +3091,7 @@ class Productos(BaseModel):
|
||||||
'descripcion': obj.descripcion,
|
'descripcion': obj.descripcion,
|
||||||
'unidad': obj.unidad.name,
|
'unidad': obj.unidad.name,
|
||||||
'valor_unitario': obj.valor_unitario,
|
'valor_unitario': obj.valor_unitario,
|
||||||
|
'existencia': obj.existencia,
|
||||||
}
|
}
|
||||||
data = {'ok': True, 'row': row, 'new': False}
|
data = {'ok': True, 'row': row, 'new': False}
|
||||||
return data
|
return data
|
||||||
|
@ -3210,6 +3212,7 @@ class Facturas(BaseModel):
|
||||||
obj.fecha_cancelacion = result['Fecha']
|
obj.fecha_cancelacion = result['Fecha']
|
||||||
obj.acuse = result['Acuse']
|
obj.acuse = result['Acuse']
|
||||||
self._actualizar_saldo_cliente(self, obj, True)
|
self._actualizar_saldo_cliente(self, obj, True)
|
||||||
|
self._update_inventory(self, obj, True)
|
||||||
else:
|
else:
|
||||||
obj.error = data['msg']
|
obj.error = data['msg']
|
||||||
obj.save()
|
obj.save()
|
||||||
|
@ -3399,6 +3402,9 @@ class Facturas(BaseModel):
|
||||||
if invoice.donativo and invoice.forma_pago == '12':
|
if invoice.donativo and invoice.forma_pago == '12':
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if invoice.cliente.rfc == RFC_PUBLICO:
|
||||||
|
return
|
||||||
|
|
||||||
importe = invoice.total_mn
|
importe = invoice.total_mn
|
||||||
if invoice.tipo_comprobante == 'E':
|
if invoice.tipo_comprobante == 'E':
|
||||||
importe *= -1
|
importe *= -1
|
||||||
|
@ -3645,6 +3651,7 @@ class Facturas(BaseModel):
|
||||||
q.execute()
|
q.execute()
|
||||||
q = FacturasRelacionadas.delete().where(FacturasRelacionadas.factura==obj)
|
q = FacturasRelacionadas.delete().where(FacturasRelacionadas.factura==obj)
|
||||||
q.execute()
|
q.execute()
|
||||||
|
Tickets.uncancel(obj)
|
||||||
return bool(obj.delete_instance())
|
return bool(obj.delete_instance())
|
||||||
|
|
||||||
def _get_folio(self, serie):
|
def _get_folio(self, serie):
|
||||||
|
@ -4156,8 +4163,26 @@ class Facturas(BaseModel):
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@util.run_in_thread
|
||||||
|
def _update_inventory(self, invoice, cancel=False):
|
||||||
|
if invoice.tipo_comprobante != 'I':
|
||||||
|
return
|
||||||
|
|
||||||
|
products = FacturasDetalle.get_by_invoice(invoice.id)
|
||||||
|
for p in products:
|
||||||
|
if p.producto.inventario:
|
||||||
|
if cancel:
|
||||||
|
p.producto.existencia += Decimal(p.cantidad)
|
||||||
|
else:
|
||||||
|
p.producto.existencia -= Decimal(p.cantidad)
|
||||||
|
p.producto.save()
|
||||||
|
return
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def timbrar(cls, id):
|
def timbrar(cls, values):
|
||||||
|
id = int(values['id'])
|
||||||
|
update = util.loads(values.get('update', 'true'))
|
||||||
|
|
||||||
auth = Emisor.get_auth()
|
auth = Emisor.get_auth()
|
||||||
obj = Facturas.get(Facturas.id == id)
|
obj = Facturas.get(Facturas.id == id)
|
||||||
obj.xml = cls._make_xml(cls, obj, auth)
|
obj.xml = cls._make_xml(cls, obj, auth)
|
||||||
|
@ -4169,7 +4194,6 @@ class Facturas(BaseModel):
|
||||||
anticipo = False
|
anticipo = False
|
||||||
msg = 'Factura timbrada correctamente'
|
msg = 'Factura timbrada correctamente'
|
||||||
result = util.timbra_xml(obj.xml, auth)
|
result = util.timbra_xml(obj.xml, auth)
|
||||||
# ~ print (result)
|
|
||||||
if result['ok']:
|
if result['ok']:
|
||||||
obj.xml = result['xml']
|
obj.xml = result['xml']
|
||||||
obj.uuid = result['uuid']
|
obj.uuid = result['uuid']
|
||||||
|
@ -4183,6 +4207,8 @@ class Facturas(BaseModel):
|
||||||
if obj.tipo_comprobante == 'I' and obj.tipo_relacion == '07':
|
if obj.tipo_comprobante == 'I' and obj.tipo_relacion == '07':
|
||||||
anticipo = True
|
anticipo = True
|
||||||
cls._actualizar_saldo_cliente(cls, obj)
|
cls._actualizar_saldo_cliente(cls, obj)
|
||||||
|
if update:
|
||||||
|
cls._update_inventory(cls, obj)
|
||||||
cls._sync(cls, id, auth)
|
cls._sync(cls, id, auth)
|
||||||
else:
|
else:
|
||||||
msg = result['error']
|
msg = result['error']
|
||||||
|
@ -4231,7 +4257,7 @@ class Facturas(BaseModel):
|
||||||
tipo_persona = 1
|
tipo_persona = 1
|
||||||
if receptor['rfc'] == 'XEXX010101000':
|
if receptor['rfc'] == 'XEXX010101000':
|
||||||
tipo_persona = 4
|
tipo_persona = 4
|
||||||
elif receptor['rfc'] == 'XAXX010101000':
|
elif receptor['rfc'] == RFC_PUBLICO:
|
||||||
tipo_persona = 3
|
tipo_persona = 3
|
||||||
elif len(receptor['rfc']) == 12:
|
elif len(receptor['rfc']) == 12:
|
||||||
tipo_persona = 2
|
tipo_persona = 2
|
||||||
|
@ -4859,6 +4885,10 @@ class FacturasDetalle(BaseModel):
|
||||||
.where(model_pt.productos_id==id).dicts())
|
.where(model_pt.productos_id==id).dicts())
|
||||||
return impuestos
|
return impuestos
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_by_invoice(cls, id):
|
||||||
|
return FacturasDetalle.select().where(FacturasDetalle.factura==id)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def reinvoice(cls, id):
|
def reinvoice(cls, id):
|
||||||
data = []
|
data = []
|
||||||
|
@ -5328,6 +5358,15 @@ class Tickets(BaseModel):
|
||||||
|
|
||||||
return inicio
|
return inicio
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def uncancel(cls, invoice):
|
||||||
|
query = (Tickets
|
||||||
|
.update(estatus='Generado', cancelado=False, factura=None)
|
||||||
|
.where(Tickets.factura==invoice)
|
||||||
|
)
|
||||||
|
result = query.execute()
|
||||||
|
return result
|
||||||
|
|
||||||
def _cancel_tickets(self, invoice, tickets):
|
def _cancel_tickets(self, invoice, tickets):
|
||||||
query = (Tickets
|
query = (Tickets
|
||||||
.update(estatus='Facturado', cancelado=True, factura=invoice)
|
.update(estatus='Facturado', cancelado=True, factura=invoice)
|
||||||
|
@ -5428,7 +5467,7 @@ class Tickets(BaseModel):
|
||||||
|
|
||||||
if is_invoice_day:
|
if is_invoice_day:
|
||||||
filters = (
|
filters = (
|
||||||
Socios.rfc == 'XAXX010101000' and
|
Socios.rfc == RFC_PUBLICO and
|
||||||
Socios.slug == 'publico_en_general')
|
Socios.slug == 'publico_en_general')
|
||||||
try:
|
try:
|
||||||
client = Socios.get(filters)
|
client = Socios.get(filters)
|
||||||
|
@ -7141,7 +7180,7 @@ def _init_values(rfc):
|
||||||
data = (
|
data = (
|
||||||
{'clave': 'version', 'valor': VERSION},
|
{'clave': 'version', 'valor': VERSION},
|
||||||
{'clave': 'migracion', 'valor': '0'},
|
{'clave': 'migracion', 'valor': '0'},
|
||||||
{'clave': 'rfc_publico', 'valor': 'XAXX010101000'},
|
{'clave': 'rfc_publico', 'valor': RFC_PUBLICO},
|
||||||
{'clave': 'rfc_extranjero', 'valor': 'XEXX010101000'},
|
{'clave': 'rfc_extranjero', 'valor': 'XEXX010101000'},
|
||||||
{'clave': 'decimales', 'valor': '2'},
|
{'clave': 'decimales', 'valor': '2'},
|
||||||
{'clave': 'path_key', 'valor': ''},
|
{'clave': 'path_key', 'valor': ''},
|
||||||
|
@ -8089,8 +8128,16 @@ def _exportar_documentos():
|
||||||
msg = 'Extrayendo factura {} de {}: {}-{}'.format(
|
msg = 'Extrayendo factura {} de {}: {}-{}'.format(
|
||||||
i+1, t, row['serie'], row['folio'])
|
i+1, t, row['serie'], row['folio'])
|
||||||
log.info(msg)
|
log.info(msg)
|
||||||
Facturas.get_xml(row['id'])
|
_, name = Facturas.get_xml(row['id'])
|
||||||
|
msg = '\tXML extraido...'
|
||||||
|
log.info(msg)
|
||||||
|
# ~ name = name[:-3] + 'pdf'
|
||||||
|
# ~ path = '/home/mau/facturas/{}/{}/{}/{}'.format(rfc, year, month, name)
|
||||||
|
# ~ if util.exists(path):
|
||||||
|
# ~ continue
|
||||||
Facturas.get_pdf(row['id'], rfc, True)
|
Facturas.get_pdf(row['id'], rfc, True)
|
||||||
|
msg = '\tPDF generado...'
|
||||||
|
log.info(msg)
|
||||||
log.info('Documentos exportados...')
|
log.info('Documentos exportados...')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -495,6 +495,16 @@ function cmd_cancelar_ticket_click(){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(row['estatus']=='Cancelado'){
|
||||||
|
msg_error('El ticket ya esta cancelado')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if(row['estatus']=='Facturado'){
|
||||||
|
msg_error('El ticket esta facturado')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
msg = '¿Estás seguro de cancelar el siguiente Ticket?<BR><BR>'
|
msg = '¿Estás seguro de cancelar el siguiente Ticket?<BR><BR>'
|
||||||
msg += 'Folio: ' + row['folio']
|
msg += 'Folio: ' + row['folio']
|
||||||
msg += '<BR><BR>ESTA ACCIÓN NO SE PUEDE DESHACER'
|
msg += '<BR><BR>ESTA ACCIÓN NO SE PUEDE DESHACER'
|
||||||
|
@ -521,7 +531,7 @@ function chk_is_invoice_day_change(new_value, old_value){
|
||||||
|
|
||||||
|
|
||||||
function send_timbrar_invoice(id){
|
function send_timbrar_invoice(id){
|
||||||
webix.ajax().get('/values/timbrar', {id: id}, function(text, data){
|
webix.ajax().get('/values/timbrar', {id: id, update: false}, function(text, data){
|
||||||
var values = data.json()
|
var values = data.json()
|
||||||
if(values.ok){
|
if(values.ok){
|
||||||
msg_ok(values.msg)
|
msg_ok(values.msg)
|
||||||
|
|
Loading…
Reference in New Issue