Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4088 มุมมอง

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
เม.ย. 23
2719
2
ก.พ. 25
40421
2
พ.ย. 22
2804
1
ก.พ. 22
7836
0
ต.ค. 21
2250