Skip to Content
Menú
This question has been flagged
3 Respostes
2793 Vistes

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
Descartar
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
Descartar
Autor Best Answer

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

Avatar
Descartar

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
Descartar

No not from the base , its from account.

Related Posts Respostes Vistes Activitat
1
de maig 22
3149
2
de febr. 20
4257
1
de set. 15
4959
0
de març 15
5282
1
de març 15
8547