-
-
Notifications
You must be signed in to change notification settings - Fork 692
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
22 changed files
with
1,073 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,97 @@ | ||
======================================= | ||
Account Invoice Discount Display Amount | ||
======================================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:40d23985f16c93440f24221ada8d772d5fe62dfadb80067c4ac54132a02b9850 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Faccount--invoicing-lightgray.png?logo=github | ||
:target: https://github.com/OCA/account-invoicing/tree/16.0/account_invoice_discount_display_amount | ||
:alt: OCA/account-invoicing | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/account-invoicing-16-0/account-invoicing-16-0-account_invoice_discount_display_amount | ||
: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/account-invoicing&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows to show the total discount amount | ||
applied to an invoice, both in the backend and the | ||
invoice PDF repot. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
#. No configuration instructions needed. | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Apply a discount on an invoice line. | ||
#. The values 'Discount Total' and 'Total Without Discount' | ||
will be automatically updated. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/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/account-invoicing/issues/new?body=module:%20account_invoice_discount_display_amount%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 | ||
~~~~~~~ | ||
|
||
* Sygel | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Manuel Regidor <[email protected]> | ||
* Alexei Rivera <[email protected]> | ||
- [APSL](https://apsl.tech): | ||
- Santi Amorós \<<[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/account-invoicing <https://github.com/OCA/account-invoicing/tree/16.0/account_invoice_discount_display_amount>`_ 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 @@ | ||
from . import models |
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,18 @@ | ||
# Copyright 2022 Manuel Regidor <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Account Invoice Discount Display Amount", | ||
"summary": """ | ||
Show total discount applied and total without | ||
discount on invoices.""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Sygel,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/account-invoicing", | ||
"depends": ["base", "account"], | ||
"data": [ | ||
"views/account_move_views.xml", | ||
"report/report_invoice.xml", | ||
], | ||
} |
45 changes: 45 additions & 0 deletions
45
account_invoice_discount_display_amount/i18n/account_invoice_discount_display_amount.pot
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,45 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_invoice_discount_display_amount | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 15.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: account_invoice_discount_display_amount | ||
#: model_terms:ir.ui.view,arch_db:account_invoice_discount_display_amount.invoice_discount_display_amount_document | ||
msgid "<strong>Discount</strong>" | ||
msgstr "" | ||
|
||
#. module: account_invoice_discount_display_amount | ||
#: model:ir.model.fields,field_description:account_invoice_discount_display_amount.field_account_bank_statement_line__discount_total | ||
#: model:ir.model.fields,field_description:account_invoice_discount_display_amount.field_account_move__discount_total | ||
#: model:ir.model.fields,field_description:account_invoice_discount_display_amount.field_account_move_line__discount_total | ||
#: model:ir.model.fields,field_description:account_invoice_discount_display_amount.field_account_payment__discount_total | ||
msgid "Discount Total" | ||
msgstr "" | ||
|
||
#. module: account_invoice_discount_display_amount | ||
#: model:ir.model,name:account_invoice_discount_display_amount.model_account_move | ||
msgid "Journal Entry" | ||
msgstr "" | ||
|
||
#. module: account_invoice_discount_display_amount | ||
#: model:ir.model,name:account_invoice_discount_display_amount.model_account_move_line | ||
msgid "Journal Item" | ||
msgstr "" | ||
|
||
#. module: account_invoice_discount_display_amount | ||
#: model:ir.model.fields,field_description:account_invoice_discount_display_amount.field_account_bank_statement_line__price_total_no_discount | ||
#: model:ir.model.fields,field_description:account_invoice_discount_display_amount.field_account_move__price_total_no_discount | ||
#: model:ir.model.fields,field_description:account_invoice_discount_display_amount.field_account_move_line__price_total_no_discount | ||
#: model:ir.model.fields,field_description:account_invoice_discount_display_amount.field_account_payment__price_total_no_discount | ||
msgid "Total Without Discount" | ||
msgstr "" |
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 account_move | ||
from . import account_move_line |
47 changes: 47 additions & 0 deletions
47
account_invoice_discount_display_amount/models/account_move.py
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,47 @@ | ||
# Copyright 2022 Manuel Regidor <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountMove(models.Model): | ||
_inherit = "account.move" | ||
|
||
discount_total = fields.Monetary( | ||
compute="_compute_discount_total", | ||
currency_field="currency_id", | ||
store=True, | ||
) | ||
price_total_no_discount = fields.Monetary( | ||
compute="_compute_discount_total", | ||
string="Total Without Discount", | ||
currency_field="currency_id", | ||
store=True, | ||
) | ||
|
||
@api.depends( | ||
"invoice_line_ids.discount_total", "invoice_line_ids.price_total_no_discount" | ||
) | ||
def _compute_discount_total(self): | ||
invoices_discount = self.filtered(lambda a: a.is_invoice()) | ||
|
||
# Invoices with discount | ||
for invoice in invoices_discount: | ||
discount_total = sum(invoice.invoice_line_ids.mapped("discount_total")) | ||
price_total_no_discount = sum( | ||
invoice.invoice_line_ids.mapped("price_total_no_discount") | ||
) | ||
invoice.update( | ||
{ | ||
"discount_total": discount_total, | ||
"price_total_no_discount": price_total_no_discount, | ||
} | ||
) | ||
|
||
# Account moves that are not invoices are excluded | ||
(self - invoices_discount).update( | ||
{ | ||
"discount_total": 0.0, | ||
"price_total_no_discount": 0.0, | ||
} | ||
) |
44 changes: 44 additions & 0 deletions
44
account_invoice_discount_display_amount/models/account_move_line.py
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 2022 Manuel Regidor <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountMoveLine(models.Model): | ||
_inherit = "account.move.line" | ||
|
||
discount_total = fields.Monetary(compute="_compute_discount_amount", store=True) | ||
price_total_no_discount = fields.Monetary( | ||
compute="_compute_discount_amount", string="Total Without Discount", store=True | ||
) | ||
|
||
@api.depends("discount", "price_total") | ||
def _compute_discount_amount(self): | ||
invoice_lines_discount = self.filtered(lambda a: a.display_type == "product") | ||
for line in invoice_lines_discount: | ||
price_total_no_discount = line.price_total | ||
discount_total = 0 | ||
if line.discount: | ||
taxes = line.tax_ids.compute_all( | ||
line.price_unit, | ||
line.move_id.currency_id, | ||
line.quantity, | ||
product=line.product_id, | ||
partner=line.partner_id, | ||
) | ||
price_total_no_discount = taxes["total_included"] | ||
discount_total = price_total_no_discount - line.price_total | ||
line.update( | ||
{ | ||
"discount_total": discount_total, | ||
"price_total_no_discount": price_total_no_discount, | ||
} | ||
) | ||
|
||
# Lines that are not invoice lines are excluded | ||
(self - invoice_lines_discount).update( | ||
{ | ||
"discount_total": 0.0, | ||
"price_total_no_discount": 0.0, | ||
} | ||
) |
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 @@ | ||
To configure this module, you need to: | ||
|
||
#. No configuration instructions needed. |
4 changes: 4 additions & 0 deletions
4
account_invoice_discount_display_amount/readme/CONTRIBUTORS.rst
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 @@ | ||
* Manuel Regidor <[email protected]> | ||
* Alexei Rivera <[email protected]> | ||
- [APSL](https://apsl.tech): | ||
- Santi Amorós \<<[email protected]>\> |
3 changes: 3 additions & 0 deletions
3
account_invoice_discount_display_amount/readme/DESCRIPTION.rst
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 @@ | ||
This module allows to show the total discount amount | ||
applied to an invoice, both in the backend and the | ||
invoice PDF repot. |
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,5 @@ | ||
To use this module, you need to: | ||
|
||
#. Apply a discount on an invoice line. | ||
#. The values 'Discount Total' and 'Total Without Discount' | ||
will be automatically updated. |
16 changes: 16 additions & 0 deletions
16
account_invoice_discount_display_amount/report/report_invoice.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,16 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<template | ||
id="invoice_discount_display_amount_document" | ||
inherit_id="account.report_invoice_document" | ||
> | ||
<xpath expr="//t[@t-call='account.document_tax_totals']" position="after"> | ||
<tr t-if="display_discount" class="border-black"> | ||
<td name="td_discount_total_label"><strong>Discount</strong></td> | ||
<td name="td_discount_total" class="text-end"> | ||
<span t-field="o.discount_total" /> | ||
</td> | ||
</tr> | ||
</xpath> | ||
</template> | ||
</odoo> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.