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 Dec 1, 2024
1 parent 50146a8 commit 5a3e261
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 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>\>
14 changes: 9 additions & 5 deletions partner_invoicing_mode_at_shipping/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down 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 All @@ -427,7 +429,9 @@ <h2><a class="toc-backref" href="#toc-entry-5">Other credits</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class TestInvoiceModeAtShipping(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.partner = cls.env.ref("base.res_partner_1")
cls.product = cls.env.ref("product.product_delivery_01")
cls.so1 = cls.env["sale.order"].create(
Expand All @@ -30,7 +29,6 @@ def setUpClass(cls):
},
)
],
"pricelist_id": cls.env.ref("product.list0").id,
}
)

Expand All @@ -40,7 +38,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 +51,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 +69,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 +89,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 +104,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 +114,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 5a3e261

Please sign in to comment.