Wizard access control group
This commit is contained in:
parent
59f465daa4
commit
4623b9c6fb
|
@ -15,10 +15,12 @@ def register():
|
|||
shift.SectionEmployee,
|
||||
shift.AddShiftStart,
|
||||
access.ReportHoursStart,
|
||||
access.AddAccessGroupStart,
|
||||
module='staff_access', type_='model')
|
||||
Pool.register(
|
||||
shift.AddShift,
|
||||
access.ReportHoursWiz,
|
||||
access.AddAccessGroup,
|
||||
module='staff_access', type_='wizard')
|
||||
Pool.register(
|
||||
access.ReportHours,
|
||||
|
|
51
access.py
51
access.py
|
@ -6,11 +6,11 @@ from decimal import Decimal
|
|||
from trytond.model import Workflow, ModelView, ModelSQL, fields
|
||||
from trytond.report import Report
|
||||
from trytond.pool import Pool
|
||||
from trytond.wizard import Wizard, StateView, Button, StateReport
|
||||
from trytond.wizard import Wizard, StateView, Button, StateReport, StateTransition
|
||||
from trytond.pyson import Eval
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
__all__ = ['StaffAccess']
|
||||
__all__ = ['StaffAccess', 'AddAccessGroup', 'AddAccessGroupStart']
|
||||
|
||||
STATES = {'readonly': (Eval('state') == 'done')}
|
||||
|
||||
|
@ -236,3 +236,50 @@ class ReportHours(Report):
|
|||
report_context['month'] = period.name
|
||||
report_context['records'] = lines_dom
|
||||
return report_context
|
||||
|
||||
|
||||
class AddAccessGroupStart(ModelView):
|
||||
'Add Access group Start'
|
||||
__name__ = 'staff.access.add_access_group.start'
|
||||
enter_timestamp = fields.DateTime('Enter', required=True, states=STATES)
|
||||
exit_timestamp = fields.DateTime('Exit', required=True, states=STATES)
|
||||
start_rest = fields.DateTime('Start Rest', required=True, states=STATES)
|
||||
end_rest = fields.DateTime('End Rest', required=True, states=STATES)
|
||||
employees = fields.Many2Many('company.employee', None, None,
|
||||
'Employees', required=True,
|
||||
domain=[('contracting_state', '=', 'active')])
|
||||
project = fields.Many2One('project.work', 'Project')
|
||||
|
||||
|
||||
class AddAccessGroup(Wizard):
|
||||
'Add Access Group'
|
||||
__name__ = 'staff.access.add_access_group'
|
||||
|
||||
start = StateView('staff.access.add_access_group.start',
|
||||
'staff_access.add_access_group_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Ok', 'accept', 'tryton-ok', default=True),
|
||||
])
|
||||
accept = StateTransition()
|
||||
|
||||
def transition_accept(self):
|
||||
Access = Pool().get('staff.access')
|
||||
|
||||
enter_ = self.start.enter_timestamp
|
||||
exit_ = self.start.exit_timestamp
|
||||
enter_rest_ = self.start.start_rest
|
||||
exit_rest_ = self.start.end_rest
|
||||
project_ = self.start.project
|
||||
|
||||
for e in self.start.employees:
|
||||
value = {
|
||||
'employee': e.id,
|
||||
'enter_timestamp': enter_,
|
||||
'exit_timestamp': exit_,
|
||||
'start_rest': enter_rest_,
|
||||
'end_rest': exit_rest_,
|
||||
'rest': Access.compute_timedelta(self, enter_rest_, exit_rest_),
|
||||
'project': project_,
|
||||
}
|
||||
Access.create([value])
|
||||
return 'end'
|
||||
|
|
16
access.xml
16
access.xml
|
@ -52,5 +52,21 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<menuitem parent="staff.menu_reporting" id="menu_report_hours"
|
||||
sequence="100" action="wizard_report_hours"/>
|
||||
|
||||
<record model="ir.action.wizard" id="wizard_add_access_group">
|
||||
<field name="name">Add access group</field>
|
||||
<field name="wiz_name">staff.access.add_access_group</field>
|
||||
<field name="model">staff.access</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="add_access_group_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">staff.access,-1</field>
|
||||
<field name="action" ref="wizard_add_access_group"/>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="add_access_group_view_form">
|
||||
<field name="type">form</field>
|
||||
<field name="model">staff.access.add_access_group.start</field>
|
||||
<field name="name">add_access_group_view_form</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
BIN
shift_sheet.ods
BIN
shift_sheet.ods
Binary file not shown.
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<group colspan='4'>
|
||||
<group colspan='2'>
|
||||
<label name="enter_timestamp" />
|
||||
<field name="enter_timestamp" widget="date"/>
|
||||
<field name="enter_timestamp" widget="time"/>
|
||||
</group>
|
||||
<group colspan='2'>
|
||||
<label name="exit_timestamp" />
|
||||
<field name="exit_timestamp" widget="date"/>
|
||||
<field name="exit_timestamp" widget="time"/>
|
||||
</group>
|
||||
</group>
|
||||
<group colspan='4'>
|
||||
<group colspan='2'>
|
||||
<label name="start_rest"/>
|
||||
<field name="start_rest" widget="date"/>
|
||||
<field name="start_rest" widget="time"/>
|
||||
</group>
|
||||
<group colspan='2'>
|
||||
<label name="end_rest"/>
|
||||
<field name="end_rest" widget="date"/>
|
||||
<field name="end_rest" widget="time"/>
|
||||
</group>
|
||||
</group>
|
||||
<label name="project"/>
|
||||
<field name="project"/>
|
||||
<separator name="employees" colspan="4"/>
|
||||
<field name="employees" colspan="4"/>
|
||||
</form>
|
Loading…
Reference in New Issue