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
101 changes: 101 additions & 0 deletions sale_product_email/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

==================
Sale product email
==================

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

.. |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/license-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_product_email
: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_product_email
: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 adds an optional email template to products.
When a sale is confirmed, a single mail will be sent for each product with the mail template set in the 'Sale confirmation email' (`sale_confirmation_mail_template_id`) field.

This module differs from `product_email_template`, as it sends a mail when an invoice is posted, whereas this module sends a mail when a sale order is confirmed.
As such, depending on your workflow, you may pick either module for the email timing you require.
For instance, if a sale order leads to a contract which generates invoices recurrently, you may prefer to only send a mail when the sale order is confirmed.

**Table of contents**

.. contents::
:local:

Usage
=====

How to use this module :

1. Create an Email template for the Sale Order (`sale.order`) model.
2. Edit a product, then go into the 'Sales' notebook tab.
3. In the 'Sale confirmation email' field, select your newly created email template.

Afterwards, when this product is present in a confirmed sale, a mail based on the configured template will be sent.

.. image:: https://raw.githubusercontent.com/sale_product_email/static/description/mail_template_select.png
:alt: Mail template selection on a Product

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_product_email%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
~~~~~~~

* Commown SCIC
* Akretion

Contributors
~~~~~~~~~~~~

* Florent Cayré <florent@commown.coop>
* Chafique Delli <chafique.delli@akretion.com>

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_product_email>`_ 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_product_email/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions sale_product_email/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2022-today Commown SCIC (https://commown.coop)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Sale product email",
"category": "Sales",
"summary": "Send a product-specific email to its buyers",
"version": "16.0.1.0.0",
"author": "Commown SCIC, Akretion, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/sale-workflow",
"data": [
"views/product_template.xml",
],
"depends": [
"sale",
],
"installable": True,
}
2 changes: 2 additions & 0 deletions sale_product_email/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import product_template
from . import sale_order
17 changes: 17 additions & 0 deletions sale_product_email/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2022-today Commown SCIC (https://commown.coop)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

sale_confirmation_mail_template_id = fields.Many2one(
"mail.template",
string="Sale confirmation email",
domain=lambda self: [
("model_id", "=", self.env.ref("sale.model_sale_order").id),
],
help=("If set, this email will be sent to the buyer on sale" " confirmation"),
)
26 changes: 26 additions & 0 deletions sale_product_email/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2022-today Commown SCIC (https://commown.coop)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class SaleOrder(models.Model):
_inherit = "sale.order"

def action_confirm(self):
res = super().action_confirm()
self.send_sold_products_mail()
return res

def send_sold_products_mail(self):
for order in self:
for line in order.order_line:
product_tmpl = line.product_id.product_tmpl_id
mail_template = product_tmpl.sale_confirmation_mail_template_id
if mail_template:
order.with_context(
product_tmpl=product_tmpl,
default_composition_mode="comment",
default_partner_ids=order.partner_id.ids,
custom_layout="sale.email_template_edi_sale",
).message_post_with_template(mail_template.id)
2 changes: 2 additions & 0 deletions sale_product_email/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Florent Cayré <florent@commown.coop>
* Chafique Delli <chafique.delli@akretion.com>
6 changes: 6 additions & 0 deletions sale_product_email/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module adds an optional email template to products.
When a sale is confirmed, a single mail will be sent for each product with the mail template set in the 'Sale confirmation email' (`sale_confirmation_mail_template_id`) field.

This module differs from `product_email_template`, as it sends a mail when an invoice is posted, whereas this module sends a mail when a sale order is confirmed.
As such, depending on your workflow, you may pick either module for the email timing you require.
For instance, if a sale order leads to a contract which generates invoices recurrently, you may prefer to only send a mail when the sale order is confirmed.
10 changes: 10 additions & 0 deletions sale_product_email/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
How to use this module :

1. Create an Email template for the Sale Order (`sale.order`) model.
2. Edit a product, then go into the 'Sales' notebook tab.
3. In the 'Sale confirmation email' field, select your newly created email template.

Afterwards, when this product is present in a confirmed sale, a mail based on the configured template will be sent.

.. image:: /sale_product_email/static/description/mail_template_select.png
:alt: Mail template selection on a Product
Loading