Hello,
I need to create an M2O field that only shows the user customers and not other partners. In earlier Odo versions I solved it this way and everything worked:
customer_id = fields.Many2one('res.partner', domain="['&', ('customer', '=', 'True'), ('is_company', '=', 'True')]", string='Customer')
For the current version of Odoo, I modified the code as follows:
customer_id = fields.Many2one('res.partner', domain="['&', ('customer_rank', '>', 0), ('is_company', '=', 'True')]", string='Customer')
While a module with this code can be installed and run, every time I try to upgrade, a critical error occurs that causes the server to stop working:
"Unknown field "res.partner.customer_rank" in domain of field 'customer_id' (['&', ('customer_rank', '>', 0), ('is_company', '=', 'True')])"
This error also occurs for the "supplier_rank" field. On the other hand, the "is_company" field works without any problems.
Does anyone have an idea what the error might be and how to fix it? Any help would be very appreciated.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
Hi ThinFilm,
Please add "account" as dependent module into your custom module manifest file Because "customer_rank" and "supplier_rank" fields are adds from the account module not in the base module.
Hope it will help you.
Yes, I added account to manifest and it works! Thank you very much Malay Khamar!
Your Welcome ThinFilm.
Please Add Vote for the Answer.
Hi,
Have you tried adding the 'account' module to the depends in __manifest__.py file?
If that doesn't work, Please try to add this domain from the XML (View) Part.
<field name="customer_id" domain="['&', ('customer_rank', '>', 0), ('is_company', '=', 'True')]"/>
No not from the base , its from account.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
May 22
|
2991 | ||
|
2
Feb 20
|
4030 | ||
|
1
Sep 15
|
4794 | ||
|
0
Mar 15
|
5064 | ||
|
1
Mar 15
|
8341 |