Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions sale_order_note_template/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
==========================================
Sale Orders Terms and conditions Templates
==========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2a1bd6a57e66c4ae980cba82e6dc493578eef827402412687cda4e47ea5d4e7a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/16.0/sale_order_note_template
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_note_template
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module add sale terms and conditions templates and change existing terms
and conditions (`sale_order.note`) field type from `Text` to `Html`.

Users will be able to select *terms and conditions template* to fulfill *terms and
conditions* likes in mail composer users can configure their template using
`jinja2`.


How this module differ from `sale_comment_template`_?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* `base_comment_template`_ is for managing comments not terms, it would probably
see as mess for users to mixed terms and comments.

* `sale_comment_template`_ depends on `account_comment_template`_ comments are
forwards to generated invoices, here we don't really display sales terms on
final invoices

* `base_comment_template`_ at the time writing do not support template engine


.. _base_comment_template: https://github.com/OCA/reporting-engine/tree/14.0/base_comment_template
.. _sale_comment_template: https://github.com/OCA/sale-reporting/tree/14.0/sale_comment_template
.. _account_comment_template: https://github.com/OCA/account-invoice-reporting/tree/14.0/account_comment_template

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

* add a post_init_hook and / or a uninstall_hook to handle correctly the conversion (Text <--> Html).
* support qweb report templating engine

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`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**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Pierre Verkest

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

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.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_order_note_template/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions sale_order_note_template/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# © 2020 Pierre Verkest <pierreverkest84@gmail.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Sale Orders Terms and conditions Templates",
"summary": "Add sale orders terms and conditions template that can be "
"used to quickly fullfill sale order terms and conditions",
"category": "Sales/Sales",
"version": "16.0.1.0.0",
"author": "Pierre Verkest,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"license": "AGPL-3",
"depends": ["sale_management"],
"data": [
"security/ir.model.access.csv",
"views/sale_views.xml",
"views/sale_terms_template.xml",
],
"installable": True,
}
96 changes: 96 additions & 0 deletions sale_order_note_template/i18n/sale_order_note_template.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_note_template
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_order_note_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__active
msgid "Active"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__create_uid
msgid "Created by"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__create_date
msgid "Created on"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_order__display_name
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__display_name
msgid "Display Name"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_order__id
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__id
msgid "ID"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_order____last_update
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template____last_update
msgid "Last Modified on"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__write_uid
msgid "Last Updated by"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__write_date
msgid "Last Updated on"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__name
#: model_terms:ir.ui.view,arch_db:sale_order_note_template.view_sale_terms_template_form
msgid "Name"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_order__note
msgid "Note"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model,name:sale_order_note_template.model_sale_terms_template
msgid "Sale terms template"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model,name:sale_order_note_template.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: sale_order_note_template
#: model_terms:ir.ui.view,arch_db:sale_order_note_template.view_sale_terms_template_form
#: model_terms:ir.ui.view,arch_db:sale_order_note_template.view_sale_terms_template_search
msgid "Terms and conditions Templates"
msgstr ""

#. module: sale_order_note_template
#: model:ir.actions.act_window,name:sale_order_note_template.action_sale_terms_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_order__terms_template_id
#: model_terms:ir.ui.view,arch_db:sale_order_note_template.view_order_form_terms_template
msgid "Terms and conditions template"
msgstr ""

#. module: sale_order_note_template
#: model:ir.model.fields,field_description:sale_order_note_template.field_sale_terms_template__text
msgid "Terms template"
msgstr ""
2 changes: 2 additions & 0 deletions sale_order_note_template/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import sale_terms_template
from . import sale_order
22 changes: 22 additions & 0 deletions sale_order_note_template/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2021 Pierre Verkest <pierreverkest84@gmail.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class SaleOrder(models.Model):

_inherit = "sale.order"

terms_template_id = fields.Many2one(
"sale.terms_template",
string="Terms and conditions template",
readonly=True,
states={"draft": [("readonly", False)]},
)
note = fields.Html(readonly=True, states={"draft": [("readonly", False)]})

@api.onchange("terms_template_id")
def _onchange_terms_template_id(self):
if self.terms_template_id:
self.note = self.terms_template_id.get_value(self)
45 changes: 45 additions & 0 deletions sale_order_note_template/models/sale_terms_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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 SaleTermsTemplate(models.Model):
_name = "sale.terms_template"
_description = "Sale terms template"

active = fields.Boolean(default=True)

name = fields.Char(required=True)

text = fields.Html(string="Terms template", translate=True)

def get_value(self, sale_order, add_context=None, post_process=True):
"""Get sales terms from template.

Like in mail composer `text` template can use jinja or qweb syntax.

if `partner_id` is provide, it will retreive it's lang to use the
right translation.

Then template is populated with model/res_id attributes according
jinja/qweb instructions.

:param sale_order: recordset (browsed) sale order
:param add_context: context forwarded to the templating engine
:param post_process: what ever to use `post_process` from the templating
engine. If `True` urls are transform to absolute urls
"""
self.ensure_one()
sale_order.ensure_one()
lang = sale_order.partner_id.lang if sale_order.partner_id else None
comment_texts = self.env["mail.render.mixin"]._render_template(
template_src=self.with_context(lang=lang).text,
model="sale.order",
res_ids=[sale_order.id],
engine="inline_template",
add_context=add_context,
post_process=post_process,
)
return comment_texts[sale_order.id] or ""
1 change: 1 addition & 0 deletions sale_order_note_template/readme/CONTRIBUTOR.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Pierre Verkest <pierrevkest84@gmail.com>
24 changes: 24 additions & 0 deletions sale_order_note_template/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This module add sale terms and conditions templates and change existing terms
and conditions (`sale_order.note`) field type from `Text` to `Html`.

Users will be able to select *terms and conditions template* to fulfill *terms and
conditions* likes in mail composer users can configure their template using
`jinja2`.


How this module differ from `sale_comment_template`_?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* `base_comment_template`_ is for managing comments not terms, it would probably
see as mess for users to mixed terms and comments.

* `sale_comment_template`_ depends on `account_comment_template`_ comments are
forwards to generated invoices, here we don't really display sales terms on
final invoices

* `base_comment_template`_ at the time writing do not support template engine


.. _base_comment_template: https://github.com/OCA/reporting-engine/tree/14.0/base_comment_template
.. _sale_comment_template: https://github.com/OCA/sale-reporting/tree/14.0/sale_comment_template
.. _account_comment_template: https://github.com/OCA/account-invoice-reporting/tree/14.0/account_comment_template
2 changes: 2 additions & 0 deletions sale_order_note_template/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* add a post_init_hook and / or a uninstall_hook to handle correctly the conversion (Text <--> Html).
* support qweb report templating engine
3 changes: 3 additions & 0 deletions sale_order_note_template/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sale_terms_template_sale_manager,Access sale_terms_template sale manager,model_sale_terms_template,sales_team.group_sale_manager,1,1,1,1
access_sale_terms_template_users,Access sale_terms_template users,model_sale_terms_template,base.group_user,1,0,0,0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading