diff --git a/openerp/addons/base/__openerp__.py b/openerp/addons/base/__openerp__.py index 57ce6b31e32..3d0d3e4dda4 100644 --- a/openerp/addons/base/__openerp__.py +++ b/openerp/addons/base/__openerp__.py @@ -58,6 +58,7 @@ The kernel of OpenERP, needed for all installation. 'ir/osv_memory_autovacuum.xml', 'ir/ir_model_report.xml', 'ir/ir_logging_view.xml', + 'ir/ir_qweb.xml', 'workflow/workflow_view.xml', 'module/module_view.xml', 'module/module_data.xml', diff --git a/openerp/addons/base/ir/ir_actions.py b/openerp/addons/base/ir/ir_actions.py index 7b0681fd661..4cd0492d95c 100644 --- a/openerp/addons/base/ir/ir_actions.py +++ b/openerp/addons/base/ir/ir_actions.py @@ -141,12 +141,12 @@ class ir_actions_report_xml(osv.osv): 'model': fields.char('Model', required=True), 'report_type': fields.selection([('qweb-pdf', 'PDF'), ('qweb-html', 'HTML'), - ('other', 'Other'), + ('controller', 'Controller'), ('pdf', 'RML pdf (deprecated)'), ('sxw', 'RML sxw (deprecated)'), ('webkit', 'Webkit (deprecated)'), - ], 'Report Type', required=True, help="PDF will use wkhtmltopdf to render html to pdf, HTML will directly show html, Other will force download the controller output keeping the MIME type."), - 'report_name': fields.char('Controller Name', required=True, help="URL of the report will be /report//, the default controller also use this field to get the name of the qweb ir.ui.view to render. For RML reports, this is the LocalService name."), + ], '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."), + '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."), 'groups_id': fields.many2many('res.groups', 'res_groups_report_rel', 'uid', 'gid', 'Groups'), # options @@ -163,7 +163,7 @@ class ir_actions_report_xml(osv.osv): 'report_xsl': fields.char('XSL Path'), 'report_xml': fields.char('XML Path'), - 'report_rml': fields.char('Main Report File Path', help="The path to the main report file (depending on Report Type) or NULL if the content is in another data field"), + '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"), '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), 'report_sxw': fields.function(_report_sxw, type='char', string='SXW Path'), diff --git a/openerp/addons/base/ir/ir_actions.xml b/openerp/addons/base/ir/ir_actions.xml index 77d7eb23e8c..4eb869daa80 100644 --- a/openerp/addons/base/ir/ir_actions.xml +++ b/openerp/addons/base/ir/ir_actions.xml @@ -59,12 +59,13 @@ - + + - - + + diff --git a/openerp/addons/base/ir/ir_qweb.py b/openerp/addons/base/ir/ir_qweb.py index 0b3bf91dc1f..f19a1fa6746 100644 --- a/openerp/addons/base/ir/ir_qweb.py +++ b/openerp/addons/base/ir/ir_qweb.py @@ -808,6 +808,38 @@ class RelativeDatetimeConverter(osv.AbstractModel): return babel.dates.format_timedelta( value - reference, add_direction=True, locale=locale) + +class Contact(orm.AbstractModel): + _name = 'ir.qweb.field.contact' + _inherit = 'ir.qweb.field.many2one' + + def record_to_html(self, cr, uid, field_name, record, column, options=None, context=None): + opf = options.get('fields') or ["name", "address", "phone", "mobile", "fax", "email"] + + if not getattr(record, field_name): + return None + + id = getattr(record, field_name).id + field_browse = self.pool[column._obj].browse(cr, openerp.SUPERUSER_ID, id, context={"show_address": True}) + value = werkzeug.utils.escape( field_browse.name_get()[0][1] ) + + val = { + 'name': value.split("\n")[0], + 'address': werkzeug.utils.escape("\n".join(value.split("\n")[1:])), + 'phone': field_browse.phone, + 'mobile': field_browse.mobile, + 'fax': field_browse.fax, + 'city': field_browse.city, + 'country_id': field_browse.country_id and field_browse.country_id.name_get()[0][1], + 'email': field_browse.email, + 'fields': opf, + 'options': options + } + + html = self.pool["ir.ui.view"].render(cr, uid, "base.contact", val, engine='ir.qweb', context=context).decode('utf8') + + return HTMLSafe(html) + class HTMLSafe(object): """ HTMLSafe string wrapper, Werkzeug's escape() has special handling for objects with a ``__html__`` methods but AFAIK does not provide any such diff --git a/openerp/addons/base/ir/ir_qweb.xml b/openerp/addons/base/ir/ir_qweb.xml new file mode 100644 index 00000000000..25bb4ef8ef9 --- /dev/null +++ b/openerp/addons/base/ir/ir_qweb.xml @@ -0,0 +1,21 @@ + + + + +