Skip to Content
Menu
This question has been flagged
2 Replies
3205 Views

Hello everyone! Sorry in advance for the newbie question. I'm just getting started with Odoo. As an item in one of my forms, I need to be able to pick what days of the week an office is open. The only way I can figure out how to do this in studio, it to create a days of the week menu item, populate it with monday, tuesday, ect and do a Many2Many selection on it. But, this seems completely wrong like I'm missing a key concept here. Can someone help me figure out how to do a many2many select without making a whole menu item for it?


Also, are there any good intro videos/books I can get ahold of to bring me up to speed quicker? Thanks!!

Avatar
Discard
Best Answer

Hi Rick,

To add a many2many field you can look this Code,

class TestModel(models.Model):
_name = 'model1.name'

test_field1 = fields.Many2many('new.model1', 'weak_days', 'a', 'b', string="Week")

class WeekDays(models.Model):
_name = 'new.model1'

weak_days = fields.Many2many('model1.name', 'test_field1','b','a', string="Days")
name = fields.Char("Days")

In the first model, you have to define a many2many field and in the second model, you have to add a many2one field. Then you can add the week days by clicking the create button in the field.

Thank you

Avatar
Discard
Author Best Answer

Thank you very much for your response Niyas. I guess my biggest issue is that I can't figure out how to break out of this darn drag and drop WYSIWYG studio editor to get at the underlying classes. Is this possible to do with the single free app/online edition plan?

Avatar
Discard