Anael Lorimier
10 years ago
5 changed files with 58 additions and 43 deletions
-
3__init__.py
-
6__openerp__.py
-
49ir_report.py
-
8ir_report.xml
-
35py3o_report.py
@ -1,2 +1,5 @@ |
|||||
import ir_report |
import ir_report |
||||
import py3o_report |
import py3o_report |
||||
|
import py3o_template |
||||
|
import py3o_server |
||||
|
import py3o_fusion_filetype |
@ -1,46 +1,21 @@ |
|||||
from base64 import b64encode |
|
||||
|
|
||||
from openerp import addons |
|
||||
from openerp.osv import fields, osv |
from openerp.osv import fields, osv |
||||
from openerp.tools.translate import _ |
|
||||
|
|
||||
|
|
||||
class report_xml(osv.osv): |
|
||||
|
class report_xml(osv.Model): |
||||
''' Inherit from ir.actions.report.xml to allow customizing the template |
''' Inherit from ir.actions.report.xml to allow customizing the template |
||||
file. By default, the file defined when registering the report is used; |
|
||||
but the user can download / upload a new one. ''' |
|
||||
|
file. The user cam chose a template from a list. |
||||
|
The list is configurable in the configuration tab, see py3o_template.py |
||||
|
''' |
||||
|
|
||||
_inherit = 'ir.actions.report.xml' |
_inherit = 'ir.actions.report.xml' |
||||
|
|
||||
def _get_filename(self, cr, uid, ids, field_name, arg, context): |
|
||||
return { |
|
||||
br.id: br.name + '.odt' |
|
||||
for br in self.browse(cr, uid, ids, context=context) |
|
||||
if br.report_type == 'py3o' |
|
||||
} |
|
||||
|
|
||||
def _get_template_data(self, cr, uid, ids, field_name, arg, context): |
|
||||
''' Just return the data stored in the binary field, unless it is |
|
||||
empty; in that case, read the template file. ''' |
|
||||
|
|
||||
return { |
|
||||
br.id: (br.py3o_template_data or |
|
||||
b64encode(file(addons.get_module_resource( |
|
||||
*br.report_file.split('/')), 'rb').read())) |
|
||||
for br in self.browse(cr, uid, ids, context=context) |
|
||||
if br.report_type == 'py3o' |
|
||||
} |
|
||||
|
|
||||
_columns = { |
_columns = { |
||||
'py3o_filename': fields.function(_get_filename, |
|
||||
type='char', |
|
||||
method=True, |
|
||||
readonly=True), |
|
||||
|
|
||||
'py3o_template': fields.function(_get_template_data, |
|
||||
type='binary', |
|
||||
method=True, |
|
||||
readonly=True), |
|
||||
|
|
||||
'py3o_template_data': fields.binary(_('LibreOffice template')), |
|
||||
|
'py3o_fusion_filetype': fields.many2one( |
||||
|
'py3o.fusion.filetype', |
||||
|
u"Output Format", |
||||
|
), |
||||
|
'py3o_template_id': fields.many2one( |
||||
|
'py3o.template', |
||||
|
u"Template", |
||||
|
), |
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue