mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
fix flakes8
This commit is contained in:
@@ -81,7 +81,7 @@ Contributors
|
|||||||
'author': 'Agile Business Group & Domsense, Pegueroles SCP, NaN',
|
'author': 'Agile Business Group & Domsense, Pegueroles SCP, NaN',
|
||||||
'website': 'http://www.agilebg.com',
|
'website': 'http://www.agilebg.com',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
"depends" : ['base', 'base_calendar'],
|
"depends": ['base', 'base_calendar'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/security.xml',
|
'security/security.xml',
|
||||||
'printing_data.xml',
|
'printing_data.xml',
|
||||||
|
|||||||
@@ -30,12 +30,11 @@ import cups
|
|||||||
|
|
||||||
from openerp.osv import orm, fields
|
from openerp.osv import orm, fields
|
||||||
|
|
||||||
#
|
|
||||||
# Reports
|
|
||||||
#
|
|
||||||
|
|
||||||
class report_xml(orm.Model):
|
class report_xml(orm.Model):
|
||||||
|
"""
|
||||||
|
Reports
|
||||||
|
"""
|
||||||
|
|
||||||
def set_print_options(self, cr, uid, report_id, format, context=None):
|
def set_print_options(self, cr, uid, report_id, format, context=None):
|
||||||
"""
|
"""
|
||||||
@@ -79,7 +78,10 @@ class report_xml(orm.Model):
|
|||||||
method=True,
|
method=True,
|
||||||
),
|
),
|
||||||
'printing_printer_id': fields.many2one('printing.printer', 'Printer'),
|
'printing_printer_id': fields.many2one('printing.printer', 'Printer'),
|
||||||
'printing_action_ids': fields.one2many('printing.report.xml.action', 'report_id', 'Actions', help='This field allows configuring action and printer on a per user basis'),
|
'printing_action_ids': fields.one2many(
|
||||||
|
'printing.report.xml.action', 'report_id', 'Actions',
|
||||||
|
help='This field allows configuring action and printer on a per '
|
||||||
|
'user basis'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def behaviour(self, cr, uid, ids, context=None):
|
def behaviour(self, cr, uid, ids, context=None):
|
||||||
@@ -105,16 +107,18 @@ class report_xml(orm.Model):
|
|||||||
printer = default_printer
|
printer = default_printer
|
||||||
|
|
||||||
# Retrieve report default values
|
# Retrieve report default values
|
||||||
if report.property_printing_action and report.property_printing_action.type != 'user_default':
|
if (report.property_printing_action
|
||||||
|
and report.property_printing_action.type != 'user_default'):
|
||||||
action = report.property_printing_action.type
|
action = report.property_printing_action.type
|
||||||
if report.printing_printer_id:
|
if report.printing_printer_id:
|
||||||
printer = report.printing_printer_id
|
printer = report.printing_printer_id
|
||||||
|
|
||||||
# Retrieve report-user specific values
|
# Retrieve report-user specific values
|
||||||
act_ids = printing_act_obj.search(cr, uid,
|
act_ids = printing_act_obj.search(
|
||||||
[('report_id', '=', report.id),
|
cr, uid,
|
||||||
('user_id', '=', uid),
|
[('report_id', '=', report.id),
|
||||||
('action', '!=', 'user_default')], context=context)
|
('user_id', '=', uid),
|
||||||
|
('action', '!=', 'user_default')], context=context)
|
||||||
if act_ids:
|
if act_ids:
|
||||||
user_action = printing_act_obj.behaviour(cr, uid, act_ids[0], context)
|
user_action = printing_act_obj.behaviour(cr, uid, act_ids[0], context)
|
||||||
action = user_action['action']
|
action = user_action['action']
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import time
|
import time
|
||||||
import base64
|
|
||||||
|
|
||||||
import cups
|
import cups
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
@@ -32,25 +31,53 @@ from threading import Lock
|
|||||||
from openerp import pooler
|
from openerp import pooler
|
||||||
from openerp.osv import orm, fields
|
from openerp.osv import orm, fields
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp.addons.base_calendar import base_calendar
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Printers
|
|
||||||
#
|
|
||||||
class printing_printer(orm.Model):
|
class printing_printer(orm.Model):
|
||||||
|
"""
|
||||||
|
Printers
|
||||||
|
"""
|
||||||
_name = "printing.printer"
|
_name = "printing.printer"
|
||||||
_description = "Printer"
|
_description = "Printer"
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name' : fields.char('Name',size=64,required=True,select="1"),
|
'name': fields.char(
|
||||||
'system_name': fields.char('System Name',size=64,required=True,select="1"),
|
'Name',
|
||||||
'default':fields.boolean('Default Printer', readonly=True),
|
size=64,
|
||||||
'status': fields.selection([('unavailable','Unavailable'),('printing','Printing'),('unknown','Unknown'),('available','Available'),('error','Error'),('server-error','Server Error')], 'Status', required=True, readonly=True),
|
required=True,
|
||||||
'status_message': fields.char('Status Message', size=500, readonly=True),
|
select="1"),
|
||||||
'model': fields.char('Model', size=500, readonly=True),
|
'system_name': fields.char(
|
||||||
'location': fields.char('Location', size=500, readonly=True),
|
'System Name',
|
||||||
'uri': fields.char('URI', size=500, readonly=True),
|
size=64,
|
||||||
|
required=True,
|
||||||
|
select="1"),
|
||||||
|
'default': fields.boolean(
|
||||||
|
'Default Printer',
|
||||||
|
readonly=True),
|
||||||
|
'status': fields.selection(
|
||||||
|
[('unavailable', 'Unavailable'),
|
||||||
|
('printing', 'Printing'),
|
||||||
|
('unknown', 'Unknown'),
|
||||||
|
('available', 'Available'),
|
||||||
|
('error', 'Error'),
|
||||||
|
('server-error', 'Server Error')],
|
||||||
|
'Status', required=True, readonly=True),
|
||||||
|
'status_message': fields.char(
|
||||||
|
'Status Message',
|
||||||
|
size=500,
|
||||||
|
readonly=True),
|
||||||
|
'model': fields.char(
|
||||||
|
'Model',
|
||||||
|
size=500,
|
||||||
|
readonly=True),
|
||||||
|
'location': fields.char(
|
||||||
|
'Location',
|
||||||
|
size=500,
|
||||||
|
readonly=True),
|
||||||
|
'uri': fields.char(
|
||||||
|
'URI',
|
||||||
|
size=500,
|
||||||
|
readonly=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
_order = "name"
|
_order = "name"
|
||||||
@@ -78,9 +105,9 @@ class printing_printer(orm.Model):
|
|||||||
server_error = True
|
server_error = True
|
||||||
|
|
||||||
mapping = {
|
mapping = {
|
||||||
3 : 'available',
|
3: 'available',
|
||||||
4 : 'printing',
|
4: 'printing',
|
||||||
5 : 'error'
|
5: 'error'
|
||||||
}
|
}
|
||||||
|
|
||||||
if context is None:
|
if context is None:
|
||||||
@@ -96,7 +123,7 @@ class printing_printer(orm.Model):
|
|||||||
status = 'server-error'
|
status = 'server-error'
|
||||||
elif printer.system_name in printers:
|
elif printer.system_name in printers:
|
||||||
info = printers[printer.system_name]
|
info = printers[printer.system_name]
|
||||||
status = mapping.get( info['printer-state'], 'unknown' )
|
status = mapping.get(info['printer-state'], 'unknown')
|
||||||
vals = {
|
vals = {
|
||||||
'model': info.get('printer-make-and-model', False),
|
'model': info.get('printer-make-and-model', False),
|
||||||
'location': info.get('printer-location', False),
|
'location': info.get('printer-location', False),
|
||||||
@@ -117,7 +144,6 @@ class printing_printer(orm.Model):
|
|||||||
self.updating = False
|
self.updating = False
|
||||||
self.last_update = time.time()
|
self.last_update = time.time()
|
||||||
|
|
||||||
|
|
||||||
def start_printer_update(self, cr, uid, context):
|
def start_printer_update(self, cr, uid, context):
|
||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
if self.updating:
|
if self.updating:
|
||||||
@@ -140,7 +166,7 @@ class printing_printer(orm.Model):
|
|||||||
if not last_update or now - last_update > 10:
|
if not last_update or now - last_update > 10:
|
||||||
self.start_printer_update(cr, uid, context)
|
self.start_printer_update(cr, uid, context)
|
||||||
# Wait up to five seconds for printer status update
|
# Wait up to five seconds for printer status update
|
||||||
for x in range(0,5):
|
for x in range(0, 5):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
updating = self.updating
|
updating = self.updating
|
||||||
@@ -149,28 +175,32 @@ class printing_printer(orm.Model):
|
|||||||
break
|
break
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
|
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||||
|
context=None, count=False):
|
||||||
self.update(cr, uid, context)
|
self.update(cr, uid, context)
|
||||||
return super(printing_printer,self).search(cr, uid, args, offset, limit, order, context, count)
|
return super(printing_printer, self
|
||||||
|
).search(cr, uid, args, offset,
|
||||||
|
limit, order, context, count)
|
||||||
|
|
||||||
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||||
self.update(cr, uid, context)
|
self.update(cr, uid, context)
|
||||||
return super(printing_printer,self).read(cr, uid, ids, fields, context, load)
|
return super(printing_printer, self
|
||||||
|
).read(cr, uid, ids, fields, context, load)
|
||||||
|
|
||||||
def browse(self, cr, uid, ids, context=None):
|
def browse(self, cr, uid, ids, context=None):
|
||||||
self.update(cr, uid, context)
|
self.update(cr, uid, context)
|
||||||
return super(printing_printer,self).browse(cr, uid, ids, context)
|
return super(printing_printer, self).browse(cr, uid, ids, context)
|
||||||
|
|
||||||
def set_default(self, cr, uid, ids, context):
|
def set_default(self, cr, uid, ids, context):
|
||||||
if not ids:
|
if not ids:
|
||||||
return
|
return
|
||||||
default_ids= self.search(cr, uid,[('default','=',True)])
|
default_ids = self.search(cr, uid, [('default', '=', True)])
|
||||||
self.write(cr, uid, default_ids, {'default':False}, context)
|
self.write(cr, uid, default_ids, {'default': False}, context)
|
||||||
self.write(cr, uid, ids[0], {'default':True}, context)
|
self.write(cr, uid, ids[0], {'default': True}, context)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_default(self,cr,uid,context):
|
def get_default(self, cr, uid, context):
|
||||||
printer_ids = self.search(cr, uid,[('default','=',True)])
|
printer_ids = self.search(cr, uid, [('default', '=', True)])
|
||||||
if printer_ids:
|
if printer_ids:
|
||||||
return printer_ids[0]
|
return printer_ids[0]
|
||||||
return False
|
return False
|
||||||
@@ -182,11 +212,12 @@ class printing_printer(orm.Model):
|
|||||||
|
|
||||||
def _available_action_types(self, cr, uid, context=None):
|
def _available_action_types(self, cr, uid, context=None):
|
||||||
return [
|
return [
|
||||||
('server',_('Send to Printer')),
|
('server', _('Send to Printer')),
|
||||||
('client',_('Send to Client')),
|
('client', _('Send to Client')),
|
||||||
('user_default',_("Use user's defaults")),
|
('user_default', _("Use user's defaults")),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class printing_action(orm.Model):
|
class printing_action(orm.Model):
|
||||||
_name = 'printing.action'
|
_name = 'printing.action'
|
||||||
_description = 'Print Job Action'
|
_description = 'Print Job Action'
|
||||||
@@ -195,5 +226,3 @@ class printing_action(orm.Model):
|
|||||||
'name': fields.char('Name', size=256, required=True),
|
'name': fields.char('Name', size=256, required=True),
|
||||||
'type': fields.selection(_available_action_types, 'Type', required=True),
|
'type': fields.selection(_available_action_types, 'Type', required=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import base64
|
|||||||
from openerp import pooler
|
from openerp import pooler
|
||||||
from openerp.addons.base_calendar import base_calendar
|
from openerp.addons.base_calendar import base_calendar
|
||||||
|
|
||||||
|
|
||||||
class virtual_report_spool(base_calendar.virtual_report_spool):
|
class virtual_report_spool(base_calendar.virtual_report_spool):
|
||||||
|
|
||||||
def exp_report(self, db, uid, object, ids, datas=None, context=None):
|
def exp_report(self, db, uid, object, ids, datas=None, context=None):
|
||||||
@@ -41,22 +42,26 @@ class virtual_report_spool(base_calendar.virtual_report_spool):
|
|||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
# First of all load report defaults: name, action and printer
|
# First of all load report defaults: name, action and printer
|
||||||
report_obj = pool.get('ir.actions.report.xml')
|
report_obj = pool.get('ir.actions.report.xml')
|
||||||
report = report_obj.search(cr,uid,[('report_name','=',self._reports[report_id]['report_name'])])
|
report = report_obj.search(
|
||||||
|
cr, uid, [('report_name', '=', self._reports[report_id]['report_name'])])
|
||||||
if report:
|
if report:
|
||||||
report = report_obj.browse(cr,uid,report[0])
|
report = report_obj.browse(cr, uid, report[0])
|
||||||
name = report.name
|
|
||||||
data = report.behaviour()[report.id]
|
data = report.behaviour()[report.id]
|
||||||
action = data['action']
|
action = data['action']
|
||||||
printer = data['printer']
|
printer = data['printer']
|
||||||
if action != 'client':
|
if action != 'client':
|
||||||
if (self._reports and self._reports.get(report_id, False) and self._reports[report_id].get('result', False)
|
if (self._reports and self._reports.get(report_id, False)
|
||||||
and self._reports[report_id].get('format', False)):
|
and self._reports[report_id].get('result', False)
|
||||||
report_obj.print_direct(cr, uid, report.id, base64.encodestring(self._reports[report_id]['result']),
|
and self._reports[report_id].get('format', False)):
|
||||||
|
report_obj.print_direct(
|
||||||
|
cr, uid, report.id, base64.encodestring(self._reports[report_id]['result']),
|
||||||
self._reports[report_id]['format'], printer)
|
self._reports[report_id]['format'], printer)
|
||||||
# XXX "Warning" removed as it breaks the workflow
|
# XXX "Warning" removed as it breaks the workflow
|
||||||
# it would be interesting to have a dialog box to confirm if we really want to print
|
# it would be interesting to have a dialog box to confirm if we really want to print
|
||||||
# in this case it must be with a by pass parameter to allow massive impression
|
# in this case it must be with a by pass parameter to allow massive impression
|
||||||
#raise osv.except_osv(_('Printing...'), _('Document sent to printer %s') % (printer,))
|
# raise osv.except_osv(
|
||||||
|
# _('Printing...'),
|
||||||
|
# _('Document sent to printer %s') % (printer,))
|
||||||
|
|
||||||
except:
|
except:
|
||||||
cr.rollback()
|
cr.rollback()
|
||||||
|
|||||||
@@ -26,17 +26,19 @@ from openerp.osv import orm, fields
|
|||||||
|
|
||||||
from printing import _available_action_types
|
from printing import _available_action_types
|
||||||
|
|
||||||
#
|
|
||||||
# Users
|
|
||||||
#
|
|
||||||
class res_users(orm.Model):
|
class res_users(orm.Model):
|
||||||
|
"""
|
||||||
|
Users
|
||||||
|
"""
|
||||||
_name = "res.users"
|
_name = "res.users"
|
||||||
_inherit = "res.users"
|
_inherit = "res.users"
|
||||||
|
|
||||||
def _user_available_action_types(self, cr, uid, context=None):
|
def _user_available_action_types(self, cr, uid, context=None):
|
||||||
if context is None:
|
if context is None:
|
||||||
context={}
|
context = {}
|
||||||
return [x for x in _available_action_types(self, cr, uid, context) if x[0] != 'user_default']
|
return [x for x in _available_action_types(self, cr, uid, context)
|
||||||
|
if x[0] != 'user_default']
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'printing_action': fields.selection(_user_available_action_types, 'Printing Action'),
|
'printing_action': fields.selection(_user_available_action_types, 'Printing Action'),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
||||||
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
||||||
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
|
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
||||||
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
||||||
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
|
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
|
||||||
@@ -37,14 +37,16 @@ class printing_printer_update_wizard(orm.TransientModel):
|
|||||||
|
|
||||||
def action_ok(self, cr, uid, ids, context=None):
|
def action_ok(self, cr, uid, ids, context=None):
|
||||||
# Update Printers
|
# Update Printers
|
||||||
|
printer_obj = self.pool['printing.printer']
|
||||||
try:
|
try:
|
||||||
connection = cups.Connection()
|
connection = cups.Connection()
|
||||||
printers = connection.getPrinters()
|
printers = connection.getPrinters()
|
||||||
except:
|
except:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
ids = self.pool.get('printing.printer').search(cr, uid, [('system_name','in',printers.keys())], context=context)
|
ids = printer_obj.search(
|
||||||
for printer in self.pool.get('printing.printer').browse(cr, uid, ids, context=context):
|
cr, uid, [('system_name', 'in', printers.keys())], context=context)
|
||||||
|
for printer in printer_obj.browse(cr, uid, ids, context=context):
|
||||||
del printers[printer.system_name]
|
del printers[printer.system_name]
|
||||||
|
|
||||||
for name in printers:
|
for name in printers:
|
||||||
|
|||||||
@@ -23,4 +23,3 @@ import ir_attachment
|
|||||||
import pingen
|
import pingen
|
||||||
import pingen_document
|
import pingen_document
|
||||||
import res_company
|
import res_company
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ class Pingen(object):
|
|||||||
|
|
||||||
if response.json['error']:
|
if response.json['error']:
|
||||||
raise APIError(
|
raise APIError(
|
||||||
"%s: %s" % (response.json['errorcode'], response.json['errormessage']))
|
"%s: %s" % (response.json['errorcode'], response.json['errormessage']))
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@@ -169,10 +169,10 @@ class Pingen(object):
|
|||||||
multipart, content_type = encode_multipart_formdata(formdata)
|
multipart, content_type = encode_multipart_formdata(formdata)
|
||||||
|
|
||||||
response = self._send(
|
response = self._send(
|
||||||
self.session.post,
|
self.session.post,
|
||||||
'document/upload',
|
'document/upload',
|
||||||
headers={'Content-Type': content_type},
|
headers={'Content-Type': content_type},
|
||||||
data=multipart)
|
data=multipart)
|
||||||
|
|
||||||
rjson = response.json
|
rjson = response.json
|
||||||
|
|
||||||
@@ -198,10 +198,10 @@ class Pingen(object):
|
|||||||
'color': color,
|
'color': color,
|
||||||
}
|
}
|
||||||
response = self._send(
|
response = self._send(
|
||||||
self.session.post,
|
self.session.post,
|
||||||
'document/send',
|
'document/send',
|
||||||
params={'id': document_id},
|
params={'id': document_id},
|
||||||
data={'data': json.dumps(data)})
|
data={'data': json.dumps(data)})
|
||||||
|
|
||||||
return response.json['id']
|
return response.json['id']
|
||||||
|
|
||||||
@@ -212,9 +212,9 @@ class Pingen(object):
|
|||||||
:return: dict of infos of the post
|
:return: dict of infos of the post
|
||||||
"""
|
"""
|
||||||
response = self._send(
|
response = self._send(
|
||||||
self.session.get,
|
self.session.get,
|
||||||
'post/get',
|
'post/get',
|
||||||
params={'id': post_id})
|
params={'id': post_id})
|
||||||
|
|
||||||
return response.json['item']
|
return response.json['item']
|
||||||
|
|
||||||
@@ -225,4 +225,3 @@ class Pingen(object):
|
|||||||
:param dict post_infos: post infos returned by `post_infos`
|
:param dict post_infos: post infos returned by `post_infos`
|
||||||
"""
|
"""
|
||||||
return post_infos['status'] == 200
|
return post_infos['status'] == 200
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ from openerp.osv import osv, orm, fields
|
|||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp import pooler, tools
|
from openerp import pooler, tools
|
||||||
from .pingen import APIError, ConnectionError, POST_SENDING_STATUS, \
|
from .pingen import APIError, ConnectionError, POST_SENDING_STATUS, \
|
||||||
pingen_datetime_to_utc
|
pingen_datetime_to_utc
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ class pingen_document(orm.Model):
|
|||||||
def _get_pingen_session(self, cr, uid, context=None):
|
def _get_pingen_session(self, cr, uid, context=None):
|
||||||
""" Returns a pingen session for a user """
|
""" Returns a pingen session for a user """
|
||||||
company = self.pool.get('res.users').browse(
|
company = self.pool.get('res.users').browse(
|
||||||
cr, uid, uid, context=context).company_id
|
cr, uid, uid, context=context).company_id
|
||||||
return self.pool.get('res.company')._pingen(cr, uid, company, context=context)
|
return self.pool.get('res.company')._pingen(cr, uid, company, context=context)
|
||||||
|
|
||||||
def _push_to_pingen(self, cr, uid, document, pingen=None, context=None):
|
def _push_to_pingen(self, cr, uid, document, pingen=None, context=None):
|
||||||
@@ -105,7 +105,7 @@ class pingen_document(orm.Model):
|
|||||||
attachment_obj = self.pool.get('ir.attachment')
|
attachment_obj = self.pool.get('ir.attachment')
|
||||||
|
|
||||||
decoded_document = attachment_obj._decoded_content(
|
decoded_document = attachment_obj._decoded_content(
|
||||||
cr, uid, document.attachment_id, context=context)
|
cr, uid, document.attachment_id, context=context)
|
||||||
|
|
||||||
if pingen is None:
|
if pingen is None:
|
||||||
pingen = self._get_pingen_session(cr, uid, context=context)
|
pingen = self._get_pingen_session(cr, uid, context=context)
|
||||||
@@ -116,16 +116,16 @@ class pingen_document(orm.Model):
|
|||||||
document.pingen_send,
|
document.pingen_send,
|
||||||
document.pingen_speed,
|
document.pingen_speed,
|
||||||
document.pingen_color)
|
document.pingen_color)
|
||||||
except ConnectionError as e:
|
except ConnectionError:
|
||||||
_logger.exception(
|
_logger.exception(
|
||||||
'Connection Error when pushing Pingen Document %s to %s.' %
|
'Connection Error when pushing Pingen Document %s to %s.' %
|
||||||
(document.id, pingen.url))
|
(document.id, pingen.url))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
except APIError as e:
|
except APIError:
|
||||||
_logger.error(
|
_logger.error(
|
||||||
'API Error when pushing Pingen Document %s to %s.' %
|
'API Error when pushing Pingen Document %s to %s.' %
|
||||||
(document.id, pingen.url))
|
(document.id, pingen.url))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
error = False
|
error = False
|
||||||
@@ -174,8 +174,8 @@ class pingen_document(orm.Model):
|
|||||||
|
|
||||||
except:
|
except:
|
||||||
_logger.exception(
|
_logger.exception(
|
||||||
'Unexcepted Error when updating the status of pingen.document %s: ' %
|
'Unexcepted Error when updating the status of pingen.document %s: ' %
|
||||||
document.id)
|
document.id)
|
||||||
raise osv.except_osv(
|
raise osv.except_osv(
|
||||||
_('Error'),
|
_('Error'),
|
||||||
_('Unexcepted Error when updating the status of Document %s') % document.name)
|
_('Unexcepted Error when updating the status of Document %s') % document.name)
|
||||||
@@ -263,13 +263,13 @@ class pingen_document(orm.Model):
|
|||||||
document.pingen_id,
|
document.pingen_id,
|
||||||
document.pingen_speed,
|
document.pingen_speed,
|
||||||
document.pingen_color)
|
document.pingen_color)
|
||||||
except ConnectionError as e:
|
except ConnectionError:
|
||||||
_logger.exception('Connection Error when asking for sending Pingen Document %s to %s.' %
|
_logger.exception('Connection Error when asking for sending Pingen Document %s to %s.' %
|
||||||
(document.id, pingen.url))
|
(document.id, pingen.url))
|
||||||
raise
|
raise
|
||||||
except APIError as e:
|
except APIError:
|
||||||
_logger.exception('API Error when asking for sending Pingen Document %s to %s.' %
|
_logger.exception('API Error when asking for sending Pingen Document %s to %s.' %
|
||||||
(document.id, pingen.url))
|
(document.id, pingen.url))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
document.write(
|
document.write(
|
||||||
@@ -306,8 +306,8 @@ class pingen_document(orm.Model):
|
|||||||
|
|
||||||
except:
|
except:
|
||||||
_logger.exception(
|
_logger.exception(
|
||||||
'Unexcepted Error when updating the status of pingen.document %s: ' %
|
'Unexcepted Error when updating the status of pingen.document %s: ' %
|
||||||
document.id)
|
document.id)
|
||||||
raise osv.except_osv(
|
raise osv.except_osv(
|
||||||
_('Error'),
|
_('Error'),
|
||||||
_('Unexcepted Error when updating the status of Document %s') % document.name)
|
_('Unexcepted Error when updating the status of Document %s') % document.name)
|
||||||
@@ -323,22 +323,22 @@ class pingen_document(orm.Model):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
post_infos = pingen.post_infos(document.post_id)
|
post_infos = pingen.post_infos(document.post_id)
|
||||||
except ConnectionError as e:
|
except ConnectionError:
|
||||||
_logger.exception(
|
_logger.exception(
|
||||||
'Connection Error when asking for '
|
'Connection Error when asking for '
|
||||||
'sending Pingen Document %s to %s.' %
|
'sending Pingen Document %s to %s.' %
|
||||||
(document.id, pingen.url))
|
(document.id, pingen.url))
|
||||||
raise
|
raise
|
||||||
except APIError as e:
|
except APIError:
|
||||||
_logger.exception(
|
_logger.exception(
|
||||||
'API Error when asking for sending Pingen Document %s to %s.' %
|
'API Error when asking for sending Pingen Document %s to %s.' %
|
||||||
(document.id, pingen.url))
|
(document.id, pingen.url))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
currency_ids = self.pool.get('res.currency').search(
|
currency_ids = self.pool.get('res.currency').search(
|
||||||
cr, uid, [('name', '=', post_infos['currency'])], context=context)
|
cr, uid, [('name', '=', post_infos['currency'])], context=context)
|
||||||
country_ids = self.pool.get('res.country').search(
|
country_ids = self.pool.get('res.country').search(
|
||||||
cr, uid, [('code', '=', post_infos['country'])], context=context)
|
cr, uid, [('code', '=', post_infos['country'])], context=context)
|
||||||
|
|
||||||
send_date = pingen_datetime_to_utc(infos['date'])
|
send_date = pingen_datetime_to_utc(infos['date'])
|
||||||
|
|
||||||
@@ -369,9 +369,9 @@ class pingen_document(orm.Model):
|
|||||||
"""
|
"""
|
||||||
if not ids:
|
if not ids:
|
||||||
ids = self.search(
|
ids = self.search(
|
||||||
cr, uid,
|
cr, uid,
|
||||||
[('state', '=', 'sendcenter')],
|
[('state', '=', 'sendcenter')],
|
||||||
context=context)
|
context=context)
|
||||||
|
|
||||||
with closing(pooler.get_db(cr.dbname).cursor()) as loc_cr, \
|
with closing(pooler.get_db(cr.dbname).cursor()) as loc_cr, \
|
||||||
self._get_pingen_session(cr, uid, context=context) as session:
|
self._get_pingen_session(cr, uid, context=context) as session:
|
||||||
@@ -417,10 +417,9 @@ class pingen_document(orm.Model):
|
|||||||
|
|
||||||
except:
|
except:
|
||||||
_logger.exception(
|
_logger.exception(
|
||||||
'Unexcepted Error when updating the status of pingen.document %s: ' %
|
'Unexcepted Error when updating the status of pingen.document %s: ' %
|
||||||
document.id)
|
document.id)
|
||||||
raise osv.except_osv(
|
raise osv.except_osv(
|
||||||
_('Error'),
|
_('Error'),
|
||||||
_('Unexcepted Error when updating the status of Document %s') % document.name)
|
_('Unexcepted Error when updating the status of Document %s') % document.name)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from openerp.osv import orm, fields
|
|||||||
from openerp.osv.orm import browse_record
|
from openerp.osv.orm import browse_record
|
||||||
from .pingen import Pingen
|
from .pingen import Pingen
|
||||||
|
|
||||||
|
|
||||||
class res_company(orm.Model):
|
class res_company(orm.Model):
|
||||||
|
|
||||||
_inherit = 'res.company'
|
_inherit = 'res.company'
|
||||||
@@ -39,4 +40,3 @@ class res_company(orm.Model):
|
|||||||
if not isinstance(company, browse_record):
|
if not isinstance(company, browse_record):
|
||||||
company = self.browse(cr, uid, company, context=context)
|
company = self.browse(cr, uid, company, context=context)
|
||||||
return Pingen(company.pingen_token, staging=company.pingen_staging)
|
return Pingen(company.pingen_token, staging=company.pingen_staging)
|
||||||
|
|
||||||
|
|||||||
@@ -18,4 +18,3 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
|||||||
@@ -20,14 +20,14 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
{
|
{
|
||||||
'name' : 'pingen.com integration (document)',
|
'name': 'pingen.com integration (document)',
|
||||||
'version' : '1.0',
|
'version': '1.0',
|
||||||
'author' : 'Camptocamp',
|
'author': 'Camptocamp',
|
||||||
'maintainer': 'Camptocamp',
|
'maintainer': 'Camptocamp',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'Reporting',
|
'category': 'Reporting',
|
||||||
'complexity': 'easy',
|
'complexity': 'easy',
|
||||||
'depends' : ['document', 'pingen'],
|
'depends': ['document', 'pingen'],
|
||||||
'description': """
|
'description': """
|
||||||
Glue module between the `pingen` and the `document` modules.
|
Glue module between the `pingen` and the `document` modules.
|
||||||
""",
|
""",
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ class ReportXML(orm.Model):
|
|||||||
|
|
||||||
# Retrieve report-user specific values
|
# Retrieve report-user specific values
|
||||||
act_ids = printing_act_obj.search(
|
act_ids = printing_act_obj.search(
|
||||||
cr, uid,
|
cr, uid,
|
||||||
[('report_id', '=', report.id),
|
[('report_id', '=', report.id),
|
||||||
('user_id', '=', uid),
|
('user_id', '=', uid),
|
||||||
('action', '!=', 'user_default')], context=context)
|
('action', '!=', 'user_default')], context=context)
|
||||||
if act_ids:
|
if act_ids:
|
||||||
user_action = printing_act_obj.browse(cr, uid, act_ids[0], context=context)
|
user_action = printing_act_obj.browse(cr, uid, act_ids[0], context=context)
|
||||||
if user_action.tray_id:
|
if user_action.tray_id:
|
||||||
|
|||||||
Reference in New Issue
Block a user