Merge lp:~luigi.grilli/openobject-addons/product_metel into lp:~openerp-community/openobject-addons/trunk-addons-community
- product_metel
- Merge into trunk-addons-community
Proposed by
Luigi Grilli
Status: | Needs review |
---|---|
Proposed branch: | lp:~luigi.grilli/openobject-addons/product_metel |
Merge into: | lp:~openerp-community/openobject-addons/trunk-addons-community |
Diff against target: |
959 lines (+898/-0) 11 files modified
product_metel/__init__.py (+35/-0) product_metel/__terp__.py (+45/-0) product_metel/i18n/it_IT.po (+148/-0) product_metel/i18n/product_metel.pot (+148/-0) product_metel/metel.py (+50/-0) product_metel/metel_view.xml (+20/-0) product_metel/metel_wizard.xml (+17/-0) product_metel/test/metel-test.py (+58/-0) product_metel/wizard/__init__.py (+28/-0) product_metel/wizard/metel_import.py (+244/-0) product_metel/wizard/wizard_metel_import.py (+105/-0) |
To merge this branch: | bzr merge lp:~luigi.grilli/openobject-addons/product_metel |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+19266@code.launchpad.net |
Commit message
Merging product_metel module
Description of the change
To post a comment you must log in.
Unmerged revisions
- 1. By Luigi Grilli
-
Initial import
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'product_metel' | |||
2 | === added file 'product_metel/__init__.py' | |||
3 | --- product_metel/__init__.py 1970-01-01 00:00:00 +0000 | |||
4 | +++ product_metel/__init__.py 2010-02-13 11:58:12 +0000 | |||
5 | @@ -0,0 +1,35 @@ | |||
6 | 1 | # -*- encoding: utf-8 -*- | ||
7 | 2 | ############################################################################## | ||
8 | 3 | # | ||
9 | 4 | # Copyright (c) 2009 Luigi Grilli (luigi.grilli at gmail.com) | ||
10 | 5 | # All Rights Reserved. | ||
11 | 6 | # | ||
12 | 7 | # WARNING: This program as such is intended to be used by professional | ||
13 | 8 | # programmers who take the whole responsability of assessing all potential | ||
14 | 9 | # consequences resulting from its eventual inadequacies and bugs | ||
15 | 10 | # End users who are looking for a ready-to-use solution with commercial | ||
16 | 11 | # garantees and support are strongly adviced to contract a Free Software | ||
17 | 12 | # Service Company | ||
18 | 13 | # | ||
19 | 14 | # This program is Free Software; you can redistribute it and/or | ||
20 | 15 | # modify it under the terms of the GNU General Public License | ||
21 | 16 | # as published by the Free Software Foundation; either version 2 | ||
22 | 17 | # of the License, or (at your option) any later version. | ||
23 | 18 | # | ||
24 | 19 | # This program is distributed in the hope that it will be useful, | ||
25 | 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
26 | 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
27 | 22 | # GNU General Public License for more details. | ||
28 | 23 | # | ||
29 | 24 | # You should have received a copy of the GNU General Public License | ||
30 | 25 | # along with this program; if not, write to the Free Software | ||
31 | 26 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
32 | 27 | # | ||
33 | 28 | ############################################################################## | ||
34 | 29 | # I used the code of account_bankimport as base for this module. | ||
35 | 30 | # | ||
36 | 31 | # This module can import metel formatted files (see www.metel.it) | ||
37 | 32 | # | ||
38 | 33 | |||
39 | 34 | import wizard | ||
40 | 35 | import metel | ||
41 | 0 | 36 | ||
42 | === added file 'product_metel/__terp__.py' | |||
43 | --- product_metel/__terp__.py 1970-01-01 00:00:00 +0000 | |||
44 | +++ product_metel/__terp__.py 2010-02-13 11:58:12 +0000 | |||
45 | @@ -0,0 +1,45 @@ | |||
46 | 1 | # -*- encoding: utf-8 -*- | ||
47 | 2 | ############################################################################## | ||
48 | 3 | # | ||
49 | 4 | # Copyright (c) 2009 Luigi Grilli (luigi.grilli at gmail.com) | ||
50 | 5 | # All Rights Reserved. | ||
51 | 6 | # | ||
52 | 7 | # WARNING: This program as such is intended to be used by professional | ||
53 | 8 | # programmers who take the whole responsability of assessing all potential | ||
54 | 9 | # consequences resulting from its eventual inadequacies and bugs | ||
55 | 10 | # End users who are looking for a ready-to-use solution with commercial | ||
56 | 11 | # garantees and support are strongly adviced to contract a Free Software | ||
57 | 12 | # Service Company | ||
58 | 13 | # | ||
59 | 14 | # This program is Free Software; you can redistribute it and/or | ||
60 | 15 | # modify it under the terms of the GNU General Public License | ||
61 | 16 | # as published by the Free Software Foundation; either version 2 | ||
62 | 17 | # of the License, or (at your option) any later version. | ||
63 | 18 | # | ||
64 | 19 | # This program is distributed in the hope that it will be useful, | ||
65 | 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
66 | 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
67 | 22 | # GNU General Public License for more details. | ||
68 | 23 | # | ||
69 | 24 | # You should have received a copy of the GNU General Public License | ||
70 | 25 | # along with this program; if not, write to the Free Software | ||
71 | 26 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
72 | 27 | # | ||
73 | 28 | ############################################################################## | ||
74 | 29 | # I used the code of account_bankimport as base for this module. | ||
75 | 30 | # | ||
76 | 31 | # This module can import metel formatted files (see www.metel.it) | ||
77 | 32 | # | ||
78 | 33 | |||
79 | 34 | { | ||
80 | 35 | "name":"Metel Listprice Import/Export", | ||
81 | 36 | "version":"0.0.1", | ||
82 | 37 | "author":"Luigi Grilli", | ||
83 | 38 | "category":"Generic Modules/Others", | ||
84 | 39 | "description":"Import and export Metel formatted pricelist", | ||
85 | 40 | "depends":["base", "product_electronic"], | ||
86 | 41 | "init_xml":[], | ||
87 | 42 | "update_xml" : ["metel_view.xml", "metel_wizard.xml"], | ||
88 | 43 | "active":False, | ||
89 | 44 | "installable":True, | ||
90 | 45 | } | ||
91 | 0 | 46 | ||
92 | === added directory 'product_metel/i18n' | |||
93 | === added file 'product_metel/i18n/it_IT.po' | |||
94 | --- product_metel/i18n/it_IT.po 1970-01-01 00:00:00 +0000 | |||
95 | +++ product_metel/i18n/it_IT.po 2010-02-13 11:58:12 +0000 | |||
96 | @@ -0,0 +1,148 @@ | |||
97 | 1 | # Translation of OpenERP Server. | ||
98 | 2 | # This file contains the translation of the following modules: | ||
99 | 3 | # * product_metel | ||
100 | 4 | # | ||
101 | 5 | msgid "" | ||
102 | 6 | msgstr "" | ||
103 | 7 | "Project-Id-Version: OpenERP Server 5.0.6\n" | ||
104 | 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" | ||
105 | 9 | "POT-Creation-Date: 2010-02-13 08:49:31+0000\n" | ||
106 | 10 | "PO-Revision-Date: 2010-02-13 08:49:31+0000\n" | ||
107 | 11 | "Last-Translator: <>\n" | ||
108 | 12 | "Language-Team: \n" | ||
109 | 13 | "MIME-Version: 1.0\n" | ||
110 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
111 | 15 | "Content-Transfer-Encoding: \n" | ||
112 | 16 | "Plural-Forms: \n" | ||
113 | 17 | |||
114 | 18 | #. module: product_metel | ||
115 | 19 | #: model:ir.module.module,description:product_metel.module_meta_information | ||
116 | 20 | msgid "Import and export Metel formatted pricelist" | ||
117 | 21 | msgstr "Importa ed esporta Listini Metel" | ||
118 | 22 | |||
119 | 23 | #. module: product_metel | ||
120 | 24 | #: wizard_button:metel.pricelist,import,end:0 | ||
121 | 25 | msgid "End" | ||
122 | 26 | msgstr "Fine" | ||
123 | 27 | |||
124 | 28 | #. module: product_metel | ||
125 | 29 | #: view:res.partner:0 | ||
126 | 30 | msgid "Sales & Purchases" | ||
127 | 31 | msgstr "" | ||
128 | 32 | |||
129 | 33 | #. module: product_metel | ||
130 | 34 | #: constraint:ir.model:0 | ||
131 | 35 | msgid "The Object name must start with x_ and not contain any special character !" | ||
132 | 36 | msgstr "" | ||
133 | 37 | |||
134 | 38 | #. module: product_metel | ||
135 | 39 | #: wizard_view:metel.pricelist,init:0 | ||
136 | 40 | msgid "Please select metel pricelist file to import." | ||
137 | 41 | msgstr "Selezionare il file del listino da importare" | ||
138 | 42 | |||
139 | 43 | #. module: product_metel | ||
140 | 44 | #: field:res.partner,metel_category:0 | ||
141 | 45 | msgid "Import Category" | ||
142 | 46 | msgstr "Categoria importazione" | ||
143 | 47 | |||
144 | 48 | #. module: product_metel | ||
145 | 49 | #: code:addons\product_metel\wizard\metel_import.py:0 | ||
146 | 50 | #, python-format | ||
147 | 51 | msgid "Metel Import Completed" | ||
148 | 52 | msgstr "Importazione Metel completata" | ||
149 | 53 | |||
150 | 54 | #. module: product_metel | ||
151 | 55 | #: code:addons\product_metel\wizard\wizard_metel_import.py:0 | ||
152 | 56 | #, python-format | ||
153 | 57 | msgid "Error: could not find a partner with this metel code: %s" | ||
154 | 58 | msgstr "Errore: impossibile trovare un partner con questo codice metel: %s" | ||
155 | 59 | |||
156 | 60 | #. module: product_metel | ||
157 | 61 | #: wizard_field:metel.pricelist,import,uo_message:0 | ||
158 | 62 | msgid "Status" | ||
159 | 63 | msgstr "Stato" | ||
160 | 64 | |||
161 | 65 | #. module: product_metel | ||
162 | 66 | #: code:addons\product_metel\wizard\wizard_metel_import.py:0 | ||
163 | 67 | #, python-format | ||
164 | 68 | msgid "Error: no import category defined for the partner." | ||
165 | 69 | msgstr "Errore: non è stata specificata una categoria per il partner." | ||
166 | 70 | |||
167 | 71 | #. module: product_metel | ||
168 | 72 | #: code:addons\product_metel\wizard\wizard_metel_import.py:0 | ||
169 | 73 | #, python-format | ||
170 | 74 | msgid "Import operation in progress" | ||
171 | 75 | msgstr "Importazione dei dati in corso" | ||
172 | 76 | |||
173 | 77 | #. module: product_metel | ||
174 | 78 | #: model:ir.model,name:product_metel.model_product_metel_fileimport | ||
175 | 79 | msgid "product.metel.fileimport" | ||
176 | 80 | msgstr "" | ||
177 | 81 | |||
178 | 82 | #. module: product_metel | ||
179 | 83 | #: model:ir.ui.menu,name:product_metel.menu_metel_import_action | ||
180 | 84 | msgid "Import Metel Pricelist file" | ||
181 | 85 | msgstr "Importa listino Metel" | ||
182 | 86 | |||
183 | 87 | #. module: product_metel | ||
184 | 88 | #: wizard_button:metel.pricelist,init,import:0 | ||
185 | 89 | msgid "Import pricelist" | ||
186 | 90 | msgstr "Importa listino" | ||
187 | 91 | |||
188 | 92 | #. module: product_metel | ||
189 | 93 | #: field:res.partner,metel_code:0 | ||
190 | 94 | msgid "Metel Code" | ||
191 | 95 | msgstr "Codice Metel" | ||
192 | 96 | |||
193 | 97 | #. module: product_metel | ||
194 | 98 | #: wizard_field:metel.pricelist,init,metel_file:0 | ||
195 | 99 | msgid "Metel pricelist file" | ||
196 | 100 | msgstr "File del listino Metel" | ||
197 | 101 | |||
198 | 102 | #. module: product_metel | ||
199 | 103 | #: constraint:ir.ui.view:0 | ||
200 | 104 | msgid "Invalid XML for View Architecture!" | ||
201 | 105 | msgstr "" | ||
202 | 106 | |||
203 | 107 | #. module: product_metel | ||
204 | 108 | #: model:ir.actions.wizard,name:product_metel.wizard_metel_pricelist | ||
205 | 109 | msgid "Import Metel pricelist file" | ||
206 | 110 | msgstr "Importa file listino Metel" | ||
207 | 111 | |||
208 | 112 | #. module: product_metel | ||
209 | 113 | #: field:product.metel.fileimport,tmpfilename:0 | ||
210 | 114 | msgid "File Metel" | ||
211 | 115 | msgstr "File Metel" | ||
212 | 116 | |||
213 | 117 | #. module: product_metel | ||
214 | 118 | #: model:ir.module.module,shortdesc:product_metel.module_meta_information | ||
215 | 119 | msgid "Metel Listprice Import/Export" | ||
216 | 120 | msgstr "Importazione/Esportazione Listini Metel" | ||
217 | 121 | |||
218 | 122 | #. module: product_metel | ||
219 | 123 | #: view:res.partner:0 | ||
220 | 124 | msgid "Metel Properties" | ||
221 | 125 | msgstr "Proprietà Metel" | ||
222 | 126 | |||
223 | 127 | #. module: product_metel | ||
224 | 128 | #: code:addons\product_metel\wizard\metel_import.py:0 | ||
225 | 129 | #, python-format | ||
226 | 130 | msgid "Imported products: %d \nUpdated products: %d" | ||
227 | 131 | msgstr "Nuovi prodotti importati: %d\Prodotti aggiornati: %d" | ||
228 | 132 | |||
229 | 133 | #. module: product_metel | ||
230 | 134 | #: wizard_view:metel.pricelist,import:0 | ||
231 | 135 | msgid "Metel pricelist import report" | ||
232 | 136 | msgstr "Rapporto di importazione file Metel" | ||
233 | 137 | |||
234 | 138 | #. module: product_metel | ||
235 | 139 | #: wizard_button:metel.pricelist,init,end:0 | ||
236 | 140 | msgid "Cancel" | ||
237 | 141 | msgstr "Annulla" | ||
238 | 142 | |||
239 | 143 | #. module: product_metel | ||
240 | 144 | #: wizard_view:metel.pricelist,import:0 | ||
241 | 145 | #: wizard_view:metel.pricelist,init:0 | ||
242 | 146 | msgid "Metel pricelist import" | ||
243 | 147 | msgstr "Importazione listino Metel" | ||
244 | 148 | |||
245 | 0 | 149 | ||
246 | === added file 'product_metel/i18n/product_metel.pot' | |||
247 | --- product_metel/i18n/product_metel.pot 1970-01-01 00:00:00 +0000 | |||
248 | +++ product_metel/i18n/product_metel.pot 2010-02-13 11:58:12 +0000 | |||
249 | @@ -0,0 +1,148 @@ | |||
250 | 1 | # Translation of OpenERP Server. | ||
251 | 2 | # This file contains the translation of the following modules: | ||
252 | 3 | # * product_metel | ||
253 | 4 | # | ||
254 | 5 | msgid "" | ||
255 | 6 | msgstr "" | ||
256 | 7 | "Project-Id-Version: OpenERP Server 5.0.6\n" | ||
257 | 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" | ||
258 | 9 | "POT-Creation-Date: 2010-02-13 08:49:31+0000\n" | ||
259 | 10 | "PO-Revision-Date: 2010-02-13 08:49:31+0000\n" | ||
260 | 11 | "Last-Translator: <>\n" | ||
261 | 12 | "Language-Team: \n" | ||
262 | 13 | "MIME-Version: 1.0\n" | ||
263 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
264 | 15 | "Content-Transfer-Encoding: \n" | ||
265 | 16 | "Plural-Forms: \n" | ||
266 | 17 | |||
267 | 18 | #. module: product_metel | ||
268 | 19 | #: model:ir.module.module,description:product_metel.module_meta_information | ||
269 | 20 | msgid "Import and export Metel formatted pricelist" | ||
270 | 21 | msgstr "" | ||
271 | 22 | |||
272 | 23 | #. module: product_metel | ||
273 | 24 | #: wizard_button:metel.pricelist,import,end:0 | ||
274 | 25 | msgid "End" | ||
275 | 26 | msgstr "" | ||
276 | 27 | |||
277 | 28 | #. module: product_metel | ||
278 | 29 | #: view:res.partner:0 | ||
279 | 30 | msgid "Sales & Purchases" | ||
280 | 31 | msgstr "" | ||
281 | 32 | |||
282 | 33 | #. module: product_metel | ||
283 | 34 | #: constraint:ir.model:0 | ||
284 | 35 | msgid "The Object name must start with x_ and not contain any special character !" | ||
285 | 36 | msgstr "" | ||
286 | 37 | |||
287 | 38 | #. module: product_metel | ||
288 | 39 | #: wizard_view:metel.pricelist,init:0 | ||
289 | 40 | msgid "Please select metel pricelist file to import." | ||
290 | 41 | msgstr "" | ||
291 | 42 | |||
292 | 43 | #. module: product_metel | ||
293 | 44 | #: field:res.partner,metel_category:0 | ||
294 | 45 | msgid "Import Category" | ||
295 | 46 | msgstr "" | ||
296 | 47 | |||
297 | 48 | #. module: product_metel | ||
298 | 49 | #: code:addons\product_metel\wizard\metel_import.py:0 | ||
299 | 50 | #, python-format | ||
300 | 51 | msgid "Metel Import Completed" | ||
301 | 52 | msgstr "" | ||
302 | 53 | |||
303 | 54 | #. module: product_metel | ||
304 | 55 | #: code:addons\product_metel\wizard\wizard_metel_import.py:0 | ||
305 | 56 | #, python-format | ||
306 | 57 | msgid "Error: could not find a partner with this metel code: %s" | ||
307 | 58 | msgstr "" | ||
308 | 59 | |||
309 | 60 | #. module: product_metel | ||
310 | 61 | #: wizard_field:metel.pricelist,import,uo_message:0 | ||
311 | 62 | msgid "Status" | ||
312 | 63 | msgstr "" | ||
313 | 64 | |||
314 | 65 | #. module: product_metel | ||
315 | 66 | #: code:addons\product_metel\wizard\wizard_metel_import.py:0 | ||
316 | 67 | #, python-format | ||
317 | 68 | msgid "Error: no import category defined for the partner." | ||
318 | 69 | msgstr "" | ||
319 | 70 | |||
320 | 71 | #. module: product_metel | ||
321 | 72 | #: code:addons\product_metel\wizard\wizard_metel_import.py:0 | ||
322 | 73 | #, python-format | ||
323 | 74 | msgid "Import operation in progress" | ||
324 | 75 | msgstr "" | ||
325 | 76 | |||
326 | 77 | #. module: product_metel | ||
327 | 78 | #: model:ir.model,name:product_metel.model_product_metel_fileimport | ||
328 | 79 | msgid "product.metel.fileimport" | ||
329 | 80 | msgstr "" | ||
330 | 81 | |||
331 | 82 | #. module: product_metel | ||
332 | 83 | #: model:ir.ui.menu,name:product_metel.menu_metel_import_action | ||
333 | 84 | msgid "Import Metel Pricelist file" | ||
334 | 85 | msgstr "" | ||
335 | 86 | |||
336 | 87 | #. module: product_metel | ||
337 | 88 | #: wizard_button:metel.pricelist,init,import:0 | ||
338 | 89 | msgid "Import pricelist" | ||
339 | 90 | msgstr "" | ||
340 | 91 | |||
341 | 92 | #. module: product_metel | ||
342 | 93 | #: field:res.partner,metel_code:0 | ||
343 | 94 | msgid "Metel Code" | ||
344 | 95 | msgstr "" | ||
345 | 96 | |||
346 | 97 | #. module: product_metel | ||
347 | 98 | #: wizard_field:metel.pricelist,init,metel_file:0 | ||
348 | 99 | msgid "Metel pricelist file" | ||
349 | 100 | msgstr "" | ||
350 | 101 | |||
351 | 102 | #. module: product_metel | ||
352 | 103 | #: constraint:ir.ui.view:0 | ||
353 | 104 | msgid "Invalid XML for View Architecture!" | ||
354 | 105 | msgstr "" | ||
355 | 106 | |||
356 | 107 | #. module: product_metel | ||
357 | 108 | #: model:ir.actions.wizard,name:product_metel.wizard_metel_pricelist | ||
358 | 109 | msgid "Import Metel pricelist file" | ||
359 | 110 | msgstr "" | ||
360 | 111 | |||
361 | 112 | #. module: product_metel | ||
362 | 113 | #: field:product.metel.fileimport,tmpfilename:0 | ||
363 | 114 | msgid "File Metel" | ||
364 | 115 | msgstr "" | ||
365 | 116 | |||
366 | 117 | #. module: product_metel | ||
367 | 118 | #: model:ir.module.module,shortdesc:product_metel.module_meta_information | ||
368 | 119 | msgid "Metel Listprice Import/Export" | ||
369 | 120 | msgstr "" | ||
370 | 121 | |||
371 | 122 | #. module: product_metel | ||
372 | 123 | #: view:res.partner:0 | ||
373 | 124 | msgid "Metel Properties" | ||
374 | 125 | msgstr "" | ||
375 | 126 | |||
376 | 127 | #. module: product_metel | ||
377 | 128 | #: code:addons\product_metel\wizard\metel_import.py:0 | ||
378 | 129 | #, python-format | ||
379 | 130 | msgid "Imported products: %d \nUpdated products: %d" | ||
380 | 131 | msgstr "" | ||
381 | 132 | |||
382 | 133 | #. module: product_metel | ||
383 | 134 | #: wizard_view:metel.pricelist,import:0 | ||
384 | 135 | msgid "Metel pricelist import report" | ||
385 | 136 | msgstr "" | ||
386 | 137 | |||
387 | 138 | #. module: product_metel | ||
388 | 139 | #: wizard_button:metel.pricelist,init,end:0 | ||
389 | 140 | msgid "Cancel" | ||
390 | 141 | msgstr "" | ||
391 | 142 | |||
392 | 143 | #. module: product_metel | ||
393 | 144 | #: wizard_view:metel.pricelist,import:0 | ||
394 | 145 | #: wizard_view:metel.pricelist,init:0 | ||
395 | 146 | msgid "Metel pricelist import" | ||
396 | 147 | msgstr "" | ||
397 | 148 | |||
398 | 0 | 149 | ||
399 | === added file 'product_metel/metel.py' | |||
400 | --- product_metel/metel.py 1970-01-01 00:00:00 +0000 | |||
401 | +++ product_metel/metel.py 2010-02-13 11:58:12 +0000 | |||
402 | @@ -0,0 +1,50 @@ | |||
403 | 1 | ############################################################################## | ||
404 | 2 | # | ||
405 | 3 | # Copyright (c) 2009 Luigi Grilli (luigi.grilli at gmail.com) | ||
406 | 4 | # All Rights Reserved. | ||
407 | 5 | # | ||
408 | 6 | # WARNING: This program as such is intended to be used by professional | ||
409 | 7 | # programmers who take the whole responsability of assessing all potential | ||
410 | 8 | # consequences resulting from its eventual inadequacies and bugs | ||
411 | 9 | # End users who are looking for a ready-to-use solution with commercial | ||
412 | 10 | # garantees and support are strongly adviced to contract a Free Software | ||
413 | 11 | # Service Company | ||
414 | 12 | # | ||
415 | 13 | # This program is Free Software; you can redistribute it and/or | ||
416 | 14 | # modify it under the terms of the GNU General Public License | ||
417 | 15 | # as published by the Free Software Foundation; either version 2 | ||
418 | 16 | # of the License, or (at your option) any later version. | ||
419 | 17 | # | ||
420 | 18 | # This program is distributed in the hope that it will be useful, | ||
421 | 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
422 | 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
423 | 21 | # GNU General Public License for more details. | ||
424 | 22 | # | ||
425 | 23 | # You should have received a copy of the GNU General Public License | ||
426 | 24 | # along with this program; if not, write to the Free Software | ||
427 | 25 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
428 | 26 | # | ||
429 | 27 | ############################################################################## | ||
430 | 28 | # I used the code of account_bankimport as base for this module. | ||
431 | 29 | # | ||
432 | 30 | # This module can import metel formatted files (see www.metel.it) | ||
433 | 31 | # | ||
434 | 32 | |||
435 | 33 | from osv import fields,osv | ||
436 | 34 | |||
437 | 35 | class res_partner(osv.osv): | ||
438 | 36 | _inherit = 'res.partner' | ||
439 | 37 | _columns = { | ||
440 | 38 | 'metel_code': fields.char('Metel Code', size=10, required=False, translate=False), | ||
441 | 39 | 'metel_category': fields.many2one('product.category', 'Import Category', required=False, translate=False), | ||
442 | 40 | } | ||
443 | 41 | res_partner() | ||
444 | 42 | |||
445 | 43 | class metel_file(osv.osv): | ||
446 | 44 | _name = 'product.metel.fileimport' | ||
447 | 45 | _columns = { | ||
448 | 46 | 'tmpfilename': fields.char('File Metel', size=255, required=True, translate=False), | ||
449 | 47 | } | ||
450 | 48 | metel_file() | ||
451 | 49 | |||
452 | 50 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
453 | 0 | 51 | ||
454 | === added file 'product_metel/metel_view.xml' | |||
455 | --- product_metel/metel_view.xml 1970-01-01 00:00:00 +0000 | |||
456 | +++ product_metel/metel_view.xml 2010-02-13 11:58:12 +0000 | |||
457 | @@ -0,0 +1,20 @@ | |||
458 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
459 | 2 | <openerp> | ||
460 | 3 | <data> | ||
461 | 4 | <record model="ir.ui.view" id="view_partner_property_form"> | ||
462 | 5 | <field name="name">res.partner.product.property.form.inherit</field> | ||
463 | 6 | <field name="model">res.partner</field> | ||
464 | 7 | <field name="type">form</field> | ||
465 | 8 | <field name="inherit_id" ref="base.view_partner_form"/> | ||
466 | 9 | <field name="arch" type="xml"> | ||
467 | 10 | <page string="Sales & Purchases" position="inside"> | ||
468 | 11 | <group colspan="2" col="2" name="metel"> | ||
469 | 12 | <separator string="Metel Properties" colspan="2"/> | ||
470 | 13 | <field name="metel_code"/> | ||
471 | 14 | <field name="metel_category"/> | ||
472 | 15 | </group> | ||
473 | 16 | </page> | ||
474 | 17 | </field> | ||
475 | 18 | </record> | ||
476 | 19 | </data> | ||
477 | 20 | </openerp> | ||
478 | 0 | \ No newline at end of file | 21 | \ No newline at end of file |
479 | 1 | 22 | ||
480 | === added file 'product_metel/metel_wizard.xml' | |||
481 | --- product_metel/metel_wizard.xml 1970-01-01 00:00:00 +0000 | |||
482 | +++ product_metel/metel_wizard.xml 2010-02-13 11:58:12 +0000 | |||
483 | @@ -0,0 +1,17 @@ | |||
484 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
485 | 2 | <openerp> | ||
486 | 3 | <data> | ||
487 | 4 | <wizard | ||
488 | 5 | id="wizard_metel_pricelist" | ||
489 | 6 | string="Import Metel pricelist file" | ||
490 | 7 | model="ir.module.module" | ||
491 | 8 | name="metel.pricelist" /> | ||
492 | 9 | |||
493 | 10 | <menuitem | ||
494 | 11 | parent="product.menu_product_pricelist_main" | ||
495 | 12 | name="Import Metel Pricelist file" | ||
496 | 13 | type="wizard" | ||
497 | 14 | action="wizard_metel_pricelist" | ||
498 | 15 | id="menu_metel_import_action"/> | ||
499 | 16 | </data> | ||
500 | 17 | </openerp> | ||
501 | 0 | \ No newline at end of file | 18 | \ No newline at end of file |
502 | 1 | 19 | ||
503 | === added directory 'product_metel/test' | |||
504 | === added file 'product_metel/test/metel-test.py' | |||
505 | --- product_metel/test/metel-test.py 1970-01-01 00:00:00 +0000 | |||
506 | +++ product_metel/test/metel-test.py 2010-02-13 11:58:12 +0000 | |||
507 | @@ -0,0 +1,58 @@ | |||
508 | 1 | ############################################################################## | ||
509 | 2 | # TRACCIATO FILE LISTINO METEL (ver 020) | ||
510 | 3 | # | ||
511 | 4 | # pos descrizione campo column tipo e lunghezza del campo | ||
512 | 5 | # 1 Sigla Marchio 1 M An 03 | ||
513 | 6 | # 2 Codice Prodotto Produttore 4 M An 16 | ||
514 | 7 | # 3 Codice EAN 20 O N 13 | ||
515 | 8 | # 4 Descrizione prodotto 33 M An 43 | ||
516 | 9 | # 5 Quantita cartone 76 M N 05 | ||
517 | 10 | # 6 Quantita multipla ordinazione 81 M N 05 | ||
518 | 11 | # 7 Quantita minima ordinazione 86 M N 05 | ||
519 | 12 | # 8 Quantita massima ordinazione 91 M N 06 | ||
520 | 13 | # 9 Lead Time 97 M An 1 | ||
521 | 14 | # 10 Prezzo al grossista 98 M N 11.2 | ||
522 | 15 | # 11 Prezzo al Pubblico 109 M N 11.2 | ||
523 | 16 | # 12 Moltiplicatore prezzo 120 M N 06 | ||
524 | 17 | # 13 Codice Valuta 126 M A 03 | ||
525 | 18 | # 14 Unita di misura 129 M An 03 | ||
526 | 19 | # 15 Prodotto Composto 132 M N 01 | ||
527 | 20 | # 16 Stato del prodotto 133 M An 01 | ||
528 | 21 | # 17 Data ultima variazione 134 M Dt | ||
529 | 22 | # 18 Famiglia di sconto 142 O An 18 | ||
530 | 23 | # 19 Famiglia statistica 160 O An 18 | ||
531 | 24 | # Lunghezza Record 177 bytes seguito da un fine riga (CR+LF = Carriage Return e Line feed) | ||
532 | 25 | # | ||
533 | 26 | ############################################################################## | ||
534 | 27 | |||
535 | 28 | import datetime | ||
536 | 29 | |||
537 | 30 | f = open(r'Beclsp09.txt') | ||
538 | 31 | |||
539 | 32 | line = f.readline() | ||
540 | 33 | metel = line[0:20].strip() | ||
541 | 34 | prod = line[20:23] | ||
542 | 35 | desc = line[56:125].strip() | ||
543 | 36 | date_start = datetime.date(int(line[40:44]), int(line[44:46]), int(line[46:48])) | ||
544 | 37 | last_change = datetime.date(int(line[48:52]), int(line[52:54]), int(line[54:56])) | ||
545 | 38 | |||
546 | 39 | print prod, "\t", desc, "\t", date_start, " last changed ", last_change | ||
547 | 40 | |||
548 | 41 | for line in f: | ||
549 | 42 | prod = line[0:3] | ||
550 | 43 | code = line[3:19].strip() | ||
551 | 44 | desc = line[32:75].strip() | ||
552 | 45 | qmin = int(line[85:90].strip()) | ||
553 | 46 | leadtime = line[96:97] | ||
554 | 47 | price1 = float(line[97:108].strip()) / 100 | ||
555 | 48 | price2 = float(line[108:119].strip()) / 100 | ||
556 | 49 | price_multi = float(line[119:125].strip()); | ||
557 | 50 | price1 /= price_multi | ||
558 | 51 | price2 /= price_multi | ||
559 | 52 | |||
560 | 53 | family_discount = line[141:159].strip() | ||
561 | 54 | family_stat = line[159:177].strip() | ||
562 | 55 | print prod, " ", code, "\t", qmin, "\t", leadtime, "\t", price_multi, "\t", family_discount, "\t", family_stat, "\t", price1, "\t", price2, "\t", desc | ||
563 | 56 | |||
564 | 57 | |||
565 | 58 | f.close() | ||
566 | 0 | \ No newline at end of file | 59 | \ No newline at end of file |
567 | 1 | 60 | ||
568 | === added directory 'product_metel/wizard' | |||
569 | === added file 'product_metel/wizard/__init__.py' | |||
570 | --- product_metel/wizard/__init__.py 1970-01-01 00:00:00 +0000 | |||
571 | +++ product_metel/wizard/__init__.py 2010-02-13 11:58:12 +0000 | |||
572 | @@ -0,0 +1,28 @@ | |||
573 | 1 | # -*- encoding: utf-8 -*- | ||
574 | 2 | ############################################################################## | ||
575 | 3 | # | ||
576 | 4 | # OpenERP, Open Source Management Solution | ||
577 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved | ||
578 | 6 | # $Id$ | ||
579 | 7 | # | ||
580 | 8 | # This program is free software: you can redistribute it and/or modify | ||
581 | 9 | # it under the terms of the GNU General Public License as published by | ||
582 | 10 | # the Free Software Foundation, either version 3 of the License, or | ||
583 | 11 | # (at your option) any later version. | ||
584 | 12 | # | ||
585 | 13 | # This program is distributed in the hope that it will be useful, | ||
586 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
587 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
588 | 16 | # GNU General Public License for more details. | ||
589 | 17 | # | ||
590 | 18 | # You should have received a copy of the GNU General Public License | ||
591 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
592 | 20 | # | ||
593 | 21 | ############################################################################## | ||
594 | 22 | |||
595 | 23 | |||
596 | 24 | import wizard_metel_import | ||
597 | 25 | import metel_import | ||
598 | 26 | |||
599 | 27 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
600 | 28 | |||
601 | 0 | 29 | ||
602 | === added file 'product_metel/wizard/metel_import.py' | |||
603 | --- product_metel/wizard/metel_import.py 1970-01-01 00:00:00 +0000 | |||
604 | +++ product_metel/wizard/metel_import.py 2010-02-13 11:58:12 +0000 | |||
605 | @@ -0,0 +1,244 @@ | |||
606 | 1 | # -*- encoding: utf-8 -*- | ||
607 | 2 | ############################################################################## | ||
608 | 3 | # | ||
609 | 4 | # Copyright (c) 2010 Luigi Grilli (luigi.grilli at gmail.com) | ||
610 | 5 | # All Rights Reserved. | ||
611 | 6 | # | ||
612 | 7 | # This program is free software: you can redistribute it and/or modify | ||
613 | 8 | # it under the terms of the GNU General Public License as published by | ||
614 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
615 | 10 | # (at your option) any later version. | ||
616 | 11 | # | ||
617 | 12 | # This program is distributed in the hope that it will be useful, | ||
618 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
619 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
620 | 15 | # GNU General Public License for more details. | ||
621 | 16 | # | ||
622 | 17 | # You should have received a copy of the GNU General Public License | ||
623 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
624 | 19 | # | ||
625 | 20 | ############################################################################## | ||
626 | 21 | |||
627 | 22 | |||
628 | 23 | import pooler | ||
629 | 24 | import time | ||
630 | 25 | import datetime | ||
631 | 26 | import netsvc | ||
632 | 27 | import base64 | ||
633 | 28 | import tools | ||
634 | 29 | import threading | ||
635 | 30 | from osv import fields, osv | ||
636 | 31 | from tools.translate import _ | ||
637 | 32 | from tempfile import TemporaryFile | ||
638 | 33 | from tools.misc import debug | ||
639 | 34 | |||
640 | 35 | class MetelImport(threading.Thread): | ||
641 | 36 | def Init(self, cr, uid, data): | ||
642 | 37 | self.uid = uid | ||
643 | 38 | |||
644 | 39 | self.dbname = cr.dbname | ||
645 | 40 | self.pool = pooler.get_pool(cr.dbname) | ||
646 | 41 | self.cr = cr | ||
647 | 42 | |||
648 | 43 | self.uo_new = 0 | ||
649 | 44 | self.uo_update = 0 | ||
650 | 45 | self.SetFile(data) | ||
651 | 46 | |||
652 | 47 | return self.ReadMetelHeader() | ||
653 | 48 | |||
654 | 49 | def SetFile(self, data): | ||
655 | 50 | self.fileobj = TemporaryFile() | ||
656 | 51 | self.fileobj.write( data ) | ||
657 | 52 | self.fileobj.seek(0) | ||
658 | 53 | return | ||
659 | 54 | |||
660 | 55 | def run(self): | ||
661 | 56 | self.cr = pooler.get_db(self.dbname).cursor() | ||
662 | 57 | self.pool = pooler.get_pool(self.cr.dbname) | ||
663 | 58 | |||
664 | 59 | self.ImportFile() | ||
665 | 60 | |||
666 | 61 | body = _("Imported products: %d \nUpdated products: %d") % (self.uo_new, self.uo_update) | ||
667 | 62 | request = self.pool.get('res.request') | ||
668 | 63 | request.create(self.cr, self.uid, { | ||
669 | 64 | 'name': _("Metel Import Completed"), | ||
670 | 65 | 'act_from': self.uid, | ||
671 | 66 | 'act_to': self.uid, | ||
672 | 67 | 'ref_partner_id': self.partner_id, | ||
673 | 68 | 'state': 'waiting', | ||
674 | 69 | 'body': body, | ||
675 | 70 | 'active': True, | ||
676 | 71 | }) | ||
677 | 72 | |||
678 | 73 | self.cr.commit() | ||
679 | 74 | self.cr.close() | ||
680 | 75 | |||
681 | 76 | return | ||
682 | 77 | |||
683 | 78 | def ReadMetelHeader(self): | ||
684 | 79 | line = self.fileobj.readline() | ||
685 | 80 | self.metel = line[0:20].strip() | ||
686 | 81 | self.prod = line[20:23] | ||
687 | 82 | self.desc = line[56:125].strip() | ||
688 | 83 | self.date_start = datetime.date(int(line[40:44]), int(line[44:46]), int(line[46:48])) | ||
689 | 84 | self.last_change = datetime.date(int(line[48:52]), int(line[52:54]), int(line[54:56])) | ||
690 | 85 | |||
691 | 86 | # is there a matching partner? | ||
692 | 87 | partner_ids = self.pool.get('res.partner').search(self.cr, self.uid, [('metel_code', '=', self.prod)]) | ||
693 | 88 | |||
694 | 89 | if partner_ids: | ||
695 | 90 | self.partner_id = partner_ids[0] | ||
696 | 91 | #get partner record | ||
697 | 92 | self.partner_obj = self.pool.get('res.partner').browse(self.cr, self.uid, partner_ids) | ||
698 | 93 | if self.partner_obj[0].metel_category: | ||
699 | 94 | self.cat_id = self.partner_obj[0].metel_category.id | ||
700 | 95 | return 1 | ||
701 | 96 | |||
702 | 97 | return -2 | ||
703 | 98 | else: | ||
704 | 99 | self.partner_id = 0 | ||
705 | 100 | self.partner_obj = None | ||
706 | 101 | self.cat_id = 0 | ||
707 | 102 | |||
708 | 103 | return -1 | ||
709 | 104 | |||
710 | 105 | def GetDiscountFamily(self, name): | ||
711 | 106 | '''Get the category that match the specified discount family, in not found create it | ||
712 | 107 | |||
713 | 108 | Args: | ||
714 | 109 | name: Discount family name | ||
715 | 110 | |||
716 | 111 | Returns: | ||
717 | 112 | The category ID of the product | ||
718 | 113 | ''' | ||
719 | 114 | if len(name) > 0: | ||
720 | 115 | #is there a matching category ? | ||
721 | 116 | family_id = self.pool.get('product.category').search(self.cr, self.uid, [('name', '=', name), ("parent_id", '=', self.cat_id)]) | ||
722 | 117 | |||
723 | 118 | # family found | ||
724 | 119 | if family_id: | ||
725 | 120 | return family_id[0] | ||
726 | 121 | #family discount not found, create it | ||
727 | 122 | else: | ||
728 | 123 | return self.pool.get('product.category').create(self.cr, self.uid, | ||
729 | 124 | { | ||
730 | 125 | 'name': name, | ||
731 | 126 | 'parent_id': self.cat_id, | ||
732 | 127 | }) | ||
733 | 128 | |||
734 | 129 | #if category name is empty return the main import category ID | ||
735 | 130 | return self.cat_id | ||
736 | 131 | |||
737 | 132 | def GetUOM(self, uom): | ||
738 | 133 | '''Get the unity of measure specified, in not found create it | ||
739 | 134 | |||
740 | 135 | Args: | ||
741 | 136 | name: UOM name | ||
742 | 137 | |||
743 | 138 | Returns: | ||
744 | 139 | The UOM ID of the product | ||
745 | 140 | ''' | ||
746 | 141 | |||
747 | 142 | if len(uom) <= 0: | ||
748 | 143 | return 0 | ||
749 | 144 | |||
750 | 145 | #is there a matching category ? | ||
751 | 146 | uom_id = self.pool.get('product.uom').search(self.cr, self.uid, [('name', '=', uom)]) | ||
752 | 147 | |||
753 | 148 | if uom_id: | ||
754 | 149 | return uom_id[0] | ||
755 | 150 | else: | ||
756 | 151 | uom_cat_ids = self.pool.get('product.uom.categ').search(self.cr, self.uid, [('name', '=', 'Unit')]) | ||
757 | 152 | return self.pool.get('product.uom').create(self.cr, self.uid, | ||
758 | 153 | { | ||
759 | 154 | 'name': uom, | ||
760 | 155 | 'category_id': uom_cat_ids[0], | ||
761 | 156 | }) | ||
762 | 157 | |||
763 | 158 | return 0 | ||
764 | 159 | |||
765 | 160 | def ImportFile(self): | ||
766 | 161 | if self.partner_id > 0: | ||
767 | 162 | #Import Products | ||
768 | 163 | for line in self.fileobj: | ||
769 | 164 | self.ImportRow(line) | ||
770 | 165 | return | ||
771 | 166 | |||
772 | 167 | def ImportRow(self, line): | ||
773 | 168 | prod = line[0:3] | ||
774 | 169 | code = line[3:19].strip() | ||
775 | 170 | ean13 = line[19:32] | ||
776 | 171 | desc = line[32:75].strip() | ||
777 | 172 | qmin = int(line[85:90].strip()) | ||
778 | 173 | leadtime = line[96:97] | ||
779 | 174 | price1 = float(line[97:108].strip()) / 100 | ||
780 | 175 | price2 = float(line[108:119].strip()) / 100 | ||
781 | 176 | price_multi = float(line[119:125].strip()); | ||
782 | 177 | price1 /= price_multi | ||
783 | 178 | price2 /= price_multi | ||
784 | 179 | uom = line[128:131].strip() | ||
785 | 180 | family_discount = line[141:159].strip() | ||
786 | 181 | family_stat = line[159:177].strip() | ||
787 | 182 | |||
788 | 183 | if len(code) <= 0: | ||
789 | 184 | return | ||
790 | 185 | |||
791 | 186 | print "code:", code, " partner_id:", self.partner_id | ||
792 | 187 | # is there a matching product ? | ||
793 | 188 | product_id = self.pool.get('product.product').search(self.cr, self.uid, [('manufacturer', '=', self.partner_id), ("manufacturer_pref", '=', code)]) | ||
794 | 189 | |||
795 | 190 | # product found, update it | ||
796 | 191 | if product_id: | ||
797 | 192 | self.uo_update += 1 | ||
798 | 193 | product = self.pool.get('product.product').write(self.cr, self.uid, product_id[0], {'standard_price': price1}) | ||
799 | 194 | |||
800 | 195 | # is there a matching supplier info ? | ||
801 | 196 | supplier_id = self.pool.get('product.supplierinfo').search(self.cr, self.uid, [('product_id', '=', product_id[0])]) | ||
802 | 197 | |||
803 | 198 | #updated supplier info with leadtime and minimun quantity | ||
804 | 199 | if supplier_id: | ||
805 | 200 | supplier = self.pool.get('product.supplierinfo').write(self.cr, self.uid, supplier_id[0], {'qty': qmin, 'delay': leadtime}) | ||
806 | 201 | # create the supplier info for the manufacturer | ||
807 | 202 | else: | ||
808 | 203 | supplier = self.pool.get('product.supplierinfo').create(self.cr, self.uid, | ||
809 | 204 | { | ||
810 | 205 | 'product_id': product_id[0], | ||
811 | 206 | 'qty': qmin, | ||
812 | 207 | 'delay': leadtime, | ||
813 | 208 | 'name': self.partner_id, | ||
814 | 209 | 'product_code': code, | ||
815 | 210 | 'product_name': desc, | ||
816 | 211 | }) | ||
817 | 212 | |||
818 | 213 | #product not found, create it. we use the code and the description of the manufacturer | ||
819 | 214 | else: | ||
820 | 215 | self.uo_new += 1 | ||
821 | 216 | |||
822 | 217 | product_cat = self.GetDiscountFamily(family_discount) | ||
823 | 218 | product_uom = self.GetUOM(uom) | ||
824 | 219 | |||
825 | 220 | product = self.pool.get('product.product').create(self.cr, self.uid, | ||
826 | 221 | { | ||
827 | 222 | 'default_code': code, | ||
828 | 223 | 'name': desc, | ||
829 | 224 | 'ean13': ean13, | ||
830 | 225 | 'manufacturer': self.partner_id, | ||
831 | 226 | 'manufacturer_pref': code, | ||
832 | 227 | 'manufacturer_pname': desc, | ||
833 | 228 | 'standard_price': price1, | ||
834 | 229 | 'list_price': price2, | ||
835 | 230 | 'categ_id': product_cat, | ||
836 | 231 | 'uom_id': product_uom, | ||
837 | 232 | 'uom_po_id': product_uom, | ||
838 | 233 | }) | ||
839 | 234 | |||
840 | 235 | # create the supplier info for the manufacturer | ||
841 | 236 | supplier = self.pool.get('product.supplierinfo').create(self.cr, self.uid, | ||
842 | 237 | { | ||
843 | 238 | 'product_id': product, | ||
844 | 239 | 'qty': qmin, | ||
845 | 240 | 'delay': leadtime, | ||
846 | 241 | 'name': self.partner_id, | ||
847 | 242 | 'product_code': code, | ||
848 | 243 | 'product_name': desc, | ||
849 | 244 | }) | ||
850 | 0 | 245 | ||
851 | === added file 'product_metel/wizard/wizard_metel_import.py' | |||
852 | --- product_metel/wizard/wizard_metel_import.py 1970-01-01 00:00:00 +0000 | |||
853 | +++ product_metel/wizard/wizard_metel_import.py 2010-02-13 11:58:12 +0000 | |||
854 | @@ -0,0 +1,105 @@ | |||
855 | 1 | # -*- encoding: utf-8 -*- | ||
856 | 2 | ############################################################################## | ||
857 | 3 | # | ||
858 | 4 | # Copyright (c) 2009 Luigi Grilli (luigi.grilli at gmail.com) | ||
859 | 5 | # All Rights Reserved. | ||
860 | 6 | # | ||
861 | 7 | # This program is free software: you can redistribute it and/or modify | ||
862 | 8 | # it under the terms of the GNU General Public License as published by | ||
863 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
864 | 10 | # (at your option) any later version. | ||
865 | 11 | # | ||
866 | 12 | # This program is distributed in the hope that it will be useful, | ||
867 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
868 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
869 | 15 | # GNU General Public License for more details. | ||
870 | 16 | # | ||
871 | 17 | # You should have received a copy of the GNU General Public License | ||
872 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
873 | 19 | # | ||
874 | 20 | ############################################################################## | ||
875 | 21 | |||
876 | 22 | |||
877 | 23 | import pooler | ||
878 | 24 | import time | ||
879 | 25 | import datetime | ||
880 | 26 | import wizard | ||
881 | 27 | import netsvc | ||
882 | 28 | import base64 | ||
883 | 29 | import tools | ||
884 | 30 | from osv import fields, osv | ||
885 | 31 | from tools.translate import _ | ||
886 | 32 | from tempfile import TemporaryFile | ||
887 | 33 | from tools.misc import debug | ||
888 | 34 | import metel_import | ||
889 | 35 | |||
890 | 36 | _finish_form ="""<?xml version="1.0"?> | ||
891 | 37 | <form string="Metel pricelist import"> | ||
892 | 38 | <separator string="Metel pricelist import report" colspan="4" /> | ||
893 | 39 | <field name="uo_message"/> | ||
894 | 40 | </form>""" | ||
895 | 41 | |||
896 | 42 | _ask_form ="""<?xml version="1.0"?> | ||
897 | 43 | <form string="Metel pricelist import"> | ||
898 | 44 | <label string="Please select metel pricelist file to import." colspan="4"/> | ||
899 | 45 | <field name="metel_file"/> | ||
900 | 46 | </form>""" | ||
901 | 47 | |||
902 | 48 | _ask_fields = { | ||
903 | 49 | 'metel_file': {'string': 'Metel pricelist file', 'type': 'binary', 'required': True}, | ||
904 | 50 | } | ||
905 | 51 | |||
906 | 52 | _finish_fields = { | ||
907 | 53 | 'uo_message': {'string':'Status', 'readonly': True, 'type':'text'}, | ||
908 | 54 | } | ||
909 | 55 | |||
910 | 56 | class metel_import_pricelist(wizard.interface): | ||
911 | 57 | def ImportPriceList(self, cr, uid, data, context): | ||
912 | 58 | '''Import the pricelist from a Metel file, creating products where needed | ||
913 | 59 | |||
914 | 60 | Returns: | ||
915 | 61 | uo_message: Messagge for the user | ||
916 | 62 | ''' | ||
917 | 63 | |||
918 | 64 | |||
919 | 65 | #initialization | ||
920 | 66 | metel = metel_import.MetelImport() | ||
921 | 67 | execute = metel.Init(cr, uid, base64.decodestring(data['form']['metel_file'])) | ||
922 | 68 | |||
923 | 69 | if execute == 1: | ||
924 | 70 | metel.start() | ||
925 | 71 | uo_message = _("Import operation in progress") | ||
926 | 72 | elif execute == -1: | ||
927 | 73 | uo_message = _("Error: could not find a partner with this metel code: %s") % metel.prod | ||
928 | 74 | elif execute == -2: | ||
929 | 75 | uo_message = _("Error: no import category defined for the partner.") | ||
930 | 76 | |||
931 | 77 | return {'uo_message': uo_message} | ||
932 | 78 | |||
933 | 79 | states = { | ||
934 | 80 | 'init': { | ||
935 | 81 | 'actions': [], | ||
936 | 82 | 'result': { | ||
937 | 83 | 'type': 'form', | ||
938 | 84 | 'arch': _ask_form, | ||
939 | 85 | 'fields': _ask_fields, | ||
940 | 86 | 'state': [ | ||
941 | 87 | ('end', 'Cancel', 'gtk-cancel'), | ||
942 | 88 | ('import', 'Import pricelist', 'gtk-ok', True) | ||
943 | 89 | ] | ||
944 | 90 | } | ||
945 | 91 | }, | ||
946 | 92 | 'import': { | ||
947 | 93 | 'actions': [ImportPriceList], | ||
948 | 94 | 'result': { | ||
949 | 95 | 'type': 'form', | ||
950 | 96 | 'arch': _finish_form, | ||
951 | 97 | 'fields': _finish_fields, | ||
952 | 98 | 'state': [('end','End')] | ||
953 | 99 | } | ||
954 | 100 | }, | ||
955 | 101 | } | ||
956 | 102 | metel_import_pricelist("metel.pricelist") | ||
957 | 103 | |||
958 | 104 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
959 | 105 |
Metel pricelists import module