mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 15:09:20 +00:00
[serial no] Allow creation only of Warehouse is not set, [translation] Italian
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
cur_frm.add_fetch("customer", "customer_name", "customer_name")
|
||||
cur_frm.add_fetch("supplier", "supplier_name", "supplier_name")
|
||||
|
||||
cur_frm.add_fetch("item_code", "item_name", "item_name")
|
||||
cur_frm.add_fetch("item_code", "description", "description")
|
||||
cur_frm.add_fetch("item_code", "item_group", "item_group")
|
||||
cur_frm.add_fetch("item_code", "brand", "brand")
|
||||
|
||||
@@ -11,6 +11,7 @@ from webnotes import msgprint, _
|
||||
from controllers.stock_controller import StockController
|
||||
|
||||
class SerialNoCannotCreateDirectError(webnotes.ValidationError): pass
|
||||
class SerialNoCannotCannotChangeError(webnotes.ValidationError): pass
|
||||
|
||||
class DocType(StockController):
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@@ -19,8 +20,9 @@ class DocType(StockController):
|
||||
self.via_stock_ledger = False
|
||||
|
||||
def validate(self):
|
||||
if self.doc.fields.get("__islocal") and not self.via_stock_ledger:
|
||||
webnotes.throw(_("Serial No cannot be created directly"), SerialNoCannotCreateDirectError)
|
||||
if self.doc.fields.get("__islocal") and self.doc.warehouse:
|
||||
webnotes.throw(_("New Serial No cannot have Warehouse. Warehouse must be set by Stock Entry or Purchase Receipt"),
|
||||
SerialNoCannotCreateDirectError)
|
||||
|
||||
self.validate_warranty_status()
|
||||
self.validate_amc_status()
|
||||
@@ -47,9 +49,9 @@ class DocType(StockController):
|
||||
item_code, warehouse = webnotes.conn.get_value("Serial No",
|
||||
self.doc.name, ["item_code", "warehouse"])
|
||||
if item_code != self.doc.item_code:
|
||||
webnotes.throw(_("Item Code cannot be changed for Serial No."))
|
||||
webnotes.throw(_("Item Code cannot be changed for Serial No."), SerialNoCannotCannotChangeError)
|
||||
if not self.via_stock_ledger and warehouse != self.doc.warehouse:
|
||||
webnotes.throw(_("Warehouse cannot be changed for Serial No."))
|
||||
webnotes.throw(_("Warehouse cannot be changed for Serial No."), SerialNoCannotCannotChangeError)
|
||||
|
||||
if not self.doc.warehouse and self.doc.status=="Available":
|
||||
self.doc.status = "Not Available"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-16 10:59:15",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-08-14 18:26:23",
|
||||
"modified": "2013-08-16 10:16:00",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -12,9 +12,9 @@
|
||||
"autoname": "field:serial_no",
|
||||
"description": "Distinct unit of an Item",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Other",
|
||||
"document_type": "Master",
|
||||
"icon": "icon-barcode",
|
||||
"in_create": 1,
|
||||
"in_create": 0,
|
||||
"module": "Stock",
|
||||
"name": "__common__",
|
||||
"search_fields": "item_code,status"
|
||||
@@ -58,7 +58,7 @@
|
||||
},
|
||||
{
|
||||
"default": "In Store",
|
||||
"description": "Only Serial Nos with status \"In Store\" can be delivered.",
|
||||
"description": "Only Serial Nos with status \"Available\" can be delivered.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
@@ -96,11 +96,12 @@
|
||||
"oldfieldname": "item_code",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Item",
|
||||
"read_only": 1,
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"description": "Warehouse can only be changed via Stock Entry / Delivery Note / Purchase Receipt",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "warehouse",
|
||||
"fieldtype": "Link",
|
||||
@@ -219,7 +220,7 @@
|
||||
"label": "Creation Time",
|
||||
"no_copy": 1,
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -232,7 +233,7 @@
|
||||
"oldfieldtype": "Currency",
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1,
|
||||
"reqd": 1,
|
||||
"reqd": 0,
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
@@ -250,7 +251,7 @@
|
||||
"label": "Supplier",
|
||||
"no_copy": 1,
|
||||
"options": "Supplier",
|
||||
"read_only": 1
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -337,7 +338,7 @@
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Customer",
|
||||
"print_hide": 1,
|
||||
"read_only": 1,
|
||||
"read_only": 0,
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
|
||||
@@ -16,5 +16,14 @@ class TestSerialNo(unittest.TestCase):
|
||||
def test_cannot_create_direct(self):
|
||||
sr = webnotes.new_bean("Serial No")
|
||||
sr.doc.item_code = "_Test Serialized Item"
|
||||
sr.doc.warehouse = "_Test Warehouse - _TC"
|
||||
sr.doc.serial_no = "_TCSER0001"
|
||||
sr.doc.purchase_rate = 10
|
||||
self.assertRaises(SerialNoCannotCreateDirectError, sr.insert)
|
||||
self.assertRaises(SerialNoCannotCreateDirectError, sr.insert)
|
||||
|
||||
sr.doc.warehouse = None
|
||||
sr.insert()
|
||||
self.assertTrue(sr.doc.name)
|
||||
|
||||
sr.doc.warehouse = "_Test Warehouse - _TC"
|
||||
self.assertTrue(SerialNoCannotCannotChangeError, sr.doc.save)
|
||||
@@ -165,7 +165,6 @@ class DocType(DocListController):
|
||||
sr.doc.serial_no = serial_no
|
||||
sr.doc.status = "Available"
|
||||
sr.doc.item_code = self.doc.item_code
|
||||
sr.doc.warehouse = self.doc.warehouse
|
||||
sr.doc.purchase_rate = self.doc.incoming_rate
|
||||
sr.doc.purchase_document_type = self.doc.voucher_type
|
||||
sr.doc.purchase_document_no = self.doc.voucher_no
|
||||
@@ -173,6 +172,10 @@ class DocType(DocListController):
|
||||
sr.doc.purchase_time = self.doc.posting_time
|
||||
sr.make_controller().via_stock_ledger = True
|
||||
sr.insert()
|
||||
|
||||
# set warehouse
|
||||
sr.doc.warehouse = self.doc.warehouse
|
||||
sr.save()
|
||||
webnotes.msgprint(_("Serial No created") + ": " + sr.doc.name)
|
||||
return sr.doc.name
|
||||
|
||||
|
||||
Reference in New Issue
Block a user