mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[ADD] custom dynamic parties
This commit is contained in:
@@ -170,6 +170,20 @@ class Agreement(models.Model):
|
||||
company_contact_email = fields.Char(
|
||||
related="company_contact_id.email", string="Email"
|
||||
)
|
||||
use_parties_content = fields.Boolean(
|
||||
string="Use parties content",
|
||||
default = False,
|
||||
help="Use custom content for parties" )
|
||||
parties = fields.Html(
|
||||
string="Parties",
|
||||
track_visibility="onchange",
|
||||
help="Parties of the agreement",
|
||||
)
|
||||
dynamic_parties = fields.Html(
|
||||
compute="_compute_dynamic_parties",
|
||||
string="Dynamic Parties",
|
||||
help="Compute dynamic parties",
|
||||
)
|
||||
agreement_type_id = fields.Many2one(
|
||||
"agreement.type",
|
||||
string="Agreement Type",
|
||||
@@ -308,6 +322,18 @@ class Agreement(models.Model):
|
||||
)
|
||||
agreement.dynamic_description = description
|
||||
|
||||
@api.multi
|
||||
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.dynamic_parties = parties
|
||||
|
||||
@api.multi
|
||||
def _compute_dynamic_special_terms(self):
|
||||
MailTemplates = self.env["mail.template"]
|
||||
|
||||
@@ -25,25 +25,32 @@
|
||||
<div class="page">
|
||||
<h1 t-field="doc.name"/>
|
||||
<div name="description">
|
||||
<p t-field="doc.dynamic_description"/>
|
||||
<span t-field="doc.dynamic_description"/>
|
||||
</div>
|
||||
<h2>Parties</h2>
|
||||
<h3>Company Information</h3>
|
||||
<div name="company_address">
|
||||
<address t-field="doc.company_partner_id"
|
||||
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
|
||||
</div>
|
||||
<div name="company_contact">
|
||||
Represented by <span t-field="doc.company_contact_id.name"/>.
|
||||
</div>
|
||||
<h3>Partner Information</h3>
|
||||
<div name="partner_address">
|
||||
<address t-field="doc.partner_id"
|
||||
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
|
||||
</div>
|
||||
<div name="partner_contact">
|
||||
Represented by <span t-field="doc.partner_contact_id.name"/>.
|
||||
<div name="parties">
|
||||
<t t-if="doc.use_parties_content">
|
||||
<p t-field="doc.dynamic_parties"/>
|
||||
</t>
|
||||
</div>
|
||||
<t t-if="not doc.use_parties_content">
|
||||
<h3>Company Information</h3>
|
||||
<div name="company_address">
|
||||
<address t-field="doc.company_partner_id"
|
||||
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
|
||||
</div>
|
||||
<div name="company_contact">
|
||||
Represented by <span t-field="doc.company_contact_id.name"/>.
|
||||
</div>
|
||||
<h3>Partner Information</h3>
|
||||
<div name="partner_address">
|
||||
<address t-field="doc.partner_id"
|
||||
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
|
||||
</div>
|
||||
<div name="partner_contact">
|
||||
Represented by <span t-field="doc.partner_contact_id.name"/>.
|
||||
</div>
|
||||
</t>
|
||||
<h2>Agreement</h2>
|
||||
<h3>Recitals</h3>
|
||||
<table class="table table-condensed">
|
||||
|
||||
@@ -90,7 +90,15 @@
|
||||
</p>
|
||||
</group>
|
||||
<group name="parties" string="Parties">
|
||||
<group name="partner"
|
||||
<group name="cust_parties">
|
||||
<field name="use_parties_content" string="Use custom content" />
|
||||
</group>
|
||||
<group name="cust_parties">
|
||||
<p>
|
||||
This section (on the left) allows you to replace the default listing of the parties with custom dynamic content.
|
||||
</p>
|
||||
</group>
|
||||
<group name="partner"
|
||||
string="Partner">
|
||||
<div class="o_address_format">
|
||||
<field name="partner_id"
|
||||
@@ -119,6 +127,9 @@
|
||||
<field name="company_contact_email" widget="email" readonly="1" nolabel="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<group name="parties_content" string="Parties Content" attrs="{'invisible':[('use_parties_content', '=', False)]}">
|
||||
<field name="parties" nolabel="1"/>
|
||||
</group>
|
||||
<group name="term_information">
|
||||
<group name="termdates_left" string="Term Dates">
|
||||
<field name="start_date" attrs="{'required': [('is_template', '=', False)], 'invisible': [('is_template', '=', True)]}"/>
|
||||
|
||||
Reference in New Issue
Block a user