コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5670 ビュー

Hello,

I have two form view using the same model, which have the field.Char:

abc = fields.Char('Reference')


In the first form view. I set for the field abc must be required via XML like this:

<field name="abc" required='True'/>


But in the second, I set for the field abc which no need to be required:

<field name="abc"/>


After clicking the button to open the first and the second form view, it worked well with required or not required the user to input the value in field abc.

But when the user does not put the value in the second form view, it will show the value: 'False' in tree view.


I want to hide the value 'False' and it just shows the 'empty' value in field abc.

I'd tried to set default=' ' in the model. It worked to show the 'empty' value in field abc, but it will effects all form view and ignore the required rule which I'd set in the first form view by XML.


So how to hide the value 'False' base on the required form view when shown in the tree view?

Please help!

Thank you!


 

アバター
破棄
著作者 最善の回答

Finally, I have resolved my issue. Just using context to pass the empty value (' '), then it will work fine if the user does not inputs the value in the field abc. The code in the model like this:

'context': {'default_name': self.name.id,

                  'default_abc': ' '

                 },


アバター
破棄
関連投稿 返信 ビュー 活動
1
7月 24
11676
0
12月 21
2781
0
7月 21
94
3
6月 25
724
1
2月 21
7273