ソースを参照

commit inicial

Rodney Elpidio Enciso Arias 6 年 前
コミット
f265785f5b

+ 3 - 0
__init__.py

@@ -0,0 +1,3 @@
+# -*- encoding: utf-8 -*-
+
+import model

BIN
__init__.pyc


+ 21 - 0
__openerp__.py

@@ -0,0 +1,21 @@
+# -*- encoding: utf-8 -*-
+{
+    'name': 'Factura Venta J.E Machuca',
+    'version': '0.1',
+    'category': 'account',
+    'description': """
+Factura Venta Legal
+===================
+Factura legal para J.E Machuca
+    """,
+    'author': 'Eiru',
+    'website': 'http://www.eiru.com.py',
+    'depends': ['base','account'],
+    'data': [
+        'report/report_view.xml',
+        'view/account_invoice_view.xml',
+        'templates.xml',
+        # 'view/res_currency_view.xml',
+    ],
+    'installable': True,
+}

+ 4 - 0
model/__init__.py

@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+import account_invoice
+import model
+import res_currency

BIN
model/__init__.pyc


+ 24 - 0
model/account_invoice.py

@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+
+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
model/account_invoice.pyc


+ 30 - 0
model/model.py

@@ -0,0 +1,30 @@
+from openerp import api, models
+import datetime
+from num2words import num2words
+
+class ReportInvoiceJEMachuca(models.AbstractModel):
+    _name = 'report.factura_venta_jemachuca.report_invoice_jemachuca'
+
+    @api.multi
+    def render_html(self, data=None):
+        report_obj = self.env['report']
+        report = report_obj._get_report_from_name('factura_venta_jemachuca.report_invoice_jemachuca')
+        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_jemachuca.report_invoice_jemachuca', 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
model/model.pyc


+ 31 - 0
model/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
model/res_currency.pyc


+ 254 - 0
report/report_view.xml

@@ -0,0 +1,254 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <report id="factura_venta_jemachuca"
+            model="account.invoice"
+            string="Factura Legal"
+            report_type="qweb-html"
+            name="factura_venta_jemachuca.report_invoice_jemachuca"
+            file="factura_venta_jemachuca.report_invoice_jemachuca"
+        />
+
+        <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_invoice_jemachuca">
+            <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>
+                                .borderless td, .borderless th {
+                                    border: none !important;
+                                }
+                            </style>
+                            <t t-foreach="docs" t-as="o">
+                                <div class="pagina">
+                                    <!--
+                                    ======================================================================
+                                        CABECERA
+                                    ======================================================================
+                                    -->
+                                    <div style="height:3.3cm;">
+                                        <div style="padding-left:8.6cm;padding-top:0.4cm;font-size:10px;">
+                                            <div>Fecha de Emisión: <span t-field="o.date_invoice" t-field-options='{"format": "dd/MM/yyyy"}'/></div>
+                                            <div>Nombre / Razón Social: <span t-field="o.partner_id.name"/></div>
+                                            <div>
+                                                R.U.C: <span t-field="o.partner_id.ruc"/> &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
+                                                Cond de Venta: <t t-if="o.contado">Contado</t><t t-if="o.credito">Crédito</t>
+                                            </div>
+                                            <div>Dirección: <span t-field="o.partner_id.street"/>,<span t-field="o.partner_id.street2"/></div>
+                                            <div><span t-field="o.partner_id.state_id.display_name"/>,<span t-field="o.partner_id.country_id.name"/></div>
+                                            <div>Nota de Remisión: </div>
+                                        </div>
+                                    </div>
+                                    <!--
+                                    ======================================================================
+                                        TABLA
+                                    ======================================================================
+                                    -->
+                                    <div style="height:3.5cm;padding-right:0.6cm;">
+                                        <div style="font-size:9px;">
+                                            <table class="table borderless table-condensed">
+                                                <t t-set="valor_exentas" t-value="0"/>
+                                                <t t-set="valor_5" t-value="0"/>
+                                                <t t-set="valor_10" t-value="0"/>
+                                                <tbody>
+                                                    <tr t-foreach="o.invoice_line" t-as="l">
+                                                        <!-- CODIGO DE PRODUCTO -->
+                                                        <td style="width:1cm;overflow: auto; text-align: center;">
+                                                            <span t-field="l.id"/>
+                                                        </td>
+                                                        <!-- CANTIDAD -->
+                                                        <td style="width:1.3cm;overflow: auto; text-align: center;">
+                                                            <span t-field="l.quantity"/>
+                                                        </td>
+                                                        <!-- NOMBRE DEL PRODUCTO -->
+                                                        <td style="width:9.5cm;overflow: auto;">
+                                                            <span t-field="l.name"/>
+                                                        </td>
+                                                        <!-- PRECIO UNITARIO -->
+                                                        <td style="width:1.7cm;overflow: auto; text-align: right;">
+                                                            <t t-if="o.currency_id.id == 166">
+                                                                <span t-esc="'{0:,.0f}'.format(l.price_unit)"/>
+                                                            </t>
+                                                            <t t-if="o.currency_id.id != 166">
+                                                                <span t-esc="'{0:,.2f}'.format(l.price_unit)"/>
+                                                            </t>
+                                                        </td>
+                                                        <!-- EXENTAS -->
+                                                        <td style="width:2.2cm;overflow: auto; text-align: right;">
+                                                            <span t-if="'IVA 5% Venta' not 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]">
+                                                                <t t-if="o.currency_id.id == 166">
+                                                                    <span t-esc="'{0:,.0f}'.format(l.quantity * l.price_unit)"/>
+                                                                </t>
+                                                                <t t-if="o.currency_id.id != 166">
+                                                                    <span t-esc="'{0:,.2f}'.format(l.quantity * l.price_unit)"/>
+                                                                </t>
+                                                                <t t-set="valor_exentas" t-value="valor_exentas+(l.quantity * l.price_unit)"/>
+                                                            </span>
+                                                        </td>
+
+                                                        <!-- IVA 5% -->
+                                                        <td style="width:1.9cm;overflow: auto; text-align: right;">
+                                                            <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]">
+                                                                <t t-if="o.currency_id.id == 166">
+                                                                    <span t-esc="'{0:,.0f}'.format(l.quantity * l.price_unit)"/>
+                                                                </t>
+                                                                <t t-if="o.currency_id.id != 166">
+                                                                    <span t-esc="'{0:,.2f}'.format(l.quantity * l.price_unit)"/>
+                                                                </t>
+                                                                <t t-set="valor_5" t-value="valor_5+(l.quantity * l.price_unit)"/>
+                                                            </span>
+                                                        </td>
+
+                                                        <!-- IVA 10% -->
+                                                        <td style="width:2.5cm;overflow: auto; text-align: right;">
+                                                            <span t-if="'IVA 10% Venta' in [ilt.name for ilt in l.invoice_line_tax_id]">
+                                                                <t t-if="o.currency_id.id == 166">
+                                                                    <span t-esc="'{0:,.0f}'.format(l.quantity * l.price_unit)"/>
+                                                                </t>
+                                                                <t t-if="o.currency_id.id != 166">
+                                                                    <span t-esc="'{0:,.2f}'.format(l.quantity * l.price_unit)"/>
+                                                                </t>
+                                                                <t t-set="valor_10" t-value="valor_10+(l.quantity * l.price_unit)"/>
+                                                            </span>
+                                                        </td>
+                                                   </tr>
+                                                </tbody>
+                                            </table>
+                                        </div>
+                                    </div>
+                                    <!--
+                                    ======================================================================
+                                        TABLA
+                                    ======================================================================
+                                    -->
+                                    <div style="height:1.9cm;padding-right:0.6cm;">
+                                        <div style="font-size:9px;">
+                                            <t t-set="total_5" t-value="0"/>
+                                            <t t-set="total_10" t-value="0"/>
+                                            <t t-set="iva_5" t-value="0"/>
+                                            <t t-set="iva_10" t-value="0"/>
+                                            <table class="table borderless table-condensed">
+                                                <tbody>
+                                                    <!-- LINEA DE SUBTOTALES -->
+                                                    <tr>
+                                                        <td style="width:1.0cm;overflow: auto; text-align: center;"></td>
+                                                        <td style="width:1.3cm;overflow: auto; text-align: center;"></td>
+                                                        <td style="width:9.5cm;overflow: auto; text-align: center;"></td>
+                                                        <td style="width:1.7cm;overflow: auto; text-align: center;"></td>
+                                                        <td style="width:2.2cm;overflow: auto; text-align: right;">
+                                                            <t t-if="o.currency_id.id == 166">
+                                                                <span t-esc="'{0:,.0f}'.format(valor_exentas)"/>
+                                                            </t>
+                                                            <t t-if="o.currency_id.id != 166">
+                                                                <span t-esc="'{0:,.2f}'.format(valor_exentas)"/>
+                                                            </t>
+                                                        </td>
+                                                        <td style="width:1.9cm;overflow: auto; text-align: right;">
+                                                            <t t-if="o.currency_id.id == 166">
+                                                                <span t-esc="'{0:,.0f}'.format(valor_5)"/>
+                                                            </t>
+                                                            <t t-if="o.currency_id.id != 166">
+                                                                <span t-esc="'{0:,.2f}'.format(valor_5)"/>
+                                                            </t>
+                                                            <t t-set="iva_5" t-value="valor_5/21" />
+                                                        </td>
+                                                        <td style="width:2.5cm;overflow: auto; text-align: right;">
+                                                            <t t-if="o.currency_id.id == 166">
+                                                                <span t-esc="'{0:,.0f}'.format(valor_10)"/>
+                                                            </t>
+                                                            <t t-if="o.currency_id.id != 166">
+                                                                <span t-esc="'{0:,.2f}'.format(valor_10)"/>
+                                                            </t>
+                                                            <t t-set="iva_10" t-value="valor_10/11" />
+                                                        </td>
+                                                    </tr>
+                                                    <!-- LINEA TOTAL EN LETRAS Y TOTAL GENERAL -->
+                                                    <tr>
+                                                        <td style="width:1.0cm;overflow: auto; text-align: center;"></td>
+                                                        <td style="width:1.3cm;overflow: auto; text-align: center;"></td>
+                                                        <td style="width:9.5cm;overflow: auto; text-align: center;">
+                                                            <div><span t-esc="o.currency_id.local_name"/> : <span t-esc="convertir(o.amount_total,o.currency_id.en_letras)"/></div>
+                                                        </td>
+                                                        <td style="width:1.7cm;overflow: auto; text-align: center;"></td>
+                                                        <td style="width:2.2cm;overflow: auto; text-align: right;"></td>
+                                                        <td style="width:1.9cm;overflow: auto; text-align: right;"></td>
+                                                        <td style="width:2.5cm;overflow: auto; text-align: right;">
+                                                            <t t-if="o.currency_id.id == 166">
+                                                                <span t-esc="'{0:,.0f}'.format(o.amount_total)"/>
+                                                            </t>
+                                                            <t t-if="o.currency_id.id != 166">
+                                                                <span t-esc="'{0:,.2f}'.format(o.amount_total)"/>
+                                                            </t>
+                                                        </td>
+                                                    </tr>
+                                                    <!-- TOTAL DE IVA -->
+                                                    <tr>
+                                                        <td style="width:1.0cm;overflow: auto; text-align: center;"></td>
+                                                        <td style="width:1.3cm;overflow: auto; text-align: center;"></td>
+                                                        <td style="width:9.5cm;overflow: auto; text-align: center;">
+                                                            <t t-if="o.currency_id.id == 166">
+                                                                <div>
+                                                                    IVA 10%: <span t-esc="'%.2f'%iva_10"/>
+                                                                    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
+                                                                    IVA 5%: <span t-esc="'%.2f'%iva_5"/></div>
+                                                            </t>
+                                                            <t t-if="o.currency_id.id != 166">
+                                                                <div>
+                                                                    IVA 10%: <span t-esc="'{0:,.2f}'.format(iva_10)"/>
+                                                                    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
+                                                                    IVA 5%: <span t-esc="{0:,.2f}'.format(iva_5)"/>
+                                                                </div>
+                                                            </t>
+                                                        </td>
+                                                        <td style="width:1.7cm;overflow: auto; text-align: center;"></td>
+                                                        <td style="width:2.2cm;overflow: auto; text-align: right;"></td>
+                                                        <td style="width:1.9cm;overflow: auto; text-align: right;"></td>
+                                                        <td style="width:2.5cm;overflow: auto; text-align: right;">
+                                                            <t t-if="o.currency_id.id == 166">
+                                                                <span t-esc="'{0:,.0f}'.format(o.amount_tax)"/>
+                                                            </t>
+                                                            <t t-if="o.currency_id.id != 166">
+                                                                <span t-esc="'{0:,.2f}'.format(o.amount_tax)"/>
+                                                            </t>
+                                                        </td>
+                                                    </tr>
+                                                </tbody>
+                                            </table>
+                                        </div>
+                                    </div>
+                                    <!--
+                                    ======================================================================
+                                        INFO
+                                    ======================================================================
+                                    -->
+                                    <t t-if="i != 2">
+                                        <div style="height:2.4cm;"></div>
+                                    </t>
+                                    <t t-if="i == 2">
+                                        <div style="height:2.1cm;"></div>
+                                    </t>
+                                </div>
+                            </t>
+                        </div>
+    				</t>
+                </t>
+            </t>
+        </template>
+
+    </data>
+</openerp>

+ 10 - 0
templates.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <template id="factura_venta_jemachuca_assets" inherit_id="eiru_assets.assets">
+            <xpath expr="." position="inside">
+
+            </xpath>
+        </template>
+    </data>
+</openerp>

+ 17 - 0
view/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>

+ 16 - 0
view/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>