~vauxoo/addons-vauxoo/7.0-purchase_requisition_contract_analyst-dev-1482-kty

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/python
# -*- encoding: utf-8 -*-
###########################################################################
#    Module Writen to OpenERP, Open Source Management Solution
#    Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
#    All Rights Reserved
# Credits######################################################
#    Coded by: Maria Gabriela Quilarque  <gabrielaquilarque97@gmail.com>
#    Planified by: Nhomar Hernandez
#    Finance by: Helados Gilda, C.A. http://heladosgilda.com.ve
#    Audited by: Humberto Arocha humberto@openerp.com.ve
#############################################################################
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU 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 General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
##############################################################################

from openerp.osv import fields, osv
from openerp.tools.translate import _

from tools import config
import time
import pooler
import cupstree


class print_model(osv.Model):

    _name = 'print.model'
    _description = '''Class to introduce the model to send to the printer'''

    _columns = {
        'model': fields.many2one('ir.model', 'Modelo', required=True, help='Introduzca en este campo el modelo que sera enviado directamente a la impresora'),
        'model_report_ids': fields.one2many('print.model.reports', 'model_id', 'Modelo Reports', required=True,),
    }
    _rec_name = 'model'
    _sql_constraint = [(
        'name_uniq', 'unique(model)', 'No se puede repetir un modelo')]



class print_lpr_option(osv.Model):
    _name = 'print.lpr.option'
    _description = ''' http://www.cups.org/documentation.php/options.html '''

    _columns = {
        'name': fields.char('Name', size=256, required=True, help='Set the name for this LPR Profile'),
        'cpi': fields.integer('Number of Characters Per Inch', help='Sets the number of characters per inch'),
        'lpi': fields.integer('Number of Lines Per Inch', help='Sets the number of lines per inch'),
        'media': fields.selection([
            ('Letter', 'Letter'),
            ('Legal', 'Legal'),
            ('A4', 'A4'),
            ('DL', 'DL'),
            ('halfletter', 'Half Letter'),
        ], 'Media', help='Sets the media size'),
        'fit_to_page': fields.boolean('Fit to page', help='Specifies that the document should be scaled to fit on the page'),
        'orientation_requested': fields.selection([
            ('3', 'Portrait (no rotation)'),
            ('4', 'Landscape (90 degrees)'),
            ('5', 'Reverse landscape (270 degrees)'),
            ('6', 'Reverse portrait (180 degrees)'),
        ], 'Orientation Requested', help='The orientation-requested option rotates the page depending on the value of N:\n3 - portrait orientation (no rotation)\n4 - landscape orientation (90 degrees)\n5 - reverse landscape or seascape orientation (270 degrees)\n6 - reverse portrait or upside-down orientation (180 degrees)'),
    }



class print_gs_option(osv.Model):
    _name = 'print.gs.option'
    _description = ''' ftp://mirror.switch.ch/mirror/ghost/gs5man_e.pdf '''

    _columns = {
        'name': fields.char('Name', size=256, required=True, help='Set the name for this Ghostscript'),
        'device': fields.selection([
            ('epson', ' Epson-compatible dot matrix printer (9 or 24 pi'),
            ('eps9mid', 'Epson-compatible 9-pin, intermediate resolution'),
            ('eps9high', ' Epson-compatible 9-pin, triple resolutio'),
        ], 'Device Driver', help='Sets the device driver'),
    }



class print_model_reports(osv.Model):
    _name = 'print.model.reports'
    _description = '''Class used for introduce the report to print and this features.'''

    def _get_print(self, cr, uid, context={}):
        lista_p = []
        try:
            lista = cupstree.gethost()
            for i in lista:
                lista_p.append((i, i))
            lista_p.append(("none", 'None'))
        except:
            lista_p.append(("none", 'None'))
        return lista_p

    _columns = {
        'model_id': fields.many2one('print.model', string='Model', ondelete='cascade'),
        'num_copies': fields.integer('Number of Copies', help='Set the number of copies to print'),
        'report_id': fields.many2one('ir.actions.report.xml', 'Report', required=True, help='Set in this field, the model to send directing to the printer'),
        'lpr_option_id': fields.many2one('print.lpr.option', 'Lpr Options'),
        'gs_option_id': fields.many2one('print.gs.option', 'Ghostscript Options'),
        'printer': fields.selection(_get_print, size=256, string='Printers', help="Select the printer that will be used for print the report", select=True,),
        'allow_repeat': fields.boolean('Allow print again', help="Checking this field will allow you to print more than once this report",),
        'depend_state': fields.boolean('Depends State', help="Checking this field to allow the printing by states filter"),
        'check_note_use': fields.boolean('Use to print Check?', help="Checking this field when allow you to take different headers to print"),
        'state': fields.char('States', size=256, required=False, help='Set the states to used for allow the printing of the document. States must be separated by commas and no spaces. Example: draft,open,done. The state field must be defined in the model as state'),
        'gs_use': fields.boolean('Use Ghostscript?', help="Checking this field will allow to print Ghostscript options"),
        'python_code': fields.text('Python Code', size=1024, help='Set the python code to use',),
    }
    _rec_name = 'report_id'
    _defaults = {
        'printer': lambda *a: 'none',
        'num_copies': lambda *a: 1,
    }

    def check_print(self, cr, uid, id, report_xml_id, model_id, context={}):
        ir_print_obj = self.pool.get('ir.print')

        print_brw = self.browse(cr, uid, id, context=None)

        result_ids = ir_print_obj.search(cr, uid, [(
            'report_id', '=', report_xml_id), ('model_id', '=', model_id)])
        if result_ids and not print_brw.allow_repeat:
            return False
        return True



class ir_print(osv.Model):
    _name = 'ir.print'
    _description = ''' '''

    _columns = {
        'report_id': fields.many2one('ir.actions.report.xml', 'Report', readonly=True),
        'model_id': fields.integer('Document', readonly=True),
        'create_date': fields.datetime('Date Created', readonly=True),
        'create_uid':  fields.many2one('res.users', 'Creator', readonly=True),
    }