Merge lp:~camptocamp/openobject-addons/7.0-fix-multi-comp-webkit-header into lp:openobject-addons/7.0

Proposed by Nicolas Bessi - Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/7.0-fix-multi-comp-webkit-header
Merge into: lp:openobject-addons/7.0
Diff against target: 51 lines (+17/-9)
1 file modified
report_webkit/report_helper.py (+17/-9)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/7.0-fix-multi-comp-webkit-header
Reviewer Review Type Date Requested Status
Csaba TOTH (community) technical Needs Fixing
Alexandre Fayolle - camptocamp (community) code review, no test Approve
OpenERP Core Team Pending
Review via email: mp+151696@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

I'll port the patch to OCB so that it gets easily available until merged upstream.

review: Approve (code review, no test)
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Ok thanks for the OCB port.

Revision history for this message
Csaba TOTH (tsabi) wrote :

I don't like this kind of domain filter for company_id!

Generally we use this domain restrictions in ir.rules:

['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]

But sometimes it is longer defined (look the "Product multi-company" ir.rule):

['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)]

The minimum what i miss, is the possiblity to get the records what is not bounded to any company even when i specify a company.

review: Needs Fixing (technical)
8798. By Yannick Vaucher @ Camptocamp on 2013-05-16

[IMP] report_webkit - raise an exception when the webkit report image is not found in webkit helpers

Unmerged revisions

8798. By Yannick Vaucher @ Camptocamp on 2013-05-16

[IMP] report_webkit - raise an exception when the webkit report image is not found in webkit helpers

8797. By Nicolas Bessi - Camptocamp on 2013-03-05

[FIX] report_webkit embed_logo_by_name multi-company support

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'report_webkit/report_helper.py'
2--- report_webkit/report_helper.py 2013-05-14 14:28:37 +0000
3+++ report_webkit/report_helper.py 2013-05-16 09:40:11 +0000
4@@ -30,6 +30,8 @@
5 ##############################################################################
6
7 from openerp import pooler
8+from openerp.osv import orm
9+from tools.translate import _
10
11 class WebKitHelper(object):
12 """Set of usefull report helper"""
13@@ -59,25 +61,31 @@
14 return toreturn
15
16
17- def get_logo_by_name(self, name):
18+ def get_logo_by_name(self, name, company_id=None):
19 """Return logo by name"""
20 header_obj = self.pool.get('ir.header_img')
21- header_img_id = header_obj.search(
22- self.cursor,
23- self.uid,
24- [('name','=',name)]
25- )
26+ domain = [('name','=',name)]
27+ if company_id:
28+ domain.append(('company_id', '=', company_id))
29+ header_img_id = header_obj.search(self.cursor,
30+ self.uid,
31+ domain)
32 if not header_img_id :
33- return u''
34+ msg = _("No header image named '%s' found.") % name
35+ if company_id:
36+ company_obj = self.pool.get('res.company')
37+ company = company_obj.browse(self.cursor, self.uid, company_id)
38+ msg = _("No header image named '%s' found for company %s.") % (name, company.name)
39+ raise orm.except_orm('Error', msg)
40 if isinstance(header_img_id, list):
41 header_img_id = header_img_id[0]
42
43 head = header_obj.browse(self.cursor, self.uid, header_img_id)
44 return (head.img, head.type)
45
46- def embed_logo_by_name(self, name, width=0, height=0):
47+ def embed_logo_by_name(self, name, width=0, height=0, company_id=None):
48 """Return HTML embedded logo by name"""
49- img, type = self.get_logo_by_name(name)
50+ img, type = self.get_logo_by_name(name, company_id=company_id)
51 return self.embed_image(type, img, width, height)
52
53