Merge lp:~openerp-dev/openobject-server/trunk-report-refactoring-sle into lp:openobject-server

Proposed by sle-openerp
Status: Merged
Merged at revision: 5147
Proposed branch: lp:~openerp-dev/openobject-server/trunk-report-refactoring-sle
Merge into: lp:openobject-server
Diff against target: 130 lines (+62/-7)
5 files modified
openerp/addons/base/__openerp__.py (+1/-0)
openerp/addons/base/ir/ir_actions.py (+4/-4)
openerp/addons/base/ir/ir_actions.xml (+4/-3)
openerp/addons/base/ir/ir_qweb.py (+32/-0)
openerp/addons/base/ir/ir_qweb.xml (+21/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-report-refactoring-sle
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+212455@code.launchpad.net
To post a comment you must log in.
5147. By sle-openerp

[IMP] ir.actions.report.xml form view: hide the attachmend fields when report_type controller is selected

5148. By sle-openerp

[MERGE] trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/addons/base/__openerp__.py'
2--- openerp/addons/base/__openerp__.py 2014-03-10 11:11:37 +0000
3+++ openerp/addons/base/__openerp__.py 2014-03-24 16:45:30 +0000
4@@ -58,6 +58,7 @@
5 'ir/osv_memory_autovacuum.xml',
6 'ir/ir_model_report.xml',
7 'ir/ir_logging_view.xml',
8+ 'ir/ir_qweb.xml',
9 'workflow/workflow_view.xml',
10 'module/module_view.xml',
11 'module/module_data.xml',
12
13=== modified file 'openerp/addons/base/ir/ir_actions.py'
14--- openerp/addons/base/ir/ir_actions.py 2014-03-07 01:13:05 +0000
15+++ openerp/addons/base/ir/ir_actions.py 2014-03-24 16:45:30 +0000
16@@ -141,12 +141,12 @@
17 'model': fields.char('Model', required=True),
18 'report_type': fields.selection([('qweb-pdf', 'PDF'),
19 ('qweb-html', 'HTML'),
20- ('other', 'Other'),
21+ ('controller', 'Controller'),
22 ('pdf', 'RML pdf (deprecated)'),
23 ('sxw', 'RML sxw (deprecated)'),
24 ('webkit', 'Webkit (deprecated)'),
25- ], '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."),
26- 'report_name': fields.char('Controller Name', required=True, help="URL of the report will be /report/<controller name>/<ids>, 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."),
27+ ], '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."),
28+ '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."),
29 'groups_id': fields.many2many('res.groups', 'res_groups_report_rel', 'uid', 'gid', 'Groups'),
30
31 # options
32@@ -163,7 +163,7 @@
33 'report_xsl': fields.char('XSL Path'),
34 'report_xml': fields.char('XML Path'),
35
36- '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"),
37+ '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"),
38 '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),
39
40 'report_sxw': fields.function(_report_sxw, type='char', string='SXW Path'),
41
42=== modified file 'openerp/addons/base/ir/ir_actions.xml'
43--- openerp/addons/base/ir/ir_actions.xml 2014-03-07 01:13:05 +0000
44+++ openerp/addons/base/ir/ir_actions.xml 2014-03-24 16:45:30 +0000
45@@ -59,12 +59,13 @@
46 <field name="name"/>
47 <field name="model"/>
48 <field name="report_type"/>
49- <field name="report_name"/>
50+ <field name="report_name" attrs="{'invisible':[('report_type','=', 'controller')]}"/>
51+ <field name="report_rml" attrs="{'invisible':[('report_type','!=', 'controller')]}"/>
52 </group>
53 <group>
54 <field name="multi"/>
55- <field name="attachment_use"/>
56- <field name="attachment"/>
57+ <field name="attachment_use" attrs="{'invisible':[('report_type','=', 'controller')]}"/>
58+ <field name="attachment" attrs="{'invisible':[('report_type','=', 'controller')]}"/>
59 </group>
60 </group>
61 <notebook>
62
63=== modified file 'openerp/addons/base/ir/ir_qweb.py'
64--- openerp/addons/base/ir/ir_qweb.py 2014-03-17 11:09:04 +0000
65+++ openerp/addons/base/ir/ir_qweb.py 2014-03-24 16:45:30 +0000
66@@ -808,6 +808,38 @@
67 return babel.dates.format_timedelta(
68 value - reference, add_direction=True, locale=locale)
69
70+
71+class Contact(orm.AbstractModel):
72+ _name = 'ir.qweb.field.contact'
73+ _inherit = 'ir.qweb.field.many2one'
74+
75+ def record_to_html(self, cr, uid, field_name, record, column, options=None, context=None):
76+ opf = options.get('fields') or ["name", "address", "phone", "mobile", "fax", "email"]
77+
78+ if not getattr(record, field_name):
79+ return None
80+
81+ id = getattr(record, field_name).id
82+ field_browse = self.pool[column._obj].browse(cr, openerp.SUPERUSER_ID, id, context={"show_address": True})
83+ value = werkzeug.utils.escape( field_browse.name_get()[0][1] )
84+
85+ val = {
86+ 'name': value.split("\n")[0],
87+ 'address': werkzeug.utils.escape("\n".join(value.split("\n")[1:])),
88+ 'phone': field_browse.phone,
89+ 'mobile': field_browse.mobile,
90+ 'fax': field_browse.fax,
91+ 'city': field_browse.city,
92+ 'country_id': field_browse.country_id and field_browse.country_id.name_get()[0][1],
93+ 'email': field_browse.email,
94+ 'fields': opf,
95+ 'options': options
96+ }
97+
98+ html = self.pool["ir.ui.view"].render(cr, uid, "base.contact", val, engine='ir.qweb', context=context).decode('utf8')
99+
100+ return HTMLSafe(html)
101+
102 class HTMLSafe(object):
103 """ HTMLSafe string wrapper, Werkzeug's escape() has special handling for
104 objects with a ``__html__`` methods but AFAIK does not provide any such
105
106=== added file 'openerp/addons/base/ir/ir_qweb.xml'
107--- openerp/addons/base/ir/ir_qweb.xml 1970-01-01 00:00:00 +0000
108+++ openerp/addons/base/ir/ir_qweb.xml 2014-03-24 16:45:30 +0000
109@@ -0,0 +1,21 @@
110+<openerp>
111+<data>
112+<template id="contact">
113+ <address t-ignore="true" class="mb0" itemscope="itemscope" itemtype="http://schema.org/Organization">
114+ <div t-att-class="'name' not in fields and 'css_non_editable_mode_hidden'"><span itemprop="name" t-esc="name"/></div>
115+ <div itemprop="address" itemscope="itemscope" itemtype="http://schema.org/PostalAddress">
116+ <div t-if="address and 'address' in fields" class='css_editable_mode_hidden'>
117+ <i t-if="not options.get('no_marker')" class='fa fa-map-marker'/> <span itemprop="streetAddress" t-raw="address.replace('\n', options.get('no_tag_br') and ', ' or ('&lt;br/&gt;%s' % ('' if options.get('no_marker') else '&amp;nbsp; &amp;nbsp; ')))"/>
118+ </div>
119+ <div t-if="city and 'city' in fields" class='css_editable_mode_hidden'>
120+ <i t-if="not options.get('no_marker')" class='fa fa-map-marker'/> <span itemprop="addressLocality" t-raw="city"/>, <span itemprop="addressCountry" t-raw="country_id"/>
121+ </div>
122+ <div t-if="phone and 'phone' in fields" class='css_editable_mode_hidden'><i t-if="not options.get('no_marker')" class='fa fa-phone'/> <span itemprop="telephone" t-esc="phone"/></div>
123+ <div t-if="mobile and 'mobile' in fields" class='css_editable_mode_hidden'><i t-if="not options.get('no_marker')" class='fa fa-mobile-phone'/> <span itemprop="telephone" t-esc="mobile"/></div>
124+ <div t-if="fax and 'fax' in fields" class='css_editable_mode_hidden'><i t-if="not options.get('no_marker')" class='fa fa-file-text-o'/> <span itemprop="faxNumber" t-esc="fax"/></div>
125+ <div t-if="email and 'email' in fields" class='css_editable_mode_hidden'><i t-if="not options.get('no_marker')" class='fa fa-envelope'/> <span itemprop="email" t-esc="email"/></div>
126+ </div>
127+ </address>
128+</template>
129+ </data>
130+</openerp>