Community mailing list archives

community@mail.odoo.com

Get a value from res.users and use it in a domain

by
Victor Inojosa
- 06/19/2015 22:05:19
Hi all.

I need some help.

I want to obtain a value from an extended field from res.users and use it as a domain for a window action in another view, but I get no clear reference to this matter.

Basically I'm doing this:

1.- Extend res.users model

class ResUsersExtended(models.Model):
    """Extensión del modelo res.users"""
    _name = 'res.users'
    _inherit = 'res.users'
    dependencia_id = fields.Many2one('sisr.dependencia', string="Dependencia" help="Dependencia de Adscripción")


2.- Extend the res.users form view

<record model="ir.ui.view" id="view_resusers_extend">
        <field name="name">res.users.form.extend</field>
        <field name="model">res.users</field>
        <field name="inherit_id" ref="base.view_users_form"/>
        <field name="arch" type="xml">
            <field name="active" position="before">
                <field name="dependencia_id"/>
            </field>
        </field>
</record>

3.- define the domain in the window action

<record model="ir.actions.act_window" id="action_trabajador">
        <field name="name">Trabajador</field>
        <field name="domain">[('dependencia_id','=', uid.dependencia_id )]</field>
        <field name="res_model">trabajador</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>


but I get this error: Error: AttributeError: object has no attribute 'dependencia_id'

Would you please give a clue about how to take that value and pass it to the action?


--
- Victor José Inojosa Mundo -
A.K.A. vijoin
Usuario GNU/Linux # 418487
Canaima & Debian User...
San Carlos - Estado Cojedes - Venezuela
Twitter: @vijoin