Merge lp:~luc-demeyer/account-financial-report/7.0-account_journal_report_xls-namespace-extra into lp:~account-report-core-editor/account-financial-report/7.0

Proposed by Luc De Meyer (Noviat)
Status: Needs review
Proposed branch: lp:~luc-demeyer/account-financial-report/7.0-account_journal_report_xls-namespace-extra
Merge into: lp:~account-report-core-editor/account-financial-report/7.0
Diff against target: 137 lines (+26/-11)
4 files modified
account_journal_report_xls/__openerp__.py (+1/-1)
account_journal_report_xls/account_journal.py (+15/-4)
account_journal_report_xls/report/__init__.py (+3/-3)
account_journal_report_xls/report/nov_account_journal_xls.py (+7/-3)
To merge this branch: bzr merge lp:~luc-demeyer/account-financial-report/7.0-account_journal_report_xls-namespace-extra
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Alexandre Fayolle - camptocamp code review, no tests Needs Information
Review via email: mp+220527@code.launchpad.net

Description of the change

add possibility to extend namespace for use in xls template via inherited module.

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

I find your naming very confusing. Could you clarify what is "space" and what is "namespace" here?

review: Needs Information (code review, no tests)
Revision history for this message
Luc De Meyer (Noviat) (luc-demeyer) wrote :

Namespace means python namespace.
Luc

www.noviat.com
Rusatiralaan 1, 1083 Brussel
+32 2 808 86 38

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Alexandre Fayolle - camptocamp
Sent: donderdag 26 juni 2014 16:21
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-report/7.0-account_journal_report_xls-namespace-extra into lp:account-financial-report

Review: Needs Information code review, no tests

I find your naming very confusing. Could you clarify what is "space" and what is "namespace" here?
--
https://code.launchpad.net/~luc-demeyer/account-financial-report/7.0-account_journal_report_xls-namespace-extra/+merge/220527
You are the owner of lp:~luc-demeyer/account-financial-report/7.0-account_journal_report_xls-namespace-extra.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :
review: Needs Resubmitting

Unmerged revisions

91. By Luc De Meyer

update account_journal_report_xls

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_journal_report_xls/__openerp__.py'
2--- account_journal_report_xls/__openerp__.py 2014-02-21 16:43:10 +0000
3+++ account_journal_report_xls/__openerp__.py 2014-05-21 20:48:21 +0000
4@@ -22,7 +22,7 @@
5
6 {
7 'name': 'Financial Journal reports',
8- 'version': '0.2',
9+ 'version': '0.3',
10 'license': 'AGPL-3',
11 'author': 'Noviat',
12 'category': 'Accounting & Finance',
13
14=== modified file 'account_journal_report_xls/account_journal.py'
15--- account_journal_report_xls/account_journal.py 2014-01-19 18:16:42 +0000
16+++ account_journal_report_xls/account_journal.py 2014-05-21 20:48:21 +0000
17@@ -3,7 +3,7 @@
18 #
19 # OpenERP, Open Source Management Solution
20 #
21-# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
22+# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
23 #
24 # This program is free software: you can redistribute it and/or modify
25 # it under the terms of the GNU Affero General Public License as
26@@ -12,11 +12,11 @@
27 #
28 # This program is distributed in the hope that it will be useful,
29 # but WITHOUT ANY WARRANTY; without even the implied warranty of
30-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 # GNU Affero General Public License for more details.
33 #
34 # You should have received a copy of the GNU Affero General Public License
35-# along with this program. If not, see <http://www.gnu.org/licenses/>.
36+# along with this program. If not, see <http://www.gnu.org/licenses/>.
37 #
38 ##############################################################################
39
40@@ -36,9 +36,20 @@
41 return (select_extra, join_extra, where_extra)
42
43 # allow inherited modules to add document references
44- def _report_xls_document_extra(self, cr, uid, context):
45+ def _report_xls_document_extra(self, cr, uid, context=None):
46 return "''"
47
48+ # allow inherited modules to extend the render namespace
49+ def _report_xls_render_space_extra(self, cr, uid, context=None):
50+ """
51+ extend render namespace for use in the template 'lines', e.g.
52+ space_extra = {
53+ 'partner_obj': self.pool.get('res.partner'),
54+ }
55+ return space_extra
56+ """
57+ return None
58+
59 # override list in inherited module to add/drop columns or change order
60 def _report_xls_fields(self, cr, uid, context=None):
61 res = [
62
63=== modified file 'account_journal_report_xls/report/__init__.py'
64--- account_journal_report_xls/report/__init__.py 2013-12-19 17:08:40 +0000
65+++ account_journal_report_xls/report/__init__.py 2014-05-21 20:48:21 +0000
66@@ -3,7 +3,7 @@
67 #
68 # OpenERP, Open Source Management Solution
69 #
70-# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
71+# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
72 #
73 # This program is free software: you can redistribute it and/or modify
74 # it under the terms of the GNU Affero General Public License as
75@@ -12,11 +12,11 @@
76 #
77 # This program is distributed in the hope that it will be useful,
78 # but WITHOUT ANY WARRANTY; without even the implied warranty of
79-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81 # GNU Affero General Public License for more details.
82 #
83 # You should have received a copy of the GNU Affero General Public License
84-# along with this program. If not, see <http://www.gnu.org/licenses/>.
85+# along with this program. If not, see <http://www.gnu.org/licenses/>.
86 #
87 ##############################################################################
88
89
90=== modified file 'account_journal_report_xls/report/nov_account_journal_xls.py'
91--- account_journal_report_xls/report/nov_account_journal_xls.py 2014-01-19 18:16:42 +0000
92+++ account_journal_report_xls/report/nov_account_journal_xls.py 2014-05-21 20:48:21 +0000
93@@ -3,7 +3,7 @@
94 #
95 # OpenERP, Open Source Management Solution
96 #
97-# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
98+# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
99 #
100 # This program is free software: you can redistribute it and/or modify
101 # it under the terms of the GNU Affero General Public License as
102@@ -12,11 +12,11 @@
103 #
104 # This program is distributed in the hope that it will be useful,
105 # but WITHOUT ANY WARRANTY; without even the implied warranty of
106-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
107+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108 # GNU Affero General Public License for more details.
109 #
110 # You should have received a copy of the GNU Affero General Public License
111-# along with this program. If not, see <http://www.gnu.org/licenses/>.
112+# along with this program. If not, see <http://www.gnu.org/licenses/>.
113 #
114 ##############################################################################
115
116@@ -41,10 +41,12 @@
117 self.context = context
118 wanted_list = journal_obj._report_xls_fields(cr, uid, context)
119 template_changes = journal_obj._report_xls_template(cr, uid, context)
120+ space_extra = journal_obj._report_xls_render_space_extra(cr, uid, context)
121 self.localcontext.update({
122 'datetime': datetime,
123 'wanted_list': wanted_list,
124 'template_changes': template_changes,
125+ 'space_extra': space_extra,
126 })
127
128
129@@ -210,6 +212,8 @@
130
131 def _journal_lines(self, o, ws, _p, row_pos, xlwt, _xs):
132
133+ if _p.space_extra:
134+ locals().update(_p.space_extra)
135 wanted_list = self.wanted_list
136 debit_pos = self.debit_pos
137 credit_pos = self.credit_pos