OrderChangeManager: add_position() returns a handle to the newly created position (#5557)

* OrderChangeManager: Add support for custom operations

* OrderChangeManager: Add callback to AddPosition operation

This is also meant as a way to fix #5548

* Refs #5557: Checkstyle fix

* Refs #5557: Added tests

* Refs #5557: Changes requested in the PR review

* Refs #5557: Fix error in previous merge conflict

* Refs #5557: PR review
This commit is contained in:
Luca Sorace "Stranck
2026-01-05 17:34:53 +01:00
committed by GitHub
parent 59c09e27fd
commit 8cc12fa1c7
2 changed files with 29 additions and 3 deletions

View File

@@ -2465,6 +2465,16 @@ class OrderChangeManagerTests(TestCase):
assert nop.price == Decimal('12.00')
assert nop.subevent == se1
@classscope(attr='o')
def test_add_item_result_value(self):
res_shirt = self.ocm.add_position(self.shirt, None, None, None)
res_ticket2 = self.ocm.add_position(self.ticket2, None, None, None)
with self.assertRaises(RuntimeError):
_ = res_ticket2.position
self.ocm.commit()
assert res_shirt.position.item == self.shirt
assert res_ticket2.position.item == self.ticket2
@classscope(attr='o')
def test_add_item_with_rounding(self):
self.order.tax_rounding_mode = "sum_by_net"