Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
7862 Widoki

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?

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

It did the work. thanks for your help.

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

Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

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.

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.