Skip to content

Commit

Permalink
[MIG] purchase_reception_notify: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Jan 9, 2025
1 parent 12d6d31 commit 2bc3481
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 50 deletions.
15 changes: 8 additions & 7 deletions purchase_reception_notify/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Purchase Reception Notify
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/17.0/purchase_reception_notify
:target: https://github.com/OCA/purchase-workflow/tree/18.0/purchase_reception_notify
:alt: OCA/purchase-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/purchase-workflow-17-0/purchase-workflow-17-0-purchase_reception_notify
:target: https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_reception_notify
: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/purchase-workflow&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -59,7 +59,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/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 <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_reception_notify%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_reception_notify%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Expand All @@ -74,8 +74,9 @@ Authors
Contributors
------------

- Aaron Henriquez <[email protected]>
- Jordi Ballester <[email protected]>
- Aaron Henriquez <[email protected]>
- Jordi Ballester <[email protected]>
- ``Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>``\ \_

Maintainers
-----------
Expand All @@ -90,6 +91,6 @@ 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.

This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/17.0/purchase_reception_notify>`_ project on GitHub.
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/18.0/purchase_reception_notify>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion purchase_reception_notify/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Purchase Reception Notify",
"version": "17.0.1.0.1",
"version": "18.0.1.0.1",
"category": "Purchase Management",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/purchase-workflow",
Expand Down
8 changes: 4 additions & 4 deletions purchase_reception_notify/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class Picking(models.Model):
def _purchase_order_picking_confirm_message_content(self, picking, purchase_dict):
if not purchase_dict:
purchase_dict = {}
title = _("Receipt confirmation %s") % (picking.name)
message = "<h3>%s</h3>" % title
title = _("Receipt confirmation {}").format(picking.name)
message = f"<h3>{title}</h3>"
message += _(
"The following items have now been received in Incoming Shipment %s:"
) % (picking.name)
"The following items have now been received in Incoming Shipment {}:"
).format(picking.name)
message += "<ul>"
for purchase_line_id in purchase_dict.values():
display_name = purchase_line_id["purchase_line"].product_id.display_name
Expand Down
1 change: 1 addition & 0 deletions purchase_reception_notify/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Aaron Henriquez \<<[email protected]>\>
- Jordi Ballester \<<[email protected]>\>
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`_
7 changes: 4 additions & 3 deletions purchase_reception_notify/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Purchase Reception Notify</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:89ba5ac27372aebfe4ac5ca99325846c6804309fb9c0315a2a4e4430f55b41c8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/purchase-workflow/tree/17.0/purchase_reception_notify"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/purchase-workflow-17-0/purchase-workflow-17-0-purchase_reception_notify"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/purchase-workflow/tree/18.0/purchase_reception_notify"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_reception_notify"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module automatically notifies the employees following a purchase
order as soon as the associated products have been received into stock.</p>
<p>It also introduces a new message subtype specifically created for those
Expand Down Expand Up @@ -404,7 +404,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/purchase-workflow/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_reception_notify%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_reception_notify%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -420,6 +420,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Aaron Henriquez &lt;<a class="reference external" href="mailto:ahenriquez&#64;forgeflow.com">ahenriquez&#64;forgeflow.com</a>&gt;</li>
<li>Jordi Ballester &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
<li><tt class="docutils literal">Heliconia Solutions Pvt. Ltd. <span class="pre">&lt;https://www.heliconia.io&gt;</span></tt>_</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -431,7 +432,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<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>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/purchase-workflow/tree/17.0/purchase_reception_notify">OCA/purchase-workflow</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/purchase-workflow/tree/18.0/purchase_reception_notify">OCA/purchase-workflow</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
80 changes: 45 additions & 35 deletions purchase_reception_notify/tests/test_purchase_reception_notify.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright 2019-2024 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.fields import Datetime
from odoo.tests.common import TransactionCase

Expand All @@ -14,39 +11,52 @@ def setUp(self):
prod_model = self.env["product.product"]
self.product_uom_model = self.env["uom.uom"]

# partners
pa_dict = {"name": "Partner 1"}
self.partner = partner_model.sudo().create(pa_dict)
# Partners
self.partner = partner_model.sudo().create({"name": "Partner 1"})

# Purchase Order Num 1
po_dict = {"partner_id": self.partner.id}
self.purchase_order = self.purchase_order_model.create(po_dict)
# Purchase Order
self.purchase_order = self.purchase_order_model.create(
{"partner_id": self.partner.id}
)
uom_id = self.env.ref("uom.product_uom_unit").id
pr_dict = {
"name": "Product Test",
"uom_id": uom_id,
"purchase_method": "purchase",
}
self.product = prod_model.sudo().create(pr_dict)
pl_dict1 = {
"date_planned": Datetime.now(),
"name": "PO01",
"order_id": self.purchase_order.id,
"product_id": self.product.id,
"product_uom": uom_id,
"price_unit": 1.0,
"product_qty": 5.0,
}
self.purchase_order_line = purchase_order_line_model.sudo().create(pl_dict1)
self.product = prod_model.sudo().create(
{
"name": "Product Test",
"uom_id": uom_id,
"purchase_method": "purchase",
}
)
self.purchase_order_line = purchase_order_line_model.sudo().create(
{
"date_planned": Datetime.now(),
"name": "PO01",
"order_id": self.purchase_order.id,
"product_id": self.product.id,
"product_uom": uom_id,
"price_unit": 1.0,
"product_qty": 5.0,
}
)
self.purchase_order.button_confirm()

def test_reception_notification(self):
# Now we receive the products
for picking in self.purchase_order.picking_ids:
picking.move_ids.write({"quantity": 5.0})
picking.button_validate()
self.assertTrue(
"Receipt confirmation %s" % picking.name
in self.purchase_order_line.order_id.message_ids[0].body,
"PO user not notified",
)
def test_action_done_no_purchase_dict(self):
"""Test that _action_done handles empty purchase_dict correctly."""
# Get the picking related to the purchase order
picking = self.purchase_order.picking_ids

# Ensure the picking has no moves linked to purchase lines
picking.move_ids.write({"purchase_line_id": False})

for move in picking.move_ids:
move.write({"quantity": 5.0})

# Validate the picking to trigger _action_done
picking.button_validate()

# Check that the message is posted without crashing
last_message = self.purchase_order.message_ids[0]
self.assertIn(
"Receipt confirmation",
last_message.body,
"Message should be posted even with an empty purchase_dict",
)

0 comments on commit 2bc3481

Please sign in to comment.