Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged

Suppose I have 2 models:

modela.py :

    start_date = fields.Date('Start Date working')

modelb.py:

    name = fields.Many2one('hr.employee', 'Employee')

    start_datetime = fields.Datetime('Start Datetime working')

    end_datetime = fields.Datetime('End Datetime working')


In modelb.py, I created 3 records via field name and start_datetime:

Employee Name              Start Datetime working               End Datetime working

A                                          11/22/2021    23.00                       11/23/2021   05.00

B                                          11/22/2021    22.00                       11/23/2021   06.00

C                                          11/22/2021    23.00                       11/23/2021   05.00

In modela.py, I selected via field start_date: 11/22/2021

and want to load ALL records of modelb.py which have start date on: 11/22/2021 and end date on: 11/23/2021 without going through time, via the function button using @onchange('start_date')

I'd used compute field with store = True to get start date and end date from start_datetime and end_datetime field like this:

modelb.py :

get_start_date = fields.Date('Start date in modelb', compute='_get_start_datel', store=True)
@api.depends('start_datetime')
def _get_start_date(self):
   for rec in self:
     rec.get_start_date = rec.start_datetime.date()


get_end_date = fields.Date('End date in modelb', compute='_get_end_datel', store=True)
@api.depends('end_datetime')
def _get_end_date(self):
  for rec in self:
     rec.get_end_date = rec.end_datetime.date()


So... with the get_start_date field; I got the right results when it can show all records which have the date on 11/22/2021.

But with the get_end_date field; I got the WRONG results when it still show the date on 11/22/2021 instead of 11/23/2021 


Please help

Thank you


Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
2
jan. 24
2596
2
jun. 22
4528
2
jun. 18
6076
2
nov. 16
13700
2
feb. 24
12571