diff --git a/agreement_legal/README.rst b/agreement_legal/README.rst index 1d1c55df..caaa7e20 100644 --- a/agreement_legal/README.rst +++ b/agreement_legal/README.rst @@ -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 =========== @@ -96,22 +96,23 @@ Authors Contributors ------------ -- Patrick Wilson -- Bhavesh Odedra -- Wolfgang Hall -- Maxime Chambreuil -- Sandip Mangukiya -- Yves Goldberg -- Tharathip Chaweewongphan +- Patrick Wilson +- Bhavesh Odedra +- Wolfgang Hall +- Maxime Chambreuil +- Sandip Mangukiya +- Yves Goldberg +- Tharathip Chaweewongphan +- Italo LOPES 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 ----------- diff --git a/agreement_legal/models/agreement.py b/agreement_legal/models/agreement.py index a07a1985..e6a41934 100644 --- a/agreement_legal/models/agreement.py +++ b/agreement_legal/models/agreement.py @@ -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 @@ -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" ) @@ -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", @@ -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 diff --git a/agreement_legal/readme/CONTRIBUTORS.md b/agreement_legal/readme/CONTRIBUTORS.md index 3d6bc2d8..114aafda 100644 --- a/agreement_legal/readme/CONTRIBUTORS.md +++ b/agreement_legal/readme/CONTRIBUTORS.md @@ -5,3 +5,4 @@ - Sandip Mangukiya \<\> - Yves Goldberg \<\> - Tharathip Chaweewongphan \<\> +- Italo LOPES \<\> diff --git a/agreement_legal/static/description/index.html b/agreement_legal/static/description/index.html index f07cdbae..203f1ce6 100644 --- a/agreement_legal/static/description/index.html +++ b/agreement_legal/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -: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. @@ -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 } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -451,6 +452,7 @@

Contributors

  • Sandip Mangukiya <smangukiya@opensourceintegrators.com>
  • Yves Goldberg <yves@ygol.com>
  • Tharathip Chaweewongphan <tharathipc@ecosoft.co.th>
  • +
  • Italo LOPES <italo.lopes@camptocamp.com>
  • @@ -465,7 +467,9 @@

    Other credits

    Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +Odoo Community Association +

    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.

    diff --git a/agreement_legal/static/src/js/form_view.esm.js b/agreement_legal/static/src/js/form_view.esm.js index ee4dc264..7504e495 100644 --- a/agreement_legal/static/src/js/form_view.esm.js +++ b/agreement_legal/static/src/js/form_view.esm.js @@ -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 { diff --git a/agreement_legal/static/src/js/kanban_view.esm.js b/agreement_legal/static/src/js/kanban_view.esm.js index ade31a32..813ef77a 100644 --- a/agreement_legal/static/src/js/kanban_view.esm.js +++ b/agreement_legal/static/src/js/kanban_view.esm.js @@ -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 { @@ -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); diff --git a/agreement_legal/static/src/js/list_view.esm.js b/agreement_legal/static/src/js/list_view.esm.js index 99b9dd22..f9e7393f 100644 --- a/agreement_legal/static/src/js/list_view.esm.js +++ b/agreement_legal/static/src/js/list_view.esm.js @@ -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 { @@ -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); diff --git a/agreement_legal/static/src/xml/agreement.xml b/agreement_legal/static/src/xml/agreement.xml deleted file mode 100644 index 130ec37c..00000000 --- a/agreement_legal/static/src/xml/agreement.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - canCreateTemplate - - - - - - - - - - - - - canCreateTemplate - - - - - - - - !noCreate and canCreateTemplate - - - - - - diff --git a/agreement_legal/static/src/xml/agreement_form_view.xml b/agreement_legal/static/src/xml/agreement_form_view.xml new file mode 100644 index 00000000..86842468 --- /dev/null +++ b/agreement_legal/static/src/xml/agreement_form_view.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + canCreateTemplate + + + + diff --git a/agreement_legal/static/src/xml/agreement_kanban_view.xml b/agreement_legal/static/src/xml/agreement_kanban_view.xml new file mode 100644 index 00000000..ffa55629 --- /dev/null +++ b/agreement_legal/static/src/xml/agreement_kanban_view.xml @@ -0,0 +1,24 @@ + + + + +
    + +
    +
    + + + !noCreate and canCreateTemplate + + + + +
    diff --git a/agreement_legal/static/src/xml/agreement_list_view.xml b/agreement_legal/static/src/xml/agreement_list_view.xml new file mode 100644 index 00000000..1312636c --- /dev/null +++ b/agreement_legal/static/src/xml/agreement_list_view.xml @@ -0,0 +1,17 @@ + + + + + canCreateTemplate + + + + + + + + diff --git a/agreement_legal/static/src/xml/agreement_template.xml b/agreement_legal/static/src/xml/agreement_template.xml new file mode 100644 index 00000000..5d6ad3aa --- /dev/null +++ b/agreement_legal/static/src/xml/agreement_template.xml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/agreement_legal/tests/test_agreement.py b/agreement_legal/tests/test_agreement.py index 1d87b500..6fcfa5c4 100644 --- a/agreement_legal/tests/test_agreement.py +++ b/agreement_legal/tests/test_agreement.py @@ -106,15 +106,13 @@ def test_read_group_stage_ids(self): # Test fields_view_get def test_agreement_fields_view_get(self): - res = self.env["agreement"].fields_view_get( + res = self.env["agreement"].get_view( view_id=self.ref("agreement_legal.partner_agreement_form_view"), view_type="form", ) doc = etree.XML(res["arch"]) field = doc.xpath("//field[@name='partner_contact_id']") - self.assertEqual( - field[0].get("modifiers", ""), '{"readonly": [["readonly", "=", true]]}' - ) + self.assertEqual(field[0].get("readonly", ""), "bool(readonly)") def test_action_create_new_version(self): self.test_agreement.create_new_version() @@ -125,10 +123,10 @@ def test_cron(self): self.agreement_type.write( {"review_user_id": self.env.user.id, "review_days": 0} ) - self.agreement_type.flush() + self.agreement_type.flush_recordset() self.test_agreement.write({"agreement_type_id": self.agreement_type.id}) - self.test_agreement.flush() - self.test_agreement.refresh() + self.test_agreement.flush_recordset() + self.test_agreement.invalidate_recordset() self.assertFalse( self.env["mail.activity"].search_count( [ diff --git a/agreement_legal/views/agreement.xml b/agreement_legal/views/agreement.xml index 02217cb5..b7a3d3a6 100644 --- a/agreement_legal/views/agreement.xml +++ b/agreement_legal/views/agreement.xml @@ -6,7 +6,7 @@ agreement - + @@ -14,7 +14,7 @@ - + @@ -32,14 +32,14 @@ type="object" name="create_new_version" class="oe_highlight" - attrs="{'invisible': [('state', '=', 'active')]}" + invisible="state == 'active'" />
    -
    - - - -

    Advanced Features

    -
    -
    -
    - -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    - -
    -
    -