Skip to Content
Menu
This question has been flagged
3 Replies
2591 Views

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.

Avatar
Discard
Best Answer

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.


Avatar
Discard
Author Best Answer

Yes, I added account to manifest and it works! Thank you very much Malay Khamar!

Avatar
Discard

Your Welcome ThinFilm.
Please Add Vote for the Answer.

Best 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_rank" invisible="1"/>
<field name="customer_id" domain="['&amp;', ('customer_rank', '&gt;', 0), ('is_company', '=', 'True')]"/>



Avatar
Discard

No not from the base , its from account.

Related Posts Replies Views Activity
1
May 22
2991
2
Feb 20
4030
1
Sep 15
4794
0
Mar 15
5064
1
Mar 15
8341