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.

1

Modify task->"Assigned to" from res.users to hr.employee

By
kobi segev
on 9/29/13, 10:23 AM 1,751 views

Im trying to figure out how to modify column properties of existing module. In this case, project tasks, should be assigned to employee and not user. The current column is: 'user_id': fields.many2one('res.users', 'Assigned to', track_visibility='onchange'), should be changed to: 'user_id': fields.many2one('hr.employee, 'Assigned to', track_visibility='onchange'),

I would like to override and not create new one in order to make use of the existing functionality around user_id.

Any thoughts on how it can be done?

1

This is my sample...

In your .py inherit the class you want to change the user id fro example

class class_name(osv.osv):
_inherit = "class.name"


_columns = {
    'user_id': fields.many2one('hr.employee, 'Assigned to', track_visibility='onchange'),
}
class_name()

and in you .xml

  <record id="name_you_want" model="ir.ui.view">
        <field name="name">name.you.want</field>
        <field name="model">table.you.inherited</field>
        <field name="type">form</field>

        <field name="inherit_id" ref="table_you_inherited.name_of_the_form_where_you_want_to_change"/>
          <field name="arch" type="xml">

               <xpath expr ="//field[@name='user_id']" position="replace">
                    <field name="user_id" />
              </xpath> 
            </field>
    </record>

I hope it will work :D

It did the work. thanks for your help.

kobi segev
on 9/30/13, 3:30 AM

Your welcome :D i'm just sharing what i've learn, i also encounter that problem what i'm new to openerp :D

Lady Sharmane Udtuhan
on 9/30/13, 4:12 AM
2

Daniel Reis

--Daniel Reis--
3436
| 6 7 9
Lisbon, Portugal
--Daniel Reis--

Author of the "Odoo Development Essentials" book.

Applications Manager at Securitas Portugal

Github: https://github.com/dreispt

Twitter; @reis_pt


Daniel Reis
On 9/30/13, 6:38 AM

That's similar to this other question.

I'll give you the same advice I gave there: create a User for each employee instead, and avoid unnecessary customizations.

I am assuming that. My problem is that i dont understand why user/employee is not the same entity at the first place (But one2many???). It gets event stranger (at least for tasks), when i need to manage employee timesheet, or filter by department (while selecting the user_id), it just doesn't adds up.

kobi segev
on 9/30/13, 7:52 AM

I agree, the HR data model has some important issues; another one is the confusing relation of Employees vs Partners. Let's hope all this is fixed in v8.

Daniel Reis
on 10/1/13, 7:55 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

0 follower(s)

Stats

Asked: 9/29/13, 10:23 AM
Seen: 1751 times
Last updated: 3/16/15, 8:10 AM