如何在odoo中创建customer(res.partner)时添加Tags(Category_id)?

时间:2015-04-15 07:14:55

标签: ios openerp odoo openerp-8 odoo-8

我正在ODOO iOS应用程序上工作。 我正在使用res.partner模型和create方法创建客户。 客户正在成功创建而没有任何错误,但我在创建过程中选择的标签字段未生成。

我使用以下代码创建客户:

NSArray *inputParameter = [NSArray arrayWithObjects:[userDic objectForKey:@"database"],[userDic objectForKey:@"userId"],[userDic objectForKey:@"password"],@"res.partner",@"create",customerDictionary,nil];

    // Show progress hud on main thread
    [[OpenERPGlobal appDelegate] showProgressHUD:@"Please wait" withView:self.view];

    // Depending on Id's read records
    WebService *service = [[WebService alloc] init];
    [service fetchDataWIthURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/xmlrpc/object",[userDic objectForKey:@"hostUrl"]]] withMethodName:ExecuteFunctionName withParameter:inputParameter withResult:^(id result,NSError *error)
     {
         [[OpenERPGlobal appDelegate] hideProgressHUD];

         if([result isKindOfClass:[NSNumber class]])
         {
            [OpenERPGlobal showMessage:@"Customer created successfully." delegate:self tag:10 cancelButtonTitle:@"Ok" otherButtonTitles:nil];
         }
     }

以上调用的输入参数如下:

{
    "category_id" =     (
        17,
        10,
        9,
        13
    );
    city = California;
    email = "sample@gmail.com";
    fax = "";
    function = "";
    "is_company" = 0;
    mobile = "";
    name = "123 Sample Customer";
    phone = "";
    street = "Street address";
    website = "http://www.sample.com";
}

在上面输入参数category_id是我的标签键。

有人遇到过这种问题吗?

1 个答案:

答案 0 :(得分:2)

res_partner 对象 category_id 中有很多关系。所以你需要使用 [6,0,[ids]]

添加

尝试以下值:

{
    "category_id" = [(6, 0, [17, 10, 9, 13])],
    city = California;
    email = "sample@gmail.com";
    fax = "";
    function = "";
    "is_company" = 0;
    mobile = "";
    name = "123 Sample Customer";
    phone = "";
    street = "Street address";
    website = "http://www.sample.com";
}

For more details of Many2one, One2many and Many2many field