Hello Gents,
Need help for below.
I need to prevent entering records one2many field( sparepartslines ) in the same Asset model based on the field 'name' from spareparts_lineitem.
User can enter the same spareparts_lineitem in different Asset
class Asset(models.Model):
_name = 'asset'
name = fields.Char(string="Code", required=True)
assetname = fields.Char(string='Asset Name')
sparepartslines = fields.One2many('spareparts_lineitem', 'asset', string='Spareparts')
class Spareparts(models.Model):
_name = 'spareparts'
name = fields.Char(string="Item number", required=True)
description = fields.Char(string='Description')
class Spareparts_lineitem(models.Model):
_name = 'spareparts_lineitem'
name = fields.Many2one('spareparts', string="Item number", required=True)
description = fields.Char(string='Description', related='name.description', store=True, readonly=True)
quantity = fields.Float(string='Quantity', required=True)
quantityinstore = fields.Float(string='Qty in Store')
asset = fields.Many2one('asset', string="Asset")