record["product_id"])]["id"])

        tax_id = record.get("tax_id", False)
        if tax_id:
            record["tax_id"] = [(6, 0, [
                int(impuestos_dict[str(tax_id)]["id"])
                for tax_id in tax_id[0][2]
            ])]

        record["discount"] = round(record["discount"], 2)
    return records


#Descargar datos en Jsons
conn1 = Odoo(origin_db, origin_user, origin_pass, origin_host)
conn1.authenticate()
fields = [
    "id", "name", "product_id", "product_uom_qty", "product_uom", "price_unit",
    "tax_id", "purchase_price", "order_id", "discount", "customer_lead"
]
file_name = conn1.download_json(
    "sale.order.line",
    fields,
    domain=[["order_id", "!=", False],
            ["order_id.partner_id", "not in", [1, 2, 3, 4, 5, 6]]],
    transform=transform,
    order="id ASC",
    limit=0)

conn2 = Odoo(url=destination_host, session=destination_session)
#conn2.authenticate()
예제 #2
0
from odoo import Odoo
import json
import base64
from PIL import Image
from io import BytesIO
from datetime import datetime
import pandas as pd

#Establecer Parámetros
##################################################################
conn = Odoo(db="universal",login="******",password="******",
            url="localhost:8005",ssl=False)
##################################################################

conn.authenticate()


def fetch_product_ids(conn):
    res = conn.call_kw("product.template","search_read",[],{"domain":[],"fields":["id"]})
    return list(map(lambda r:r["id"],res))

def download_product_image(conn,product_id):
    error_logs = open("error_logs_{}.logs".format(datetime.now().strftime("%Y-%m-%d %H-%M-%S")),"w")
    res = conn.call_kw("product.template","search_read",[],{"domain":[["id","=",product_id]],"fields":["name","image"]})
    if len(res)>0:
        image_id = res[0]["id"]
        image_b64 = res[0]["image"]
        try:
            im = Image.open(BytesIO(base64.b64decode(image_b64)))
            im.save('images/{}.png'.format(image_id), 'PNG')
        except Exception as e: