mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP]13481: compute dynamic content using mako template mechanism and render it in preview-pdf generation for agreement, clause, recital, section, appendix
This commit is contained in:
@@ -40,6 +40,9 @@ class Agreement(models.Model):
|
|||||||
track_visibility='onchange',
|
track_visibility='onchange',
|
||||||
help="Description of the agreement"
|
help="Description of the agreement"
|
||||||
)
|
)
|
||||||
|
dynamic_description = fields.Text(compute="_compute_dynamic_description",
|
||||||
|
string="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',
|
||||||
@@ -323,6 +326,17 @@ class Agreement(models.Model):
|
|||||||
track_visibility='always'
|
track_visibility='always'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# compute the dynamic content for mako expression
|
||||||
|
@api.multi
|
||||||
|
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.dynamic_description = description
|
||||||
|
|
||||||
# compute contract_value field
|
# compute contract_value field
|
||||||
@api.depends('total_customer_mrc', 'total_customer_nrc', 'term')
|
@api.depends('total_customer_mrc', 'total_customer_nrc', 'term')
|
||||||
def _compute_contract_value(self):
|
def _compute_contract_value(self):
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (C) 2018 - TODAY, Pavlov Media
|
# Copyright (C) 2018 - TODAY, Pavlov Media
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class AgreementAppendix(models.Model):
|
class AgreementAppendix(models.Model):
|
||||||
@@ -15,6 +15,9 @@ class AgreementAppendix(models.Model):
|
|||||||
"The name is not.")
|
"The name is not.")
|
||||||
sequence = fields.Integer(string="Sequence", default=10)
|
sequence = fields.Integer(string="Sequence", default=10)
|
||||||
content = fields.Html(string="Content")
|
content = fields.Html(string="Content")
|
||||||
|
dynamic_content = fields.Html(compute="_compute_dynamic_content",
|
||||||
|
string="Dynamic Content",
|
||||||
|
help='compute dynamic Content')
|
||||||
agreement_id = fields.Many2one('agreement', string="Agreement",
|
agreement_id = fields.Many2one('agreement', string="Agreement",
|
||||||
ondelete="cascade")
|
ondelete="cascade")
|
||||||
active = fields.Boolean(
|
active = fields.Boolean(
|
||||||
@@ -22,3 +25,15 @@ class AgreementAppendix(models.Model):
|
|||||||
default=True,
|
default=True,
|
||||||
help="If unchecked, it will allow you to hide this appendix without "
|
help="If unchecked, it will allow you to hide this appendix without "
|
||||||
"removing it.")
|
"removing it.")
|
||||||
|
|
||||||
|
# compute the dynamic content for mako expression
|
||||||
|
@api.multi
|
||||||
|
def _compute_dynamic_content(self):
|
||||||
|
MailTemplates = self.env['mail.template']
|
||||||
|
for appendix in self:
|
||||||
|
lang = appendix.agreement_id and \
|
||||||
|
appendix.agreement_id.partner_id.lang or 'en_US'
|
||||||
|
content = \
|
||||||
|
MailTemplates.with_context(lang=lang).render_template(
|
||||||
|
appendix.content, 'agreement.appendix', appendix.id)
|
||||||
|
appendix.dynamic_content = content
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (C) 2018 - TODAY, Pavlov Media
|
# Copyright (C) 2018 - TODAY, Pavlov Media
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class AgreementClause(models.Model):
|
class AgreementClause(models.Model):
|
||||||
@@ -25,9 +25,24 @@ class AgreementClause(models.Model):
|
|||||||
ondelete="cascade"
|
ondelete="cascade"
|
||||||
)
|
)
|
||||||
content = fields.Html(string="Clause Content")
|
content = fields.Html(string="Clause Content")
|
||||||
|
dynamic_content = fields.Html(compute="_compute_dynamic_content",
|
||||||
|
string="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."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# compute the dynamic content for mako expression
|
||||||
|
@api.multi
|
||||||
|
def _compute_dynamic_content(self):
|
||||||
|
MailTemplates = self.env['mail.template']
|
||||||
|
for clause in self:
|
||||||
|
lang = 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.dynamic_content = content
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (C) 2018 - TODAY, Pavlov Media
|
# Copyright (C) 2018 - TODAY, Pavlov Media
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class AgreementRecital(models.Model):
|
class AgreementRecital(models.Model):
|
||||||
@@ -15,6 +15,9 @@ class AgreementRecital(models.Model):
|
|||||||
"The name is not.")
|
"The name is not.")
|
||||||
sequence = fields.Integer(string="Sequence", default=10)
|
sequence = fields.Integer(string="Sequence", default=10)
|
||||||
content = fields.Html(string="Content")
|
content = fields.Html(string="Content")
|
||||||
|
dynamic_content = fields.Html(compute="_compute_dynamic_content",
|
||||||
|
string="Dynamic Content",
|
||||||
|
help='compute dynamic Content')
|
||||||
agreement_id = fields.Many2one('agreement', string="Agreement",
|
agreement_id = fields.Many2one('agreement', string="Agreement",
|
||||||
ondelete="cascade")
|
ondelete="cascade")
|
||||||
active = fields.Boolean(
|
active = fields.Boolean(
|
||||||
@@ -22,3 +25,15 @@ class AgreementRecital(models.Model):
|
|||||||
default=True,
|
default=True,
|
||||||
help="If unchecked, it will allow you to hide this recital without "
|
help="If unchecked, it will allow you to hide this recital without "
|
||||||
"removing it.")
|
"removing it.")
|
||||||
|
|
||||||
|
# compute the dynamic content for mako expression
|
||||||
|
@api.multi
|
||||||
|
def _compute_dynamic_content(self):
|
||||||
|
MailTemplates = self.env['mail.template']
|
||||||
|
for recital in self:
|
||||||
|
lang = 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.dynamic_content = content
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (C) 2018 - TODAY, Pavlov Media
|
# Copyright (C) 2018 - TODAY, Pavlov Media
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class AgreementSection(models.Model):
|
class AgreementSection(models.Model):
|
||||||
@@ -25,9 +25,24 @@ class AgreementSection(models.Model):
|
|||||||
string="Clauses"
|
string="Clauses"
|
||||||
)
|
)
|
||||||
content = fields.Html(string="Section Content")
|
content = fields.Html(string="Section Content")
|
||||||
|
dynamic_content = fields.Html(compute="_compute_dynamic_content",
|
||||||
|
string="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."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# compute the dynamic content for mako expression
|
||||||
|
@api.multi
|
||||||
|
def _compute_dynamic_content(self):
|
||||||
|
MailTemplates = self.env['mail.template']
|
||||||
|
for section in self:
|
||||||
|
lang = 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.dynamic_content = content
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
|
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
|
||||||
* Wolfgang Hall <whall@opensourceintegrators.com>
|
* Wolfgang Hall <whall@opensourceintegrators.com>
|
||||||
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
|
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
|
||||||
|
* Sandip Mangukiya <smangukiya@opensourceintegrators.com>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<div class="page">
|
<div class="page">
|
||||||
<h1 t-field="doc.name"/>
|
<h1 t-field="doc.name"/>
|
||||||
<div name="description">
|
<div name="description">
|
||||||
<p t-field="doc.description"/>
|
<p t-field="doc.dynamic_description"/>
|
||||||
</div>
|
</div>
|
||||||
<h2>Parties</h2>
|
<h2>Parties</h2>
|
||||||
<h3>Company Information</h3>
|
<h3>Company Information</h3>
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
<t t-if="r.title">
|
<t t-if="r.title">
|
||||||
<h3 t-field="r.title"/>
|
<h3 t-field="r.title"/>
|
||||||
</t>
|
</t>
|
||||||
<p t-field="r.content"/>
|
<p t-field="r.dynamic_content"/>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</td>
|
</td>
|
||||||
@@ -71,13 +71,13 @@
|
|||||||
<t t-if="s.title">
|
<t t-if="s.title">
|
||||||
<h3 t-field="s.title"/>
|
<h3 t-field="s.title"/>
|
||||||
</t>
|
</t>
|
||||||
<p t-field="s.content"/>
|
<p t-field="s.dynamic_content"/>
|
||||||
<ol>
|
<ol>
|
||||||
<li t-foreach="s.clauses_ids" t-as="c">
|
<li t-foreach="s.clauses_ids" t-as="c">
|
||||||
<t t-if="c.title">
|
<t t-if="c.title">
|
||||||
<h4 t-field="c.title"/>
|
<h4 t-field="c.title"/>
|
||||||
</t>
|
</t>
|
||||||
<p t-field="c.content"/>
|
<p t-field="c.dynamic_content"/>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</li>
|
</li>
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
<div class="page">
|
<div class="page">
|
||||||
<h1 t-field="a.title"
|
<h1 t-field="a.title"
|
||||||
style="page-break-before: always;"/>
|
style="page-break-before: always;"/>
|
||||||
<p t-field="a.content"/>
|
<p t-field="a.dynamic_content"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
|
|||||||
@@ -63,6 +63,13 @@
|
|||||||
required="True"
|
required="True"
|
||||||
nolabel="1"/>
|
nolabel="1"/>
|
||||||
</group>
|
</group>
|
||||||
|
<div class="oe_edit_only">
|
||||||
|
<p>
|
||||||
|
For dynamic content use mako expression '${expression}'. For ex:
|
||||||
|
1. object's field name: ${object.field_name} or
|
||||||
|
2. many2one field name: ${object.many2one_field_id.field_name}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
<group name="parties" string="Parties">
|
<group name="parties" string="Parties">
|
||||||
<group name="partner"
|
<group name="partner"
|
||||||
string="Partner">
|
string="Partner">
|
||||||
|
|||||||
@@ -42,6 +42,13 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<field name="content" widget="html"/>
|
<field name="content" widget="html"/>
|
||||||
|
<div class="oe_edit_only">
|
||||||
|
<p>
|
||||||
|
For dynamic content use mako expression '${expression}'. For ex:
|
||||||
|
1. object's field name: ${object.field_name} or
|
||||||
|
2. many2one field name: ${object.many2one_field_id.field_name}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -44,6 +44,13 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<field name="content" widget="html"/>
|
<field name="content" widget="html"/>
|
||||||
|
<div class="oe_edit_only">
|
||||||
|
<p>
|
||||||
|
For dynamic content use mako expression '${expression}'. For ex:
|
||||||
|
1. object's field name: ${object.field_name} or
|
||||||
|
2. many2one field name: ${object.many2one_field_id.field_name}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -42,6 +42,13 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<field name="content" widget="html"/>
|
<field name="content" widget="html"/>
|
||||||
|
<div class="oe_edit_only">
|
||||||
|
<p>
|
||||||
|
For dynamic content use mako expression '${expression}'. For ex:
|
||||||
|
1. object's field name: ${object.field_name} or
|
||||||
|
2. many2one field name: ${object.many2one_field_id.field_name}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -44,6 +44,13 @@
|
|||||||
<notebook>
|
<notebook>
|
||||||
<page string="Content">
|
<page string="Content">
|
||||||
<field name='content' nolabel="1"/>
|
<field name='content' nolabel="1"/>
|
||||||
|
<div class="oe_edit_only">
|
||||||
|
<p>
|
||||||
|
For dynamic content use mako expression '${expression}'. For ex:
|
||||||
|
1. object's field name: ${object.field_name} or
|
||||||
|
2. many2one field name: ${object.many2one_field_id.field_name}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</page>
|
</page>
|
||||||
<page string="Clauses">
|
<page string="Clauses">
|
||||||
<field name="clauses_ids"
|
<field name="clauses_ids"
|
||||||
|
|||||||
@@ -123,6 +123,12 @@
|
|||||||
parent="agreement_configuration"
|
parent="agreement_configuration"
|
||||||
sequence="30"
|
sequence="30"
|
||||||
action="partner_agreement_action_renewaltype"/>
|
action="partner_agreement_action_renewaltype"/>
|
||||||
|
<menuitem
|
||||||
|
name="Increase Types"
|
||||||
|
id="agreement_increamenttypes"
|
||||||
|
parent="agreement_configuration"
|
||||||
|
sequence="31"
|
||||||
|
action="partner_agreement_action_increasetype"/>
|
||||||
<menuitem
|
<menuitem
|
||||||
name="Stages"
|
name="Stages"
|
||||||
id="agreement_stages"
|
id="agreement_stages"
|
||||||
|
|||||||
Reference in New Issue
Block a user