diff --git a/.travis.yml b/.travis.yml index 6716bfa..75c8bde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,11 @@ env: - VERSION="13.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0" install: + # FIXME: + - git clone --branch 13.0-add_account_fiscal_position_allowed_journal_tbi + https://github.com/acsone/account-financial-tools.git PR937 + - rm -rf account_fiscal_position_allowed_journal && cp -ar + PR937/account_fiscal_position_allowed_journal . - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} diff --git a/account_fiscal_position_allowed_journal_sale/README.rst b/account_fiscal_position_allowed_journal_sale/README.rst new file mode 100644 index 0000000..0a0d51c --- /dev/null +++ b/account_fiscal_position_allowed_journal_sale/README.rst @@ -0,0 +1,86 @@ +============================================ +Account Fiscal Position Allowed Journal Sale +============================================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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--financial-lightgray.png?logo=github + :target: https://github.com/OCA/sale-financial/tree/13.0/account_fiscal_position_allowed_journal_sale + :alt: OCA/sale-financial +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-financial-13-0/sale-financial-13-0-account_fiscal_position_allowed_journal_sale + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/147/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +When creating an invoice from a sale order, take the allowed sale journal on the fiscal position, if there is exactly one on it. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +See configuration of Account Fiscal Position Allowed Journal. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Thomas Binsfeld (https://www.acsone.eu/) + +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. + +.. |maintainer-ThomasBinsfeld| image:: https://github.com/ThomasBinsfeld.png?size=40px + :target: https://github.com/ThomasBinsfeld + :alt: ThomasBinsfeld + +Current `maintainer `__: + +|maintainer-ThomasBinsfeld| + +This module is part of the `OCA/sale-financial `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_fiscal_position_allowed_journal_sale/__init__.py b/account_fiscal_position_allowed_journal_sale/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/account_fiscal_position_allowed_journal_sale/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_fiscal_position_allowed_journal_sale/__manifest__.py b/account_fiscal_position_allowed_journal_sale/__manifest__.py new file mode 100644 index 0000000..47007d6 --- /dev/null +++ b/account_fiscal_position_allowed_journal_sale/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Account Fiscal Position Allowed Journal Sale", + "summary": """ + Use an allowed journal when creating an invoice from a sale order.""", + "version": "13.0.1.0.0", + "development_status": "Beta", + "license": "AGPL-3", + "author": "ACSONE SA/NV, Odoo Community Association (OCA)", + "maintainers": ["ThomasBinsfeld"], + "website": "https://github.com/OCA/sale-financial", + "depends": ["sale", "account_fiscal_position_allowed_journal"], +} diff --git a/account_fiscal_position_allowed_journal_sale/models/__init__.py b/account_fiscal_position_allowed_journal_sale/models/__init__.py new file mode 100644 index 0000000..6aacb75 --- /dev/null +++ b/account_fiscal_position_allowed_journal_sale/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order diff --git a/account_fiscal_position_allowed_journal_sale/models/sale_order.py b/account_fiscal_position_allowed_journal_sale/models/sale_order.py new file mode 100644 index 0000000..b40d73d --- /dev/null +++ b/account_fiscal_position_allowed_journal_sale/models/sale_order.py @@ -0,0 +1,23 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + def _prepare_invoice(self): + """ + If there is a fiscal position in vals and exactly one sale journal + allowed on it, set this journal in vals. + """ + res = super()._prepare_invoice() + fiscal_position_id = res.get("fiscal_position_id") + if fiscal_position_id: + fiscal_position_model = self.env["account.fiscal.position"] + fiscal_position = fiscal_position_model.browse(fiscal_position_id) + sale_journal = fiscal_position._get_allowed_journal("sale") + if sale_journal: + res["journal_id"] = sale_journal.id + return res diff --git a/account_fiscal_position_allowed_journal_sale/readme/CONFIGURE.rst b/account_fiscal_position_allowed_journal_sale/readme/CONFIGURE.rst new file mode 100644 index 0000000..d7ac282 --- /dev/null +++ b/account_fiscal_position_allowed_journal_sale/readme/CONFIGURE.rst @@ -0,0 +1 @@ +See configuration of Account Fiscal Position Allowed Journal. diff --git a/account_fiscal_position_allowed_journal_sale/readme/CONTRIBUTORS.rst b/account_fiscal_position_allowed_journal_sale/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..0a9ab3e --- /dev/null +++ b/account_fiscal_position_allowed_journal_sale/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Thomas Binsfeld (https://www.acsone.eu/) diff --git a/account_fiscal_position_allowed_journal_sale/readme/DESCRIPTION.rst b/account_fiscal_position_allowed_journal_sale/readme/DESCRIPTION.rst new file mode 100644 index 0000000..d8611d9 --- /dev/null +++ b/account_fiscal_position_allowed_journal_sale/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +When creating an invoice from a sale order, take the allowed sale journal on the fiscal position, if there is exactly one on it. diff --git a/account_fiscal_position_allowed_journal_sale/static/description/icon.png b/account_fiscal_position_allowed_journal_sale/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/account_fiscal_position_allowed_journal_sale/static/description/icon.png differ diff --git a/account_fiscal_position_allowed_journal_sale/static/description/index.html b/account_fiscal_position_allowed_journal_sale/static/description/index.html new file mode 100644 index 0000000..3185907 --- /dev/null +++ b/account_fiscal_position_allowed_journal_sale/static/description/index.html @@ -0,0 +1,426 @@ + + + + + + +Account Fiscal Position Allowed Journal Sale + + + +
+

Account Fiscal Position Allowed Journal Sale

+ + +

Beta License: AGPL-3 OCA/sale-financial Translate me on Weblate Try me on Runbot

+

When creating an invoice from a sale order, take the allowed sale journal on the fiscal position, if there is exactly one on it.

+

Table of contents

+ +
+

Configuration

+

See configuration of Account Fiscal Position Allowed Journal.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

ThomasBinsfeld

+

This module is part of the OCA/sale-financial project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_fiscal_position_allowed_journal_sale/tests/__init__.py b/account_fiscal_position_allowed_journal_sale/tests/__init__.py new file mode 100644 index 0000000..7df1619 --- /dev/null +++ b/account_fiscal_position_allowed_journal_sale/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_fiscal_position_allowed_journal_sale diff --git a/account_fiscal_position_allowed_journal_sale/tests/test_account_fiscal_position_allowed_journal_sale.py b/account_fiscal_position_allowed_journal_sale/tests/test_account_fiscal_position_allowed_journal_sale.py new file mode 100644 index 0000000..802c3f9 --- /dev/null +++ b/account_fiscal_position_allowed_journal_sale/tests/test_account_fiscal_position_allowed_journal_sale.py @@ -0,0 +1,91 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import SavepointCase + + +class TestAccountFiscalPositionAllowedJournalSale(SavepointCase): + @classmethod + def setUpClass(cls): + super(TestAccountFiscalPositionAllowedJournalSale, cls).setUpClass() + + # MODELS + cls.account_model = cls.env["account.account"] + cls.fiscal_position_model = cls.env["account.fiscal.position"] + cls.journal_model = cls.env["account.journal"] + cls.partner_model = cls.env["res.partner"] + cls.product_product_model = cls.env["product.product"] + cls.sale_order_model = cls.env["sale.order"] + + # INSTANCES + cls.fiscal_position_01 = cls.fiscal_position_model.create( + {"name": "Fiscal position 01"} + ) + cls.journal_01 = cls.journal_model.search([("type", "=", "sale")], limit=1) + cls.journal_02 = cls.journal_01.copy() + cls.partner_01 = cls.partner_model.search([], limit=1) + cls.product_01 = cls.product_product_model.search( + [("type", "=", "service")], limit=1 + ) + cls.sale_order_01 = cls.sale_order_model.create( + { + "partner_id": cls.partner_01.id, + "fiscal_position_id": cls.fiscal_position_01.id, + "order_line": [ + ( + 0, + 0, + { + "name": "Sale order line 01", + "product_id": cls.product_01.id, + "product_uom_qty": 1, + "price_unit": 1, + }, + ) + ], + } + ) + cls.sale_order_01.action_confirm() + + def test_01(self): + """ + Data: + - A confirmed sale order with a fiscal position + - Exactly one sale journal allowed on the fiscal position + Test case: + - Create the invoice from the sale order + Expected result: + - The allowed sale journal is set on the invoice + """ + self.fiscal_position_01.allowed_journal_ids = [(6, 0, self.journal_02.ids)] + invoice = self.sale_order_01._create_invoices() + self.assertEqual(invoice.journal_id, self.journal_02) + + def test_02(self): + """ + Data: + - A confirmed sale order with no fiscal position + Test case: + - Create the invoice from the sale order + Expected result: + - Invoice created + """ + self.sale_order_01.fiscal_position_id = False + invoice = self.sale_order_01._create_invoices() + self.assertTrue(invoice) + + def test_03(self): + """ + Data: + - A confirmed sale order with a fiscal position + - Two sale journals allowed on the fiscal position + Test case: + - Create the invoice from the sale order + Expected result: + - The default sale journal is set on the invoice + """ + self.fiscal_position_01.allowed_journal_ids = [ + (6, 0, (self.journal_01 | self.journal_02).ids) + ] + invoice = self.sale_order_01._create_invoices() + self.assertEqual(invoice.journal_id, self.journal_01) diff --git a/oca_dependencies.txt b/oca_dependencies.txt new file mode 100644 index 0000000..626b4c8 --- /dev/null +++ b/oca_dependencies.txt @@ -0,0 +1 @@ +account-financial-tools diff --git a/setup/.setuptools-odoo-make-default-ignore b/setup/.setuptools-odoo-make-default-ignore new file mode 100644 index 0000000..207e615 --- /dev/null +++ b/setup/.setuptools-odoo-make-default-ignore @@ -0,0 +1,2 @@ +# addons listed in this file are ignored by +# setuptools-odoo-make-default (one addon per line) diff --git a/setup/README b/setup/README new file mode 100644 index 0000000..a63d633 --- /dev/null +++ b/setup/README @@ -0,0 +1,2 @@ +To learn more about this directory, please visit +https://pypi.python.org/pypi/setuptools-odoo diff --git a/setup/account_fiscal_position_allowed_journal_sale/odoo/addons/account_fiscal_position_allowed_journal_sale b/setup/account_fiscal_position_allowed_journal_sale/odoo/addons/account_fiscal_position_allowed_journal_sale new file mode 120000 index 0000000..c857362 --- /dev/null +++ b/setup/account_fiscal_position_allowed_journal_sale/odoo/addons/account_fiscal_position_allowed_journal_sale @@ -0,0 +1 @@ +../../../../account_fiscal_position_allowed_journal_sale \ No newline at end of file diff --git a/setup/account_fiscal_position_allowed_journal_sale/setup.py b/setup/account_fiscal_position_allowed_journal_sale/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/account_fiscal_position_allowed_journal_sale/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)