Browse Source

Para impresión de factura legal de ventas para Sion.

Sebas 5 years ago
commit
0283b08d73

+ 27 - 0
__init__.py

@@ -0,0 +1,27 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#    product_brand for OpenERP                                                  #
+#    Copyright (C) 2009 NetAndCo (<http://www.netandco.net>).                   #
+#    Authors, Mathieu Lemercier, mathieu@netandco.net,                          #
+#             Franck Bret, franck@netandco.net                                  #
+#    Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>   #
+#                                                                               #
+#    This program is free software: you can redistribute it and/or modify       #
+#    it under the terms of the GNU Affero General Public License as             #
+#    published by the Free Software Foundation, either version 3 of the         #
+#    License, or (at your option) any later version.                            #
+#                                                                               #
+#    This program is distributed in the hope that it will be useful,            #
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of             #
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
+#    GNU Affero General Public License for more details.                        #
+#                                                                               #
+#    You should have received a copy of the GNU Affero General Public License   #
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.      #
+#                                                                               #
+#################################################################################
+###################################################################################
+# Product Brand is an Openobject module wich enable Brand management for products #
+###################################################################################
+from . import factura_venta_sion, account_invoice, res_currency

BIN
__init__.pyc


+ 47 - 0
__openerp__.py

@@ -0,0 +1,47 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#    product_features for OpenERP                                                  #
+#    Copyright (C) 2009 NetAndCo (<http://www.netandco.net>).                   #
+#    Authors, Mathieu Lemercier, mathieu@netandco.net,                          #
+#             Franck Bret, franck@netandco.net                                  #
+#    Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>   #
+#                                                                               #
+#    This program is free software: you can redistribute it and/or modify       #
+#    it under the terms of the GNU Affero General Public License as             #
+#    published by the Free Software Foundation, either version 3 of the         #
+#    License, or (at your option) any later version.                            #
+#                                                                               #
+#    This program is distributed in the hope that it will be useful,            #
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of             #
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
+#    GNU Affero General Public License for more details.                        #
+#                                                                               #
+#    You should have received a copy of the GNU Affero General Public License   #
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.      #
+#                                                                               #
+#################################################################################
+###################################################################################
+# Product features is an Openobject module wich enable features management for products #
+###################################################################################
+{
+    'name': 'Factura Venta Legal Sion',
+    'version': '0.1',
+    'category': 'Product',
+    'description': """
+Factura Venta Legal Sion
+==========================
+
+Formato para imprimir la factura legal de Sion
+
+    """,
+    'author': 'Eiru/Sebastian Penayo',
+    'website': 'http://www.eiru.com',
+    'depends': ['base','account'],
+    'data': [
+        'factura_venta_sion.xml',
+        'account_invoice_view.xml',
+        'res_currency_view.xml'
+    ],
+    'installable': True,
+}

+ 40 - 0
account_invoice.py

@@ -0,0 +1,40 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#    This program is free software: you can redistribute it and/or modify       #
+#    it under the terms of the GNU Affero General Public License as             #
+#    published by the Free Software Foundation, either version 3 of the         #
+#    License, or (at your option) any later version.                            #
+#                                                                               #
+#    This program is distributed in the hope that it will be useful,            #
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of             #
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
+#    GNU Affero General Public License for more details.                        #
+#                                                                               #
+#    You should have received a copy of the GNU Affero General Public License   #
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.      #
+#                                                                               #
+#################################################################################
+
+from openerp import models, fields, api
+
+class account_invoice(models.Model):
+    _inherit = 'account.invoice'
+    _name = 'account.invoice'
+
+    contado = fields.Boolean('Contado')
+    credito = fields.Boolean('Crédito')
+
+    _defaults = {
+        'contado': True
+    }
+
+    @api.one
+    @api.onchange('credito')
+    def cambiar_estado_credito(self):
+        self.contado = not self.credito
+
+    @api.one
+    @api.onchange('contado')
+    def cambiar_estado_contado(self):
+        self.credito = not self.contado

BIN
account_invoice.pyc


+ 17 - 0
account_invoice_view.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<openerp>
+    <data>
+        <record id="account_invoice_cred_cont" model="ir.ui.view">
+            <field name="name">account.invoice.cred.cont</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="account.invoice_form" />
+            <field name="arch" type="xml">
+                <field name="fiscal_position" position="after">
+                        <field name="contado"/>
+                        <field name="credito"/>
+                </field>
+            </field>
+        </record>
+    </data>
+</openerp>

+ 30 - 0
factura_venta_sion.py

@@ -0,0 +1,30 @@
+from openerp import api, models
+import datetime
+from num2words import num2words
+
+class report_factura_sion(models.AbstractModel):
+    _name = 'report.factura_venta_sion.report_factura_sion'
+
+    @api.multi
+    def render_html(self, data=None):
+        report_obj = self.env['report']
+        report = report_obj._get_report_from_name('factura_venta_sion.report_factura_sion')
+        docargs = {
+            'doc_ids': self._ids,
+            'doc_model': report.model,
+            'docs': self.env[report.model].browse(self._ids),
+            'convertir':self.convertir,
+            'calcular_precio':self.calcular_precio,
+        }
+        return report_obj.render('factura_venta_sion.report_factura_sion', docargs)
+
+    def convertir(self,nro,moneda):
+        letra = num2words(nro,lang="es")
+        letra = letra.capitalize()
+        if not moneda:
+            moneda=''
+        letra = letra +' '+moneda
+        return letra
+
+    def calcular_precio(self,precio):
+        return (precio*1.1)

BIN
factura_venta_sion.pyc


+ 304 - 0
factura_venta_sion.xml

@@ -0,0 +1,304 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+     <report id="factura_venta_sion"
+        model="account.invoice"
+        string="Factura Legal"
+        report_type="qweb-html"
+        name="factura_venta_sion.report_factura_sion"
+        file="factura_venta_sion.report_factura_sion"
+     />
+
+    <template id="report_header_custom" inherit_id="report.external_layout_header">
+         <xpath expr="//div[@class='header']" position="replace">
+            <div class ="header">
+            </div>
+         </xpath>
+    </template>
+
+    <template id="external_layout_footer" inherit_id="report.external_layout_footer">
+        <xpath expr="//div[@class='footer']"  position="replace">
+            <div class ="footer">
+            </div>
+        </xpath>
+    </template>
+
+    <template id="report_factura_sion">
+        <t t-call="report.html_container">
+            <t t-call="report.external_layout">
+			    <t t-foreach="[1,2,3]" t-as="i">
+                <div class="page">
+                    <style type="text/css">
+                        body{
+                            font-size: 2.7mm;
+                            font-family: Arial, Helvetica, sans-serif;
+                        }
+                        div{
+                            padding: 0px;
+                        }
+                        .pagina{
+                            width:19.3cm;
+                        }
+                        .logo{
+                            height: 0.4cm;
+                            width: 100%;
+                            top: 0px;
+                        }
+                        .espacio{
+                            height: 0.2cm;
+                            width: 100%;
+                        }
+                        .fecha_emision_data{
+                            width: 11.5cm;
+                            padding-left: 5.2cm;
+                            float: left;
+                            min-height: 0.5cm;
+                        }
+                        .contado_x{
+                            width: 1.8cm;
+                            float: left;
+                            padding-left: 9cm;
+                            min-height: 0.5cm;
+                        }
+                        .linea2{
+                            position: relative;
+                            top: -0.12cm;
+                            min-height: 0.5cm;
+                         }
+                        .razon_data{
+                            width: 15cm;
+                            float: left;
+                            padding-left: 5.2cm;
+                            min-height: 0.4cm;
+                        }
+                        .ruc_data{
+                            width: 5.5cm;
+                            float: left;
+                            padding-left: 0.2cm;
+                            min-height: 0.5cm;
+                        }
+                        .linea3{
+                            position: relative;
+                            top: -0.12cm;
+                            min-height: 0.3cm;
+                         }
+                        .direccion_data{
+                            width: 14cm;
+                            float: left;
+                            padding-left: 5.2cm;
+                            min-height: 0.4cm;
+                        }
+                        .linea4{
+                            position: relative;
+                            top: -0.12cm;
+                            min-height: 0.3cm;
+                         }
+                        .telefono_data{
+                            width: 9cm;
+                            float: left;
+                            padding-left: 5.2cm;
+                            min-height: 0.4cm;
+                        }
+                        .contado_x{
+                            width: 9cm;
+                            float: left;
+                            padding-left: 0.2cm;
+                            min-height: 0.4cm;
+                        }
+
+                        .cab-articulos{
+                            height: 1.1cm;
+                            clear: both;
+                        }
+                        .articulos{
+                            height: 4.7cm;
+                        }
+                        .art-col1{
+                            width:0.5cm;
+                            text-align: center;
+                        }
+                        .art-col2{
+                            padding-left: 1cm;
+                            width:12.5cm;
+                        }
+                        .art-col3{
+                            width:2.7cm;
+                            padding-left: 0.3cm;
+                            text-align: right;
+                        }
+                        .art-col4{
+                            width:2.4cm;
+                            padding-left: 0.3cm;
+                            text-align: right;
+                        }
+                        .art-col5{
+                            width:2.6cm;
+                            padding-left: 0.2cm;
+                            text-align: right;
+                        }
+                        .art-col6{
+                            width:2.5cm;
+                            text-align: right;
+                        }
+						.logo1{
+                            height: 2.8cm;
+                            width: 100%;
+                            top: 0px;
+                        }
+                        .subtotal_data{
+                            width: 6cm;
+                            float: left;
+                            padding-top: 0.002cm;
+                            padding-left: 2.3cm;
+                            min-height: 0.2cm;
+                        }
+                        .subtotal_excentas{
+                            width: 2cm;
+                            float: left;
+                            text-align: right;
+							padding-left: 8cm;
+                            padding-top: 0.6cm;
+                            min-height: 0.2cm;
+                        }
+                        .subtotal_5{
+                            width: 2.2cm;
+                            float: left;
+							padding-left: 1cm;
+                            text-align: right;
+                            padding-top: 0.6cm;
+                            min-height: 0.2cm;
+                        }
+                        .subtotal_10{
+                            width: 2.4cm;
+                            float: left;
+							padding-left: 0.9cm;
+                            text-align: right;
+                            padding-top: 0.6cm;
+                            min-height: 0.2cm;
+                        }
+                        .total_pagar_data{
+                            width: 16.7cm;
+                            float: left;
+                            padding-top: 0.3cm;
+                            padding-left: 5cm;
+                            min-height: 0.3cm;
+                        }
+                        .total_pagar{
+                            width: 2.2cm;
+                            float: left;
+                            padding-left: 0cm;
+                            text-align: right;
+                            padding-top: 0.3cm;
+                            min-height: 0.2cm;
+                        }
+                        .iva_5_data{
+                            width: 6.5cm;
+                            float: left;
+                            padding-top: 0.2cm;
+                            padding-left: 3.0cm;
+                            min-height: 0.25cm;
+                        }
+                        .iva_10_data{
+                            width: 6.5cm;
+                            float: left;
+                            padding-top: 0.2cm;
+                            padding-left: 2.8cm;
+                            min-height: 0.25cm;
+                        }
+                        .iva_total_data{
+                            width: 6cm;
+                            float: left;
+                            padding-top: 0.2cm;
+                            padding-left: 1.5cm;
+                            min-height: 0.25cm;
+                        }
+
+                    </style>
+                    <t t-foreach="docs" t-as="o">
+
+                        <div class="pagina">
+                            <div class="logo"> </div>
+                            <div class="espacio"> </div>
+                            <div class="linea1">
+                                <div class="fecha_emision_data">Ciudad del Este,<span t-field="o.date_invoice" t-field-options='{"format": "dd MMMM yyyy"}'/></div>
+                                <div class="ruc_data"><b>R.U.C. N°: </b><span t-field="o.partner_id.ruc"/></div>
+                            </div>
+
+                            <div class="linea2">
+                                <div class="razon_data"><b>Cliente: </b><span t-field="o.partner_id.name"/></div>
+                            </div>
+
+                            <div class="linea3">
+                                <div class="direccion_data"><b>Dirección: </b>
+                                    <t t-f="o.partner_id.street"><span t-field="o.partner_id.street"/> <span t-field="o.partner_id.street2"/></t>
+                                    <t t-f="not o.partner_id.street"> </t>
+                                </div>
+                            </div>
+
+                            <div class="linea4">
+                                <div class="telefono_data"><b>Teléfono: </b><span t-field="o.partner_id.phone"/></div>
+                                <div class="contado_x"><b>Condición de pago: </b>
+                                    <t t-if="o.contado == True">Contado</t>
+                                    <t t-if="o.contado == False">Crédito</t>
+                                </div>
+                            </div>
+                            <div class="cab-articulos"> </div>
+                            <div class="articulos">
+                                <table class="tab-articulos">
+                                    <t t-set="valor_exenta" t-value="0"/>
+                                    <t t-set="valor_5" t-value="0"/>
+                                    <t t-set="valor_10" t-value="0"/>
+                                    <tr t-foreach="o.invoice_line" t-as="l">
+                                        <td class="art-col1"><span t-esc="'%.0f'%l.quantity"/></td>
+                                        <td class="art-col2"><span t-field="l.name"/></td>
+                                        <td class="art-col3"><span t-field="l.price_unit"/></td>
+                                        <td class="art-col4"></td>
+                                        <td class="art-col5">
+                                            <span t-if="'IVA 5% Venta' in [ilt.name for ilt in l.invoice_line_tax_id] and 'IVA 10% Venta' not in [ilt.name for ilt in l.invoice_line_tax_id]">
+                                                <span t-esc="l.quantity * l.price_unit">
+                                                    <span t-value="valor_5+(l.quantity * l.price_unit)"/></span>
+                                                    <t t-set="valor_5" t-value="valor_5+(l.quantity * l.price_unit)"/>
+                                                </span>
+                                        </td>
+                                        <td class="art-col6">
+                                            <span t-if="'IVA 10% Venta' in [ilt.name for ilt in l.invoice_line_tax_id]">
+                                                <span t-esc="l.quantity * l.price_unit" >
+                                                    <span t-value="valor_10+(l.quantity * l.price_unit)"/></span>
+                                                    <t t-set="valor_10" t-value="valor_10+(l.quantity * l.price_unit)"/>
+                                                </span>
+                                        </td>
+                                   </tr>
+                                </table>
+                            </div>
+                              <t t-set="iva_5" t-value="0"/>
+                              <t t-set="iva_10" t-value="0"/>
+                             <div class="subtotal_data"> </div>
+                             <div class="subtotal_excentas"> </div>
+                             <div class="subtotal_5">
+                                  <span t-esc="valor_5"></span>
+                                  <t t-set="iva_5" t-value="valor_5/21" />
+                             </div>
+                             <div class="subtotal_10">
+                                 <span t-esc="valor_10"></span>
+                                 <t t-set="iva_10" t-value="valor_10/11" />
+                             </div>
+
+                             <div class="total_pagar_data"><span t-esc="convertir(o.amount_total,o.currency_id.en_letras)"/></div>
+                             <!-- <div class="total_pagar_data"><span t-esc="o.amount_total"/></div> -->
+                             <div class="total_pagar"><span t-esc="o.amount_total"/></div>
+
+                             <div class="iva_5_data"><span t-esc="'%.0f'%iva_5"></span></div>
+                             <div class="iva_10_data"><span t-esc="'%.0f'%iva_10"></span></div>
+                             <div class="iva_total_data"><span t-esc="'%.0f'%o.amount_tax"/></div>
+                        </div>
+                       <div class="logo1"> </div>
+                    </t>
+                </div>
+				</t>
+            </t>
+        </t>
+    </template>
+
+</data>
+</openerp>

+ 31 - 0
res_currency.py

@@ -0,0 +1,31 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#    product_features for OpenERP                                                  #
+#    Copyright (C) 2009 NetAndCo (<http://www.netandco.net>).                   #
+#    Authors, Mathieu Lemercier, mathieu@netandco.net,                          #
+#             Franck Bret, franck@netandco.net                                  #
+#    Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>   #
+#                                                                               #
+#    This program is free software: you can redistribute it and/or modify       #
+#    it under the terms of the GNU Affero General Public License as             #
+#    published by the Free Software Foundation, either version 3 of the         #
+#    License, or (at your option) any later version.                            #
+#                                                                               #
+#    This program is distributed in the hope that it will be useful,            #
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of             #
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
+#    GNU Affero General Public License for more details.                        #
+#                                                                               #
+#    You should have received a copy of the GNU Affero General Public License   #
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.      #
+#                                                                               #
+#################################################################################
+
+from openerp import models, fields
+
+class res_currency(models.Model):
+    _inherit = 'res.currency'
+    _name = 'res.currency'
+
+    en_letras = fields.Char('En letras')

BIN
res_currency.pyc


+ 16 - 0
res_currency_view.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<openerp>
+    <data>
+        <record id="res_currency_en_letras" model="ir.ui.view">
+            <field name="name">res.currency.en.letras</field>
+            <field name="model">res.currency</field>
+            <field name="inherit_id" ref="base.view_currency_form" />
+            <field name="arch" type="xml">
+                <field name="symbol" position="after">
+                    <field name="en_letras"/>
+                </field>
+            </field>
+        </record>
+    </data>
+</openerp>

BIN
static/description/icon.png