Skip to content

Commit

Permalink
[17.0][MIG] agreement_legal: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ilo authored and luisDIXMIT committed Jan 27, 2025
1 parent c7fb879 commit e0d17c4
Show file tree
Hide file tree
Showing 21 changed files with 303 additions and 356 deletions.
47 changes: 24 additions & 23 deletions agreement_legal/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,29 @@ Configuration

To configure this module:

- Go to Agreement > Configuration > Templates
- Create a new template with sections and clauses and their respective
content
- Go to Agreement > Configuration > Stages
- Create and reorder stages to match your process
- Go to Agreement > Configuration > Templates
- Create a new template with sections and clauses and their respective
content
- Go to Agreement > Configuration > Stages
- Create and reorder stages to match your process

Usage
=====

To use this module:

- Go to Agreement > Agreements
- Create a new agreement
- Select a template
- Follow the process to get the required approval
- Send the invitation to the customer to review and sign the agreement
- Go to Agreement > Agreements
- Create a new agreement
- Select a template
- Follow the process to get the required approval
- Send the invitation to the customer to review and sign the agreement

Known issues / Roadmap
======================

- Split the module to remove the dependencies on sale and account and
provide the same feature in extra modules (agreement_sale,
agreement_account, agreement_purchase)
- Split the module to remove the dependencies on sale and account and
provide the same feature in extra modules (agreement_sale,
agreement_account, agreement_purchase)

Bug Tracker
===========
Expand All @@ -96,22 +96,23 @@ Authors
Contributors
------------

- Patrick Wilson <[email protected]>
- Bhavesh Odedra <[email protected]>
- Wolfgang Hall <[email protected]>
- Maxime Chambreuil <[email protected]>
- Sandip Mangukiya <[email protected]>
- Yves Goldberg <[email protected]>
- Tharathip Chaweewongphan <[email protected]>
- Patrick Wilson <[email protected]>
- Bhavesh Odedra <[email protected]>
- Wolfgang Hall <[email protected]>
- Maxime Chambreuil <[email protected]>
- Sandip Mangukiya <[email protected]>
- Yves Goldberg <[email protected]>
- Tharathip Chaweewongphan <[email protected]>
- Italo LOPES <[email protected]>

Other credits
-------------

The development of this module has been financially supported by:

- Pavlov Media
- Open Source Integrators
- Yves Goldberg
- Pavlov Media
- Open Source Integrators
- Yves Goldberg

Maintainers
-----------
Expand Down
56 changes: 15 additions & 41 deletions agreement_legal/models/agreement.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import ast
import json as simplejson
from datetime import timedelta

from lxml import etree
Expand Down Expand Up @@ -144,9 +142,7 @@ def _get_default_parties(self):
"""
return deftext

parties = fields.Html(
tracking=True, default=_get_default_parties, help="Parties of the agreement"
)
parties = fields.Html(default=_get_default_parties, help="Parties of the agreement")
dynamic_parties = fields.Html(
compute="_compute_dynamic_parties", help="Compute dynamic parties"
)
Expand Down Expand Up @@ -233,9 +229,9 @@ def _get_default_parties(self):
field_id = fields.Many2one(
"ir.model.fields",
string="Field",
help="""Select target field from the related document model. If it is a
relationship field you will be able to select a target field at the
destination of the relationship.""",
help="""You can select a target field from the related document model.
If it is a relationship field you will be able to select a target field
at the destination of the relationship.""",
)
sub_object_id = fields.Many2one(
"ir.model",
Expand Down Expand Up @@ -465,44 +461,22 @@ def copy(self, default=None):
def _exclude_readonly_field(self):
return ["stage_id"]

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

@api.model
def fields_view_get(
self, view_id=None, view_type=False, toolbar=False, submenu=False
):
res = super().fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
)
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"):
for node in doc.xpath("//field[@name][not(ancestor::field)]"):
if node.attrib.get("name") in self._exclude_readonly_field():
continue
attrs = ast.literal_eval(node.attrib.get("attrs", "{}"))
if attrs:
if attrs.get("readonly"):
attrs["readonly"] = ["|", ("readonly", "=", True)] + attrs[
"readonly"
]
else:
attrs["readonly"] = [("readonly", "=", True)]
else:
attrs["readonly"] = [("readonly", "=", True)]
node.set("attrs", simplejson.dumps(attrs))
modifiers = ast.literal_eval(
node.attrib.get("modifiers", "{}")
.replace("true", "True")
.replace("false", "False")
)
readonly = modifiers.get("readonly")
invisible = modifiers.get("invisible")
required = modifiers.get("required")
if isinstance(readonly, bool) and readonly:
attrs["readonly"] = readonly
if isinstance(invisible, bool) and invisible:
attrs["invisible"] = invisible
if isinstance(required, bool) and required:
attrs["required"] = required
node.set("modifiers", simplejson.dumps(attrs))
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)
return res
1 change: 1 addition & 0 deletions agreement_legal/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
- Sandip Mangukiya \<<[email protected]>\>
- Yves Goldberg \<<[email protected]>\>
- Tharathip Chaweewongphan \<<[email protected]>\>
- Italo LOPES \<<[email protected]>\>
12 changes: 8 additions & 4 deletions agreement_legal/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -451,6 +452,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<li>Sandip Mangukiya &lt;<a class="reference external" href="mailto:smangukiya&#64;opensourceintegrators.com">smangukiya&#64;opensourceintegrators.com</a>&gt;</li>
<li>Yves Goldberg &lt;<a class="reference external" href="mailto:yves&#64;ygol.com">yves&#64;ygol.com</a>&gt;</li>
<li>Tharathip Chaweewongphan &lt;<a class="reference external" href="mailto:tharathipc&#64;ecosoft.co.th">tharathipc&#64;ecosoft.co.th</a>&gt;</li>
<li>Italo LOPES &lt;<a class="reference external" href="mailto:italo.lopes&#64;camptocamp.com">italo.lopes&#64;camptocamp.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand All @@ -465,7 +467,9 @@ <h2><a class="toc-backref" href="#toc-entry-8">Other credits</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
2 changes: 1 addition & 1 deletion agreement_legal/static/src/js/form_view.esm.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @odoo-module **/

import {registry} from "@web/core/registry";
import {FormController} from "@web/views/form/form_controller";
import {formView} from "@web/views/form/form_view";
import {registry} from "@web/core/registry";
import {useService} from "@web/core/utils/hooks";

export class AgreementFormController extends FormController {
Expand Down
4 changes: 2 additions & 2 deletions agreement_legal/static/src/js/kanban_view.esm.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @odoo-module **/

import {registry} from "@web/core/registry";
import {KanbanController} from "@web/views/kanban/kanban_controller";
import {kanbanView} from "@web/views/kanban/kanban_view";
import {registry} from "@web/core/registry";
import {useService} from "@web/core/utils/hooks";

export class AgreementKanbanController extends KanbanController {
Expand All @@ -19,7 +19,7 @@ export class AgreementKanbanController extends KanbanController {
export const AgreementKanbanView = {
...kanbanView,
Controller: AgreementKanbanController,
buttonTemplate: "agreement.KanbanView.Buttons",
buttonTemplate: "agreement_legal.KanbanViewButtons",
};

registry.category("views").add("agreement_template_kanban", AgreementKanbanView);
4 changes: 2 additions & 2 deletions agreement_legal/static/src/js/list_view.esm.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @odoo-module **/

import {registry} from "@web/core/registry";
import {ListController} from "@web/views/list/list_controller";
import {listView} from "@web/views/list/list_view";
import {registry} from "@web/core/registry";
import {useService} from "@web/core/utils/hooks";

export class AgreementListController extends ListController {
Expand All @@ -19,7 +19,7 @@ export class AgreementListController extends ListController {
export const AgreementListView = {
...listView,
Controller: AgreementListController,
buttonTemplate: "agreement.ListView.Buttons",
buttonTemplate: "agreement_legal.ListView",
};

registry.category("views").add("agreement_template_tree", AgreementListView);
64 changes: 0 additions & 64 deletions agreement_legal/static/src/xml/agreement.xml

This file was deleted.

21 changes: 21 additions & 0 deletions agreement_legal/static/src/xml/agreement_form_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>

<t t-inherit="web.FormView" t-inherit-mode="extension">
<xpath
expr="//*[@class='btn btn-secondary o_form_button_create']"
position="after"
>
<t t-if="props.resModel === 'agreement'">
<t t-call="agreement_legal.TemplateButton" />
</t>
</xpath>
<xpath
expr="//*[@class='btn btn-secondary o_form_button_create']"
position="attributes"
>
<attribute name="t-if">canCreateTemplate</attribute>
</xpath>
</t>

</templates>
24 changes: 24 additions & 0 deletions agreement_legal/static/src/xml/agreement_kanban_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>

<t
t-name="agreement_legal.KanbanViewButtons"
t-inherit="web.KanbanView.Buttons"
t-inherit-mode="primary"
>
<div role="toolbar" position="inside">
<t t-call="agreement_legal.TemplateButton" />
</div>
</t>
<t
t-name="agreement_legal.KanbanView"
t-inherit="web.KanbanView"
t-inherit-mode="primary"
>
<xpath expr="//button[hasclass('o-kanban-button-new')]" position="attributes">
<attribute name="t-if">!noCreate and canCreateTemplate</attribute>
</xpath>
</t>


</templates>
17 changes: 17 additions & 0 deletions agreement_legal/static/src/xml/agreement_list_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t
t-name="agreement_legal.ListView"
t-inherit="web.ListView.Buttons"
t-inherit-mode="primary"
>
<xpath expr="//div[hasclass('o_list_buttons')]" position="attributes">
<attribute name="t-if">canCreateTemplate</attribute>
</xpath>
<xpath expr="//div[hasclass('o_list_buttons')]" position="after">
<t t-call="agreement_legal.TemplateButton" />
</xpath>
</t>


</templates>
Loading

0 comments on commit e0d17c4

Please sign in to comment.