Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
2785 Vistas

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
Mejor respuesta

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 Mejor respuesta

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.

Mejor respuesta

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.

Publicaciones relacionadas Respuestas Vistas Actividad
1
may 22
3148
2
feb 20
4256
1
sept 15
4953
0
mar 15
5270
1
mar 15
8543