This question has been flagged
660 Views

Please help me. I have this two classes :

class ProductWizard(models.TransientModel):
_name = 'product_wizard'

product_final_name=fields.Char(string='Final Name')
product_mpn_ids = fields.One2many(comodel_name='product_wizard_mpn', inverse_name='product_mpn_id', ondelete="cascade")


class ProductWizardMPN(models.TransientModel):
_name = 'product_wizard_mpn'

product_mpn_id=fields.Many2one(comodel_name='_product_wizard', inverse_name='product_mpn_ids' )
product_mpn=fields.Char(string="Name")
But I am unable, in code to create automatically the values for them (based on data I retreive from an API).

I tried

mpn_obj=self.env['product_wizard_mpn']
ids=[]
for result in data['results'] :
ids.append(mpn_obj.create({'product_mpn':result['part']['mpn']}))
new_prod_wiz = self.env['product_wizard'].create('product_mpn_ids':(0,0,ids)})

and other ways but always unable. Can someone please help me. I am stucked.

PS:data{'results'] are the API returned, that I wanted to map.



Avatar
Discard