Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
1616 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Auteur Meilleure réponse

Thank Duong Nguyen. It works.

Avatar
Ignorer
Publications associées Réponses Vues Activité
4
mai 25
2455
2
mai 25
5792
1
mars 25
1631
4
mars 25
4424
3
févr. 25
5405