mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[PEP8]
This commit is contained in:
@@ -18,8 +18,8 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
{'name' : 'Report to printer - Paper tray selection',
|
{'name': 'Report to printer - Paper tray selection',
|
||||||
'version' : '1.0',
|
'version': '1.0',
|
||||||
'category': 'Printer',
|
'category': 'Printer',
|
||||||
'description': """
|
'description': """
|
||||||
Report to printer - Paper tray selection
|
Report to printer - Paper tray selection
|
||||||
@@ -38,12 +38,12 @@ Report to printer - Paper tray selection
|
|||||||
This allows you to dedicate a specific paper source for exemple for prepinted
|
This allows you to dedicate a specific paper source for exemple for prepinted
|
||||||
paper such as payment slip.
|
paper such as payment slip.
|
||||||
""",
|
""",
|
||||||
'author' : 'Camptocamp',
|
'author': 'Camptocamp',
|
||||||
'maintainer': 'Camptocamp',
|
'maintainer': 'Camptocamp',
|
||||||
'website': 'http://www.camptocamp.com/',
|
'website': 'http://www.camptocamp.com/',
|
||||||
'depends' : ['base_report_assembler',
|
'depends': ['base_report_assembler',
|
||||||
'base_report_to_printer',
|
'base_report_to_printer',
|
||||||
],
|
],
|
||||||
'data': [
|
'data': [
|
||||||
'users_view.xml',
|
'users_view.xml',
|
||||||
'ir_report_view.xml',
|
'ir_report_view.xml',
|
||||||
|
|||||||
@@ -20,12 +20,14 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
from openerp.osv import orm, fields
|
from openerp.osv import orm, fields
|
||||||
|
|
||||||
|
|
||||||
class ReportXML(orm.Model):
|
class ReportXML(orm.Model):
|
||||||
|
|
||||||
_inherit = 'ir.actions.report.xml'
|
_inherit = 'ir.actions.report.xml'
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'printer_tray_id': fields.many2one('printing.tray', 'Paper Source',
|
'printer_tray_id': fields.many2one(
|
||||||
|
'printing.tray', 'Paper Source',
|
||||||
domain="[('printer_id', '=', printing_printer_id)]"),
|
domain="[('printer_id', '=', printing_printer_id)]"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +48,8 @@ class ReportXML(orm.Model):
|
|||||||
tray = report.printer_tray_id
|
tray = report.printer_tray_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(
|
||||||
|
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)
|
||||||
@@ -58,4 +61,3 @@ class ReportXML(orm.Model):
|
|||||||
if tray:
|
if tray:
|
||||||
options['InputSlot'] = str(tray.system_name)
|
options['InputSlot'] = str(tray.system_name)
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|||||||
@@ -24,13 +24,14 @@ from cups import PPD
|
|||||||
from openerp import pooler
|
from openerp import pooler
|
||||||
from openerp.osv import orm, fields
|
from openerp.osv import orm, fields
|
||||||
|
|
||||||
|
|
||||||
class Printer(orm.Model):
|
class Printer(orm.Model):
|
||||||
|
|
||||||
_inherit = 'printing.printer'
|
_inherit = 'printing.printer'
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'tray_ids': fields.one2many('printing.tray', 'printer_id', 'Paper Sources'),
|
'tray_ids': fields.one2many('printing.tray', 'printer_id', 'Paper Sources'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _update_tray_option(self, db_name, uid, printer, context=None):
|
def _update_tray_option(self, db_name, uid, printer, context=None):
|
||||||
"""
|
"""
|
||||||
@@ -45,25 +46,22 @@ class Printer(orm.Model):
|
|||||||
ppd_file_path = connection.getPPD3(printer.system_name)
|
ppd_file_path = connection.getPPD3(printer.system_name)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not ppd_file_path[2]:
|
if not ppd_file_path[2]:
|
||||||
return
|
return
|
||||||
ppd = PPD(ppd_file_path[2])
|
ppd = PPD(ppd_file_path[2])
|
||||||
option = ppd.findOption('InputSlot')
|
option = ppd.findOption('InputSlot')
|
||||||
if not option:
|
if not option:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for tray_opt in option.choices:
|
for tray_opt in option.choices:
|
||||||
if tray_opt['choice'] not in [t.system_name for t in printer.tray_ids]:
|
if tray_opt['choice'] not in [t.system_name for t in printer.tray_ids]:
|
||||||
tray_vals = {
|
tray_vals = {
|
||||||
'name': tray_opt['text'],
|
'name': tray_opt['text'],
|
||||||
'system_name': tray_opt['choice'],
|
'system_name': tray_opt['choice'],
|
||||||
'printer_id': printer.id,
|
'printer_id': printer.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
tray_obj.create(cr, uid, tray_vals, context=context)
|
tray_obj.create(cr, uid, tray_vals, context=context)
|
||||||
|
|
||||||
cr.commit()
|
cr.commit()
|
||||||
except:
|
except:
|
||||||
cr.rollback()
|
cr.rollback()
|
||||||
@@ -72,7 +70,6 @@ class Printer(orm.Model):
|
|||||||
cr.close()
|
cr.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def update_printers_status(self, db_name, uid, context=None):
|
def update_printers_status(self, db_name, uid, context=None):
|
||||||
"""
|
"""
|
||||||
Add creation of tray if no tray are defined
|
Add creation of tray if no tray are defined
|
||||||
@@ -95,6 +92,4 @@ class Printer(orm.Model):
|
|||||||
# XXX we consider config of printer won't change
|
# XXX we consider config of printer won't change
|
||||||
if not printer.tray_ids:
|
if not printer.tray_ids:
|
||||||
self._update_tray_option(db_name, uid, printer, context=context)
|
self._update_tray_option(db_name, uid, printer, context=context)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
from openerp.osv import orm, fields
|
from openerp.osv import orm, fields
|
||||||
|
|
||||||
|
|
||||||
class PrinterTray(orm.Model):
|
class PrinterTray(orm.Model):
|
||||||
|
|
||||||
_name = 'printing.tray'
|
_name = 'printing.tray'
|
||||||
|
|||||||
@@ -21,11 +21,13 @@
|
|||||||
|
|
||||||
from openerp.osv import orm, fields
|
from openerp.osv import orm, fields
|
||||||
|
|
||||||
|
|
||||||
class ReportXMLAction(orm.Model):
|
class ReportXMLAction(orm.Model):
|
||||||
_inherit = 'printing.report.xml.action'
|
_inherit = 'printing.report.xml.action'
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'printer_tray_id': fields.many2one('printing.tray', 'Paper Source',
|
'printer_tray_id': fields.many2one(
|
||||||
|
'printing.tray', 'Paper Source',
|
||||||
domain="[('printer_id', '=', printer_id)]"),
|
domain="[('printer_id', '=', printer_id)]"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +36,3 @@ class ReportXMLAction(orm.Model):
|
|||||||
action = self.browse(cr, uid, act_id, context=context)
|
action = self.browse(cr, uid, act_id, context=context)
|
||||||
res['tray'] = action.printer_tray_id.system_name
|
res['tray'] = action.printer_tray_id.system_name
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,13 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
from openerp.osv import orm, fields
|
from openerp.osv import orm, fields
|
||||||
|
|
||||||
|
|
||||||
class ResUsers(orm.Model):
|
class ResUsers(orm.Model):
|
||||||
|
|
||||||
_inherit = "res.users"
|
_inherit = "res.users"
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'printer_tray_id': fields.many2one('printing.tray', 'Default Printer Paper Source',
|
'printer_tray_id': fields.many2one(
|
||||||
|
'printing.tray', 'Default Printer Paper Source',
|
||||||
domain="[('printer_id', '=', printing_printer_id)]"),
|
domain="[('printer_id', '=', printing_printer_id)]"),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user