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 committed Sep 20, 2024
1 parent d0c6075 commit bee2fb9
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 213 deletions.
12 changes: 3 additions & 9 deletions agreement_legal/models/agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,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 @@ -466,12 +464,8 @@ def _exclude_readonly_field(self):
return ["stage_id"]

@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"])
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
2 changes: 1 addition & 1 deletion 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 Down
2 changes: 1 addition & 1 deletion 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 Down
22 changes: 10 additions & 12 deletions agreement_legal/static/src/xml/agreement.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t
t-name="agreement.ListView.Buttons"
t-inherit="web.ListView.Buttons"
t-inherit-mode="primary"
owl="1"
>
<t t-name="agreement.ListView" t-inherit="web.ListView" t-inherit-mode="primary">
<xpath
expr="//*[@class='btn btn-primary o_list_button_add']"
position="attributes"
Expand All @@ -16,27 +11,28 @@
<t t-call="agreement.TemplateButton" />
</xpath>
</t>

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

<t
t-name="agreement.KanbanView.Buttons"
t-inherit="web.KanbanView.Buttons"
t-name="agreement.KanbanView"
t-inherit="web.KanbanView"
t-inherit-mode="primary"
owl="1"
>
<xpath
expr="//*[@class='btn btn-primary o-kanban-button-new']"
Expand All @@ -51,7 +47,8 @@
<attribute name="t-if">!noCreate and canCreateTemplate</attribute>
</xpath>
</t>
<t t-name="agreement.TemplateButton" owl="1">

<t t-name="agreement.TemplateButton">
<button
type="button"
t-if="!canCreateTemplate"
Expand All @@ -61,4 +58,5 @@
Create From Template
</button>
</t>

</templates>
6 changes: 3 additions & 3 deletions agreement_legal/tests/test_agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,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(
[
Expand Down
39 changes: 20 additions & 19 deletions agreement_legal/views/agreement.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<field name="model">agreement</field>
<field name="arch" type="xml">
<tree js_class="agreement_template_tree" default_order="code desc, name">
<field name="code" invisible="context.get('default_model')" />
<field name="code" column_invisible="context.get('default_model')" />
<field name="name" />
<field name="partner_id" />
<field name="company_id" />
Expand All @@ -32,14 +32,14 @@
type="object"
name="create_new_version"
class="oe_highlight"
attrs="{'invisible': [('state', '=', 'active')]}"
invisible="state == 'active'"
/>
<button
string="New Agreement"
type="object"
name="create_new_agreement"
class="oe_highlight"
attrs="{'invisible': [('is_template', '=', False)]}"
invisible="is_template == False"
/>
<field
name="stage_id"
Expand All @@ -55,7 +55,7 @@
name="web_ribbon"
title="Template"
bg_color="bg-info"
attrs="{'invisible': [('is_template', '=', False)]}"
invisible="is_template == False"
/>
<div class="oe_title">
<label
Expand All @@ -75,10 +75,7 @@
domain="[('partner_id', '=', partner_id)]"
/>
<field name="is_template" invisible="1" />
<field
name="template_id"
attrs="{'invisible': [('is_template', '=', True)]}"
/>
<field name="template_id" invisible="is_template == True" />
</group>
<group>
<field
Expand All @@ -93,7 +90,8 @@
/>
<field
name="assigned_user_id"
attrs="{'invisible': [('is_template', '=', True)], 'readonly':[('is_template', '=', True)]}"
invisible="is_template == True"
readonly="is_template == True"
/>
<field name="active" invisible="1" />
<field name="state" invisible="1" />
Expand Down Expand Up @@ -216,27 +214,30 @@
<group
name="parties_content"
string="Parties Content"
attrs="{'invisible':[('use_parties_content', '=', False)]}"
invisible="use_parties_content == False"
>
<field name="parties" nolabel="1" />
<field name="parties" nolabel="1" colspan="2" />
</group>
<group name="term_information">
<group name="termdates_left" string="Term Dates">
<field
name="signature_date"
attrs="{'invisible': [('is_template', '=', True)]}"
invisible="is_template == True"
/>
<field
name="start_date"
attrs="{'required': [('is_template', '=', False)], 'invisible': [('is_template', '=', True)]}"
required="is_template == False"
invisible="is_template == True"
/>
<field
name="end_date"
attrs="{'required': [('is_template', '=', False)], 'invisible': [('is_template', '=', True)]}"
required="is_template == False"
invisible="is_template == True"
/>
<field
name="to_review_date"
attrs="{'required': [('is_template', '=', False), ('end_date', '!=', False)], 'invisible': [('is_template', '=', True)]}"
required="is_template == False and end_date != False"
invisible="is_template == True"
/>
<field name="expiration_notice" />
<field name="change_notice" />
Expand Down Expand Up @@ -375,22 +376,22 @@
<field
name="create_uid"
readonly="True"
attrs="{'invisible': [('parent_agreement_id', '!=', False)]}"
invisible="parent_agreement_id != False"
/>
<field
name="create_uid_parent"
attrs="{'invisible': [('parent_agreement_id', '=', False)]}"
invisible="parent_agreement_id == False"
/>
| Created On:
<field
name="create_date"
readonly="True"
attrs="{'invisible': [('parent_agreement_id', '!=', False)]}"
invisible="parent_agreement_id != False"
/>
<field
name="create_date_parent"
readonly="True"
attrs="{'invisible': [('parent_agreement_id', '=', False)]}"
invisible="parent_agreement_id == False"
/>
</p>
</sheet>
Expand Down
2 changes: 1 addition & 1 deletion agreement_legal/views/agreement_appendix.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active == True"
/>
<field name="active" invisible="1" />
<div class="oe_title">
Expand Down
2 changes: 1 addition & 1 deletion agreement_legal/views/agreement_clause.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active == True"
/>
<field name="active" invisible="1" />
<div class="oe_title">
Expand Down
2 changes: 1 addition & 1 deletion agreement_legal/views/agreement_recital.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active == True"
/>
<field name="active" invisible="1" />
<div class="oe_title">
Expand Down
2 changes: 1 addition & 1 deletion agreement_legal/views/agreement_section.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active == True"
/>
<field name="active" invisible="1" />
<div class="oe_title">
Expand Down
2 changes: 1 addition & 1 deletion agreement_legal/views/agreement_stages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active == True"
/>
<div class="oe_title">
<label for="name" class="oe_edit_only" />
Expand Down
2 changes: 1 addition & 1 deletion agreement_legal/views/agreement_subtype.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active == True"
/>
<div class="oe_title">
<label for="name" class="oe_edit_only" />
Expand Down
Loading

0 comments on commit bee2fb9

Please sign in to comment.