Skip to content

Commit 8477e98

Browse files
committed
[FIX] purchase_duplicate_check: Code review fixing
1 parent 41e2a9d commit 8477e98

File tree

4 files changed

+4
-11
lines changed

4 files changed

+4
-11
lines changed

purchase_duplicate_check/__manifest__.py

-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77
"license": "AGPL-3",
88
"category": "Inventory/Purchase",
99
"website": "https://github.com/OCA/purchase-workflow",
10-
"live_test_url": "https://demo.cetmix.com",
1110
"depends": ["purchase_stock", "confirmation_wizard"],
12-
"external_dependencies": {},
1311
"data": [
1412
"views/purchase_order_views.xml",
1513
"views/res_config_settings_views.xml",
1614
"wizard/confirmation_wizard_views.xml",
1715
],
18-
"assets": {},
1916
"installable": True,
2017
"application": False,
2118
}

purchase_duplicate_check/models/purchase_order.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ def _prepare_pending_orders_message(self, product_id):
1212
:return str: message
1313
"""
1414
message_parts = []
15-
order_lines = self.env["purchase.order.line"].search(
16-
[("product_id", "=", product_id), ("order_id", "in", self.ids)]
17-
)
15+
order_lines = self.order_line.filtered(lambda l: l.product_id.id == product_id)
1816
for line in order_lines:
1917
order = line.order_id
2018
order_href = (

purchase_duplicate_check/models/purchase_order_line.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ def _compute_pending_order_ids(self):
2020
if not product_lines:
2121
return
2222

23-
product_ids = tuple(product_lines.mapped("product_id.id"))
24-
order_ids = tuple(product_lines.mapped("order_id.id"))
25-
23+
product_ids = tuple(product_lines.mapped("product_id")._origin.ids)
24+
order_ids = tuple(product_lines.mapped("order_id")._origin.ids)
2625
if not product_ids:
2726
product_lines.pending_order_ids = False
2827
return

purchase_duplicate_check/tests/test_purchase_order.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from odoo.fields import Date
21
from odoo.tests import Form, TransactionCase
32

43

@@ -43,7 +42,7 @@ def test_prepare_pending_orders_message(self):
4342
"""Test flow where prepare message for purchase order"""
4443
message = self.order1._prepare_pending_orders_message(self.product_2.id)
4544
self.assertFalse(message, "Message must be empty")
46-
expected_message = f"RFQ: <a href='/web#id={self.order1.id}&model=purchase.order'>{self.order1.name}</a> date: {Date.today()} Qty: 10.0<br/>" # noqa
45+
expected_message = f"RFQ: <a href='/web#id={self.order1.id}&model=purchase.order'>{self.order1.name}</a> date: {self.order1.create_date.date()} Qty: 10.0<br/>" # noqa
4746
message = self.order1._prepare_pending_orders_message(self.product_1.id)
4847
self.assertEqual(message, expected_message, "Messages must be the same")
4948

0 commit comments

Comments
 (0)