Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
from . import sale_terms_template
from . import sale_order

View File

@@ -0,0 +1,19 @@
# 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",
)
note = fields.Html()
@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)

View File

@@ -0,0 +1,44 @@
# 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,
)
return comment_texts[sale_order.id] or ""