0
機能していない書き込みそれは情報をもたらしますが、それは保存しません。は、私はそれがに起こっているのを知っている</p> <p>...私が働いている.WRITE私の他のモジュールでは、res.partnerのためにだけ、このファイルに情報を変更しようとすると、私は問題を抱えているOdoo 8
また、以前は機能していましたが、明白な理由がないため、これ以上動作しません。
誰もがそれを引き起こす可能性があると考えていますか?
# -*- 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
ありがとうございました! – Zada1100
あなたは大歓迎です! –