Skip to content

Commit

Permalink
Merge bfb9bb2 into 1f905f7
Browse files Browse the repository at this point in the history
  • Loading branch information
andhit-r committed Aug 22, 2020
2 parents 1f905f7 + bfb9bb2 commit ae3cbf7
Show file tree
Hide file tree
Showing 34 changed files with 799 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"website": "https://opensynergy-indonesia.com",
"author": "OpenSynergy Indonesia",
"license": "AGPL-3",
"installable": True,
"installable": False,
"depends": [
"hr_attendance_overtime_request",
"base_tier_validation",
Expand Down
2 changes: 1 addition & 1 deletion hr_expense_tier_validation/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"website": "https://opensynergy-indonesia.com",
"author": "OpenSynergy Indonesia",
"license": "AGPL-3",
"installable": True,
"installable": False,
"depends": [
"hr_expense",
"base_tier_validation",
Expand Down
2 changes: 1 addition & 1 deletion hr_payslip_tier_validation/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"website": "https://opensynergy-indonesia.com",
"author": "OpenSynergy Indonesia",
"license": "AGPL-3",
"installable": True,
"installable": False,
"depends": [
"hr_payslip_extend",
"base_tier_validation",
Expand Down
39 changes: 39 additions & 0 deletions hr_timesheet_accrue_income/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.. 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

=================================================
Generate Accrue Income Based On Timesheet Details
=================================================


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 *Generate Accrue Income Based On Timesheet Details*
6. Install the module

Credits
=======

Contributors
------------

* Michael Viriyananda <viriyananda.michael@gmail.com>
* Andhitia Rama <andhitia.r@gmail.com>
* Nurazmi <azmimr67@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.
8 changes: 8 additions & 0 deletions hr_timesheet_accrue_income/__init__.py
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,
)
25 changes: 25 additions & 0 deletions hr_timesheet_accrue_income/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- 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": "Generate Accrue Income Based On Timesheet Details",
"version": "8.0.1.0.0",
"website": "https://simetri-sinergi.id",
"author": "PT. Simetri Sinergi Indonesia, OpenSynergy Indonesia",
"license": "AGPL-3",
"installable": True,
"depends": [
"account_analytic_analysis",
"hr_timesheet_bypass_check",
"hr_timesheet_onchange",
],
"data": [
"views/hr_employee_views.xml",
"views/account_analytic_account_views.xml",
"views/hr_analytic_timesheet_views.xml",
],
"images": [
"static/description/banner.png",
],
}
10 changes: 10 additions & 0 deletions hr_timesheet_accrue_income/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- 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 (
account_analytic_account,
hr_analytic_timesheet,
hr_employee,
)
33 changes: 33 additions & 0 deletions hr_timesheet_accrue_income/models/account_analytic_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- 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 AccountAnalyticAccount(models.Model):
_name = "account.analytic.account"
_inherit = "account.analytic.account"

accrue_income_journal_id = fields.Many2one(
string="Accrue Income Journal",
comodel_name="account.journal",
domain=[
("type", "=", "general"),
],
)
accrue_income_account_id = fields.Many2one(
string="Accrue Income Account",
comodel_name="account.account",
domain=[
("type", "=", "other"),
],
)
accrue_income_ok = fields.Boolean(
string="Can Create Accrue Income",
default=False,
)
prepaid_price_unit = fields.Float(
string="Prepaid Price Unit",
)
205 changes: 205 additions & 0 deletions hr_timesheet_accrue_income/models/hr_analytic_timesheet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# -*- 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 fields, models, api, _
from openerp.exceptions import Warning as UserError


class HrAnalyticTimesheet(models.Model):
_name = "hr.analytic.timesheet"
_inherit = "hr.analytic.timesheet"

accrue_income_journal_id = fields.Many2one(
string="Accrue Income Journal",
comodel_name="account.journal",
domain=[
("type", "=", "general"),
],
)
accrue_income_account_id = fields.Many2one(
string="Accrue Income Account",
comodel_name="account.account",
domain=[
("type", "=", "other"),
],
)
accrue_income_ok = fields.Boolean(
string="Can Create Accrue Income",
default=False,
)
accrue_income_move_id = fields.Many2one(
string="Accrue Income Move",
comodel_name="account.move",
readonly=True,
ondelete="restrict",
)

@api.onchange(
"user_id",
"account_id",
)
def onchange_accrue_income_journal_id(self):
journal = False
if self.user_id and \
len(self.user_id.employee_ids) > 0 and \
self.user_id.employee_ids[0].accrue_income_journal_id:
journal = self.user_id.employee_ids[0].accrue_income_journal_id

if not journal and \
self.account_id and \
self.account_id.accrue_income_journal_id:
journal = self.account_id.accrue_income_journal_id

self.accrue_income_journal_id = journal

@api.onchange(
"user_id",
"account_id",
)
def onchange_accrue_income_account_id(self):
account = False
if self.user_id and \
len(self.user_id.employee_ids) > 0 and \
self.user_id.employee_ids[0].accrue_income_account_id:
account = self.user_id.employee_ids[0].accrue_income_account_id

if not account and \
self.account_id and \
self.account_id.accrue_income_account_id:
account = self.account_id.accrue_income_account_id

self.accrue_income_account_id = account

@api.onchange(
"account_id",
)
def onchange_accrue_income_ok(self):
result = False

if self.account_id:
result = self.account_id.accrue_income_ok

self.accrue_income_ok = result

@api.multi
def action_create_accrue_income_move(self):
for document in self:
document._create_accrue_income_move()

@api.multi
def action_unlink_accrue_income_move(self):
for document in self:
document._unlink_accrue_income_move()

@api.multi
def _unlink_accrue_income_move(self):
self.ensure_one()
move = self.accrue_income_move_id
self.write({
"accrue_income_move_id": False,
})
move.unlink()

@api.multi
def _create_accrue_income_move(self):
self.ensure_one()
obj_move = self.env["account.move"]
move = obj_move.create(self._prepare_accrue_income_move())
self.write({
"accrue_income_move_id": move.id,
})

@api.multi
def _get_accrue_income_journal(self):
self.ensure_one()
if not self.accrue_income_journal_id:
err_msg = _("No accrue income journal defined")
raise UserError(err_msg)
return self.accrue_income_journal_id

@api.multi
def _get_accrue_income_account(self):
self.ensure_one()
if not self.accrue_income_account_id:
err_msg = _("No accrue income account defined")
raise UserError(err_msg)
return self.accrue_income_account_id

@api.multi
def _get_income_account(self):
self.ensure_one()
result = self.product_id.categ_id.property_account_income_categ
if not result:
result = self.product_id.property_income_account
if not result:
err_msg = _("No income account defined")
raise UserError(err_msg)
return result

@api.multi
def _get_period(self):
self.ensure_one()
period = self.env["account.period"].find(self.date)
return period

@api.multi
def _prepare_accrue_income_move(self):
self.ensure_one()
journal = self._get_accrue_income_journal()
period = self._get_period()
return {
"journal_id": journal.id,
"period_id": period.id,
"date": self.date,
"line_id": self._prepare_move_lines()
}

@api.multi
def _prepare_move_lines(self):
self.ensure_one()
result = []
result.append(self._prepare_accrue_income_line())
result.append(self._prepare_income_line())
return result

@api.multi
def _get_partner(self):
self.ensure_one()
partner = self.account_id.partner_id
if not partner:
err_msg = _("No customer defined")
raise UserError(err_msg)
return partner

@api.multi
def _prepare_accrue_income_line(self):
self.ensure_one()
amount = self.unit_amount * self.account_id.prepaid_price_unit
return (0, 0, {
"account_id": self._get_accrue_income_account().id,
"credit": 0.0,
"debit": amount,
"partner_id": self._get_partner().id,
"name": self.name,
"product_id": self.product_id.id,
"product_uom_id": self.product_uom_id.id,
"quantity": self.unit_amount,
})

@api.multi
def _prepare_income_line(self):
self.ensure_one()
amount = self.unit_amount * self.account_id.prepaid_price_unit
return (0, 0, {
"account_id": self._get_income_account().id,
"analytic_account_id": self.account_id.id,
"debit": 0.0,
"credit": amount,
"partner_id": self._get_partner().id,
"name": self.name,
"product_id": self.product_id.id,
"product_uom_id": self.product_uom_id.id,
"quantity": self.unit_amount,
})
26 changes: 26 additions & 0 deletions hr_timesheet_accrue_income/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- 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 HrEmployee(models.Model):
_name = "hr.employee"
_inherit = "hr.employee"

accrue_income_journal_id = fields.Many2one(
string="Accrue Income Journal",
comodel_name="account.journal",
domain=[
("type", "=", "general"),
],
)
accrue_income_account_id = fields.Many2one(
string="Accrue Income Account",
comodel_name="account.account",
domain=[
("type", "=", "other"),
],
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ae3cbf7

Please sign in to comment.