Filter out previously selected assets from employee view in Odoo 11

83 views Asked by At

In employee form view I have a asset_ids One2many field to 'account.asset.asset'.

When I want to add a new asset to an employee, the asset which was already assigned to an employee is also shown in the list. How can I only show unallocated assets in employee form view?

Code Sample

class HrEmployee(models.Model):
_inherit = ['hr.employee']

asset_ids = fields.One2many('account.asset.asset','employee_id', string='Assets Owned')


class AccountAssetAsset(models.Model):
_inherit = ['account.asset.asset']

employee_id = fields.Many2one('hr.employee', string="Employee")

Can this be done using domain filters?

0

There are 0 answers