Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions purchase_request/tests/test_purchase_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def test_purchase_request_status(self):
with self.assertRaises(UserError):
purchase_request_line.unlink()
purchase = purchase_request_line.purchase_lines.order_id
purchase_request_line.purchase_lines.price_unit = 100.0
purchase.button_done()
self.assertEqual(purchase.state, "done")

Expand Down
14 changes: 10 additions & 4 deletions purchase_request/tests/test_purchase_request_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ def test_purchase_request_allocation(self):
active_ids=[purchase_request_line1.id, purchase_request_line2.id],
).create(vals)
wiz_id.make_purchase_order()
(
purchase_request_line1 + purchase_request_line2
).purchase_lines.price_unit = 100.0
purchase_request1.action_view_purchase_order()
po_line = purchase_request_line1.purchase_lines[0]
# Add unit price in PO Line
po_line.write({"price_unit": 10})
purchase = po_line.order_id
purchase.order_line.action_open_request_line_tree_view()
purchase.button_confirm()
Expand Down Expand Up @@ -157,10 +158,9 @@ def test_purchase_request_allocation_services(self):
active_model="purchase.request.line", active_ids=[purchase_request_line1.id]
).create(vals)
wiz_id.make_purchase_order()
purchase_request_line1.purchase_lines.price_unit = 100.0
purchase_request1.action_view_purchase_order()
po_line = purchase_request_line1.purchase_lines[0]
# Add unit price in PO Line
po_line.write({"price_unit": 10})
purchase = po_line.order_id
purchase.button_confirm()
self.assertEqual(purchase_request_line1.qty_in_progress, 2.0)
Expand Down Expand Up @@ -191,6 +191,7 @@ def test_purchase_request_allocation_services(self):
active_model="purchase.request.line", active_ids=[purchase_request_line2.id]
).create(vals)
wiz_id.make_purchase_order()
purchase_request_line2.purchase_lines.price_unit = 100.0
(purchase_request1 + purchase_request2).action_view_purchase_order()
po_line = purchase_request_line2.purchase_lines[0]
purchase2 = po_line.order_id
Expand Down Expand Up @@ -229,6 +230,7 @@ def test_purchase_request_allocation_min_qty(self):
active_model="purchase.request.line", active_ids=[purchase_request_line1.id]
).create(vals)
wiz_id.make_purchase_order()
purchase_request_line1.purchase_lines.price_unit = 100.0
self.assertEqual(
purchase_request_line1.purchase_request_allocation_ids[0].open_product_qty,
2.0,
Expand Down Expand Up @@ -265,6 +267,9 @@ def test_purchase_request_stock_allocation(self):
).create(vals)
# Create PO
wiz_id.make_purchase_order()
(
purchase_request_line1 + purchase_request_line2
).purchase_lines.price_unit = 100.0
po_line = purchase_request_line1.purchase_lines[0]
self.assertEqual(po_line.product_qty, 2, "Quantity should be 2")
self.assertEqual(
Expand Down Expand Up @@ -349,6 +354,7 @@ def test_purchase_request_stock_allocation_unlink(self):
).create(vals)
# Create PO
wiz_id.make_purchase_order()
purchase_request_line1.purchase_lines.price_unit = 100.0
po_line = purchase_request_line1.purchase_lines[0]
self.assertEqual(
purchase_request_line1.purchase_request_allocation_ids[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,17 @@ def _post_process_po_line(self, item, po_line, new_pr_line):
new_qty = self.env["purchase.request.line"]._calc_new_qty(
line, po_line=po_line, new_pr_line=new_pr_line
)
po_line.product_qty = new_qty
if item.keep_estimated_cost:
po_line.price_unit = price_unit
po_line._compute_amount()
# The quantity update triggers a compute method that alters the
# unit price (which is what we want, to honor graduate pricing)
# but also the scheduled date which is what we don't want.
date_required = line.date_required
po_line.date_planned = datetime(
date_planned = datetime(
date_required.year, date_required.month, date_required.day
)
po_line.write({"product_qty": new_qty, "date_planned": date_planned})
if item.keep_estimated_cost:
po_line.price_unit = price_unit
po_line._compute_amount()


class PurchaseRequestLineMakePurchaseOrderItem(models.TransientModel):
Expand Down