Skip to content

Commit

Permalink
[ADD] sale_order_invoicing_picking_filter_groping_criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
Tisho99 committed Dec 18, 2024
1 parent 5bd8959 commit 729f1fc
Show file tree
Hide file tree
Showing 16 changed files with 493 additions and 0 deletions.
112 changes: 112 additions & 0 deletions sale_order_invoicing_picking_filter_groping_criteria/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/sale-workflow/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/sale-workflow/issues/new?body=module:%20sale_order_invoicing_picking_filter_groping_criteria%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
------------

- `Sygel <https://www.sygel.es>`__:

- 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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-tisho99|

This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/16.0/sale_order_invoicing_picking_filter_groping_criteria>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import wizards
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2024 Alberto Martínez <[email protected]>
# 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",
],
}
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [Sygel](https://www.sygel.es):
- Alberto Martínez
- Valentin Vinagre
- Harald Panten
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Module name</h2>
<p>This module was written to extend the functionality of ... to support ... and allow you to ...</p>
</div>
</div>
</section>

<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Installation</h2>
</div>
<div class="oe_span6">
<p class="oe_mt32">To install this module, you need to:
<ul>
<li>...</li>
</ul>
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<a href="https://www.odoo.com/saas_master/demo?lang=en_US&module=crm">
<img src="crm_sc_01.png">
</a>
</div>
</div>
</div>
</section>

<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Configuration</h2>
</div>
<div class="oe_span6">
<p class="oe_mt32">To configure this module, you need to:
<ul>
<li>...</li>
</ul>
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<a href="https://www.odoo.com/saas_master/demo?lang=en_US&module=crm">
<img src="crm_sc_01.png">
</a>
</div>
</div>
</div>
</section>

<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Usage</h2>
</div>
<div class="oe_span6">
<p class="oe_mt32">To use this module, you need to:
<ul>
<li>...</li>
</ul>
</p>
<p class="oe_mt32">For further information, please visit:
<ul>
<li><a href="https://www.odoo.com/forum/help-1">https://www.odoo.com/forum/help-1</a></li>
</ul>
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<a href="https://www.odoo.com/saas_master/demo?lang=en_US&module=crm">
<img src="crm_sc_01.png">
</a>
</div>
</div>
</div>
</section>

<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Known issues / Roadmap</h2>
</div>
<div class="oe_span6">
<p class="oe_mt32">
<ul>
<li>...</li>
</ul>
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<a href="https://www.odoo.com/saas_master/demo?lang=en_US&module=crm">
<img src="crm_sc_01.png">
</a>
</div>
</div>
</div>
</section>

<section class="oe_container oe_dark">
<div class="oe_row">
<div class="oe_span12">
<h2 class="oe_slogan">Credits</h2>
</div>
<div class="oe_span12">
<h3>Contributors</h3>
<ul>
<li>Firstname Lastname &lt;<a href="mailto:[email protected]">[email protected]</a>&gt;</li>
</ul>
</div>
<div class="oe_span12">
<h3>Maintainer</h3>
<p>
This module is maintained by the OCA.<br/>
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.<br/>
To contribute to this module, please visit <a href="http://odoo-community.org">http://odoo-community.org</a>.<br/>
<a href="http://odoo-community.org"><img class="oe_picture oe_centered" src="http://odoo-community.org/logo.png"></a>
</p>
</div>
</div>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import test_sale_invoicing
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Copyright 2024 Alberto Martínez <[email protected]>
# 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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import sale_advance_payment_inv
Loading

0 comments on commit 729f1fc

Please sign in to comment.