[item] [naming] by series or code / [naming series] optionally set number of digits

This commit is contained in:
Rushabh Mehta 2013-05-02 15:36:33 +05:30
parent 88f6acdbe4
commit f5f478ee78
8 changed files with 108 additions and 22 deletions

View File

@ -1,6 +1,8 @@
erpnext.updates = [ erpnext.updates = [
["2nd May", ["Buying: Warehouse must belong to same company as transaction", ["2nd May", ["Buying: Warehouse must belong to same company as transaction",
"Price List": "Added Currency Field. One price list can have only one currency"]], "Price List: Added Currency Field. One price list can have only one currency",
"Item: Naming can now be by series or item code",
"Naming Series: Set number of digits in series (optionally)"]],
["18th April", ["Cost Center: Set a default Cost Center for a Company"]], ["18th April", ["Cost Center: Set a default Cost Center for a Company"]],
["12th April", ["Employee: List of Leave Approvers who can approve the Employee's Leave Applications"]], ["12th April", ["Employee: List of Leave Approvers who can approve the Employee's Leave Applications"]],
["10th April", ["Redesigned File Uploads and added File Manager in Setup"]], ["10th April", ["Redesigned File Uploads and added File Manager in Setup"]],

View File

@ -31,6 +31,7 @@ keydict = {
'item_group': 'default_item_group', 'item_group': 'default_item_group',
'customer_group': 'default_customer_group', 'customer_group': 'default_customer_group',
'cust_master_name': 'cust_master_name', 'cust_master_name': 'cust_master_name',
"item_naming_by": "item_naming_by",
'supplier_type': 'default_supplier_type', 'supplier_type': 'default_supplier_type',
'supp_master_name': 'supp_master_name', 'supp_master_name': 'supp_master_name',
'territory': 'default_territory', 'territory': 'default_territory',

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-03-25 11:08:14", "creation": "2013-04-01 15:05:24",
"docstatus": 0, "docstatus": 0,
"modified": "2013-03-28 15:41:03", "modified": "2013-05-02 15:05:21",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -27,8 +27,6 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"doctype": "DocPerm", "doctype": "DocPerm",
"name": "__common__", "name": "__common__",
@ -167,6 +165,13 @@
"read_only": 0, "read_only": 0,
"width": "50%" "width": "50%"
}, },
{
"doctype": "DocField",
"fieldname": "item_naming_by",
"fieldtype": "Select",
"label": "Item Naming By",
"options": "Item Code\nNaming Series"
},
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "default_item_group", "fieldname": "default_item_group",
@ -502,6 +507,11 @@
"label": "SMS Sender Name", "label": "SMS Sender Name",
"read_only": 0 "read_only": 0
}, },
{
"amend": 0,
"cancel": 0,
"doctype": "DocPerm"
},
{ {
"doctype": "DocPerm" "doctype": "DocPerm"
} }

View File

@ -123,7 +123,14 @@ class DocType:
def validate_series_name(self, n): def validate_series_name(self, n):
import re import re
if not re.match('[a-zA-Z0-9]+(([-/][a-zA-Z0-9])?[-/][a-zA-Z0-9]*)*',n): if "." in n:
parts = n.split(".")
if len(parts) > 2:
msgprint("Only one dot (.) allowed in " + n, raise_exception=1)
if not re.match("#+$", parts[-1]):
msgprint("Numbering series must be in hashes (e.g. ####)", raise_exception=1)
n = n[0]
if not re.match("^[a-zA-Z0-9-/]*$", n):
msgprint('Special Characters except "-" and "/" not allowed in naming series') msgprint('Special Characters except "-" and "/" not allowed in naming series')
raise Exception raise Exception

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-01-10 16:34:23", "creation": "2013-01-25 11:35:08",
"docstatus": 0, "docstatus": 0,
"modified": "2013-01-22 14:56:34", "modified": "2013-05-02 15:34:41",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -25,8 +25,6 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"doctype": "DocPerm", "doctype": "DocPerm",
"name": "__common__", "name": "__common__",
@ -62,7 +60,7 @@
"fieldname": "help_html", "fieldname": "help_html",
"fieldtype": "HTML", "fieldtype": "HTML",
"label": "Help HTML", "label": "Help HTML",
"options": "<div class=\"help-box\">\nEdit list of Series in the box below. Each Series Prefix on a new line.<br><br>\nAllowed special characters are \"/\" and \"-\"<br>\nExamples:<br>\nINV-<br>\nINV-10-<br>\nINVK-<br>\n</div>" "options": "<div class=\"well\">\nEdit list of Series in the box below. Rules:\n<ul>\n<li>Each Series Prefix on a new line.</li>\n<li>Allowed special characters are \"/\" and \"-\"</li>\n<li>Optionally, set the number of digits in the series using dot (.) followed by hashes (#). For example, \".####\" means that the series will have four digits. Default is five digits.</li>\n</ul>\nExamples:<br>\nINV-<br>\nINV-10-<br>\nINVK-<br>\nINV-.####<br>\n</div>"
}, },
{ {
"doctype": "DocField", "doctype": "DocField",

View File

@ -20,7 +20,11 @@ cur_frm.cscript.refresh = function(doc) {
// make sensitive fields(has_serial_no, is_stock_item, valuation_method) // make sensitive fields(has_serial_no, is_stock_item, valuation_method)
// read only if any stock ledger entry exists // read only if any stock ledger entry exists
cur_frm.toggle_enable("item_code", doc.__islocal); cur_frm.toggle_display("naming_series", sys_defaults.item_naming_by=="Naming Series"
&& doc.__islocal)
cur_frm.toggle_display("item_code", sys_defaults.item_naming_by!="Naming Series"
&& doc.__islocal)
if ((!doc.__islocal) && (doc.is_stock_item == 'Yes')) { if ((!doc.__islocal) && (doc.is_stock_item == 'Yes')) {
var callback = function(r, rt) { var callback = function(r, rt) {

View File

@ -27,6 +27,13 @@ from webnotes.model.controller import DocListController
class PriceListCurrencyMismatch(Exception): pass class PriceListCurrencyMismatch(Exception): pass
class DocType(DocListController): class DocType(DocListController):
def autoname(self):
if webnotes.conn.get_default("item_naming_by")=="Naming Series":
from webnotes.model.doc import make_autoname
self.doc.item_code = make_autoname(self.doc.naming_series+'.#####')
self.doc.name = self.doc.item_code
def validate(self): def validate(self):
if not self.doc.stock_uom: if not self.doc.stock_uom:
msgprint(_("Please enter Default Unit of Measure"), raise_exception=1) msgprint(_("Please enter Default Unit of Measure"), raise_exception=1)

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-03-28 15:56:38", "creation": "2013-04-25 10:56:55",
"docstatus": 0, "docstatus": 0,
"modified": "2013-04-23 11:44:39", "modified": "2013-05-02 15:10:53",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -34,7 +34,6 @@
"parent": "Item", "parent": "Item",
"parentfield": "permissions", "parentfield": "permissions",
"parenttype": "DocType", "parenttype": "DocType",
"permlevel": 0,
"read": 1, "read": 1,
"submit": 0 "submit": 0
}, },
@ -51,6 +50,13 @@
"oldfieldtype": "Section Break", "oldfieldtype": "Section Break",
"read_only": 0 "read_only": 0
}, },
{
"doctype": "DocField",
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Naming Series",
"options": "\nITEM"
},
{ {
"description": "Item will be saved by this name in the data base.", "description": "Item will be saved by this name in the data base.",
"doctype": "DocField", "doctype": "DocField",
@ -877,17 +883,12 @@
"label": "Website Description", "label": "Website Description",
"read_only": 0 "read_only": 0
}, },
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Material Master Manager",
"write": 1
},
{ {
"cancel": 0, "cancel": 0,
"create": 0, "create": 0,
"doctype": "DocPerm", "doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "Material Manager", "role": "Material Manager",
"write": 0 "write": 0
}, },
@ -895,7 +896,63 @@
"cancel": 0, "cancel": 0,
"create": 0, "create": 0,
"doctype": "DocPerm", "doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material Manager",
"write": 0
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "Material User", "role": "Material User",
"write": 0 "write": 0
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material User",
"write": 0
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material Master Manager",
"write": 1
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "Material Master Manager",
"write": 0
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "System Manager",
"write": 1
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "System Manager",
"write": 0
} }
] ]