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