from this picture here
when i click on the add new item, i want employee list that show up is only employees from the selected department, in the pict case is "IT" department. iam using odoo v8
ive tried this in my o2m field :
class overtime(models.Model):
_name = 'overtime.overtime'
department_id = fields.Many2one('hr.department', string='Department', readonly=True, states={'draft': [('readonly', False)]})
employee_ids = fields.One2many('overtime.overtime_details', 'overtime_id', string="Employee",
domain="[('hr.employee.department_id', '=', department_id)]")
class overtime_details(models.Model):
_name='overtime.overtime_details'
nik = fields.Char('NIK', size=250, required=True)
overtime_id = fields.Many2one('overtime.overtime', string="Overtime", ondelete='cascade')
job_id = fields.Many2one('hr.job', string="Position")
employee_id = fields.Many2one('hr.employee', "Employee", required=True, select=True)
and got error like this :
Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 544, in _handle_exception
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 581, in dispatch
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 317, in _call_function
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\service\model.py", line 118, in wrapper
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 314, in checked_call
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 810, in __call__
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 410, in response_wrap
File "C:\Program Files (x86)\Odoo 8.0\server\openerp\addons\web\controllers\main.py", line 944, in call_kw
File "C:\Program Files (x86)\Odoo 8.0\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\models.py", line 3148, in read
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\models.py", line 3183, in read
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\models.py", line 3370, in _read_from_database
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\osv\fields.py", line 774, in get
TypeError: cannot concatenate 'str' and 'list' objects
here is the xml :
<record id="overtime_form1" model="ir.ui.view">
<field name="name">overtime_form1</field>
<field name="model">overtime.overtime</field>
<field name="arch" type="xml">
<form string="Overtime Request Form">
<sheet>
<div class="oe_title">
<label for="code" class="oe_edit_only"
string="Overtime Code" />
<h1>
<field name="code" />
</h1>
</div>
<group>
<field name="department_id"/>
<label string="Duration"/>
<div>
<group col="5">
<field name="start_date" class="oe_inline"/>
<label string="-" class="oe_inline"/>
<field name="end_date" class="oe_inline"/>
</group>
</div>
<field name="total_overtime"/>
<field name="overtime_bonus"/>
<field name="reason"/>
</group>
<notebook>
<page string="Employees">
<field name="employee_ids" >
<tree string="Employees" editable="bottom">
<field name="nik"/>
<field name="employee_id"/>
<field name="job_id"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
thanks before :)