Guardar logos del emisor en carpeta correcta
This commit is contained in:
parent
812e510660
commit
454de7bf1e
|
@ -584,6 +584,16 @@ class TemplateInvoice(BaseDocTemplate):
|
||||||
ps = ParagraphStyle(**v['estilo'])
|
ps = ParagraphStyle(**v['estilo'])
|
||||||
p = Paragraph(data[k], ps)
|
p = Paragraph(data[k], ps)
|
||||||
ls.append(p)
|
ls.append(p)
|
||||||
|
elif k=='formametodopago':
|
||||||
|
ps = ParagraphStyle(**v['estilo'])
|
||||||
|
v = f"{data['formadepago']} - {data['metododepago']}"
|
||||||
|
p = Paragraph(v, ps)
|
||||||
|
ls.append(p)
|
||||||
|
elif k=='monedatipocambio':
|
||||||
|
ps = ParagraphStyle(**v['estilo'])
|
||||||
|
v = f"{data['moneda']} - {data['tipocambio']}"
|
||||||
|
p = Paragraph(v, ps)
|
||||||
|
ls.append(p)
|
||||||
|
|
||||||
cbb = Image(data['path_cbb'])
|
cbb = Image(data['path_cbb'])
|
||||||
cbb.drawHeight = 4 * cm
|
cbb.drawHeight = 4 * cm
|
||||||
|
|
|
@ -1596,10 +1596,13 @@ def to_pdf_from_json(rfc, version, data):
|
||||||
name = '{}_{}.json'.format(rfc, version)
|
name = '{}_{}.json'.format(rfc, version)
|
||||||
custom_styles = get_custom_styles(name)
|
custom_styles = get_custom_styles(name)
|
||||||
|
|
||||||
path_logo = _join(PATHS['IMG'], f"{rfc}.png")
|
path_logo = _join(PATHS['LOGOS'], f"{rfc}.png")
|
||||||
data['emisor']['logo'] = path_logo
|
if exists(path_logo):
|
||||||
path_logo = _join(PATHS['IMG'], f"{rfc}_2.png")
|
data['emisor']['logo'] = path_logo
|
||||||
data['emisor']['logo2'] = path_logo
|
|
||||||
|
path_logo = _join(PATHS['LOGOS'], f"{rfc}_2.png")
|
||||||
|
if exists(path_logo):
|
||||||
|
data['emisor']['logo2'] = path_logo
|
||||||
|
|
||||||
path = get_path_temp()
|
path = get_path_temp()
|
||||||
pdf = TemplateInvoice(path)
|
pdf = TemplateInvoice(path)
|
||||||
|
@ -1735,7 +1738,7 @@ def _comprobante(doc, options):
|
||||||
|
|
||||||
serie = ''
|
serie = ''
|
||||||
if 'serie' in data:
|
if 'serie' in data:
|
||||||
serie = '{} -'.format(data['serie'])
|
serie = '{}-'.format(data['serie'])
|
||||||
data['seriefolio'] = '{}{}'.format(serie, data.get('folio', ''))
|
data['seriefolio'] = '{}{}'.format(serie, data.get('folio', ''))
|
||||||
data['totalenletras'] = to_letters(float(data['total']), data['moneda'])
|
data['totalenletras'] = to_letters(float(data['total']), data['moneda'])
|
||||||
|
|
||||||
|
|
|
@ -876,7 +876,7 @@ class Emisor(BaseModel):
|
||||||
emisor = Emisor.select()[0]
|
emisor = Emisor.select()[0]
|
||||||
rfc = emisor.rfc.lower()
|
rfc = emisor.rfc.lower()
|
||||||
name = f'{rfc}.png'
|
name = f'{rfc}.png'
|
||||||
path = util._join(PATHS['IMG'], name)
|
path = util._join(PATHS['LOGOS'], name)
|
||||||
if util.save_file(path, file_obj.file.read()):
|
if util.save_file(path, file_obj.file.read()):
|
||||||
emisor.logo = file_obj.filename
|
emisor.logo = file_obj.filename
|
||||||
emisor.save()
|
emisor.save()
|
||||||
|
|
|
@ -59,6 +59,7 @@ path_docs = os.path.abspath(os.path.join(BASE_DIR, '..', 'docs'))
|
||||||
path_css = os.path.join(path_static, 'css')
|
path_css = os.path.join(path_static, 'css')
|
||||||
path_img = os.path.join(path_static, 'img')
|
path_img = os.path.join(path_static, 'img')
|
||||||
path_user_template = os.path.join(path_docs, 'templates')
|
path_user_template = os.path.join(path_docs, 'templates')
|
||||||
|
path_user_logos = os.path.join(path_docs, 'logos')
|
||||||
|
|
||||||
# ~ PATH_STATIC = os.path.abspath(os.path.join(BASE_DIR, '..'))
|
# ~ PATH_STATIC = os.path.abspath(os.path.join(BASE_DIR, '..'))
|
||||||
|
|
||||||
|
@ -209,6 +210,7 @@ PATHS = {
|
||||||
'IMG': path_img,
|
'IMG': path_img,
|
||||||
'DOCS': path_docs,
|
'DOCS': path_docs,
|
||||||
'USER': path_user_template,
|
'USER': path_user_template,
|
||||||
|
'LOGOS': path_user_logos,
|
||||||
}
|
}
|
||||||
VALUES_PDF = {
|
VALUES_PDF = {
|
||||||
'CANCEL': {True: 'inline', False: 'none'},
|
'CANCEL': {True: 'inline', False: 'none'},
|
||||||
|
|
Loading…
Reference in New Issue