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

I have created a Many2one field in my custom model

Python:

class SalesGroup(models.Model):    
    _name = 'pl.sales.group'
    
    warehouse_id = fields.Many2one('stock.warehouse', string='Warehouse',required=True)

However, when i am creating/editing a record, all the warehouses listed down, but when i select one value and save the form/record, the warehouse field sets to null.



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

I solved it myself. The field wasn't setting to null rather than it was not showing any data value. A many2one relation shows display_name field value, when record is saved. I set store=True flag on display_name, without computing or initiating it, which is why that field was set to null on all records.

アバター
破棄
最善の回答

Hi , 

Try Giving force_save="1" along with field definition in XML.
      

Hope It Helps,
Kiran K


アバター
破棄
著作者

Tried force_save="1" and store=True. Not solved. I think this is specifically in case of stock.warehouse

関連投稿 返信 ビュー 活動
2
4月 23
2711
2
2月 25
40409
2
11月 22
2796
1
2月 22
7823
0
10月 21
2246