~openbias/bias-trunk/bias-public-trunk

« back to all changes in this revision

Viewing changes to bias_electronic_invoice_42/res_company.py

  • Committer: Jose Patricio
  • Date: 2011-10-19 03:16:40 UTC
  • Revision ID: josepato@bias.com.mx-20111019031640-05zd7r5lxwx084qu
el push inicial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
 
5
#
 
6
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
 
7
#
 
8
# WARNING: This program as such is intended to be used by professional
 
9
# programmers who take the whole responsability of assessing all potential
 
10
# consequences resulting from its eventual inadequacies and bugs
 
11
# End users who are looking for a ready-to-use solution with commercial
 
12
# garantees and support are strongly adviced to contract a Free Software
 
13
# Service Company
 
14
#
 
15
# This program is Free Software; you can redistribute it and/or
 
16
# modify it under the terms of the GNU General Public License
 
17
# as published by the Free Software Foundation; either version 2
 
18
# of the License, or (at your option) any later version.
 
19
#
 
20
# This program is distributed in the hope that it will be useful,
 
21
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
# GNU General Public License for more details.
 
24
#
 
25
# You should have received a copy of the GNU General Public License
 
26
# along with this program; if not, write to the Free Software
 
27
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
28
#
 
29
##############################################################################
 
30
 
 
31
from osv import fields, osv
 
32
 
 
33
class res_company(osv.osv):
 
34
        _inherit = 'res.company'
 
35
 
 
36
        _columns = {
 
37
                'certificate': fields.char('Certificate', size=256,  help='Wrigth the compleat path of the .Key file'),
 
38
                'nocertificado': fields.char('Numero de Certificado', size=20,),
 
39
                #'key': fields.many2one('ir.attachment','Key',  required=True,                                         help='Attach your Key .key to the company as an Attachment,/n and then select it here'),
 
40
                'key':fields.char('Key', size=256,  help='Wrigth the compleat path of the .Key file'),
 
41
                'key_phrase': fields.char('Key Phrase',  invisible=True, size=32, required=True),
 
42
                'folio_ids': fields.one2many('res.company.folios', 'company_id', 'Folios'),
 
43
        }
 
44
 
 
45
res_company()
 
46
 
 
47
 
 
48
 
 
49
class res_company_folios(osv.osv):
 
50
    _name = "res.company.folios"
 
51
    _description = "Folios autorizados a la compania"
 
52
 
 
53
    _rec_name = 'folio_from'
 
54
    
 
55
    _columns = {
 
56
            'serie': fields.char('Serie', size=5,),
 
57
            'folio_from': fields.integer('Folio From', required=True),
 
58
            'folio_to': fields.integer('Folio To', required=True),
 
59
            'approved_year': fields.integer('Approved Year',required=True),
 
60
            'approved_number': fields.char('Approved Number', size=32, required=True),
 
61
            'company_id': fields.many2one('res.company', 'Company', required=True, select=True),
 
62
            }
 
63
    _defaults = {
 
64
 
 
65
    }
 
66
    _order = "folio_from"
 
67
 
 
68
    def get_folio_info(self, cr, uid, company_id, folio, field, serie=''):
 
69
            if serie:
 
70
                    serie = " and serie='%s'"%(serie)
 
71
            query = "SELECT %s from res_company_folios where %s <= folio_to and %s >= folio_from and company_id=%s %s"%(field, folio, folio, company_id, serie)
 
72
            cr.execute(query)
 
73
            res = cr.fetchone()
 
74
            try:
 
75
                    res = str(res[0])
 
76
            except:
 
77
                    raise osv.except_osv(('Error !'), ('No se encontro un folio valido!.'))
 
78
            return res
 
79
                                                
 
80
 
 
81
res_company_folios()
 
82
 
 
83
 
 
84
 
 
85