class BuildingDefinition(models.Model):
_name = 'building.definition'
name = fields.Char(required=True, string='Building Name')
main_building = fields.Many2one('building.definition')
class BuildingUnits(models.Model):
_name = 'building.units'
name = fields.Char()
unit = fields.Many2one('building.definition')
@api.multi
def unit_check(self):
for rec in self:
domain = [('main_building', '=', True)]
only_main = self.env['building.definition'].search([]).mapped('main_building').mapped('name')
all_build = self.env['building.definition'].search([]).mapped('name')
res = list(set(all_build) - set(only_main))
self.unit = [(6, 0, res.ids)]
-------
every building usually have a main building and units
in field unit i need buildings(at BuildingDefinition module with 'name') whcih are not main buildings ( at BuildingDefinition module with 'main_building)
tryed also domains in XML but still not working
kindely how to solve ?