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

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

Unmerged revisions

8798. By Yannick Vaucher @ Camptocamp

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

8797. By Nicolas Bessi - Camptocamp

[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
=== modified file 'report_webkit/report_helper.py'
--- report_webkit/report_helper.py 2013-05-14 14:28:37 +0000
+++ report_webkit/report_helper.py 2013-05-16 09:40:11 +0000
@@ -30,6 +30,8 @@
30##############################################################################30##############################################################################
3131
32from openerp import pooler32from openerp import pooler
33from openerp.osv import orm
34from tools.translate import _
3335
34class WebKitHelper(object):36class WebKitHelper(object):
35 """Set of usefull report helper"""37 """Set of usefull report helper"""
@@ -59,25 +61,31 @@
59 return toreturn61 return toreturn
60 62
61 63
62 def get_logo_by_name(self, name):64 def get_logo_by_name(self, name, company_id=None):
63 """Return logo by name"""65 """Return logo by name"""
64 header_obj = self.pool.get('ir.header_img')66 header_obj = self.pool.get('ir.header_img')
65 header_img_id = header_obj.search(67 domain = [('name','=',name)]
66 self.cursor, 68 if company_id:
67 self.uid, 69 domain.append(('company_id', '=', company_id))
68 [('name','=',name)]70 header_img_id = header_obj.search(self.cursor,
69 )71 self.uid,
72 domain)
70 if not header_img_id :73 if not header_img_id :
71 return u''74 msg = _("No header image named '%s' found.") % name
75 if company_id:
76 company_obj = self.pool.get('res.company')
77 company = company_obj.browse(self.cursor, self.uid, company_id)
78 msg = _("No header image named '%s' found for company %s.") % (name, company.name)
79 raise orm.except_orm('Error', msg)
72 if isinstance(header_img_id, list):80 if isinstance(header_img_id, list):
73 header_img_id = header_img_id[0]81 header_img_id = header_img_id[0]
7482
75 head = header_obj.browse(self.cursor, self.uid, header_img_id)83 head = header_obj.browse(self.cursor, self.uid, header_img_id)
76 return (head.img, head.type)84 return (head.img, head.type)
77 85
78 def embed_logo_by_name(self, name, width=0, height=0):86 def embed_logo_by_name(self, name, width=0, height=0, company_id=None):
79 """Return HTML embedded logo by name"""87 """Return HTML embedded logo by name"""
80 img, type = self.get_logo_by_name(name)88 img, type = self.get_logo_by_name(name, company_id=company_id)
81 return self.embed_image(type, img, width, height)89 return self.embed_image(type, img, width, height)
82 90
8391