~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to openerp_print/report_sxw.py

  • Committer: Moises Lopez
  • Date: 2014-10-09 21:30:17 UTC
  • mfrom: (879.1.7 trunk-addons-vauxoo)
  • Revision ID: moylop260@vauxoo.com-20141009213017-u3jicyg8xery3r8c
[MERGE] upforward 7.0
-Fix unused import
-Fix relative import
-Fix full path import
-Fix trailing whitespace pylint error C0303
-Fix autopep8 ignoring E501 & E128
-Fix reimported
-Fix __openerp__.py files
-Translate update

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import report
27
27
from openerp.report import report_sxw
28
28
from report.report_sxw import *
29
 
from report.report_sxw import _format
30
 
from report.report_sxw import _float_format
31
 
from report.report_sxw import _int_format
32
 
from report.report_sxw import _date_format
33
 
from report.report_sxw import _dttime_format
34
 
from report.report_sxw import browse_record_list
35
29
from report.report_sxw import rml_parse
36
30
from lxml import etree
37
31
import subprocess
38
32
import os
39
 
import StringIO
40
33
import cStringIO
41
34
import base64
42
 
import copy
43
 
import locale
44
 
import mx.DateTime
45
 
import re
46
35
import time
47
36
 
48
37
import openerp.netsvc as netsvc
49
 
from openerp.osv import osv
50
38
import openerp.tools as tools
51
 
import warnings
52
 
import zipfile
53
39
import openerp.netsvc as netsvc
54
40
 
55
41
logger = netsvc.Logger()
69
55
 
70
56
checkBins("lpr")
71
57
 
72
 
    #~ def search_model(self,cr,uid,model)
73
 
        #~ pool = pooler.get_pool(cr.dbname)
74
 
        #~ print_report_obj =pool.get('print.model.reports')
75
 
        #~ file_data =get_file(cr,uid,report_data)
76
 
        #~
77
 
        #~ for pt_re in ptre_obj.browse(cr,uid,[('report_id.id','=',report_xml_id)])
78
 
            #~ print 'ID PRINT REPORT', pt_re
79
 
            #~ if pt_re:
80
 
                #~ self.create_single_pdf(cr, uid, ids, data, report_xml, context)
81
 
            #~ else:
 
58
#~ def search_model(self,cr,uid,model)
 
59
#~ pool = pooler.get_pool(cr.dbname)
 
60
#~ print_report_obj =pool.get('print.model.reports')
 
61
#~ file_data =get_file(cr,uid,report_data)
 
62
#~
 
63
#~ for pt_re in ptre_obj.browse(cr,uid,[('report_id.id','=',report_xml_id)])
 
64
#~ print 'ID PRINT REPORT', pt_re
 
65
#~ if pt_re:
 
66
#~ self.create_single_pdf(cr, uid, ids, data, report_xml, context)
 
67
#~ else:
82
68
 
83
69
 
84
70
class Printer(object):
 
71
 
85
72
    def __init__(self, opts={}):
86
73
        """initializes the printer with options"""
87
74
        self.options = []
133
120
def get_file(cr, uid, report_data):
134
121
    file_print = open('mi_archivo.pdf', 'wb+')
135
122
    file_print.write(report_data)
136
 
    file_print.close
137
123
    return file_print
138
124
 
139
125
 
220
206
        #~ print 'HEADER',self.header
221
207
        #~ print 'STORE',self.store
222
208
        pool = pooler.get_pool(cr.dbname)
223
 
        company_obj = pool.get('res.company')
224
209
 
225
210
        ir_obj = pool.get('ir.actions.report.xml')
226
211
        report_xml_ids = ir_obj.search(cr, uid,
234
219
            report_type = data.get('report_type', 'pdf')
235
220
 
236
221
            class a(object):
 
222
 
237
223
                def __init__(self, *args, **argv):
238
224
                    for key, arg in argv.items():
239
225
                        setattr(self, key, arg)
267
253
        #~ be printed or not
268
254
        #~ if context.get('allow',False):
269
255
        validate_report(cr, uid, result['brw'], fnct_ret[0], data['id'])
270
 
                #~ self.create_ir_print(cr,uid,report_xml.id,data['id'])
 
256
        #~ self.create_ir_print(cr,uid,report_xml.id,data['id'])
271
257
        return fnct_ret
272
258
 
273
259
    def create_ir_print(self, cr, uid, report_xml_id, id_obj):
277
263
            'report_id': report_xml_id,
278
264
            'model_id': id_obj,
279
265
        }
280
 
        ir_print_id = ir_print_obj.create(cr, uid, res)
 
266
        ir_print_obj.create(cr, uid, res)
281
267
 
282
268
    def validate_report(self, cr, uid, report_xml_id, id_obj, context):
283
269
        pool = pooler.get_pool(cr.dbname)
361
347
    def _add_header_bank(self, rml_dom, bank_header):
362
348
        head_dom = etree.XML(bank_header)
363
349
        for tag in head_dom:
364
 
            found = rml_dom.find('.//'+tag.tag)
 
350
            found = rml_dom.find('.//' + tag.tag)
365
351
            if found is not None and len(found):
366
352
                if tag.get('position'):
367
353
                    found.append(tag)
386
372
                aname = eval(attach, {'object': obj, 'time': time})
387
373
                result = False
388
374
                if report_xml.attachment_use and aname and context.get('attachment_use', True):
389
 
                    aids = pool.get('ir.attachment').search(cr, uid, [('datas_fname', '=', aname+'.pdf'), (
 
375
                    aids = pool.get('ir.attachment').search(cr, uid, [('datas_fname', '=', aname + '.pdf'), (
390
376
                        'res_model', '=', self.table), ('res_id', '=', obj.id)])
391
377
                    if aids:
392
378
                        brow_rec = pool.get(
403
389
                try:
404
390
                    if aname:
405
391
                        flag = True  # ya que entra solo la primera vez sin attachment
406
 
                        name = aname+'.'+result[1]
 
392
                        name = aname + '.' + result[1]
407
393
                        pool.get('ir.attachment').create(cr, uid, {
408
394
                            'name': aname,
409
395
                            'datas': base64.encodestring(result[0]),
417
403
                except Exception, e:
418
404
                    import traceback
419
405
                    import sys
420
 
                    tb_s = reduce(lambda x, y: x+y, traceback.format_exception(
 
406
                    tb_s = reduce(lambda x, y: x + y, traceback.format_exception(
421
407
                        sys.exc_type, sys.exc_value, sys.exc_traceback))
422
408
                    netsvc.Logger().notifyChannel(
423
409
                        'report', netsvc.LOG_ERROR, str(e))