Skip to Content
Menu
This question has been flagged
1 Reply
4778 Views

I have a wizard and In need a temporary list of other transientmodel. My code is the following: 


class proves_wizard_raws(models.TransientModel):
_name = 'game.proves_wizard_raws'
wizard = fields.Many2one('game.proves_wizard')
raw = fields.Many2one('game.raw')
quantity = fields.Integer()


class proves_wizard(models.TransientModel):
_name = 'game.proves_wizard'

def _default_player(self):
return self.env['res.partner'].browse(self._context.get('active_id'))

player = fields.Many2one('res.partner', default=_default_player)
raw = fields.Many2one('game.raw', store=False)
quantity = fields.Integer(store=False)
raws = fields.Many2many('games.proves_wizard_raws', compute='_get_raws')

def _get_raws(self):
for p in self:
list= self.env['game.proves_wizard_raws'].search(['wizard','=',p.id])
p.raws = list


def create_raws(self):
raw = self.env['game.proves_wizard_raws'].create({'wizard': self.id, 'raw': self.raw.id, 'quantity': self.quantity})
return {
'name': 'proves wizards',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'game.proves_wizard',
'res_id': self.id,
'context': self._context,
'type': 'ir.actions.act_window',
'target': 'new',
}

But the Many2many doesn't works. I tried it with a One2many, but I have similar error.

Is there a way to have a temporary many2many?


EDIT: 

I just solve the problem. It is the name of the transientmodel, It fails with two underscore lines _ I changed it to proves_wizardraws and it works. I finalty used One2many instead of the Many2many computed. 

Thanks.


Avatar
Discard
Author Best Answer

Solved

I just solve the problem. It is the name of the transientmodel, It fails with two underscore lines _ I changed it to proves_wizardraws and it works. I finalty used One2many instead of the Many2many computed. 

Thanks.

Avatar
Discard
Related Posts Replies Views Activity
2
Mar 15
6863
1
Feb 24
839
0
Jul 24
1507
0
Jul 22
60
1
Jul 22
1418