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

Hi all,

My custom module has a m2m field 'picking_type_ids'. I want to auto fill this field when creating a record. Below is 'default_get' function. 

@api.model
def default_get(self, fields_list):

res = super(ElwQualityPoint, self).default_get(fields_list)

if not res.get('picking_type_ids'):
picking_type_ids_ids = self.env['stock.picking.type'].search([]).ids
print(picking_type_ids_ids)
res['picking_type_ids'] = self.env['stock.picking.type'].browse(picking_type_ids_ids[0])
return res

This function outputs WARNING as follows:  Please advise

[1, 2]

2024-06-07 04:18:04,447 10092 WARNING db_3 py.warnings: c:\learning\odoo_code\odoo-04\addons\web\models\models.py:953: UserWarning: unsupported operand type(s) for "==": 'stock.picking.type()' == ''

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

it need to set the ids not record set

from odoo Command
res['picking_type_ids'] = [Command.set(self.env['stock.picking.type'].search([]).ids)]



อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thank Duong Nguyen. It works.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
4
พ.ค. 25
2484
2
พ.ค. 25
5832
1
มี.ค. 25
1661
4
มี.ค. 25
4447
3
ก.พ. 25
5445