In this below image you can check i have created two class efficiency and test ,in efficiency class there is one field called start_time so i need this field to display the minimum value of all record in start field ,which is present in test class.for this i am writing one function can anyone help,how i should get minimum value of start field and displayed into my start_time field which is present in another model.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
3
Odpowiedzi
11562
Widoki
As an option:
get the lowest amount of 'start' - test . search([],order='start asc', limit=1)
define 'start_time' as float and make it equal to the result above or as integer and store 'id' of the record with min 'start' amount.
Hi,
An alternative solution. You may try like this:
class effeciency(models.Model):
_name= "effeciency.effeciency"
def _get_min_test(self):
recs = self.env['test.line'].search([])
if recs:
recs_sorted = recs.sorted(key=lambda r: r.start)
return recs_sorted[0].id
start_time = fields.Many2one('test.line',string="Start Time", default=_get_min_test)
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
Error when passing information through API
Rozwiązane
|
|
1
wrz 23
|
2522 | |
|
6
paź 20
|
9015 | ||
|
3
kwi 19
|
3397 | ||
|
2
sie 18
|
4185 | ||
|
1
sty 16
|
4094 |