-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
283 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
==================== | ||
Timesheet Auto Input | ||
==================== | ||
|
||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
1. Clone the branch 8.0 of the repository https://github.com/open-synergy/opnsynid-hr | ||
2. Add the path to this repository in your configuration (addons-path) | ||
3. Update the module list | ||
4. Go to menu *Setting -> Modules -> Local Modules* | ||
5. Search For *Timesheet Auto Input* | ||
6. Install the module | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Michael Viriyananda <viriyananda.michael@gmail.com> | ||
* Andhitia Rama <andhitia.r@gmail.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://simetri-sinergi.id/logo.png | ||
:alt: PT. Simetri Sinergi Indonesia | ||
:target: https://simetri-sinergi.id.com | ||
|
||
This module is maintained by the PT. Simetri Sinergi Indonesia. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 OpenSynergy Indonesia | ||
# Copyright 2020 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from . import( | ||
models, | ||
wizards, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 OpenSynergy Indonesia | ||
# Copyright 2020 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Timesheet Auto Input", | ||
"version": "8.0.1.0.0", | ||
"website": "https://simetri-sinergi.id", | ||
"author": "PT. Simetri Sinergi Indonesia, OpenSynergy Indonesia", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"auto_install": True, | ||
"depends": [ | ||
"hr_timesheet_sheet", | ||
], | ||
"data": [ | ||
"wizards/wizard_timesheet_auto_input.xml", | ||
"views/hr_timesheet_sheet_view.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 OpenSynergy Indonesia | ||
# Copyright 2020 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from . import ( | ||
hr_timesheet_sheet, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 OpenSynergy Indonesia | ||
# Copyright 2020 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from openerp import models, fields | ||
|
||
|
||
class HrTimesheetSheet(models.Model): | ||
_inherit = "hr_timesheet_sheet.sheet" | ||
|
||
current_timesheet_account_id = fields.Many2one( | ||
string="Current Timesheet Account", | ||
comodel_name="account.analytic.account", | ||
readonly=True, | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2020 OpenSynergy Indonesia | ||
Copyright 2020 PT. Simetri Sinergi Indonesia | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
|
||
<openerp> | ||
<data> | ||
|
||
<record id="hr_timesheet_sheet_views_form" model="ir.ui.view"> | ||
<field name="name">hr.timesheet.sheet.auto.input.form</field> | ||
<field name="model">hr_timesheet_sheet.sheet</field> | ||
<field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form"/> | ||
<field name="priority" eval="30"/> | ||
<field name="arch" type="xml"> | ||
<data> | ||
<xpath expr="//notebook/page[3]/group[1]/group" position="replace"> | ||
<group name="grp_auto_input"> | ||
<label name="lbl_current_timesheet" for="current_timesheet_account_id"/> | ||
<div name="div_current_timesheet"> | ||
<field name="current_timesheet_account_id"/> | ||
</div> | ||
|
||
<label name="lbl_state_attendance" for="state_attendance"/> | ||
<div name="div_state_attendance"> | ||
<field name="state_attendance"/> | ||
<button | ||
name="%(hr_timesheet_sheet_sheet_auto_input_action)d" | ||
attrs="{'invisible': [('state_attendance', '=', 'present')]}" | ||
context="{'state_attendance': 'present'}" | ||
type="action" | ||
string="Sign In" | ||
class="oe_link"/> | ||
<button | ||
name="%(hr_timesheet_sheet_sheet_auto_input_action)d" | ||
attrs="{'invisible': ['|', ('state_attendance','=',False), ('state_attendance', '=', 'absent')]}" | ||
context="{'state_attendance': 'absent'}" | ||
type="action" | ||
string="Sign Out" | ||
class="oe_link"/> | ||
</div> | ||
</group> | ||
</xpath> | ||
</data> | ||
</field> | ||
</record> | ||
|
||
|
||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 OpenSynergy Indonesia | ||
# Copyright 2020 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from . import( | ||
wizard_timesheet_auto_input, | ||
) |
101 changes: 101 additions & 0 deletions
101
hr_timesheet_auto_input/wizards/wizard_timesheet_auto_input.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 OpenSynergy Indonesia | ||
# Copyright 2020 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from openerp import models, fields, api | ||
|
||
|
||
class WizardTimesheetAutoInput(models.TransientModel): | ||
_name = "hr_timesheet_sheet.sheet.auto_input" | ||
_description = "Timesheet Auto Input" | ||
|
||
@api.model | ||
def _default_sheet_id(self): | ||
active_id =\ | ||
self.env.context.get("active_id", False) | ||
return active_id | ||
|
||
sheet_id = fields.Many2one( | ||
string="Timesheet", | ||
comodel_name="hr_timesheet_sheet.sheet", | ||
default=lambda self: self._default_sheet_id(), | ||
) | ||
timesheet_account_id = fields.Many2one( | ||
string="Timesheet Account", | ||
comodel_name="account.analytic.account", | ||
domain=[ | ||
("type", "<>", "view"), | ||
("use_timesheets", "=", True) | ||
], | ||
) | ||
description = fields.Text( | ||
string="Description", | ||
) | ||
|
||
@api.model | ||
def _default_state_attendance(self): | ||
state_attendance =\ | ||
self.env.context.get("state_attendance", False) | ||
return state_attendance | ||
|
||
state_attendance = fields.Selection( | ||
string="State Attendance", | ||
selection=[ | ||
("present", "Present"), | ||
("absent", "Absent"), | ||
], | ||
default=lambda self: self._default_state_attendance(), | ||
) | ||
|
||
@api.multi | ||
def _prepare_present_data(self): | ||
self.ensure_one() | ||
return { | ||
"current_timesheet_account_id": self.timesheet_account_id.id, | ||
} | ||
|
||
@api.multi | ||
def _prepare_absent_data(self): | ||
self.ensure_one() | ||
return { | ||
"current_timesheet_account_id": False, | ||
} | ||
|
||
@api.multi | ||
def _prepare_analytic_timesheet_data(self): | ||
self.ensure_one() | ||
account_id =\ | ||
self.sheet_id.current_timesheet_account_id.id | ||
journal_id =\ | ||
self.sheet_id.employee_id.journal_id.id | ||
difference =\ | ||
self.sheet_id.total_difference | ||
|
||
return { | ||
"sheet_id": self.sheet_id.id, | ||
"name": self.description, | ||
"account_id": account_id, | ||
"journal_id": journal_id, | ||
"unit_amount": difference, | ||
} | ||
|
||
@api.multi | ||
def create_analytic_timesheet(self): | ||
obj_hr_analytic_timesheet =\ | ||
self.env["hr.analytic.timesheet"] | ||
obj_hr_analytic_timesheet.create( | ||
self._prepare_analytic_timesheet_data()) | ||
return True | ||
|
||
@api.multi | ||
def action_ok(self): | ||
self.ensure_one() | ||
|
||
if self.state_attendance == "present": | ||
self.sheet_id.write(self._prepare_present_data()) | ||
else: | ||
self.create_analytic_timesheet() | ||
self.sheet_id.write(self._prepare_absent_data()) | ||
|
||
self.sheet_id.attendance_action_change() | ||
return {"type": "ir.actions.act_window_close"} |
38 changes: 38 additions & 0 deletions
38
hr_timesheet_auto_input/wizards/wizard_timesheet_auto_input.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="hr_timesheet_sheet_sheet_auto_input_view_form" model="ir.ui.view"> | ||
<field name="name">hr.timesheet.sheet.sheet.auto.input.form</field> | ||
<field name="model">hr_timesheet_sheet.sheet.auto_input</field> | ||
<field name="arch" type="xml"> | ||
<form> | ||
<group name="grp_wizard_auto_input"> | ||
<field name="timesheet_account_id" attrs="{'required':[('state_attendance', '=', 'present')], 'invisible':[('state_attendance', '=', 'absent')]}"/> | ||
<field name="description" attrs="{'required':[('state_attendance', '=', 'absent')], 'invisible':[('state_attendance', '=', 'present')]}"/> | ||
<field name="state_attendance" invisible="1"/> | ||
</group> | ||
|
||
<footer> | ||
<button name="action_ok" | ||
type="object" | ||
string="Confirm" | ||
class="oe_highlight"/> | ||
or | ||
<button special="cancel" | ||
string="Cancel"/> | ||
</footer> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="hr_timesheet_sheet_sheet_auto_input_action" model="ir.actions.act_window"> | ||
<field name="name">Sign In/Out</field> | ||
<field name="res_model">hr_timesheet_sheet.sheet.auto_input</field> | ||
<field name="view_type">form</field> | ||
<field name="view_mode">form</field> | ||
<field name="target">new</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |