Skip to Content
Menu
This question has been flagged
1 Reply
2659 Views

Hi i have a Problem :
I made a Modul for Odoo (Ver. 9 ) , this Modul Imports Products over Itscope API and XMLRPC.
When i want to install this Modul , Odoo is only loading a long time.
This is the Loading Screen :
 https://picload.org/image/rarigcra/modul.png
The folder structure is:
     - ->demo:
         -->demo.xml
    -->models:
       -->__init__.py
       -->models.py
      -->models.xml
   -->security:
       -->ir.model.access.csv
   -->__init__.py
  -->__openerp__.py
This are the Files:
models.py

# -*- encoding: utf-8 -*-
#Description: ITScope Modul für Odoo
#Dev: Patrick Mitteregger
from openerp import osv, fields, api
from openerp.tools.translate import _
from httplib import *
from base64 import b64encode
import libxml2import
xmlrpcliburl = 'XXXXXXXXXXX'
username = 'XXXXXX'
pwd = 'XXXXXXXXXX'
dbname = 'XXXXXXXXX'
sock_common = xmlrpclib.ServerProxy('{}/xmlrpc/common'.format(url))
login = sock_common.login(dbname,username,pwd)
sock = xmlrpclib.ServerProxy('{}/xmlrpc/object'.format(url))
product = 'product.template'
accountID = "XXXXXX"
apiKey = "XXXXXXXX"
ean = 0
class product_search(osv.osv):
########################################################################
#Auswahl des Nutzers (Über Formular) auslesen und in Variablen speichern#
#########################################################################
_name = 'itscope_modul.itscope_modul'
eanumber = fields.Float('EAN',required=True,string="Ean")
language = fields.Char('Language',default="de",string="lang")
@api.one def
search_prod():
#########################################################################
#Mit der ItScope API verbinden und die Infos vom Produkt holen #
 #########################################################################
try:
headers = {'Authorization' : 'Basic %s' % base64.b64encode(accountID+ ':'+ apiKey), 'Accept-Language' : language}
url = "https://api.itscope.com/2.0" Get = "/products/ean/" + eanumber + "/standard." + "xml"
req = urllib2.Request(url + Get,headers=headers)
response = urllib2.urlopen(req)
itscope = response.read()
xmlread = libxml2.parseDoc(itscope)
# Antwort-XML Feld auswahl
eancode = xmlread.xpathEval('/products/product/ean')
prodname = xmlread.xpathEval('/products/product/supplierItems/supplierItem/productName')
manuf = xmlread.xpathEval('/products/product/supplierItems/supplierItem/manufacturerName ')
description = xmlread.xpathEval('/products/product/longDescription')
pricelist = xmlread.xpathEval('/products/product/price')
except Exception,e:
print str(e)
#########################################################################
#Die Infos zum Produkt in die Datenbank eintragen #
#########################################################################
try:
product_colum={ 'barcode': eancode[0].content, 'name' : prodname[0].content, 'list_price' : pricelist[0].content, 'manufacture': manuf[0].content, 'description_sale' : description[0].content }
prodimport = sock.execute(dbname,login,pwd,product,'create',product_colum)
print "Produkt wurde erfolgreich eingetragen"
except Exception ,e :
print str(e)

models.xml:

<?xml version='1.0' encoding='utf-8'?>
<openerp>
<data>
<record id="itscope_modul_wizard" model="ir.ui.view">
<field name="name">itscope.modul.wizard.form</field>
<field name="model">itscope.modul.wizard</field>
<field name="arch" type="xml">
<form string="Import Itscope" version="0.1">
<group col="4" colspan="4" attrs="{'invisible':[('state','=','done')]}">
<label string="Willkommen beim Itscope Import" colspan="4"/>
<field name="Ean"/><newline/>
<field name="Language"/><newline/>
 </group>
<group col="2" colspan="4">
<field name="state" invisible="1"/>
<button string="Cancel" special="cancel" icon="gtk-cancel" states="first"/>
<button string="import" name="search_prod" type="object" icon="gtk-ok" states="first"/>
<button string="Close" special="cancel" icon="gtk-ok" states="done"/>
</group>
</form>
</field>
</record>
<act_window name="Import Itscope" res_model="itscope.modul.wizard" src_model="product.product" view_mode="form" target="new" key2="client_action_multi" id="itscope_modul_act"/>
</data>
</openerp>
Avatar
Discard
Author Best Answer

I solved the Problem. The Problem was the installed Odoo not my Module.

Avatar
Discard
Related Posts Replies Views Activity
1
Jun 21
4105
0
Jan 24
2991
3
Feb 20
1300
2
Dec 15
4341
3
Aug 21
2552