Skip to content

Instantly share code, notes, and snippets.

@martintamare
Created February 10, 2024 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martintamare/8f9f2fa7f5dbb1519158b652a9c75287 to your computer and use it in GitHub Desktop.
Save martintamare/8f9f2fa7f5dbb1519158b652a9c75287 to your computer and use it in GitHub Desktop.
Account.move read error
#!/usr/bin/env python
# -*-coding:utf-8 -*
import xmlrpc.client
from alkivi.config import ConfigManager
from xmlrpc.client import Fault, ProtocolError
import time
config = ConfigManager("odoo")
endpoint = config.get("default", "endpoint")
url = config.get(endpoint, "url")
port = config.get(endpoint, "port")
protocol = config.get(endpoint, "protocol")
version = config.get(endpoint, "version")
user = config.get(endpoint, "user")
password = config.get(endpoint, "password")
db = config.get(endpoint, "db")
url = f"https://{url}"
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
print(common.version())
uid = common.authenticate(db, user, password, {})
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
fields = models.execute_kw(db, uid, password, 'account.move', 'fields_get', [], {})
# Testing field one by one
for field, field_data in fields.items():
stop = False
while not stop:
try:
data = models.execute_kw(db, uid, password, 'account.move', 'read', [[49928]], {'fields': [field]})
print(f"{field} OK")
stop = True
except Fault as e:
print(f"Error on {field=} {e}")
stop = True
except ProtocolError as e:
time.sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment