-
-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] account_invoice_discount_display_amount: Migration to 16.0
- Loading branch information
Santiago Amorós Guillen
committed
Dec 1, 2023
1 parent
27b7a74
commit ed3d1e8
Showing
14 changed files
with
306 additions
and
60 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 |
---|---|---|
|
@@ -7,7 +7,7 @@ Account Invoice Discount Display Amount | |
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:c11ca367c7ff1cfc8a3a2e5a2dbb5de01ee6336f7213f238c3da652847332dd5 | ||
!! source digest: sha256:40d23985f16c93440f24221ada8d772d5fe62dfadb80067c4ac54132a02b9850 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
|
@@ -17,13 +17,13 @@ Account Invoice Discount Display Amount | |
: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/15.0/account_invoice_discount_display_amount | ||
: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-15-0/account-invoicing-15-0-account_invoice_discount_display_amount | ||
: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=15.0 | ||
: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| | ||
|
@@ -59,7 +59,7 @@ 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:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
`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. | ||
|
||
|
@@ -75,7 +75,9 @@ Contributors | |
~~~~~~~~~~~~ | ||
|
||
* Manuel Regidor <[email protected]> | ||
* Alexei Rivera <[email protected]> (migration to 15.0) | ||
* Alexei Rivera <[email protected]> | ||
- [APSL](https://apsl.tech): | ||
- Santi Amorós \<<[email protected]>\> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
@@ -90,6 +92,6 @@ 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/15.0/account_invoice_discount_display_amount>`_ project on GitHub. | ||
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
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
4 changes: 3 additions & 1 deletion
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
* Manuel Regidor <[email protected]> | ||
* Alexei Rivera <[email protected]> (migration to 15.0) | ||
* Alexei Rivera <[email protected]> | ||
- [APSL](https://apsl.tech): | ||
- Santi Amorós \<<[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
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
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
from . import test_invoice_discount_display_amount | ||
from . import test_account_move_line | ||
from . import test_account_move | ||
from . import common |
108 changes: 108 additions & 0 deletions
108
account_invoice_discount_display_amount/tests/common.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,108 @@ | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestInvoiceDiscountDisplayCommon(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
|
||
super().setUpClass() | ||
cls.account_invoice = cls.env["account.move"] | ||
cls.account_journal = cls.env["account.journal"] | ||
cls.journal = cls.account_journal.create( | ||
{"code": "test", "name": "test", "type": "sale"} | ||
) | ||
cls.partner = cls.env.ref("base.res_partner_3") | ||
|
||
cls.account_account = cls.env["account.account"] | ||
cls.account_rec1_id = cls.account_account.create( | ||
dict( | ||
code="20000", | ||
name="customer account", | ||
account_type="asset_receivable", | ||
reconcile=True, | ||
) | ||
) | ||
cls.product_product = cls.env["product.product"] | ||
cls.product = cls.product_product.create( | ||
{ | ||
"name": "Test", | ||
"categ_id": cls.env.ref("product.product_category_all").id, | ||
"list_price": 100, | ||
"type": "service", | ||
} | ||
) | ||
cls.tax_tax = cls.env["account.tax"] | ||
cls.tax_25 = cls.tax_tax.create( | ||
{ | ||
"amount": 25, | ||
"amount_type": "percent", | ||
"name": "Tax 25%", | ||
} | ||
) | ||
cls.tax_15 = cls.tax_tax.create( | ||
{ | ||
"amount": 15, | ||
"amount_type": "percent", | ||
"name": "Tax 15%", | ||
} | ||
) | ||
invoice_line_data = [ | ||
( | ||
0, | ||
0, | ||
{ | ||
"product_id": cls.product.id, | ||
"quantity": 10.0, | ||
"account_id": cls.account_account.search( | ||
[ | ||
( | ||
"account_type", | ||
"=", | ||
"income", | ||
) | ||
], | ||
limit=1, | ||
).id, | ||
"name": "product 1", | ||
"price_unit": 100.00, | ||
"tax_ids": cls.tax_25, | ||
"discount": 50, | ||
}, | ||
) | ||
] | ||
|
||
cls.invoice = cls.account_invoice.create( | ||
dict( | ||
name="Test Customer Invoice", | ||
journal_id=cls.journal.id, | ||
partner_id=cls.partner.id, | ||
invoice_line_ids=invoice_line_data, | ||
move_type="out_invoice", | ||
) | ||
) | ||
|
||
def return_taxes(self): | ||
return self.tax_ids.compute_all( | ||
self.price_unit, | ||
self.move_id.currency_id, | ||
self.quantity, | ||
product=self.product_id, | ||
partner=self.partner_id, | ||
) | ||
|
||
@classmethod | ||
def obtain_attributes(cls, line): | ||
taxes = cls.return_taxes(line) | ||
tax_per_cent_amount = (line.tax_ids.amount) / 100 | ||
line_applied_discount_prior_taxes = line.price_subtotal | ||
line_applied_discount_with_taxes = line.price_total | ||
line_without_discount_prior_taxes = taxes["total_excluded"] | ||
line_without_discount_with_taxes = taxes["total_included"] | ||
return ( | ||
taxes, | ||
tax_per_cent_amount, | ||
line_applied_discount_prior_taxes, | ||
line_applied_discount_with_taxes, | ||
line_without_discount_prior_taxes, | ||
line_without_discount_with_taxes, | ||
) |
110 changes: 110 additions & 0 deletions
110
account_invoice_discount_display_amount/tests/test_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,110 @@ | ||
from .common import TestInvoiceDiscountDisplayCommon | ||
|
||
|
||
class TestAccountMoveLine(TestInvoiceDiscountDisplayCommon): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
# Add some more lines | ||
invoice_line_data = [ | ||
( | ||
0, | ||
0, | ||
{ | ||
"product_id": cls.product.id, | ||
"quantity": 10.0, | ||
"account_id": cls.account_account.search( | ||
[ | ||
( | ||
"account_type", | ||
"=", | ||
"income", | ||
) | ||
], | ||
limit=1, | ||
).id, | ||
"name": "product line 1", | ||
"price_unit": 100.00, | ||
"tax_ids": cls.tax_25, | ||
"discount": 50, | ||
}, | ||
), | ||
( | ||
0, | ||
0, | ||
{ | ||
"product_id": cls.product.id, | ||
"quantity": 1.0, | ||
"account_id": cls.account_account.search( | ||
[ | ||
( | ||
"account_type", | ||
"=", | ||
"income", | ||
) | ||
], | ||
limit=1, | ||
).id, | ||
"name": "product line 2", | ||
"price_unit": 1000.00, | ||
"tax_ids": cls.tax_15, | ||
"discount": 40, | ||
}, | ||
), | ||
( | ||
0, | ||
0, | ||
{ | ||
"product_id": cls.product.id, | ||
"quantity": 5.0, | ||
"account_id": cls.account_account.search( | ||
[ | ||
( | ||
"account_type", | ||
"=", | ||
"income", | ||
) | ||
], | ||
limit=1, | ||
).id, | ||
"name": "product line 3", | ||
"price_unit": 20.00, | ||
"tax_ids": cls.tax_25, | ||
"discount": 50, | ||
}, | ||
), | ||
] | ||
|
||
cls.invoice = cls.account_invoice.create( | ||
dict( | ||
name="Test Customer Invoice", | ||
journal_id=cls.journal.id, | ||
partner_id=cls.partner.id, | ||
invoice_line_ids=invoice_line_data, | ||
move_type="out_invoice", | ||
) | ||
) | ||
|
||
def test06_check_invoice_setup(self): | ||
# check initial SetUp is Ok | ||
invoice = self.invoice | ||
|
||
self.assertEqual(invoice.discount_total, 1147.5) | ||
self.assertEqual(invoice.price_total_no_discount, 2525) | ||
|
||
def test07_check_invoice_when_lines_change(self): | ||
# Producing a recompute of discount_total/price_total_no_discount | ||
# on each of the lines in order to cause a recompute of the invoice's | ||
# own discount_total/price_total_no_discount attributes. | ||
invoice = self.invoice | ||
|
||
line1 = invoice.invoice_line_ids[0] | ||
line2 = invoice.invoice_line_ids[1] | ||
line3 = invoice.invoice_line_ids[2] | ||
|
||
line1.price_unit = 75 | ||
line2.tax_ids = self.tax_25 | ||
line3.quantity = 16 | ||
|
||
self.assertEqual(invoice.price_total_no_discount, 2587.5) | ||
self.assertEqual(invoice.discount_total, 1168.75) |
Oops, something went wrong.