Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
5386 Widoki

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 .
Awatar
Odrzuć

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

Najlepsza odpowiedź

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

Awatar
Odrzuć
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')]}"

Powiązane posty Odpowiedzi Widoki Czynność
1
lis 19
4179
2
sie 17
5231
1
mar 25
1484
1
gru 19
9013
1
sie 15
7568