mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
Merge pull request #324 from ursais/12.0-fix-323
[FIX] agreement_legal: Copy (#323)
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
access_agreement_read,Read access on agreement to Employees,model_agreement,base.group_user,1,0,0,0
|
access_agreement_read,Read access on agreement to Employees,model_agreement,base.group_user,1,0,0,0
|
||||||
access_agreement_full,Full access on agreement grp,model_agreement,base.group_no_one,1,1,1,1
|
access_agreement_full,Full access on agreement grp,model_agreement,base.group_no_one,1,1,1,1
|
||||||
|
|||||||
|
@@ -17,159 +17,123 @@ class Agreement(models.Model):
|
|||||||
string="Is a Template?",
|
string="Is a Template?",
|
||||||
default=False,
|
default=False,
|
||||||
copy=False,
|
copy=False,
|
||||||
help="Make this agreement a template.",
|
help="Make this agreement a template.")
|
||||||
)
|
|
||||||
version = fields.Integer(
|
version = fields.Integer(
|
||||||
string="Version",
|
string="Version",
|
||||||
default=1,
|
default=1,
|
||||||
copy=False,
|
copy=False,
|
||||||
help="The versions are used to keep track of document history and "
|
help="The versions are used to keep track of document history and "
|
||||||
"previous versions can be referenced.",
|
"previous versions can be referenced.")
|
||||||
)
|
|
||||||
revision = fields.Integer(
|
revision = fields.Integer(
|
||||||
string="Revision",
|
string="Revision",
|
||||||
default=0,
|
default=0,
|
||||||
copy=False,
|
copy=False,
|
||||||
help="The revision will increase with every save event.",
|
help="The revision will increase with every save event.")
|
||||||
)
|
|
||||||
description = fields.Text(
|
description = fields.Text(
|
||||||
string="Description",
|
string="Description",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Description of the agreement",
|
help="Description of the agreement")
|
||||||
)
|
|
||||||
dynamic_description = fields.Text(
|
dynamic_description = fields.Text(
|
||||||
compute="_compute_dynamic_description",
|
compute="_compute_dynamic_description",
|
||||||
string="Dynamic Description",
|
string="Dynamic Description",
|
||||||
help="Compute dynamic description",
|
help="Compute dynamic description")
|
||||||
)
|
|
||||||
start_date = fields.Date(
|
start_date = fields.Date(
|
||||||
string="Start Date",
|
string="Start Date",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="When the agreement starts.",
|
help="When the agreement starts.")
|
||||||
)
|
|
||||||
end_date = fields.Date(
|
end_date = fields.Date(
|
||||||
string="End Date",
|
string="End Date",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="When the agreement ends.",
|
help="When the agreement ends.")
|
||||||
)
|
color = fields.Integer(string="Color")
|
||||||
color = fields.Integer()
|
|
||||||
active = fields.Boolean(
|
active = fields.Boolean(
|
||||||
string="Active",
|
string="Active",
|
||||||
default=True,
|
default=True,
|
||||||
help="If unchecked, it will allow you to hide the agreement without "
|
help="If unchecked, it will allow you to hide the agreement without "
|
||||||
"removing it.",
|
"removing it.")
|
||||||
)
|
|
||||||
company_signed_date = fields.Date(
|
company_signed_date = fields.Date(
|
||||||
string="Signed on",
|
string="Signed on",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Date the contract was signed by Company.",
|
help="Date the contract was signed by Company.")
|
||||||
)
|
|
||||||
partner_signed_date = fields.Date(
|
partner_signed_date = fields.Date(
|
||||||
string="Signed on",
|
string="Signed on (Partner)",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Date the contract was signed by the Partner.",
|
help="Date the contract was signed by the Partner.")
|
||||||
)
|
|
||||||
term = fields.Integer(
|
term = fields.Integer(
|
||||||
string="Term (Months)",
|
string="Term (Months)",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Number of months this agreement/contract is in effect with the "
|
help="Number of months this agreement/contract is in effect with the "
|
||||||
"partner.",
|
"partner.")
|
||||||
)
|
|
||||||
expiration_notice = fields.Integer(
|
expiration_notice = fields.Integer(
|
||||||
string="Exp. Notice (Days)",
|
string="Exp. Notice (Days)",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Number of Days before expiration to be notified.",
|
help="Number of Days before expiration to be notified.")
|
||||||
)
|
|
||||||
change_notice = fields.Integer(
|
change_notice = fields.Integer(
|
||||||
string="Change Notice (Days)",
|
string="Change Notice (Days)",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Number of Days to be notified before changes.",
|
help="Number of Days to be notified before changes.")
|
||||||
)
|
|
||||||
special_terms = fields.Text(
|
special_terms = fields.Text(
|
||||||
string="Special Terms",
|
string="Special Terms",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Any terms that you have agreed to and want to track on the "
|
help="Any terms that you have agreed to and want to track on the "
|
||||||
"agreement/contract.",
|
"agreement/contract.")
|
||||||
)
|
|
||||||
dynamic_special_terms = fields.Text(
|
dynamic_special_terms = fields.Text(
|
||||||
compute="_compute_dynamic_special_terms",
|
compute="_compute_dynamic_special_terms",
|
||||||
string="Dynamic Special Terms",
|
string="Dynamic Special Terms",
|
||||||
help="Compute dynamic special terms",
|
help="Compute dynamic special terms")
|
||||||
)
|
|
||||||
code = fields.Char(
|
code = fields.Char(
|
||||||
string="Reference",
|
string="Reference",
|
||||||
required=True,
|
required=True,
|
||||||
default=lambda self: _("New"),
|
default=lambda self: _("New"),
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
copy=False,
|
copy=False,
|
||||||
help="ID used for internal contract tracking.",
|
help="ID used for internal contract tracking.")
|
||||||
)
|
|
||||||
increase_type_id = fields.Many2one(
|
increase_type_id = fields.Many2one(
|
||||||
"agreement.increasetype",
|
"agreement.increasetype",
|
||||||
string="Increase Type",
|
string="Increase Type",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="The amount that certain rates may increase.",
|
help="The amount that certain rates may increase.")
|
||||||
)
|
|
||||||
termination_requested = fields.Date(
|
termination_requested = fields.Date(
|
||||||
string="Termination Requested Date",
|
string="Termination Requested Date",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Date that a request for termination was received.",
|
help="Date that a request for termination was received.")
|
||||||
)
|
|
||||||
termination_date = fields.Date(
|
termination_date = fields.Date(
|
||||||
string="Termination Date",
|
string="Termination Date",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Date that the contract was terminated.",
|
help="Date that the contract was terminated.")
|
||||||
)
|
|
||||||
reviewed_date = fields.Date(
|
reviewed_date = fields.Date(
|
||||||
string="Reviewed Date", track_visibility="onchange"
|
string="Reviewed Date", track_visibility="onchange")
|
||||||
)
|
|
||||||
reviewed_user_id = fields.Many2one(
|
reviewed_user_id = fields.Many2one(
|
||||||
"res.users", string="Reviewed By", track_visibility="onchange"
|
"res.users", string="Reviewed By", track_visibility="onchange")
|
||||||
)
|
|
||||||
approved_date = fields.Date(
|
approved_date = fields.Date(
|
||||||
string="Approved Date", track_visibility="onchange"
|
string="Approved Date", track_visibility="onchange")
|
||||||
)
|
|
||||||
approved_user_id = fields.Many2one(
|
approved_user_id = fields.Many2one(
|
||||||
"res.users", string="Approved By", track_visibility="onchange"
|
"res.users", string="Approved By", track_visibility="onchange")
|
||||||
)
|
|
||||||
currency_id = fields.Many2one("res.currency", string="Currency")
|
currency_id = fields.Many2one("res.currency", string="Currency")
|
||||||
partner_id = fields.Many2one(
|
partner_id = fields.Many2one(
|
||||||
"res.partner",
|
"res.partner",
|
||||||
string="Partner",
|
string="Partner",
|
||||||
required=False,
|
required=False,
|
||||||
copy=True,
|
copy=True,
|
||||||
help="The customer or vendor this agreement is related to.",
|
help="The customer or vendor this agreement is related to.")
|
||||||
)
|
|
||||||
company_partner_id = fields.Many2one(
|
|
||||||
"res.partner",
|
|
||||||
string="Company",
|
|
||||||
copy=True,
|
|
||||||
default=lambda self: self.env.user.company_id.partner_id,
|
|
||||||
)
|
|
||||||
partner_contact_id = fields.Many2one(
|
partner_contact_id = fields.Many2one(
|
||||||
"res.partner",
|
"res.partner",
|
||||||
string="Partner Contact",
|
string="Partner Contact",
|
||||||
copy=True,
|
copy=True,
|
||||||
help="The primary partner contact (If Applicable).",
|
help="The primary partner contact (If Applicable).")
|
||||||
)
|
|
||||||
partner_contact_phone = fields.Char(
|
partner_contact_phone = fields.Char(
|
||||||
related="partner_contact_id.phone", string="Phone"
|
related="partner_contact_id.phone", string="Partner Phone")
|
||||||
)
|
|
||||||
partner_contact_email = fields.Char(
|
partner_contact_email = fields.Char(
|
||||||
related="partner_contact_id.email", string="Email"
|
related="partner_contact_id.email", string="Partner Email")
|
||||||
)
|
|
||||||
company_contact_id = fields.Many2one(
|
company_contact_id = fields.Many2one(
|
||||||
"res.partner",
|
"res.partner",
|
||||||
string="Company Contact",
|
string="Company Contact",
|
||||||
copy=True,
|
copy=True,
|
||||||
help="The primary contact in the company.",
|
help="The primary contact in the company.")
|
||||||
)
|
|
||||||
company_contact_phone = fields.Char(
|
company_contact_phone = fields.Char(
|
||||||
related="company_contact_id.phone", string="Phone"
|
related="company_contact_id.phone", string="Phone")
|
||||||
)
|
|
||||||
company_contact_email = fields.Char(
|
company_contact_email = fields.Char(
|
||||||
related="company_contact_id.email", string="Email"
|
related="company_contact_id.email", string="Email")
|
||||||
)
|
|
||||||
use_parties_content = fields.Boolean(
|
use_parties_content = fields.Boolean(
|
||||||
string="Use parties content",
|
string="Use parties content",
|
||||||
help="Use custom content for parties")
|
help="Use custom content for parties")
|
||||||
@@ -178,12 +142,12 @@ class Agreement(models.Model):
|
|||||||
deftext = """
|
deftext = """
|
||||||
<h3>Company Information</h3>
|
<h3>Company Information</h3>
|
||||||
<p>
|
<p>
|
||||||
${object.company_partner_id.name or ''}.<br>
|
${object.company_id.partner_id.name or ''}.<br>
|
||||||
${object.company_partner_id.street or ''} <br>
|
${object.company_id.partner_id.street or ''} <br>
|
||||||
${object.company_partner_id.state_id.code or ''}
|
${object.company_id.partner_id.state_id.code or ''}
|
||||||
${object.company_partner_id.zip or ''}
|
${object.company_id.partner_id.zip or ''}
|
||||||
${object.company_partner_id.city or ''}<br>
|
${object.company_id.partner_id.city or ''}<br>
|
||||||
${object.company_partner_id.country_id.name or ''}.<br><br>
|
${object.company_id.partner_id.country_id.name or ''}.<br><br>
|
||||||
Represented by <b>${object.company_contact_id.name or ''}.</b>
|
Represented by <b>${object.company_contact_id.name or ''}.</b>
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p></p>
|
||||||
@@ -203,137 +167,112 @@ class Agreement(models.Model):
|
|||||||
string="Parties",
|
string="Parties",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
default=_get_default_parties,
|
default=_get_default_parties,
|
||||||
help="Parties of the agreement",
|
help="Parties of the agreement")
|
||||||
)
|
|
||||||
dynamic_parties = fields.Html(
|
dynamic_parties = fields.Html(
|
||||||
compute="_compute_dynamic_parties",
|
compute="_compute_dynamic_parties",
|
||||||
string="Dynamic Parties",
|
string="Dynamic Parties",
|
||||||
help="Compute dynamic parties",
|
help="Compute dynamic parties")
|
||||||
)
|
|
||||||
agreement_type_id = fields.Many2one(
|
agreement_type_id = fields.Many2one(
|
||||||
"agreement.type",
|
"agreement.type",
|
||||||
string="Agreement Type",
|
string="Agreement Type",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Select the type of agreement.",
|
help="Select the type of agreement.")
|
||||||
)
|
|
||||||
agreement_subtype_id = fields.Many2one(
|
agreement_subtype_id = fields.Many2one(
|
||||||
"agreement.subtype",
|
"agreement.subtype",
|
||||||
string="Agreement Sub-type",
|
string="Agreement Sub-type",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Select the sub-type of this agreement. Sub-Types are related to "
|
help="Select the sub-type of this agreement. Sub-Types are related to "
|
||||||
"agreement types.",
|
"agreement types.")
|
||||||
)
|
|
||||||
product_ids = fields.Many2many(
|
product_ids = fields.Many2many(
|
||||||
"product.template", string="Products & Services"
|
"product.template", string="Products & Services")
|
||||||
)
|
|
||||||
assigned_user_id = fields.Many2one(
|
assigned_user_id = fields.Many2one(
|
||||||
"res.users",
|
"res.users",
|
||||||
string="Assigned To",
|
string="Assigned To",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Select the user who manages this agreement.",
|
help="Select the user who manages this agreement.")
|
||||||
)
|
|
||||||
company_signed_user_id = fields.Many2one(
|
company_signed_user_id = fields.Many2one(
|
||||||
"res.users",
|
"res.users",
|
||||||
string="Signed By",
|
string="Signed By",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="The user at our company who authorized/signed the agreement or "
|
help="The user at our company who authorized/signed the agreement or "
|
||||||
"contract.",
|
"contract.")
|
||||||
)
|
|
||||||
partner_signed_user_id = fields.Many2one(
|
partner_signed_user_id = fields.Many2one(
|
||||||
"res.partner",
|
"res.partner",
|
||||||
string="Signed By",
|
string="Signed By (Partner)",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Contact on the account that signed the agreement/contract.",
|
help="Contact on the account that signed the agreement/contract.")
|
||||||
)
|
|
||||||
parent_agreement_id = fields.Many2one(
|
parent_agreement_id = fields.Many2one(
|
||||||
"agreement",
|
"agreement",
|
||||||
string="Parent Agreement",
|
string="Parent Agreement",
|
||||||
help="Link this agreement to a parent agreement. For example if this "
|
help="Link this agreement to a parent agreement. For example if this "
|
||||||
"agreement is an amendment to another agreement. This list will "
|
"agreement is an amendment to another agreement. This list will "
|
||||||
"only show other agreements related to the same account.",
|
"only show other agreements related to the same account.")
|
||||||
)
|
|
||||||
renewal_type_id = fields.Many2one(
|
renewal_type_id = fields.Many2one(
|
||||||
"agreement.renewaltype",
|
"agreement.renewaltype",
|
||||||
string="Renewal Type",
|
string="Renewal Type",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
help="Describes what happens after the contract expires.",
|
help="Describes what happens after the contract expires.")
|
||||||
)
|
|
||||||
recital_ids = fields.One2many(
|
recital_ids = fields.One2many(
|
||||||
"agreement.recital", "agreement_id", string="Recitals", copy=True
|
"agreement.recital", "agreement_id", string="Recitals", copy=True)
|
||||||
)
|
|
||||||
sections_ids = fields.One2many(
|
sections_ids = fields.One2many(
|
||||||
"agreement.section", "agreement_id", string="Sections", copy=True
|
"agreement.section", "agreement_id", string="Sections", copy=True)
|
||||||
)
|
|
||||||
clauses_ids = fields.One2many(
|
clauses_ids = fields.One2many(
|
||||||
"agreement.clause", "agreement_id", string="Clauses", copy=True
|
"agreement.clause", "agreement_id", string="Clauses")
|
||||||
)
|
|
||||||
appendix_ids = fields.One2many(
|
appendix_ids = fields.One2many(
|
||||||
"agreement.appendix", "agreement_id", string="Appendices", copy=True
|
"agreement.appendix", "agreement_id", string="Appendices", copy=True)
|
||||||
)
|
|
||||||
previous_version_agreements_ids = fields.One2many(
|
previous_version_agreements_ids = fields.One2many(
|
||||||
"agreement",
|
"agreement",
|
||||||
"parent_agreement_id",
|
"parent_agreement_id",
|
||||||
string="Child Agreements",
|
string="Previous Versions",
|
||||||
copy=False,
|
copy=False,
|
||||||
domain=[("active", "=", False)],
|
domain=[("active", "=", False)])
|
||||||
)
|
|
||||||
child_agreements_ids = fields.One2many(
|
child_agreements_ids = fields.One2many(
|
||||||
"agreement",
|
"agreement",
|
||||||
"parent_agreement_id",
|
"parent_agreement_id",
|
||||||
string="Child Agreements",
|
string="Child Agreements",
|
||||||
copy=False,
|
copy=False,
|
||||||
domain=[("active", "=", True)],
|
domain=[("active", "=", True)])
|
||||||
)
|
|
||||||
line_ids = fields.One2many(
|
line_ids = fields.One2many(
|
||||||
"agreement.line",
|
"agreement.line",
|
||||||
"agreement_id",
|
"agreement_id",
|
||||||
string="Products/Services",
|
string="Products/Services",
|
||||||
copy=False,
|
copy=False)
|
||||||
)
|
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
[("draft", "Draft"), ("active", "Active"), ("inactive", "Inactive")],
|
[("draft", "Draft"), ("active", "Active"), ("inactive", "Inactive")],
|
||||||
default="draft",
|
default="draft",
|
||||||
track_visibility="always",
|
track_visibility="always")
|
||||||
)
|
|
||||||
notification_address_id = fields.Many2one(
|
notification_address_id = fields.Many2one(
|
||||||
"res.partner",
|
"res.partner",
|
||||||
string="Notification Address",
|
string="Notification Address",
|
||||||
help="The address to send notificaitons to, if different from "
|
help="The address to send notificaitons to, if different from "
|
||||||
"customer address.(Address Type = Other)",
|
"customer address.(Address Type = Other)")
|
||||||
)
|
|
||||||
signed_contract_filename = fields.Char(string="Filename")
|
signed_contract_filename = fields.Char(string="Filename")
|
||||||
signed_contract = fields.Binary(
|
signed_contract = fields.Binary(
|
||||||
string="Signed Document", track_visibility="always"
|
string="Signed Document", track_visibility="always")
|
||||||
)
|
|
||||||
field_id = fields.Many2one(
|
field_id = fields.Many2one(
|
||||||
"ir.model.fields",
|
"ir.model.fields",
|
||||||
string="Field",
|
string="Field",
|
||||||
help="""Select target field from the related document model. If it is a
|
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
|
relationship field you will be able to select a target field at the
|
||||||
destination of the relationship.""",
|
destination of the relationship.""")
|
||||||
)
|
|
||||||
sub_object_id = fields.Many2one(
|
sub_object_id = fields.Many2one(
|
||||||
"ir.model",
|
"ir.model",
|
||||||
string="Sub-model",
|
string="Sub-model",
|
||||||
help="""When a relationship field is selected as first field, this
|
help="""When a relationship field is selected as first field, this
|
||||||
field shows the document model the relationship goes to.""",
|
field shows the document model the relationship goes to.""")
|
||||||
)
|
|
||||||
sub_model_object_field_id = fields.Many2one(
|
sub_model_object_field_id = fields.Many2one(
|
||||||
"ir.model.fields",
|
"ir.model.fields",
|
||||||
string="Sub-field",
|
string="Sub-field",
|
||||||
help="""When a relationship field is selected as first field, this
|
help="""When a relationship field is selected as first field, this
|
||||||
field lets you select the target field within the destination document
|
field lets you select the target field within the destination document
|
||||||
model (sub-model).""",
|
model (sub-model).""")
|
||||||
)
|
|
||||||
default_value = fields.Char(
|
default_value = fields.Char(
|
||||||
string="Default Value",
|
string="Default Value",
|
||||||
help="Optional value to use if the target field is empty.",
|
help="Optional value to use if the target field is empty.")
|
||||||
)
|
|
||||||
copyvalue = fields.Char(
|
copyvalue = fields.Char(
|
||||||
string="Placeholder Expression",
|
string="Placeholder Expression",
|
||||||
help="""Final placeholder expression, to be copy-pasted in the desired
|
help="""Final placeholder expression, to be copy-pasted in the desired
|
||||||
template field.""",
|
template field.""")
|
||||||
)
|
|
||||||
|
|
||||||
# compute the dynamic content for mako expression
|
# compute the dynamic content for mako expression
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -379,19 +318,16 @@ class Agreement(models.Model):
|
|||||||
self.sub_object_id = False
|
self.sub_object_id = False
|
||||||
if self.field_id and not self.field_id.relation:
|
if self.field_id and not self.field_id.relation:
|
||||||
self.copyvalue = "${{object.{} or {}}}".format(
|
self.copyvalue = "${{object.{} or {}}}".format(
|
||||||
self.field_id.name, self.default_value or "''"
|
self.field_id.name, self.default_value or "''")
|
||||||
)
|
|
||||||
self.sub_model_object_field_id = False
|
self.sub_model_object_field_id = False
|
||||||
if self.field_id and self.field_id.relation:
|
if self.field_id and self.field_id.relation:
|
||||||
self.sub_object_id = self.env["ir.model"].search(
|
self.sub_object_id = self.env["ir.model"].search(
|
||||||
[("model", "=", self.field_id.relation)]
|
[("model", "=", self.field_id.relation)])[0]
|
||||||
)[0]
|
|
||||||
if self.sub_model_object_field_id:
|
if self.sub_model_object_field_id:
|
||||||
self.copyvalue = "${{object.{}.{} or {}}}".format(
|
self.copyvalue = "${{object.{}.{} or {}}}".format(
|
||||||
self.field_id.name,
|
self.field_id.name,
|
||||||
self.sub_model_object_field_id.name,
|
self.sub_model_object_field_id.name,
|
||||||
self.default_value or "''",
|
self.default_value or "''")
|
||||||
)
|
|
||||||
|
|
||||||
# Used for Kanban grouped_by view
|
# Used for Kanban grouped_by view
|
||||||
@api.model
|
@api.model
|
||||||
@@ -403,11 +339,10 @@ class Agreement(models.Model):
|
|||||||
"agreement.stage",
|
"agreement.stage",
|
||||||
string="Stage",
|
string="Stage",
|
||||||
group_expand="_read_group_stage_ids",
|
group_expand="_read_group_stage_ids",
|
||||||
|
default=lambda self: self._default_stage_id(),
|
||||||
help="Select the current stage of the agreement.",
|
help="Select the current stage of the agreement.",
|
||||||
track_visibility="onchange",
|
track_visibility="onchange",
|
||||||
index=True,
|
index=True)
|
||||||
# default=lambda self: self._default_stage_id(),
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create New Version Button
|
# Create New Version Button
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -436,8 +371,10 @@ class Agreement(models.Model):
|
|||||||
"version": 1,
|
"version": 1,
|
||||||
"revision": 0,
|
"revision": 0,
|
||||||
"state": "draft",
|
"state": "draft",
|
||||||
|
"stage_id": self.env.ref("agreement_legal.agreement_stage_new").id,
|
||||||
}
|
}
|
||||||
res = self.copy(default=default_vals)
|
res = self.copy(default=default_vals)
|
||||||
|
res.sections_ids.clauses_ids.write({'agreement_id': res.id})
|
||||||
return {
|
return {
|
||||||
"res_model": "agreement",
|
"res_model": "agreement",
|
||||||
"type": "ir.actions.act_window",
|
"type": "ir.actions.act_window",
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ class AgreementClause(models.Model):
|
|||||||
name = fields.Char(string="Name", required=True)
|
name = fields.Char(string="Name", required=True)
|
||||||
title = fields.Char(
|
title = fields.Char(
|
||||||
string="Title",
|
string="Title",
|
||||||
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")
|
sequence = fields.Integer(string="Sequence")
|
||||||
agreement_id = fields.Many2one(
|
agreement_id = fields.Many2one(
|
||||||
"agreement",
|
"agreement",
|
||||||
@@ -22,20 +21,17 @@ class AgreementClause(models.Model):
|
|||||||
section_id = fields.Many2one(
|
section_id = fields.Many2one(
|
||||||
"agreement.section",
|
"agreement.section",
|
||||||
string="Section",
|
string="Section",
|
||||||
ondelete="cascade"
|
ondelete="cascade")
|
||||||
)
|
|
||||||
content = fields.Html(string="Clause Content")
|
content = fields.Html(string="Clause Content")
|
||||||
dynamic_content = fields.Html(
|
dynamic_content = fields.Html(
|
||||||
compute="_compute_dynamic_content",
|
compute="_compute_dynamic_content",
|
||||||
string="Dynamic Content",
|
string="Dynamic Content",
|
||||||
help="compute dynamic Content",
|
help="compute dynamic Content")
|
||||||
)
|
|
||||||
active = fields.Boolean(
|
active = fields.Boolean(
|
||||||
string="Active",
|
string="Active",
|
||||||
default=True,
|
default=True,
|
||||||
help="If unchecked, it will allow you to hide the agreement without "
|
help="If unchecked, it will allow you to hide the agreement without "
|
||||||
"removing it.",
|
"removing it.")
|
||||||
)
|
|
||||||
|
|
||||||
# Dynamic field editor
|
# Dynamic field editor
|
||||||
field_id = fields.Many2one(
|
field_id = fields.Many2one(
|
||||||
@@ -43,30 +39,25 @@ class AgreementClause(models.Model):
|
|||||||
string="Field",
|
string="Field",
|
||||||
help="""Select target field from the related document model. If it is a
|
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
|
relationship field you will be able to select a target field at the
|
||||||
destination of the relationship.""",
|
destination of the relationship.""")
|
||||||
)
|
|
||||||
sub_object_id = fields.Many2one(
|
sub_object_id = fields.Many2one(
|
||||||
"ir.model",
|
"ir.model",
|
||||||
string="Sub-model",
|
string="Sub-model",
|
||||||
help="""When a relationship field is selected as first field, this
|
help="""When a relationship field is selected as first field, this
|
||||||
field shows the document model the relationship goes to.""",
|
field shows the document model the relationship goes to.""")
|
||||||
)
|
|
||||||
sub_model_object_field_id = fields.Many2one(
|
sub_model_object_field_id = fields.Many2one(
|
||||||
"ir.model.fields",
|
"ir.model.fields",
|
||||||
string="Sub-field",
|
string="Sub-field",
|
||||||
help="""When a relationship field is selected as first field, this
|
help="""When a relationship field is selected as first field, this
|
||||||
field lets you select the target field within the destination document
|
field lets you select the target field within the destination document
|
||||||
model (sub-model).""",
|
model (sub-model).""")
|
||||||
)
|
|
||||||
default_value = fields.Char(
|
default_value = fields.Char(
|
||||||
string="Default Value",
|
string="Default Value",
|
||||||
help="Optional value to use if the target field is empty.",
|
help="Optional value to use if the target field is empty.")
|
||||||
)
|
|
||||||
copyvalue = fields.Char(
|
copyvalue = fields.Char(
|
||||||
string="Placeholder Expression",
|
string="Placeholder Expression",
|
||||||
help="""Final placeholder expression, to be copy-pasted in the desired
|
help="""Final placeholder expression, to be copy-pasted in the desired
|
||||||
template field.""",
|
template field.""")
|
||||||
)
|
|
||||||
|
|
||||||
@api.onchange('field_id', 'sub_model_object_field_id', 'default_value')
|
@api.onchange('field_id', 'sub_model_object_field_id', 'default_value')
|
||||||
def onchange_copyvalue(self):
|
def onchange_copyvalue(self):
|
||||||
|
|||||||
@@ -12,27 +12,22 @@ class AgreementSection(models.Model):
|
|||||||
name = fields.Char(string="Name", required=True)
|
name = fields.Char(string="Name", required=True)
|
||||||
title = fields.Char(
|
title = fields.Char(
|
||||||
string="Title",
|
string="Title",
|
||||||
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")
|
sequence = fields.Integer(string="Sequence")
|
||||||
agreement_id = fields.Many2one(
|
agreement_id = fields.Many2one(
|
||||||
"agreement", string="Agreement", ondelete="cascade"
|
"agreement", string="Agreement", ondelete="cascade")
|
||||||
)
|
|
||||||
clauses_ids = fields.One2many(
|
clauses_ids = fields.One2many(
|
||||||
"agreement.clause", "section_id", string="Clauses"
|
"agreement.clause", "section_id", string="Clauses", copy=True)
|
||||||
)
|
|
||||||
content = fields.Html(string="Section Content")
|
content = fields.Html(string="Section Content")
|
||||||
dynamic_content = fields.Html(
|
dynamic_content = fields.Html(
|
||||||
compute="_compute_dynamic_content",
|
compute="_compute_dynamic_content",
|
||||||
string="Dynamic Content",
|
string="Dynamic Content",
|
||||||
help="compute dynamic Content",
|
help="compute dynamic Content")
|
||||||
)
|
|
||||||
active = fields.Boolean(
|
active = fields.Boolean(
|
||||||
string="Active",
|
string="Active",
|
||||||
default=True,
|
default=True,
|
||||||
help="""If unchecked, it will allow you to hide the
|
help="If unchecked, it will allow you to hide the agreement without "
|
||||||
agreement without removing it.""",
|
"removing it.")
|
||||||
)
|
|
||||||
|
|
||||||
# Dynamic field editor
|
# Dynamic field editor
|
||||||
field_id = fields.Many2one(
|
field_id = fields.Many2one(
|
||||||
@@ -40,30 +35,25 @@ class AgreementSection(models.Model):
|
|||||||
string="Field",
|
string="Field",
|
||||||
help="""Select target field from the related document model. If it is a
|
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
|
relationship field you will be able to select a target field at the
|
||||||
destination of the relationship.""",
|
destination of the relationship.""")
|
||||||
)
|
|
||||||
sub_object_id = fields.Many2one(
|
sub_object_id = fields.Many2one(
|
||||||
"ir.model",
|
"ir.model",
|
||||||
string="Sub-model",
|
string="Sub-model",
|
||||||
help="""When a relationship field is selected as first field, this
|
help="""When a relationship field is selected as first field, this
|
||||||
field shows the document model the relationship goes to.""",
|
field shows the document model the relationship goes to.""")
|
||||||
)
|
|
||||||
sub_model_object_field_id = fields.Many2one(
|
sub_model_object_field_id = fields.Many2one(
|
||||||
"ir.model.fields",
|
"ir.model.fields",
|
||||||
string="Sub-field",
|
string="Sub-field",
|
||||||
help="""When a relationship field is selected as first field, this
|
help="""When a relationship field is selected as first field, this
|
||||||
field lets you select the target field within the destination document
|
field lets you select the target field within the destination document
|
||||||
model (sub-model).""",
|
model (sub-model).""")
|
||||||
)
|
|
||||||
default_value = fields.Char(
|
default_value = fields.Char(
|
||||||
string="Default Value",
|
string="Default Value",
|
||||||
help="Optional value to use if the target field is empty.",
|
help="Optional value to use if the target field is empty.")
|
||||||
)
|
|
||||||
copyvalue = fields.Char(
|
copyvalue = fields.Char(
|
||||||
string="Placeholder Expression",
|
string="Placeholder Expression",
|
||||||
help="""Final placeholder expression, to be copy-pasted in the desired
|
help="""Final placeholder expression, to be copy-pasted in the desired
|
||||||
template field.""",
|
template field.""")
|
||||||
)
|
|
||||||
|
|
||||||
@api.onchange("field_id", "sub_model_object_field_id", "default_value")
|
@api.onchange("field_id", "sub_model_object_field_id", "default_value")
|
||||||
def onchange_copyvalue(self):
|
def onchange_copyvalue(self):
|
||||||
@@ -72,8 +62,7 @@ class AgreementSection(models.Model):
|
|||||||
self.sub_object_id = False
|
self.sub_object_id = False
|
||||||
if self.field_id and not self.field_id.relation:
|
if self.field_id and not self.field_id.relation:
|
||||||
self.copyvalue = "${{object.{} or {}}}".format(
|
self.copyvalue = "${{object.{} or {}}}".format(
|
||||||
self.field_id.name, self.default_value or "''"
|
self.field_id.name, self.default_value or "''")
|
||||||
)
|
|
||||||
self.sub_model_object_field_id = False
|
self.sub_model_object_field_id = False
|
||||||
if self.field_id and self.field_id.relation:
|
if self.field_id and self.field_id.relation:
|
||||||
self.sub_object_id = self.env["ir.model"].search(
|
self.sub_object_id = self.env["ir.model"].search(
|
||||||
@@ -91,12 +80,8 @@ class AgreementSection(models.Model):
|
|||||||
def _compute_dynamic_content(self):
|
def _compute_dynamic_content(self):
|
||||||
MailTemplates = self.env["mail.template"]
|
MailTemplates = self.env["mail.template"]
|
||||||
for section in self:
|
for section in self:
|
||||||
lang = (
|
lang = (section.agreement_id and
|
||||||
section.agreement_id
|
section.agreement_id.partner_id.lang or "en_US")
|
||||||
and section.agreement_id.partner_id.lang
|
|
||||||
or "en_US"
|
|
||||||
)
|
|
||||||
content = MailTemplates.with_context(lang=lang)._render_template(
|
content = MailTemplates.with_context(lang=lang)._render_template(
|
||||||
section.content, "agreement.section", section.id
|
section.content, "agreement.section", section.id)
|
||||||
)
|
|
||||||
section.dynamic_content = content
|
section.dynamic_content = content
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<t t-if="not doc.use_parties_content">
|
<t t-if="not doc.use_parties_content">
|
||||||
<h3>Company Information</h3>
|
<h3>Company Information</h3>
|
||||||
<div name="company_address">
|
<div name="company_address">
|
||||||
<address t-field="doc.company_partner_id"
|
<address t-field="doc.company_id.partner_id"
|
||||||
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
|
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
|
||||||
</div>
|
</div>
|
||||||
<div name="company_contact">
|
<div name="company_contact">
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
<p>Date: </p>
|
<p>Date: </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p t-field="doc.company_partner_id"/>
|
<p t-field="doc.company_id.partner_id"/>
|
||||||
<p>By: </p>
|
<p>By: </p>
|
||||||
<p>
|
<p>
|
||||||
Name: <span t-field="doc.company_contact_id.name"/>
|
Name: <span t-field="doc.company_contact_id.name"/>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<tree string="Agreements" default_order='name'>
|
<tree string="Agreements" default_order='name'>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="partner_id"/>
|
<field name="partner_id"/>
|
||||||
<field name="company_partner_id"/>
|
<field name="company_id"/>
|
||||||
<field name="parent_agreement_id"/>
|
<field name="parent_agreement_id"/>
|
||||||
<field name="agreement_type_id"/>
|
<field name="agreement_type_id"/>
|
||||||
<field name="agreement_subtype_id"/>
|
<field name="agreement_subtype_id"/>
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
<group name="company"
|
<group name="company"
|
||||||
string="Company">
|
string="Company">
|
||||||
<div class="o_address_format">
|
<div class="o_address_format">
|
||||||
<field name="company_partner_id"
|
<field name="company_id"
|
||||||
readonly="1"
|
readonly="1"
|
||||||
context="{'show_address': 1}"
|
context="{'show_address': 1}"
|
||||||
options="{"always_reload": True}"/>
|
options="{"always_reload": True}"/>
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
<field name="partner_contact_email" widget="email" readonly="1" nolabel="1"/>
|
<field name="partner_contact_email" widget="email" readonly="1" nolabel="1"/>
|
||||||
</group>
|
</group>
|
||||||
<group name="contact_right" string="Primary Contact">
|
<group name="contact_right" string="Primary Contact">
|
||||||
<field name="company_contact_id" domain="[('parent_id', '=', company_partner_id)]" nolabel="1"/>
|
<field name="company_contact_id" domain="[('parent_id', '=', company_id.partner_id)]" nolabel="1"/>
|
||||||
<field name="company_contact_phone" widget="phone" readonly="1" nolabel="1"/>
|
<field name="company_contact_phone" widget="phone" readonly="1" nolabel="1"/>
|
||||||
<field name="company_contact_email" widget="email" readonly="1" nolabel="1"/>
|
<field name="company_contact_email" widget="email" readonly="1" nolabel="1"/>
|
||||||
</group>
|
</group>
|
||||||
@@ -137,7 +137,7 @@
|
|||||||
<field name="end_date" attrs="{'required': [('is_template', '=', False)], 'invisible': [('is_template', '=', True)]}"/>
|
<field name="end_date" attrs="{'required': [('is_template', '=', False)], 'invisible': [('is_template', '=', True)]}"/>
|
||||||
<field name="expiration_notice"/>
|
<field name="expiration_notice"/>
|
||||||
<field name="change_notice"/>
|
<field name="change_notice"/>
|
||||||
<field name="notification_address_id" domain="['|', ('parent_id', '=', partner_id), ('parent_id', '=', company_partner_id)]"/>
|
<field name="notification_address_id" domain="['|', ('parent_id', '=', partner_id), ('parent_id', '=', company_id.partner_id)]"/>
|
||||||
<field name="termination_requested"/>
|
<field name="termination_requested"/>
|
||||||
<field name="termination_date"/>
|
<field name="termination_date"/>
|
||||||
</group>
|
</group>
|
||||||
|
|||||||
Reference in New Issue
Block a user