diff --git a/sale_down_payment_wizard_taxes/README.rst b/sale_down_payment_wizard_taxes/README.rst new file mode 100644 index 00000000000..e11fa49f38d --- /dev/null +++ b/sale_down_payment_wizard_taxes/README.rst @@ -0,0 +1,81 @@ +============================== +Sale Down Payment Wizard Taxes +============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/13.0/sale_down_payment_wizard_taxes + :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-13-0/sale-workflow-13-0-sale_down_payment_wizard_taxes + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/167/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of the creation of a down payment for a sale order +and to allow you to set a tax on the down payment simultaneously +on the invoice line and the sale order line. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +When creating a down payment from a sale order, a required field for tax +of down payment will be visible in the wizard view. + +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 +~~~~~~~~~~~~ + +* Zina Rasoamanana + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_down_payment_wizard_taxes/__init__.py b/sale_down_payment_wizard_taxes/__init__.py new file mode 100644 index 00000000000..3c9f9be48be --- /dev/null +++ b/sale_down_payment_wizard_taxes/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import wizards diff --git a/sale_down_payment_wizard_taxes/__manifest__.py b/sale_down_payment_wizard_taxes/__manifest__.py new file mode 100644 index 00000000000..74fee93d878 --- /dev/null +++ b/sale_down_payment_wizard_taxes/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Sale Down Payment Wizard Taxes", + "summary": """ + Adds the option to set the tax on down payment""", + "version": "13.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/sale_make_invoice_advance_views.xml"], + "demo": [], +} diff --git a/sale_down_payment_wizard_taxes/readme/CONTRIBUTORS.rst b/sale_down_payment_wizard_taxes/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..3ee6196e833 --- /dev/null +++ b/sale_down_payment_wizard_taxes/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Zina Rasoamanana diff --git a/sale_down_payment_wizard_taxes/readme/DESCRIPTION.rst b/sale_down_payment_wizard_taxes/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..f9deefd7ea8 --- /dev/null +++ b/sale_down_payment_wizard_taxes/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module extends the functionality of the creation of a down payment for a sale order +and to allow you to set a tax on the down payment simultaneously +on the invoice line and the sale order line. diff --git a/sale_down_payment_wizard_taxes/readme/USAGE.rst b/sale_down_payment_wizard_taxes/readme/USAGE.rst new file mode 100644 index 00000000000..9ed9ba8d376 --- /dev/null +++ b/sale_down_payment_wizard_taxes/readme/USAGE.rst @@ -0,0 +1,2 @@ +When creating a down payment from a sale order, a required field for tax +of down payment will be visible in the wizard view. diff --git a/sale_down_payment_wizard_taxes/static/description/icon.png b/sale_down_payment_wizard_taxes/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/sale_down_payment_wizard_taxes/static/description/icon.png differ diff --git a/sale_down_payment_wizard_taxes/static/description/index.html b/sale_down_payment_wizard_taxes/static/description/index.html new file mode 100644 index 00000000000..a459e44634b --- /dev/null +++ b/sale_down_payment_wizard_taxes/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Sale Down Payment Wizard Taxes + + + +
+

Sale Down Payment Wizard Taxes

+ + +

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

+

This module extends the functionality of the creation of a down payment for a sale order +and to allow you to set a tax on the down payment simultaneously +on the invoice line and the sale order line.

+

Table of contents

+ +
+

Usage

+

When creating a down payment from a sale order, a required field for tax +of down payment will be visible in the wizard view.

+
+
+

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

+ +
+
+

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.

+

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

+

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

+
+
+
+ + diff --git a/sale_down_payment_wizard_taxes/tests/__init__.py b/sale_down_payment_wizard_taxes/tests/__init__.py new file mode 100644 index 00000000000..3847eec8bdb --- /dev/null +++ b/sale_down_payment_wizard_taxes/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_sale_down_payment_wizard_taxes diff --git a/sale_down_payment_wizard_taxes/tests/test_sale_down_payment_wizard_taxes.py b/sale_down_payment_wizard_taxes/tests/test_sale_down_payment_wizard_taxes.py new file mode 100644 index 00000000000..eb68da55bb3 --- /dev/null +++ b/sale_down_payment_wizard_taxes/tests/test_sale_down_payment_wizard_taxes.py @@ -0,0 +1,83 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.fields import first +from odoo.tests.common import SavepointCase + + +class TestSaleOrderLinePriceUnitFixed(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.Partner = cls.env["res.partner"] + cls.Product = cls.env["product.product"] + cls.SaleOrder = cls.env["sale.order"] + cls.PriceList = cls.env["product.pricelist"] + cls.SaleOrderLine = cls.env["sale.order.line"] + cls.partner = cls.Partner.create({"name": "Customer"}) + cls.product1 = cls.Product.create({"name": "Test Product 1", "list_price": 10}) + cls.tax15 = cls.env["account.tax"].create( + { + "name": "TAX 15%", + "amount_type": "percent", + "type_tax_use": "sale", + "amount": 15.0, + } + ) + + cls.sale_order = cls.SaleOrder.create( + { + "partner_id": cls.partner.id, + "order_line": [ + ( + 0, + 0, + { + "product_id": cls.product1.id, + "name": "line 1", + "product_uom_qty": 1, + "price_unit": 10, + }, + ), + ], + } + ) + + # Context + cls.context = { + "active_model": cls.sale_order._name, + "active_ids": cls.sale_order.ids, + "active_id": cls.sale_order.id, + } + + def test_downpayment(self): + """Test downpayment and ensures + that the tax is the same on the invoice and the sale order""" + so = self.sale_order + # Confirm the SO + so.action_confirm() + # Let's do an invoice for a deposit of 100 and 15% tax + payment = ( + self.env["sale.advance.payment.inv"] + .with_context(**self.context) + .create( + { + "advance_payment_method": "fixed", + "fixed_amount": 100, + "deposit_taxes_id": self.tax15, + } + ) + ) + payment.create_invoices() + + self.assertEqual(len(so.invoice_ids), 1, "Invoice should be created for the SO") + downpayment_line = so.order_line.filtered(lambda l: l.is_downpayment) + self.assertEqual( + len(downpayment_line), 1, "SO line downpayment should be created on SO" + ) + + inv_line = first(first(so.invoice_ids).invoice_line_ids) + self.assertEqual(downpayment_line.tax_id, first(inv_line.tax_ids)) + self.assertEqual(downpayment_line.tax_id, self.tax15) + self.assertEqual(first(inv_line.tax_ids), self.tax15) diff --git a/sale_down_payment_wizard_taxes/views/sale_make_invoice_advance_views.xml b/sale_down_payment_wizard_taxes/views/sale_make_invoice_advance_views.xml new file mode 100644 index 00000000000..28666eb34d2 --- /dev/null +++ b/sale_down_payment_wizard_taxes/views/sale_make_invoice_advance_views.xml @@ -0,0 +1,17 @@ + + + + Invoice Orders (in sale_down_payment_wizard_taxes) + sale.advance.payment.inv + + + + + + {'required': [('advance_payment_method', 'not in', + ('delivered'))],'invisible': [('advance_payment_method','in', ('delivered'))]} + + + + + diff --git a/sale_down_payment_wizard_taxes/wizards/__init__.py b/sale_down_payment_wizard_taxes/wizards/__init__.py new file mode 100644 index 00000000000..8ee112e81f4 --- /dev/null +++ b/sale_down_payment_wizard_taxes/wizards/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import sale_advance_payment_inv diff --git a/sale_down_payment_wizard_taxes/wizards/sale_advance_payment_inv.py b/sale_down_payment_wizard_taxes/wizards/sale_advance_payment_inv.py new file mode 100644 index 00000000000..36929078687 --- /dev/null +++ b/sale_down_payment_wizard_taxes/wizards/sale_advance_payment_inv.py @@ -0,0 +1,15 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class SaleAdvancePaymentInv(models.TransientModel): + _inherit = "sale.advance.payment.inv" + + def _prepare_so_line(self, order, analytic_tag_ids, tax_ids, amount): + ret = super()._prepare_so_line(order, analytic_tag_ids, tax_ids, amount) + if self.advance_payment_method != "delivered": + # override the tax_id on so line + ret["tax_id"] = [(6, 0, self.deposit_taxes_id.ids)] + return ret diff --git a/setup/sale_down_payment_wizard_taxes/odoo/addons/sale_down_payment_wizard_taxes b/setup/sale_down_payment_wizard_taxes/odoo/addons/sale_down_payment_wizard_taxes new file mode 120000 index 00000000000..767f425599a --- /dev/null +++ b/setup/sale_down_payment_wizard_taxes/odoo/addons/sale_down_payment_wizard_taxes @@ -0,0 +1 @@ +../../../../sale_down_payment_wizard_taxes \ No newline at end of file diff --git a/setup/sale_down_payment_wizard_taxes/setup.py b/setup/sale_down_payment_wizard_taxes/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/sale_down_payment_wizard_taxes/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)