2015-04-15 51 views
2

我正在做ODOO iOS應用程序的工作。 我使用res.partner模型和create方法創建客戶。 客戶無任何錯誤地成功創建,但我在創建過程中選擇的標籤字段沒有生成。如何在odoo中創建客戶(res.partner)時添加標籤(Category_id)?

我用下面的代碼來創建客戶:

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 = "[email protected]"; 
    fax = ""; 
    function = ""; 
    "is_company" = 0; 
    mobile = ""; 
    name = "123 Sample Customer"; 
    phone = ""; 
    street = "Street address"; 
    website = "http://www.sample.com"; 
} 

在上面輸入參數category_id是我的標籤鍵。

有沒有人遇到過這種問題?

回答

2

res_partner object category_id有許多關係。所以,你需要使用[6,0,[IDS]添加

試試這個值:

{ 
    "category_id" = [(6, 0, [17, 10, 9, 13])], 
    city = California; 
    email = "[email protected]"; 
    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

+0

非常感謝您Odedra ......我現在面臨這個問題從前2天。你很酷。 –

+1

@Odedra''category_id「= [(6,0,[17,10,9,13])]中的'6'和'0'是什麼意思?沒有解釋,他們似乎相當隨意的一個noob。有沒有可以參考的文件解釋這個? –

+0

@MichaelMügge你是對的。我應該包括它的簡要說明。你可以參考更新的答案鏈接。 –

相關問題