123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- # -*- coding: 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, tools, api, _
- class account_invoice(models.Model):
- _name = 'account.invoice'
- _inherit = 'account.invoice'
- _description = 'Add extra data to SET in account invoice'
- cdc = fields.Char('Código de Control (CDC)')
- nro_factura = fields.Char(string='Factura Nº', related='number', store = True)
- suc = fields.Char('SUC')
- sec = fields.Char('Sec')
- talonario = fields.Many2one('ruc.documentos.timbrados', string='Talonario')
- timbrado = fields.Char(string='Timbrado', related="talonario.name")
- fecha_final = fields.Date(string='Vencimiento de Timbrado', related="talonario.fecha_final")
- nro_actual = fields.Integer('Nro Actual')
- no_mostrar_libro_iva = fields.Boolean(string='No visualizar en el libro IVA')
- importacion = fields.Boolean(string='Fact. de importación')
- importacion_gasto = fields.Boolean(string='Fact. de gastos de importación')
- @api.multi
- def action_invoice_open(self):
- res = super(AccountInvoice, self).action_invoice_open()
- for invoice in self:
- if invoice.type == 'out_invoice':
- campo_original = invoice.nro_factura.replace("-", "")
- campo1 = campo_original[:3]
- campo2 = campo_original[4:7]
- campo3 = campo_original[7:]
- invoice.suc = campo1
- invoice.sec = campo2
- invoice.nro_actual = campo3
- return res
- # def separar_cadena (self):
- # if self.nro_factura:
- # longitud = len(self.nro_factura)
- # if longitud >= 3:
- # self.sec = self.nro_factura[3:6]
- # if longitud >= 6:
- # self.nro_actual = self.nro_factura[6:]
- # self.suc = self.nro_factura[:3]
|