|
@@ -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'
|
|
|
|
+ )
|