Skip to content

Commit 341ac19

Browse files
committed
Merge PR #3605 into 16.0
Signed-off-by rousseldenis
2 parents ef6db1e + d8b3f04 commit 341ac19

File tree

20 files changed

+897
-0
lines changed

20 files changed

+897
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
==========================================
2+
Sale Orders Terms and conditions Templates
3+
==========================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:2a1bd6a57e66c4ae980cba82e6dc493578eef827402412687cda4e47ea5d4e7a
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
20+
:target: https://github.com/OCA/sale-workflow/tree/16.0/sale_order_note_template
21+
:alt: OCA/sale-workflow
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_note_template
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module add sale terms and conditions templates and change existing terms
32+
and conditions (`sale_order.note`) field type from `Text` to `Html`.
33+
34+
Users will be able to select *terms and conditions template* to fulfill *terms and
35+
conditions* likes in mail composer users can configure their template using
36+
`jinja2`.
37+
38+
39+
How this module differ from `sale_comment_template`_?
40+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41+
42+
* `base_comment_template`_ is for managing comments not terms, it would probably
43+
see as mess for users to mixed terms and comments.
44+
45+
* `sale_comment_template`_ depends on `account_comment_template`_ comments are
46+
forwards to generated invoices, here we don't really display sales terms on
47+
final invoices
48+
49+
* `base_comment_template`_ at the time writing do not support template engine
50+
51+
52+
.. _base_comment_template: https://github.com/OCA/reporting-engine/tree/14.0/base_comment_template
53+
.. _sale_comment_template: https://github.com/OCA/sale-reporting/tree/14.0/sale_comment_template
54+
.. _account_comment_template: https://github.com/OCA/account-invoice-reporting/tree/14.0/account_comment_template
55+
56+
**Table of contents**
57+
58+
.. contents::
59+
:local:
60+
61+
Known issues / Roadmap
62+
======================
63+
64+
* add a post_init_hook and / or a uninstall_hook to handle correctly the conversion (Text <--> Html).
65+
* support qweb report templating engine
66+
67+
Bug Tracker
68+
===========
69+
70+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
71+
In case of trouble, please check there if your issue has already been reported.
72+
If you spotted it first, help us to smash it by providing a detailed and welcomed
73+
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_note_template%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
74+
75+
Do not contact contributors directly about support or help with technical issues.
76+
77+
Credits
78+
=======
79+
80+
Authors
81+
~~~~~~~
82+
83+
* Pierre Verkest
84+
85+
Maintainers
86+
~~~~~~~~~~~
87+
88+
This module is maintained by the OCA.
89+
90+
.. image:: https://odoo-community.org/logo.png
91+
:alt: Odoo Community Association
92+
:target: https://odoo-community.org
93+
94+
OCA, or the Odoo Community Association, is a nonprofit organization whose
95+
mission is to support the collaborative development of Odoo features and
96+
promote its widespread use.
97+
98+
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/16.0/sale_order_note_template>`_ project on GitHub.
99+
100+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# © 2020 Pierre Verkest <pierreverkest84@gmail.com>)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Sale Orders Terms and conditions Templates",
6+
"summary": "Add sale orders terms and conditions template that can be "
7+
"used to quickly fullfill sale order terms and conditions",
8+
"category": "Sales/Sales",
9+
"version": "16.0.1.0.0",
10+
"author": "Pierre Verkest,Odoo Community Association (OCA)",
11+
"website": "https://github.com/OCA/sale-workflow",
12+
"license": "AGPL-3",
13+
"depends": ["sale_management"],
14+
"data": [
15+
"security/ir.model.access.csv",
16+
"views/sale_views.xml",
17+
"views/sale_terms_template.xml",
18+
],
19+
"installable": True,
20+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * sale_order_note_template
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 14.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: \n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: sale_order_note_template
17+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__active
18+
msgid "Active"
19+
msgstr ""
20+
21+
#. module: sale_order_note_template
22+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__create_uid
23+
msgid "Created by"
24+
msgstr ""
25+
26+
#. module: sale_order_note_template
27+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__create_date
28+
msgid "Created on"
29+
msgstr ""
30+
31+
#. module: sale_order_note_template
32+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_order__display_name
33+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__display_name
34+
msgid "Display Name"
35+
msgstr ""
36+
37+
#. module: sale_order_note_template
38+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_order__id
39+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__id
40+
msgid "ID"
41+
msgstr ""
42+
43+
#. module: sale_order_note_template
44+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_order____last_update
45+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template____last_update
46+
msgid "Last Modified on"
47+
msgstr ""
48+
49+
#. module: sale_order_note_template
50+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__write_uid
51+
msgid "Last Updated by"
52+
msgstr ""
53+
54+
#. module: sale_order_note_template
55+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__write_date
56+
msgid "Last Updated on"
57+
msgstr ""
58+
59+
#. module: sale_order_note_template
60+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__name
61+
#: model_terms:ir.ui.view,arch_db:sale_order_note_template.view_sale_terms_template_form
62+
msgid "Name"
63+
msgstr ""
64+
65+
#. module: sale_order_note_template
66+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_order__note
67+
msgid "Note"
68+
msgstr ""
69+
70+
#. module: sale_order_note_template
71+
#: model:ir.model,name:sale_order_note_template.model_sale_terms_template
72+
msgid "Sale terms template"
73+
msgstr ""
74+
75+
#. module: sale_order_note_template
76+
#: model:ir.model,name:sale_order_note_template.model_sale_order
77+
msgid "Sales Order"
78+
msgstr ""
79+
80+
#. module: sale_order_note_template
81+
#: model_terms:ir.ui.view,arch_db:sale_order_note_template.view_sale_terms_template_form
82+
#: model_terms:ir.ui.view,arch_db:sale_order_note_template.view_sale_terms_template_search
83+
msgid "Terms and conditions Templates"
84+
msgstr ""
85+
86+
#. module: sale_order_note_template
87+
#: model:ir.actions.act_window,name:sale_order_note_template.action_sale_terms_template
88+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_order__terms_template_id
89+
#: model_terms:ir.ui.view,arch_db:sale_order_note_template.view_order_form_terms_template
90+
msgid "Terms and conditions template"
91+
msgstr ""
92+
93+
#. module: sale_order_note_template
94+
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__text
95+
msgid "Terms template"
96+
msgstr ""
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import sale_terms_template
2+
from . import sale_order
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2021 Pierre Verkest <pierreverkest84@gmail.com>
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class SaleOrder(models.Model):
8+
9+
_inherit = "sale.order"
10+
11+
terms_template_id = fields.Many2one(
12+
"sale.terms_template",
13+
string="Terms and conditions template",
14+
readonly=True,
15+
states={"draft": [("readonly", False)]},
16+
)
17+
note = fields.Html(readonly=True, states={"draft": [("readonly", False)]})
18+
19+
@api.onchange("terms_template_id")
20+
def _onchange_terms_template_id(self):
21+
if self.terms_template_id:
22+
self.note = self.terms_template_id.get_value(self)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2014 Guewen Baconnier (Camptocamp SA)
2+
# Copyright 2013-2014 Nicolas Bessi (Camptocamp SA)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
from odoo import fields, models
6+
7+
8+
class SaleTermsTemplate(models.Model):
9+
_name = "sale.terms_template"
10+
_description = "Sale terms template"
11+
12+
active = fields.Boolean(default=True)
13+
14+
name = fields.Char(required=True)
15+
16+
text = fields.Html(string="Terms template", translate=True)
17+
18+
def get_value(self, sale_order, add_context=None, post_process=True):
19+
"""Get sales terms from template.
20+
21+
Like in mail composer `text` template can use jinja or qweb syntax.
22+
23+
if `partner_id` is provide, it will retreive it's lang to use the
24+
right translation.
25+
26+
Then template is populated with model/res_id attributes according
27+
jinja/qweb instructions.
28+
29+
:param sale_order: recordset (browsed) sale order
30+
:param add_context: context forwarded to the templating engine
31+
:param post_process: what ever to use `post_process` from the templating
32+
engine. If `True` urls are transform to absolute urls
33+
"""
34+
self.ensure_one()
35+
sale_order.ensure_one()
36+
lang = sale_order.partner_id.lang if sale_order.partner_id else None
37+
comment_texts = self.env["mail.render.mixin"]._render_template(
38+
template_src=self.with_context(lang=lang).text,
39+
model="sale.order",
40+
res_ids=[sale_order.id],
41+
engine="inline_template",
42+
add_context=add_context,
43+
post_process=post_process,
44+
)
45+
return comment_texts[sale_order.id] or ""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Pierre Verkest <pierrevkest84@gmail.com>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This module add sale terms and conditions templates and change existing terms
2+
and conditions (`sale_order.note`) field type from `Text` to `Html`.
3+
4+
Users will be able to select *terms and conditions template* to fulfill *terms and
5+
conditions* likes in mail composer users can configure their template using
6+
`jinja2`.
7+
8+
9+
How this module differ from `sale_comment_template`_?
10+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11+
12+
* `base_comment_template`_ is for managing comments not terms, it would probably
13+
see as mess for users to mixed terms and comments.
14+
15+
* `sale_comment_template`_ depends on `account_comment_template`_ comments are
16+
forwards to generated invoices, here we don't really display sales terms on
17+
final invoices
18+
19+
* `base_comment_template`_ at the time writing do not support template engine
20+
21+
22+
.. _base_comment_template: https://github.com/OCA/reporting-engine/tree/14.0/base_comment_template
23+
.. _sale_comment_template: https://github.com/OCA/sale-reporting/tree/14.0/sale_comment_template
24+
.. _account_comment_template: https://github.com/OCA/account-invoice-reporting/tree/14.0/account_comment_template
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* add a post_init_hook and / or a uninstall_hook to handle correctly the conversion (Text <--> Html).
2+
* support qweb report templating engine

0 commit comments

Comments
 (0)