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

I would like to set as a default value in a many2one the first value that my many2one has written and that the user does not see the many2one field without any value initially. Obviously, I would like the many2one field to show a default value for the user to be able to modify the value selected in the many2one if they wish. This is my code:

@api.model    
def default_location_ids_origin(self):
for move_line in self:
locations = self.env['stock.quant'].search([('product_id','=',move_line.product_id.id),('quantity','>',0.00),('on_hand','!=',False)],limit=1)
return locations.location_id.id
location_ids_origin = fields.Many2one('stock.location',string='From',domain="[('id','in',location_id_products)]",default = default_location_ids_origin)
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ค. 20
3341
3
ต.ค. 18
40801
0
ก.ย. 22
60
1
เม.ย. 25
3960
0
ม.ค. 21
3012