~openerp-dev/openobject-server/trunk-imp-onchange-behave-darshan

« back to all changes in this revision

Viewing changes to openerp/addons/base/ir/ir_actions.py

  • Committer: Darshan Kalola(OpenERP)
  • Date: 2014-04-09 08:44:52 UTC
  • mfrom: (4936.1.232 openobject-server)
  • Revision ID: dka@tinyerp.com-20140409084452-w1e499j21i3eli9d
[MERGE]sync with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
            cr.execute("SELECT * FROM ir_act_report_xml WHERE report_name=%s", (name,))
105
105
            r = cr.dictfetchone()
106
106
            if r:
107
 
                if r['report_rml'] or r['report_rml_content_data']:
 
107
                if r['report_type'] in ['qweb-pdf', 'qweb-html']:
 
108
                    return r['report_name']
 
109
                elif r['report_rml'] or r['report_rml_content_data']:
108
110
                    if r['parser']:
109
111
                        kwargs = { 'parser': operator.attrgetter(r['parser'])(openerp.addons) }
110
112
                    else:
127
129
        Look up a report definition and render the report for the provided IDs.
128
130
        """
129
131
        new_report = self._lookup_report(cr, name)
130
 
        return new_report.create(cr, uid, res_ids, data, context)
 
132
        # in order to use current yml test files with qweb reports
 
133
        if isinstance(new_report, (str, unicode)):
 
134
            return self.pool['report'].get_pdf(cr, uid, res_ids, new_report, data=data, context=context), 'pdf'
 
135
        else:
 
136
            return new_report.create(cr, uid, res_ids, data, context)
131
137
 
132
138
    _name = 'ir.actions.report.xml'
133
139
    _inherit = 'ir.actions.actions'
135
141
    _sequence = 'ir_actions_id_seq'
136
142
    _order = 'name'
137
143
    _columns = {
 
144
        'type': fields.char('Action Type', size=32, required=True),
138
145
        'name': fields.char('Name', size=64, required=True, translate=True),
139
 
        'model': fields.char('Object', size=64, required=True),
140
 
        'type': fields.char('Action Type', size=32, required=True),
141
 
        'report_name': fields.char('Service Name', size=64, required=True),
142
 
        'usage': fields.char('Action Usage', size=32),
143
 
        'report_type': fields.char('Report Type', size=32, required=True, help="Report Type, e.g. pdf, html, raw, sxw, odt, html2html, mako2html, ..."),
 
146
 
 
147
        'model': fields.char('Model', required=True),
 
148
        'report_type': fields.selection([('qweb-pdf', 'PDF'),
 
149
                    ('qweb-html', 'HTML'),
 
150
                    ('controller', 'Controller'),
 
151
                    ('pdf', 'RML pdf (deprecated)'),
 
152
                    ('sxw', 'RML sxw (deprecated)'),
 
153
                    ('webkit', 'Webkit (deprecated)'),
 
154
                    ], 'Report Type', required=True, help="HTML will open the report directly in your browser, PDF will use wkhtmltopdf to render the HTML into a PDF file and let you download it, Controller allows you to define the url of a custom controller outputting any kind of report."),
 
155
        'report_name': fields.char('Template Name', required=True, help="For QWeb reports, name of the template used in the rendering. The method 'render_html' of the model 'report.template_name' will be called (if any) to give the html. For RML reports, this is the LocalService name."),
144
156
        'groups_id': fields.many2many('res.groups', 'res_groups_report_rel', 'uid', 'gid', 'Groups'),
 
157
 
 
158
        # options
145
159
        'multi': fields.boolean('On Multiple Doc.', help="If set to true, the action will not be displayed on the right toolbar of a form view."),
 
160
        'attachment_use': fields.boolean('Reload from Attachment', help='If you check this, then the second time the user prints with same attachment name, it returns the previous report.'),
146
161
        'attachment': fields.char('Save as Attachment Prefix', size=128, help='This is the filename of the attachment used to store the printing result. Keep empty to not save the printed reports. You can use a python expression with the object and time variables.'),
147
 
        'attachment_use': fields.boolean('Reload from Attachment', help='If you check this, then the second time the user prints with same attachment name, it returns the previous report.'),
 
162
 
 
163
        # Deprecated rml stuff
 
164
        'usage': fields.char('Action Usage', size=32),
 
165
        'header': fields.boolean('Add RML Header', help="Add or not the corporate RML header"),
 
166
        'parser': fields.char('Parser Class'),
148
167
        'auto': fields.boolean('Custom Python Parser'),
149
168
 
150
 
        'header': fields.boolean('Add RML Header', help="Add or not the corporate RML header"),
151
 
 
152
 
        'report_xsl': fields.char('XSL Path', size=256),
153
 
        'report_xml': fields.char('XML Path', size=256, help=''),
154
 
 
155
 
        # Pending deprecation... to be replaced by report_file as this object will become the default report object (not so specific to RML anymore)
156
 
        'report_rml': fields.char('Main Report File Path', size=256, help="The path to the main report file (depending on Report Type) or NULL if the content is in another data field"),
157
 
        # temporary related field as report_rml is pending deprecation - this field will replace report_rml after v6.0
158
 
        'report_file': fields.related('report_rml', type="char", size=256, required=False, readonly=False, string='Report File', help="The path to the main report file (depending on Report Type) or NULL if the content is in another field", store=True),
 
169
        'report_xsl': fields.char('XSL Path'),
 
170
        'report_xml': fields.char('XML Path'),
 
171
 
 
172
        'report_rml': fields.char('Main Report File Path/controller', help="The path to the main report file/controller (depending on Report Type) or NULL if the content is in another data field"),
 
173
        'report_file': fields.related('report_rml', type="char", required=False, readonly=False, string='Report File', help="The path to the main report file (depending on Report Type) or NULL if the content is in another field", store=True),
159
174
 
160
175
        'report_sxw': fields.function(_report_sxw, type='char', string='SXW Path'),
161
176
        'report_sxw_content_data': fields.binary('SXW Content'),
162
177
        'report_rml_content_data': fields.binary('RML Content'),
163
178
        'report_sxw_content': fields.function(_report_content, fnct_inv=_report_content_inv, type='binary', string='SXW Content',),
164
179
        'report_rml_content': fields.function(_report_content, fnct_inv=_report_content_inv, type='binary', string='RML Content'),
165
 
 
166
 
        'parser': fields.char('Parser Class'),
167
180
    }
168
181
    _defaults = {
169
182
        'type': 'ir.actions.report.xml',
937
950
            'uid': uid,
938
951
            'user': user,
939
952
            'context': context,
940
 
            'workflow': workflow
 
953
            'workflow': workflow,
 
954
            'Warning': openerp.exceptions.Warning,
941
955
        }
942
956
 
943
957
    def run(self, cr, uid, ids, context=None):