119 lines
3.9 KiB
Python
119 lines
3.9 KiB
Python
# url = 'https://dnm68672.odoo.com'
|
|
# db = 'dnm68672'
|
|
# username = 'dnm68672@omeie.com'
|
|
# password = '1234567890'
|
|
# import xmlrpc.client
|
|
# # info = xmlrpc.client.ServerProxy(url).start()
|
|
# # url, db, username, password = info['host'], info['database'], info['user'], info['password']
|
|
# common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
|
|
# # print(common.version())
|
|
# uid = common.authenticate(db, username, password, {})
|
|
|
|
# if uid:
|
|
# print("success")
|
|
# else:
|
|
# print("failed")
|
|
# # id = models.execute_kw(db, username, password, 'res.partner', 'create', [{'name': "New Partner"}])
|
|
|
|
# models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
|
|
# partners = models.execute_kw(db, uid, password, 'res.partner', 'search', [[]])
|
|
|
|
# print(partners)
|
|
|
|
# # models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
|
|
# # print(models.execute_kw(db, uid, password, 'account.report_invoice_with_payments', 'create', ()))
|
|
|
|
|
|
# invoice_id = 279777
|
|
|
|
# sale_id = 16
|
|
|
|
|
|
|
|
# posted_inv = models.execute_kw(db, uid, password, 'account.move', 'action_post', [])
|
|
|
|
import xmlrpc.client
|
|
|
|
|
|
url = 'http://89.117.54.97:8069'
|
|
db = 'odoo_1'
|
|
username = 'it@aqdamy.com.sa'
|
|
password = '1234567890'
|
|
# info = xmlrpc.client.ServerProxy(url).start()
|
|
# url, db, username, password = info['host'], info['database'], info['user'], info['password']
|
|
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
|
|
# print(common.version())
|
|
uid = common.authenticate(db, username, password, {})
|
|
|
|
if uid:
|
|
print("success")
|
|
else:
|
|
print("failed")
|
|
# id = models.execute_kw(db, username, password, 'res.partner', 'create', [{'name': "New Partner"}])
|
|
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
|
|
|
|
# ------------------------- 1 product 1 invoice
|
|
|
|
# partners_id = models.execute_kw(db, uid, password, 'res.partner', 'search', [[]])
|
|
# print(partners_id)
|
|
|
|
# product_id = models.execute_kw(db, uid, password, 'product.product', 'search', [[]], {'limit':2})
|
|
# print(product_id)
|
|
|
|
# import random
|
|
# invoice_id = models.execute_kw(db, uid, password, 'account.move', 'create', [{
|
|
# 'name': '23A000003',
|
|
# 'invoice_date': '2023-02-04',
|
|
# 'invoice_date_due': '2023-02-04',
|
|
# 'partner_id': partners_id[1],
|
|
# 'ref': 'create from api',
|
|
# 'move_type': 'out_invoice',
|
|
# 'invoice_line_ids': [(0,0, {
|
|
# 'product_id': product_id[0],
|
|
# 'quantity': 1,
|
|
# })],
|
|
# }])
|
|
# print(invoice_id)
|
|
|
|
# ------------------------------------------------------------
|
|
|
|
# action_post = models.execute_kw(db, uid, password, 'account.move', 'action_post', [[invoice_id]])
|
|
# print(action_post)
|
|
|
|
# action_register_payment = models.execute_kw(db, uid, password, 'account.move', 'action_register_payment', [[29]])
|
|
# print(action_register_payment)
|
|
|
|
# fields_get = models.execute_kw(db, uid, password, 'account.move', 'fields_get', [], {'attributes': ['string', 'help', 'type']})
|
|
# print(fields_get)
|
|
|
|
# action_register_payment = models.execute_kw(db, uid, password, 'account.move', 'action_register_payment', [], {'attributes': ['string', 'help', 'type']})
|
|
# print(action_register_payment)
|
|
|
|
|
|
|
|
# ------------------------- many product many invoice
|
|
invoice_vals = []
|
|
partners_id = models.execute_kw(db, uid, password, 'res.partner', 'search', [[]])
|
|
product_id = models.execute_kw(db, uid, password, 'product.product', 'search', [[]])
|
|
|
|
for partner in partners_id:
|
|
invoice_val = {
|
|
'name': '23A000001',
|
|
'partner_id': partner,
|
|
'ref': 'create from api',
|
|
'move_type': 'out_invoice',
|
|
}
|
|
invoice_lines = []
|
|
for product in product_id:
|
|
invoice_lines.append((0,0, {
|
|
'product_id': product,
|
|
'quantity': 1,
|
|
}))
|
|
invoice_val.update({'invoice_line_ids': invoice_lines})
|
|
invoice_vals.append(invoice_val)
|
|
print(invoice_vals)
|
|
|
|
# invoice_id = models.execute_kw(db, uid, password, 'account.move', 'create', [invoice_vals])
|
|
# print(invoice_id)
|
|
|