In a model with 2 one2many fields from the table but with a different domain:
inter_put_ids = fields.One2many(
comodel_name='project.roadmap.inter.rel', inverse_name='roadmap_id',
domain=[('category_id.is_put', '=', True)]
)
inter_get_ids = fields.One2many(
comodel_name='project.roadmap.inter.rel', inverse_name='roadmap_id',
domain=[('category_id.is_put', '=', False)]
)
Trying to populate the fields from a date:
@api.onchange('date')
def _populate_roadmap(self):
Intervention = self.env['project.intervention']
for roadmap in self:
# Installation
roadmap.inter_put_ids = [(5, 0, 0)]
inter_ids = Intervention.search([
'&',
('date', '=', roadmap.date),
('category_id.is_put', '=', True),
])
for inter in inter_ids:
roadmap.inter_put_ids = [(0, 0, {'roadmap_id': roadmap.id, 'inter_id': inter.id})]
# Getting back
roadmap.inter_get_ids = [(5, 0, 0)]
inter_ids = Intervention.search([
'&',
('date', '=', roadmap.date),
('category_id.is_put', '=', False),
])
for inter in inter_ids:
roadmap.inter_get_ids = [(0, 0, {'roadmap_id': roadmap.id, 'inter_id': inter.id})]
I'm sure that it worked, but now when adding to roadmap.inter_get_ids, roadmap.inter_put_ids is empty by the ORM.
How the framework is supposed to handle this ? If it is expected that it cleans the first field, how am i supposed to insert then consult those values ?