1
0
forked from erp-dev/erp

fix: comsume_detial_ids

This commit is contained in:
2026-02-02 18:29:17 +08:00
parent 117e13195c
commit 9c07d7d85a
4 changed files with 48 additions and 3 deletions

View File

@@ -28,11 +28,32 @@ class SalesOrderServiceTestCase(TestCase):
self.relaxed_items = [
{'product_id': self.product.id, 'quantity': 80, 'num_of_rolls': 2, 'price': '28.0', 'unit': ''}
]
stock_record = stock_models.StockChangeRecord.objects.create(
merchant=self.merchant,
type=stock_models.StockChangeTypeEnum.ADD,
warehouse=self.warehouse_strict_out,
source_type=stock_models.StockChangeSourceEnum.PURCHASE,
created_by=self.user,
)
stock_detail_1 = stock_models.StockChangeDetail.objects.create(
merchant=self.merchant,
product=self.product,
unit=self.product.unit,
stock_change_record=stock_record,
quantity='6',
)
stock_detail_2 = stock_models.StockChangeDetail.objects.create(
merchant=self.merchant,
product=self.product,
unit=self.product.unit,
stock_change_record=stock_record,
quantity='4',
)
self.strict_out_items = [
{
'product_id': self.product.id,
'consume_detail_ids': [1, 2],
'quantity': 40,
'consume_detail_ids': [stock_detail_1.id, stock_detail_2.id],
'quantity': 10,
'price': '32.0',
'unit': '',
}
@@ -169,7 +190,9 @@ class SalesOrderServiceTestCase(TestCase):
created_by=self.user,
)
item = sales_order.items.first()
self.assertEqual(item.consume_detail_ids, '1,2')
consume_ids = [str(value) for value in self.strict_out_items[0]['consume_detail_ids']]
self.assertEqual(item.consume_detail_ids, ','.join(consume_ids))
self.assertEqual(item.quantity_of_rolls, '6,4')
def test_sales_order_outgoing_missing_consume_ids_raises(self):
payload = [