Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
5939 Widoki

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.


Awatar
Odrzuć
Autor Najlepsza odpowiedź

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.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
mar 15
7617
1
lut 24
1952
0
lip 24
2989
0
lip 22
60
1
lip 22
2864