[14.0][MIG] agreement_legal (Version 12.0 to 14.0)

[MIG] Black & Cleanup

[IMP] Reviewer Requested Changes

[IMP] Black

[IMP] Reviewer Suggestion

[FIX] Tests

[FIX] Multiple Issues

- Added 'is_old_version' field to better display old versions. Before these were marked as inactive therefore not showing in the agreement.
- 'is_template' field now copies when making a template revision or copying a template.
- New Versions now retain original create date.
- Moved version/revision and created on/by fields out of footer to top in order to have the save buttons when creating children.
- Moved demo data out of data folder into the demo.xml

[FIX] demo data

[FIX] Revert back to only migration

[FIX] Report dynamic field rendering

[FIX] Test
This commit is contained in:
Patrick Wilson
2021-05-04 11:38:03 -06:00
committed by Enric Tobella
parent 884fcd1b93
commit 9cf3d551b0
41 changed files with 892 additions and 364 deletions

View File

@@ -1,14 +1,4 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, SUPERUSER_ID
from . import models
def post_init_agreement_legal(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, dict())
cr.execute(
"UPDATE agreement SET stage_id = %s WHERE stage_id IS NULL;",
(env.ref("agreement_legal.agreement_stage_new").id,),
)
return True

View File

@@ -36,8 +36,6 @@
"views/menu.xml",
],
"demo": ["demo/demo.xml"],
"qweb": ["static/src/xml/domain_widget_view.xml"],
"post_init_hook": "post_init_agreement_legal",
"application": True,
"development_status": "Beta",
"maintainers": ["max3903", "ygol"],

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="agreement_stage_new" model="agreement.stage">
<field name="name">New</field>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="agreement_type_agreement" model="agreement.type">
<field name="name">Agreement</field>

View File

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<!-- Sequence for agreement -->
<record id="seq_agreement" model="ir.sequence">

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="agreement" model="ir.module.category">
<field name="name">Agreement</field>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!--
© 2019 Ygol Internetwork (yves@ygol.com)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

View File

@@ -7,7 +7,6 @@ from odoo import _, api, fields, models
class Agreement(models.Model):
_inherit = "agreement"
# General
name = fields.Char(string="Title", required=True)
version = fields.Integer(
string="Version",
@@ -23,7 +22,7 @@ class Agreement(models.Model):
help="The revision will increase with every save event.",
)
description = fields.Text(
string="Description", tracking=True, help="Description of the agreement",
string="Description", tracking=True, help="Description of the agreement"
)
dynamic_description = fields.Text(
compute="_compute_dynamic_description",
@@ -31,7 +30,7 @@ class Agreement(models.Model):
help="Compute dynamic description",
)
start_date = fields.Date(
string="Start Date", tracking=True, help="When the agreement starts.",
string="Start Date", tracking=True, help="When the agreement starts."
)
end_date = fields.Date(
string="End Date", tracking=True, help="When the agreement ends."
@@ -89,7 +88,7 @@ class Agreement(models.Model):
help="ID used for internal contract tracking.",
)
increase_type_id = fields.Many2one(
comodel_name="agreement.increasetype",
"agreement.increasetype",
string="Increase Type",
tracking=True,
help="The amount that certain rates may increase.",
@@ -105,23 +104,19 @@ class Agreement(models.Model):
help="Date that the contract was terminated.",
)
reviewed_date = fields.Date(string="Reviewed Date", tracking=True)
reviewed_user_id = fields.Many2one(
comodel_name="res.users", string="Reviewed By", tracking=True
)
reviewed_user_id = fields.Many2one("res.users", string="Reviewed By", tracking=True)
approved_date = fields.Date(string="Approved Date", tracking=True)
approved_user_id = fields.Many2one(
comodel_name="res.users", string="Approved By", tracking=True
)
currency_id = fields.Many2one(comodel_name="res.currency", string="Currency")
approved_user_id = fields.Many2one("res.users", string="Approved By", tracking=True)
currency_id = fields.Many2one("res.currency", string="Currency")
partner_id = fields.Many2one(
comodel_name="res.partner",
"res.partner",
string="Partner",
required=False,
copy=True,
help="The customer or vendor this agreement is related to.",
)
partner_contact_id = fields.Many2one(
comodel_name="res.partner",
"res.partner",
string="Partner Contact",
copy=True,
help="The primary partner contact (If Applicable).",
@@ -133,7 +128,7 @@ class Agreement(models.Model):
related="partner_contact_id.email", string="Partner Email"
)
company_contact_id = fields.Many2one(
comodel_name="res.partner",
"res.partner",
string="Company Contact",
copy=True,
help="The primary contact in the company.",
@@ -187,89 +182,73 @@ class Agreement(models.Model):
string="Dynamic Parties",
help="Compute dynamic parties",
)
agreement_type_id = fields.Many2one(tracking=True)
agreement_type_id = fields.Many2one(tracking=True,)
agreement_subtype_id = fields.Many2one(
comodel_name="agreement.subtype",
"agreement.subtype",
string="Agreement Sub-type",
tracking=True,
help="Select the sub-type of this agreement. Sub-Types are related to "
"agreement types.",
)
product_ids = fields.Many2many(
comodel_name="product.template", string="Products & Services"
)
product_ids = fields.Many2many("product.template", string="Products & Services")
assigned_user_id = fields.Many2one(
comodel_name="res.users",
"res.users",
string="Assigned To",
tracking=True,
help="Select the user who manages this agreement.",
)
company_signed_user_id = fields.Many2one(
comodel_name="res.users",
"res.users",
string="Signed By",
tracking=True,
help="The user at our company who authorized/signed the agreement or "
"contract.",
)
partner_signed_user_id = fields.Many2one(
comodel_name="res.partner",
"res.partner",
string="Signed By (Partner)",
tracking=True,
help="Contact on the account that signed the agreement/contract.",
)
parent_agreement_id = fields.Many2one(
comodel_name="agreement",
"agreement",
string="Parent Agreement",
help="Link this agreement to a parent agreement. For example if this "
"agreement is an amendment to another agreement. This list will "
"only show other agreements related to the same account.",
)
renewal_type_id = fields.Many2one(
comodel_name="agreement.renewaltype",
"agreement.renewaltype",
string="Renewal Type",
tracking=True,
help="Describes what happens after the contract expires.",
)
recital_ids = fields.One2many(
comodel_name="agreement.recital",
inverse_name="agreement_id",
string="Recitals",
copy=True,
"agreement.recital", "agreement_id", string="Recitals", copy=True
)
sections_ids = fields.One2many(
comodel_name="agreement.section",
inverse_name="agreement_id",
string="Sections",
copy=True,
)
clauses_ids = fields.One2many(
comodel_name="agreement.clause", inverse_name="agreement_id", string="Clauses"
"agreement.section", "agreement_id", string="Sections", copy=True
)
clauses_ids = fields.One2many("agreement.clause", "agreement_id", string="Clauses")
appendix_ids = fields.One2many(
comodel_name="agreement.appendix",
inverse_name="agreement_id",
string="Appendices",
copy=True,
"agreement.appendix", "agreement_id", string="Appendices", copy=True
)
previous_version_agreements_ids = fields.One2many(
comodel_name="agreement",
inverse_name="parent_agreement_id",
"agreement",
"parent_agreement_id",
string="Previous Versions",
copy=False,
context={"active_test": False},
)
child_agreements_ids = fields.One2many(
comodel_name="agreement",
inverse_name="parent_agreement_id",
"agreement",
"parent_agreement_id",
string="Child Agreements",
copy=False,
domain=[("active", "=", True)],
)
line_ids = fields.One2many(
comodel_name="agreement.line",
inverse_name="agreement_id",
string="Products/Services",
copy=False,
"agreement.line", "agreement_id", string="Products/Services", copy=False
)
state = fields.Selection(
[("draft", "Draft"), ("active", "Active"), ("inactive", "Inactive")],
@@ -277,17 +256,32 @@ class Agreement(models.Model):
tracking=True,
)
notification_address_id = fields.Many2one(
comodel_name="res.partner",
"res.partner",
string="Notification Address",
help="The address to send notificaitons to, if different from "
"customer address.(Address Type = Other)",
)
signed_contract_filename = fields.Char(string="Filename")
signed_contract = fields.Binary(string="Signed Document", tracking=True)
# Dynamic field editor
field_domain = fields.Char(
string="Field Expression", default='[["active", "=", True]]'
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.""",
)
sub_object_id = fields.Many2one(
"ir.model",
string="Sub-model",
help="""When a relationship field is selected as first field, this
field shows the document model the relationship goes to.""",
)
sub_model_object_field_id = fields.Many2one(
"ir.model.fields",
string="Sub-field",
help="""When a relationship field is selected as first field, this
field lets you select the target field within the destination document
model (sub-model).""",
)
default_value = fields.Char(
string="Default Value",
@@ -299,33 +293,25 @@ class Agreement(models.Model):
template field.""",
)
@api.onchange("field_domain", "default_value")
def onchange_copyvalue(self):
self.copyvalue = False
if self.field_domain:
string_list = self.field_domain.split(",")
if string_list:
field_domain = string_list[0][3:-1]
self.copyvalue = "${{object.{} or {}}}".format(
field_domain, self.default_value or "''"
)
# compute the dynamic content for mako expression
def _compute_dynamic_description(self):
MailTemplates = self.env["mail.template"]
for agreement in self:
lang = agreement.partner_id.lang or "en_US"
description = MailTemplates.with_context(lang=lang)._render_template(
agreement.description, "agreement", agreement.id
agreement.description, "agreement", [agreement.id]
)
agreement.dynamic_description = description
des = ""
for i in description:
des += description[i]
agreement.dynamic_description = des
def _compute_dynamic_parties(self):
MailTemplates = self.env["mail.template"]
for agreement in self:
lang = agreement.partner_id.lang or "en_US"
parties = MailTemplates.with_context(lang=lang)._render_template(
agreement.parties, "agreement", agreement.id
agreement.parties, "agreement", [agreement.id]
)
agreement.dynamic_parties = parties
@@ -334,10 +320,31 @@ class Agreement(models.Model):
for agreement in self:
lang = agreement.partner_id.lang or "en_US"
special_terms = MailTemplates.with_context(lang=lang)._render_template(
agreement.special_terms, "agreement", agreement.id
agreement.special_terms, "agreement", [agreement.id]
)
agreement.dynamic_special_terms = special_terms
@api.onchange("field_id", "sub_model_object_field_id", "default_value")
def onchange_copyvalue(self):
self.sub_object_id = False
self.copyvalue = False
self.sub_object_id = False
if self.field_id and not self.field_id.relation:
self.copyvalue = "${{object.{} or {}}}".format(
self.field_id.name, self.default_value or "''"
)
self.sub_model_object_field_id = False
if self.field_id and self.field_id.relation:
self.sub_object_id = self.env["ir.model"].search(
[("model", "=", self.field_id.relation)]
)[0]
if self.sub_model_object_field_id:
self.copyvalue = "${{object.{}.{} or {}}}".format(
self.field_id.name,
self.sub_model_object_field_id.name,
self.default_value or "''",
)
# Used for Kanban grouped_by view
@api.model
def _read_group_stage_ids(self, stages, domain, order):
@@ -347,7 +354,7 @@ class Agreement(models.Model):
return stage_ids
stage_id = fields.Many2one(
comodel_name="agreement.stage",
"agreement.stage",
string="Stage",
group_expand="_read_group_stage_ids",
help="Select the current stage of the agreement.",
@@ -365,14 +372,19 @@ class Agreement(models.Model):
"name": "{} - OLD VERSION".format(rec.name),
"active": False,
"parent_agreement_id": rec.id,
"version": rec.version,
"code": rec.code + "-V" + str(rec.version),
}
# Make a current copy and mark it as old
rec.copy(default=default_vals)
# Increment the Version
rec.version = rec.version + 1
return super().write({"revision": 0})
def create_new_agreement(self):
self.ensure_one()
default_vals = {
"name": "NEW",
"name": "New",
"active": True,
"version": 1,
"revision": 0,
@@ -395,12 +407,9 @@ class Agreement(models.Model):
vals["code"] = self.env["ir.sequence"].next_by_code("agreement") or _("New")
if not vals.get("stage_id"):
vals["stage_id"] = self.env.ref("agreement_legal.agreement_stage_new").id
return super(Agreement, self).create(vals)
return super().create(vals)
# Increments the revision on each save action
def write(self, vals):
res = True
for rec in self:
vals["revision"] = rec.revision + 1
res = super(Agreement, rec).write(vals)
return res
vals["revision"] = self.revision + 1
return super().write(vals)

View File

@@ -13,7 +13,7 @@ class AgreementAppendix(models.Model):
title = fields.Char(
string="Title",
required=True,
help="The title is displayed on the PDF." "The name is not.",
help="The title is displayed on the PDF. The name is not.",
)
sequence = fields.Integer(string="Sequence", default=10)
content = fields.Html(string="Content")
@@ -22,9 +22,7 @@ class AgreementAppendix(models.Model):
string="Dynamic Content",
help="compute dynamic Content",
)
agreement_id = fields.Many2one(
comodel_name="agreement", string="Agreement", ondelete="cascade"
)
agreement_id = fields.Many2one("agreement", string="Agreement", ondelete="cascade")
active = fields.Boolean(
string="Active",
default=True,
@@ -33,8 +31,25 @@ class AgreementAppendix(models.Model):
)
# Dynamic field editor
field_domain = fields.Char(
string="Field Expression", default='[["active", "=", True]]'
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.""",
)
sub_object_id = fields.Many2one(
"ir.model",
string="Sub-model",
help="""When a relationship field is selected as first field, this
field shows the document model the relationship goes to.""",
)
sub_model_object_field_id = fields.Many2one(
"ir.model.fields",
string="Sub-field",
help="""When a relationship field is selected as first field, this
field lets you select the target field within the destination document
model (sub-model).""",
)
default_value = fields.Char(
string="Default Value",
@@ -46,16 +61,26 @@ class AgreementAppendix(models.Model):
template field.""",
)
@api.onchange("field_domain", "default_value")
@api.onchange("field_id", "sub_model_object_field_id", "default_value")
def onchange_copyvalue(self):
self.sub_object_id = False
self.copyvalue = False
if self.field_domain:
string_list = self.field_domain.split(",")
if string_list:
field_domain = string_list[0][3:-1]
self.copyvalue = "${{object.{} or {}}}".format(
field_domain, self.default_value or "''"
)
self.sub_object_id = False
if self.field_id and not self.field_id.relation:
self.copyvalue = "${{object.{} or {}}}".format(
self.field_id.name, self.default_value or "''",
)
self.sub_model_object_field_id = False
if self.field_id and self.field_id.relation:
self.sub_object_id = self.env["ir.model"].search(
[("model", "=", self.field_id.relation)]
)[0]
if self.sub_model_object_field_id:
self.copyvalue = "${{object.{}.{} or {}}}".format(
self.field_id.name,
self.sub_model_object_field_id.name,
self.default_value or "''",
)
# compute the dynamic content for mako expression
def _compute_dynamic_content(self):
@@ -67,6 +92,6 @@ class AgreementAppendix(models.Model):
or "en_US"
)
content = MailTemplates.with_context(lang=lang)._render_template(
appendix.content, "agreement.appendix", appendix.id
appendix.content, "agreement.appendix", [appendix.id]
)
appendix.dynamic_content = content

View File

@@ -11,14 +11,12 @@ class AgreementClause(models.Model):
name = fields.Char(string="Name", required=True)
title = fields.Char(
string="Title", help="The title is displayed on the PDF." "The name is not."
string="Title", help="The title is displayed on the PDF. The name is not."
)
sequence = fields.Integer(string="Sequence")
agreement_id = fields.Many2one(
comodel_name="agreement", string="Agreement", ondelete="cascade"
)
agreement_id = fields.Many2one("agreement", string="Agreement", ondelete="cascade")
section_id = fields.Many2one(
comodel_name="agreement.section", string="Section", ondelete="cascade"
"agreement.section", string="Section", ondelete="cascade"
)
content = fields.Html(string="Clause Content")
dynamic_content = fields.Html(
@@ -34,8 +32,25 @@ class AgreementClause(models.Model):
)
# Dynamic field editor
field_domain = fields.Char(
string="Field Expression", default='[["active", "=", True]]'
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.""",
)
sub_object_id = fields.Many2one(
"ir.model",
string="Sub-model",
help="""When a relationship field is selected as first field, this
field shows the document model the relationship goes to.""",
)
sub_model_object_field_id = fields.Many2one(
"ir.model.fields",
string="Sub-field",
help="""When a relationship field is selected as first field, this
field lets you select the target field within the destination document
model (sub-model).""",
)
default_value = fields.Char(
string="Default Value",
@@ -47,16 +62,26 @@ class AgreementClause(models.Model):
template field.""",
)
@api.onchange("field_domain", "default_value")
@api.onchange("field_id", "sub_model_object_field_id", "default_value")
def onchange_copyvalue(self):
self.sub_object_id = False
self.copyvalue = False
if self.field_domain:
string_list = self.field_domain.split(",")
if string_list:
field_domain = string_list[0][3:-1]
self.copyvalue = "${{object.{} or {}}}".format(
field_domain, self.default_value or "''"
)
self.sub_object_id = False
if self.field_id and not self.field_id.relation:
self.copyvalue = "${{object.{} or {}}}".format(
self.field_id.name, self.default_value or "''",
)
self.sub_model_object_field_id = False
if self.field_id and self.field_id.relation:
self.sub_object_id = self.env["ir.model"].search(
[("model", "=", self.field_id.relation)]
)[0]
if self.sub_model_object_field_id:
self.copyvalue = "${{object.{}.{} or {}}}".format(
self.field_id.name,
self.sub_model_object_field_id.name,
self.default_value or "''",
)
# compute the dynamic content for mako expression
def _compute_dynamic_content(self):
@@ -66,6 +91,6 @@ class AgreementClause(models.Model):
clause.agreement_id and clause.agreement_id.partner_id.lang or "en_US"
)
content = MailTemplates.with_context(lang=lang)._render_template(
clause.content, "agreement.clause", clause.id
clause.content, "agreement.clause", [clause.id]
)
clause.dynamic_content = content

View File

@@ -8,15 +8,11 @@ class AgreementLine(models.Model):
_name = "agreement.line"
_description = "Agreement Lines"
product_id = fields.Many2one(comodel_name="product.product", string="Product")
product_id = fields.Many2one("product.product", string="Product")
name = fields.Char(string="Description", required=True)
agreement_id = fields.Many2one(
comodel_name="agreement", string="Agreement", ondelete="cascade"
)
agreement_id = fields.Many2one("agreement", string="Agreement", ondelete="cascade")
qty = fields.Float(string="Quantity")
uom_id = fields.Many2one(
comodel_name="uom.uom", string="Unit of Measure", required=True
)
uom_id = fields.Many2one("uom.uom", string="Unit of Measure", required=True)
@api.onchange("product_id")
def _onchange_product_id(self):

View File

@@ -11,7 +11,7 @@ class AgreementRecital(models.Model):
name = fields.Char(string="Name", required=True)
title = fields.Char(
string="Title", help="The title is displayed on the PDF." "The name is not."
string="Title", help="The title is displayed on the PDF." "The name is not.",
)
sequence = fields.Integer(string="Sequence", default=10)
content = fields.Html(string="Content")
@@ -20,9 +20,7 @@ class AgreementRecital(models.Model):
string="Dynamic Content",
help="compute dynamic Content",
)
agreement_id = fields.Many2one(
comodel_name="agreement", string="Agreement", ondelete="cascade"
)
agreement_id = fields.Many2one("agreement", string="Agreement", ondelete="cascade")
active = fields.Boolean(
string="Active",
default=True,
@@ -31,8 +29,25 @@ class AgreementRecital(models.Model):
)
# Dynamic field editor
field_domain = fields.Char(
string="Field Expression", default='[["active", "=", True]]'
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.""",
)
sub_object_id = fields.Many2one(
"ir.model",
string="Sub-model",
help="""When a relationship field is selected as first field, this
field shows the document model the relationship goes to.""",
)
sub_model_object_field_id = fields.Many2one(
"ir.model.fields",
string="Sub-field",
help="""When a relationship field is selected as first field, this
field lets you select the target field within the destination document
model (sub-model).""",
)
default_value = fields.Char(
string="Default Value",
@@ -44,16 +59,26 @@ class AgreementRecital(models.Model):
template field.""",
)
@api.onchange("field_domain", "default_value")
@api.onchange("field_id", "sub_model_object_field_id", "default_value")
def onchange_copyvalue(self):
self.sub_object_id = False
self.copyvalue = False
if self.field_domain:
string_list = self.field_domain.split(",")
if string_list:
field_domain = string_list[0][3:-1]
self.copyvalue = "${{object.{} or {}}}".format(
field_domain, self.default_value or "''"
)
self.sub_object_id = False
if self.field_id and not self.field_id.relation:
self.copyvalue = "${{object.{} or {}}}".format(
self.field_id.name, self.default_value or "''"
)
self.sub_model_object_field_id = False
if self.field_id and self.field_id.relation:
self.sub_object_id = self.env["ir.model"].search(
[("model", "=", self.field_id.relation)]
)[0]
if self.sub_model_object_field_id:
self.copyvalue = "${{object.{}.{} or {}}}".format(
self.field_id.name,
self.sub_model_object_field_id.name,
self.default_value or "''",
)
# compute the dynamic content for mako expression
def _compute_dynamic_content(self):
@@ -63,6 +88,6 @@ class AgreementRecital(models.Model):
recital.agreement_id and recital.agreement_id.partner_id.lang or "en_US"
)
content = MailTemplates.with_context(lang=lang)._render_template(
recital.content, "agreement.recital", recital.id
recital.content, "agreement.recital", [recital.id]
)
recital.dynamic_content = content

View File

@@ -14,14 +14,9 @@ class AgreementSection(models.Model):
string="Title", help="The title is displayed on the PDF. The name is not."
)
sequence = fields.Integer(string="Sequence")
agreement_id = fields.Many2one(
comodel_name="agreement", string="Agreement", ondelete="cascade"
)
agreement_id = fields.Many2one("agreement", string="Agreement", ondelete="cascade")
clauses_ids = fields.One2many(
comodel_name="agreement.clause",
inverse_name="section_id",
string="Clauses",
copy=True,
"agreement.clause", "section_id", string="Clauses", copy=True
)
content = fields.Html(string="Section Content")
dynamic_content = fields.Html(
@@ -37,8 +32,25 @@ class AgreementSection(models.Model):
)
# Dynamic field editor
field_domain = fields.Char(
string="Field Expression", default='[["active", "=", True]]'
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.""",
)
sub_object_id = fields.Many2one(
"ir.model",
string="Sub-model",
help="""When a relationship field is selected as first field, this
field shows the document model the relationship goes to.""",
)
sub_model_object_field_id = fields.Many2one(
"ir.model.fields",
string="Sub-field",
help="""When a relationship field is selected as first field, this
field lets you select the target field within the destination document
model (sub-model).""",
)
default_value = fields.Char(
string="Default Value",
@@ -50,16 +62,26 @@ class AgreementSection(models.Model):
template field.""",
)
@api.onchange("field_domain", "default_value")
@api.onchange("field_id", "sub_model_object_field_id", "default_value")
def onchange_copyvalue(self):
self.sub_object_id = False
self.copyvalue = False
if self.field_domain:
string_list = self.field_domain.split(",")
if string_list:
field_domain = string_list[0][3:-1]
self.copyvalue = "${{object.{} or {}}}".format(
field_domain, self.default_value or "''"
)
self.sub_object_id = False
if self.field_id and not self.field_id.relation:
self.copyvalue = "${{object.{} or {}}}".format(
self.field_id.name, self.default_value or "''"
)
self.sub_model_object_field_id = False
if self.field_id and self.field_id.relation:
self.sub_object_id = self.env["ir.model"].search(
[("model", "=", self.field_id.relation)]
)[0]
if self.sub_model_object_field_id:
self.copyvalue = "${{object.{}.{} or {}}}".format(
self.field_id.name,
self.sub_model_object_field_id.name,
self.default_value or "''",
)
# compute the dynamic content for mako expression
def _compute_dynamic_content(self):
@@ -69,6 +91,6 @@ class AgreementSection(models.Model):
section.agreement_id and section.agreement_id.partner_id.lang or "en_US"
)
content = MailTemplates.with_context(lang=lang)._render_template(
section.content, "agreement.section", section.id
section.content, "agreement.section", [section.id]
)
section.dynamic_content = content

View File

@@ -9,6 +9,4 @@ class AgreementSubtype(models.Model):
_description = "Agreement Subtypes"
name = fields.Char(string="Name", required=True)
agreement_type_id = fields.Many2one(
comodel_name="agreement.type", string="Agreement Type"
)
agreement_type_id = fields.Many2one("agreement.type", string="Agreement Type")

View File

@@ -9,7 +9,5 @@ class AgreementType(models.Model):
_description = "Agreement Types"
agreement_subtypes_ids = fields.One2many(
comodel_name="agreement.subtype",
inverse_name="agreement_type_id",
string="Subtypes",
"agreement.subtype", "agreement_type_id", string="Subtypes"
)

View File

@@ -7,4 +7,4 @@ from odoo import fields, models
class Product(models.Model):
_inherit = "product.template"
agreements_ids = fields.Many2many(comodel_name="agreement", string="Agreements")
agreements_ids = fields.Many2many("agreement", string="Agreements")

View File

@@ -7,6 +7,4 @@ from odoo import fields, models
class Partner(models.Model):
_inherit = "res.partner"
agreement_ids = fields.One2many(
comodel_name="agreement", inverse_name="partner_id", string="Agreements"
)
agreement_ids = fields.One2many("agreement", "partner_id", string="Agreements")

View File

@@ -1,21 +1,19 @@
<?xml version="1.0" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<report
id="partner_agreement_contract_document"
model="agreement"
string="Contract Document"
name="agreement_legal.report_agreement_document"
file="agreement_legal.report_agreement_document"
report_type="qweb-pdf"
/>
<report
id="partner_agreement_contract_document_preview"
model="agreement"
string="Contract Document Preview"
name="agreement_legal.report_agreement_document"
file="agreement_legal.report_agreement_document"
report_type="qweb-html"
/>
<record id="partner_agreement_contract_document" model="ir.actions.report">
<field name="name">Agreement</field>
<field name="model">agreement</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">agreement_legal.report_agreement_document</field>
<field name="report_file">agreement_legal.report_agreement_document</field>
</record>
<record id="partner_agreement_contract_document_preview" model="ir.actions.report">
<field name="name">Agreement Preview</field>
<field name="model">agreement</field>
<field name="report_type">qweb-html</field>
<field name="report_name">agreement_legal.report_agreement_document</field>
<field name="report_file">agreement_legal.report_agreement_document</field>
</record>
<template id="report_agreement_document">
<t t-name="agreement.report_agreement_document">
<t t-call="web.html_container">
@@ -111,7 +109,7 @@
</tr>
</tbody>
</table>
<t t-if="doc.special_terms">
<t t-if="special_term">
<h2>Special Terms</h2>
<div name="special_term">
<p t-field="doc.dynamic_special_terms" />

View File

@@ -1,11 +1,11 @@
odoo.define("agreement_legal.domain_widget_ext", function(require) {
"use strict";
const basic_fields = require("web.basic_fields");
const DomainSelector = require("web.DomainSelector");
const session = require("web.session");
const core = require("web.core");
const qweb = core.qweb;
var basic_fields = require("web.basic_fields");
var DomainSelector = require("web.DomainSelector");
var session = require("web.session");
var core = require("web.core");
var qweb = core.qweb;
basic_fields.FieldDomain.include({
/**
@@ -26,7 +26,6 @@ odoo.define("agreement_legal.domain_widget_ext", function(require) {
* @override _render from AbstractField
* @returns {Deferred}
*/
/* eslint-disable no-unused-vars */
_render: function() {
// If there is no model, only change the non-domain-selector content
if (!this._domainModel) {
@@ -35,7 +34,7 @@ odoo.define("agreement_legal.domain_widget_ext", function(require) {
}
// Convert char value to array value
const value = this.value || "[]";
var value = this.value || "[]";
// Create the domain selector or change the value of the current
// one...

View File

@@ -3,17 +3,6 @@
<t t-name="FieldDomain.content">
<t t-if="partialUse">
<div t-if="hasModel" class="o_field_domain_panel">
<!--<div t-if="hasModel" class="o_field_domain_panel">
<i class="fa fa-arrow-right" role="img" aria-label="Domain" title="Domain"/>
<button t-if="isValid" class="btn btn-sm btn-secondary o_domain_show_selection_button" type="button">
<t t-esc="nbRecords"/> record(s)
</button>
<span t-else="" class="text-warning" role="alert"><i class="fa fa-exclamation-triangle" role="img" aria-label="Warning" title="Warning"/> Invalid domain</span>
<button t-if="inDialogEdit" class="btn btn-sm btn-primary o_field_domain_dialog_button">Edit Domain</button>
</div>
<div t-else="">Select a model to add a filter.</div>-->
</div>
</t>
<t t-if="!partialUse">

View File

@@ -1 +1,8 @@
# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
from . import test_agreement
from . import test_agreement_appendix
from . import test_agreement_clause
from . import test_agreement_line
from . import test_agreement_recital
from . import test_agreement_section

View File

@@ -1,13 +1,116 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from odoo.addons.agreement.tests import test_agreement
from datetime import timedelta
from odoo import fields
from odoo.tests.common import TransactionCase
class TestAgreement(test_agreement.TestAgreement):
class TestAgreement(TransactionCase):
def setUp(self):
super().setUp()
self.test_customer = self.env["res.partner"].create({"name": "TestCustomer"})
self.agreement_type = self.env["agreement.type"].create(
{"name": "Test Agreement Type", "domain": "sale"}
)
self.test_agreement = self.env["agreement"].create(
{
"name": "TestAgreement",
"description": "Test",
"special_terms": "Test",
"partner_id": self.test_customer.id,
"start_date": fields.Date.today(),
"end_date": fields.Date.today() + timedelta(days=365),
"state": "active",
}
)
# TEST 01: Set 'Field' for dynamic placeholder, test onchange method
def test_onchange_copyvalue(self):
agreement_01 = self.test_agreement
field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement"), ("name", "=", "active")]
)
agreement_01.field_id = field_01.id
agreement_01.onchange_copyvalue()
self.assertEqual(agreement_01.copyvalue, "${object.active or ''}")
# TEST 02: Set related 'Field' for dynamic placeholder to
# test onchange method
def test_onchange_copyvalue2(self):
agreement_01 = self.test_agreement
field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement"), ("name", "=", "agreement_type_id")]
)
sub_field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement.type"), ("name", "=", "active")]
)
agreement_01.field_id = field_01.id
agreement_01.onchange_copyvalue()
self.assertEqual(agreement_01.sub_object_id.model, "agreement.type")
agreement_01.sub_model_object_field_id = sub_field_01.id
agreement_01.onchange_copyvalue()
self.assertEqual(
agreement_01.copyvalue, "${object.agreement_type_id.active or ''}"
)
# TEST 03: Create New Version
def test_create_new_version(self):
agreement_01 = self.test_agreement
agreement_01.create_new_version()
old_agreement = self.env["agreement"].search(
[("code", "=", agreement_01.code + "-V1"), ("active", "=", False)]
)
self.assertEqual(len(old_agreement), 1)
new_agreement = self.env["agreement"].search(
[("name", "=", "TestAgreement"), ("version", "=", 2)]
)
self.assertEqual(len(new_agreement), 1)
# TEST 04: Create New Agreement
def test_create_new_agreement(self):
agreement_01 = self.test_agreement
agreement_01.create_new_agreement()
new_agreement = self.env["agreement"].search([("name", "=", "New")])
self.assertEqual(len(new_agreement), 1)
# TEST 05: Test Description Dynamic Field
def test_compute_dynamic_description(self):
agreement_01 = self.test_agreement
agreement_01.description = "${object.name}"
self.assertEqual(
agreement_01.dynamic_description, "TestAgreement",
)
# TEST 06: Test Parties Dynamic Field
def test_compute_dynamic_parties(self):
agreement_01 = self.test_agreement
agreement_01.parties = "${object.name}"
self.assertEqual(
agreement_01.dynamic_parties,
"<p>{" + str(agreement_01.id) + ": '</p><p>TestAgreement</p>'}",
)
# TEST 07: Test Special Terms Dynamic Field
def test_compute_dynamic_special_terms(self):
agreement_01 = self.test_agreement
agreement_01.special_terms = "${object.name}"
self.assertEqual(
agreement_01.dynamic_special_terms,
"{" + str(agreement_01.id) + ": 'TestAgreement'}",
)
# TEST 02: Check Read Stages
def test_read_group_stage_ids(self):
agreement_01 = self.test_agreement
self.assertEqual(
agreement_01._read_group_stage_ids(self.env["agreement.stage"], [], "id"),
self.env["agreement.stage"].search(
[("stage_type", "=", "agreement")], order="id",
),
)
def test_action_create_new_version(self):
self.agreement.create_new_version()
self.assertEqual(self.agreement.state, "draft")
self.assertEqual(len(self.agreement.previous_version_agreements_ids), 1)
self.test_agreement.create_new_version()
self.assertEqual(self.test_agreement.state, "draft")
self.assertEqual(len(self.test_agreement.previous_version_agreements_ids), 1)

View File

@@ -0,0 +1,69 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from datetime import timedelta
from odoo import fields
from odoo.tests.common import TransactionCase
class TestAgreementAppendices(TransactionCase):
def setUp(self):
super().setUp()
self.test_customer = self.env["res.partner"].create({"name": "TestCustomer"})
self.agreement_type = self.env["agreement.type"].create(
{"name": "Test Agreement Type", "domain": "sale"}
)
self.test_agreement = self.env["agreement"].create(
{
"name": "TestAgreement",
"description": "Test",
"special_terms": "Test",
"partner_id": self.test_customer.id,
"start_date": fields.Date.today(),
"end_date": fields.Date.today() + timedelta(days=365),
}
)
self.test_appendices = self.env["agreement.appendix"].create(
{
"name": "TestAppendices",
"title": "Test",
"content": "Test",
"agreement_id": self.test_agreement.id,
}
)
# TEST 01: Set 'Field' for dynamic placeholder, test onchange method
def test_onchange_copyvalue(self):
appendix_01 = self.test_appendices
field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement.appendix"), ("name", "=", "active")]
)
appendix_01.field_id = field_01.id
appendix_01.onchange_copyvalue()
self.assertEqual(appendix_01.copyvalue, "${object.active or ''}")
# TEST 02: Set related 'Field' for dynamic placeholder to
# test onchange method
def test_onchange_copyvalue2(self):
appendix_01 = self.test_appendices
field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement.appendix"), ("name", "=", "agreement_id")]
)
sub_field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement"), ("name", "=", "active")]
)
appendix_01.field_id = field_01.id
appendix_01.onchange_copyvalue()
self.assertEqual(appendix_01.sub_object_id.model, "agreement")
appendix_01.sub_model_object_field_id = sub_field_01.id
appendix_01.onchange_copyvalue()
self.assertEqual(appendix_01.copyvalue, "${object.agreement_id.active or ''}")
# TEST 03: Test Dynamic Field
def test_compute_dynamic_content(self):
appendix_01 = self.test_appendices
appendix_01.content = "${object.name}"
self.assertEqual(
appendix_01.dynamic_content,
"<p>{" + str(appendix_01.id) + ": '</p><p>TestAppendices</p>'}",
)

View File

@@ -0,0 +1,69 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from datetime import timedelta
from odoo import fields
from odoo.tests.common import TransactionCase
class TestAgreementClauses(TransactionCase):
def setUp(self):
super().setUp()
self.test_customer = self.env["res.partner"].create({"name": "TestCustomer"})
self.agreement_type = self.env["agreement.type"].create(
{"name": "Test Agreement Type", "domain": "sale"}
)
self.test_agreement = self.env["agreement"].create(
{
"name": "TestAgreement",
"description": "Test",
"special_terms": "Test",
"partner_id": self.test_customer.id,
"start_date": fields.Date.today(),
"end_date": fields.Date.today() + timedelta(days=365),
}
)
self.test_clause = self.env["agreement.clause"].create(
{
"name": "TestClause",
"title": "Test",
"content": "Test",
"agreement_id": self.test_agreement.id,
}
)
# TEST 01: Set 'Field' for dynamic placeholder, test onchange method
def test_onchange_copyvalue(self):
clause_01 = self.test_clause
field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement.clause"), ("name", "=", "active")]
)
clause_01.field_id = field_01.id
clause_01.onchange_copyvalue()
self.assertEqual(clause_01.copyvalue, "${object.active or ''}")
# TEST 02: Set related 'Field' for dynamic placeholder to
# test onchange method
def test_onchange_copyvalue2(self):
clause_01 = self.test_clause
field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement.clause"), ("name", "=", "agreement_id")]
)
sub_field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement"), ("name", "=", "active")]
)
clause_01.field_id = field_01.id
clause_01.onchange_copyvalue()
self.assertEqual(clause_01.sub_object_id.model, "agreement")
clause_01.sub_model_object_field_id = sub_field_01.id
clause_01.onchange_copyvalue()
self.assertEqual(clause_01.copyvalue, "${object.agreement_id.active or ''}")
# TEST 03: Test Dynamic Field
def test_compute_dynamic_content(self):
clause_01 = self.test_clause
clause_01.content = "${object.name}"
self.assertEqual(
clause_01.dynamic_content,
"<p>{" + str(clause_01.id) + ": '</p><p>TestClause</p>'}",
)

View File

@@ -0,0 +1,42 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from datetime import timedelta
from odoo import fields
from odoo.tests.common import TransactionCase
class TestAgreementLine(TransactionCase):
def setUp(self):
super().setUp()
self.test_customer = self.env["res.partner"].create({"name": "TestCustomer"})
self.agreement_type = self.env["agreement.type"].create(
{"name": "Test Agreement Type", "domain": "sale"}
)
self.test_agreement = self.env["agreement"].create(
{
"name": "TestAgreement",
"description": "Test",
"special_terms": "Test",
"partner_id": self.test_customer.id,
"start_date": fields.Date.today(),
"end_date": fields.Date.today() + timedelta(days=365),
}
)
self.test_product1 = self.env["product.product"].create({"name": "TEST1"})
self.test_product2 = self.env["product.product"].create({"name": "TEST2"})
self.test_line = self.env["agreement.line"].create(
{
"product_id": self.test_product1.id,
"name": "Test",
"uom_id": 1,
"agreement_id": self.test_agreement.id,
}
)
# TEST 01: Set line product onchange method
def test_onchange_product_id(self):
line_01 = self.test_line
line_01.product_id = self.test_product2.id
line_01._onchange_product_id()
self.assertEqual(line_01.name, "TEST2")

View File

@@ -0,0 +1,69 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from datetime import timedelta
from odoo import fields
from odoo.tests.common import TransactionCase
class TestAgreementRectical(TransactionCase):
def setUp(self):
super().setUp()
self.test_customer = self.env["res.partner"].create({"name": "TestCustomer"})
self.agreement_type = self.env["agreement.type"].create(
{"name": "Test Agreement Type", "domain": "sale"}
)
self.test_agreement = self.env["agreement"].create(
{
"name": "TestAgreement",
"description": "Test",
"special_terms": "Test",
"partner_id": self.test_customer.id,
"start_date": fields.Date.today(),
"end_date": fields.Date.today() + timedelta(days=365),
}
)
self.test_recital = self.env["agreement.recital"].create(
{
"name": "TestRecital",
"title": "Test",
"content": "Test",
"agreement_id": self.test_agreement.id,
}
)
# TEST 01: Set 'Field' for dynamic placeholder, test onchange method
def test_onchange_copyvalue(self):
recital_01 = self.test_recital
field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement.recital"), ("name", "=", "active")]
)
recital_01.field_id = field_01.id
recital_01.onchange_copyvalue()
self.assertEqual(recital_01.copyvalue, "${object.active or ''}")
# TEST 02: Set related 'Field' for dynamic placeholder to
# test onchange method
def test_onchange_copyvalue2(self):
recital_01 = self.test_recital
field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement.recital"), ("name", "=", "agreement_id")]
)
sub_field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement"), ("name", "=", "active")]
)
recital_01.field_id = field_01.id
recital_01.onchange_copyvalue()
self.assertEqual(recital_01.sub_object_id.model, "agreement")
recital_01.sub_model_object_field_id = sub_field_01.id
recital_01.onchange_copyvalue()
self.assertEqual(recital_01.copyvalue, "${object.agreement_id.active or ''}")
# TEST 03: Test Dynamic Field
def test_compute_dynamic_content(self):
recital_01 = self.test_recital
recital_01.content = "${object.name}"
self.assertEqual(
recital_01.dynamic_content,
"<p>{" + str(recital_01.id) + ": '</p><p>TestRecital</p>'}",
)

View File

@@ -0,0 +1,69 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from datetime import timedelta
from odoo import fields
from odoo.tests.common import TransactionCase
class TestAgreementSection(TransactionCase):
def setUp(self):
super().setUp()
self.test_customer = self.env["res.partner"].create({"name": "TestCustomer"})
self.agreement_type = self.env["agreement.type"].create(
{"name": "Test Agreement Type", "domain": "sale"}
)
self.test_agreement = self.env["agreement"].create(
{
"name": "TestAgreement",
"description": "Test",
"special_terms": "Test",
"partner_id": self.test_customer.id,
"start_date": fields.Date.today(),
"end_date": fields.Date.today() + timedelta(days=365),
}
)
self.test_section = self.env["agreement.section"].create(
{
"name": "TestSection",
"title": "Test",
"content": "Test",
"agreement_id": self.test_agreement.id,
}
)
# TEST 01: Set 'Field' for dynamic placeholder, test onchange method
def test_onchange_copyvalue(self):
section_01 = self.test_section
field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement.section"), ("name", "=", "active")]
)
section_01.field_id = field_01.id
section_01.onchange_copyvalue()
self.assertEqual(section_01.copyvalue, "${object.active or ''}")
# TEST 02: Set related 'Field' for dynamic placeholder to
# test onchange method
def test_onchange_copyvalue2(self):
section_01 = self.test_section
field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement.section"), ("name", "=", "agreement_id")]
)
sub_field_01 = self.env["ir.model.fields"].search(
[("model", "=", "agreement"), ("name", "=", "active")]
)
section_01.field_id = field_01.id
section_01.onchange_copyvalue()
self.assertEqual(section_01.sub_object_id.model, "agreement")
section_01.sub_model_object_field_id = sub_field_01.id
section_01.onchange_copyvalue()
self.assertEqual(section_01.copyvalue, "${object.agreement_id.active or ''}")
# TEST 03: Test Dynamic Field
def test_compute_dynamic_content(self):
section_01 = self.test_section
section_01.content = "${object.name}"
self.assertEqual(
section_01.dynamic_content,
"<p>{" + str(section_01.id) + ": '</p><p>TestSection</p>'}",
)

View File

@@ -1,17 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template
id="assets_backend"
name="agreement_legal assets"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/agreement_legal/static/src/js/domain_widget_ext.js"
/>
</xpath>
</template>
<!-- Agreement List View-->
<record model="ir.ui.view" id="partner_agreement_list_view">
<field name="name">Agreement List</field>
@@ -59,8 +47,7 @@
/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
</div>
<div class="oe_button_box" name="button_box" />
<div class="oe_title">
<label
for="name"
@@ -103,21 +90,30 @@
<field name="description" required="True" nolabel="1" />
</group>
<group class="oe_edit_only">
<field
name="field_domain"
widget="domain"
nolabel="1"
options="{'model': 'agreement',
'partial_use': True}"
/>
<group>
<field
name="field_id"
domain="[('model_id', '=', active_model),
('ttype', '!=', 'one2many'),
('ttype', '!=', 'many2many')]"
/>
<field name="sub_object_id" readonly="1" />
<field
name="sub_model_object_field_id"
domain="[('model_id', '=', sub_object_id),
('ttype', '!=', 'one2many'),
('ttype', '!=', 'many2many')]"
attrs="{'readonly':[('sub_object_id', '=', False)],
'required':[('sub_object_id', '!=', False)]}"
/>
<field name="default_value" />
<field name="copyvalue" />
</group>
<p>
This section (on the left) allows you to add dynamic fields inside the description and special terms.
<ol>
<li>Select the agreement field using the popup</li>
<li>Select the agreement field</li>
<li>Select the sub-field</li>
<li>Enter the default value if the field is empty</li>
<li
>Copy and paste the placeholder expression in the description or the special terms</li>
@@ -388,10 +384,7 @@
<div
class="o_kanban_record_subtitle text-muted"
>
<field
name="partner_id"
invisible="context.get('default_partner_id', False)"
/>
<field name="partner_id" />
<t
t-if="record.end_date.raw_value and record.end_date.raw_value lt (new Date())"
t-set="red"
@@ -416,6 +409,7 @@
<span
class="fa fa-ellipsis-v"
aria-hidden="true"
title="Icon"
/>
</a>
<ul

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Agreement Appendix List View-->
<record model="ir.ui.view" id="agreement_appendix_tree">
@@ -21,20 +21,14 @@
<field name="arch" type="xml">
<form string="Appendix">
<sheet>
<div class="oe_button_box" name="button_box">
<button
name="toggle_active"
type="object"
class="oe_stat_button"
icon="fa-archive"
>
<field
name="active"
widget="boolean_button"
options="{&quot;terminology&quot;: &quot;archive&quot;}"
/>
</button>
</div>
<div class="oe_button_box" name="button_box" />
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
<field name="active" invisible="1" />
<div class="oe_title">
<label for="name" class="oe_edit_only" />
<h1>
@@ -52,21 +46,30 @@
</group>
<field name="content" widget="html" />
<group class="oe_edit_only">
<field
name="field_domain"
widget="domain"
nolabel="1"
options="{'model': 'agreement.appendix',
'partial_use': True}"
/>
<group>
<field
name="field_id"
domain="[('model_id', '=', active_model),
('ttype', '!=', 'one2many'),
('ttype', '!=', 'many2many')]"
/>
<field name="sub_object_id" readonly="1" />
<field
name="sub_model_object_field_id"
domain="[('model_id', '=', sub_object_id),
('ttype', '!=', 'one2many'),
('ttype', '!=', 'many2many')]"
attrs="{'readonly':[('sub_object_id', '=', False)],
'required':[('sub_object_id', '!=', False)]}"
/>
<field name="default_value" />
<field name="copyvalue" />
</group>
<p>
This section (on the left) allows you to add dynamic fields inside the content.
<ol>
<li>Select the field using the popup</li>
<li>Select the appendix field</li>
<li>Select the sub-field</li>
<li>Enter the default value if the field is empty</li>
<li
>Copy and paste the placeholder expression in the content</li>
@@ -82,7 +85,8 @@
<field name="name">Agreement Appendix Search</field>
<field name="model">agreement.appendix</field>
<field name="arch" type="xml">
<search>
<search string="Appendix">
<field name="name" />
<filter
name="group_agreement"
icon="terp-partner"

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Agreement Clause List View-->
<record model="ir.ui.view" id="partner_agreement_clause_list_view">
@@ -22,20 +22,14 @@
<field name="arch" type="xml">
<form string="Clause">
<sheet>
<div class="oe_button_box" name="button_box">
<button
name="toggle_active"
type="object"
class="oe_stat_button"
icon="fa-archive"
>
<field
name="active"
widget="boolean_button"
options="{&quot;terminology&quot;: &quot;archive&quot;}"
/>
</button>
</div>
<div class="oe_button_box" name="button_box" />
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
<field name="active" invisible="1" />
<div class="oe_title">
<label for="name" class="oe_edit_only" />
<h1>
@@ -57,21 +51,30 @@
</group>
<field name="content" widget="html" />
<group class="oe_edit_only">
<field
name="field_domain"
widget="domain"
nolabel="1"
options="{'model': 'agreement.clause',
'partial_use': True}"
/>
<group>
<field
name="field_id"
domain="[('model_id', '=', active_model),
('ttype', '!=', 'one2many'),
('ttype', '!=', 'many2many')]"
/>
<field name="sub_object_id" readonly="1" />
<field
name="sub_model_object_field_id"
domain="[('model_id', '=', sub_object_id),
('ttype', '!=', 'one2many'),
('ttype', '!=', 'many2many')]"
attrs="{'readonly':[('sub_object_id', '=', False)],
'required':[('sub_object_id', '!=', False)]}"
/>
<field name="default_value" />
<field name="copyvalue" />
</group>
<p>
This section (on the left) allows you to add dynamic fields inside the content.
<ol>
<li>Select the field using the popup</li>
<li>Select the clause field</li>
<li>Select the sub-field</li>
<li>Enter the default value if the field is empty</li>
<li
>Copy and paste the placeholder expression in the content</li>
@@ -87,7 +90,8 @@
<field name="name">Agreement Clause Search</field>
<field name="model">agreement.clause</field>
<field name="arch" type="xml">
<search string="Agreement Clause Search">
<search string="Clause">
<field name="name" />
<filter
name="group_agreement"
icon="terp-partner"

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Agreement Increase Type List View-->
<record model="ir.ui.view" id="partner_agreement_increasetype_list_view">

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Agreement Recital List View-->
<record model="ir.ui.view" id="agreement_recital_tree">
@@ -21,20 +21,14 @@
<field name="arch" type="xml">
<form string="Recital">
<sheet>
<div class="oe_button_box" name="button_box">
<button
name="toggle_active"
type="object"
class="oe_stat_button"
icon="fa-archive"
>
<field
name="active"
widget="boolean_button"
options="{&quot;terminology&quot;: &quot;archive&quot;}"
/>
</button>
</div>
<div class="oe_button_box" name="button_box" />
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
<field name="active" invisible="1" />
<div class="oe_title">
<label for="name" class="oe_edit_only" />
<h1>
@@ -52,21 +46,30 @@
</group>
<field name="content" widget="html" />
<group class="oe_edit_only">
<field
name="field_domain"
widget="domain"
nolabel="1"
options="{'model': 'agreement.recital',
'partial_use': True}"
/>
<group>
<field
name="field_id"
domain="[('model_id', '=', active_model),
('ttype', '!=', 'one2many'),
('ttype', '!=', 'many2many')]"
/>
<field name="sub_object_id" readonly="1" />
<field
name="sub_model_object_field_id"
domain="[('model_id', '=', sub_object_id),
('ttype', '!=', 'one2many'),
('ttype', '!=', 'many2many')]"
attrs="{'readonly':[('sub_object_id', '=', False)],
'required':[('sub_object_id', '!=', False)]}"
/>
<field name="default_value" />
<field name="copyvalue" />
</group>
<p>
This section (on the left) allows you to add dynamic fields inside the content.
<ol>
<li>Select the field using the popup</li>
<li>Select the recital field</li>
<li>Select the sub-field</li>
<li>Enter the default value if the field is empty</li>
<li
>Copy and paste the placeholder expression in the content</li>
@@ -82,7 +85,8 @@
<field name="name">Agreement Recital Search</field>
<field name="model">agreement.recital</field>
<field name="arch" type="xml">
<search>
<search string="Recitals">
<field name="name" />
<filter
name="group_agreement"
icon="terp-partner"

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Agreement Renewal Type List View-->
<record model="ir.ui.view" id="partner_agreement_renewaltype_list_view">

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Agreement Sections List View-->
<record model="ir.ui.view" id="partner_agreement_section_list_view">
@@ -21,20 +21,14 @@
<field name="arch" type="xml">
<form string="Section">
<sheet>
<div class="oe_button_box" name="button_box">
<button
name="toggle_active"
type="object"
class="oe_stat_button"
icon="fa-archive"
>
<field
name="active"
widget="boolean_button"
options="{&quot;terminology&quot;: &quot;archive&quot;}"
/>
</button>
</div>
<div class="oe_button_box" name="button_box" />
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
<field name="active" invisible="1" />
<div class="oe_title">
<label for="name" class="oe_edit_only" />
<h1>
@@ -54,21 +48,30 @@
<page string="Content">
<field name='content' nolabel="1" />
<group class="oe_edit_only">
<field
name="field_domain"
widget="domain"
nolabel="1"
options="{'model': 'agreement.section',
'partial_use': True}"
/>
<group>
<field
name="field_id"
domain="[('model_id', '=', active_model),
('ttype', '!=', 'one2many'),
('ttype', '!=', 'many2many')]"
/>
<field name="sub_object_id" readonly="1" />
<field
name="sub_model_object_field_id"
domain="[('model_id', '=', sub_object_id),
('ttype', '!=', 'one2many'),
('ttype', '!=', 'many2many')]"
attrs="{'readonly':[('sub_object_id', '=', False)],
'required':[('sub_object_id', '!=', False)]}"
/>
<field name="default_value" />
<field name="copyvalue" />
</group>
<p>
This section (on the left) allows you to add dynamic fields inside the content.
<ol>
<li>Select the field using the popup</li>
<li>Select the section field</li>
<li>Select the sub-field</li>
<li
>Enter the default value if the field is empty</li>
<li
@@ -100,7 +103,8 @@
<field name="name">Agreement Section Search</field>
<field name="model">agreement.section</field>
<field name="arch" type="xml">
<search string="Agreement Section Search">
<search string="Section">
<field name="name" />
<filter
name="group_agreement"
string="Agreements"

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Agreement Stage List View-->
<record model="ir.ui.view" id="partner_agreement_stage_list_view">

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Agreement Sub Type List View-->
<record model="ir.ui.view" id="partner_agreement_subtype_list_view">

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Agreement Type List View-->
<record model="ir.ui.view" id="partner_agreement_type_list_view">

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Remove top menu from agreement module -->
<!-- <delete model="ir.ui.menu" id="agreement.agreement_menu" /> -->

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.agreement</field>
@@ -49,7 +49,7 @@
<field name="module_agreement_sale" />
</div>
<div class="o_setting_right_pane">
<label for="" string="Sales" />
<label for="module_agreement_sale" string="Sales" />
<div class="text-muted">
Create an agreement when the sales order is confirmed
</div>
@@ -63,7 +63,10 @@
<field name="module_agreement_sale_subscription" />
</div>
<div class="o_setting_right_pane">
<label for="" string="Sale Subscriptions" />
<label
for="module_agreement_sale_subscription"
string="Sale Subscriptions"
/>
<div class="text-muted">
Link your subscriptions to an agreement
</div>
@@ -74,7 +77,10 @@
<field name="module_fieldservice_agreement" />
</div>
<div class="o_setting_right_pane">
<label for="" string="Field Service" />
<label
for="module_fieldservice_agreement"
string="Field Service"
/>
<div class="text-muted">
Link your Field Service orders and equipments to an agreement
</div>
@@ -85,7 +91,10 @@
<field name="module_agreement_stock" />
</div>
<div class="o_setting_right_pane">
<label for="" string="Inventory" />
<label
for="module_agreement_stock"
string="Inventory"
/>
<div class="text-muted">
Link your transfers to an agreement
</div>
@@ -96,7 +105,7 @@
<field name="module_agreement_rma" />
</div>
<div class="o_setting_right_pane">
<label for="" string="Returns" />
<label for="module_agreement_rma" string="Returns" />
<div class="text-muted">
Link your returns to an agreement
</div>
@@ -107,7 +116,10 @@
<field name="module_agreement_maintenance" />
</div>
<div class="o_setting_right_pane">
<label for="" string="Maintenance" />
<label
for="module_agreement_maintenance"
string="Maintenance"
/>
<div class="text-muted">
Manage maintenance agreements and contracts
</div>
@@ -118,7 +130,10 @@
<field name="module_agreement_mrp" />
</div>
<div class="o_setting_right_pane">
<label for="" string="Manufacturing" />
<label
for="module_agreement_mrp"
string="Manufacturing"
/>
<div class="text-muted">
Link your manufacturing orders to an agreement
</div>
@@ -129,7 +144,7 @@
<field name="module_agreement_repair" />
</div>
<div class="o_setting_right_pane">
<label for="" string="Repair" />
<label for="module_agreement_repair" string="Repair" />
<div class="text-muted">
Link your repair orders to an agreement
</div>
@@ -140,7 +155,10 @@
<field name="module_agreement_project" />
</div>
<div class="o_setting_right_pane">
<label for="" string="Project" />
<label
for="module_agreement_project"
string="Project"
/>
<div class="text-muted">
Link your projects and tasks to an agreement
</div>
@@ -151,7 +169,10 @@
<field name="module_agreement_helpdesk" />
</div>
<div class="o_setting_right_pane">
<label for="" string="Helpdesk" />
<label
for="module_agreement_helpdesk"
string="Helpdesk"
/>
<div class="text-muted">
Link your Helpdesk tickets to an agreement
</div>
@@ -162,12 +183,11 @@
</xpath>
</field>
</record>
<act_window
id="action_agreement_config"
name="Settings"
res_model="res.config.settings"
view_mode="form"
target="inline"
context="{'module': 'agreement'}"
/>
<record id="action_agreement_config" model="ir.actions.act_window">
<field name="name">Settings</field>
<field name="res_model">res.config.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
<field name="context">{'module': 'agreement'}</field>
</record>
</odoo>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record model="ir.ui.view" id="partner_form">
<field name="model">res.partner</field>