Odoo Help

0

get name of many2one field in sequence

By
Koffi KPONOUGLO
on 8/10/16, 7:11 AM 453 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)

1
Ahmed M.Elmubarak
On 8/10/16, 7:25 AM

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

Hi Ahmed,

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

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

Koffi KPONOUGLO
on 8/10/16, 7:53 AM

Koffi,

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

Pawan
on 8/10/16, 8:17 AM

Thanks it is working.

Koffi KPONOUGLO
on 8/10/16, 9:45 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 8/10/16, 7:11 AM
Seen: 453 times
Last updated: 8/10/16, 7:25 AM