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

===============
Agreement Stage
===============

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

.. |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_stage
: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_stage
: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 adds a configurable stage workflow to legal agreements.

It introduces the ``agreement.stage`` model, a ``Stage`` field on
agreements with a kanban grouped by stage, a statusbar on the agreement
form, and a stage-driven read-only lock that prevents editing an
agreement once it reaches a stage flagged as read-only.

.. image:: https://raw.githubusercontent.com/OCA/agreement/19.0/agreement_stage/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_stage%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_stage>`_ 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_stage/__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
26 changes: 26 additions & 0 deletions agreement_stage/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Agreement Stage",
"summary": "Add a stage workflow to legal agreements",
"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": [
"security/ir.model.access.csv",
"data/agreement_stage.xml",
"views/agreement_stages.xml",
"views/agreement.xml",
"views/menu.xml",
],
"development_status": "Beta",
"maintainers": ["max3903", "ygol"],
}
63 changes: 63 additions & 0 deletions agreement_stage/data/agreement_stage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<odoo>
<record id="agreement_stage_new" model="agreement.stage">
<field name="name">New</field>
<field name="sequence">10</field>
<field name="stage_type">agreement</field>
</record>

<record id="agreement_stage_draft" model="agreement.stage">
<field name="name">Draft</field>
<field name="sequence">20</field>
<field name="stage_type">agreement</field>
</record>

<record id="agreement_stage_reviewed" model="agreement.stage">
<field name="name">Reviewed</field>
<field name="sequence">30</field>
<field name="stage_type">agreement</field>
</record>

<record id="agreement_stage_negotiation" model="agreement.stage">
<field name="name">Negotiation</field>
<field name="sequence">40</field>
<field name="stage_type">agreement</field>
</record>

<record id="agreement_stage_out" model="agreement.stage">
<field name="name">Out for Customer Signature</field>
<field name="sequence">50</field>
<field name="stage_type">agreement</field>
</record>

<record id="agreement_stage_internal" model="agreement.stage">
<field name="name">Waiting Internal Signature</field>
<field name="sequence">60</field>
<field name="stage_type">agreement</field>
</record>

<record id="agreement_stage_active" model="agreement.stage">
<field name="name">Active</field>
<field name="sequence">70</field>
<field name="stage_type">agreement</field>
</record>

<record id="agreement_stage_expired" model="agreement.stage">
<field name="name">Expired</field>
<field name="sequence">80</field>
<field name="stage_type">agreement</field>
</record>

<record id="agreement_stage_terminated" model="agreement.stage">
<field name="name">Terminated</field>
<field name="sequence">90</field>
<field name="fold">True</field>
<field name="stage_type">agreement</field>
</record>

<record id="agreement_stage_cancelled" model="agreement.stage">
<field name="name">Cancelled</field>
<field name="sequence">100</field>
<field name="fold">True</field>
<field name="stage_type">agreement</field>
</record>
</odoo>
4 changes: 4 additions & 0 deletions agreement_stage/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_stage
from . import agreement
73 changes: 73 additions & 0 deletions agreement_stage/models/agreement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from lxml import etree

from odoo import api, fields, models


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

readonly = fields.Boolean(related="stage_id.readonly")

# Used for Kanban grouped_by view
@api.model
def _read_group_stage_ids(self, stages, domain, order=None):
stage_ids = self.env["agreement.stage"].search(
[("stage_type", "=", "agreement")]
)
return stage_ids

stage_id = fields.Many2one(
"agreement.stage",
string="Stage",
group_expand="_read_group_stage_ids",
help="Select the current stage of the agreement.",
default=lambda self: self._get_default_stage_id(),
tracking=True,
index=True,
copy=False,
)

@api.model
def _get_default_stage_id(self):
try:
stage_id = self.env.ref("agreement_legal_stage.agreement_stage_new").id
except ValueError:
stage_id = False
return stage_id

def _get_old_version_default_vals(self):
vals = super()._get_old_version_default_vals()
vals["stage_id"] = self.stage_id.id
return vals

def _fill_create_vals(self, vals):
vals = super()._fill_create_vals(vals)
if not vals.get("stage_id"):
vals["stage_id"] = self._get_default_stage_id()
return vals

def _exclude_readonly_field(self):
return ["stage_id"]

def _get_agreement_readonly_domain(self):
return "bool(readonly)"

@api.model
def get_view(self, view_id=None, view_type=False, **options):
res = super().get_view(view_id, view_type, **options)
# Readonly fields
if view_type == "form":
doc = etree.XML(res["arch"])
for node in doc.xpath("//field[@name][not(ancestor::field)]"):
if node.attrib.get("name") in self._exclude_readonly_field():
continue
new_r_modifier = self._get_agreement_readonly_domain()
old_r_modifier = node.attrib.get("readonly")
if old_r_modifier:
new_r_modifier = f"({old_r_modifier}) or ({new_r_modifier})"
node.attrib["readonly"] = new_r_modifier
res["arch"] = etree.tostring(doc, encoding="unicode")
return res
27 changes: 27 additions & 0 deletions agreement_stage/models/agreement_stage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


# Main Stage on the Agreement
class AgreementStage(models.Model):
_name = "agreement.stage"
_description = "Agreement Stages"
_order = "sequence"

# General
name = fields.Char(string="Stage Name", required=True, translate=True)
sequence = fields.Integer(default="1", required=False)
fold = fields.Boolean(
string="Is Folded",
required=False,
help="This stage is folded in the kanban view by default.",
)
stage_type = fields.Selection(
[("agreement", "Agreement")], string="Type", required=True
)
active = fields.Boolean(default=True)
readonly = fields.Boolean(
default=False, help="The agreement can not edit if set Readonly = True."
)
3 changes: 3 additions & 0 deletions agreement_stage/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_stage/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
8 changes: 8 additions & 0 deletions agreement_stage/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This module adds a configurable stage workflow to legal agreements.

It introduces the `agreement.stage` model, a `Stage` field on agreements with a
kanban grouped by stage, a statusbar on the agreement form, and a stage-driven
read-only lock that prevents editing an agreement once it reaches a stage
flagged as read-only.

![Agreement Form](../static/description/screenshot_form.png)
3 changes: 3 additions & 0 deletions agreement_stage/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
access_agreement_stage_readonly,stage readonly,model_agreement_stage,agreement.group_agreement_readonly,1,0,0,0
access_agreement_stage_manager,stage manager,model_agreement_stage,agreement.group_agreement_manager,1,1,1,1
Binary file added agreement_stage/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