コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
10888 ビュー

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

}

}


アバター
破棄
最善の回答

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
アバター
破棄
関連投稿 返信 ビュー 活動
2
7月 24
14259
1
7月 21
8493
0
4月 20
4973
1
5月 18
3253
0
4月 18
3744