@bb4first/odoo-xmlrpc
Version:
Odoo XMLRPC Interface
103 lines • 2.98 kB
text/typescript
//#region src/models/odoo.types.d.ts
declare enum MODEL_TYPE {
CONTACTS = "res.partner",
LEAD_OPPORTUNITY = "crm.lead",
EMPLOYEES = "hr.employee",
}
interface IServerVersion {
server_version: string;
server_version_info: any[];
server_serie: string;
protocol_version: number;
}
interface IContact {
name?: string;
phone?: string;
email?: string;
ref?: string;
category_id?: any[];
}
interface ILead {
name?: string;
partner_id?: number;
contact_name?: string;
email_from?: string;
phone?: string;
description?: string;
source_id?: number;
user_id?: number;
team_id?: number;
tag_ids?: number[];
type?: "lead" | "opportunity";
}
interface IEmployee {
department_id?: number;
name?: string;
work_email?: string;
work_phone?: string;
category_ids?: any[];
}
//#endregion
//#region src/controllers/odoo.crud.d.ts
declare class OdooCRUD<T> {
private _model;
private _odoo;
protected _keys: string[];
constructor(model: string, odoo: Odoo, keys?: string[]);
count(): Promise<number>;
create(value: T): Promise<number>;
searchRead(query: any[], limit?: number, keys?: string[]): Promise<T[]>;
getByIds(ids: number[], keys?: string[]): Promise<T[]>;
read(ids: number[], keys?: string[]): Promise<T[]>;
getById(id: number, keys?: string[]): Promise<T | undefined>;
getAllIds(limit?: number): Promise<number[]>;
update(id: number, data: T): Promise<boolean>;
delete(id: number): Promise<boolean>;
}
//#endregion
//#region src/controllers/contacts.odoo.d.ts
declare class Contacts extends OdooCRUD<IContact> {
constructor(odoo: Odoo);
create(value: IContact): Promise<number>;
searchByEmail(email: string): Promise<IContact[]>;
searchByPhone(phone: string): Promise<IContact[]>;
}
//#endregion
//#region src/controllers/employees.odoo.d.ts
declare class Employees extends OdooCRUD<IEmployee> {
constructor(odoo: Odoo);
searchByEmail(email: string): Promise<IEmployee[]>;
searchByPhone(phone: string): Promise<IEmployee[]>;
}
//#endregion
//#region src/controllers/leads.odoo.d.ts
declare class Leads extends OdooCRUD<ILead> {
constructor(odoo: Odoo);
searchByEmail(email: string): Promise<ILead[]>;
searchByPhone(phone: string): Promise<ILead[]>;
}
//#endregion
//#region src/controllers/odoo.d.ts
declare class Odoo {
private _client;
private _uid;
private _db;
private _password;
constructor(host: string, port?: number);
private _commonPath;
private _objectPath;
version(): Promise<IServerVersion>;
authenticate(db: string, username: string, password: string): Promise<number>;
callRPC(params: any[]): Promise<any>;
getModelActions(model: MODEL_TYPE): Contacts | Leads | Employees;
}
//#endregion
//#region src/constants/errors.enum.d.ts
declare const ERRORS: {
INVALID_CREDENTIALS: {
value: number;
str: string;
};
};
//#endregion
export { Contacts, ERRORS, Employees, IContact, IEmployee, ILead, IServerVersion, Leads, MODEL_TYPE, Odoo, OdooCRUD };