fix: clear "Retain Sample" and "Max Sample Quantity" in Item card if Has Batch No is uncheck (#30307)
This commit is contained in:
parent
4859574233
commit
ca8d757691
@ -107,6 +107,7 @@ class Item(Document):
|
|||||||
self.validate_variant_attributes()
|
self.validate_variant_attributes()
|
||||||
self.validate_variant_based_on_change()
|
self.validate_variant_based_on_change()
|
||||||
self.validate_fixed_asset()
|
self.validate_fixed_asset()
|
||||||
|
self.clear_retain_sample()
|
||||||
self.validate_retain_sample()
|
self.validate_retain_sample()
|
||||||
self.validate_uom_conversion_factor()
|
self.validate_uom_conversion_factor()
|
||||||
self.validate_customer_provided_part()
|
self.validate_customer_provided_part()
|
||||||
@ -209,6 +210,13 @@ class Item(Document):
|
|||||||
frappe.throw(_("{0} Retain Sample is based on batch, please check Has Batch No to retain sample of item").format(
|
frappe.throw(_("{0} Retain Sample is based on batch, please check Has Batch No to retain sample of item").format(
|
||||||
self.item_code))
|
self.item_code))
|
||||||
|
|
||||||
|
def clear_retain_sample(self):
|
||||||
|
if not self.has_batch_no:
|
||||||
|
self.retain_sample = None
|
||||||
|
|
||||||
|
if not self.retain_sample:
|
||||||
|
self.sample_quantity = None
|
||||||
|
|
||||||
def add_default_uom_in_conversion_factor_table(self):
|
def add_default_uom_in_conversion_factor_table(self):
|
||||||
if not self.is_new() and self.has_value_changed("stock_uom"):
|
if not self.is_new() and self.has_value_changed("stock_uom"):
|
||||||
self.uoms = []
|
self.uoms = []
|
||||||
|
@ -656,6 +656,20 @@ class TestItem(FrappeTestCase):
|
|||||||
make_stock_entry(qty=1, item_code=item.name, target="_Test Warehouse - _TC", posting_date = add_days(today(), 5))
|
make_stock_entry(qty=1, item_code=item.name, target="_Test Warehouse - _TC", posting_date = add_days(today(), 5))
|
||||||
self.consume_item_code_with_differet_stock_transactions(item_code=item.name)
|
self.consume_item_code_with_differet_stock_transactions(item_code=item.name)
|
||||||
|
|
||||||
|
@change_settings("Stock Settings", {"sample_retention_warehouse": 0})
|
||||||
|
def test_retain_sample(self):
|
||||||
|
frappe.db.set_single_value('Stock Settings', 'sample_retention_warehouse', '_Test Retain Sample Warehouse')
|
||||||
|
item = make_item("_TestRetainSample", {'has_batch_no': 1, 'retain_sample': 1, 'sample_quantity': 1})
|
||||||
|
|
||||||
|
self.assertEqual(item.has_batch_no, 1)
|
||||||
|
self.assertEqual(item.retain_sample, 1)
|
||||||
|
self.assertEqual(item.sample_quantity, 1)
|
||||||
|
|
||||||
|
item.has_batch_no = None
|
||||||
|
item.save()
|
||||||
|
self.assertEqual(item.retain_sample, None)
|
||||||
|
self.assertEqual(item.sample_quantity, None)
|
||||||
|
item.delete()
|
||||||
|
|
||||||
def consume_item_code_with_differet_stock_transactions(self, item_code, warehouse="_Test Warehouse - _TC"):
|
def consume_item_code_with_differet_stock_transactions(self, item_code, warehouse="_Test Warehouse - _TC"):
|
||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||||
|
@ -60,5 +60,12 @@
|
|||||||
"warehouse_name": "_Test Warehouse Group-C2",
|
"warehouse_name": "_Test Warehouse Group-C2",
|
||||||
"is_group": 0,
|
"is_group": 0,
|
||||||
"parent_warehouse": "_Test Warehouse Group - _TC"
|
"parent_warehouse": "_Test Warehouse Group - _TC"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Warehouse",
|
||||||
|
"warehouse_name": "_Test Retain Sample Warehouse",
|
||||||
|
"parent_warehouse": "_Test Warehouse Group - _TC",
|
||||||
|
"is_group": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user