Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
2064 Weergaven

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")


Avatar
Annuleer
Beste antwoord

Hi, 

You can try this:

First, you can add the widget = "many2many_tags" to your checkpoints (m2m) field in the form view file of gas.route model.
Now assuming that you have two checkpoints CP1 and CP2. You can now select your checkpoints in a sequence of your choice in every Gas Route.

Let's say for gas route 1 you added checkpoints like CP2 and CP1.
For another gas route record, you can add Checkpoints CP1 and CP2 and similarly, you can add checkpoints in any sequence of your choice in every route.

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
feb. 23
1779
2
feb. 23
2602
0
jun. 22
2341
0
dec. 19
4174
2
dec. 18
9097