diff --git a/sale_order_invoicing_picking_filter_groping_criteria/README.rst b/sale_order_invoicing_picking_filter_groping_criteria/README.rst new file mode 100644 index 00000000000..516b591e489 --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/README.rst @@ -0,0 +1,112 @@ +===================================================== +Sale Order Invoicing Picking Filter Grouping Criteria +===================================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a6122ba11e3c8e3ffe6e3243f3d076d29b2a67a3d294acecef4ba2532e87bb56 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.0/sale_order_invoicing_picking_filter_groping_criteria + :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-16-0/sale-workflow-16-0-sale_order_invoicing_picking_filter_groping_criteria + :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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of +sale_order_invoicing_grouping_criteria and +sale_order_invoicing_picking_filter, to support both the functionality +of selecting the pickings that will be invoiced, and grouping the +generated invoices, when invoicing multiple sales at the same time. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to follow the instructions of the +sale_order_invoicing_picking_filter and +sale_order_invoicing_grouping_criteria modules. + +Usage +===== + +To use this module, you need to: + +1. Go to Sales / To Invoice / Orders to Invoice +2. Select sales orders whose invoicing you want to do. +3. Click on *Action > Create invoices*. +4. Select the pickings whose invoicing you want to do. +5. Click on "Create and View Invoices" button. +6. On that moment, the grouping criteria will be applied, and you will + see different invoices if the criteria doesn't match for the sales. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Sygel + +Contributors +------------ + +- `Sygel `__: + + - Alberto Martínez + - Valentin Vinagre + - Harald Panten + +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-tisho99| image:: https://github.com/tisho99.png?size=40px + :target: https://github.com/tisho99 + :alt: tisho99 + +Current `maintainer `__: + +|maintainer-tisho99| + +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_order_invoicing_picking_filter_groping_criteria/__init__.py b/sale_order_invoicing_picking_filter_groping_criteria/__init__.py new file mode 100644 index 00000000000..74d71de4bef --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import wizards diff --git a/sale_order_invoicing_picking_filter_groping_criteria/__manifest__.py b/sale_order_invoicing_picking_filter_groping_criteria/__manifest__.py new file mode 100644 index 00000000000..2eb99199aa2 --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 Alberto Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Sale Order Invoicing Picking Filter Grouping Criteria", + "summary": "Glues the picking filter with sale_order_invoicing_grouping_criteria", + "version": "16.0.1.0.0", + "category": "Invoicing", + "website": "https://github.com/OCA/sale-workflow", + "author": "Sygel, Odoo Community Association (OCA)", + "maintainers": ["tisho99"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "sale_order_invoicing_grouping_criteria", + "sale_order_invoicing_picking_filter", + ], +} diff --git a/sale_order_invoicing_picking_filter_groping_criteria/readme/CONFIGURE.md b/sale_order_invoicing_picking_filter_groping_criteria/readme/CONFIGURE.md new file mode 100644 index 00000000000..d30167673fe --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/readme/CONFIGURE.md @@ -0,0 +1 @@ +To configure this module, you need to follow the instructions of the sale_order_invoicing_picking_filter and sale_order_invoicing_grouping_criteria modules. diff --git a/sale_order_invoicing_picking_filter_groping_criteria/readme/CONTRIBUTORS.md b/sale_order_invoicing_picking_filter_groping_criteria/readme/CONTRIBUTORS.md new file mode 100755 index 00000000000..f566245042c --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- [Sygel](https://www.sygel.es): + - Alberto Martínez + - Valentin Vinagre + - Harald Panten diff --git a/sale_order_invoicing_picking_filter_groping_criteria/readme/DESCRIPTION.md b/sale_order_invoicing_picking_filter_groping_criteria/readme/DESCRIPTION.md new file mode 100755 index 00000000000..1a1b0e89837 --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module extends the functionality of sale_order_invoicing_grouping_criteria and sale_order_invoicing_picking_filter, to support both the functionality of selecting the pickings that will be invoiced, and grouping the generated invoices, when invoicing multiple sales at the same time. diff --git a/sale_order_invoicing_picking_filter_groping_criteria/readme/USAGE.md b/sale_order_invoicing_picking_filter_groping_criteria/readme/USAGE.md new file mode 100755 index 00000000000..5c2c597caba --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/readme/USAGE.md @@ -0,0 +1,9 @@ +To use this module, you need to: + +1. Go to Sales / To Invoice / Orders to Invoice +2. Select sales orders whose invoicing you want to do. +3. Click on *Action > Create invoices*. +4. Select the pickings whose invoicing you want to do. +5. Click on "Create and View Invoices" button. +6. On that moment, the grouping criteria will be applied, and you will see + different invoices if the criteria doesn't match for the sales. diff --git a/sale_order_invoicing_picking_filter_groping_criteria/static/description/icon.png b/sale_order_invoicing_picking_filter_groping_criteria/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/sale_order_invoicing_picking_filter_groping_criteria/static/description/icon.png differ diff --git a/sale_order_invoicing_picking_filter_groping_criteria/static/description/icon.svg b/sale_order_invoicing_picking_filter_groping_criteria/static/description/icon.svg new file mode 100644 index 00000000000..a7a26d0932a --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/static/description/icon.svg @@ -0,0 +1,79 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/sale_order_invoicing_picking_filter_groping_criteria/static/description/index.html b/sale_order_invoicing_picking_filter_groping_criteria/static/description/index.html new file mode 100644 index 00000000000..f92d18ab8d6 --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/static/description/index.html @@ -0,0 +1,124 @@ +
+
+
+

Module name

+

This module was written to extend the functionality of ... to support ... and allow you to ...

+
+
+
+ +
+
+
+

Installation

+
+
+

To install this module, you need to: +

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Configuration

+
+
+

To configure this module, you need to: +

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Usage

+
+
+

To use this module, you need to: +

    +
  • ...
  • +
+

+

For further information, please visit: +

+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Known issues / Roadmap

+
+
+

+

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Credits

+
+
+

Contributors

+ +
+
+

Maintainer

+

+ This module is maintained by the OCA.
+ 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.
+ To contribute to this module, please visit http://odoo-community.org.
+ +

+
+
+
diff --git a/sale_order_invoicing_picking_filter_groping_criteria/tests/__init__.py b/sale_order_invoicing_picking_filter_groping_criteria/tests/__init__.py new file mode 100644 index 00000000000..46986072dd1 --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_sale_invoicing diff --git a/sale_order_invoicing_picking_filter_groping_criteria/tests/test_sale_invoicing.py b/sale_order_invoicing_picking_filter_groping_criteria/tests/test_sale_invoicing.py new file mode 100644 index 00000000000..4a864b48479 --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/tests/test_sale_invoicing.py @@ -0,0 +1,107 @@ +# Copyright 2024 Alberto Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestSaleInvoiging(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env( + context=dict( + cls.env.context, + mail_create_nolog=True, + mail_create_nosubscribe=True, + mail_notrack=True, + no_reset_password=True, + tracking_disable=True, + ) + ) + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.partner = cls.env["res.partner"].create({"name": "Test partner"}) + cls.partner_delivery1 = cls.env["res.partner"].create( + { + "name": "Test delivery 1", + "type": "delivery", + "company_type": "person", + "parent_id": cls.partner.id, + } + ) + cls.partner_delivery2 = cls.env["res.partner"].create( + { + "name": "Test delivery 2", + "type": "delivery", + "company_type": "person", + "parent_id": cls.partner.id, + } + ) + cls.product = cls.env["product.product"].create( + {"name": "Test product", "type": "product"} + ) + cls.GroupingCriteria = cls.env["sale.invoicing.grouping.criteria"] + cls.grouping_criteria = cls.GroupingCriteria.create( + { + "name": "Delivery Address", + "field_ids": [ + (4, cls.env.ref("sale.field_sale_order__partner_shipping_id").id) + ], + } + ) + cls.partner.sale_invoicing_grouping_criteria_id = cls.grouping_criteria + cls.order = cls.env["sale.order"].create( + { + "partner_id": cls.partner.id, + "partner_shipping_id": cls.partner_delivery1.id, + "partner_invoice_id": cls.partner.id, + "pricelist_id": cls.partner.property_product_pricelist.id, + "order_line": [ + ( + 0, + 0, + { + "name": cls.product.name, + "product_id": cls.product.id, + "price_unit": 20, + "product_uom_qty": 1, + "product_uom": cls.product.uom_id.id, + }, + ) + ], + } + ) + cls.order.action_confirm() + cls.order2 = cls.order.copy() + cls.order2.partner_shipping_id = cls.partner_delivery2 + cls.order2.action_confirm() + + for picking in (cls.order + cls.order2).picking_ids: + picking.move_ids.write({"quantity_done": 1}) + picking._action_done() + + def create_invoicing_wizard( + self, order_ids, picking_ids, invoice_service_products=False + ): + return self.env["sale.advance.payment.inv"].create( + { + "sale_order_ids": order_ids, + "advance_payment_method": "delivered", + "stock_picking_ids": picking_ids, + "inv_service_products": invoice_service_products, + } + ) + + def test_invoicing_no_filtering(self): + invoice_ids = (self.order + self.order2)._create_invoices() + self.assertEqual(len(invoice_ids), 2) + self.assertNotEqual(self.order.invoice_ids, self.order2.invoice_ids) + + def test_invoicing_picking_filtering(self): + orders = self.order + self.order2 + wizard = self.create_invoicing_wizard( + orders.mapped("id"), + orders.mapped("picking_ids.id"), + ) + invoice_ids = wizard.create_invoices() + self.assertEqual(len(invoice_ids), 2) + self.assertNotEqual(self.order.invoice_ids, self.order2.invoice_ids) diff --git a/sale_order_invoicing_picking_filter_groping_criteria/wizards/__init__.py b/sale_order_invoicing_picking_filter_groping_criteria/wizards/__init__.py new file mode 100644 index 00000000000..e16f21e7413 --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/wizards/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import sale_advance_payment_inv diff --git a/sale_order_invoicing_picking_filter_groping_criteria/wizards/sale_advance_payment_inv.py b/sale_order_invoicing_picking_filter_groping_criteria/wizards/sale_advance_payment_inv.py new file mode 100644 index 00000000000..a1aa7b4e3ba --- /dev/null +++ b/sale_order_invoicing_picking_filter_groping_criteria/wizards/sale_advance_payment_inv.py @@ -0,0 +1,22 @@ +# Copyright 2024 Alberto Martínez +# 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 _create_invoices(self, sale_orders): + """Slice the batch according grouping criteria.""" + order_groups = {} + for order in self.sale_order_ids: + group_key = order._get_sale_invoicing_group_key() + if group_key not in order_groups: + order_groups[group_key] = order + else: + order_groups[group_key] += order + moves = self.env["account.move"] + for group in order_groups.values(): + moves += super()._create_invoices(group) + return moves diff --git a/setup/sale_order_invoicing_picking_filter_groping_criteria/odoo/addons/sale_order_invoicing_picking_filter_groping_criteria b/setup/sale_order_invoicing_picking_filter_groping_criteria/odoo/addons/sale_order_invoicing_picking_filter_groping_criteria new file mode 120000 index 00000000000..6a4c40c720e --- /dev/null +++ b/setup/sale_order_invoicing_picking_filter_groping_criteria/odoo/addons/sale_order_invoicing_picking_filter_groping_criteria @@ -0,0 +1 @@ +../../../../sale_order_invoicing_picking_filter_groping_criteria \ No newline at end of file diff --git a/setup/sale_order_invoicing_picking_filter_groping_criteria/setup.py b/setup/sale_order_invoicing_picking_filter_groping_criteria/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/sale_order_invoicing_picking_filter_groping_criteria/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)