account_move.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. from openerp import models, fields, tools, api, _
  22. class account_invoice(models.Model):
  23. _name = 'account.invoice'
  24. _inherit = 'account.invoice'
  25. _description = 'Add extra data to SET in account invoice'
  26. cdc = fields.Char('Código de Control (CDC)')
  27. nro_factura = fields.Char(string='Factura Nº', related='number', store = True)
  28. suc = fields.Char('SUC')
  29. sec = fields.Char('Sec')
  30. talonario = fields.Many2one('ruc.documentos.timbrados', string='Talonario')
  31. timbrado = fields.Char(string='Timbrado', related="talonario.name")
  32. fecha_final = fields.Date(string='Vencimiento de Timbrado', related="talonario.fecha_final")
  33. nro_actual = fields.Integer('Nro Actual')
  34. no_mostrar_libro_iva = fields.Boolean(string='No visualizar en el libro IVA')
  35. importacion = fields.Boolean(string='Fact. de importación')
  36. importacion_gasto = fields.Boolean(string='Fact. de gastos de importación')
  37. @api.multi
  38. def action_invoice_open(self):
  39. res = super(AccountInvoice, self).action_invoice_open()
  40. for invoice in self:
  41. if invoice.type == 'out_invoice':
  42. campo_original = invoice.nro_factura.replace("-", "")
  43. campo1 = campo_original[:3]
  44. campo2 = campo_original[4:7]
  45. campo3 = campo_original[7:]
  46. invoice.suc = campo1
  47. invoice.sec = campo2
  48. invoice.nro_actual = campo3
  49. return res
  50. # def separar_cadena (self):
  51. # if self.nro_factura:
  52. # longitud = len(self.nro_factura)
  53. # if longitud >= 3:
  54. # self.sec = self.nro_factura[3:6]
  55. # if longitud >= 6:
  56. # self.nro_actual = self.nro_factura[6:]
  57. # self.suc = self.nro_factura[:3]