From 150f82d69bb9930f45e483140ed638e24dbb1159 Mon Sep 17 00:00:00 2001 From: Nils Coenen <74965194+NICO-SOLUTIONS@users.noreply.github.com> Date: Mon, 8 Apr 2024 22:25:31 +0200 Subject: [PATCH] [MIG] partner_invoicing_mode_at_shipping: Migration to 17.0 --- partner_invoicing_mode_at_shipping/README.rst | 7 +++++- .../__manifest__.py | 5 +++- .../migrations/16.0.1.1.0/pre-migrate.py | 13 ---------- .../models/__init__.py | 1 - .../models/stock_move.py | 19 --------------- .../models/stock_picking.py | 3 ++- .../readme/CONTRIBUTORS.md | 2 ++ .../readme/CREDITS.md | 2 +- .../static/description/index.html | 7 +++++- .../tests/common.py | 2 -- .../tests/test_invoice_mode_at_shipping.py | 24 +++++++++---------- .../tests/test_invoice_mode_group_delivery.py | 4 ++-- requirements.txt | 2 ++ 13 files changed, 37 insertions(+), 54 deletions(-) delete mode 100644 partner_invoicing_mode_at_shipping/migrations/16.0.1.1.0/pre-migrate.py delete mode 100644 partner_invoicing_mode_at_shipping/models/stock_move.py create mode 100644 requirements.txt diff --git a/partner_invoicing_mode_at_shipping/README.rst b/partner_invoicing_mode_at_shipping/README.rst index e47260cb17b..119dcd6f845 100644 --- a/partner_invoicing_mode_at_shipping/README.rst +++ b/partner_invoicing_mode_at_shipping/README.rst @@ -69,10 +69,15 @@ Contributors - Phuc (Tran Thanh) +- Nils Coenen + +- Chau Le + Other credits ------------- -The development of this module has been financially supported by: +The development and migration of this module has been financially +supported by: - Camptocamp diff --git a/partner_invoicing_mode_at_shipping/__manifest__.py b/partner_invoicing_mode_at_shipping/__manifest__.py index bb14468e348..cfb64ef27fd 100644 --- a/partner_invoicing_mode_at_shipping/__manifest__.py +++ b/partner_invoicing_mode_at_shipping/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Partner Invoicing Mode At Shipping", - "version": "16.0.1.2.0", + "version": "17.0.1.0.0", "summary": "Create invoices automatically when goods are shipped.", "author": "Camptocamp, Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-invoicing", @@ -13,5 +13,8 @@ "views/res_partner.xml", ], "depends": ["account", "partner_invoicing_mode", "queue_job", "stock"], + "external_dependencies": { + "python": ["openupgradelib"], + }, "pre_init_hook": "pre_init_hook", } diff --git a/partner_invoicing_mode_at_shipping/migrations/16.0.1.1.0/pre-migrate.py b/partner_invoicing_mode_at_shipping/migrations/16.0.1.1.0/pre-migrate.py deleted file mode 100644 index d6262c5da7b..00000000000 --- a/partner_invoicing_mode_at_shipping/migrations/16.0.1.1.0/pre-migrate.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2023 ACSONE SA/NV -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from openupgradelib import openupgrade - -# pylint: disable=odoo-addons-relative-import -from odoo.addons.partner_invoicing_mode_at_shipping.hooks import ( - _add_one_invoice_per_shipping, -) - - -@openupgrade.migrate() -def migrate(env, version): - _add_one_invoice_per_shipping(env) diff --git a/partner_invoicing_mode_at_shipping/models/__init__.py b/partner_invoicing_mode_at_shipping/models/__init__.py index eee3b02a332..ddbf4e06b0d 100644 --- a/partner_invoicing_mode_at_shipping/models/__init__.py +++ b/partner_invoicing_mode_at_shipping/models/__init__.py @@ -1,4 +1,3 @@ from . import res_partner -from . import stock_move from . import stock_picking from . import sale_order diff --git a/partner_invoicing_mode_at_shipping/models/stock_move.py b/partner_invoicing_mode_at_shipping/models/stock_move.py deleted file mode 100644 index 7dc6546baed..00000000000 --- a/partner_invoicing_mode_at_shipping/models/stock_move.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2020 Camptocamp SA -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) - -from odoo import models - - -class StockMove(models.Model): - _inherit = "stock.move" - - def _get_related_invoices(self): - """Overridden from stock_account to return the customer invoices - related to this stock move. - """ - invoices = super()._get_related_invoices() - line_invoices = self.sale_line_id.order_id.invoice_ids.filtered( - lambda x: x.state == "posted" - ) - invoices |= line_invoices - return invoices diff --git a/partner_invoicing_mode_at_shipping/models/stock_picking.py b/partner_invoicing_mode_at_shipping/models/stock_picking.py index ee5edfee2a0..ae4d5208967 100644 --- a/partner_invoicing_mode_at_shipping/models/stock_picking.py +++ b/partner_invoicing_mode_at_shipping/models/stock_picking.py @@ -1,7 +1,7 @@ # Copyright 2020 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) -from odoo import _, models +from odoo import _, api, models class StockPicking(models.Model): @@ -27,6 +27,7 @@ def _invoicing_at_shipping_validation(self, invoices): lambda invoice: invoice.partner_id.invoicing_mode == "at_shipping" ) + @api.model def _invoicing_at_shipping(self): self.ensure_one() sales = self._get_sales_order_to_invoice() diff --git a/partner_invoicing_mode_at_shipping/readme/CONTRIBUTORS.md b/partner_invoicing_mode_at_shipping/readme/CONTRIBUTORS.md index 7d04f82d381..fd3082e3509 100644 --- a/partner_invoicing_mode_at_shipping/readme/CONTRIBUTORS.md +++ b/partner_invoicing_mode_at_shipping/readme/CONTRIBUTORS.md @@ -3,3 +3,5 @@ > - Thierry Ducrest \<\> - Phuc (Tran Thanh) \<\> +- Nils Coenen \<\> +- Chau Le \<\> diff --git a/partner_invoicing_mode_at_shipping/readme/CREDITS.md b/partner_invoicing_mode_at_shipping/readme/CREDITS.md index 705d3b30cad..c2d2a1e6b83 100644 --- a/partner_invoicing_mode_at_shipping/readme/CREDITS.md +++ b/partner_invoicing_mode_at_shipping/readme/CREDITS.md @@ -1,3 +1,3 @@ -The development of this module has been financially supported by: +The development and migration of this module has been financially supported by: - Camptocamp diff --git a/partner_invoicing_mode_at_shipping/static/description/index.html b/partner_invoicing_mode_at_shipping/static/description/index.html index f4d54cc6f93..d84384fd192 100644 --- a/partner_invoicing_mode_at_shipping/static/description/index.html +++ b/partner_invoicing_mode_at_shipping/static/description/index.html @@ -418,11 +418,16 @@

Contributors

  • Phuc (Tran Thanh) <phuc@trobz.com>

  • +
  • Nils Coenen <nils.coenen@nico-solutions.de>

    +
  • +
  • Chau Le <chaulb@trobz.com>

    +
  • Other credits

    -

    The development of this module has been financially supported by:

    +

    The development and migration of this module has been financially +supported by:

    • Camptocamp
    diff --git a/partner_invoicing_mode_at_shipping/tests/common.py b/partner_invoicing_mode_at_shipping/tests/common.py index 0d8b587ab21..a2690f3cc9d 100644 --- a/partner_invoicing_mode_at_shipping/tests/common.py +++ b/partner_invoicing_mode_at_shipping/tests/common.py @@ -27,7 +27,6 @@ def setUpClass(cls): }, ) ], - "pricelist_id": cls.env.ref("product.list0").id, } ) @@ -51,6 +50,5 @@ def _create_order(cls): }, ) ], - "pricelist_id": cls.env.ref("product.list0").id, } ) diff --git a/partner_invoicing_mode_at_shipping/tests/test_invoice_mode_at_shipping.py b/partner_invoicing_mode_at_shipping/tests/test_invoice_mode_at_shipping.py index 3621c28964a..254929c81d1 100644 --- a/partner_invoicing_mode_at_shipping/tests/test_invoice_mode_at_shipping.py +++ b/partner_invoicing_mode_at_shipping/tests/test_invoice_mode_at_shipping.py @@ -19,10 +19,10 @@ def test_invoice_created_at_shipping(self): self.so1.action_confirm() for picking in self.so1.picking_ids: for move in picking.move_ids: - move.quantity_done = move.product_uom_qty + move.quantity = move.product_uom_qty picking.action_assign() with mute_logger("odoo.addons.queue_job.delay"): - picking.with_context(test_queue_job_no_delay=True).button_validate() + picking.with_context(queue_job__no_delay=True).button_validate() self.assertEqual(len(self.so1.invoice_ids), 1) self.assertEqual(self.so1.invoice_ids.state, "posted") @@ -32,10 +32,10 @@ def test_invoice_not_created_at_shipping(self): self.so1.action_confirm() for picking in self.so1.picking_ids: for move in picking.move_ids: - move.quantity_done = move.product_uom_qty + move.quantity = move.product_uom_qty picking.action_assign() with mute_logger("odoo.addons.queue_job.delay"): - picking.with_context(test_queue_job_no_delay=True).button_validate() + picking.with_context(queue_job__no_delay=True).button_validate() self.assertEqual(len(self.so1.invoice_ids), 0) def test_picking_multi_order_single_invoice(self): @@ -50,10 +50,10 @@ def test_picking_multi_order_single_invoice(self): so2.picking_ids.move_ids.picking_id = picking # Transfer the remaining picking with moves for move in picking.move_ids: - move.quantity_done = move.product_uom_qty + move.quantity = move.product_uom_qty picking.action_assign() with mute_logger("odoo.addons.queue_job.delay"): - picking.with_context(test_queue_job_no_delay=True).button_validate() + picking.with_context(queue_job__no_delay=True).button_validate() self.assertEqual(len(self.so1.invoice_ids), 1) self.assertEqual(self.so1.invoice_ids.state, "posted") self.assertEqual(self.so1.invoice_ids, so2.invoice_ids) @@ -70,10 +70,10 @@ def test_picking_multi_order_multi_invoice(self): so2.picking_ids.move_ids.picking_id = picking # Transfer the remaining picking with moves for move in picking.move_ids: - move.quantity_done = move.product_uom_qty + move.quantity = move.product_uom_qty picking.action_assign() with mute_logger("odoo.addons.queue_job.delay"): - picking.with_context(test_queue_job_no_delay=True).button_validate() + picking.with_context(queue_job__no_delay=True).button_validate() self.assertEqual(len(self.so1.invoice_ids), 1) self.assertEqual(self.so1.invoice_ids.state, "posted") self.assertEqual(len(so2.invoice_ids), 1) @@ -85,20 +85,20 @@ def test_picking_backorder(self): self.partner.invoicing_mode = "at_shipping" self.so1.action_confirm() picking = self.so1.picking_ids - picking.move_ids.quantity_done = 2 + picking.move_ids.quantity = 2 picking.action_assign() with mute_logger("odoo.addons.queue_job.delay"): picking.with_context( - skip_backorder=True, test_queue_job_no_delay=True + skip_backorder=True, queue_job__no_delay=True ).button_validate() self.assertEqual(len(self.so1.invoice_ids), 1) self.assertEqual(self.so1.invoice_ids.state, "posted") # Now process the backorder backorder = self.so1.picking_ids - picking - backorder.move_ids.quantity_done = 2 + backorder.move_ids.quantity = 2 backorder.action_assign() with mute_logger("odoo.addons.queue_job.delay"): - backorder.with_context(test_queue_job_no_delay=True).button_validate() + backorder.with_context(queue_job__no_delay=True).button_validate() self.assertEqual(len(self.so1.invoice_ids), 2) self.assertTrue( all(invoice.state == "posted") for invoice in self.so1.invoice_ids diff --git a/partner_invoicing_mode_at_shipping/tests/test_invoice_mode_group_delivery.py b/partner_invoicing_mode_at_shipping/tests/test_invoice_mode_group_delivery.py index fa44a7ad3da..7a69359eb9b 100644 --- a/partner_invoicing_mode_at_shipping/tests/test_invoice_mode_group_delivery.py +++ b/partner_invoicing_mode_at_shipping/tests/test_invoice_mode_group_delivery.py @@ -24,7 +24,7 @@ def test_invoice_created_at_shipping_per_delivery(self): picking = self.so1.picking_ids # Deliver partially - picking.move_ids.quantity_done = 2.0 + picking.move_ids.write({"quantity": 2.0, "picked": True}) with trap_jobs() as trap: picking._action_done() trap.assert_enqueued_job( @@ -43,7 +43,7 @@ def test_invoice_created_at_shipping_per_delivery(self): backorder = self.so1.picking_ids - picking self.assertTrue(backorder) - backorder.move_ids.quantity_done = 2.0 + backorder.move_ids.write({"quantity": 2.0, "picked": True}) with trap_jobs() as trap: backorder._action_done() trap.assert_enqueued_job( diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000000..180fc49789b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# generated from manifests external_dependencies +openupgradelib