So I have this Many2many field which autofills with records as intended although I have a question, can I access the "x-th" record after autofilling?
The reason why I want this to use it in related fields later. Much thanks!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
So I have this Many2many field which autofills with records as intended although I have a question, can I access the "x-th" record after autofilling?
The reason why I want this to use it in related fields later. Much thanks!
I presume you are making the auto fill with the Command function In Python to create the relationships between records?
- at the end of the function why not return the action by putting res_id = x.id
if the return is conditional use an if…?
Autofilling it this way:
@api.model
def _get_default_product_variant_ids(self):
return self.env['hotel.employeetasks'].search([]).ids
product_variant_ids = fields.Many2many('hotel.employeetasks', string='Variants',
default=_get_default_product_variant_ids)
The reason why I want this way is because I have a model called "hotel.employeetasks" which holds some records and I have another model called "hotel.dashboard". In the "hotel.dashboard" I want to display 5 records from "hotel.employeetasks" model and only three fields need to be displayed like "today", "nameofemployee" and "task".
So the way I have thinking about it is making related fields in "hotel.dashboard", so
field1 = field.Char(related="task_ids['first record'].task")
field2 = field.Char(related="task_ids['second record'].task")
etc...
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Feb 23
|
1468 | ||
|
0
Dec 19
|
3034 | ||
|
0
Jan 20
|
2637 | ||
|
3
Nov 23
|
15303 | ||
|
1
Feb 24
|
929 |