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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Faster order form, reception, bills and budget tabs on large volumes (missing indexes, budget check and prices read in one query)
- An order can no longer be locked by picking, from its form, a status that only the validation workflow should set
- Default order status labels are no longer stored HTML-escaped
- The order item search no longer fails when the product name or manufacturer reference column is displayed, and its price columns have the right labels

## [2.12.12] - 2026-10-06

Expand Down
17 changes: 10 additions & 7 deletions inc/order_item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function rawSearchOptions()
'id' => 1,
'table' => self::getTable(),
'field' => 'price_ati',
'name' => __s('Unit price tax free', 'order'),
'name' => __s('Price ATI', 'order'),
'datatype' => 'decimal',
], [
'id' => 2,
Expand All @@ -144,7 +144,7 @@ public function rawSearchOptions()
'id' => 3,
'table' => self::getTable(),
'field' => 'price_taxfree',
'name' => __s('Discount (%)', 'order'),
'name' => __s('Unit price tax free', 'order'),
'datatype' => 'decimal',
], [
'id' => 4,
Expand All @@ -165,16 +165,19 @@ public function rawSearchOptions()
'injectable' => true,
], [
'id' => 6,
'table' => self::getTable(),
'table' => PluginOrderReference::getTable(),
'field' => 'name',
'name' => __s('Product name', 'order'),
'autocomplete' => true,
'datatype' => 'itemlink',
'itemlink_type' => PluginOrderReference::class,
'massiveaction' => false,
], [
'id' => 7,
'table' => self::getTable(),
'field' => 'reference_code',
'table' => PluginOrderReference::getTable(),
'field' => 'manufacturers_reference',
'name' => __s("Manufacturer's product reference", 'order'),
'autocomplete' => true,
'datatype' => 'string',
'massiveaction' => false,
], [
'id' => 16,
'table' => self::getTable(),
Expand Down
32 changes: 32 additions & 0 deletions tests/Units/OrderItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use PluginOrderOrder;
use PluginOrderOrder_Item;
use PluginOrderReference;
use Search;

final class OrderItemTest extends DbTestCase
{
Expand Down Expand Up @@ -124,6 +125,36 @@ public function testUpdateDiscountAppliesToItemOfCurrentOrder(): void
$this->assertEquals(50, (float) $order_item->fields['price_discounted']);
}

public function testSearchWithAllColumnsDisplayed(): void
{
$this->login();

[$order_item] = $this->createItemInOrderAndForeignOrder();
$reference_id = (int) $order_item->fields['plugin_order_references_id'];
$this->updateItem(PluginOrderReference::class, $reference_id, [
'manufacturers_reference' => 'MFR-REF-42',
]);

$options = array_filter(
array_keys(Search::getOptions(PluginOrderOrder_Item::class)),
'is_int',
);

$data = Search::getDatas(PluginOrderOrder_Item::class, [
'criteria' => [[
'field' => 7,
'searchtype' => 'contains',
'value' => 'MFR-REF-42',
],
],
], $options);

$this->assertSame(1, $data['data']['totalcount']);
$row = $data['data']['rows'][0];
$this->assertSame('Order test reference', $row['PluginOrderOrder_Item_6'][0]['name']);
$this->assertSame('MFR-REF-42', $row['PluginOrderOrder_Item_7'][0]['name']);
}

/** @return array{0: PluginOrderOrder_Item, 1: int} */
private function createItemInOrderAndForeignOrder(): array
{
Expand All @@ -150,6 +181,7 @@ private function createItemInOrderAndForeignOrder(): array
]);

$order_item = $this->createItem(PluginOrderOrder_Item::class, [
'entities_id' => $entities_id,
'plugin_order_orders_id' => $order->getID(),
'plugin_order_references_id' => $reference->getID(),
'itemtype' => Computer::class,
Expand Down