mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
@@ -25,12 +25,22 @@ Base Comments Templates
|
|||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||||
|
|
||||||
Add a new model to define templates of comments to print on
|
Add a new mixin class to define templates of comments to print on documents.
|
||||||
documents.
|
The comment templates can be defined like make templates, so you can use variables from linked models.
|
||||||
|
|
||||||
Two positions are available for the comments:
|
Two positions are available for the comments:
|
||||||
* above document lines
|
|
||||||
* below document lines
|
* above document lines (before_lines)
|
||||||
|
* below document lines (after_lines)
|
||||||
|
|
||||||
|
The template are general, and can be attached to any Model and based on some domain defined in the template.
|
||||||
|
You can define one default template per Model and domain, which can be overwritten for any company and partners.
|
||||||
|
It has a priority field (smaller number = higher priority)
|
||||||
|
|
||||||
|
In existing reports, if you add this line will get the comment template if you created one like
|
||||||
|
|
||||||
|
* <span t-raw="o.get_comment_template('position',company_id=o.company_id, partner_id=o.parnter_id )"/> ( or without any parameter)
|
||||||
|
|
||||||
|
|
||||||
This module is the base module for following modules:
|
This module is the base module for following modules:
|
||||||
|
|
||||||
@@ -44,6 +54,53 @@ This module is the base module for following modules:
|
|||||||
.. contents::
|
.. contents::
|
||||||
:local:
|
:local:
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
=============
|
||||||
|
|
||||||
|
Go to *Settings > Technical > Reporting > Comment Templates* and start designing you comment templates.
|
||||||
|
|
||||||
|
This module is the base module for following modules:
|
||||||
|
|
||||||
|
* sale_comment_template
|
||||||
|
* purchase_comment_template
|
||||||
|
* invoice_comment_template
|
||||||
|
* stock_picking_comment_template
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
#. Go to *Settings* and activate the developer mode.
|
||||||
|
#. Go to *Settings > Technical > Reporting > Comment Templates*.
|
||||||
|
#. Create a new record.
|
||||||
|
#. Define the Company the template is linked or leave default for all companies.
|
||||||
|
#. Define the Partner the template is linked or leave default for all partners.
|
||||||
|
#. Define the Model, Domain the template is linked.
|
||||||
|
#. Define the Position where the template will be printed:
|
||||||
|
|
||||||
|
* above document lines
|
||||||
|
* below document lines
|
||||||
|
|
||||||
|
You should have at least one template with Default field set, if you choose a Partner the template is deselected as a Default one.
|
||||||
|
If you create a new template with the same configuration (Model, Domain, Position) and set it as Default, the previous one will be deselected as a default one.
|
||||||
|
|
||||||
|
The template is a html field which will be rendered just like a mail template, so you can use variables like ${object}, ${user}, ${ctx} to add dynamic content.
|
||||||
|
|
||||||
|
Change the report related to the model from configuration and add a statement like:
|
||||||
|
|
||||||
|
<p t-if="o.get_comment_template('before_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)">
|
||||||
|
|
||||||
|
<span t-raw="o.get_comment_template('before_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)"/>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p t-if="o.get_comment_template('after_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)">
|
||||||
|
|
||||||
|
<span t-raw="o.get_comment_template('after_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)"/>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
You should always use t-if since the method returns False if no template is found.
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
@@ -79,6 +136,15 @@ Contributors
|
|||||||
* Iván Todorovich <ivan.todorovich@druidoo.io>
|
* Iván Todorovich <ivan.todorovich@druidoo.io>
|
||||||
* Pierre Verkest <pierreverkest84@gmail.com>
|
* Pierre Verkest <pierreverkest84@gmail.com>
|
||||||
|
|
||||||
|
* `NextERP Romania <https://www.nexterp.ro>`_:
|
||||||
|
|
||||||
|
* Fekete Mihai <feketemihai@nexterp.ro>
|
||||||
|
|
||||||
|
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||||
|
|
||||||
|
* Carlos Roca
|
||||||
|
* Víctor Martínez
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -3,18 +3,19 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Base Comments Templates",
|
"name": "Base Comments Templates",
|
||||||
"summary": "Comments templates on documents",
|
"summary": "Add conditional mako template to any report"
|
||||||
"version": "14.0.1.0.0",
|
"on models that inherits comment.template.",
|
||||||
"category": "Sale",
|
"version": "14.0.2.0.0",
|
||||||
|
"category": "Reporting",
|
||||||
"website": "https://github.com/OCA/reporting-engine",
|
"website": "https://github.com/OCA/reporting-engine",
|
||||||
"author": "Camptocamp, Odoo Community Association (OCA)",
|
"author": "Camptocamp, Odoo Community Association (OCA)",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"depends": ["base"],
|
"depends": ["base", "mail"],
|
||||||
"data": [
|
"data": [
|
||||||
"security/ir.model.access.csv",
|
"security/ir.model.access.csv",
|
||||||
"security/security.xml",
|
"security/security.xml",
|
||||||
"views/comment_view.xml",
|
"views/base_comment_template_view.xml",
|
||||||
"views/res_partner.xml",
|
"views/res_partner_view.xml",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 14.0\n"
|
"Project-Id-Version: Odoo Server 13.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2021-02-09 09:55+0000\n"
|
||||||
|
"PO-Revision-Date: 2021-02-09 09:55+0000\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
@@ -24,8 +26,8 @@ msgid "After lines"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model,name:base_comment_template.model_base_comment_template
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
||||||
msgid "Base comment template"
|
msgid "Archived"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
@@ -34,21 +36,30 @@ msgid "Before lines"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__text
|
|
||||||
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
||||||
msgid "Comment"
|
msgid "Comment"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_ir_model__is_comment_template
|
||||||
|
msgid "Comment Template"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.actions.act_window,name:base_comment_template.action_base_comment_template
|
#: model:ir.actions.act_window,name:base_comment_template.action_base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_res_partner__base_comment_template_ids
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_res_users__base_comment_template_ids
|
||||||
|
#: model:ir.ui.menu,name:base_comment_template.reports_base_comment_template_menuitem
|
||||||
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
||||||
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_search
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_search
|
||||||
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_tree
|
||||||
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_partner_form
|
||||||
msgid "Comment Templates"
|
msgid "Comment Templates"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__name
|
#: model:ir.model,name:base_comment_template.model_base_comment_template
|
||||||
msgid "Comment summary"
|
msgid "Comments Template"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
@@ -56,12 +67,6 @@ msgstr ""
|
|||||||
msgid "Company"
|
msgid "Company"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_res_partner__property_comment_template_id
|
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_res_users__property_comment_template_id
|
|
||||||
msgid "Conditions template"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model,name:base_comment_template.model_res_partner
|
#: model:ir.model,name:base_comment_template.model_res_partner
|
||||||
msgid "Contact"
|
msgid "Contact"
|
||||||
@@ -79,24 +84,43 @@ msgstr ""
|
|||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__display_name
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__display_name
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_res_partner__display_name
|
#: model:ir.model.fields,field_description:base_comment_template.field_comment_template__display_name
|
||||||
msgid "Display Name"
|
msgid "Display Name"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__domain
|
||||||
|
msgid "Filter Domain"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__id
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__id
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_res_partner__id
|
#: model:ir.model.fields,field_description:base_comment_template.field_comment_template__id
|
||||||
msgid "ID"
|
msgid "ID"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__model_ids
|
||||||
|
msgid "IR Model"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__company_id
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__company_id
|
||||||
msgid "If set, it'll only be available for this company"
|
msgid ""
|
||||||
|
"If set, the comment template will be available only for the selected "
|
||||||
|
"company."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__partner_ids
|
||||||
|
msgid ""
|
||||||
|
"If set, the comment template will be available only for the selected "
|
||||||
|
"partner."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template____last_update
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template____last_update
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_res_partner____last_update
|
#: model:ir.model.fields,field_description:base_comment_template.field_comment_template____last_update
|
||||||
msgid "Last Modified on"
|
msgid "Last Modified on"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -111,16 +135,91 @@ msgid "Last Updated on"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model,name:base_comment_template.model_ir_model
|
||||||
|
msgid "Models"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__name
|
||||||
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
||||||
msgid "Name"
|
msgid "Name"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__name
|
||||||
|
msgid "Name/description of this comment template"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__partner_ids
|
||||||
|
msgid "Partner"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__position
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__position
|
||||||
msgid "Position"
|
msgid "Position on document"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__priority
|
||||||
|
msgid "Priority"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_res_partner__base_comment_template_ids
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_res_users__base_comment_template_ids
|
||||||
|
msgid "Specific partner comments that can be included in reports"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__text
|
||||||
|
msgid "Template"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: code:addons/base_comment_template/models/base_comment_template.py:0
|
||||||
|
#, python-format
|
||||||
|
msgid ""
|
||||||
|
"There are other records with same models, priority, domain and position."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__model_ids
|
||||||
|
msgid ""
|
||||||
|
"This comment template will be available on this models. You can see here "
|
||||||
|
"only models allowed to set the coment template."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__domain
|
||||||
|
msgid ""
|
||||||
|
"This comment template will be available only for objects that satisfy the "
|
||||||
|
"condition"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__position
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__position
|
||||||
msgid "Position on document"
|
msgid "This field allows to select the position of the comment on reports."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__text
|
||||||
|
msgid "This is the text template that will be inserted into reports."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_ir_model__is_comment_template
|
||||||
|
msgid "Whether this model supports in reports to add comment templates."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model,name:base_comment_template.model_comment_template
|
||||||
|
msgid ""
|
||||||
|
"base.comment.template to put header and footer in reports based on created "
|
||||||
|
"comment templates"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__priority
|
||||||
|
msgid "the highest priority = the smallest number"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -8,70 +8,73 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 10.0\n"
|
"Project-Id-Version: Odoo Server 10.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2018-01-05 01:40+0000\n"
|
"POT-Creation-Date: 2021-02-09 09:55+0000\n"
|
||||||
"PO-Revision-Date: 2018-01-05 01:40+0000\n"
|
"PO-Revision-Date: 2021-02-09 11:21+0100\n"
|
||||||
"Last-Translator: enjolras <yo@miguelrevilla.com>, 2018\n"
|
"Last-Translator: Carlos <carlos.roca@tecnativa.com>\n"
|
||||||
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
|
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
|
||||||
"Language: es\n"
|
"Language: es\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: \n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
"X-Generator: Poedit 2.0.6\n"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__active
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__active
|
||||||
msgid "Active"
|
msgid "Active"
|
||||||
msgstr ""
|
msgstr "Activo"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: selection:base.comment.template,position:0
|
#: model:ir.model.fields.selection,name:base_comment_template.selection__base_comment_template__position__after_lines
|
||||||
msgid "After lines"
|
msgid "After lines"
|
||||||
msgstr "Después de las líneas"
|
msgstr "Después de las líneas"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model,name:base_comment_template.model_base_comment_template
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
||||||
msgid "Base comment template"
|
msgid "Archived"
|
||||||
msgstr "Plantilla de comentario base"
|
msgstr "Archivado"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: selection:base.comment.template,position:0
|
#: model:ir.model.fields.selection,name:base_comment_template.selection__base_comment_template__position__before_lines
|
||||||
msgid "Before lines"
|
msgid "Before lines"
|
||||||
msgstr "Antes de las líneas"
|
msgstr "Antes de las líneas"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__text
|
|
||||||
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
||||||
msgid "Comment"
|
msgid "Comment"
|
||||||
msgstr "Comentario"
|
msgstr "Comentario"
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_ir_model__is_comment_template
|
||||||
|
msgid "Comment Template"
|
||||||
|
msgstr "Plantilla de comentario"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.actions.act_window,name:base_comment_template.action_base_comment_template
|
#: model:ir.actions.act_window,name:base_comment_template.action_base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_res_partner__base_comment_template_ids
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_res_users__base_comment_template_ids
|
||||||
|
#: model:ir.ui.menu,name:base_comment_template.reports_base_comment_template_menuitem
|
||||||
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
||||||
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_search
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_search
|
||||||
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_tree
|
||||||
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_partner_form
|
||||||
msgid "Comment Templates"
|
msgid "Comment Templates"
|
||||||
msgstr "Plantillas de comentarios"
|
msgstr "Plantillas de comentarios"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__name
|
#: model:ir.model,name:base_comment_template.model_base_comment_template
|
||||||
msgid "Comment summary"
|
msgid "Comments Template"
|
||||||
msgstr "Índice de comentarios"
|
msgstr "Plantillas de comentarios"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__company_id
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__company_id
|
||||||
msgid "Company"
|
msgid "Company"
|
||||||
msgstr ""
|
msgstr "Compañía"
|
||||||
|
|
||||||
#. module: base_comment_template
|
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_res_partner__property_comment_template_id
|
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_res_users__property_comment_template_id
|
|
||||||
#, fuzzy
|
|
||||||
msgid "Conditions template"
|
|
||||||
msgstr "Plantillas de comentarios"
|
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model,name:base_comment_template.model_res_partner
|
#: model:ir.model,name:base_comment_template.model_res_partner
|
||||||
msgid "Contact"
|
msgid "Contact"
|
||||||
msgstr ""
|
msgstr "Contacto"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__create_uid
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__create_uid
|
||||||
@@ -85,21 +88,45 @@ msgstr "Creado el"
|
|||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__display_name
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__display_name
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_comment_template__display_name
|
||||||
msgid "Display Name"
|
msgid "Display Name"
|
||||||
msgstr "Nombre mostrado"
|
msgstr "Nombre mostrado"
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__domain
|
||||||
|
msgid "Filter Domain"
|
||||||
|
msgstr "Filtro de dominio"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__id
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__id
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_comment_template__id
|
||||||
msgid "ID"
|
msgid "ID"
|
||||||
msgstr "ID"
|
msgstr "ID"
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__model_ids
|
||||||
|
msgid "IR Model"
|
||||||
|
msgstr "Modelo"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__company_id
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__company_id
|
||||||
msgid "If set, it'll only be available for this company"
|
msgid ""
|
||||||
|
"If set, the comment template will be available only for the selected company."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
"Si se define, la plantilla de comentario va a estar disponible para las "
|
||||||
|
"compañías seleccionadas."
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__partner_ids
|
||||||
|
msgid ""
|
||||||
|
"If set, the comment template will be available only for the selected partner."
|
||||||
|
msgstr ""
|
||||||
|
"Si se define, la plantilla de comentario va a estar disponible para los "
|
||||||
|
"contactos seleccionados."
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template____last_update
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template____last_update
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_comment_template____last_update
|
||||||
msgid "Last Modified on"
|
msgid "Last Modified on"
|
||||||
msgstr "Última modificación el"
|
msgstr "Última modificación el"
|
||||||
|
|
||||||
@@ -114,16 +141,112 @@ msgid "Last Updated on"
|
|||||||
msgstr "Última modificación el"
|
msgstr "Última modificación el"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model,name:base_comment_template.model_ir_model
|
||||||
|
msgid "Models"
|
||||||
|
msgstr "Modelos"
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__name
|
||||||
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
#: model_terms:ir.ui.view,arch_db:base_comment_template.view_base_comment_template_form
|
||||||
msgid "Name"
|
msgid "Name"
|
||||||
msgstr ""
|
msgstr "Nombre"
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__name
|
||||||
|
msgid "Name/description of this comment template"
|
||||||
|
msgstr "Nombre de la plantilla de comentario"
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__partner_ids
|
||||||
|
msgid "Partner"
|
||||||
|
msgstr "Contacto"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__position
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__position
|
||||||
msgid "Position"
|
msgid "Position on document"
|
||||||
msgstr "Posició"
|
msgstr "Posición en el documento"
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__priority
|
||||||
|
msgid "Priority"
|
||||||
|
msgstr "Prioridad"
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_res_partner__base_comment_template_ids
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_res_users__base_comment_template_ids
|
||||||
|
msgid "Specific partner comments that can be included in reports"
|
||||||
|
msgstr "Comentarios de contactos que se pueden incluir en informes"
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,field_description:base_comment_template.field_base_comment_template__text
|
||||||
|
msgid "Template"
|
||||||
|
msgstr "Plantilla de comentario"
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: code:addons/base_comment_template/models/base_comment_template.py:0
|
||||||
|
#, python-format
|
||||||
|
msgid ""
|
||||||
|
"There are other records with same models, priority, domain and position."
|
||||||
|
msgstr ""
|
||||||
|
"Hay otros registros con los mismos datos en modelo, prioridad, dominio y "
|
||||||
|
"posición."
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__model_ids
|
||||||
|
msgid ""
|
||||||
|
"This comment template will be available on this models. You can see here "
|
||||||
|
"only models allowed to set the coment template."
|
||||||
|
msgstr ""
|
||||||
|
"Esta plantilla de comentarios estará disponible en estos modelos. Sólo vas a "
|
||||||
|
"ver los modelos autorizados para configurar la plantilla de comentarios."
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__domain
|
||||||
|
msgid ""
|
||||||
|
"This comment template will be available only for objects that satisfy the "
|
||||||
|
"condition"
|
||||||
|
msgstr ""
|
||||||
|
"Esta plantilla de comentarios estará disponible solo para objetos que "
|
||||||
|
"satisfagan la condición"
|
||||||
|
|
||||||
#. module: base_comment_template
|
#. module: base_comment_template
|
||||||
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__position
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__position
|
||||||
msgid "Position on document"
|
msgid "This field allows to select the position of the comment on reports."
|
||||||
msgstr "Posición en el documento"
|
msgstr ""
|
||||||
|
"Este campo permite seleccionar la posición del comentario en los informes."
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__text
|
||||||
|
msgid "This is the text template that will be inserted into reports."
|
||||||
|
msgstr "Esta es la plantilla de texto que se insertará en los informes."
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_ir_model__is_comment_template
|
||||||
|
msgid "Whether this model supports in reports to add comment templates."
|
||||||
|
msgstr ""
|
||||||
|
"Si este modelo admite en los informes, añadir plantillas de comentarios."
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model,name:base_comment_template.model_comment_template
|
||||||
|
msgid ""
|
||||||
|
"base.comment.template to put header and footer in reports based on created "
|
||||||
|
"comment templates"
|
||||||
|
msgstr ""
|
||||||
|
"base.comment.template para poner cabecera y pie de página en los informes "
|
||||||
|
"basados en las plantillas de comentarios creadas"
|
||||||
|
|
||||||
|
#. module: base_comment_template
|
||||||
|
#: model:ir.model.fields,help:base_comment_template.field_base_comment_template__priority
|
||||||
|
msgid "the highest priority = the smallest number"
|
||||||
|
msgstr "Mayor prioridad = número menor"
|
||||||
|
|
||||||
|
#~ msgid "Comment summary"
|
||||||
|
#~ msgstr "Índice de comentarios"
|
||||||
|
|
||||||
|
#, fuzzy
|
||||||
|
#~| msgid "Comment Templates"
|
||||||
|
#~ msgid "Conditions template"
|
||||||
|
#~ msgstr "Plantillas de comentarios"
|
||||||
|
|
||||||
|
#~ msgid "Position"
|
||||||
|
#~ msgstr "Posició"
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||||
|
# Copyright 2021 Tecnativa - Pedro M. Baeza
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
from openupgradelib import openupgrade
|
||||||
|
|
||||||
|
from odoo.tools import parse_version
|
||||||
|
|
||||||
|
|
||||||
|
@openupgrade.migrate()
|
||||||
|
def migrate(env, version):
|
||||||
|
if parse_version(version) == parse_version("14.0.1.0.0"):
|
||||||
|
openupgrade.logged_query(
|
||||||
|
env.cr,
|
||||||
|
"""
|
||||||
|
INSERT INTO base_comment_template_res_partner_rel
|
||||||
|
(res_partner_id, base_comment_template_id)
|
||||||
|
SELECT SPLIT_PART(ip.res_id, ',', 2)::int AS res_partner_id,
|
||||||
|
SPLIT_PART(ip.value_reference, ',', 2)::int AS base_comment_template_id
|
||||||
|
FROM ir_property ip
|
||||||
|
JOIN ir_model_fields imf ON ip.fields_id = imf.id
|
||||||
|
JOIN res_partner rp ON rp.id = SPLIT_PART(ip.res_id, ',', 2)::int
|
||||||
|
JOIN base_comment_template bct
|
||||||
|
ON bct.id = SPLIT_PART(ip.value_reference, ',', 2)::int
|
||||||
|
WHERE imf.name = 'property_comment_template_id'
|
||||||
|
AND imf.model = 'res.partner'
|
||||||
|
AND ip.res_id IS NOT NULL
|
||||||
|
ON CONFLICT DO NOTHING
|
||||||
|
""",
|
||||||
|
)
|
||||||
30
base_comment_template/migrations/14.0.2.0.0/pre-migration.py
Normal file
30
base_comment_template/migrations/14.0.2.0.0/pre-migration.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||||
|
# Copyright 2021 Tecnativa - Pedro M: Baeza
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
from openupgradelib import openupgrade
|
||||||
|
|
||||||
|
from odoo.tools import parse_version
|
||||||
|
|
||||||
|
field_renames = [
|
||||||
|
("base.comment.template", "base_comment_template", "priority", "sequence"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@openupgrade.migrate()
|
||||||
|
def migrate(env, version):
|
||||||
|
if parse_version(version) == parse_version("14.0.1.0.0"):
|
||||||
|
openupgrade.rename_fields(env, field_renames)
|
||||||
|
if openupgrade.table_exists(env.cr, "base_comment_template_res_partner_rel"):
|
||||||
|
# Swap column names, as they were incorrect
|
||||||
|
env.cr.execute(
|
||||||
|
"ALTER TABLE base_comment_template_res_partner_rel "
|
||||||
|
"RENAME base_comment_template_id TO temp"
|
||||||
|
)
|
||||||
|
env.cr.execute(
|
||||||
|
"ALTER TABLE base_comment_template_res_partner_rel "
|
||||||
|
"RENAME res_partner_id TO base_comment_template_id"
|
||||||
|
)
|
||||||
|
env.cr.execute(
|
||||||
|
"ALTER TABLE base_comment_template_res_partner_rel "
|
||||||
|
"RENAME temp TO res_partner_id"
|
||||||
|
)
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
from . import base_comment_template
|
||||||
from . import comment
|
from . import comment_template
|
||||||
from . import res_partner
|
from . import res_partner
|
||||||
|
from . import ir_model
|
||||||
|
|||||||
88
base_comment_template/models/base_comment_template.py
Normal file
88
base_comment_template/models/base_comment_template.py
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
# Copyright 2014 Guewen Baconnier (Camptocamp SA)
|
||||||
|
# Copyright 2013-2014 Nicolas Bessi (Camptocamp SA)
|
||||||
|
# Copyright 2020 NextERP Romania SRL
|
||||||
|
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class BaseCommentTemplate(models.Model):
|
||||||
|
"""Comment templates printed on reports"""
|
||||||
|
|
||||||
|
_name = "base.comment.template"
|
||||||
|
_description = "Comments Template"
|
||||||
|
_order = "sequence,id"
|
||||||
|
|
||||||
|
active = fields.Boolean(default=True)
|
||||||
|
position = fields.Selection(
|
||||||
|
string="Position on document",
|
||||||
|
selection=[("before_lines", "Top"), ("after_lines", "Bottom")],
|
||||||
|
required=True,
|
||||||
|
default="before_lines",
|
||||||
|
help="This field allows to select the position of the comment on reports.",
|
||||||
|
)
|
||||||
|
name = fields.Char(
|
||||||
|
string="Name",
|
||||||
|
translate=True,
|
||||||
|
required=True,
|
||||||
|
help="Name/description of this comment template",
|
||||||
|
)
|
||||||
|
text = fields.Html(
|
||||||
|
string="Template",
|
||||||
|
translate=True,
|
||||||
|
required=True,
|
||||||
|
sanitize=False,
|
||||||
|
help="This is the text template that will be inserted into reports.",
|
||||||
|
)
|
||||||
|
company_id = fields.Many2one(
|
||||||
|
comodel_name="res.company",
|
||||||
|
string="Company",
|
||||||
|
ondelete="cascade",
|
||||||
|
index=True,
|
||||||
|
help="If set, the comment template will be available only for the selected "
|
||||||
|
"company.",
|
||||||
|
)
|
||||||
|
partner_ids = fields.Many2many(
|
||||||
|
comodel_name="res.partner",
|
||||||
|
relation="base_comment_template_res_partner_rel",
|
||||||
|
column1="base_comment_template_id",
|
||||||
|
column2="res_partner_id",
|
||||||
|
string="Partner",
|
||||||
|
readonly=True,
|
||||||
|
help="If set, the comment template will be available only for the selected "
|
||||||
|
"partner.",
|
||||||
|
)
|
||||||
|
model_ids = fields.Many2many(
|
||||||
|
comodel_name="ir.model",
|
||||||
|
string="IR Model",
|
||||||
|
ondelete="cascade",
|
||||||
|
domain=[
|
||||||
|
("is_comment_template", "=", True),
|
||||||
|
("model", "!=", "comment.template"),
|
||||||
|
],
|
||||||
|
required=True,
|
||||||
|
help="This comment template will be available on this models. "
|
||||||
|
"You can see here only models allowed to set the coment template.",
|
||||||
|
)
|
||||||
|
domain = fields.Char(
|
||||||
|
string="Filter Domain",
|
||||||
|
required=True,
|
||||||
|
default="[]",
|
||||||
|
help="This comment template will be available only for objects "
|
||||||
|
"that satisfy the condition",
|
||||||
|
)
|
||||||
|
sequence = fields.Integer(
|
||||||
|
required=True, default=10, help="The smaller number = The higher priority"
|
||||||
|
)
|
||||||
|
|
||||||
|
def name_get(self):
|
||||||
|
"""Redefine the name_get method to show the template name with the position."""
|
||||||
|
res = []
|
||||||
|
for item in self:
|
||||||
|
name = "{} ({})".format(
|
||||||
|
item.name, dict(self._fields["position"].selection).get(item.position)
|
||||||
|
)
|
||||||
|
if self.env.context.get("comment_template_model_display"):
|
||||||
|
name += " (%s)" % ", ".join(item.model_ids.mapped("name"))
|
||||||
|
res.append((item.id, name))
|
||||||
|
return res
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
# Copyright 2014 Guewen Baconnier (Camptocamp SA)
|
|
||||||
# Copyright 2013-2014 Nicolas Bessi (Camptocamp SA)
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
||||||
|
|
||||||
from odoo import fields, models
|
|
||||||
|
|
||||||
|
|
||||||
class BaseCommentTemplate(models.Model):
|
|
||||||
_name = "base.comment.template"
|
|
||||||
_description = "Base comment template"
|
|
||||||
|
|
||||||
active = fields.Boolean(default=True)
|
|
||||||
|
|
||||||
name = fields.Char(
|
|
||||||
string="Comment summary",
|
|
||||||
required=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
position = fields.Selection(
|
|
||||||
selection=[
|
|
||||||
("before_lines", "Before lines"),
|
|
||||||
("after_lines", "After lines"),
|
|
||||||
],
|
|
||||||
required=True,
|
|
||||||
default="before_lines",
|
|
||||||
help="Position on document",
|
|
||||||
)
|
|
||||||
|
|
||||||
text = fields.Html(
|
|
||||||
string="Comment",
|
|
||||||
translate=True,
|
|
||||||
required=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
company_id = fields.Many2one(
|
|
||||||
"res.company",
|
|
||||||
string="Company",
|
|
||||||
help="If set, it'll only be available for this company",
|
|
||||||
ondelete="cascade",
|
|
||||||
index=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_value(self, partner_id=False):
|
|
||||||
self.ensure_one()
|
|
||||||
lang = None
|
|
||||||
if partner_id:
|
|
||||||
lang = self.env["res.partner"].browse(partner_id).lang
|
|
||||||
return self.with_context(lang=lang).text
|
|
||||||
45
base_comment_template/models/comment_template.py
Normal file
45
base_comment_template/models/comment_template.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# Copyright 2014 Guewen Baconnier (Camptocamp SA)
|
||||||
|
# Copyright 2013-2014 Nicolas Bessi (Camptocamp SA)
|
||||||
|
# Copyright 2020 NextERP Romania SRL
|
||||||
|
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
from odoo import api, fields, models
|
||||||
|
from odoo.tools.safe_eval import safe_eval
|
||||||
|
|
||||||
|
|
||||||
|
class CommentTemplate(models.AbstractModel):
|
||||||
|
_name = "comment.template"
|
||||||
|
_description = (
|
||||||
|
"base.comment.template to put header and footer "
|
||||||
|
"in reports based on created comment templates"
|
||||||
|
)
|
||||||
|
# This field allows to set any given field that determines the source partner for
|
||||||
|
# the comment templates downstream.
|
||||||
|
# E.g.: other models where the partner field is called customer_id.
|
||||||
|
_comment_template_partner_field_name = "partner_id"
|
||||||
|
|
||||||
|
comment_template_ids = fields.Many2many(
|
||||||
|
compute="_compute_comment_template_ids",
|
||||||
|
comodel_name="base.comment.template",
|
||||||
|
string="Comment Template",
|
||||||
|
domain=lambda self: [("model_ids.model", "=", self._name)],
|
||||||
|
store=True,
|
||||||
|
readonly=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends(_comment_template_partner_field_name)
|
||||||
|
def _compute_comment_template_ids(self):
|
||||||
|
for record in self:
|
||||||
|
partner = record[self._comment_template_partner_field_name]
|
||||||
|
record.comment_template_ids = [(5,)]
|
||||||
|
templates = self.env["base.comment.template"].search(
|
||||||
|
[
|
||||||
|
("id", "in", partner.base_comment_template_ids.ids),
|
||||||
|
("model_ids.model", "=", self._name),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
for template in templates:
|
||||||
|
if not template.domain or self in self.search(
|
||||||
|
safe_eval(template.domain)
|
||||||
|
):
|
||||||
|
record.comment_template_ids = [(4, template.id)]
|
||||||
33
base_comment_template/models/ir_model.py
Normal file
33
base_comment_template/models/ir_model.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Copyright 2020 NextERP Romania SRL
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class IrModel(models.Model):
|
||||||
|
_inherit = "ir.model"
|
||||||
|
|
||||||
|
is_comment_template = fields.Boolean(
|
||||||
|
string="Comment Template",
|
||||||
|
default=False,
|
||||||
|
help="Whether this model supports in reports to add comment templates.",
|
||||||
|
)
|
||||||
|
|
||||||
|
def _reflect_model_params(self, model):
|
||||||
|
vals = super(IrModel, self)._reflect_model_params(model)
|
||||||
|
vals["is_comment_template"] = issubclass(
|
||||||
|
type(model), self.pool["comment.template"]
|
||||||
|
)
|
||||||
|
return vals
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _instanciate(self, model_data):
|
||||||
|
model_class = super(IrModel, self)._instanciate(model_data)
|
||||||
|
if (
|
||||||
|
model_data.get("is_comment_template")
|
||||||
|
and model_class._name != "comment.template"
|
||||||
|
):
|
||||||
|
parents = model_class._inherit or []
|
||||||
|
parents = [parents] if isinstance(parents, str) else parents
|
||||||
|
model_class._inherit = parents + ["comment.template"]
|
||||||
|
return model_class
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# Copyright 2020 NextERP Romania SRL
|
||||||
|
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
@@ -6,14 +8,16 @@ from odoo import api, fields, models
|
|||||||
class ResPartner(models.Model):
|
class ResPartner(models.Model):
|
||||||
_inherit = "res.partner"
|
_inherit = "res.partner"
|
||||||
|
|
||||||
property_comment_template_id = fields.Many2one(
|
base_comment_template_ids = fields.Many2many(
|
||||||
comodel_name="base.comment.template",
|
comodel_name="base.comment.template",
|
||||||
string="Conditions template",
|
relation="base_comment_template_res_partner_rel",
|
||||||
company_dependent=True,
|
column1="res_partner_id",
|
||||||
|
column2="base_comment_template_id",
|
||||||
|
string="Comment Templates",
|
||||||
|
help="Specific partner comments that can be included in reports",
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _commercial_fields(self):
|
def _commercial_fields(self):
|
||||||
res = super(ResPartner, self)._commercial_fields()
|
"""Add comment templates to commercial fields"""
|
||||||
res += ["property_comment_template_id"]
|
return super()._commercial_fields() + ["base_comment_template_ids"]
|
||||||
return res
|
|
||||||
|
|||||||
8
base_comment_template/readme/CONFIGURE.rst
Normal file
8
base_comment_template/readme/CONFIGURE.rst
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
Go to *Settings > Technical > Reporting > Comment Templates* and start designing you comment templates.
|
||||||
|
|
||||||
|
This module is the base module for following modules:
|
||||||
|
|
||||||
|
* sale_comment_template
|
||||||
|
* purchase_comment_template
|
||||||
|
* invoice_comment_template
|
||||||
|
* stock_picking_comment_template
|
||||||
@@ -11,3 +11,12 @@
|
|||||||
|
|
||||||
* Iván Todorovich <ivan.todorovich@druidoo.io>
|
* Iván Todorovich <ivan.todorovich@druidoo.io>
|
||||||
* Pierre Verkest <pierreverkest84@gmail.com>
|
* Pierre Verkest <pierreverkest84@gmail.com>
|
||||||
|
|
||||||
|
* `NextERP Romania <https://www.nexterp.ro>`_:
|
||||||
|
|
||||||
|
* Fekete Mihai <feketemihai@nexterp.ro>
|
||||||
|
|
||||||
|
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||||
|
|
||||||
|
* Carlos Roca
|
||||||
|
* Víctor Martínez
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
Add a new model to define templates of comments to print on
|
Add a new mixin class to define templates of comments to print on documents.
|
||||||
documents.
|
The comment templates can be defined like make templates, so you can use variables from linked models.
|
||||||
|
|
||||||
Two positions are available for the comments:
|
Two positions are available for the comments:
|
||||||
* above document lines
|
|
||||||
* below document lines
|
* above document lines (before_lines)
|
||||||
|
* below document lines (after_lines)
|
||||||
|
|
||||||
|
The template are general, and can be attached to any Model and based on some domain defined in the template.
|
||||||
|
You can define one default template per Model and domain, which can be overwritten for any company and partners.
|
||||||
|
It has a priority field (smaller number = higher priority)
|
||||||
|
|
||||||
|
In existing reports, if you add this line will get the comment template if you created one like
|
||||||
|
|
||||||
|
* <span t-raw="o.get_comment_template('position',company_id=o.company_id, partner_id=o.parnter_id )"/> ( or without any parameter)
|
||||||
|
|
||||||
|
|
||||||
This module is the base module for following modules:
|
This module is the base module for following modules:
|
||||||
|
|
||||||
|
|||||||
31
base_comment_template/readme/USAGE.rst
Normal file
31
base_comment_template/readme/USAGE.rst
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#. Go to *Settings* and activate the developer mode.
|
||||||
|
#. Go to *Settings > Technical > Reporting > Comment Templates*.
|
||||||
|
#. Create a new record.
|
||||||
|
#. Define the Company the template is linked or leave default for all companies.
|
||||||
|
#. Define the Partner the template is linked or leave default for all partners.
|
||||||
|
#. Define the Model, Domain the template is linked.
|
||||||
|
#. Define the Position where the template will be printed:
|
||||||
|
|
||||||
|
* above document lines
|
||||||
|
* below document lines
|
||||||
|
|
||||||
|
You should have at least one template with Default field set, if you choose a Partner the template is deselected as a Default one.
|
||||||
|
If you create a new template with the same configuration (Model, Domain, Position) and set it as Default, the previous one will be deselected as a default one.
|
||||||
|
|
||||||
|
The template is a html field which will be rendered just like a mail template, so you can use variables like ${object}, ${user}, ${ctx} to add dynamic content.
|
||||||
|
|
||||||
|
Change the report related to the model from configuration and add a statement like:
|
||||||
|
|
||||||
|
<p t-if="o.get_comment_template('before_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)">
|
||||||
|
|
||||||
|
<span t-raw="o.get_comment_template('before_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)"/>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p t-if="o.get_comment_template('after_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)">
|
||||||
|
|
||||||
|
<span t-raw="o.get_comment_template('after_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)"/>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
You should always use t-if since the method returns False if no template is found.
|
||||||
@@ -1,2 +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_base_comment_template_user,access_base_comment_template_user,model_base_comment_template,,1,0,0,0
|
||||||
access_base_comment_template,access_base_comment_template no one,model_base_comment_template,base.group_no_one,1,1,1,1
|
access_base_comment_template,access_base_comment_template no one,model_base_comment_template,base.group_no_one,1,1,1,1
|
||||||
|
|||||||
|
@@ -5,9 +5,8 @@
|
|||||||
<field name="name">Base comment multi-company</field>
|
<field name="name">Base comment multi-company</field>
|
||||||
<field name="model_id" ref="model_base_comment_template" />
|
<field name="model_id" ref="model_base_comment_template" />
|
||||||
<field name="global" eval="True" />
|
<field name="global" eval="True" />
|
||||||
<field
|
<field name="domain_force">
|
||||||
name="domain_force"
|
['|',('company_id','=',False),('company_id','in',company_ids)]</field>
|
||||||
>['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
|
||||||
<title>Base Comments Templates</title>
|
<title>Base Comments Templates</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
@@ -368,11 +368,20 @@ ul.auto-toc {
|
|||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/14.0/base_comment_template"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/reporting-engine-14-0/reporting-engine-14-0-base_comment_template"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/143/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/14.0/base_comment_template"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/reporting-engine-14-0/reporting-engine-14-0-base_comment_template"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/143/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||||
<p>Add a new model to define templates of comments to print on
|
<p>Add a new mixin class to define templates of comments to print on documents.
|
||||||
documents.</p>
|
The comment templates can be defined like make templates, so you can use variables from linked models.</p>
|
||||||
<p>Two positions are available for the comments:
|
<p>Two positions are available for the comments:</p>
|
||||||
* above document lines
|
<ul class="simple">
|
||||||
* below document lines</p>
|
<li>above document lines (before_lines)</li>
|
||||||
|
<li>below document lines (after_lines)</li>
|
||||||
|
</ul>
|
||||||
|
<p>The template are general, and can be attached to any Model and based on some domain defined in the template.
|
||||||
|
You can define one default template per Model and domain, which can be overwritten for any company and partners.
|
||||||
|
It has a priority field (smaller number = higher priority)</p>
|
||||||
|
<p>In existing reports, if you add this line will get the comment template if you created one like</p>
|
||||||
|
<ul class="simple">
|
||||||
|
<li><span t-raw=”o.get_comment_template(‘position’,company_id=o.company_id, partner_id=o.parnter_id )”/> ( or without any parameter)</li>
|
||||||
|
</ul>
|
||||||
<p>This module is the base module for following modules:</p>
|
<p>This module is the base module for following modules:</p>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>sale_comment_template</li>
|
<li>sale_comment_template</li>
|
||||||
@@ -383,17 +392,59 @@ documents.</p>
|
|||||||
<p><strong>Table of contents</strong></p>
|
<p><strong>Table of contents</strong></p>
|
||||||
<div class="contents local topic" id="contents">
|
<div class="contents local topic" id="contents">
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
|
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
|
||||||
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
|
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
|
||||||
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
|
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
|
||||||
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
|
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
|
||||||
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
|
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
|
||||||
|
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
|
||||||
|
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="section" id="configuration">
|
||||||
|
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
|
||||||
|
<p>Go to <em>Settings > Technical > Reporting > Comment Templates</em> and start designing you comment templates.</p>
|
||||||
|
<p>This module is the base module for following modules:</p>
|
||||||
|
<ul class="simple">
|
||||||
|
<li>sale_comment_template</li>
|
||||||
|
<li>purchase_comment_template</li>
|
||||||
|
<li>invoice_comment_template</li>
|
||||||
|
<li>stock_picking_comment_template</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="usage">
|
||||||
|
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
|
||||||
|
<ol class="arabic simple">
|
||||||
|
<li>Go to <em>Settings</em> and activate the developer mode.</li>
|
||||||
|
<li>Go to <em>Settings > Technical > Reporting > Comment Templates</em>.</li>
|
||||||
|
<li>Create a new record.</li>
|
||||||
|
<li>Define the Company the template is linked or leave default for all companies.</li>
|
||||||
|
<li>Define the Partner the template is linked or leave default for all partners.</li>
|
||||||
|
<li>Define the Model, Domain the template is linked.</li>
|
||||||
|
<li>Define the Position where the template will be printed:<ul>
|
||||||
|
<li>above document lines</li>
|
||||||
|
<li>below document lines</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<p>You should have at least one template with Default field set, if you choose a Partner the template is deselected as a Default one.
|
||||||
|
If you create a new template with the same configuration (Model, Domain, Position) and set it as Default, the previous one will be deselected as a default one.</p>
|
||||||
|
<p>The template is a html field which will be rendered just like a mail template, so you can use variables like ${object}, ${user}, ${ctx} to add dynamic content.</p>
|
||||||
|
<p>Change the report related to the model from configuration and add a statement like:</p>
|
||||||
|
<p><p t-if=”o.get_comment_template(‘before_lines’, o.company_id.id, o.partner_id and o.partner_id.id or False)”></p>
|
||||||
|
<blockquote>
|
||||||
|
<span t-raw=”o.get_comment_template(‘before_lines’, o.company_id.id, o.partner_id and o.partner_id.id or False)”/></blockquote>
|
||||||
|
<p></p></p>
|
||||||
|
<p><p t-if=”o.get_comment_template(‘after_lines’, o.company_id.id, o.partner_id and o.partner_id.id or False)”></p>
|
||||||
|
<blockquote>
|
||||||
|
<span t-raw=”o.get_comment_template(‘after_lines’, o.company_id.id, o.partner_id and o.partner_id.id or False)”/></blockquote>
|
||||||
|
<p></p></p>
|
||||||
|
<p>You should always use t-if since the method returns False if no template is found.</p>
|
||||||
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
@@ -401,15 +452,15 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
<h1><a class="toc-backref" href="#id2">Credits</a></h1>
|
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
|
||||||
<div class="section" id="authors">
|
<div class="section" id="authors">
|
||||||
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
|
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Camptocamp</li>
|
<li>Camptocamp</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="contributors">
|
<div class="section" id="contributors">
|
||||||
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
|
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Xavier Jimenez <<a class="reference external" href="mailto:xavier.jimenez@qubiq.es">xavier.jimenez@qubiq.es</a>></li>
|
<li>Xavier Jimenez <<a class="reference external" href="mailto:xavier.jimenez@qubiq.es">xavier.jimenez@qubiq.es</a>></li>
|
||||||
<li>Nicolas Bessi <<a class="reference external" href="mailto:nicolas.bessi@camptocamp.com">nicolas.bessi@camptocamp.com</a>></li>
|
<li>Nicolas Bessi <<a class="reference external" href="mailto:nicolas.bessi@camptocamp.com">nicolas.bessi@camptocamp.com</a>></li>
|
||||||
@@ -425,10 +476,19 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>Pierre Verkest <<a class="reference external" href="mailto:pierreverkest84@gmail.com">pierreverkest84@gmail.com</a>></li>
|
<li>Pierre Verkest <<a class="reference external" href="mailto:pierreverkest84@gmail.com">pierreverkest84@gmail.com</a>></li>
|
||||||
|
<li><a class="reference external" href="https://www.nexterp.ro">NextERP Romania</a>:<ul>
|
||||||
|
<li>Fekete Mihai <<a class="reference external" href="mailto:feketemihai@nexterp.ro">feketemihai@nexterp.ro</a>></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
|
||||||
|
<li>Carlos Roca</li>
|
||||||
|
<li>Víctor Martínez</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
|
||||||
<p>This module is maintained by the OCA.</p>
|
<p>This module is maintained by the OCA.</p>
|
||||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
|
|||||||
34
base_comment_template/tests/fake_models.py
Normal file
34
base_comment_template/tests/fake_models.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Copyright 2017 LasLabs Inc.
|
||||||
|
# Copyright 2018 ACSONE
|
||||||
|
# Copyright 2018 Camptocamp
|
||||||
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
|
||||||
|
|
||||||
|
from odoo import models
|
||||||
|
|
||||||
|
|
||||||
|
def setup_test_model(env, model_cls):
|
||||||
|
"""Pass a test model class and initialize it.
|
||||||
|
|
||||||
|
Courtesy of SBidoul from https://github.com/OCA/mis-builder :)
|
||||||
|
"""
|
||||||
|
model_cls._build_model(env.registry, env.cr)
|
||||||
|
env.registry.setup_models(env.cr)
|
||||||
|
env.registry.init_models(
|
||||||
|
env.cr, [model_cls._name], dict(env.context, update_custom_fields=True)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def teardown_test_model(env, model_cls):
|
||||||
|
"""Pass a test model class and deinitialize it.
|
||||||
|
|
||||||
|
Courtesy of SBidoul from https://github.com/OCA/mis-builder :)
|
||||||
|
"""
|
||||||
|
if not getattr(model_cls, "_teardown_no_delete", False):
|
||||||
|
del env.registry.models[model_cls._name]
|
||||||
|
env.registry.setup_models(env.cr)
|
||||||
|
|
||||||
|
|
||||||
|
class ResUsers(models.Model):
|
||||||
|
_name = "res.users"
|
||||||
|
_inherit = ["res.users", "comment.template"]
|
||||||
|
_teardown_no_delete = True
|
||||||
@@ -1,37 +1,89 @@
|
|||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# Copyright 2020 NextERP Romania SRL
|
||||||
from odoo.tests.common import TransactionCase
|
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
from odoo.tests import common
|
||||||
|
|
||||||
|
from .fake_models import ResUsers, setup_test_model, teardown_test_model
|
||||||
|
|
||||||
|
|
||||||
class TestResPartner(TransactionCase):
|
class TestCommentTemplate(common.SavepointCase):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
super(TestResPartner, self).setUp()
|
def setUpClass(cls):
|
||||||
self.template_id = self.env["base.comment.template"].create(
|
super().setUpClass()
|
||||||
|
setup_test_model(cls.env, ResUsers)
|
||||||
|
cls.user_obj = cls.env.ref("base.model_res_users")
|
||||||
|
cls.user = cls.env.ref("base.user_demo")
|
||||||
|
cls.user2 = cls.env.ref("base.demo_user0")
|
||||||
|
cls.partner_id = cls.env.ref("base.res_partner_12")
|
||||||
|
cls.partner2_id = cls.env.ref("base.res_partner_10")
|
||||||
|
cls.main_company = cls.env.ref("base.main_company")
|
||||||
|
cls.company = cls.env["res.company"].create({"name": "Test company"})
|
||||||
|
cls.before_template_id = cls.env["base.comment.template"].create(
|
||||||
{
|
{
|
||||||
"name": "Comment before lines",
|
"name": "Top template",
|
||||||
"position": "before_lines",
|
"text": "Text before lines",
|
||||||
"text": "<p>Text before lines</p>",
|
"model_ids": [(6, 0, cls.user_obj.ids)],
|
||||||
|
"company_id": cls.company.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
cls.after_template_id = cls.env["base.comment.template"].create(
|
||||||
|
{
|
||||||
|
"name": "Bottom template",
|
||||||
|
"position": "after_lines",
|
||||||
|
"text": "Text after lines",
|
||||||
|
"model_ids": [(6, 0, cls.user_obj.ids)],
|
||||||
|
"company_id": cls.company.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
cls.user.partner_id.base_comment_template_ids = [
|
||||||
|
(4, cls.before_template_id.id),
|
||||||
|
(4, cls.after_template_id.id),
|
||||||
|
]
|
||||||
|
|
||||||
def test_commercial_partner_fields(self):
|
@classmethod
|
||||||
# Azure Interior
|
def tearDownClass(cls):
|
||||||
partner_id = self.env.ref("base.res_partner_12")
|
teardown_test_model(cls.env, ResUsers)
|
||||||
partner_id.property_comment_template_id = self.template_id.id
|
super(TestCommentTemplate, cls).tearDownClass()
|
||||||
# Test childs propagation of commercial partner field
|
|
||||||
for child_id in partner_id.child_ids:
|
|
||||||
self.assertEqual(child_id.property_comment_template_id, self.template_id)
|
|
||||||
|
|
||||||
def test_get_value_without_partner(self):
|
def test_template_name_get(self):
|
||||||
self.assertEqual(self.template_id.get_value(), "<p>Text before lines</p>")
|
self.assertEqual(
|
||||||
|
self.before_template_id.display_name,
|
||||||
def test_get_value_with_partner(self):
|
"Top template (Top)",
|
||||||
self.env["res.lang"]._activate_lang("fr_BE")
|
|
||||||
partner = self.env.ref("base.res_partner_12")
|
|
||||||
partner.write({"lang": "fr_BE"})
|
|
||||||
self.template_id.with_context(lang="fr_BE").write(
|
|
||||||
{"text": "<p>Testing translated fr_BE</p>"}
|
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.template_id.get_value(partner_id=partner.id),
|
self.after_template_id.display_name,
|
||||||
"<p>Testing translated fr_BE</p>",
|
"Bottom template (Bottom)",
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_general_template(self):
|
||||||
|
# Need to force _compute because only trigger when partner_id have changed
|
||||||
|
self.user._compute_comment_template_ids()
|
||||||
|
# Check getting default comment template
|
||||||
|
self.assertTrue(self.before_template_id in self.user.comment_template_ids)
|
||||||
|
self.assertTrue(self.after_template_id in self.user.comment_template_ids)
|
||||||
|
|
||||||
|
def test_partner_template(self):
|
||||||
|
self.partner2_id.base_comment_template_ids = [
|
||||||
|
(4, self.before_template_id.id),
|
||||||
|
(4, self.after_template_id.id),
|
||||||
|
]
|
||||||
|
self.assertTrue(
|
||||||
|
self.before_template_id in self.partner2_id.base_comment_template_ids
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
self.after_template_id in self.partner2_id.base_comment_template_ids
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_partner_template_domain(self):
|
||||||
|
# Check getting the comment template if domain is set
|
||||||
|
self.partner2_id.base_comment_template_ids = [
|
||||||
|
(4, self.before_template_id.id),
|
||||||
|
(4, self.after_template_id.id),
|
||||||
|
]
|
||||||
|
self.before_template_id.domain = "[('id', 'in', %s)]" % self.user.ids
|
||||||
|
self.assertTrue(
|
||||||
|
self.before_template_id in self.partner2_id.base_comment_template_ids
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
self.before_template_id not in self.partner_id.base_comment_template_ids
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
<record model="ir.ui.view" id="view_base_comment_template_tree">
|
||||||
|
<field name="name">base.comment.template.search</field>
|
||||||
|
<field name="model">base.comment.template</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="Comment Templates">
|
||||||
|
<field name="sequence" widget="handle" />
|
||||||
|
<field name="name" />
|
||||||
|
<field name="position" />
|
||||||
|
<field name="company_id" groups="base.group_multi_company" />
|
||||||
|
<field name="partner_ids" />
|
||||||
|
<field name="model_ids" />
|
||||||
|
<field name="domain" />
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
<record model="ir.ui.view" id="view_base_comment_template_search">
|
<record model="ir.ui.view" id="view_base_comment_template_search">
|
||||||
<field name="name">base.comment.template.search</field>
|
<field name="name">base.comment.template.search</field>
|
||||||
<field name="model">base.comment.template</field>
|
<field name="model">base.comment.template</field>
|
||||||
@@ -9,6 +23,10 @@
|
|||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="position" />
|
<field name="position" />
|
||||||
<field name="company_id" groups="base.group_multi_company" />
|
<field name="company_id" groups="base.group_multi_company" />
|
||||||
|
<field name="partner_ids" />
|
||||||
|
<field name="model_ids" />
|
||||||
|
<field name="domain" />
|
||||||
|
<field name="sequence" />
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -20,18 +38,12 @@
|
|||||||
<form string="Comment Templates">
|
<form string="Comment Templates">
|
||||||
<sheet>
|
<sheet>
|
||||||
<div class="oe_button_box" name="button_box">
|
<div class="oe_button_box" name="button_box">
|
||||||
<button
|
<widget
|
||||||
name="toggle_active"
|
name="web_ribbon"
|
||||||
type="object"
|
title="Archived"
|
||||||
class="oe_stat_button"
|
bg_color="bg-danger"
|
||||||
icon="fa-archive"
|
attrs="{'invisible': [('active', '=', True)]}"
|
||||||
>
|
/>
|
||||||
<field
|
|
||||||
name="active"
|
|
||||||
widget="boolean_button"
|
|
||||||
options="{"terminology": "archive"}"
|
|
||||||
/>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="oe_title">
|
<div class="oe_title">
|
||||||
<h1>
|
<h1>
|
||||||
@@ -40,17 +52,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field
|
<field name="active" invisible="1" />
|
||||||
name="position"
|
<field name="position" />
|
||||||
widget="radio"
|
|
||||||
invisible="context.get('default_position')"
|
|
||||||
/>
|
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<field
|
<field
|
||||||
name="company_id"
|
name="company_id"
|
||||||
groups="base.group_multi_company"
|
groups="base.group_multi_company"
|
||||||
/>
|
/>
|
||||||
|
<field name="domain" />
|
||||||
|
<field name="model_ids" widget="many2many_tags" />
|
||||||
|
<field name="partner_ids" widget="many2many_tags" />
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
@@ -62,20 +72,6 @@
|
|||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="view_base_comment_template_tree">
|
|
||||||
<field name="name">account.comment.template.list</field>
|
|
||||||
<field name="model">base.comment.template</field>
|
|
||||||
<field name="priority" eval="6" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<tree>
|
|
||||||
<field name="name" />
|
|
||||||
<field name="position" />
|
|
||||||
<field name="company_id" groups="base.group_multi_company" />
|
|
||||||
</tree>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record model="ir.actions.act_window" id="action_base_comment_template">
|
<record model="ir.actions.act_window" id="action_base_comment_template">
|
||||||
<field name="name">Comment Templates</field>
|
<field name="name">Comment Templates</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
@@ -83,5 +79,13 @@
|
|||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" ref="view_base_comment_template_tree" />
|
<field name="view_id" ref="view_base_comment_template_tree" />
|
||||||
</record>
|
</record>
|
||||||
|
<!-- menu in settings/technical/reporting -->
|
||||||
|
<menuitem
|
||||||
|
id="reports_base_comment_template_menuitem"
|
||||||
|
name="Comment Templates"
|
||||||
|
parent="base.reporting_menuitem"
|
||||||
|
action="action_base_comment_template"
|
||||||
|
sequence="4"
|
||||||
|
groups="base.group_no_one"
|
||||||
|
/>
|
||||||
</odoo>
|
</odoo>
|
||||||
28
base_comment_template/views/res_partner_view.xml
Normal file
28
base_comment_template/views/res_partner_view.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<odoo>
|
||||||
|
<record id="view_partner_form" model="ir.ui.view">
|
||||||
|
<field name="model">res.partner</field>
|
||||||
|
<field name="inherit_id" ref="base.view_partner_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<page name='internal_notes' position="after">
|
||||||
|
<page name='base_comment_template_ids' string="Comment Templates">
|
||||||
|
<field
|
||||||
|
name="base_comment_template_ids"
|
||||||
|
nolabel="1"
|
||||||
|
context="{'comment_template_model_display': True}"
|
||||||
|
>
|
||||||
|
<tree>
|
||||||
|
<field name="display_name" string="Name" />
|
||||||
|
<field name="position" />
|
||||||
|
<field
|
||||||
|
name="company_id"
|
||||||
|
groups="base.group_multi_company"
|
||||||
|
/>
|
||||||
|
<field name="model_ids" />
|
||||||
|
<field name="domain" />
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</page>
|
||||||
|
</page>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user