İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
5396 Görünümler

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
Vazgeç

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

En İyi Yanıt

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
Vazgeç
Üretici

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.

Üretici

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

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

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Kas 19
4180
2
Ağu 17
5237
1
Mar 25
1494
1
Ara 19
9018
1
Ağu 15
7577