Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2380 Lượt xem

New Odoo user here. I'm trying to add a custom view to the HR module where you can only see the remaining vacation days of the employee related to the logged-in user, but I don't know how to make a reference to the logged-in user as there's no field to reference it in the hr.employee model.  

Here's what I have so far:

<openerp>
    <data>
        <record model="ir.ui.view" id="sq_employee_leave_view">
            <field name="name">sqemployeeleaves.form</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr_holidays.view_employee_form_leave_inherit"/>            
            <field name="arch" type="xml">
                <xpath expr="//field[@name='remaining_leaves']" position="replace">
                    <field name="remaining_leaves" attrs="{'invisible':[('user_id', '!=', uid)]}"/>
                </xpath>
            </field>
        </record>
    </data>
</openerp>

This gives me a 'uid is not defined' error.  Can anyone tell me how to go about referencing the current user?  I'm working in Odoo 8.  Thanks!

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi Cyril, I don't have enough karma to comment on your post yet but the suggested fix didn't work. It didn't throw an error but uid is still not recognized as the current logged-in user so the constraint doesn't work. Thanks for the help, though!