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

How to read/get field's value in another module

By
youta
on 2/15/16, 8:13 AM 420 views

Hello,

I've added a new field inside hr.employee module .

The field is : 'available_tickets': fields.float("Available Tickets")

I need to read this field's value in another module let's say travel.request module.

Here's my code:

class travel_request(osv.osv):
_name = 'travel.request'
    def _get_available_tickets(self, cr, uid, context=None):
ticket_obj = self.pool.get('hr.employee')
ticket_ids = self.pool.get('hr.employee').search(cr, uid, [])
for t_id in ticket_ids:
ticket = ticket_obj.browse(cr, uid, t_id, context=context)
available_tickets = ticket.available_tickets
        return available_tickets

     _columns = {
         'available_tickets_id': fields.many2one('hr.employee', "Number of Available Tickets", readonly=True),
     }
     _defaults = {
         'available_tickets_id': _get_available_tickets,
     }


class hr_employee(osv.osv):

_inherit="hr.employee"

    _columns = {

'available_tickets': fields.float("Available Tickets"),

     }


But it didn't work, can anyone help me to fix it.



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: 2/15/16, 8:13 AM
Seen: 420 times
Last updated: 2/15/16, 8:33 AM