Skip to content
Open
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
107 changes: 107 additions & 0 deletions agreement_type/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

==============
Agreement Type
==============

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-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-OCA%2Fagreement-lightgray.png?logo=github
:target: https://github.com/OCA/agreement/tree/19.0/agreement_type
:alt: OCA/agreement
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/agreement-19-0/agreement-19-0-agreement_type
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/agreement&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module turns agreement types into a hierarchy: an agreement type
can have a parent type, so sub-types are simply child agreement types
(the standalone agreement.subtype model is no longer needed).

It also carries the review-reminder feature: the review user/days on the
type, the agreement's computed review date, and the cron that schedules
a review activity before an agreement expires.

.. image:: https://raw.githubusercontent.com/OCA/agreement/19.0/agreement_type/static/description/screenshot_form.png
:alt: Agreement Form

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/agreement/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/OCA/agreement/issues/new?body=module:%20agreement_type%0Aversion:%2019.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
-------

* Pavlov Media
* Open Source Integrators
* Yves Goldberg (Ygol Internetwork)

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

- Pavlov Media
- Open Source Integrators
- Yves Goldberg (Ygol Internetwork)
- `glueckkanja AG <https://www.glueckkanja.com/>`__:

- Christopher Rogos

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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

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

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-max3903| |maintainer-ygol|

This module is part of the `OCA/agreement <https://github.com/OCA/agreement/tree/19.0/agreement_type>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions agreement_type/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
24 changes: 24 additions & 0 deletions agreement_type/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Agreement Type",
"summary": "Hierarchical agreement types (with sub-types) and review reminders",
"author": "Pavlov Media, "
"Open Source Integrators, "
"Yves Goldberg (Ygol Internetwork), "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/agreement",
"category": "Partner",
"license": "AGPL-3",
"version": "19.0.1.0.0",
"depends": ["agreement"],
"excludes": ["agreement_legal"],
"data": [
"data/cron.xml",
"views/agreement_type.xml",
"views/agreement.xml",
],
"development_status": "Beta",
"maintainers": ["max3903", "ygol"],
}
23 changes: 23 additions & 0 deletions agreement_type/data/cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<!-- Add warning days -->
<record id="mail_activity_review_agreement" model="mail.activity.type">
<field name="name">Agreement needs a review</field>
<field name="summary">note</field>
<field name="category">default</field>
<field name="res_model">agreement</field>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
<!--Test warning days -->
<record model="ir.cron" forcecreate="True" id="ir_cron_test_acc_move_except">
<field name="name">Agreement: Check to Review Days</field>
<field name="model_id" ref="agreement.model_agreement" />
<field name="state">code</field>
<field name="code">model._alert_to_review_date()</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_number">20</field>
<field name="interval_type">minutes</field>
<field name="active" eval="True" />
</record>
</odoo>
4 changes: 4 additions & 0 deletions agreement_type/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import agreement_type
from . import agreement
46 changes: 46 additions & 0 deletions agreement_type/models/agreement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import timedelta

from odoo import api, fields, models


class Agreement(models.Model):
_inherit = "agreement"

to_review_date = fields.Date(
compute="_compute_to_review_date",
store=True,
readonly=False,
help="Date used to warn us some days before agreement expires",
)

@api.depends("agreement_type_id", "end_date")
def _compute_to_review_date(self):
for record in self:
if record.end_date:
record.to_review_date = record.end_date + timedelta(
days=-record.agreement_type_id.review_days
)

@api.model
def _alert_to_review_date(self):
agreements = self.search(
[
("to_review_date", "=", fields.Date.today()),
("agreement_type_id.review_user_id", "!=", False),
]
)
for agreement in agreements:
if (
self.env["mail.activity"].search_count(
[("res_id", "=", agreement.id), ("res_model", "=", self._name)]
)
== 0
):
agreement.activity_schedule(
"agreement_legal_type.mail_activity_review_agreement",
user_id=agreement.agreement_type_id.review_user_id.id,
note=self.env._("Your activity is going to end soon"),
)
31 changes: 31 additions & 0 deletions agreement_type/models/agreement_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class AgreementType(models.Model):
_inherit = "agreement.type"

parent_type_id = fields.Many2one(
"agreement.type",
string="Parent Type",
ondelete="cascade",
help="When set, this type is a sub-type of the selected parent type.",
)
child_type_ids = fields.One2many(
"agreement.type", "parent_type_id", string="Sub-Types"
)
review_user_id = fields.Many2one(
"res.users", help="User assigned automatically the activity on review date"
)
review_days = fields.Integer()

@api.depends("name")
def _compute_display_name(self):
for agreement_type in self:
agreement_type.display_name = (
f"{agreement_type.parent_type_id.display_name} / {agreement_type.name}"
if agreement_type.parent_type_id
else agreement_type.name
)
3 changes: 3 additions & 0 deletions agreement_type/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
5 changes: 5 additions & 0 deletions agreement_type/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Pavlov Media
- Open Source Integrators
- Yves Goldberg (Ygol Internetwork)
- [glueckkanja AG](https://www.glueckkanja.com/):
- Christopher Rogos
9 changes: 9 additions & 0 deletions agreement_type/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This module turns agreement types into a hierarchy: an agreement type can have
a parent type, so sub-types are simply child agreement types (the standalone
agreement.subtype model is no longer needed).

It also carries the review-reminder feature: the review user/days on the type,
the agreement's computed review date, and the cron that schedules a review
activity before an agreement expires.

![Agreement Form](../static/description/screenshot_form.png)
Binary file added agreement_type/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading