Prechádzať zdrojové kódy

Crear órdenes de pago para bioelectric.

SEBAS 1 mesiac pred
commit
9ecf393f6f

+ 23 - 0
__init__.py

@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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/>.
+#
+##############################################################################
+
+import orden_pago
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
__init__.pyc


+ 17 - 0
__openerp__.py

@@ -0,0 +1,17 @@
+# -*- encoding: utf-8 -*-
+{
+    'name': 'Orden de Pago',
+    'version': '1.0',
+    'category': 'Accounting',
+    'description': 'Modulo para registrar ordenes de pago a proveedores',
+    'author': 'Sebastian Penayo',
+    'depends': ['base', 'account'],
+    'data': [
+        'orden_pago_sequence.xml',
+        'data/report_paperformat_pagoorden.xml',
+        'reports/orden_pago_report.xml',
+        'orden_pago_view.xml',
+    ],
+    'installable': True,
+    'auto_install': False,
+}

+ 20 - 0
data/report_paperformat_pagoorden.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="paperformat_orden_pagoorden" model="report.paperformat">
+            <field name="name">Orden de pago</field>
+            <field name="default" eval="True"/>
+            <field name="format">custom</field>
+            <field name="page_height">150</field>
+            <field name="page_width">80</field>
+            <field name="orientation">Portrait</field>
+            <field name="margin_top">1</field>
+            <field name="margin_bottom">1</field>
+            <field name="margin_left">1</field>
+            <field name="margin_right">1</field>
+            <field name="header_line" eval="False" />
+            <field name="header_spacing">0</field>
+            <field name="dpi">300</field>
+        </record>
+    </data>
+</openerp>

+ 166 - 0
orden_pago.py

@@ -0,0 +1,166 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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
+from openerp.exceptions import ValidationError, except_orm, Warning, RedirectWarning
+from openerp.tools import DEFAULT_SERVER_TIME_FORMAT
+from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
+from datetime import datetime
+
+
+class OrdenPago(models.Model):
+    _name = 'orden.pago'
+    _description = 'Orden de Pago'
+
+    def _get_user(self):
+        return self.env.uid
+
+    def _get_number(self):
+        return self.env['ir.sequence'].next_by_code('orden.pago') or '*'
+
+    name = fields.Char(
+        string=u'Referencia',
+        readonly=True,
+        default=_get_number,
+    )
+
+    partner_id = fields.Many2one(
+        'res.partner',
+        string='Cliente',
+        required=True
+    )
+
+    date = fields.Date(
+        string='Fecha elab.',
+        default=fields.Date.context_today
+    )
+
+    user_id = fields.Many2one(
+        comodel_name='res.users',
+        string='Preparado por:',
+        default=_get_user
+    )
+
+    company_id = fields.Many2one(
+        'res.company',
+        string='Compañía',
+        required=True,
+        default=lambda self: self.env.user.company_id
+    )
+
+    invoice_ids = fields.One2many(
+        comodel_name='account.invoice',
+        inverse_name='ordenpago_invoice_id',
+        string='Facturas'
+    )
+
+    responsable = fields.Char(
+        string='Aprobado Gerencia General:'
+    )
+
+    celular_partner = fields.Char(
+        related='partner_id.mobile',
+        string='Móvil',
+        store=True
+    )
+
+    telefono_partner = fields.Char(
+        related='partner_id.phone',
+        string='Teléfono',
+        store=True
+    )
+
+    ruc_partner = fields.Char(
+        related='partner_id.ruc',
+        string='RUC:',
+        readonly=True
+    )
+
+    contacto = fields.Char(
+        string='Contacto'
+    )
+
+    metodo_ids = fields.One2many(
+        'orden.pago.metodo',
+        'orden_id',
+        string='Líneas de Métodos de Pagos'
+    )
+
+    total = fields.Float(
+        string='Total',
+        compute='_compute_total',
+        store=True
+    )
+
+    @api.depends('invoice_ids.amount_total')
+    def _compute_total(self):
+        for rec in self:
+            rec.total = sum(line.amount_total for line in rec.invoice_ids)
+
+    @api.onchange('partner_id')
+    def _onchange_partner_id(self):
+        # Filtro dinámico para facturas abiertas del cliente seleccionado
+        if self.partner_id:
+            return {
+                'domain': {
+                    'invoice_ids': [
+                        ('partner_id', '=', self.partner_id.id),
+                        ('state', '=', 'open'),
+                        ('type', '=', 'out_invoice')
+                    ]
+                }
+            }
+
+
+class OrdenPagoMetodo(models.Model):
+    _name = 'orden.pago.metodo'
+    _description = 'Línea de Método de Orden de Pago'
+
+    orden_id = fields.Many2one(
+        'orden.pago',
+        string='Orden de Pago'
+    )
+
+    forma_pago = fields.Char(
+        string='Forma de Pago'
+    )
+
+    cheque_nro = fields.Char(
+        string='Cheque N°'
+    )
+
+    comprobante_fecha = fields.Date(
+        string='Fecha Comprobante'
+    )
+
+    comprobante_monto = fields.Float(
+        string='Importe Comprobante'
+    )
+
+
+class AccountInvoice(models.Model):
+    _inherit = 'account.invoice'
+
+    ordenpago_invoice_id = fields.Many2one(
+        comodel_name='orden.pago',
+        string='Orden de Pago'
+    )

BIN
orden_pago.pyc


+ 19 - 0
orden_pago_sequence.xml

@@ -0,0 +1,19 @@
+<openerp>
+    <data noupdate="1">
+
+        <!-- Sequences for repair.workorder -->
+        <record id="seq_type_ordenpago" model="ir.sequence.type">
+            <field name="name">Orden de Pago</field>
+            <field name="code">orden.pago</field>
+        </record>
+
+        <record id="seq_orden_pago" model="ir.sequence">
+            <field name="name">Orden de Pago</field>
+            <field name="code">orden.pago</field>
+            <field name="prefix">0</field>
+            <field name="padding">7</field>
+            <field name="company_id" eval="False"/>
+        </record>
+
+    </data>
+</openerp>

+ 122 - 0
orden_pago_view.xml

@@ -0,0 +1,122 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+
+      <!-- <act_window
+            id="action_open_account_invoice_pagoorden"
+            name="Servicios"
+            res_model="account.invoice"
+            view_type="form"
+            view_mode="tree,form"
+            domain="[('ordenpago_invoice_id', '=', active_id)]"/> -->
+
+            <!-- Vista Formulario Orden de Pago -->
+          <record id="view_orden_pago_form" model="ir.ui.view">
+              <field name="name">orden.pago.form</field>
+              <field name="model">orden.pago</field>
+              <field name="arch" type="xml">
+                  <form string="Orden de Pago">
+                      <sheet>
+                          <group>
+                              <field name="name" readonly="1"/>
+                              <field name="partner_id" required="1"/>
+                              <field name="ruc_partner" readonly="1"/>
+                              <field name="date" required="1"/>
+                              <field name="celular_partner" readonly="1"/>
+                              <field name="telefono_partner" readonly="1"/>
+                              <field name="contacto"/>
+                              <field name="user_id" readonly="1"/>
+                              <field name="responsable"/>
+                          </group>
+
+                          <notebook>
+                              <page>
+                                <span style="font-weight:bold;">Facturas relacionadas a esta Orden de Servicio</span>
+
+                                <field name="invoice_ids" widget="many2many" options="{'no_create': False}">
+                                   <tree editable="top">
+                                       <field name="number" string="Número de factura" />
+                                      <field name="date_invoice" string="Fecha de factura" />
+                                        <field name="residual" string="Saldo" sum="Saldo" />
+                                        <field name="amount_total" string="Total factura" sum="Total" />
+                                        <field name="state" string="Estado" />
+                                    </tree>
+                                </field>
+                              </page>
+                          </notebook>
+                          <notebook>
+                              <page string="Métodos de Pago">
+                                  <field name="metodo_ids">
+                                      <tree editable="bottom">
+                                          <field name="forma_pago" required="1"/>
+                                          <field name="cheque_nro"/>
+                                          <field name="comprobante_fecha"/>
+                                          <field name="comprobante_monto"/>
+                                      </tree>
+                                  </field>
+                              </page>
+
+                          </notebook>
+
+                          <group>
+                              <field name="total" readonly="1"/>
+                          </group>
+
+                      </sheet>
+                  </form>
+              </field>
+          </record>
+
+          <!-- Vista Árbol Orden de Pago -->
+          <record id="view_orden_pago_tree" model="ir.ui.view">
+              <field name="name">orden.pago.tree</field>
+              <field name="model">orden.pago</field>
+              <field name="arch" type="xml">
+                  <tree>
+                      <field name="name"/>
+                      <field name="partner_id"/>
+                      <field name="date"/>
+                      <field name="total"/>
+                  </tree>
+              </field>
+          </record>
+
+          <!-- Acción de Ventana Orden de Pago -->
+          <record id="action_orden_pago" model="ir.actions.act_window">
+              <field name="name">Órdenes de Pago</field>
+              <field name="res_model">orden.pago</field>
+              <field name="view_type">form</field>
+              <field name="view_mode">tree,form</field>
+          </record>
+
+          <!-- search view -->
+
+          <record id="search_orden_pago_search" model="ir.ui.view">
+              <field name="name">orden.pago.search</field>
+              <field name="model">orden.pago</field>
+              <field name="arch" type="xml">
+                  <search string="Orden de Pago">
+                      <field name="name"/>
+                      <field name="partner_id"/>
+                      <field name="ruc_partner"/>
+                      <separator/>
+                    <filter string="Creado Hoy" domain="[('date', '&gt;=', datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')),('date', '&lt;=',datetime.datetime.now().strftime('%Y-%m-%d 23:23:59'))]"/>
+                    <filter string="Creado mes actual" domain="[('date','&lt;',(context_today()+relativedelta(months=1)).strftime('%%Y-%%m-01')), ('date','&gt;=',time.strftime('%%Y-%%m-01'))]"/>
+                    <filter string="Creado semana anterior" domain="[('date', '&gt;=', ((context_today()+relativedelta(weeks=-2, days=1, weekday=0)).strftime('%%Y-%%m-%%d'))),('date', '&lt;=', ((context_today()+relativedelta(weeks=-1, weekday=6)).strftime('%%Y-%%m-%%d')))]"/>
+                    <filter string="Creado esta semana" domain="[('date', '&gt;=', ((context_today()+relativedelta(weeks=-1, days=1, weekday=0)).strftime('%%Y-%%m-%%d'))),('date', '&lt;=', ((context_today()+relativedelta(weeks=0, weekday=6)).strftime('%%Y-%%m-%%d')))]"/>
+
+                      <group expand="0" string="Agrupar por...">
+                          <filter string="Por dia" context="{'group_by':'date:day'}"/>
+                          <filter string="Por mes" context="{'group_by':'date:month'}"/>
+                          <filter string="Usuario" domain="[]" context="{'group_by':'user_id'}" />
+                          <filter string="Cliente" domain="[]" context="{'group_by':'partner_id'}" />
+                      </group>
+                  </search>
+              </field>
+          </record>
+
+        <!-- Menú -->
+        <menuitem id="menu_orden_pago_main" name="Órdenes de Pago" parent="account.menu_finance_receivables" action="action_orden_pago" sequence="15"/>
+
+    </data>
+</openerp>

+ 2 - 0
reports/__init__.py

@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+# import orden_servicio_report

BIN
reports/__init__.pyc


+ 130 - 0
reports/orden_pago_report.xml

@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <!-- Definición del Informe -->
+        <report
+            id="report_orden_pago"
+            model="orden.pago"
+            string="Orden de Pago"
+            report_type="qweb-pdf"
+            name="orden_pago.report_orden_pago1"
+            file="orden_pago.report_orden_pago1"
+            attachment_use="False"
+        />
+
+        <!-- Plantilla del Informe en Formato PDF -->
+        <template id="report_orden_pago1">
+            <t t-call="report.html_container">
+                <t t-foreach="docs" t-as="o">
+                    <t t-call="report.external_layout">
+                        <div class="page">
+
+                            <!-- Encabezado de la Empresa -->
+                            <div class="header" style="text-align: center; margin-bottom: 20px;">
+                                <img src="/web/binary/company_logo" style="height: 80px;"/>
+                                <h3>  <span>BIOELECTRIC</span></h3>
+                                <p>
+                                    <strong>RUC:</strong> <span t-esc="o.company_id.vat"/><br/>
+                                    <strong>Dirección:</strong> <span t-esc="o.company_id.partner_id.street"/><br/>
+                                    <strong>Teléfono:</strong> <span t-esc="o.company_id.phone"/>
+                                </p>
+                            </div>
+
+                            <!-- Información del Orden de Pago -->
+                            <table style="width: 100%; border: 1px solid #ddd; margin-bottom: 20px;">
+                                <tr>
+                                    <td style="padding: 10px; border: 1px solid #ddd;">
+                                        <strong>Referencia:</strong> <span t-esc="o.name"/>
+                                    </td>
+                                    <td style="padding: 10px; border: 1px solid #ddd;">
+                                        <strong>Fecha:</strong> <span t-field="o.date" t-field-options='{"format": "dd/MM/yyyy"}'/>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td style="padding: 10px; border: 1px solid #ddd;">
+                                        <strong>Cliente:</strong> <span t-esc="o.partner_id.name"/>
+                                    </td>
+                                    <td style="padding: 10px; border: 1px solid #ddd;">
+                                        <strong>RUC:</strong> <span t-esc="o.ruc_partner"/>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td style="padding: 10px; border: 1px solid #ddd;">
+                                        <strong>Contacto:</strong> <span t-esc="o.contacto"/>
+                                    </td>
+                                    <td style="padding: 10px; border: 1px solid #ddd;">
+                                        <strong>Responsable:</strong> <span t-esc="o.responsable"/>
+                                    </td>
+                                </tr>
+                            </table>
+
+                            <!-- Detalle de Facturas -->
+                            <h4>Facturas</h4>
+                            <table style="width: 100%; border-collapse: collapse; margin-bottom: 20px;">
+                                <thead>
+                                    <tr>
+                                        <th style="border: 1px solid #ddd; padding: 8px;">Factura</th>
+                                        <th style="border: 1px solid #ddd; padding: 8px;">Fecha</th>
+                                        <th style="border: 1px solid #ddd; padding: 8px;">Número</th>
+                                        <th style="border: 1px solid #ddd; padding: 8px;">Monto</th>
+                                    </tr>
+                                </thead>
+                                <tbody>
+                                    <tr t-foreach="o.invoice_ids" t-as="line">
+                                        <td style="border: 1px solid #ddd; padding: 8px;"><span t-esc="line.number"/></td>
+                                        <td style="border: 1px solid #ddd; padding: 8px;"><span t-esc="line.date_invoice"/></td>
+                                        <td style="border: 1px solid #ddd; padding: 8px;"><span t-esc="line.number"/></td>
+                                        <td style="border: 1px solid #ddd; padding: 8px; text-align: right;"><span t-esc="'{0:,.0f}'.format(line.amount_total)"/></td>
+                                    </tr>
+                                </tbody>
+                            </table>
+
+                            <!-- Métodos de Pago -->
+                            <h4>Métodos de Pago</h4>
+                            <table style="width: 100%; border-collapse: collapse; margin-bottom: 20px;">
+                                <thead>
+                                    <tr>
+                                        <th style="border: 1px solid #ddd; padding: 8px;">Forma de Pago</th>
+                                        <th style="border: 1px solid #ddd; padding: 8px;">Cheque N°</th>
+                                        <th style="border: 1px solid #ddd; padding: 8px;">Fecha</th>
+                                        <th style="border: 1px solid #ddd; padding: 8px;">Monto</th>
+                                    </tr>
+                                </thead>
+                                <tbody>
+                                    <tr t-foreach="o.metodo_ids" t-as="metodo">
+                                        <td style="border: 1px solid #ddd; padding: 8px;"><span t-esc="metodo.forma_pago"/></td>
+                                        <td style="border: 1px solid #ddd; padding: 8px;"><span t-esc="metodo.cheque_nro"/></td>
+                                        <td style="border: 1px solid #ddd; padding: 8px;"><span t-esc="metodo.comprobante_fecha"/></td>
+                                        <td style="border: 1px solid #ddd; padding: 8px; text-align: right;"><span t-esc="'{0:,.0f}'.format(metodo.amount_total)"/></td>
+                                    </tr>
+                                </tbody>
+                            </table>
+
+                            <!-- Total -->
+                            <p style="text-align: right; font-size: 14px;">
+                                <strong>TOTAL</strong> <span t-esc="'{0:,.0f}'.format(o.total)"/>
+                            </p>
+
+                            <p style="text-align: left; font-size: 16px;">
+                                  <strong>RECIBO DE DINERO  IMPORTE TOTAL</strong> <span t-esc="'{0:,.0f}'.format(o.total)"/>
+                            </p>
+
+                            <p style="text-align: left; font-size: 14px;">
+                                <strong>Recibido por  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ C.I.Nº _ _ _ _ _ _ _ _</strong>
+                            </p>
+
+                            <p style="text-align: left; font-size: 14px;">
+                                <strong>Firma  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Fecha _ _ _ _ _ _ _ _</strong>
+                            </p>
+
+                            <p style="text-align: left; font-size: 10px;">
+                                <strong>Obs.: La firma de este documento implica la conformidad de los datos arriba detallados y la recepción de los montos de dinero.</strong>
+                            </p>
+
+                        </div>
+                    </t>
+                </t>
+            </t>
+        </template>
+    </data>
+</openerp>

BIN
static/description/icon.png