Skip to content

Commit

Permalink
Merge 9d2b451 into 00bc067
Browse files Browse the repository at this point in the history
  • Loading branch information
andhit-r committed Apr 12, 2020
2 parents 00bc067 + 9d2b451 commit 5df23f7
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 0 deletions.
39 changes: 39 additions & 0 deletions hr_contract_timesheet_pricelist/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

=================================
Timesheet Pricelist From Contract
=================================


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 Pricelist From Contract*
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_contract_timesheet_pricelist/__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,
)
21 changes: 21 additions & 0 deletions hr_contract_timesheet_pricelist/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- 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 Pricelist From Contract",
"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_pricelist",
"hr_contract",
],
"data": [
"security/ir.model.access.csv",
"views/hr_contract_views.xml",
],
}
10 changes: 10 additions & 0 deletions hr_contract_timesheet_pricelist/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 (
hr_contract,
hr_contract_timesheet_pricelist,
hr_analytic_timesheet,
)
38 changes: 38 additions & 0 deletions hr_contract_timesheet_pricelist/models/hr_analytic_timesheet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- 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, api


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

@api.onchange(
"account_id",
"user_id",
"product_id",
)
def onchange_pricelist_id(self):
_super = super(HrAnalyticTimesheet, self)
_super.onchange_pricelist_id()
obj_pricelist = self.env["hr.contract_timesheet_pricelist"]

if not self.pricelist_id and \
self.user_id and \
self.product_id:
employees = self.user_id.employee_ids
if len(employees) > 0:
# TODO: Revisit later
employee = employees[0]
if employee.contract_id:
contract = employee.contract_id
criteria = [
("contract_id", "=", contract.id),
("product_id", "=", self.product_id.id),
]
price_items = obj_pricelist.search(criteria)
if len(price_items) > 0:
self.pricelist_id = price_items[0].pricelist_id.id
17 changes: 17 additions & 0 deletions hr_contract_timesheet_pricelist/models/hr_contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- 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 HrContract(models.Model):
_name = "hr.contract"
_inherit = "hr.contract"

timesheet_pricelist_ids = fields.One2many(
string="Timesheet Pricelist",
comodel_name="hr.contract_timesheet_pricelist",
inverse_name="contract_id",
)
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 HrContractTimesheetPricelist(models.Model):
_name = "hr.contract_timesheet_pricelist"
_description = "Employee Contract Timesheet Pricelist"

contract_id = fields.Many2one(
string="Contract",
comodel_name="hr.contract",
)
product_id = fields.Many2one(
string="Product",
comodel_name="product.product",
required=True,
)
pricelist_id = fields.Many2one(
string="Timesheet Pricelist",
comodel_name="product.pricelist",
required=True,
)
3 changes: 3 additions & 0 deletions hr_contract_timesheet_pricelist/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
hr_contract_timesheet_pricelist_employee,hr.contract_timesheet_pricelist - Employee,hr_contract_timesheet_pricelist.model_hr_contract_timesheet_pricelist,base.group_user,1,1,1,1
hr_contract_timesheet_pricelist_all,hr.contract_timesheet_pricelist - All,hr_contract_timesheet_pricelist.model_hr_contract_timesheet_pricelist,,1,0,0,0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions hr_contract_timesheet_pricelist/views/hr_contract_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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_contract_view_tree" model="ir.ui.view">
<field name="name">hr.contract form</field>
<field name="model">hr.contract</field>
<field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//notebook" position="inside">
<page name="timesheet_pricelist" string="Timesheet Pricelist">
<group name="timesheet_pricelist_1" colspan="4" col="2">
<field name="timesheet_pricelist_ids" nolabel="1" colspan="2">
<tree editable="top">
<field name="product_id" domain="[('type','=','service')]"/>
<field name="pricelist_id" domain="[('type','=','timesheet')]"/>
</tree>
</field>
</group>
</page>
</xpath>
</data>
</field>
</record>


</data>
</openerp>

0 comments on commit 5df23f7

Please sign in to comment.