Reputation: 31
im new on this field and i want to create fixed list containing the days of week to choose from it in multiselect field ..i think i need use many2many relation .(the whole idea to choose vacation days for every person) so how i pass this fixed list to manytomany field for ex:
Holidays = [(saturday, saturday), (sunday,sunday), (monday, monday),(tuesday, tuesday), (wednesday', 'wednesday),(Thursday, Thursday),(Friday,Friday)]
vacation = fields.Many2many('Holidays')
Upvotes: 1
Views: 2106
Reputation: 1175
in your case you would need a new model for weekdays & then you would apply vacation relation to the new weekdays.
class CustomWeekdays(model.Models):
_name = 'custom.weekdays'
name = fields.Char()
day_type = fields.Selection([
('saturday', 'Saturday'),
('sunday', 'Sunday'),
('monday', 'Monday'),
('tuesday', 'Tuesday'),
('wednesday', 'Wednesday'),
('thursday', 'Thursday'),
('friday', 'Friday')
])
def name_get(self):
''' Here you should define how search the name '''
pass
class CustomHoliday(model.Models):
_name = 'custom.holiday'
name = fields.Char()
vaction_ids = fields.Many2many('custom.weekdays', string='Days')
Upvotes: 1