LGB
LGB

Reputation: 75

How to bulk insert record in Odoo?

Currently, develop some code in c# for insert record into res.partner(Contacts) using Odoo API one by one using loop in c#. But i want to insert all record by single time Odoo API call, is it possible ?

Please have a look my existing code

foreach (var loCustomer in loCustomeresList)
{
 if (!string.IsNullOrEmpty(loCustomer.lsName))
  {
    loRecordPairCompany = new XmlRpcStruct();
    loRecordPairCompany.Add("name", loCustomer.lsCustomerID);
    loRecordPairCompany.Add("Phone_Number", loCustomer.lsPhoneNumber);
    loRecordPairCompany.Add("email", loCustomer.lsEmail);
    loRecordPairCompany.Add("website", loCustomer.lsWebsite);
    loRecordPairCompany.Add("property_payment_term_id", loCustomer.liCustomerPaymentTerm);
    loRecordPairCompany.Add("is_company", true);
    int liCompanyID = loRpcRecord.create(Common.lsDbName, liUserid, Common.lsDbPassword, "res.partner", "create", loRecordPairCompany);
  }
}

Upvotes: 3

Views: 1632

Answers (1)

CZoellner
CZoellner

Reputation: 14801

Currently (until Odoo v11) it is not possible. Recently for master (the future Odoo v12) there was a pull request of one of the core developers for a multi creation of records. You can find it here. But that won't help you.

You could write your own ORM method like "create_in_batch" which could take your input and do a multiple call of create() at Odoo side (server side).

Upvotes: 2

Related Questions