mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[FIX] print report generation
This commit is contained in:
@@ -20,9 +20,7 @@
|
||||
##############################################################################
|
||||
import netsvc
|
||||
import logging
|
||||
from openerp.osv.orm import TransientModel, fields
|
||||
from openerp.osv.osv import except_osv
|
||||
from openerp.tools.translate import _
|
||||
from openerp.osv.orm import TransientModel, fields
|
||||
|
||||
logger = logging.getLogger('credit.control.line.mailing')
|
||||
|
||||
@@ -178,4 +176,3 @@ class CreditCommunication(TransientModel):
|
||||
l_obj = self.pool.get('credit.control.line')
|
||||
l_obj.write(cr, uid, line_ids, {'state': 'sent'}, context=context)
|
||||
return line_ids
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class CreditControlPrinter(TransientModel):
|
||||
|
||||
def print_lines(self, cr, uid, wiz_id, context=None):
|
||||
assert not (isinstance(wiz_id, list) and len(wiz_id) > 1), \
|
||||
"wiz_id: only one id expected"
|
||||
"wiz_id: only one id expected"
|
||||
comm_obj = self.pool.get('credit.control.communication')
|
||||
if isinstance(wiz_id, list):
|
||||
wiz_id = wiz_id[0]
|
||||
@@ -75,15 +75,20 @@ class CreditControlPrinter(TransientModel):
|
||||
raise except_osv(_('Error'), _('No credit control lines selected.'))
|
||||
|
||||
line_ids = [l.id for l in form.line_ids]
|
||||
comms = comm_obj._generate_comm_from_credit_line_ids(
|
||||
cr, uid, line_ids, context=context)
|
||||
comms = comm_obj._generate_comm_from_credit_line_ids(cr, uid, line_ids,
|
||||
context=context)
|
||||
report_file = comm_obj._generate_report(cr, uid, comms, context=context)
|
||||
|
||||
form.write({'report_file': base64.b64encode(report_file), 'state': 'done'})
|
||||
|
||||
if form.mark_as_sent:
|
||||
filtered_ids = self._filter_line_ids(cr, uid, line_ids, context)
|
||||
comm_obj._mark_credit_line_as_sent(cr, uid, comms, context=context)
|
||||
|
||||
return False # do not close the window, we need it to download the report
|
||||
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'res_model': 'credit.control.printer',
|
||||
'view_mode': 'form',
|
||||
'view_type': 'form',
|
||||
'res_id': form.id,
|
||||
'views': [(False, 'form')],
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user