mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[IMP] base_report_to_printer - use an action id in an action method instead of a report id makes more sens
This commit is contained in:
@@ -275,6 +275,7 @@ class report_xml(orm.Model):
|
|||||||
context={}
|
context={}
|
||||||
result = {}
|
result = {}
|
||||||
printer_obj = self.pool.get('printing.printer')
|
printer_obj = self.pool.get('printing.printer')
|
||||||
|
printing_act_obj = self.pool.get('printing.report.xml.action')
|
||||||
# Set hardcoded default action
|
# Set hardcoded default action
|
||||||
default_action = 'client'
|
default_action = 'client'
|
||||||
# Retrieve system wide printer
|
# Retrieve system wide printer
|
||||||
@@ -301,9 +302,12 @@ class report_xml(orm.Model):
|
|||||||
printer = report.printing_printer_id
|
printer = report.printing_printer_id
|
||||||
|
|
||||||
# Retrieve report-user specific values
|
# Retrieve report-user specific values
|
||||||
## XXX search by report.id instead of giving report.id in behaviour
|
act_ids = printing_act_obj.search(cr, uid,
|
||||||
user_action = self.pool.get('printing.report.xml.action').behaviour(cr, uid, report.id, context)
|
[('report_id', '=', report.id),
|
||||||
if user_action and user_action['action'] != 'user_default':
|
('user_id', '=', uid),
|
||||||
|
('action', '!=', 'user_default')], context=context)
|
||||||
|
if act_ids:
|
||||||
|
user_action = printing_act_obj.behaviour(cr, uid, act_ids[0], context)
|
||||||
action = user_action['action']
|
action = user_action['action']
|
||||||
if user_action['printer']:
|
if user_action['printer']:
|
||||||
printer = user_action['printer']
|
printer = user_action['printer']
|
||||||
@@ -325,14 +329,12 @@ class report_xml_action(orm.Model):
|
|||||||
'printer_id': fields.many2one('printing.printer', 'Printer'),
|
'printer_id': fields.many2one('printing.printer', 'Printer'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def behaviour(self, cr, uid, report_id, context=None):
|
|
||||||
if context is None:
|
def behaviour(self, cr, uid, act_id, context=None):
|
||||||
context={}
|
|
||||||
result = {}
|
result = {}
|
||||||
ids = self.search(cr, uid, [('report_id','=',report_id),('user_id','=',uid)], context=context)
|
if not act_id:
|
||||||
if not ids:
|
|
||||||
return False
|
return False
|
||||||
action = self.browse(cr, uid, ids[0], context)
|
action = self.browse(cr, uid, act_id, context=context)
|
||||||
return {
|
return {
|
||||||
'action': action.action,
|
'action': action.action,
|
||||||
'printer': action.printer_id.system_name,
|
'printer': action.printer_id.system_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user