Odoo Help

Welcome!

This community 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.

0

get name of many2one field in sequence

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

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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