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
1=== modified file 'account_override/account_invoice_report.xml'
2--- account_override/account_invoice_report.xml 2013-11-28 20:42:06 +0000
3+++ account_override/account_invoice_report.xml 2015-05-29 09:19:39 +0000
4@@ -3,16 +3,35 @@
5 <data>
6
7 <report id="open_invoices_2"
8- string="Open Invoices"
9- model="account.invoice"
10- name="open.invoices.2"
11- target_filename="Open Invoices_${company_id.instance_id.code}_%(year)s%(month)s%(day)s"
12- file="account_override/report/open_invoices_xls.mako"
13- report_type="webkit"
14- header="False"
15- auto="False"
16- menu="True"/>
17-
18+ string="Open Invoices"
19+ model="account.invoice"
20+ name="open.invoices.2"
21+ target_filename="Open Invoices_${company_id.instance_id.code}_%(year)s%(month)s%(day)s"
22+ file="account_override/report/open_invoices_xls.mako"
23+ report_type="webkit"
24+ header="False"
25+ auto="False"
26+ menu="True"/>
27+
28+ <report id="synthesis_invoices_report"
29+ string="Allocation synthesis"
30+ model="account.invoice"
31+ name="allocation.synthesis.invoices"
32+ target_filename="Allocation_synthesis_${company_id.instance_id.code}_%(year)s%(month)s%(day)s"
33+ file="account_override/report/allocation_synthesis_invoices_xls.mako"
34+ report_type="webkit"
35+ header="False"
36+ auto="False"
37+ menu="True"/>
38+
39+ <report id="allocation_invoices_report"
40+ model="account.invoice"
41+ name="allocation.invoices.report"
42+ target_filename="Allocation_report_${company_id.instance_id.code}_%(year)s%(month)s%(day)s"
43+ rml="account_override/report/allocation_invoices_report.rml"
44+ header="False"
45+ auto="False"
46+ string="Invoice allocation"/>
47 </data>
48 </openerp>
49
50
51=== modified file 'account_override/report/__init__.py'
52--- account_override/report/__init__.py 2014-03-19 13:40:41 +0000
53+++ account_override/report/__init__.py 2015-05-29 09:19:39 +0000
54@@ -1,3 +1,5 @@
55 import account_chart_export
56 import account_print_invoice
57-import report_open_invoices
58\ No newline at end of file
59+import report_open_invoices
60+import report_allocation_synthesis_invoices
61+import report_allocation_invoices
62
63=== added file 'account_override/report/allocation_invoices_report.rml'
64--- account_override/report/allocation_invoices_report.rml 1970-01-01 00:00:00 +0000
65+++ account_override/report/allocation_invoices_report.rml 2015-05-29 09:19:39 +0000
66@@ -0,0 +1,264 @@
67+<?xml version="1.0"?>
68+<document filename="allocation_invoice_report.pdf">
69+ <template pageSize="(842.0,595.0)" title="Test" author="Medecins Sans Frontieres" allowSplitting="20">
70+ <pageTemplate id="first">
71+ <frame id="first" x1="42.0" y1="57.0" width="750" height="530"/>
72+ </pageTemplate>
73+ </template>
74+ <stylesheet>
75+
76+ <!-- TABLE STYLES -->
77+ <blockTableStyle id="HeaderTable">
78+ <blockAlignment value="CENTER" />
79+ <blockValign value="MIDDLE" />
80+ <lineStyle kind="OUTLINE" colorName="#000000" />
81+ </blockTableStyle>
82+
83+ <blockTableStyle id="InformationTable">
84+ <blockAlignment value="CENTER" />
85+ <blockValign value="MIDDLE" />
86+ <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" />
87+ <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="-1,0" />
88+ <lineStyle kind="LINEBEFORE" colorName="#000000" />
89+ <lineStyle kind="LINEAFTER" colorName="#000000" />
90+ </blockTableStyle>
91+
92+ <blockTableStyle id="ProductList">
93+ <blockValign value="MIDDLE" />
94+ <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" />
95+ <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="-1,0" />
96+ <lineStyle kind="LINEBEFORE" colorName="#0b0b0b" />
97+ <lineStyle kind="LINEAFTER" colorName="#000000" />
98+ </blockTableStyle>
99+
100+ <initialize>
101+ <paraStyle name="all" alignment="justify"/>
102+ </initialize>
103+
104+ <!-- PARAGRAPH STYLES -->
105+ <paraStyle name="Standard" fontName="Helvetica"/>
106+ <paraStyle name="Header" fontName="Helvetica-Bold" fontSize="15.0" leading="20" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0" />
107+ <paraStyle name="InformationHeader" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" />
108+ <paraStyle name="Information" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" />
109+
110+ </stylesheet>
111+ <story>
112+ <pto>
113+ <para style="Standard">[[repeatIn(objects,'o')]]</para>
114+ <!--<para style="Standard">[[ setLang(o.partner_id.lang) ]]</para>-->
115+
116+ <!-- HEADER TABLE OF THE PRINTED FILE -->
117+ <blockTable colWidths="565" style="HeaderTable">
118+ <tr>
119+ <td>
120+ <para style="Header">INVOICE LINES ALLOCATION REPORT</para>
121+ </td>
122+ </tr>
123+ </blockTable>
124+
125+
126+ <para style="Standard">
127+ <font color="white"> </font>
128+ </para>
129+
130+
131+ <!-- GENERAL INFORMATION -->
132+
133+ <blockTable colWidths="162.0,162.0,162.0,162.0" style="InformationTable">
134+ <tr>
135+ <td>
136+ <para style="InformationHeader">Invoice</para>
137+ </td>
138+ <td>
139+ <para style="InformationHeader">Supplier</para>
140+ </td>
141+ <td>
142+ <para style="InformationHeader">Type</para>
143+ </td>
144+ <td>
145+ <para style="InformationHeader"></para>
146+ </td>
147+ </tr>
148+
149+ <tr>
150+ <td>
151+ <para style="Information">[[ o.number ]]</para>
152+ </td>
153+ <td>
154+ <para style="Information">[[ o.partner_id.name ]]</para>
155+ </td>
156+ <td>
157+ <para style="Information">[[ getSel(o, 'type') ]]</para>
158+ </td>
159+ <td>
160+ <para style="Information"></para>
161+ </td>
162+ </tr>
163+ </blockTable>
164+
165+ <blockTable colWidths="162.0,162.0,162.0,162.0" style="InformationTable">
166+ <tr>
167+ <td>
168+ <para style="InformationHeader">Creation date</para>
169+ </td>
170+ <td>
171+ <para style="InformationHeader">Creator</para>
172+ </td>
173+ <td>
174+ <para style="InformationHeader">State</para>
175+ </td>
176+ <td>
177+ <para style="InformationHeader">Currency</para>
178+ </td>
179+ </tr>
180+
181+ <tr>
182+ <td>
183+ <para style="Information">[[ formatLang(o.date_invoice, date=True) ]]</para>
184+ </td>
185+ <td>
186+ <para style="Information">[[ o.user_id.name ]]</para>
187+ </td>
188+ <td>
189+ <para style="Information">[[ getSel(o, 'state') ]]</para>
190+ </td>
191+ <td>
192+ <para style="Information">[[ o.currency_id.name ]]</para>
193+ </td>
194+ </tr>
195+ </blockTable>
196+
197+
198+ <para style="Standard">
199+ <font color="white"> </font>
200+ </para>
201+
202+
203+ <!-- LINES LIST -->
204+ <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">
205+ <tr>
206+ <td>
207+ <para style="InformationHeader">Line</para>
208+ </td>
209+ <td>
210+ <para style="InformationHeader">Product</para>
211+ </td>
212+ <td>
213+ <para style="InformationHeader">Description</para>
214+ </td>
215+ <td>
216+ <para style="InformationHeader">Account</para>
217+ </td>
218+ <td>
219+ <para style="InformationHeader">Qty</para>
220+ </td>
221+ <td>
222+ <para style="InformationHeader">Unit Price</para>
223+ </td>
224+ <td>
225+ <para style="InformationHeader">%</para>
226+ </td>
227+ <td>
228+ <para style="InformationHeader">Subtotal</para>
229+ </td>
230+ <td>
231+ <para style="InformationHeader">Destination</para>
232+ </td>
233+
234+ <td>
235+ <para style="InformationHeader">Cost Center</para>
236+ </td>
237+ <td>
238+ <para style="InformationHeader">Funding Pool</para>
239+ </td>
240+ </tr>
241+ </blockTable>
242+ <pto_header>
243+ <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">
244+ <tr>
245+ <td>
246+ <para style="InformationHeader">Line</para>
247+ </td>
248+ <td>
249+ <para style="InformationHeader">Product</para>
250+ </td>
251+ <td>
252+ <para style="InformationHeader">Description</para>
253+ </td>
254+ <td>
255+ <para style="InformationHeader">Account</para>
256+ </td>
257+ <td>
258+ <para style="InformationHeader">Qty</para>
259+ </td>
260+ <td>
261+ <para style="InformationHeader">Unit Price</para>
262+ </td>
263+ <td>
264+ <para style="InformationHeader">%</para>
265+ </td>
266+ <td>
267+ <para style="InformationHeader">Subtotal</para>
268+ </td>
269+
270+ <td>
271+ <para style="InformationHeader">Destination</para>
272+ </td>
273+
274+ <td>
275+ <para style="InformationHeader">Cost Center</para>
276+ </td>
277+ <td>
278+ <para style="InformationHeader">Funding Pool</para>
279+ </td>
280+ </tr>
281+ </blockTable>
282+ </pto_header>
283+
284+ <section>
285+ [[ repeatIn(get_data(o.id), 'line') ]]
286+ <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">
287+ <tr>
288+ <td>
289+ <para style="Information">[[ line[0] ]]</para>
290+ </td>
291+ <td>
292+ <para style="Information">[[ line[1] ]]</para>
293+ </td>
294+ <td>
295+ <para style="Information">[[ line[2] ]]</para>
296+ </td>
297+ <td>
298+ <para style="Information">[[ line[3] ]]</para>
299+ </td>
300+ <td>
301+ <para style="Information">[[ formatLang(line[4]) ]]</para>
302+ </td>
303+ <td>
304+ <para style="Information">[[ formatLang(line[5]) ]]</para>
305+ </td>
306+ <td>
307+ <para style="Information">[[ formatLang(line[6]) ]]</para>
308+ </td>
309+ <td>
310+ <para style="Information">[[ formatLang(line[7]) ]]</para>
311+ </td>
312+ <td>
313+ <para style="Information">[[ line[9] ]]</para>
314+ </td>
315+ <td>
316+ <para style="Information">[[ line[10] ]]</para>
317+ </td>
318+ <td>
319+ <para style="Information">[[ line[11] ]]</para>
320+ </td>
321+ </tr>
322+ </blockTable>
323+ </section>
324+
325+ <para style="Standard">
326+ <font color="white"> </font>
327+ </para>
328+ </pto>
329+ </story>
330+</document>
331
332=== added file 'account_override/report/allocation_synthesis_invoices_xls.mako'
333--- account_override/report/allocation_synthesis_invoices_xls.mako 1970-01-01 00:00:00 +0000
334+++ account_override/report/allocation_synthesis_invoices_xls.mako 2015-05-29 09:19:39 +0000
335@@ -0,0 +1,166 @@
336+<?xml version="1.0"?>
337+<?mso-application progid="Excel.Sheet"?>
338+<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
339+ xmlns:o="urn:schemas-microsoft-com:office:office"
340+ xmlns:x="urn:schemas-microsoft-com:office:excel"
341+ xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
342+ xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
343+ xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"
344+ xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
345+ xmlns:html="http://www.w3.org/TR/REC-html40">
346+ <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
347+ <Author>Tempo Consulting</Author>
348+ <LastAuthor>Tempo Consulting</LastAuthor>
349+ <Created>2015-05-19T15:32:58Z</Created>
350+ <Version>14.00</Version>
351+ </DocumentProperties>
352+ <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
353+ <AllowPNG/>
354+ </OfficeDocumentSettings>
355+ <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
356+ <WindowHeight>7995</WindowHeight>
357+ <WindowWidth>20115</WindowWidth>
358+ <WindowTopX>240</WindowTopX>
359+ <WindowTopY>75</WindowTopY>
360+ <ProtectStructure>False</ProtectStructure>
361+ <ProtectWindows>False</ProtectWindows>
362+ </ExcelWorkbook>
363+ <Styles>
364+ <Style ss:ID="Default" ss:Name="Normal">
365+ <Alignment ss:Vertical="Bottom"/>
366+ <Borders/>
367+ <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
368+ <Interior/>
369+ <NumberFormat/>
370+ <Protection/>
371+ </Style>
372+ <Style ss:ID="s63">
373+ <NumberFormat ss:Format="Standard"/>
374+ </Style>
375+ <Style ss:ID="s66">
376+ <Alignment ss:Horizontal="Left" ss:Vertical="Bottom" ss:Indent="1"/>
377+ </Style>
378+ <Style ss:ID="s67">
379+ <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
380+ ss:Bold="1"/>
381+ <NumberFormat ss:Format="Standard"/>
382+ </Style>
383+ <Style ss:ID="s69">
384+ <Alignment ss:Horizontal="Left" ss:Vertical="Bottom" ss:Indent="1"/>
385+ <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
386+ ss:Bold="1"/>
387+ </Style>
388+ <Style ss:ID="s74">
389+ <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
390+ ss:Bold="1"/>
391+ <Interior ss:Color="#DCE6F1" ss:Pattern="Solid"/>
392+ </Style>
393+ <Style ss:ID="s75">
394+ <Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>
395+ <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
396+ ss:Bold="1"/>
397+ <Interior ss:Color="#DCE6F1" ss:Pattern="Solid"/>
398+ </Style>
399+ <Style ss:ID="s76">
400+ <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
401+ ss:Bold="1"/>
402+ <Interior ss:Color="#DCE6F1" ss:Pattern="Solid"/>
403+ <NumberFormat ss:Format="Standard"/>
404+ </Style>
405+ <Style ss:ID="s98">
406+ <Borders/>
407+ </Style>
408+ <Style ss:ID="s99">
409+ <Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>
410+ <Borders>
411+ <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"
412+ ss:Color="#8DB4E2"/>
413+ </Borders>
414+ <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
415+ ss:Bold="1"/>
416+ </Style>
417+ <Style ss:ID="s100">
418+ <Borders>
419+ <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"
420+ ss:Color="#8DB4E2"/>
421+ </Borders>
422+ <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
423+ ss:Bold="1"/>
424+ <NumberFormat ss:Format="Standard"/>
425+ </Style>
426+ </Styles>
427+ % for o in objects:
428+ <Worksheet ss:Name="${(o.number or title(o)+' '+str(o.id))|x}">
429+ <Table x:FullColumns="1"
430+ x:FullRows="1" ss:DefaultColumnWidth="90" ss:DefaultRowHeight="15">
431+ <Column ss:AutoFitWidth="0" ss:Width="110.25"/>
432+ <Column ss:AutoFitWidth="0" ss:Width="95.25"/>
433+ <Column ss:AutoFitWidth="0" ss:Width="69.75"/>
434+ <Column ss:Width="121.5"/>
435+ <Column ss:Width="96"/>
436+ <Row ss:AutoFitHeight="0">
437+ <Cell><Data ss:Type="String">Invoice :</Data></Cell>
438+ <Cell><Data ss:Type="String">${(o.number or ' ')|x}</Data></Cell>
439+ </Row>
440+ <Row ss:AutoFitHeight="0">
441+ <Cell><Data ss:Type="String">Type :</Data></Cell>
442+ <Cell><Data ss:Type="String">${(title(o))|x}</Data></Cell>
443+ </Row>
444+ <Row ss:AutoFitHeight="0">
445+ <Cell><Data ss:Type="String">Supplier :</Data></Cell>
446+ <Cell><Data ss:Type="String">${(o.partner_id.name)|x}</Data></Cell>
447+ </Row>
448+ <Row ss:AutoFitHeight="0">
449+ <Cell><Data ss:Type="String">Posting date :</Data></Cell>
450+ <Cell><Data ss:Type="String">${(o.date_invoice or ' ')|x}</Data></Cell>
451+ </Row>
452+ <Row ss:AutoFitHeight="0">
453+ <Cell><Data ss:Type="String">Currency :</Data></Cell>
454+ <Cell><Data ss:Type="String">${(o.currency_id.name)|x}</Data></Cell>
455+ </Row>
456+ <Row ss:AutoFitHeight="0"/>
457+ <Row ss:AutoFitHeight="0">
458+ <Cell ss:StyleID="s74"><Data ss:Type="String">Row labels</Data></Cell>
459+ <Cell ss:StyleID="s74"><Data ss:Type="String">Sum of Amount</Data></Cell>
460+ </Row>
461+ % for row in get_data(o.id):
462+ % if level(row) == 1:
463+ <Row ss:AutoFitHeight="0">
464+ <Cell ss:StyleID="s99"><Data ss:Type="String">${(row[0])|x}</Data></Cell>
465+ <Cell ss:StyleID="s100"><Data ss:Type="Number">${(row[2])|x}</Data></Cell>
466+ </Row>
467+ % endif
468+ % if level(row) == 2:
469+ <Row ss:AutoFitHeight="0">
470+ <Cell ss:StyleID="s66"><Data ss:Type="String">${(row[1])|x}</Data></Cell>
471+ <Cell ss:StyleID="s63"><Data ss:Type="Number">${(row[2])|x}</Data></Cell>
472+ </Row>
473+ % endif
474+ % if level(row) == -1:
475+ <Row ss:AutoFitHeight="0">
476+ <Cell ss:StyleID="s75"><Data ss:Type="String">Grand Total</Data></Cell>
477+ <Cell ss:StyleID="s76"><Data ss:Type="Number">${(row[2])|x}</Data></Cell>
478+ </Row>
479+ % endif
480+ % endfor
481+ </Table>
482+ <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
483+ <PageSetup>
484+ <Header x:Margin="0.3"/>
485+ <Footer x:Margin="0.3"/>
486+ <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
487+ </PageSetup>
488+ <Unsynced/>
489+ <Print>
490+ <ValidPrinterInfo/>
491+ <PaperSizeIndex>9</PaperSizeIndex>
492+ <HorizontalResolution>600</HorizontalResolution>
493+ <VerticalResolution>600</VerticalResolution>
494+ </Print>
495+ <Selected/>
496+ <ProtectObjects>False</ProtectObjects>
497+ <ProtectScenarios>False</ProtectScenarios>
498+ </WorksheetOptions>
499+ </Worksheet>
500+ % endfor
501+</Workbook>
502
503=== added file 'account_override/report/report_allocation_invoices.py'
504--- account_override/report/report_allocation_invoices.py 1970-01-01 00:00:00 +0000
505+++ account_override/report/report_allocation_invoices.py 2015-05-29 09:19:39 +0000
506@@ -0,0 +1,81 @@
507+# -*- coding: utf-8 -*-
508+##############################################################################
509+#
510+# OpenERP, Open Source Management Solution
511+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
512+#
513+# This program is free software: you can redistribute it and/or modify
514+# it under the terms of the GNU Affero General Public License as
515+# published by the Free Software Foundation, either version 3 of the
516+# License, or (at your option) any later version.
517+#
518+# This program is distributed in the hope that it will be useful,
519+# but WITHOUT ANY WARRANTY; without even the implied warranty of
520+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
521+# GNU Affero General Public License for more details.
522+#
523+# You should have received a copy of the GNU Affero General Public License
524+# along with this program. If not, see <http://www.gnu.org/licenses/>.
525+#
526+##############################################################################
527+
528+import time
529+
530+from report import report_sxw
531+
532+
533+class allocation_invoice_report(report_sxw.rml_parse):
534+ def __init__(self, cr, uid, name, context=None):
535+ super(allocation_invoice_report, self).__init__(cr, uid, name, context=context)
536+
537+ self._cr = cr
538+
539+ self.localcontext.update({
540+ 'time': time,
541+ 'get_data': self.get_data,
542+ })
543+
544+ def get_data(self, invoice_id):
545+ 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
546+ FROM funding_pool_distribution_line a
547+ INNER JOIN account_invoice_line i ON a.distribution_id = i.analytic_distribution_id
548+ INNER JOIN account_invoice s ON s.id = i.invoice_id
549+ INNER JOIN account_analytic_account n1 ON n1.id = a.destination_id
550+ INNER JOIN account_analytic_account n2 ON n2.id = a.cost_center_id
551+ INNER JOIN account_analytic_account n3 ON n3.id = a.analytic_id
552+ INNER JOIN account_account ac ON ac.id = i.account_id
553+ LEFT JOIN product_product p ON p.id = i.product_id
554+ LEFT JOIN res_currency y ON y.id = s.currency_id
555+ WHERE i.invoice_id=%s
556+ UNION ALL
557+ 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
558+ FROM funding_pool_distribution_line a
559+ INNER JOIN account_invoice s ON s.analytic_distribution_id = a.distribution_id
560+ LEFT JOIN account_invoice_line i ON i.invoice_id = s.id AND i.analytic_distribution_id IS NULL
561+ INNER JOIN account_account ac ON ac.id = i.account_id
562+ INNER JOIN account_analytic_account n1 ON n1.id = a.destination_id
563+ INNER JOIN account_analytic_account n2 ON n2.id = a.cost_center_id
564+ INNER JOIN account_analytic_account n3 ON n3.id = a.analytic_id
565+ INNER JOIN res_currency y ON y.id = s.currency_id
566+ LEFT JOIN product_product p ON p.id = i.product_id
567+ WHERE s.id=%s
568+ UNION ALL
569+ 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
570+ FROM account_invoice_line i
571+ INNER JOIN account_invoice s ON s.id = i.invoice_id
572+ INNER JOIN account_account ac ON ac.id = i.account_id
573+ INNER JOIN res_currency y ON y.id = s.currency_id
574+ LEFT JOIN product_product p ON p.id = i.product_id
575+ WHERE s.id=%s and is_analytic_addicted = False
576+ ORDER BY line_number, destination, cost_center, funding_pool
577+ """, (invoice_id, invoice_id, invoice_id))
578+
579+ return self._cr.fetchall()
580+
581+
582+report_sxw.report_sxw('report.allocation.invoices.report',
583+ 'account.invoice',
584+ 'addons/account_override/report/allocation_invoices_report.rml',
585+ parser=allocation_invoice_report, header="landscape")
586+
587+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
588
589=== added file 'account_override/report/report_allocation_synthesis_invoices.py'
590--- account_override/report/report_allocation_synthesis_invoices.py 1970-01-01 00:00:00 +0000
591+++ account_override/report/report_allocation_synthesis_invoices.py 2015-05-29 09:19:39 +0000
592@@ -0,0 +1,87 @@
593+# -*- coding: utf-8 -*-
594+##############################################################################
595+#
596+# Copyright (C) 2015 MSF, TeMPO Consulting
597+#
598+# This program is free software: you can redistribute it and/or modify
599+# it under the terms of the GNU Affero General Public License as
600+# published by the Free Software Foundation, either version 3 of the
601+# License, or (at your option) any later version.
602+#
603+# This program is distributed in the hope that it will be useful,
604+# but WITHOUT ANY WARRANTY; without even the implied warranty of
605+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
606+# GNU Affero General Public License for more details.
607+#
608+# You should have received a copy of the GNU Affero General Public License
609+# along with this program. If not, see <http://www.gnu.org/licenses/>.
610+#
611+##############################################################################
612+
613+from spreadsheet_xml.spreadsheet_xml_write import SpreadsheetReport
614+from report import report_sxw
615+
616+
617+class report_allocation_synthesis_invoices(report_sxw.rml_parse):
618+ def __init__(self, cr, uid, name, context=None):
619+ super(report_allocation_synthesis_invoices, self).__init__(cr, uid, name, context=context)
620+
621+ self._cr = cr
622+
623+ self.localcontext.update({
624+ 'title': self.get_title,
625+ 'get_data': self.get_data,
626+ 'level': self.get_level,
627+ })
628+
629+ def get_data(self, invoice_id):
630+ self._cr.execute(""" WITH t as (
631+ SELECT ac.code as L1, n2.code as L2,
632+ ROUND(SUM(price_subtotal*percentage/100), 2) as amount
633+ FROM funding_pool_distribution_line a
634+ INNER JOIN account_invoice_line i ON a.distribution_id = i.analytic_distribution_id
635+ INNER JOIN account_analytic_account n2 ON n2.id = a.cost_center_id
636+ INNER JOIN account_account ac ON ac.id = i.account_id
637+ WHERE i.invoice_id=%s
638+ GROUP BY ac.code, n2.code
639+ UNION ALL
640+ SELECT ac.code, n2.code, ROUND(SUM(price_subtotal*percentage/100), 2)
641+ FROM funding_pool_distribution_line a
642+ INNER JOIN account_invoice s ON s.analytic_distribution_id = a.distribution_id
643+ LEFT JOIN account_invoice_line i ON i.invoice_id = s.id AND i.analytic_distribution_id IS NULL
644+ INNER JOIN account_account ac ON ac.id = i.account_id
645+ INNER JOIN account_analytic_account n2 ON n2.id = a.cost_center_id
646+ WHERE s.id=%s
647+ GROUP BY ac.code, n2.code)
648+ SELECT L1, L2, SUM(amount) as amount FROM t
649+ GROUP BY L1, L2
650+ UNION ALL
651+ SELECT L1, '', SUM(amount) FROM t
652+ GROUP BY L1
653+ UNION ALL
654+ SELECT NULL, '', SUM(amount) FROM t
655+ ORDER BY L1, L2""", (invoice_id, invoice_id))
656+
657+ return self._cr.fetchall()
658+
659+ def get_level(self, row):
660+ if row[0] is None:
661+ return -1
662+ elif row[1] == '':
663+ return 1
664+ else:
665+ return 2
666+
667+ def get_title(self, invoice):
668+
669+ invoice_types = {
670+ 'out_invoice': 'Customer Invoice',
671+ 'in_invoice': 'Supplier Invoice',
672+ 'out_refund': 'Customer Refund',
673+ 'in_refund': 'Supplier Refund'
674+ }
675+
676+ return invoice_types[invoice.type]
677+
678+
679+SpreadsheetReport('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