I am working on a custom module using odoo16 where I have a model gas.route and another model is gas.checkpoint. In gas.route model, for a route there could be multiple checkpoints. on the top of that one checkpoint can be assigned on different route.
but the problem is, in different route the checkpoints sequence is different. I can not be able to handle it to create different sequence of checkpoint for routes.
my code is
class Route(models.Model):
_name = 'gas.route'
_description = 'Config Route'
_inherit = ['mail.thread']
name=fields.Char("Name")
start_point= fields.Many2one("gas.checkpoint","Start Point", domain="[('is_start_end_checkpoint', '=', True)]")
end_point= fields.Many2one("gas.checkpoint","End Point",domain="[('is_start_end_checkpoint', '=', True)]")
distance = fields.Float(string='Distance(KM)')
updown = fields.Selection([('up','Up'),('down','Down')],string='Up/Down')
checkpoints=fields.Many2many("gas.checkpoint",'gas_route_checkpoint_rel', 'route_id', 'checkpoint_id', string='Checkpoints')
status=fields.Selection([('active', 'Active'), ('inactive', 'Inactive')],string="Status")
on checkpoint model:
class CheckPoint(models.Model):
_name = 'gas.checkpoint'
_description = 'Config Checkpoint'
_inherit = ['mail.thread']
name=fields.Char("Name")
latitude = fields.Float(string='Geo Latitude', digits=(10, 7))
longitude = fields.Float(string='Geo Longitude', digits=(10, 7))
map_location = fields.Char(string='Current Map Location', compute='_compute_map_location')
address = fields.Char(String="Address", compute='_compute_address', store=True)
is_start_end_checkpoint=fields.Boolean("Is Start/End Point")
status=fields.Selection([('active', 'Active'), ('inactive', 'Inactive')],string="Status")