Skip to content

Commit

Permalink
[MIG] partner_invoicing_mode_at_shipping: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NICO-SOLUTIONS committed Apr 8, 2024
1 parent b408c15 commit 4b40395
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
2 changes: 2 additions & 0 deletions partner_invoicing_mode_at_shipping/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Contributors

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

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

Other credits
-------------

Expand Down
2 changes: 1 addition & 1 deletion partner_invoicing_mode_at_shipping/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions partner_invoicing_mode_at_shipping/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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):
Expand All @@ -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()
Expand All @@ -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):
Expand Down
1 change: 1 addition & 0 deletions partner_invoicing_mode_at_shipping/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
> - Thierry Ducrest \<<thierry.ducrest@camptocamp.com>\>
- Phuc (Tran Thanh) \<<phuc@trobz.com>\>
- Nils Coenen \<<nils.coenen@nico-solutions.de>\>
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
</li>
<li><p class="first">Phuc (Tran Thanh) &lt;<a class="reference external" href="mailto:phuc&#64;trobz.com">phuc&#64;trobz.com</a>&gt;</p>
</li>
<li><p class="first">Nils Coenen &lt;<a class="reference external" href="mailto:nils.coenen&#64;nico-solutions.de">nils.coenen&#64;nico-solutions.de</a>&gt;</p>
</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def setUpClass(cls):
},
)
],
"pricelist_id": cls.env.ref("product.list0").id,
}
)

Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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(
Expand All @@ -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()
Expand Down

0 comments on commit 4b40395

Please sign in to comment.