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

I have an object. I would like to define his by addind one of his many2one field name's (mission_id) and his sequence. So I write this code. but when create the objet i am getting the field (mission_id) id's numbre plus the object (mission_wave) sequence. How can i get mission_id name's instead of id?

Thanks.

class mission_wave(osv.osv):
  def create(self, vals):

if vals.get('name', '/') == '/':

vals['name'] = str(vals.get('mission_id') + str(self.env['ir.sequence'].get('hr.mission.wave'))

return super(hr_mission_wave, self).create(vals)

Avatar
Discard
Best Answer

Hi,

You can use the browse record, you can try something like:

mission_name = self.pool['mission.class.name'].browse(vals.get('mission_id')).name
vals['name'] = str(mission_name + str(self.env['ir.sequence'].get('hr.mission.wave'))


hope this could helps

Avatar
Discard
Author

Hi Ahmed,

thanks for your answer. I try the code but get error.

"TypeError: browse() takes at least 3 arguments (2 given)"

Koffi,

try self.env['mission.class.name'] instead of self.pool['mission.class.name']

Author

Thanks it is working.

Related Posts Replies Views Activity
0
Feb 23
2821
0
Jan 23
86
1
Oct 22
3091
0
Apr 22
1653
2
Feb 22
1655