From 9bf56092b60493da26907969521e4ca57a5b71eb Mon Sep 17 00:00:00 2001 From: Yves Goldberg Date: Fri, 12 Apr 2019 00:19:23 +0200 Subject: [PATCH] [ADD] custom dynamic parties --- agreement_legal/models/agreement.py | 26 +++++++++++++++++++ agreement_legal/report/agreement.xml | 39 ++++++++++++++++------------ agreement_legal/views/agreement.xml | 13 +++++++++- 3 files changed, 61 insertions(+), 17 deletions(-) diff --git a/agreement_legal/models/agreement.py b/agreement_legal/models/agreement.py index 32147ddb..668708a0 100644 --- a/agreement_legal/models/agreement.py +++ b/agreement_legal/models/agreement.py @@ -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"] diff --git a/agreement_legal/report/agreement.xml b/agreement_legal/report/agreement.xml index f497e7a2..546fa212 100644 --- a/agreement_legal/report/agreement.xml +++ b/agreement_legal/report/agreement.xml @@ -25,25 +25,32 @@

-

+

Parties

-

Company Information

-
-
-
-
- Represented by . -
-

Partner Information

-
-
-
-
- Represented by . +
+ +

+

+ +

Company Information

+
+
+
+
+ Represented by . +
+

Partner Information

+
+
+
+
+ Represented by . +
+

Agreement

Recitals

diff --git a/agreement_legal/views/agreement.xml b/agreement_legal/views/agreement.xml index e9d56129..29a4b5d5 100644 --- a/agreement_legal/views/agreement.xml +++ b/agreement_legal/views/agreement.xml @@ -90,7 +90,15 @@

- + + + +

+ This section (on the left) allows you to replace the default listing of the parties with custom dynamic content. +

+
+
+ + +