Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
10895 Vizualizări

Currently, develop some code for insert record into res.partner(Contact) by calling Odoo API one by one using loop.

But, i want to insert all record by single call of Odoo API 

Is this possible ?

please have a look my existing code, implements for c#

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);

}

}


Imagine profil
Abandonează
Cel mai bun răspuns

Hi Ghanshyam,

Create method only accept single dictionary to create a single record at a time. But you can create your own method in your custom module in Odoo, that will accept the list of dictionary from C#. In that method, you can loop for the list of dictionary and then call the create method.

EX:

Class ResPartner(models.Model):
    _inherit = 'res.partner'

    @api.model
    def create_multi(self, list_vals):
        # list_vals: list of dictionary [{}, {}, {}.....]
        rec_ids = []
        for val in list_vals:
            # Call create method of current object (res.partner)
            rec_ids.append(self.create(val).id)
        # Return list of IDs
        return rec_ids

Hope this will help you.

Sudhir Arya
ERP Harbor Consulting Services
Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
iul. 24
14269
1
iul. 21
8495
0
apr. 20
4975
1
mai 18
3253
0
apr. 18
3745