# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # # 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 . # ############################################################################## # -*- coding: utf-8 -*- from openerp import models, fields class Talonario(models.Model): _name = 'talonario' _description = 'Talonario' name = fields.Char(string='Número de timbrado') nombre_documento = fields.Char(string='Descripción del documento') tipo_documento = fields.Selection([ ('1', 'Factura'), ('2', 'Factura electrónica de exportación'), ('3', 'Factura electrónica de importación'), ('4', 'Autofactura electrónica'), ('5', 'Nota de crédito electrónica'), ('6', 'Nota de débito electrónica'), ('7', 'Nota de remisión electrónica'), ('8', 'Comprobante de retención electrónico') ], 'Tipo documento') timbrado_electronico = fields.Selection([ ('1', 'Factura electrónica'), ('2', 'Factura electrónica de exportación'), ('3', 'Factura electrónica de importación'), ('4', 'Autofactura electrónica'), ('5', 'Nota de crédito electrónica'), ('6', 'Nota de débito electrónica'), ('7', 'Nota de remisión electrónica'), ('8', 'Comprobante de retención electrónico') ], 'Tipo de documento electrónico') fecha_inicio = fields.Date(string='Fecha inicio de validez') fecha_final = fields.Date(string='Fecha de expiración de timbrado') activo = fields.Boolean(string='Activo', default=True) suc = fields.Char(string='Sucursal') sec = fields.Char(string='Punto de Expedición') nro_ini = fields.Integer(string='Nº inicial') nro_fin = fields.Integer(string='Nº final') journal_id = fields.Many2one('account.journal', string='Diario', required=True) # CAMPO CAMBIADO: ahora es campo normal, sin compute ultimo_nro_utilizado = fields.Integer(string='Último Número Utilizado') company_id = fields.Many2one('res.company', string='Compañía', required=True, default=lambda self: self.env.user.company_id) company_name = fields.Char(string='Compañía', related='company_id.name', readonly=True) invoice_ids = fields.One2many('account.invoice', 'talonario_id', 'Facturas', readonly=True, copy=False) user_ids = fields.Many2many('res.users', 'talonario_res_users_rel', 'talonario_id', 'user_id', 'Usuarios') # @api.depends('journal_id') # def _compute_ultimo_nro_utilizado(self): # for record in self: # if record.journal_id and record.journal_id.sequence_id: # # Sincroniza con el número actual de la secuencia del diario # record.ultimo_nro_utilizado = record.journal_id.sequence_id.number_next_actual - 1