Merge lp:~os-1/unifield-wm/US-266 into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 2524
Proposed branch: lp:~os-1/unifield-wm/US-266
Merge into: lp:unifield-wm
Diff against target: 679 lines (+630/-11)
6 files modified
account_override/account_invoice_report.xml (+29/-10)
account_override/report/__init__.py (+3/-1)
account_override/report/allocation_invoices_report.rml (+264/-0)
account_override/report/allocation_synthesis_invoices_xls.mako (+166/-0)
account_override/report/report_allocation_invoices.py (+81/-0)
account_override/report/report_allocation_synthesis_invoices.py (+87/-0)
To merge this branch: bzr merge lp:~os-1/unifield-wm/US-266
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+260551@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_override/account_invoice_report.xml'
--- account_override/account_invoice_report.xml 2013-11-28 20:42:06 +0000
+++ account_override/account_invoice_report.xml 2015-05-29 09:19:39 +0000
@@ -3,16 +3,35 @@
3 <data>3 <data>
44
5 <report id="open_invoices_2"5 <report id="open_invoices_2"
6 string="Open Invoices"6 string="Open Invoices"
7 model="account.invoice"7 model="account.invoice"
8 name="open.invoices.2"8 name="open.invoices.2"
9 target_filename="Open Invoices_${company_id.instance_id.code}_%(year)s%(month)s%(day)s"9 target_filename="Open Invoices_${company_id.instance_id.code}_%(year)s%(month)s%(day)s"
10 file="account_override/report/open_invoices_xls.mako"10 file="account_override/report/open_invoices_xls.mako"
11 report_type="webkit"11 report_type="webkit"
12 header="False"12 header="False"
13 auto="False"13 auto="False"
14 menu="True"/>14 menu="True"/>
1515
16 <report id="synthesis_invoices_report"
17 string="Allocation synthesis"
18 model="account.invoice"
19 name="allocation.synthesis.invoices"
20 target_filename="Allocation_synthesis_${company_id.instance_id.code}_%(year)s%(month)s%(day)s"
21 file="account_override/report/allocation_synthesis_invoices_xls.mako"
22 report_type="webkit"
23 header="False"
24 auto="False"
25 menu="True"/>
26
27 <report id="allocation_invoices_report"
28 model="account.invoice"
29 name="allocation.invoices.report"
30 target_filename="Allocation_report_${company_id.instance_id.code}_%(year)s%(month)s%(day)s"
31 rml="account_override/report/allocation_invoices_report.rml"
32 header="False"
33 auto="False"
34 string="Invoice allocation"/>
16 </data>35 </data>
17</openerp>36</openerp>
1837
1938
=== modified file 'account_override/report/__init__.py'
--- account_override/report/__init__.py 2014-03-19 13:40:41 +0000
+++ account_override/report/__init__.py 2015-05-29 09:19:39 +0000
@@ -1,3 +1,5 @@
1import account_chart_export1import account_chart_export
2import account_print_invoice2import account_print_invoice
3import report_open_invoices
4\ No newline at end of file3\ No newline at end of file
4import report_open_invoices
5import report_allocation_synthesis_invoices
6import report_allocation_invoices
57
=== added file 'account_override/report/allocation_invoices_report.rml'
--- account_override/report/allocation_invoices_report.rml 1970-01-01 00:00:00 +0000
+++ account_override/report/allocation_invoices_report.rml 2015-05-29 09:19:39 +0000
@@ -0,0 +1,264 @@
1<?xml version="1.0"?>
2<document filename="allocation_invoice_report.pdf">
3 <template pageSize="(842.0,595.0)" title="Test" author="Medecins Sans Frontieres" allowSplitting="20">
4 <pageTemplate id="first">
5 <frame id="first" x1="42.0" y1="57.0" width="750" height="530"/>
6 </pageTemplate>
7 </template>
8 <stylesheet>
9
10 <!-- TABLE STYLES -->
11 <blockTableStyle id="HeaderTable">
12 <blockAlignment value="CENTER" />
13 <blockValign value="MIDDLE" />
14 <lineStyle kind="OUTLINE" colorName="#000000" />
15 </blockTableStyle>
16
17 <blockTableStyle id="InformationTable">
18 <blockAlignment value="CENTER" />
19 <blockValign value="MIDDLE" />
20 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" />
21 <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="-1,0" />
22 <lineStyle kind="LINEBEFORE" colorName="#000000" />
23 <lineStyle kind="LINEAFTER" colorName="#000000" />
24 </blockTableStyle>
25
26 <blockTableStyle id="ProductList">
27 <blockValign value="MIDDLE" />
28 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" />
29 <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="-1,0" />
30 <lineStyle kind="LINEBEFORE" colorName="#0b0b0b" />
31 <lineStyle kind="LINEAFTER" colorName="#000000" />
32 </blockTableStyle>
33
34 <initialize>
35 <paraStyle name="all" alignment="justify"/>
36 </initialize>
37
38 <!-- PARAGRAPH STYLES -->
39 <paraStyle name="Standard" fontName="Helvetica"/>
40 <paraStyle name="Header" fontName="Helvetica-Bold" fontSize="15.0" leading="20" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0" />
41 <paraStyle name="InformationHeader" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" />
42 <paraStyle name="Information" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" />
43
44 </stylesheet>
45 <story>
46 <pto>
47 <para style="Standard">[[repeatIn(objects,'o')]]</para>
48 <!--<para style="Standard">[[ setLang(o.partner_id.lang) ]]</para>-->
49
50 <!-- HEADER TABLE OF THE PRINTED FILE -->
51 <blockTable colWidths="565" style="HeaderTable">
52 <tr>
53 <td>
54 <para style="Header">INVOICE LINES ALLOCATION REPORT</para>
55 </td>
56 </tr>
57 </blockTable>
58
59
60 <para style="Standard">
61 <font color="white"> </font>
62 </para>
63
64
65 <!-- GENERAL INFORMATION -->
66
67 <blockTable colWidths="162.0,162.0,162.0,162.0" style="InformationTable">
68 <tr>
69 <td>
70 <para style="InformationHeader">Invoice</para>
71 </td>
72 <td>
73 <para style="InformationHeader">Supplier</para>
74 </td>
75 <td>
76 <para style="InformationHeader">Type</para>
77 </td>
78 <td>
79 <para style="InformationHeader"></para>
80 </td>
81 </tr>
82
83 <tr>
84 <td>
85 <para style="Information">[[ o.number ]]</para>
86 </td>
87 <td>
88 <para style="Information">[[ o.partner_id.name ]]</para>
89 </td>
90 <td>
91 <para style="Information">[[ getSel(o, 'type') ]]</para>
92 </td>
93 <td>
94 <para style="Information"></para>
95 </td>
96 </tr>
97 </blockTable>
98
99 <blockTable colWidths="162.0,162.0,162.0,162.0" style="InformationTable">
100 <tr>
101 <td>
102 <para style="InformationHeader">Creation date</para>
103 </td>
104 <td>
105 <para style="InformationHeader">Creator</para>
106 </td>
107 <td>
108 <para style="InformationHeader">State</para>
109 </td>
110 <td>
111 <para style="InformationHeader">Currency</para>
112 </td>
113 </tr>
114
115 <tr>
116 <td>
117 <para style="Information">[[ formatLang(o.date_invoice, date=True) ]]</para>
118 </td>
119 <td>
120 <para style="Information">[[ o.user_id.name ]]</para>
121 </td>
122 <td>
123 <para style="Information">[[ getSel(o, 'state') ]]</para>
124 </td>
125 <td>
126 <para style="Information">[[ o.currency_id.name ]]</para>
127 </td>
128 </tr>
129 </blockTable>
130
131
132 <para style="Standard">
133 <font color="white"> </font>
134 </para>
135
136
137 <!-- LINES LIST -->
138 <blockTable colWidths="33.0,100.0,100.0,80.0,50.0,50.0,50.0,50.0,60.0,60.0,60.0" style="ProductList">
139 <tr>
140 <td>
141 <para style="InformationHeader">Line</para>
142 </td>
143 <td>
144 <para style="InformationHeader">Product</para>
145 </td>
146 <td>
147 <para style="InformationHeader">Description</para>
148 </td>
149 <td>
150 <para style="InformationHeader">Account</para>
151 </td>
152 <td>
153 <para style="InformationHeader">Qty</para>
154 </td>
155 <td>
156 <para style="InformationHeader">Unit Price</para>
157 </td>
158 <td>
159 <para style="InformationHeader">%</para>
160 </td>
161 <td>
162 <para style="InformationHeader">Subtotal</para>
163 </td>
164 <td>
165 <para style="InformationHeader">Destination</para>
166 </td>
167
168 <td>
169 <para style="InformationHeader">Cost Center</para>
170 </td>
171 <td>
172 <para style="InformationHeader">Funding Pool</para>
173 </td>
174 </tr>
175 </blockTable>
176 <pto_header>
177 <blockTable colWidths="33.0,100.0,100.0,80.0,50.0,50.0,50.0,50.0,60.0,60.0,60.0" style="ProductList">
178 <tr>
179 <td>
180 <para style="InformationHeader">Line</para>
181 </td>
182 <td>
183 <para style="InformationHeader">Product</para>
184 </td>
185 <td>
186 <para style="InformationHeader">Description</para>
187 </td>
188 <td>
189 <para style="InformationHeader">Account</para>
190 </td>
191 <td>
192 <para style="InformationHeader">Qty</para>
193 </td>
194 <td>
195 <para style="InformationHeader">Unit Price</para>
196 </td>
197 <td>
198 <para style="InformationHeader">%</para>
199 </td>
200 <td>
201 <para style="InformationHeader">Subtotal</para>
202 </td>
203
204 <td>
205 <para style="InformationHeader">Destination</para>
206 </td>
207
208 <td>
209 <para style="InformationHeader">Cost Center</para>
210 </td>
211 <td>
212 <para style="InformationHeader">Funding Pool</para>
213 </td>
214 </tr>
215 </blockTable>
216 </pto_header>
217
218 <section>
219 [[ repeatIn(get_data(o.id), 'line') ]]
220 <blockTable colWidths="33.0,100.0,100.0,80.0,50.0,50.0,50.0,50.0,60.0,60.0,60.0" style="ProductList">
221 <tr>
222 <td>
223 <para style="Information">[[ line[0] ]]</para>
224 </td>
225 <td>
226 <para style="Information">[[ line[1] ]]</para>
227 </td>
228 <td>
229 <para style="Information">[[ line[2] ]]</para>
230 </td>
231 <td>
232 <para style="Information">[[ line[3] ]]</para>
233 </td>
234 <td>
235 <para style="Information">[[ formatLang(line[4]) ]]</para>
236 </td>
237 <td>
238 <para style="Information">[[ formatLang(line[5]) ]]</para>
239 </td>
240 <td>
241 <para style="Information">[[ formatLang(line[6]) ]]</para>
242 </td>
243 <td>
244 <para style="Information">[[ formatLang(line[7]) ]]</para>
245 </td>
246 <td>
247 <para style="Information">[[ line[9] ]]</para>
248 </td>
249 <td>
250 <para style="Information">[[ line[10] ]]</para>
251 </td>
252 <td>
253 <para style="Information">[[ line[11] ]]</para>
254 </td>
255 </tr>
256 </blockTable>
257 </section>
258
259 <para style="Standard">
260 <font color="white"> </font>
261 </para>
262 </pto>
263 </story>
264</document>
0265
=== added file 'account_override/report/allocation_synthesis_invoices_xls.mako'
--- account_override/report/allocation_synthesis_invoices_xls.mako 1970-01-01 00:00:00 +0000
+++ account_override/report/allocation_synthesis_invoices_xls.mako 2015-05-29 09:19:39 +0000
@@ -0,0 +1,166 @@
1<?xml version="1.0"?>
2<?mso-application progid="Excel.Sheet"?>
3<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
4 xmlns:o="urn:schemas-microsoft-com:office:office"
5 xmlns:x="urn:schemas-microsoft-com:office:excel"
6 xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
7 xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
8 xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"
9 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
10 xmlns:html="http://www.w3.org/TR/REC-html40">
11 <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
12 <Author>Tempo Consulting</Author>
13 <LastAuthor>Tempo Consulting</LastAuthor>
14 <Created>2015-05-19T15:32:58Z</Created>
15 <Version>14.00</Version>
16 </DocumentProperties>
17 <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
18 <AllowPNG/>
19 </OfficeDocumentSettings>
20 <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
21 <WindowHeight>7995</WindowHeight>
22 <WindowWidth>20115</WindowWidth>
23 <WindowTopX>240</WindowTopX>
24 <WindowTopY>75</WindowTopY>
25 <ProtectStructure>False</ProtectStructure>
26 <ProtectWindows>False</ProtectWindows>
27 </ExcelWorkbook>
28 <Styles>
29 <Style ss:ID="Default" ss:Name="Normal">
30 <Alignment ss:Vertical="Bottom"/>
31 <Borders/>
32 <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
33 <Interior/>
34 <NumberFormat/>
35 <Protection/>
36 </Style>
37 <Style ss:ID="s63">
38 <NumberFormat ss:Format="Standard"/>
39 </Style>
40 <Style ss:ID="s66">
41 <Alignment ss:Horizontal="Left" ss:Vertical="Bottom" ss:Indent="1"/>
42 </Style>
43 <Style ss:ID="s67">
44 <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
45 ss:Bold="1"/>
46 <NumberFormat ss:Format="Standard"/>
47 </Style>
48 <Style ss:ID="s69">
49 <Alignment ss:Horizontal="Left" ss:Vertical="Bottom" ss:Indent="1"/>
50 <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
51 ss:Bold="1"/>
52 </Style>
53 <Style ss:ID="s74">
54 <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
55 ss:Bold="1"/>
56 <Interior ss:Color="#DCE6F1" ss:Pattern="Solid"/>
57 </Style>
58 <Style ss:ID="s75">
59 <Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>
60 <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
61 ss:Bold="1"/>
62 <Interior ss:Color="#DCE6F1" ss:Pattern="Solid"/>
63 </Style>
64 <Style ss:ID="s76">
65 <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
66 ss:Bold="1"/>
67 <Interior ss:Color="#DCE6F1" ss:Pattern="Solid"/>
68 <NumberFormat ss:Format="Standard"/>
69 </Style>
70 <Style ss:ID="s98">
71 <Borders/>
72 </Style>
73 <Style ss:ID="s99">
74 <Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>
75 <Borders>
76 <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"
77 ss:Color="#8DB4E2"/>
78 </Borders>
79 <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
80 ss:Bold="1"/>
81 </Style>
82 <Style ss:ID="s100">
83 <Borders>
84 <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"
85 ss:Color="#8DB4E2"/>
86 </Borders>
87 <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
88 ss:Bold="1"/>
89 <NumberFormat ss:Format="Standard"/>
90 </Style>
91 </Styles>
92 % for o in objects:
93 <Worksheet ss:Name="${(o.number or title(o)+' '+str(o.id))|x}">
94 <Table x:FullColumns="1"
95 x:FullRows="1" ss:DefaultColumnWidth="90" ss:DefaultRowHeight="15">
96 <Column ss:AutoFitWidth="0" ss:Width="110.25"/>
97 <Column ss:AutoFitWidth="0" ss:Width="95.25"/>
98 <Column ss:AutoFitWidth="0" ss:Width="69.75"/>
99 <Column ss:Width="121.5"/>
100 <Column ss:Width="96"/>
101 <Row ss:AutoFitHeight="0">
102 <Cell><Data ss:Type="String">Invoice :</Data></Cell>
103 <Cell><Data ss:Type="String">${(o.number or ' ')|x}</Data></Cell>
104 </Row>
105 <Row ss:AutoFitHeight="0">
106 <Cell><Data ss:Type="String">Type :</Data></Cell>
107 <Cell><Data ss:Type="String">${(title(o))|x}</Data></Cell>
108 </Row>
109 <Row ss:AutoFitHeight="0">
110 <Cell><Data ss:Type="String">Supplier :</Data></Cell>
111 <Cell><Data ss:Type="String">${(o.partner_id.name)|x}</Data></Cell>
112 </Row>
113 <Row ss:AutoFitHeight="0">
114 <Cell><Data ss:Type="String">Posting date :</Data></Cell>
115 <Cell><Data ss:Type="String">${(o.date_invoice or ' ')|x}</Data></Cell>
116 </Row>
117 <Row ss:AutoFitHeight="0">
118 <Cell><Data ss:Type="String">Currency :</Data></Cell>
119 <Cell><Data ss:Type="String">${(o.currency_id.name)|x}</Data></Cell>
120 </Row>
121 <Row ss:AutoFitHeight="0"/>
122 <Row ss:AutoFitHeight="0">
123 <Cell ss:StyleID="s74"><Data ss:Type="String">Row labels</Data></Cell>
124 <Cell ss:StyleID="s74"><Data ss:Type="String">Sum of Amount</Data></Cell>
125 </Row>
126 % for row in get_data(o.id):
127 % if level(row) == 1:
128 <Row ss:AutoFitHeight="0">
129 <Cell ss:StyleID="s99"><Data ss:Type="String">${(row[0])|x}</Data></Cell>
130 <Cell ss:StyleID="s100"><Data ss:Type="Number">${(row[2])|x}</Data></Cell>
131 </Row>
132 % endif
133 % if level(row) == 2:
134 <Row ss:AutoFitHeight="0">
135 <Cell ss:StyleID="s66"><Data ss:Type="String">${(row[1])|x}</Data></Cell>
136 <Cell ss:StyleID="s63"><Data ss:Type="Number">${(row[2])|x}</Data></Cell>
137 </Row>
138 % endif
139 % if level(row) == -1:
140 <Row ss:AutoFitHeight="0">
141 <Cell ss:StyleID="s75"><Data ss:Type="String">Grand Total</Data></Cell>
142 <Cell ss:StyleID="s76"><Data ss:Type="Number">${(row[2])|x}</Data></Cell>
143 </Row>
144 % endif
145 % endfor
146 </Table>
147 <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
148 <PageSetup>
149 <Header x:Margin="0.3"/>
150 <Footer x:Margin="0.3"/>
151 <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
152 </PageSetup>
153 <Unsynced/>
154 <Print>
155 <ValidPrinterInfo/>
156 <PaperSizeIndex>9</PaperSizeIndex>
157 <HorizontalResolution>600</HorizontalResolution>
158 <VerticalResolution>600</VerticalResolution>
159 </Print>
160 <Selected/>
161 <ProtectObjects>False</ProtectObjects>
162 <ProtectScenarios>False</ProtectScenarios>
163 </WorksheetOptions>
164 </Worksheet>
165 % endfor
166</Workbook>
0167
=== added file 'account_override/report/report_allocation_invoices.py'
--- account_override/report/report_allocation_invoices.py 1970-01-01 00:00:00 +0000
+++ account_override/report/report_allocation_invoices.py 2015-05-29 09:19:39 +0000
@@ -0,0 +1,81 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import time
23
24from report import report_sxw
25
26
27class allocation_invoice_report(report_sxw.rml_parse):
28 def __init__(self, cr, uid, name, context=None):
29 super(allocation_invoice_report, self).__init__(cr, uid, name, context=context)
30
31 self._cr = cr
32
33 self.localcontext.update({
34 'time': time,
35 'get_data': self.get_data,
36 })
37
38 def get_data(self, invoice_id):
39 self._cr.execute("""SELECT line_number,NULLIF('[' || default_code || '] ' || name_template, '[] ') as product,i.name as description, ac.code || ' ' || ac.name as account, quantity, ROUND(price_unit, 2) as price_unit, ROUND(percentage, 2) as percentage, ROUND(price_subtotal*percentage/100, 2) as sub_total, y.name as currency, n1.code as destination, n2.code as cost_center, n3.code as funding_pool
40 FROM funding_pool_distribution_line a
41 INNER JOIN account_invoice_line i ON a.distribution_id = i.analytic_distribution_id
42 INNER JOIN account_invoice s ON s.id = i.invoice_id
43 INNER JOIN account_analytic_account n1 ON n1.id = a.destination_id
44 INNER JOIN account_analytic_account n2 ON n2.id = a.cost_center_id
45 INNER JOIN account_analytic_account n3 ON n3.id = a.analytic_id
46 INNER JOIN account_account ac ON ac.id = i.account_id
47 LEFT JOIN product_product p ON p.id = i.product_id
48 LEFT JOIN res_currency y ON y.id = s.currency_id
49 WHERE i.invoice_id=%s
50 UNION ALL
51 SELECT line_number,NULLIF('[' || default_code || '] ' || name_template, '[] ') as product,i.name as description, ac.code || ' ' || ac.name as account, quantity, ROUND(price_unit, 2) as price_unit, ROUND(percentage, 2) as percentage, ROUND(price_subtotal*percentage/100, 2) as sub_total, y.name as currency, n1.code as destination, n2.code as cost_center, n3.code as funding_pool
52 FROM funding_pool_distribution_line a
53 INNER JOIN account_invoice s ON s.analytic_distribution_id = a.distribution_id
54 LEFT JOIN account_invoice_line i ON i.invoice_id = s.id AND i.analytic_distribution_id IS NULL
55 INNER JOIN account_account ac ON ac.id = i.account_id
56 INNER JOIN account_analytic_account n1 ON n1.id = a.destination_id
57 INNER JOIN account_analytic_account n2 ON n2.id = a.cost_center_id
58 INNER JOIN account_analytic_account n3 ON n3.id = a.analytic_id
59 INNER JOIN res_currency y ON y.id = s.currency_id
60 LEFT JOIN product_product p ON p.id = i.product_id
61 WHERE s.id=%s
62 UNION ALL
63 SELECT line_number,NULLIF('[' || default_code || '] ' || name_template, '[] ') as product,i.name as description, ac.code || ac.name as account, quantity, ROUND(price_unit, 2) as price_unit, NULL, ROUND(price_subtotal, 2) as sub_total, y.name as currency, NULL, NULL, NULL
64 FROM account_invoice_line i
65 INNER JOIN account_invoice s ON s.id = i.invoice_id
66 INNER JOIN account_account ac ON ac.id = i.account_id
67 INNER JOIN res_currency y ON y.id = s.currency_id
68 LEFT JOIN product_product p ON p.id = i.product_id
69 WHERE s.id=%s and is_analytic_addicted = False
70 ORDER BY line_number, destination, cost_center, funding_pool
71 """, (invoice_id, invoice_id, invoice_id))
72
73 return self._cr.fetchall()
74
75
76report_sxw.report_sxw('report.allocation.invoices.report',
77 'account.invoice',
78 'addons/account_override/report/allocation_invoices_report.rml',
79 parser=allocation_invoice_report, header="landscape")
80
81# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
082
=== added file 'account_override/report/report_allocation_synthesis_invoices.py'
--- account_override/report/report_allocation_synthesis_invoices.py 1970-01-01 00:00:00 +0000
+++ account_override/report/report_allocation_synthesis_invoices.py 2015-05-29 09:19:39 +0000
@@ -0,0 +1,87 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2015 MSF, TeMPO Consulting
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as
8# published by the Free Software Foundation, either version 3 of the
9# License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21from spreadsheet_xml.spreadsheet_xml_write import SpreadsheetReport
22from report import report_sxw
23
24
25class report_allocation_synthesis_invoices(report_sxw.rml_parse):
26 def __init__(self, cr, uid, name, context=None):
27 super(report_allocation_synthesis_invoices, self).__init__(cr, uid, name, context=context)
28
29 self._cr = cr
30
31 self.localcontext.update({
32 'title': self.get_title,
33 'get_data': self.get_data,
34 'level': self.get_level,
35 })
36
37 def get_data(self, invoice_id):
38 self._cr.execute(""" WITH t as (
39 SELECT ac.code as L1, n2.code as L2,
40 ROUND(SUM(price_subtotal*percentage/100), 2) as amount
41 FROM funding_pool_distribution_line a
42 INNER JOIN account_invoice_line i ON a.distribution_id = i.analytic_distribution_id
43 INNER JOIN account_analytic_account n2 ON n2.id = a.cost_center_id
44 INNER JOIN account_account ac ON ac.id = i.account_id
45 WHERE i.invoice_id=%s
46 GROUP BY ac.code, n2.code
47 UNION ALL
48 SELECT ac.code, n2.code, ROUND(SUM(price_subtotal*percentage/100), 2)
49 FROM funding_pool_distribution_line a
50 INNER JOIN account_invoice s ON s.analytic_distribution_id = a.distribution_id
51 LEFT JOIN account_invoice_line i ON i.invoice_id = s.id AND i.analytic_distribution_id IS NULL
52 INNER JOIN account_account ac ON ac.id = i.account_id
53 INNER JOIN account_analytic_account n2 ON n2.id = a.cost_center_id
54 WHERE s.id=%s
55 GROUP BY ac.code, n2.code)
56 SELECT L1, L2, SUM(amount) as amount FROM t
57 GROUP BY L1, L2
58 UNION ALL
59 SELECT L1, '', SUM(amount) FROM t
60 GROUP BY L1
61 UNION ALL
62 SELECT NULL, '', SUM(amount) FROM t
63 ORDER BY L1, L2""", (invoice_id, invoice_id))
64
65 return self._cr.fetchall()
66
67 def get_level(self, row):
68 if row[0] is None:
69 return -1
70 elif row[1] == '':
71 return 1
72 else:
73 return 2
74
75 def get_title(self, invoice):
76
77 invoice_types = {
78 'out_invoice': 'Customer Invoice',
79 'in_invoice': 'Supplier Invoice',
80 'out_refund': 'Customer Refund',
81 'in_refund': 'Supplier Refund'
82 }
83
84 return invoice_types[invoice.type]
85
86
87SpreadsheetReport('report.allocation.synthesis.invoices', 'account.invoice', 'addons/account_override/report/allocation_synthesis_invoices_xls.mako', parser=report_allocation_synthesis_invoices)

Subscribers

People subscribed via source and target branches