跳至内容
菜单
此问题已终结
1 回复
5411 查看

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 .
形象
丢弃

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

最佳答案

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

形象
丢弃
编写者

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.

编写者

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

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

相关帖文 回复 查看 活动
1
11月 19
4181
2
8月 17
5239
1
3月 25
1501
1
12月 19
9021
1
8月 15
7584