← Back to team overview

openerp-chinese-team team mailing list archive

[Merge] lp:~luigi.grilli/openobject-addons/product_metel into lp:~openerp-community/openobject-addons/trunk-addons-community

 

Luigi Grilli has proposed merging lp:~luigi.grilli/openobject-addons/product_metel into lp:~openerp-community/openobject-addons/trunk-addons-community.

    Requested reviews:
    OpenERP Core Team (openerp)


Metel pricelists import module
-- 
https://code.launchpad.net/~luigi.grilli/openobject-addons/product_metel/+merge/19266
Your team OpenERP & OpenObject Community is subscribed to branch lp:~openerp-community/openobject-addons/trunk-addons-community.
=== added directory 'product_metel'
=== added file 'product_metel/__init__.py'
--- product_metel/__init__.py	1970-01-01 00:00:00 +0000
+++ product_metel/__init__.py	2010-02-13 11:58:12 +0000
@@ -0,0 +1,35 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2009 Luigi Grilli (luigi.grilli at gmail.com)
+#                          All Rights Reserved.
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+# I used the code of account_bankimport as base for this module.
+#
+# This module can import metel formatted files (see www.metel.it)
+#
+
+import wizard
+import metel

=== added file 'product_metel/__terp__.py'
--- product_metel/__terp__.py	1970-01-01 00:00:00 +0000
+++ product_metel/__terp__.py	2010-02-13 11:58:12 +0000
@@ -0,0 +1,45 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2009 Luigi Grilli (luigi.grilli at gmail.com)
+#                          All Rights Reserved.
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+# I used the code of account_bankimport as base for this module.
+#
+# This module can import metel formatted files (see www.metel.it)
+#
+
+{
+	"name":"Metel Listprice Import/Export",
+	"version":"0.0.1",
+	"author":"Luigi Grilli",
+	"category":"Generic Modules/Others",
+	"description":"Import and export Metel formatted pricelist",
+	"depends":["base", "product_electronic"],
+	"init_xml":[],
+	"update_xml" : ["metel_view.xml", "metel_wizard.xml"],
+	"active":False,
+	"installable":True,
+}

=== added directory 'product_metel/i18n'
=== added file 'product_metel/i18n/it_IT.po'
--- product_metel/i18n/it_IT.po	1970-01-01 00:00:00 +0000
+++ product_metel/i18n/it_IT.po	2010-02-13 11:58:12 +0000
@@ -0,0 +1,148 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* product_metel
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 5.0.6\n"
+"Report-Msgid-Bugs-To: support@xxxxxxxxxxx\n"
+"POT-Creation-Date: 2010-02-13 08:49:31+0000\n"
+"PO-Revision-Date: 2010-02-13 08:49:31+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: product_metel
+#: model:ir.module.module,description:product_metel.module_meta_information
+msgid "Import and export Metel formatted pricelist"
+msgstr "Importa ed esporta Listini Metel"
+
+#. module: product_metel
+#: wizard_button:metel.pricelist,import,end:0
+msgid "End"
+msgstr "Fine"
+
+#. module: product_metel
+#: view:res.partner:0
+msgid "Sales & Purchases"
+msgstr ""
+
+#. module: product_metel
+#: constraint:ir.model:0
+msgid "The Object name must start with x_ and not contain any special character !"
+msgstr ""
+
+#. module: product_metel
+#: wizard_view:metel.pricelist,init:0
+msgid "Please select metel pricelist file to import."
+msgstr "Selezionare il file del listino da importare"
+
+#. module: product_metel
+#: field:res.partner,metel_category:0
+msgid "Import Category"
+msgstr "Categoria importazione"
+
+#. module: product_metel
+#: code:addons\product_metel\wizard\metel_import.py:0
+#, python-format
+msgid "Metel Import Completed"
+msgstr "Importazione Metel completata"
+
+#. module: product_metel
+#: code:addons\product_metel\wizard\wizard_metel_import.py:0
+#, python-format
+msgid "Error: could not find a partner with this metel code: %s"
+msgstr "Errore: impossibile trovare un partner con questo codice metel: %s"
+
+#. module: product_metel
+#: wizard_field:metel.pricelist,import,uo_message:0
+msgid "Status"
+msgstr "Stato"
+
+#. module: product_metel
+#: code:addons\product_metel\wizard\wizard_metel_import.py:0
+#, python-format
+msgid "Error: no import category defined for the partner."
+msgstr "Errore: non è stata specificata una categoria per il partner."
+
+#. module: product_metel
+#: code:addons\product_metel\wizard\wizard_metel_import.py:0
+#, python-format
+msgid "Import operation in progress"
+msgstr "Importazione dei dati in corso"
+
+#. module: product_metel
+#: model:ir.model,name:product_metel.model_product_metel_fileimport
+msgid "product.metel.fileimport"
+msgstr ""
+
+#. module: product_metel
+#: model:ir.ui.menu,name:product_metel.menu_metel_import_action
+msgid "Import Metel Pricelist file"
+msgstr "Importa listino Metel"
+
+#. module: product_metel
+#: wizard_button:metel.pricelist,init,import:0
+msgid "Import pricelist"
+msgstr "Importa listino"
+
+#. module: product_metel
+#: field:res.partner,metel_code:0
+msgid "Metel Code"
+msgstr "Codice Metel"
+
+#. module: product_metel
+#: wizard_field:metel.pricelist,init,metel_file:0
+msgid "Metel pricelist file"
+msgstr "File del listino Metel"
+
+#. module: product_metel
+#: constraint:ir.ui.view:0
+msgid "Invalid XML for View Architecture!"
+msgstr ""
+
+#. module: product_metel
+#: model:ir.actions.wizard,name:product_metel.wizard_metel_pricelist
+msgid "Import Metel pricelist file"
+msgstr "Importa file listino Metel"
+
+#. module: product_metel
+#: field:product.metel.fileimport,tmpfilename:0
+msgid "File Metel"
+msgstr "File Metel"
+
+#. module: product_metel
+#: model:ir.module.module,shortdesc:product_metel.module_meta_information
+msgid "Metel Listprice Import/Export"
+msgstr "Importazione/Esportazione Listini Metel"
+
+#. module: product_metel
+#: view:res.partner:0
+msgid "Metel Properties"
+msgstr "Proprietà Metel"
+
+#. module: product_metel
+#: code:addons\product_metel\wizard\metel_import.py:0
+#, python-format
+msgid "Imported products: %d \nUpdated products: %d"
+msgstr "Nuovi prodotti importati: %d\Prodotti aggiornati: %d"
+
+#. module: product_metel
+#: wizard_view:metel.pricelist,import:0
+msgid "Metel pricelist import report"
+msgstr "Rapporto di importazione file Metel"
+
+#. module: product_metel
+#: wizard_button:metel.pricelist,init,end:0
+msgid "Cancel"
+msgstr "Annulla"
+
+#. module: product_metel
+#: wizard_view:metel.pricelist,import:0
+#: wizard_view:metel.pricelist,init:0
+msgid "Metel pricelist import"
+msgstr "Importazione listino Metel"
+

=== added file 'product_metel/i18n/product_metel.pot'
--- product_metel/i18n/product_metel.pot	1970-01-01 00:00:00 +0000
+++ product_metel/i18n/product_metel.pot	2010-02-13 11:58:12 +0000
@@ -0,0 +1,148 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* product_metel
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 5.0.6\n"
+"Report-Msgid-Bugs-To: support@xxxxxxxxxxx\n"
+"POT-Creation-Date: 2010-02-13 08:49:31+0000\n"
+"PO-Revision-Date: 2010-02-13 08:49:31+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: product_metel
+#: model:ir.module.module,description:product_metel.module_meta_information
+msgid "Import and export Metel formatted pricelist"
+msgstr ""
+
+#. module: product_metel
+#: wizard_button:metel.pricelist,import,end:0
+msgid "End"
+msgstr ""
+
+#. module: product_metel
+#: view:res.partner:0
+msgid "Sales & Purchases"
+msgstr ""
+
+#. module: product_metel
+#: constraint:ir.model:0
+msgid "The Object name must start with x_ and not contain any special character !"
+msgstr ""
+
+#. module: product_metel
+#: wizard_view:metel.pricelist,init:0
+msgid "Please select metel pricelist file to import."
+msgstr ""
+
+#. module: product_metel
+#: field:res.partner,metel_category:0
+msgid "Import Category"
+msgstr ""
+
+#. module: product_metel
+#: code:addons\product_metel\wizard\metel_import.py:0
+#, python-format
+msgid "Metel Import Completed"
+msgstr ""
+
+#. module: product_metel
+#: code:addons\product_metel\wizard\wizard_metel_import.py:0
+#, python-format
+msgid "Error: could not find a partner with this metel code: %s"
+msgstr ""
+
+#. module: product_metel
+#: wizard_field:metel.pricelist,import,uo_message:0
+msgid "Status"
+msgstr ""
+
+#. module: product_metel
+#: code:addons\product_metel\wizard\wizard_metel_import.py:0
+#, python-format
+msgid "Error: no import category defined for the partner."
+msgstr ""
+
+#. module: product_metel
+#: code:addons\product_metel\wizard\wizard_metel_import.py:0
+#, python-format
+msgid "Import operation in progress"
+msgstr ""
+
+#. module: product_metel
+#: model:ir.model,name:product_metel.model_product_metel_fileimport
+msgid "product.metel.fileimport"
+msgstr ""
+
+#. module: product_metel
+#: model:ir.ui.menu,name:product_metel.menu_metel_import_action
+msgid "Import Metel Pricelist file"
+msgstr ""
+
+#. module: product_metel
+#: wizard_button:metel.pricelist,init,import:0
+msgid "Import pricelist"
+msgstr ""
+
+#. module: product_metel
+#: field:res.partner,metel_code:0
+msgid "Metel Code"
+msgstr ""
+
+#. module: product_metel
+#: wizard_field:metel.pricelist,init,metel_file:0
+msgid "Metel pricelist file"
+msgstr ""
+
+#. module: product_metel
+#: constraint:ir.ui.view:0
+msgid "Invalid XML for View Architecture!"
+msgstr ""
+
+#. module: product_metel
+#: model:ir.actions.wizard,name:product_metel.wizard_metel_pricelist
+msgid "Import Metel pricelist file"
+msgstr ""
+
+#. module: product_metel
+#: field:product.metel.fileimport,tmpfilename:0
+msgid "File Metel"
+msgstr ""
+
+#. module: product_metel
+#: model:ir.module.module,shortdesc:product_metel.module_meta_information
+msgid "Metel Listprice Import/Export"
+msgstr ""
+
+#. module: product_metel
+#: view:res.partner:0
+msgid "Metel Properties"
+msgstr ""
+
+#. module: product_metel
+#: code:addons\product_metel\wizard\metel_import.py:0
+#, python-format
+msgid "Imported products: %d \nUpdated products: %d"
+msgstr ""
+
+#. module: product_metel
+#: wizard_view:metel.pricelist,import:0
+msgid "Metel pricelist import report"
+msgstr ""
+
+#. module: product_metel
+#: wizard_button:metel.pricelist,init,end:0
+msgid "Cancel"
+msgstr ""
+
+#. module: product_metel
+#: wizard_view:metel.pricelist,import:0
+#: wizard_view:metel.pricelist,init:0
+msgid "Metel pricelist import"
+msgstr ""
+

=== added file 'product_metel/metel.py'
--- product_metel/metel.py	1970-01-01 00:00:00 +0000
+++ product_metel/metel.py	2010-02-13 11:58:12 +0000
@@ -0,0 +1,50 @@
+##############################################################################
+#
+# Copyright (c) 2009 Luigi Grilli (luigi.grilli at gmail.com)
+#                          All Rights Reserved.
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+# I used the code of account_bankimport as base for this module.
+#
+# This module can import metel formatted files (see www.metel.it)
+#
+
+from osv import fields,osv
+
+class res_partner(osv.osv):
+    _inherit = 'res.partner'
+    _columns = {
+        'metel_code': fields.char('Metel Code', size=10, required=False, translate=False),
+        'metel_category': fields.many2one('product.category', 'Import Category', required=False, translate=False),
+    }
+res_partner()
+
+class metel_file(osv.osv):
+    _name = 'product.metel.fileimport'
+    _columns = {
+        'tmpfilename': fields.char('File Metel', size=255, required=True, translate=False),
+    }
+metel_file()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'product_metel/metel_view.xml'
--- product_metel/metel_view.xml	1970-01-01 00:00:00 +0000
+++ product_metel/metel_view.xml	2010-02-13 11:58:12 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <record model="ir.ui.view" id="view_partner_property_form">
+			<field name="name">res.partner.product.property.form.inherit</field>
+            <field name="model">res.partner</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="base.view_partner_form"/>
+            <field name="arch" type="xml">
+                <page string="Sales &amp; Purchases" position="inside">
+                    <group colspan="2" col="2" name="metel">
+                        <separator string="Metel Properties" colspan="2"/>
+                        <field name="metel_code"/>
+                        <field name="metel_category"/>
+                    </group>
+                </page>
+            </field>
+        </record>
+    </data>
+</openerp>
\ No newline at end of file

=== added file 'product_metel/metel_wizard.xml'
--- product_metel/metel_wizard.xml	1970-01-01 00:00:00 +0000
+++ product_metel/metel_wizard.xml	2010-02-13 11:58:12 +0000
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+		<wizard
+			id="wizard_metel_pricelist"
+			string="Import Metel pricelist file"
+            model="ir.module.module"
+			name="metel.pricelist" />
+		
+		<menuitem
+			parent="product.menu_product_pricelist_main"
+			name="Import Metel Pricelist file"
+			type="wizard"
+			action="wizard_metel_pricelist"
+			id="menu_metel_import_action"/>		
+    </data>
+</openerp>
\ No newline at end of file

=== added directory 'product_metel/test'
=== added file 'product_metel/test/metel-test.py'
--- product_metel/test/metel-test.py	1970-01-01 00:00:00 +0000
+++ product_metel/test/metel-test.py	2010-02-13 11:58:12 +0000
@@ -0,0 +1,58 @@
+##############################################################################
+# TRACCIATO FILE LISTINO METEL (ver 020)
+#
+# pos	descrizione campo				column	tipo e lunghezza del campo
+# 1		Sigla Marchio					1		M	An 03
+# 2		Codice Prodotto Produttore		4		M	An 16
+# 3		Codice EAN						20		O	N 13
+# 4		Descrizione prodotto			33		M	An 43
+# 5		Quantita cartone				76		M	N 05
+# 6		Quantita multipla ordinazione	81		M	N 05
+# 7		Quantita minima ordinazione		86		M	N 05
+# 8		Quantita massima ordinazione	91		M	N 06
+# 9		Lead Time						97		M	An 1
+# 10	Prezzo al grossista				98		M	N 11.2
+# 11	Prezzo al Pubblico				109		M	N 11.2
+# 12	Moltiplicatore prezzo			120		M	N 06
+# 13	Codice Valuta					126		M	A 03
+# 14	Unita di misura					129		M	An 03
+# 15	Prodotto Composto				132		M	N 01
+# 16	Stato del prodotto				133		M	An 01
+# 17	Data ultima variazione			134		M	Dt
+# 18	Famiglia di sconto				142		O	An 18
+# 19	Famiglia statistica				160		O	An 18
+# Lunghezza Record  177 bytes  seguito da un fine riga (CR+LF = Carriage Return e Line feed)
+# 
+##############################################################################
+
+import datetime
+
+f = open(r'Beclsp09.txt')
+
+line = f.readline()
+metel = line[0:20].strip()
+prod = line[20:23]
+desc = line[56:125].strip()
+date_start = datetime.date(int(line[40:44]), int(line[44:46]), int(line[46:48]))
+last_change = datetime.date(int(line[48:52]), int(line[52:54]), int(line[54:56]))
+
+print prod, "\t", desc, "\t", date_start, " last changed ", last_change
+
+for line in f:
+	prod = line[0:3]
+	code = line[3:19].strip()
+	desc = line[32:75].strip()
+	qmin = int(line[85:90].strip())
+	leadtime = line[96:97]
+	price1 = float(line[97:108].strip()) / 100
+	price2 = float(line[108:119].strip()) / 100
+	price_multi = float(line[119:125].strip());
+	price1 /= price_multi
+	price2 /= price_multi
+
+	family_discount = line[141:159].strip()
+	family_stat = line[159:177].strip()
+	print prod, " ", code, "\t", qmin, "\t", leadtime, "\t", price_multi, "\t", family_discount, "\t", family_stat, "\t", price1, "\t", price2, "\t", desc
+	
+
+f.close()
\ No newline at end of file

=== added directory 'product_metel/wizard'
=== added file 'product_metel/wizard/__init__.py'
--- product_metel/wizard/__init__.py	1970-01-01 00:00:00 +0000
+++ product_metel/wizard/__init__.py	2010-02-13 11:58:12 +0000
@@ -0,0 +1,28 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution	
+#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+#    $Id$
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+import wizard_metel_import
+import metel_import
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+

=== added file 'product_metel/wizard/metel_import.py'
--- product_metel/wizard/metel_import.py	1970-01-01 00:00:00 +0000
+++ product_metel/wizard/metel_import.py	2010-02-13 11:58:12 +0000
@@ -0,0 +1,244 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (c) 2010 Luigi Grilli (luigi.grilli at gmail.com)
+#                          All Rights Reserved.
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+import pooler
+import time
+import datetime
+import netsvc
+import base64
+import tools
+import threading
+from osv import fields, osv
+from tools.translate import _
+from tempfile import TemporaryFile
+from tools.misc import debug
+
+class MetelImport(threading.Thread):
+    def Init(self, cr, uid, data):
+        self.uid = uid
+        
+        self.dbname = cr.dbname
+        self.pool = pooler.get_pool(cr.dbname)
+        self.cr = cr
+        
+        self.uo_new = 0
+        self.uo_update = 0
+        self.SetFile(data)
+        
+        return self.ReadMetelHeader()
+    
+    def SetFile(self, data):
+        self.fileobj = TemporaryFile()
+        self.fileobj.write( data )
+        self.fileobj.seek(0)
+        return
+    
+    def run(self):
+        self.cr = pooler.get_db(self.dbname).cursor()
+        self.pool = pooler.get_pool(self.cr.dbname)
+
+        self.ImportFile()
+        
+        body = _("Imported products: %d \nUpdated products: %d") % (self.uo_new, self.uo_update)
+        request = self.pool.get('res.request')
+        request.create(self.cr, self.uid, {
+            'name': _("Metel Import Completed"),
+            'act_from': self.uid,
+            'act_to': self.uid,
+            'ref_partner_id': self.partner_id,
+            'state': 'waiting',
+            'body': body,
+            'active': True,
+        })
+        
+        self.cr.commit()
+        self.cr.close()
+        
+        return
+    
+    def ReadMetelHeader(self):
+        line = self.fileobj.readline()
+        self.metel = line[0:20].strip()
+        self.prod = line[20:23]
+        self.desc = line[56:125].strip()
+        self.date_start = datetime.date(int(line[40:44]), int(line[44:46]), int(line[46:48]))
+        self.last_change = datetime.date(int(line[48:52]), int(line[52:54]), int(line[54:56]))
+        
+        # is there a matching partner?
+        partner_ids = self.pool.get('res.partner').search(self.cr, self.uid, [('metel_code', '=', self.prod)])
+        
+        if partner_ids:
+            self.partner_id = partner_ids[0]
+            #get partner record
+            self.partner_obj = self.pool.get('res.partner').browse(self.cr, self.uid, partner_ids)
+            if self.partner_obj[0].metel_category:
+                self.cat_id = self.partner_obj[0].metel_category.id
+                return 1
+            
+            return -2
+        else:
+            self.partner_id = 0
+            self.partner_obj = None
+            self.cat_id = 0
+        
+        return -1
+    
+    def GetDiscountFamily(self, name):
+        '''Get the category that match the specified discount family, in not found create it
+        
+        Args:
+          name: Discount family name
+          
+        Returns:
+          The category ID of the product
+        '''
+        if len(name) > 0:
+            #is there a matching category ?
+            family_id = self.pool.get('product.category').search(self.cr, self.uid, [('name', '=', name), ("parent_id", '=', self.cat_id)])
+            
+            # family found
+            if family_id:
+                return family_id[0]
+            #family discount not found, create it
+            else:
+                return self.pool.get('product.category').create(self.cr, self.uid,
+                {
+                    'name': name,
+                    'parent_id': self.cat_id,
+                })
+        
+        #if category name is empty return the main import category ID
+        return self.cat_id
+
+    def GetUOM(self, uom):
+        '''Get the unity of measure specified, in not found create it
+        
+        Args:
+          name: UOM name
+          
+        Returns:
+          The UOM ID of the product
+        '''
+        
+        if len(uom) <= 0:
+            return 0
+        
+        #is there a matching category ?
+        uom_id = self.pool.get('product.uom').search(self.cr, self.uid, [('name', '=', uom)])
+        
+        if uom_id:
+            return uom_id[0]
+        else:
+            uom_cat_ids = self.pool.get('product.uom.categ').search(self.cr, self.uid, [('name', '=', 'Unit')])
+            return self.pool.get('product.uom').create(self.cr, self.uid,
+            {
+             'name': uom,
+             'category_id': uom_cat_ids[0],
+            })
+
+        return 0
+        
+    def ImportFile(self):
+        if self.partner_id > 0:
+            #Import Products
+            for line in self.fileobj:
+                self.ImportRow(line)
+        return
+        
+    def ImportRow(self, line):
+        prod = line[0:3]
+        code = line[3:19].strip()
+        ean13 = line[19:32]
+        desc = line[32:75].strip()
+        qmin = int(line[85:90].strip())
+        leadtime = line[96:97]
+        price1 = float(line[97:108].strip()) / 100
+        price2 = float(line[108:119].strip()) / 100
+        price_multi = float(line[119:125].strip());
+        price1 /= price_multi
+        price2 /= price_multi
+        uom = line[128:131].strip()
+        family_discount = line[141:159].strip()
+        family_stat = line[159:177].strip()
+        
+        if len(code) <= 0:
+            return
+        
+        print "code:", code, " partner_id:", self.partner_id
+        # is there a matching product ?
+        product_id = self.pool.get('product.product').search(self.cr, self.uid, [('manufacturer', '=', self.partner_id), ("manufacturer_pref", '=', code)])
+        
+        # product found, update it
+        if product_id:
+            self.uo_update += 1
+            product = self.pool.get('product.product').write(self.cr, self.uid, product_id[0], {'standard_price': price1})
+            
+            # is there a matching supplier info ?
+            supplier_id = self.pool.get('product.supplierinfo').search(self.cr, self.uid, [('product_id', '=', product_id[0])])
+            
+            #updated supplier info with leadtime and minimun quantity
+            if supplier_id:
+                supplier = self.pool.get('product.supplierinfo').write(self.cr, self.uid, supplier_id[0], {'qty': qmin, 'delay': leadtime})
+            # create the supplier info for the manufacturer
+            else:
+                supplier = self.pool.get('product.supplierinfo').create(self.cr, self.uid,
+                {
+                 'product_id': product_id[0],
+                 'qty': qmin,
+                 'delay': leadtime,
+                 'name': self.partner_id,
+                 'product_code': code,
+                 'product_name': desc,
+                })
+            
+        #product not found, create it. we use the code and the description of the manufacturer
+        else:
+            self.uo_new += 1
+            
+            product_cat = self.GetDiscountFamily(family_discount)
+            product_uom = self.GetUOM(uom)
+            
+            product = self.pool.get('product.product').create(self.cr, self.uid,
+            {
+             'default_code': code,
+             'name': desc,
+             'ean13': ean13,
+             'manufacturer': self.partner_id,
+             'manufacturer_pref': code,
+             'manufacturer_pname': desc,
+             'standard_price': price1,
+             'list_price': price2,
+             'categ_id': product_cat,
+             'uom_id': product_uom,
+             'uom_po_id': product_uom,
+            })
+            
+            # create the supplier info for the manufacturer
+            supplier = self.pool.get('product.supplierinfo').create(self.cr, self.uid,
+            {
+             'product_id': product,
+             'qty': qmin,
+             'delay': leadtime,
+             'name': self.partner_id,
+             'product_code': code,
+             'product_name': desc,
+            })

=== added file 'product_metel/wizard/wizard_metel_import.py'
--- product_metel/wizard/wizard_metel_import.py	1970-01-01 00:00:00 +0000
+++ product_metel/wizard/wizard_metel_import.py	2010-02-13 11:58:12 +0000
@@ -0,0 +1,105 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (c) 2009 Luigi Grilli (luigi.grilli at gmail.com)
+#                          All Rights Reserved.
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+import pooler
+import time
+import datetime
+import wizard
+import netsvc
+import base64
+import tools
+from osv import fields, osv
+from tools.translate import _     
+from tempfile import TemporaryFile     
+from tools.misc import debug
+import metel_import
+
+_finish_form ="""<?xml version="1.0"?>
+<form string="Metel pricelist import">
+    <separator string="Metel pricelist import report" colspan="4" />
+    <field name="uo_message"/>
+</form>"""
+
+_ask_form ="""<?xml version="1.0"?>
+<form string="Metel pricelist import">
+    <label string="Please select metel pricelist file to import." colspan="4"/>
+    <field name="metel_file"/>
+</form>"""
+
+_ask_fields = {
+    'metel_file': {'string': 'Metel pricelist file', 'type': 'binary', 'required': True},
+}
+
+_finish_fields = {
+    'uo_message': {'string':'Status', 'readonly': True, 'type':'text'},
+}
+
+class metel_import_pricelist(wizard.interface):
+    def ImportPriceList(self, cr, uid, data, context):
+        '''Import the pricelist from a Metel file, creating products where needed
+        
+        Returns:
+          uo_message: Messagge for the user
+        '''
+        
+        
+        #initialization
+        metel = metel_import.MetelImport()
+        execute = metel.Init(cr, uid, base64.decodestring(data['form']['metel_file']))
+        
+        if execute == 1:
+            metel.start()
+            uo_message = _("Import operation in progress")
+        elif execute == -1:
+            uo_message = _("Error: could not find a partner with this metel code: %s") % metel.prod
+        elif execute == -2:
+            uo_message = _("Error: no import category defined for the partner.")
+        
+        return {'uo_message': uo_message}
+
+    states = {
+        'init': {
+            'actions': [],
+            'result': {
+                'type': 'form',
+                'arch': _ask_form,
+                'fields': _ask_fields,
+                'state': [
+                    ('end', 'Cancel', 'gtk-cancel'),
+                    ('import', 'Import pricelist', 'gtk-ok', True)
+                ]
+            }
+        },
+        'import': {
+            'actions': [ImportPriceList],
+            'result': {
+                'type': 'form',
+                'arch': _finish_form,
+                'fields': _finish_fields,
+                'state': [('end','End')]
+            }
+        },
+    }
+metel_import_pricelist("metel.pricelist")
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+