Merge lp:~unifield-team/unifield-server/us-1060 into lp:unifield-server
- us-1060
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 3916 |
Proposed branch: | lp:~unifield-team/unifield-server/us-1060 |
Merge into: | lp:unifield-server |
Diff against target: |
356 lines (+268/-11) 8 files modified
bin/addons/supplier_catalogue/__init__.py (+2/-1) bin/addons/supplier_catalogue/__openerp__.py (+2/-1) bin/addons/supplier_catalogue/report/__init__.py (+24/-0) bin/addons/supplier_catalogue/report/report_supplier_catalogue_lines_xls.mako (+95/-0) bin/addons/supplier_catalogue/report/supplier_catalogue_lines_xls.py (+86/-0) bin/addons/supplier_catalogue/supplier_catalogue_report.xml (+16/-0) bin/addons/supplier_catalogue/wizard/catalogue_export_lines.py (+27/-8) bin/addons/supplier_catalogue/wizard/catalogue_export_lines_view.xml (+16/-1) |
To merge this branch: | bzr merge lp:~unifield-team/unifield-server/us-1060 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+302448@code.launchpad.net |
Commit message
Description of the change
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 'bin/addons/supplier_catalogue/__init__.py' |
2 | --- bin/addons/supplier_catalogue/__init__.py 2012-02-21 15:09:35 +0000 |
3 | +++ bin/addons/supplier_catalogue/__init__.py 2016-08-09 16:14:47 +0000 |
4 | @@ -24,5 +24,6 @@ |
5 | import partner |
6 | import purchase |
7 | import wizard |
8 | +import report |
9 | |
10 | -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
11 | \ No newline at end of file |
12 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
13 | |
14 | === modified file 'bin/addons/supplier_catalogue/__openerp__.py' |
15 | --- bin/addons/supplier_catalogue/__openerp__.py 2012-02-22 13:04:06 +0000 |
16 | +++ bin/addons/supplier_catalogue/__openerp__.py 2016-08-09 16:14:47 +0000 |
17 | @@ -41,6 +41,7 @@ |
18 | "supplier_catalogue_data.xml", |
19 | "wizard/catalogue_import_lines_view.xml", |
20 | "wizard/catalogue_export_lines_view.xml", |
21 | + "supplier_catalogue_report.xml", |
22 | "security/ir.model.access.csv", |
23 | ], |
24 | 'test': [ |
25 | @@ -51,4 +52,4 @@ |
26 | 'active': False, |
27 | } |
28 | |
29 | -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
30 | \ No newline at end of file |
31 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
32 | |
33 | === added directory 'bin/addons/supplier_catalogue/report' |
34 | === added file 'bin/addons/supplier_catalogue/report/__init__.py' |
35 | --- bin/addons/supplier_catalogue/report/__init__.py 1970-01-01 00:00:00 +0000 |
36 | +++ bin/addons/supplier_catalogue/report/__init__.py 2016-08-09 16:14:47 +0000 |
37 | @@ -0,0 +1,24 @@ |
38 | +# -*- coding: utf-8 -*- |
39 | +############################################################################## |
40 | +# |
41 | +# OpenERP, Open Source Management Solution |
42 | +# Copyright (C) 2011 MSF, TeMPO Consulting |
43 | +# |
44 | +# This program is free software: you can redistribute it and/or modify |
45 | +# it under the terms of the GNU Affero General Public License as |
46 | +# published by the Free Software Foundation, either version 3 of the |
47 | +# License, or (at your option) any later version. |
48 | +# |
49 | +# This program is distributed in the hope that it will be useful, |
50 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
51 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
52 | +# GNU Affero General Public License for more details. |
53 | +# |
54 | +# You should have received a copy of the GNU Affero General Public License |
55 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
56 | +# |
57 | +############################################################################## |
58 | + |
59 | +import supplier_catalogue_lines_xls |
60 | + |
61 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
62 | |
63 | === added file 'bin/addons/supplier_catalogue/report/report_supplier_catalogue_lines_xls.mako' |
64 | --- bin/addons/supplier_catalogue/report/report_supplier_catalogue_lines_xls.mako 1970-01-01 00:00:00 +0000 |
65 | +++ bin/addons/supplier_catalogue/report/report_supplier_catalogue_lines_xls.mako 2016-08-09 16:14:47 +0000 |
66 | @@ -0,0 +1,95 @@ |
67 | +<?xml version="1.0"?> |
68 | +<?mso-application progid="Excel.Sheet"?> |
69 | +<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" |
70 | + xmlns:o="urn:schemas-microsoft-com:office:office" |
71 | + xmlns:x="urn:schemas-microsoft-com:office:excel" |
72 | + xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" |
73 | + xmlns:html="http://www.w3.org/TR/REC-html40"> |
74 | + <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"> |
75 | + <Author>MSFUser</Author> |
76 | + <LastAuthor>MSFUser</LastAuthor> |
77 | + <Created>2012-06-18T15:46:09Z</Created> |
78 | + <Company>Medecins Sans Frontieres</Company> |
79 | + <Version>11.9999</Version> |
80 | + </DocumentProperties> |
81 | + <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> |
82 | + <WindowHeight>13170</WindowHeight> |
83 | + <WindowWidth>19020</WindowWidth> |
84 | + <WindowTopX>120</WindowTopX> |
85 | + <WindowTopY>60</WindowTopY> |
86 | + <ProtectStructure>False</ProtectStructure> |
87 | + <ProtectWindows>False</ProtectWindows> |
88 | + </ExcelWorkbook> |
89 | +<Styles> |
90 | + <Style ss:ID="header"> |
91 | + <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/> |
92 | + <Interior ss:Color="#ffcc99" ss:Pattern="Solid"/> |
93 | + <Borders> |
94 | + <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" /> |
95 | + <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" /> |
96 | + <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" /> |
97 | + <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" /> |
98 | + </Borders> |
99 | + </Style> |
100 | + <Style ss:ID="line"> |
101 | + <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/> |
102 | + <Borders> |
103 | + <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" /> |
104 | + <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" /> |
105 | + <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" /> |
106 | + <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" /> |
107 | + </Borders> |
108 | + </Style> |
109 | + <Style ss:ID="short_date"> |
110 | + <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/> |
111 | + <Borders> |
112 | + <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/> |
113 | + <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/> |
114 | + <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/> |
115 | + <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/> |
116 | + </Borders> |
117 | + <NumberFormat ss:Format="Short Date"/> |
118 | + </Style> |
119 | +</Styles> |
120 | +## ==================================== we loop over the supplier_catalogue "objects" == supplier.catalogue ==================================================== |
121 | +% for o in getOrders(objects): |
122 | +<ss:Worksheet ss:Name="${"%s"%(o.name.split('/')[-1] or 'Sheet1')|x}"> |
123 | +## definition of the columns' size |
124 | +<% nb_of_columns = 8 %> |
125 | +<Table x:FullColumns="1" x:FullRows="1"> |
126 | +<Column ss:AutoFitWidth="1" ss:Width="120" /> |
127 | +<Column ss:AutoFitWidth="1" ss:Width="300" /> |
128 | +% for x in range(2,nb_of_columns - 1): |
129 | +<Column ss:AutoFitWidth="1" ss:Width="60" /> |
130 | +% endfor |
131 | +<Column ss:AutoFitWidth="1" ss:Width="250" /> |
132 | + |
133 | +## we loop over the purchase_order_line "%s"%po_name.split('/')[-1]) |
134 | + |
135 | + <Row> |
136 | + <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Product Code')}</Data></Cell> |
137 | + <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Product Description')}</Data></Cell> |
138 | + <Cell ss:StyleID="header" ><Data ss:Type="String">${_('UoM')}</Data></Cell> |
139 | + <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Min. Qty')}</Data></Cell> |
140 | + <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Unit Price')}</Data></Cell> |
141 | + <Cell ss:StyleID="header" ><Data ss:Type="String">${_('SoQ Rounding')}</Data></Cell> |
142 | + <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Min. Order Qty.')}</Data></Cell> |
143 | + <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Comment')}</Data></Cell> |
144 | + </Row> |
145 | + % for line in getLines(o): |
146 | + <Row> |
147 | + <Cell ss:StyleID="line" ><Data ss:Type="String">${(line.product_id.default_code or '')|x}</Data></Cell> |
148 | + <Cell ss:StyleID="line" ><Data ss:Type="String">${(line.product_id.name or '')|x}</Data></Cell> |
149 | + <Cell ss:StyleID="line" ><Data ss:Type="String">${(line.line_uom_id.name or '')|x}</Data></Cell> |
150 | + <Cell ss:StyleID="line" ><Data ss:Type="Number">${(line.min_qty or 0.00)|x}</Data></Cell> |
151 | + <Cell ss:StyleID="line" ><Data ss:Type="Number">${(line.unit_price or 0.00)|x}</Data></Cell> |
152 | + <Cell ss:StyleID="line" ><Data ss:Type="Number">${(line.rounding or 0.00)|x}</Data></Cell> |
153 | + <Cell ss:StyleID="line" ><Data ss:Type="Number">${(line.min_order_qty or 0.00)|x}</Data></Cell> |
154 | + <Cell ss:StyleID="line" ><Data ss:Type="String">${(line.comment or '')|x}</Data></Cell> |
155 | + </Row> |
156 | + % endfor |
157 | +</Table> |
158 | +<x:WorksheetOptions/> |
159 | +</ss:Worksheet> |
160 | +% endfor |
161 | +</Workbook> |
162 | |
163 | === added file 'bin/addons/supplier_catalogue/report/supplier_catalogue_lines_xls.py' |
164 | --- bin/addons/supplier_catalogue/report/supplier_catalogue_lines_xls.py 1970-01-01 00:00:00 +0000 |
165 | +++ bin/addons/supplier_catalogue/report/supplier_catalogue_lines_xls.py 2016-08-09 16:14:47 +0000 |
166 | @@ -0,0 +1,86 @@ |
167 | +# -*- coding: utf-8 -*- |
168 | +############################################################################## |
169 | +# |
170 | +# OpenERP, Open Source Management Solution |
171 | +# Copyright (C) 2011 MSF, TeMPO Consulting |
172 | +# |
173 | +# This program is free software: you can redistribute it and/or modify |
174 | +# it under the terms of the GNU Affero General Public License as |
175 | +# published by the Free Software Foundation, either version 3 of the |
176 | +# License, or (at your option) any later version. |
177 | +# |
178 | +# This program is distributed in the hope that it will be useful, |
179 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
180 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
181 | +# GNU Affero General Public License for more details. |
182 | +# |
183 | +# You should have received a copy of the GNU Affero General Public License |
184 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
185 | +# |
186 | +############################################################################## |
187 | + |
188 | +from osv import osv |
189 | +from report import report_sxw |
190 | +from msf_supply_doc_export.msf_supply_doc_export import WebKitParser |
191 | +from msf_supply_doc_export.msf_supply_doc_export import getIds |
192 | + |
193 | + |
194 | +class supplier_catalogue_lines_report_parser(report_sxw.rml_parse): |
195 | + |
196 | + def __init__(self, cr, uid, name, context=None): |
197 | + super(supplier_catalogue_lines_report_parser, self).__init__(cr, uid, name, context=context) |
198 | + |
199 | + self.localcontext.update({ |
200 | + 'getLines': self._get_lines, |
201 | + 'getOrders': self._get_orders, |
202 | + }) |
203 | + self._nb_lines = 0 |
204 | + self._lines_iterator = 0 |
205 | + |
206 | + if context.get('background_id'): |
207 | + self.back_browse = self.pool.get('memory.background.report').browse(self.cr, self.uid, context['background_id']) |
208 | + else: |
209 | + self.back_browse = None |
210 | + |
211 | + def _get_orders(self, objs): |
212 | + for o in objs: |
213 | + self._nb_lines += len(o.line_ids) |
214 | + |
215 | + return objs |
216 | + |
217 | + def _get_lines(self, cat_brw): |
218 | + for cat_line in cat_brw.line_ids: |
219 | + self._lines_iterator += 1 |
220 | + if self.back_browse and self._nb_lines: |
221 | + percent = float(self._lines_iterator) / float(self._nb_lines) |
222 | + self.pool.get('memory.background.report').update_percent(self.cr, self.uid, [self.back_browse.id], percent) |
223 | + |
224 | + yield cat_line |
225 | + |
226 | + raise StopIteration |
227 | + |
228 | + |
229 | +class supplier_catalogue_lines_report_xls(WebKitParser): |
230 | + |
231 | + def __init__(self, name, table, rml=False, parser=report_sxw.rml_parse, header='external', store=False): |
232 | + WebKitParser.__init__(self, name, table, rml=rml, parser=parser, header=header, store=store) |
233 | + |
234 | + def create_single_pdf(self, cr, uid, ids, data, report_xml, context=None): |
235 | + report_xml.webkit_debug = 1 |
236 | + report_xml.header = " " |
237 | + report_xml.webkit_header.html = "${_debug or ''|n}" |
238 | + return super(supplier_catalogue_lines_report_xls, self).create_single_pdf(cr, uid, ids, data, report_xml, context) |
239 | + |
240 | + def create(self, cr, uid, ids, data, context=None): |
241 | + ids = getIds(self, cr, uid, ids, context) |
242 | + a = super(supplier_catalogue_lines_report_xls, self).create(cr, uid, ids, data, context) |
243 | + return (a[0], 'xls') |
244 | + |
245 | +supplier_catalogue_lines_report_xls( |
246 | + 'report.supplier.catalogue.lines.xls', |
247 | + 'supplier.catalogue', |
248 | + 'addons/supplier_catalogue/report/report_supplier_catalogue_lines_xls.mako', |
249 | + parser=supplier_catalogue_lines_report_parser, |
250 | +) |
251 | + |
252 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
253 | |
254 | === added file 'bin/addons/supplier_catalogue/supplier_catalogue_report.xml' |
255 | --- bin/addons/supplier_catalogue/supplier_catalogue_report.xml 1970-01-01 00:00:00 +0000 |
256 | +++ bin/addons/supplier_catalogue/supplier_catalogue_report.xml 2016-08-09 16:14:47 +0000 |
257 | @@ -0,0 +1,16 @@ |
258 | +<?xml version="1.0" encoding="utf-8" ?> |
259 | +<openerp> |
260 | + <data> |
261 | + |
262 | + <report |
263 | + id="supplier_catalogue_lines_xls" |
264 | + string="Supplier catalogue lines (xls)" |
265 | + model="supplier.catalogue" |
266 | + name="supplier.catalogue.lines.xls" |
267 | + file="supplier_catalogue/report/report_supplier_catalogue_lines_xls.mako" |
268 | + report_type="webkit" |
269 | + auto="False" |
270 | + menu="False" /> |
271 | + |
272 | + </data> |
273 | +</openerp> |
274 | |
275 | === modified file 'bin/addons/supplier_catalogue/wizard/catalogue_export_lines.py' |
276 | --- bin/addons/supplier_catalogue/wizard/catalogue_export_lines.py 2012-03-28 14:30:33 +0000 |
277 | +++ bin/addons/supplier_catalogue/wizard/catalogue_export_lines.py 2016-08-09 16:14:47 +0000 |
278 | @@ -26,23 +26,42 @@ |
279 | class catalogue_export_lines(osv.osv_memory): |
280 | _name = 'catalogue.export.lines' |
281 | _description = 'Supplier catalogue export lines' |
282 | - |
283 | + |
284 | _columns = { |
285 | 'catalogue_id': fields.many2one('supplier.catalogue', string='Catalogue', required=True), |
286 | 'file_to_export': fields.binary(string='File to export'), |
287 | } |
288 | - |
289 | + |
290 | def export_file(self, cr, uid, ids, context=None): |
291 | ''' |
292 | Export lines to file |
293 | ''' |
294 | if not context: |
295 | context = {} |
296 | - |
297 | - for wiz in self.browse(cr, uid, ids, context=context): |
298 | - pass |
299 | - # TODO: Export file |
300 | - |
301 | - return {'type': 'ir.actions.act_window_close'} |
302 | + |
303 | + catalogue_ids = context.get('active_ids', []) |
304 | + |
305 | + report_name = 'supplier.catalogue.lines.xls' |
306 | + background_id = self.pool.get('memory.background.report').create(cr, uid, { |
307 | + 'file_name': report_name, |
308 | + 'report_name': report_name, |
309 | + }, context=context) |
310 | + |
311 | + context.update({ |
312 | + 'background_id': background_id, |
313 | + 'background_time': 15, |
314 | + }) |
315 | + |
316 | + datas = {'ids': catalogue_ids, 'context': context} |
317 | + |
318 | + return { |
319 | + 'type': 'ir.actions.report.xml', |
320 | + 'report_name': report_name, |
321 | + 'datas': datas, |
322 | + 'nodestroy': True, |
323 | + 'context': context, |
324 | + } |
325 | + |
326 | +catalogue_export_lines() |
327 | |
328 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
329 | |
330 | === modified file 'bin/addons/supplier_catalogue/wizard/catalogue_export_lines_view.xml' |
331 | --- bin/addons/supplier_catalogue/wizard/catalogue_export_lines_view.xml 2012-02-22 07:38:27 +0000 |
332 | +++ bin/addons/supplier_catalogue/wizard/catalogue_export_lines_view.xml 2016-08-09 16:14:47 +0000 |
333 | @@ -16,7 +16,22 @@ |
334 | <button special="cancel" string="Cancel" icon="gtk-cancel" colspan="2" /> |
335 | </form> |
336 | </field> |
337 | - </record> |
338 | + </record> |
339 | + |
340 | + <record id="action_server_export_catalogue_lines" model="ir.actions.server"> |
341 | + <field name="name">Export lines (csv)</field> |
342 | + <field name="model_id" ref="model_catalogue_export_lines" /> |
343 | + <field name="state">code</field> |
344 | + <field name="code">action = obj.export_file(context=context)</field> |
345 | + </record> |
346 | + |
347 | + <record id="ir_export_catalogue_lines" model="ir.values"> |
348 | + <field name="key2">client_print_multi</field> |
349 | + <field name="model">supplier.catalogue</field> |
350 | + <field name="name">Export lines (Excel)</field> |
351 | + <field eval="'ir.actions.server,%d'%action_server_export_catalogue_lines" name="value" /> |
352 | + <field eval="True" name="object" /> |
353 | + </record> |
354 | |
355 | </data> |
356 | </openerp> |