feat: add date range wizard (travel)
This commit is contained in:
24
work_trace/wizards/wt_date_range_wizard.py
Normal file
24
work_trace/wizards/wt_date_range_wizard.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from odoo import models, fields, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class WtDateRangeWizard(models.TransientModel):
|
||||
_name = 'wt.date.range.wizard'
|
||||
_description = 'WorkTrace Date Range'
|
||||
|
||||
date_from = fields.Date(string='From', required=True)
|
||||
date_to = fields.Date(string='To', required=True)
|
||||
|
||||
def action_view(self):
|
||||
self.ensure_one()
|
||||
if self.date_from > self.date_to:
|
||||
raise UserError(_('Start date must be before end date.'))
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': 'Travel: %s → %s' % (self.date_from, self.date_to),
|
||||
'res_model': 'wt.location.log',
|
||||
'view_mode': 'list,form',
|
||||
'domain': [('date', '>=', self.date_from), ('date', '<=', self.date_to)],
|
||||
'context': {},
|
||||
'target': 'current',
|
||||
}
|
||||
Reference in New Issue
Block a user