Ich habe ein Problem, wenn ich versuche, Informationen für eine res.partner zu ändern, sondern nur in dieser Datei in meinen anderen Modulen .WRITE funktioniert ...schreiben funktioniert nicht Odoo 8
Ich weiß, es wird in die schreiben und es bringt die Informationen, aber es spart einfach nicht.
Es funktionierte auch vorher, aber ohne ersichtlichen Grund funktioniert es nicht mehr.
Jeder hat eine Idee von was könnte das möglicherweise verursachen?
# -*- coding: utf-8 -*-
from openerp import models, fields, api, tools, exceptions
from openerp.exceptions import Warning
import json, urllib, time
class MAJClientsWizard(models.Model):
_name = "maj.clients"
@api.one
def maj_clients(self):
erreur = ""
clients = self.env["res.partner"].search([['is_company', '=', True], ['customer', '=', True]])
for client in clients:
retour = maj_coordonnees(client)
if retour:
erreur += retour + ", "
if erreur:
raise Warning("Les détaillants qui ont une erreur dans leur code postal sont: ", erreur, "Tous les autres ont été mis à jour!")
else:
raise Warning("Tous les détaillants ont été mis à jour avec succès!")
def maj_coordonnees(client):
if client.date_localization < time.strftime("%Y-%m-%d"):
if client.zip:
result = geo_find(client.zip)
if result:
client.write({
'partner_latitude': result[0],
'partner_longitude': result[1],
'date_localization': (time.strftime("%Y-%m-%d"))
})
else:
return client.name
else:
return client.name
def geo_find(addr):
url = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=false&key=*****&address='
url += urllib.quote(addr.encode('utf8'))
try:
result = json.load(urllib.urlopen(url))
except Exception, e:
return 'Network error, Cannot contact geolocation servers. Please make sure that your internet connection is up and running (%s).' + e
if result['status'] != 'OK':
return None
try:
geo = result['results'][0]['geometry']['location']
return float(geo['lat']), float(geo['lng'])
except (KeyError, ValueError):
return None
Danke, dass es jetzt funktioniert! – Zada1100
Gern geschehen! –