Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions res_project/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
==================
Project Management
==================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:04b18a5acdb42879701da5bafdcc0bd18504edaa08eedf7924375aa61e1a15e6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-ecosoft--odoo%2Fbudgeting-lightgray.png?logo=github
:target: https://github.com/ecosoft-odoo/budgeting/tree/18.0/res_project
:alt: ecosoft-odoo/budgeting

|badge1| |badge2| |badge3|

This module is one of the master data used in all Project sections as
information

This module adds the possibility of defining a sequence for the
project's reference. The reference is then set as the default when
creating a new project, using the defined sequence.

NOTE: Before installing this module, you should check the following
information

- For projects that have a parent project, the code will be overwritten
with the code of the parent project and followed by a sub-code, such
as PJ00001-1

- For main projects, if the code already exists, it will not be changed.
However, if the code does not exist, a new code will be automatically
assigned

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, following access right must be set.

- Go to Settings > Users & Companies > Users

- Select User that you have to see Project

- Select access right on Res Project Field

- Project User
- Project Manager

To configure sequence, following access right must be set.

- You can change the default sequence (PJ00001) by the one of your
choice going to *Settings > Technical > Sequences & Identifiers >
Sequences*, and editing the record name ``Res Project Sequence``.

**Note:**

- Project User: Users will be able to see all project documents but
cannot create documents.
- Project Manager: Users will be able to see all project documents,
create documents and configuration.
- You will only have access to that section if your section has
``Technical features`` permission check marked.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/ecosoft-odoo/budgeting/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/ecosoft-odoo/budgeting/issues/new?body=module:%20res_project%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Ecosoft

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

- ``Ecosoft <http://ecosoft.co.th>``\ \_\_:

- Pimolnat Suntian pimolnats@ecosoft.co.th
- Saran Lim. saranl@ecosoft.co.th

Maintainers
-----------

.. |maintainer-Saran440| image:: https://github.com/Saran440.png?size=40px
:target: https://github.com/Saran440
:alt: Saran440

Current maintainer:

|maintainer-Saran440|

This module is part of the `ecosoft-odoo/budgeting <https://github.com/ecosoft-odoo/budgeting/tree/18.0/res_project>`_ project on GitHub.

You are welcome to contribute.
5 changes: 5 additions & 0 deletions res_project/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from . import wizard
from .hooks import assign_new_sequences
27 changes: 27 additions & 0 deletions res_project/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2020 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Project Management",
"summary": "New menu Projects management",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"category": "Project",
"website": "https://github.com/ecosoft-odoo/budgeting",
"author": "Ecosoft, Odoo Community Association (OCA)",
"depends": ["hr", "mail"],
"data": [
"security/res_project_security_groups.xml",
"security/ir.model.access.csv",
"data/res_project_cron.xml",
"data/res_project_data.xml",
"views/res_project_menuitem.xml",
"views/res_project_views.xml",
"views/res_project_split.xml",
"views/hr_department_views.xml",
"views/hr_employee_views.xml",
"wizard/split_project_wizard_view.xml",
],
"maintainers": ["Saran440"],
"development_status": "Alpha",
}
19 changes: 19 additions & 0 deletions res_project/data/res_project_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="ir_cron_res_project_expired" model="ir.cron" forcecreate="True">
<field
name="name"
>Res Project: Automatically change state expiration date</field>
<field name="model_id" ref="res_project.model_res_project" />
<field name="state">code</field>
<field name="code">model.action_auto_expired()</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field
name="nextcall"
eval="(datetime.now() + timedelta(days=1)).strftime('%Y-%m-%d 00:00:00')"
/>
<field name="active" eval="True" />
</record>
</odoo>
9 changes: 9 additions & 0 deletions res_project/data/res_project_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="seq_project" model="ir.sequence">
<field name="name">Res Project Sequence</field>
<field name="code">res.project</field>
<field name="padding" eval="5" />
<field name="prefix">PJ</field>
</record>
</odoo>
46 changes: 46 additions & 0 deletions res_project/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import SUPERUSER_ID, _, api
from odoo.exceptions import UserError


def generate_code_from_parent(parent_project):
"""generate code for project from its parent's code"""
next_split = parent_project.next_split
code = f"{parent_project.code}-{next_split}"
parent_project.write({"next_split": next_split + 1})
return code


def check_recursive_project(project):
"""Check if project has a recursive parent"""
parent_project = project
project_list = []
while parent_project.parent_project_id:
if project.id in project_list:
raise UserError(
_(
"Please check 'Parent Project' in project '{}' "
"must not be recursive."
).format(project.name)
)
project_list.append(parent_project.parent_project_id.id)
parent_project = parent_project.parent_project_id


def assign_new_sequences(cr, registry):
"""Assign new sequences to projects"""
env = api.Environment(cr, SUPERUSER_ID, {})
project_obj = env["res.project"]
sequence_obj = env["ir.sequence"]
projects = project_obj.with_context(active_test=False).search([], order="id")
for project in projects:
check_recursive_project(project)
parent_project = project.parent_project_id
# Skip it, if project is parent and has code already
if parent_project and parent_project.code != "/":
code = generate_code_from_parent(parent_project)
project.write({"code": code})
elif project.code == "/":
project.write({"code": sequence_obj.next_by_code("res.project")})
6 changes: 6 additions & 0 deletions res_project/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import hr_department
from . import hr_employee_base
from . import res_project_plan
from . import res_project
16 changes: 16 additions & 0 deletions res_project/models/hr_department.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2020 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class Department(models.Model):
_inherit = "hr.department"

project_ids = fields.One2many(
comodel_name="res.project",
inverse_name="department_id",
copy=False,
help="Project to which this department is linked "
"for structure organization.",
)
15 changes: 15 additions & 0 deletions res_project/models/hr_employee_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models


class HrEmployeeBase(models.AbstractModel):
_inherit = "hr.employee.base"

project_ids = fields.Many2many(
comodel_name="res.project",
relation="project_employee_rel",
column1="employee_id",
column2="project_id",
string="Project",
)
Loading
Loading