This commit is contained in:
oscar alvarez 2022-05-10 12:37:32 -05:00
parent 5e9fee2413
commit 073de0129e
4 changed files with 12 additions and 2 deletions

View File

@ -3,6 +3,7 @@
from datetime import datetime
from datetime import time
from decimal import Decimal
from trytond.model import Workflow, ModelView, ModelSQL, fields
from trytond.report import Report
from trytond.pool import Pool
@ -11,6 +12,7 @@ from trytond.pyson import Eval
from trytond.transaction import Transaction
from trytond.i18n import gettext
from .exceptions import StaffAccessEnterError
STATES = {'readonly': (Eval('state') == 'done')}
@ -29,10 +31,10 @@ class StaffAccess(Workflow, ModelSQL, ModelView):
('close', 'Close'),
('done', 'Done'),
], 'State', readonly=True)
shift_kind = fields.Many2One('staff.shift.kind', 'Shift Kind',
states=STATES)
# shift_line = fields.Many2One('staff.shift.line', 'Shift Line',
# states=STATES)
shift_kind = fields.Many2One('staff.shift.kind', 'Shift Kind',
states=STATES)
@classmethod
def __setup__(cls):

View File

@ -18,12 +18,17 @@ class ShiftKind(ModelSQL, ModelView):
start = fields.Time('Start', required=True)
end = fields.Time('End', required=True)
total_time = fields.Function(fields.Float('Total Time'), 'get_total_time')
legal_work_time = fields.Float('Legal Work Time', digits=(2, 2))
@classmethod
def __setup__(cls):
super(ShiftKind, cls).__setup__()
cls._order.insert(0, ('name', 'ASC'))
@staticmethod
def default_legal_work_time():
return 8
def get_total_time(self, name):
if self.start and self.end:
t1 = timedelta(hours=self.start.hour, minutes=self.start.minute)

View File

@ -10,6 +10,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="start"/>
<label name="end"/>
<field name="end"/>
<label name="legal_work_time"/>
<field name="legal_work_time"/>
<label name="total_time"/>
<field name="total_time"/>
</form>

View File

@ -6,5 +6,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="name" expand="1"/>
<field name="start" expand="1"/>
<field name="end" expand="1"/>
<field name="legal_work_time"/>
<field name="total_time"/>
</tree>