Odoo Help


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.


How to get a value of field from another module and assign a new value into it

on 2/11/16, 6:54 AM 355 views


I'm trying to make a module to manage travel leaves for employees.

What I need t do is adding extra float field in hr.employee module of 'available_tickets' . To be allocated from other module named "travel_request". How t do this?

Here's my code:

class hr_employee(osv.osv):
_columns = {
        'available_tickets': fields.float("Available Tickets"),

class travel_request(osv.osv):

_name = 'travel.request'

def _get_tickets(self, cr, uid, ids, context=None):

emp_ticket = self.pool.get('hr.employee').browse(cr, uid, ids)

return emp_ticket.available_tickets

_columns = {

'no_tickets': fields.function(_get_tickets, string='Number of Tickets', type='float'),


But it didn't work.. any idea how to fix it?

On 2/11/16, 7:39 AM

Hi Youta,

Just try to search 'hr.employee' based on any condition. And browse the records.

For ex:-

def _get_tickets(self, cr, uid, ids, context=None):

        hr_employee_obj = self.pool.get('hr.employee')

        res = {}

        for record in self.browse(cr, uid, ids, context=None): 

     emp_ticket_ids = hr_employee_obj.search(cr, uid, [], ids, context=None)

            emp_ticket = hr_employee_obj.browse(cr, uid, emp_ticket_ids[0], context=None)

            res['no_tickets'] = emp_ticket.available_tickets

        return res

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)


Asked: 2/11/16, 6:54 AM
Seen: 355 times
Last updated: 2/11/16, 7:39 AM