-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] account_invoice_sale_attachment
This module allows the automatic attachment of related sale order documents when an invoice is sent.
- Loading branch information
Showing
19 changed files
with
798 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
=============================== | ||
Account Invoice Sale Attachment | ||
=============================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:6338887aa40094db146e7a57cdf37bf46f6f98e562efa611c85e6848ea491e08 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/15.0/account_invoice_sale_attachment | ||
: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-15-0/sale-workflow-15-0-account_invoice_sale_attachment | ||
: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=15.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows the automatic attachment of related sale order documents when an | ||
invoice is sent. | ||
|
||
This module is especially useful for businesses that require the inclusion of | ||
sale order details when sending invoices, ensuring that customers have all | ||
necessary documentation at their fingertips. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
1. Select a partner. | ||
2. In the Sales/Purchases tab, check the box "Allow Joining Sale Order Documents". | ||
|
||
Usage | ||
===== | ||
|
||
1. Create an invoice linked to one or more sale orders. | ||
2. Click the Send by Email. | ||
3. The system will automatically generate and attach the sale order documents to the invoice email. | ||
4. The email sent to the customer will include the invoice and all attached sale order documents. | ||
|
||
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:%20account_invoice_sale_attachment%0Aversion:%2015.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 | ||
~~~~~~~ | ||
|
||
* ACSONE SA/NV | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Souheil Bejaoui <[email protected]> | ||
|
||
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/15.0/account_invoice_sale_attachment>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import wizards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Account Invoice Sale Attachment", | ||
"version": "15.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "ACSONE SA/NV, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/sale-workflow", | ||
"depends": ["sale"], | ||
"data": ["views/res_partner.xml"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import res_partner | ||
from . import account_move | ||
from . import sale_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class AccountMove(models.Model): | ||
|
||
_inherit = "account.move" | ||
|
||
def action_invoice_sent(self): | ||
res = super().action_invoice_sent() | ||
if not self.partner_id.allow_invoice_sale_order_attachment: | ||
return res | ||
sale_orders = self.invoice_line_ids.sale_line_ids.mapped("order_id") | ||
if not sale_orders: | ||
return res | ||
res["context"][ | ||
"sale_order_attachments" | ||
] = sale_orders._get_sale_document_attachments().ids | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
|
||
_inherit = "res.partner" | ||
|
||
allow_invoice_sale_order_attachment = fields.Boolean( | ||
string="Allow Joining Sale Order Documents", | ||
default=False, | ||
help="If enabled, sale order documents will be attached to the invoice email.", | ||
) | ||
|
||
@api.model | ||
def _commercial_fields(self): | ||
res = super()._commercial_fields() | ||
return res + ["allow_invoice_sale_order_attachment"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
import base64 | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class SaleOrder(models.Model): | ||
|
||
_inherit = "sale.order" | ||
|
||
sale_document_attachment = fields.Binary(copy=False, attachment=True, readonly=True) | ||
|
||
def _prepare_sale_document_attachment_vals(self): | ||
pdf_data = self.env.ref("sale.action_report_saleorder")._render_qweb_pdf( | ||
self.ids | ||
)[0] | ||
return { | ||
"name": self.name, | ||
"type": "binary", | ||
"datas": base64.b64encode(pdf_data).decode("utf-8"), | ||
"res_model": self._name, | ||
"res_field": "sale_document_attachment", | ||
"res_id": self.id, | ||
} | ||
|
||
def _create_sale_document_attachment(self): | ||
self.ensure_one() | ||
self.env["ir.attachment"].create( | ||
[rec._prepare_sale_document_attachment_vals() for rec in self] | ||
) | ||
|
||
def _get_sale_document_attachments(self): | ||
for rec in self: | ||
if not rec.sale_document_attachment: | ||
rec._create_sale_document_attachment() | ||
return self.env["ir.attachment"].search( | ||
[ | ||
("res_id", "in", self.ids), | ||
("res_model", "=", self._name), | ||
("res_field", "=", "sale_document_attachment"), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1. Select a partner. | ||
2. In the Sales/Purchases tab, check the box "Allow Joining Sale Order Documents". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Souheil Bejaoui <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
This module allows the automatic attachment of related sale order documents when an | ||
invoice is sent. | ||
|
||
This module is especially useful for businesses that require the inclusion of | ||
sale order details when sending invoices, ensuring that customers have all | ||
necessary documentation at their fingertips. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
1. Create an invoice linked to one or more sale orders. | ||
2. Click the Send by Email. | ||
3. The system will automatically generate and attach the sale order documents to the invoice email. | ||
4. The email sent to the customer will include the invoice and all attached sale order documents. |
Oops, something went wrong.