Skip to content

Commit

Permalink
[MIG] agreement_legal: Migration to 13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
victoralmau committed May 14, 2021
1 parent 2ff0685 commit 5250bfc
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 100 deletions.
2 changes: 1 addition & 1 deletion agreement_legal/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"website": "https://github.com/OCA/contract",
"category": "Partner",
"license": "AGPL-3",
"version": "12.0.2.0.1",
"version": "13.0.1.0.0",
"depends": ["contacts", "agreement", "product"],
"data": [
"data/ir_sequence.xml",
Expand Down
12 changes: 0 additions & 12 deletions agreement_legal/migrations/12.0.2.0.0/post-migration.py

This file was deleted.

125 changes: 66 additions & 59 deletions agreement_legal/models/agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,18 @@ class Agreement(models.Model):
help="The revision will increase with every save event.",
)
description = fields.Text(
string="Description",
track_visibility="onchange",
help="Description of the agreement",
string="Description", tracking=True, help="Description of the agreement",
)
dynamic_description = fields.Text(
compute="_compute_dynamic_description",
string="Dynamic Description",
help="Compute dynamic description",
)
start_date = fields.Date(
string="Start Date",
track_visibility="onchange",
help="When the agreement starts.",
string="Start Date", tracking=True, help="When the agreement starts.",
)
end_date = fields.Date(
string="End Date", track_visibility="onchange", help="When the agreement ends."
string="End Date", tracking=True, help="When the agreement ends."
)
color = fields.Integer(string="Color")
active = fields.Boolean(
Expand All @@ -49,33 +45,33 @@ class Agreement(models.Model):
)
company_signed_date = fields.Date(
string="Signed on",
track_visibility="onchange",
tracking=True,
help="Date the contract was signed by Company.",
)
partner_signed_date = fields.Date(
string="Signed on (Partner)",
track_visibility="onchange",
tracking=True,
help="Date the contract was signed by the Partner.",
)
term = fields.Integer(
string="Term (Months)",
track_visibility="onchange",
tracking=True,
help="Number of months this agreement/contract is in effect with the "
"partner.",
)
expiration_notice = fields.Integer(
string="Exp. Notice (Days)",
track_visibility="onchange",
tracking=True,
help="Number of Days before expiration to be notified.",
)
change_notice = fields.Integer(
string="Change Notice (Days)",
track_visibility="onchange",
tracking=True,
help="Number of Days to be notified before changes.",
)
special_terms = fields.Text(
string="Special Terms",
track_visibility="onchange",
tracking=True,
help="Any terms that you have agreed to and want to track on the "
"agreement/contract.",
)
Expand All @@ -88,44 +84,44 @@ class Agreement(models.Model):
string="Reference",
required=True,
default=lambda self: _("New"),
track_visibility="onchange",
tracking=True,
copy=False,
help="ID used for internal contract tracking.",
)
increase_type_id = fields.Many2one(
"agreement.increasetype",
comodel_name="agreement.increasetype",
string="Increase Type",
track_visibility="onchange",
tracking=True,
help="The amount that certain rates may increase.",
)
termination_requested = fields.Date(
string="Termination Requested Date",
track_visibility="onchange",
tracking=True,
help="Date that a request for termination was received.",
)
termination_date = fields.Date(
string="Termination Date",
track_visibility="onchange",
tracking=True,
help="Date that the contract was terminated.",
)
reviewed_date = fields.Date(string="Reviewed Date", track_visibility="onchange")
reviewed_date = fields.Date(string="Reviewed Date", tracking=True)
reviewed_user_id = fields.Many2one(
"res.users", string="Reviewed By", track_visibility="onchange"
comodel_name="res.users", string="Reviewed By", tracking=True
)
approved_date = fields.Date(string="Approved Date", track_visibility="onchange")
approved_date = fields.Date(string="Approved Date", tracking=True)
approved_user_id = fields.Many2one(
"res.users", string="Approved By", track_visibility="onchange"
comodel_name="res.users", string="Approved By", tracking=True
)
currency_id = fields.Many2one("res.currency", string="Currency")
currency_id = fields.Many2one(comodel_name="res.currency", string="Currency")
partner_id = fields.Many2one(
"res.partner",
comodel_name="res.partner",
string="Partner",
required=False,
copy=True,
help="The customer or vendor this agreement is related to.",
)
partner_contact_id = fields.Many2one(
"res.partner",
comodel_name="res.partner",
string="Partner Contact",
copy=True,
help="The primary partner contact (If Applicable).",
Expand All @@ -137,7 +133,7 @@ class Agreement(models.Model):
related="partner_contact_id.email", string="Partner Email"
)
company_contact_id = fields.Many2one(
"res.partner",
comodel_name="res.partner",
string="Company Contact",
copy=True,
help="The primary contact in the company.",
Expand Down Expand Up @@ -182,7 +178,7 @@ def _get_default_parties(self):

parties = fields.Html(
string="Parties",
track_visibility="onchange",
tracking=True,
default=_get_default_parties,
help="Parties of the agreement",
)
Expand All @@ -191,87 +187,103 @@ def _get_default_parties(self):
string="Dynamic Parties",
help="Compute dynamic parties",
)
agreement_type_id = fields.Many2one(track_visibility="onchange",)
agreement_type_id = fields.Many2one(tracking=True)
agreement_subtype_id = fields.Many2one(
"agreement.subtype",
comodel_name="agreement.subtype",
string="Agreement Sub-type",
track_visibility="onchange",
tracking=True,
help="Select the sub-type of this agreement. Sub-Types are related to "
"agreement types.",
)
product_ids = fields.Many2many("product.template", string="Products & Services")
product_ids = fields.Many2many(
comodel_name="product.template", string="Products & Services"
)
assigned_user_id = fields.Many2one(
"res.users",
comodel_name="res.users",
string="Assigned To",
track_visibility="onchange",
tracking=True,
help="Select the user who manages this agreement.",
)
company_signed_user_id = fields.Many2one(
"res.users",
comodel_name="res.users",
string="Signed By",
track_visibility="onchange",
tracking=True,
help="The user at our company who authorized/signed the agreement or "
"contract.",
)
partner_signed_user_id = fields.Many2one(
"res.partner",
comodel_name="res.partner",
string="Signed By (Partner)",
track_visibility="onchange",
tracking=True,
help="Contact on the account that signed the agreement/contract.",
)
parent_agreement_id = fields.Many2one(
"agreement",
comodel_name="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(
"agreement.renewaltype",
comodel_name="agreement.renewaltype",
string="Renewal Type",
track_visibility="onchange",
tracking=True,
help="Describes what happens after the contract expires.",
)
recital_ids = fields.One2many(
"agreement.recital", "agreement_id", string="Recitals", copy=True
comodel_name="agreement.recital",
inverse_name="agreement_id",
string="Recitals",
copy=True,
)
sections_ids = fields.One2many(
"agreement.section", "agreement_id", string="Sections", copy=True
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"
)
clauses_ids = fields.One2many("agreement.clause", "agreement_id", string="Clauses")
appendix_ids = fields.One2many(
"agreement.appendix", "agreement_id", string="Appendices", copy=True
comodel_name="agreement.appendix",
inverse_name="agreement_id",
string="Appendices",
copy=True,
)
previous_version_agreements_ids = fields.One2many(
"agreement",
"parent_agreement_id",
comodel_name="agreement",
inverse_name="parent_agreement_id",
string="Previous Versions",
copy=False,
domain=[("active", "=", False)],
)
child_agreements_ids = fields.One2many(
"agreement",
"parent_agreement_id",
comodel_name="agreement",
inverse_name="parent_agreement_id",
string="Child Agreements",
copy=False,
domain=[("active", "=", True)],
)
line_ids = fields.One2many(
"agreement.line", "agreement_id", string="Products/Services", copy=False
comodel_name="agreement.line",
inverse_name="agreement_id",
string="Products/Services",
copy=False,
)
state = fields.Selection(
[("draft", "Draft"), ("active", "Active"), ("inactive", "Inactive")],
default="draft",
track_visibility="always",
tracking=True,
)
notification_address_id = fields.Many2one(
"res.partner",
comodel_name="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", track_visibility="always")
signed_contract = fields.Binary(string="Signed Document", tracking=True)

# Dynamic field editor
field_domain = fields.Char(
Expand Down Expand Up @@ -299,7 +311,6 @@ def onchange_copyvalue(self):
)

# compute the dynamic content for mako expression
@api.multi
def _compute_dynamic_description(self):
MailTemplates = self.env["mail.template"]
for agreement in self:
Expand All @@ -309,7 +320,6 @@ def _compute_dynamic_description(self):
)
agreement.dynamic_description = description

@api.multi
def _compute_dynamic_parties(self):
MailTemplates = self.env["mail.template"]
for agreement in self:
Expand All @@ -319,7 +329,6 @@ def _compute_dynamic_parties(self):
)
agreement.dynamic_parties = parties

@api.multi
def _compute_dynamic_special_terms(self):
MailTemplates = self.env["mail.template"]
for agreement in self:
Expand All @@ -338,16 +347,15 @@ def _read_group_stage_ids(self, stages, domain, order):
return stage_ids

stage_id = fields.Many2one(
"agreement.stage",
comodel_name="agreement.stage",
string="Stage",
group_expand="_read_group_stage_ids",
help="Select the current stage of the agreement.",
track_visibility="onchange",
tracking=True,
index=True,
)

# Create New Version Button
@api.multi
def create_new_version(self, vals):
for rec in self:
if not rec.state == "draft":
Expand Down Expand Up @@ -394,7 +402,6 @@ def create(self, vals):
return super(Agreement, self).create(vals)

# Increments the revision on each save action
@api.multi
def write(self, vals):
res = True
for rec in self:
Expand Down
5 changes: 3 additions & 2 deletions agreement_legal/models/agreement_appendix.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class AgreementAppendix(models.Model):
string="Dynamic Content",
help="compute dynamic Content",
)
agreement_id = fields.Many2one("agreement", string="Agreement", ondelete="cascade")
agreement_id = fields.Many2one(
comodel_name="agreement", string="Agreement", ondelete="cascade"
)
active = fields.Boolean(
string="Active",
default=True,
Expand Down Expand Up @@ -56,7 +58,6 @@ def onchange_copyvalue(self):
)

# compute the dynamic content for mako expression
@api.multi
def _compute_dynamic_content(self):
MailTemplates = self.env["mail.template"]
for appendix in self:
Expand Down
7 changes: 4 additions & 3 deletions agreement_legal/models/agreement_clause.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ class AgreementClause(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("agreement", string="Agreement", ondelete="cascade")
agreement_id = fields.Many2one(
comodel_name="agreement", string="Agreement", ondelete="cascade"
)
section_id = fields.Many2one(
"agreement.section", string="Section", ondelete="cascade"
comodel_name="agreement.section", string="Section", ondelete="cascade"
)
content = fields.Html(string="Clause Content")
dynamic_content = fields.Html(
Expand Down Expand Up @@ -57,7 +59,6 @@ def onchange_copyvalue(self):
)

# compute the dynamic content for mako expression
@api.multi
def _compute_dynamic_content(self):
MailTemplates = self.env["mail.template"]
for clause in self:
Expand Down

0 comments on commit 5250bfc

Please sign in to comment.