diff --git a/sale_stock_picking_invoicing/README.rst b/sale_stock_picking_invoicing/README.rst index f127e94d51a5..1409fe21e5d8 100644 --- a/sale_stock_picking_invoicing/README.rst +++ b/sale_stock_picking_invoicing/README.rst @@ -17,13 +17,13 @@ Sales Stock Picking Invocing :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/14.0/sale_stock_picking_invoicing + :target: https://github.com/OCA/account-invoicing/tree/15.0/sale_stock_picking_invoicing :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-14-0/account-invoicing-14-0-sale_stock_picking_invoicing + :target: https://translation.odoo-community.org/projects/account-invoicing-15-0/account-invoicing-15-0-sale_stock_picking_invoicing :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=14.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=15.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -78,6 +78,11 @@ Known issues / Roadmap Changelog ========= +15.0.1.0.0 (2024-10-25) +~~~~~~~~~~~~~~~~~~~~~~~ + +* Migration to version 15.0 . + 14.0.1.0.0 (2024-03-12) ~~~~~~~~~~~~~~~~~~~~~~~ @@ -89,7 +94,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -145,6 +150,6 @@ Current `maintainers `__: |maintainer-mbcosta| |maintainer-renatonlima| -This module is part of the `OCA/account-invoicing `_ project on GitHub. +This module is part of the `OCA/account-invoicing `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_stock_picking_invoicing/__manifest__.py b/sale_stock_picking_invoicing/__manifest__.py index eb46e1c6cabb..495540eb2dd1 100644 --- a/sale_stock_picking_invoicing/__manifest__.py +++ b/sale_stock_picking_invoicing/__manifest__.py @@ -10,7 +10,7 @@ "license": "AGPL-3", "author": "Akretion, Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-invoicing", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "maintainers": ["mbcosta", "renatonlima"], "depends": [ "sale_management", diff --git a/sale_stock_picking_invoicing/models/res_company.py b/sale_stock_picking_invoicing/models/res_company.py index 1cfe0edcf7fd..4d82986d7430 100644 --- a/sale_stock_picking_invoicing/models/res_company.py +++ b/sale_stock_picking_invoicing/models/res_company.py @@ -25,7 +25,6 @@ def _default_sale_invoicing_policy(self): ("sale_order", "Sale Order"), ("stock_picking", "Stock Picking"), ], - string="Sale Invoicing Policy", help="If set to Sale Order, keep native Odoo behaviour for creation of" " invoices from Sale Orders.\n" "If set to Stock Picking, disallow creation of Invoices from Sale Orders" diff --git a/sale_stock_picking_invoicing/readme/HISTORY.rst b/sale_stock_picking_invoicing/readme/HISTORY.rst index b77168b14497..3e569d02c543 100644 --- a/sale_stock_picking_invoicing/readme/HISTORY.rst +++ b/sale_stock_picking_invoicing/readme/HISTORY.rst @@ -1,3 +1,8 @@ +15.0.1.0.0 (2024-10-25) +~~~~~~~~~~~~~~~~~~~~~~~ + +* Migration to version 15.0 . + 14.0.1.0.0 (2024-03-12) ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/sale_stock_picking_invoicing/static/description/index.html b/sale_stock_picking_invoicing/static/description/index.html index 19bf877465e8..afb1e84a132c 100644 --- a/sale_stock_picking_invoicing/static/description/index.html +++ b/sale_stock_picking_invoicing/static/description/index.html @@ -369,7 +369,7 @@

Sales Stock Picking Invocing

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:c39cc35cdfeafd3361156b4cbcf173f922dfd8032d3fa193c0f1deec98237f12 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/account-invoicing Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/account-invoicing Translate me on Weblate Try me on Runboat

This module extends Stock Picking Invoicing implementation to Sale, you can define the ‘Sale Invoicing Policy’:

  • If set to Sale Order, keep native Odoo behaviour for creation of invoices from Sale Orders.
  • @@ -384,15 +384,16 @@

    Sales Stock Picking Invocing

  • Usage
  • Known issues / Roadmap
  • Changelog
  • -
  • Bug Tracker
  • -
  • Credits @@ -427,30 +428,36 @@

    Known issues / Roadmap

    Changelog

    -

    14.0.1.0.0 (2024-03-12)

    +

    15.0.1.0.0 (2024-10-25)

    +
      +
    • Migration to version 15.0 .
    • +
    +
    +
    +

    14.0.1.0.0 (2024-03-12)

    -

    Bug Tracker

    +

    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.

    +feedback.

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

    -

    Credits

    +

    Credits

    -

    Authors

    +

    Authors

    • Akretion
    -

    Other credits

    +

    Other credits

    The development of this module has been financially supported by:

    • Aketion - www.akretion.com
    -

    Maintainers

    +

    Maintainers

    This module is maintained by the OCA.

    Odoo Community Association @@ -482,7 +489,7 @@

    Maintainers

    promote its widespread use.

    Current maintainers:

    mbcosta renatonlima

    -

    This module is part of the OCA/account-invoicing project on GitHub.

    +

    This module is part of the OCA/account-invoicing project on GitHub.

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

    diff --git a/sale_stock_picking_invoicing/tests/test_sale_stock.py b/sale_stock_picking_invoicing/tests/test_sale_stock.py index aec6e54ee9a6..39838d4f8911 100644 --- a/sale_stock_picking_invoicing/tests/test_sale_stock.py +++ b/sale_stock_picking_invoicing/tests/test_sale_stock.py @@ -8,10 +8,10 @@ # from stock_picking_invoicing # https://github.com/OCA/account-invoicing/blob/16.0/ # stock_picking_invoicing/tests/common.py -from odoo.tests import Form, SavepointCase +from odoo.tests import Form, TransactionCase -class TestSaleStock(SavepointCase): +class TestSaleStock(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -30,12 +30,10 @@ def setUpClass(cls): company.sale_invoicing_policy = "stock_picking" def _run_picking_onchanges(self, record): - record.onchange_picking_type() record.onchange_partner_id() def _run_line_onchanges(self, record): - record.onchange_product() - record.onchange_product_uom() + record._onchange_product_id() def picking_move_state(self, picking): self._run_picking_onchanges(picking) @@ -203,7 +201,7 @@ def test_picking_sale_order_product_and_service(self): } payment = ( self.env["sale.advance.payment.inv"] - .with_context(context) + .with_context(**context) .create( { "advance_payment_method": "delivered", @@ -211,7 +209,7 @@ def test_picking_sale_order_product_and_service(self): ) ) with self.assertRaises(exceptions.UserError): - payment.with_context(context).create_invoices() + payment.with_context(**context).create_invoices() invoice = self.create_invoice_wizard(picking) self.assertEqual(picking.invoice_state, "invoiced") @@ -416,7 +414,7 @@ def test_down_payment(self): # DownPayment payment_wizard = ( self.env["sale.advance.payment.inv"] - .with_context(context) + .with_context(**context) .create( { "advance_payment_method": "percentage", @@ -442,10 +440,6 @@ def test_down_payment(self): limit=1, ) payment_register.journal_id = journal_cash - payment_method_manual_in = self.env.ref( - "account.account_payment_method_manual_in" - ) - payment_register.payment_method_id = payment_method_manual_in payment_register.amount = invoice_down_payment.amount_total payment_register.save()._create_payments() diff --git a/sale_stock_picking_invoicing/wizards/stock_invoice_onshipping.py b/sale_stock_picking_invoicing/wizards/stock_invoice_onshipping.py index f90a05d6eee1..6b759099dcb1 100644 --- a/sale_stock_picking_invoicing/wizards/stock_invoice_onshipping.py +++ b/sale_stock_picking_invoicing/wizards/stock_invoice_onshipping.py @@ -200,18 +200,39 @@ def _get_invoice_line_values(self, moves, invoice_values, invoice): return values + def _get_pickings_with_sale(self, invoice_values): + pickings = self._load_pickings() + + # Filter Picking with Sales + picking_in_invoice_values = self.env["stock.picking"] + for line in invoice_values.get("invoice_line_ids"): + if line[2]: + if len(line[2].get("move_line_ids")[0]) == 2: + # [(4, 233)], + move_line_id = line[2].get("move_line_ids")[0][1] + else: + # [(, 0, [51])] + move_line_id = line[2].get("move_line_ids")[0][2] + + move_line = self.env["stock.move"].browse(move_line_id) + picking_in_invoice_values |= move_line.mapped("picking_id") + + sale_pickings = pickings.filtered( + lambda pk: pk.sale_id + # Check Sales Ungrouped + and pk.id in picking_in_invoice_values.ids + ) + + return sale_pickings + def _create_invoice(self, invoice_values): """Override this method if you need to change any values of the invoice and the lines before the invoice creation :param invoice_values: dict with the invoice and its lines :return: invoice """ - pickings = self._load_pickings() - sale_pickings = pickings.filtered( - lambda pk: pk.sale_id - # Check Sales Ungrouped - and pk.id in invoice_values.get("picking_ids")[0][2] - ) + sale_pickings = self._get_pickings_with_sale(invoice_values) + # Refund case don't included Section, Note or DownPayments if not sale_pickings or self._get_invoice_type() == "out_refund": return super()._create_invoice(invoice_values) diff --git a/setup/sale_stock_picking_invoicing/odoo/addons/sale_stock_picking_invoicing b/setup/sale_stock_picking_invoicing/odoo/addons/sale_stock_picking_invoicing new file mode 120000 index 000000000000..b1a0bd1ec36e --- /dev/null +++ b/setup/sale_stock_picking_invoicing/odoo/addons/sale_stock_picking_invoicing @@ -0,0 +1 @@ +../../../../sale_stock_picking_invoicing \ No newline at end of file diff --git a/setup/sale_stock_picking_invoicing/setup.py b/setup/sale_stock_picking_invoicing/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/sale_stock_picking_invoicing/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)