Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
1608 Prikazi

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()' == ''

Avatar
Opusti
Best Answer

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)]



Avatar
Opusti
Avtor Best Answer

Thank Duong Nguyen. It works.

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
4
maj 25
2444
2
maj 25
5777
1
mar. 25
1622
4
mar. 25
4413
3
feb. 25
5394