From 4b403958f539d596dc01a5a0c1f4468d4e202f4a 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 | 2 ++ partner_invoicing_mode_at_shipping/__manifest__.py | 2 +- .../models/stock_picking.py | 7 ++++--- .../readme/CONTRIBUTORS.md | 1 + .../static/description/index.html | 2 ++ .../tests/test_invoice_mode_at_shipping.py | 13 ++++++------- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/partner_invoicing_mode_at_shipping/README.rst b/partner_invoicing_mode_at_shipping/README.rst index 856645b6f98..5781f90a379 100644 --- a/partner_invoicing_mode_at_shipping/README.rst +++ b/partner_invoicing_mode_at_shipping/README.rst @@ -65,6 +65,8 @@ Contributors - Phuc (Tran Thanh) +- Nils Coenen + Other credits ------------- diff --git a/partner_invoicing_mode_at_shipping/__manifest__.py b/partner_invoicing_mode_at_shipping/__manifest__.py index b91a21ced78..2c6f0ea51fe 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.0.1", + "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", diff --git a/partner_invoicing_mode_at_shipping/models/stock_picking.py b/partner_invoicing_mode_at_shipping/models/stock_picking.py index da62d0fbd7c..92cab94703e 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): @@ -11,7 +11,7 @@ def _action_done(self): res = super()._action_done() for picking in self: if picking._invoice_at_shipping(): - picking.with_delay()._invoicing_at_shipping() + picking._invoicing_at_shipping() return res def _invoice_at_shipping(self): @@ -22,6 +22,7 @@ def _invoice_at_shipping(self): and self.sale_id.partner_invoice_id.invoicing_mode == "at_shipping" ) + @api.model def _invoicing_at_shipping(self): self.ensure_one() sales = self._get_sales_order_to_invoice() @@ -36,7 +37,7 @@ def _invoicing_at_shipping(self): if sales_many_invoice_per_order: invoices |= sales_many_invoice_per_order._create_invoices(grouped=False) for invoice in invoices: - invoice.with_delay()._validate_invoice() + invoice._validate_invoice() return invoices or _("Nothing to invoice.") def _get_sales_order_to_invoice(self): diff --git a/partner_invoicing_mode_at_shipping/readme/CONTRIBUTORS.md b/partner_invoicing_mode_at_shipping/readme/CONTRIBUTORS.md index 7d04f82d381..232de87a9bb 100644 --- a/partner_invoicing_mode_at_shipping/readme/CONTRIBUTORS.md +++ b/partner_invoicing_mode_at_shipping/readme/CONTRIBUTORS.md @@ -3,3 +3,4 @@ > - Thierry Ducrest \<\> - Phuc (Tran Thanh) \<\> +- Nils Coenen \<\> diff --git a/partner_invoicing_mode_at_shipping/static/description/index.html b/partner_invoicing_mode_at_shipping/static/description/index.html index 9628056b61d..c176219b68f 100644 --- a/partner_invoicing_mode_at_shipping/static/description/index.html +++ b/partner_invoicing_mode_at_shipping/static/description/index.html @@ -415,6 +415,8 @@

Contributors

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

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

    +
  • 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 b83563d9415..f4a0c7b9b1f 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 @@ -30,7 +30,6 @@ def setUpClass(cls): }, ) ], - "pricelist_id": cls.env.ref("product.list0").id, } ) @@ -40,7 +39,7 @@ 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() @@ -53,7 +52,7 @@ 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() @@ -71,7 +70,7 @@ 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() @@ -91,7 +90,7 @@ 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() @@ -106,7 +105,7 @@ 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( @@ -116,7 +115,7 @@ def test_picking_backorder(self): 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()