Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
3221 มุมมอง

Hello,

Not sure how odoo thinks the following is 4 arguments when clearly only 3 are there. Note the vals['customer_code'] currently = "BBF".

 rec_count = self.env['res.partner'].search_count('customer_code', '=', vals['customer_code'])
TypeError: BaseModel.search_count() takes from 2 to 3 positional arguments but 4 were given

Anyone know what is going on here?

Thank you.


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi, i think the issue is in the format of search_count you have defined. Try the code by changing to

rec_count = self.env['res.partner'].search_count([('customer_code', '=', vals['customer_code'])])

Regards.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

There is a syntax error in your code on the search_count method

Update the code like this

rec_count = self.env['res.partner'].search_count([('customer_code', '=', vals['customer_code'])])

Also please refer the blog to know more about ORM methods in odoo it may help you

https://www.cybrosys.com/blog/orm-methods-in-odoo-15

Regards

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Ah, yes. what a silly mistake. Thank you.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ต.ค. 25
448
1
พ.ค. 25
2046
1
มี.ค. 25
2043
MERGING CONTACTS แก้ไขแล้ว
1
ก.พ. 25
8281
Use of external id แก้ไขแล้ว
2
ก.พ. 25
4398