Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
5317 Vistas

I want partner field to be mandatory if the account selected in lines is of type payable. i have added type field in the move line related to account type 


type_account = fields.Many2one(string='type',related ='account_id.user_type_id')

and i have put a condition on the partner field which is like below.

<field name="partner_id" attrs="{'required':[('type_account','=','Payable')]}"/>
I have tried this with both "payable" and "payable" no error but doesnt work .
Avatar
Descartar

Hope this idea will help; https://goo.gl/BCxCpk

Mejor respuesta

Your related field is a M2o field and you cannot use string value in the domain for relational field. You should create a related field of the type field of user_type_id.

Try this:

type_account = fields.Selection([
('other', 'Regular'),
('receivable', 'Receivable'),
('payable', 'Payable'),
('liquidity', 'Liquidity'),
], string='Type', related=account_id.user_type_id.type)

This will give you the type of the account like: receivable, payable, etc related to the selected account

Avatar
Descartar
Autor

Thanks for replying ! if you make it a Char field it says

"TypeError: Type of related field account.move.line.type_account is inconsistent with account.account.user_type_id

"

This error as you know means that relational field must be of the same type to which you are relating it too

See my updated answer. Lets make the field selection type.

Autor

Thank You so much man. It worked and following attrs works with it

attrs="{'required':[('user_type','=','payable')]}"

Publicaciones relacionadas Respuestas Vistas Actividad
1
nov 19
4119
2
ago 17
5195
1
mar 25
1419
1
dic 19
8915
1
ago 15
7491