Created
January 18, 2016 17:10
-
-
Save gricelsepulveda/1fdd11487bbdaf49b58e to your computer and use it in GitHub Desktop.
Ejemplo de codeo de descarga de factura en txt, en modulo account.invoice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ANADIDOS EN .PY CON EL FIN DE INGRESAR LOS CAMPOS A LA BD### | |
############################################################# | |
class InvoiceMaryun(models.Model): | |
_inherit = 'account.invoice' | |
txt_filename = fields.Char() | |
txt_binary = fields.Binary() | |
@api.one | |
def generate_file(self): | |
""" | |
function called from button | |
""" | |
content = '' | |
# make something to generate content | |
return self.write({ | |
'txt_filename': 'file.txt', | |
'txt_binary': base64.encodestring(content) | |
}) | |
#ANADIDOS EN VISTA XML CON EL FIN DE MOSTRAR EL BOTON DE DESCARGA### | |
#################################################################### | |
<?xml version="1.0" encoding="UTF-8"?> | |
<openerp> | |
<data> | |
<!-- Definimos la accion --> | |
<record model="ir.ui.view" id="account_invoice_maryun_inherit"> | |
<field name="name">account.invoice.maryun.inherit</field> | |
<field name="model">account.invoice</field> | |
<field name="type">form</field> | |
<field name="inherit_id" ref="account.invoice_form"/> | |
<field name="arch" type="xml"> | |
<xpath expr="//notebook[last()]" position="inside"> | |
<page string="Facturacion TXT" name="geo_localization"> | |
<group colspan="2" col="2"> | |
<separator string="Facturacion TXT" colspan="2"/> | |
<button name="generate_file" type="object" string="Generar Factura TXT"/> | |
<field name="txt_filename" invisible="1"/> | |
<field name="txt_binary" filename="txt_filename" readonly="1" string="Descarga el archivo"/> | |
</group> | |
</page> | |
</xpath> | |
<!-- <field name="invoice_line" position="after"> | |
<button name="generate_file" type="object" string="Generar Factura TXT"/> | |
<field name="txt_filename" invisible="1"/> | |
<field name="txt_binary" filename="txt_filename" readonly="1"/> | |
</field> --> | |
</field> | |
</record> | |
</data> | |
</openerp> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment