Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4095 Lượt xem

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.



Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi , 

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

Hope It Helps,
Kiran K


Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 4 23
2724
2
thg 2 25
40423
2
thg 11 22
2809
1
thg 2 22
7844
0
thg 10 21
2256