[naming series] create, remove Property Setters to set naming fixes webnotes/erpnext#854
This commit is contained in:
parent
5566bcaa0e
commit
70d7c481e9
@ -13,4 +13,7 @@ class DocType:
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]:
|
for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]:
|
||||||
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
|
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
|
||||||
|
|
||||||
|
from setup.doctype.naming_series.naming_series import set_by_naming_series
|
||||||
|
set_by_naming_series("Supplier", "supplier_name",
|
||||||
|
self.doc.get("supp_master_name")=="Naming Series", hide_name_field=False)
|
||||||
|
@ -9,10 +9,7 @@ cur_frm.cscript.onload = function(doc,dt,dn){
|
|||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc,dt,dn) {
|
cur_frm.cscript.refresh = function(doc,dt,dn) {
|
||||||
cur_frm.cscript.make_dashboard(doc);
|
cur_frm.cscript.make_dashboard(doc);
|
||||||
if(sys_defaults.supp_master_name == 'Supplier Name')
|
erpnext.hide_naming_series();
|
||||||
hide_field('naming_series');
|
|
||||||
else
|
|
||||||
unhide_field('naming_series');
|
|
||||||
|
|
||||||
if(doc.__islocal){
|
if(doc.__islocal){
|
||||||
hide_field(['address_html','contact_html']);
|
hide_field(['address_html','contact_html']);
|
||||||
|
@ -20,12 +20,8 @@ class DocType:
|
|||||||
webnotes.throw(_("Please setup Employee Naming System in Human Resource > HR Settings"))
|
webnotes.throw(_("Please setup Employee Naming System in Human Resource > HR Settings"))
|
||||||
else:
|
else:
|
||||||
if naming_method=='Naming Series':
|
if naming_method=='Naming Series':
|
||||||
if not self.doc.naming_series:
|
|
||||||
webnotes.throw(_("Please select Naming Neries"))
|
|
||||||
self.doc.name = make_autoname(self.doc.naming_series + '.####')
|
self.doc.name = make_autoname(self.doc.naming_series + '.####')
|
||||||
elif naming_method=='Employee Number':
|
elif naming_method=='Employee Number':
|
||||||
if not self.doc.employee_number:
|
|
||||||
webnotes.throw(_("Please enter Employee Number"))
|
|
||||||
self.doc.name = self.doc.employee_number
|
self.doc.name = self.doc.employee_number
|
||||||
|
|
||||||
self.doc.employee = self.doc.name
|
self.doc.employee = self.doc.name
|
||||||
|
@ -13,12 +13,18 @@ class DocType:
|
|||||||
self.doc, self.doclist = d, dl
|
self.doc, self.doclist = d, dl
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.original_stop_birthday_reminders = cint(webnotes.conn.get_value("HR Settings",
|
self.update_birthday_reminders()
|
||||||
None, "stop_birthday_reminders"))
|
|
||||||
|
from setup.doctype.naming_series.naming_series import set_by_naming_series
|
||||||
|
set_by_naming_series("Employee", "employee_number",
|
||||||
|
self.doc.get("emp_created_by")=="Naming Series", hide_name_field=True)
|
||||||
|
|
||||||
def on_update(self):
|
def update_birthday_reminders(self):
|
||||||
|
original_stop_birthday_reminders = cint(webnotes.conn.get_value("HR Settings",
|
||||||
|
None, "stop_birthday_reminders"))
|
||||||
|
|
||||||
# reset birthday reminders
|
# reset birthday reminders
|
||||||
if cint(self.doc.stop_birthday_reminders) != self.original_stop_birthday_reminders:
|
if cint(self.doc.stop_birthday_reminders) != original_stop_birthday_reminders:
|
||||||
webnotes.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and ref_type='Employee'""")
|
webnotes.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and ref_type='Employee'""")
|
||||||
|
|
||||||
if not self.doc.stop_birthday_reminders:
|
if not self.doc.stop_birthday_reminders:
|
||||||
|
10
patches/october_2013/p09_update_naming_series_settings.py
Normal file
10
patches/october_2013/p09_update_naming_series_settings.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import webnotes
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
# reset property setters for series
|
||||||
|
for name in ("Stock Settings", "Selling Settings", "Buying Settings", "HR Settings"):
|
||||||
|
webnotes.bean(name, name).save()
|
@ -228,4 +228,5 @@ patch_list = [
|
|||||||
"patches.october_2013.repost_planned_qty",
|
"patches.october_2013.repost_planned_qty",
|
||||||
"patches.october_2013.p06_rename_packing_list_doctype",
|
"patches.october_2013.p06_rename_packing_list_doctype",
|
||||||
"execute:webnotes.delete_doc('DocType', 'Sales Common')",
|
"execute:webnotes.delete_doc('DocType', 'Sales Common')",
|
||||||
|
"patches.october_2013.p09_update_naming_series_settings",
|
||||||
]
|
]
|
@ -13,7 +13,7 @@ $.extend(erpnext, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
hide_naming_series: function() {
|
hide_naming_series: function() {
|
||||||
if(cur_frm.fields_dict.naming_series) {
|
if(cur_frm.fields_dict.naming_series && !wn.meta.get_docfield(cur_frm.doctype, "naming_series")) {
|
||||||
cur_frm.toggle_display("naming_series", cur_frm.doc.__islocal?true:false);
|
cur_frm.toggle_display("naming_series", cur_frm.doc.__islocal?true:false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -20,10 +20,7 @@ cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_
|
|||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc,dt,dn) {
|
cur_frm.cscript.refresh = function(doc,dt,dn) {
|
||||||
cur_frm.cscript.setup_dashboard(doc);
|
cur_frm.cscript.setup_dashboard(doc);
|
||||||
if(sys_defaults.cust_master_name == 'Customer Name')
|
erpnext.hide_naming_series();
|
||||||
hide_field('naming_series');
|
|
||||||
else
|
|
||||||
unhide_field('naming_series');
|
|
||||||
|
|
||||||
if(doc.__islocal){
|
if(doc.__islocal){
|
||||||
hide_field(['address_html','contact_html']);
|
hide_field(['address_html','contact_html']);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-06-11 14:26:44",
|
"creation": "2013-06-11 14:26:44",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-09-10 10:50:50",
|
"modified": "2013-10-18 16:49:20",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -48,6 +48,16 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"reqd": 0
|
"reqd": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "naming_series",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Document Numbering Series",
|
||||||
|
"no_copy": 1,
|
||||||
|
"options": "\nCUST\nCUSTMUM",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "customer_name",
|
"fieldname": "customer_name",
|
||||||
@ -76,16 +86,6 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "naming_series",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Document Numbering Series",
|
|
||||||
"no_copy": 1,
|
|
||||||
"options": "\nCUST\nCUSTMUM",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"description": "Fetch lead which will be converted into customer.",
|
"description": "Fetch lead which will be converted into customer.",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
|
@ -14,3 +14,7 @@ class DocType:
|
|||||||
for key in ["cust_master_name", "customer_group", "territory", "maintain_same_sales_rate",
|
for key in ["cust_master_name", "customer_group", "territory", "maintain_same_sales_rate",
|
||||||
"editable_price_list_rate", "selling_price_list"]:
|
"editable_price_list_rate", "selling_price_list"]:
|
||||||
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
|
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
|
||||||
|
|
||||||
|
from setup.doctype.naming_series.naming_series import set_by_naming_series
|
||||||
|
set_by_naming_series("Customer", "customer_name",
|
||||||
|
self.doc.get("cust_master_name")=="Naming Series", hide_name_field=False)
|
||||||
|
@ -134,3 +134,20 @@ class DocType:
|
|||||||
msgprint("Series Updated Successfully")
|
msgprint("Series Updated Successfully")
|
||||||
else:
|
else:
|
||||||
msgprint("Please select prefix first")
|
msgprint("Please select prefix first")
|
||||||
|
|
||||||
|
def set_by_naming_series(doctype, fieldname, naming_series, hide_name_field=True):
|
||||||
|
from core.doctype.property_setter.property_setter import make_property_setter
|
||||||
|
if naming_series:
|
||||||
|
make_property_setter(doctype, "naming_series", "hidden", 0, "Check")
|
||||||
|
make_property_setter(doctype, "naming_series", "reqd", 1, "Check")
|
||||||
|
if hide_name_field:
|
||||||
|
make_property_setter(doctype, fieldname, "reqd", 0, "Check")
|
||||||
|
make_property_setter(doctype, fieldname, "hidden", 1, "Check")
|
||||||
|
else:
|
||||||
|
make_property_setter(doctype, "naming_series", "reqd", 0, "Check")
|
||||||
|
make_property_setter(doctype, "naming_series", "hidden", 1, "Check")
|
||||||
|
if hide_name_field:
|
||||||
|
make_property_setter(doctype, fieldname, "hidden", 0, "Check")
|
||||||
|
make_property_setter(doctype, fieldname, "reqd", 1, "Check")
|
||||||
|
|
||||||
|
|
@ -6,11 +6,7 @@ cur_frm.cscript.refresh = function(doc) {
|
|||||||
// read only if any stock ledger entry exists
|
// read only if any stock ledger entry exists
|
||||||
|
|
||||||
cur_frm.cscript.make_dashboard()
|
cur_frm.cscript.make_dashboard()
|
||||||
|
erpnext.hide_naming_series();
|
||||||
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.show_in_website) {
|
if(!doc.__islocal && doc.show_in_website) {
|
||||||
cur_frm.add_custom_button("View In Website", function() {
|
cur_frm.add_custom_button("View In Website", function() {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
self.doc, self.doclist = d, dl
|
self.doc, self.doclist = d, dl
|
||||||
@ -14,3 +15,8 @@ class DocType:
|
|||||||
for key in ["item_naming_by", "item_group", "stock_uom",
|
for key in ["item_naming_by", "item_group", "stock_uom",
|
||||||
"allow_negative_stock"]:
|
"allow_negative_stock"]:
|
||||||
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
|
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
|
||||||
|
|
||||||
|
from setup.doctype.naming_series.naming_series import set_by_naming_series
|
||||||
|
set_by_naming_series("Item", "item_code",
|
||||||
|
self.doc.get("item_naming_by")=="Naming Series", hide_name_field=True)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user