refactored defaults, bin material request wip

This commit is contained in:
Rushabh Mehta 2013-02-19 15:27:31 +05:30
parent c53231a841
commit 5117d9c266
31 changed files with 55 additions and 377 deletions

View File

@ -17,11 +17,13 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, cstr, flt, get_defaults, get_first_day, get_last_day, has_common
from webnotes.utils import cint, cstr, flt, get_first_day, get_last_day, has_common
from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
from webnotes import session, msgprint
import webnotes.defaults
sql = webnotes.conn.sql
from accounts.utils import get_balance_on, get_fiscal_year
@ -65,7 +67,7 @@ class DocType:
#--- from month and to month (for MIS - Comparison Report) -------
month_list = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
fiscal_start_month = sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(get_defaults()['fiscal_year']))
fiscal_start_month = sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(webnotes.defaults.get_global_value("fiscal_year")))
fiscal_start_month = fiscal_start_month and fiscal_start_month[0][0] or 1
mon = ['']
for i in range(fiscal_start_month,13): mon.append(month_list[i-1])

View File

@ -17,12 +17,14 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, cint, cstr, flt, formatdate, get_defaults
from webnotes.utils import add_days, cint, cstr, flt, formatdate
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint, _
from setup.utils import get_company_currency
import webnotes.defaults
sql = webnotes.conn.sql
from controllers.buying_controller import BuyingController
@ -32,10 +34,6 @@ class DocType(BuyingController):
self.tname = 'Purchase Invoice Item'
self.fname = 'entries'
# ************************** Trigger Functions ****************************
# Credit To
# ----------
def get_credit_to(self):
acc_head = sql("select name, credit_days from `tabAccount` where (name = %s or (master_name = %s and master_type = 'supplier')) and docstatus != 2", (cstr(self.doc.supplier) + " - " + self.get_company_abbr(),self.doc.supplier))
@ -57,9 +55,6 @@ class DocType(BuyingController):
return ret
# Get Default Cost Center and Expense Head from Item Master
# ----------------------------------------------------------
def get_default_values(self,args):
import json
args = json.loads(args)
@ -73,9 +68,6 @@ class DocType(BuyingController):
ret['cost_center'] = cost_center and cost_center[0][0] or ''
return ret
# Get Items based on PO or PR
# ----------------------------
def pull_details(self):
if self.doc.purchase_receipt_main:
self.validate_duplicate_docname('purchase_receipt')
@ -118,16 +110,9 @@ class DocType(BuyingController):
ret={'add_tax_rate' :rate and flt(rate[0][0]) or 0 }
return ret
# *************************** Server Utility Functions *****************************
# Get Company abbr
# -----------------
def get_company_abbr(self):
return sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
# Check whether PO or PR is already fetched
# ------------------------------------------
def validate_duplicate_docname(self,doctype):
for d in getlist(self.doclist, 'entries'):
if doctype == 'purchase_receipt' and cstr(self.doc.purchase_receipt_main) == cstr(d.purchase_receipt):
@ -138,11 +123,6 @@ class DocType(BuyingController):
msgprint(cstr(self.doc.purchase_order_main) + " purchase order details have already been pulled.")
raise Exception , " Validation Error. "
# **************************** VALIDATE ********************************
# Check for Item.is_Purchase_item = 'Yes' and Item is active
# ------------------------------------------------------------------
def check_active_purchase_items(self):
for d in getlist(self.doclist, 'entries'):
if d.item_code: # extra condn coz item_code is not mandatory in PV
@ -154,8 +134,6 @@ class DocType(BuyingController):
msgprint("Item : '%s' is not Purchase Item"%(d.item_code))
raise Exception
# Check Conversion Rate
# ----------------------
def check_conversion_rate(self):
default_currency = get_company_currency(self.doc.company)
if not default_currency:
@ -259,7 +237,7 @@ class DocType(BuyingController):
raise Exception
# import_rate
rate = flt(sql('select import_rate from `tabPurchase Order Item` where item_code=%s and parent=%s and name = %s', (d.item_code, d.purchase_order, d.po_detail))[0][0])
if abs(rate - flt(d.import_rate)) > 1 and cint(get_defaults('maintain_same_rate')):
if abs(rate - flt(d.import_rate)) > 1 and cint(webnotes.defaults.get_global_default('maintain_same_rate')):
msgprint("Import Rate for %s in the Purchase Order is %s. Rate must be same as Purchase Order Rate" % (d.item_code,rate))
raise Exception
@ -277,9 +255,6 @@ class DocType(BuyingController):
msgprint("Aging Date is mandatory for opening entry")
raise Exception
# Set against account for debit to account
#------------------------------------------
def set_against_expense_account(self):
against_acc = []
for d in getlist(self.doclist, 'entries'):
@ -287,8 +262,6 @@ class DocType(BuyingController):
against_acc.append(d.expense_account)
self.doc.against_expense_account = ','.join(against_acc)
#check in manage account if purchase order required or not.
# ====================================================================================
def po_required(self):
res = sql("select value from `tabSingles` where doctype = 'Global Defaults' and field = 'po_required'")
if res and res[0][0] == 'Yes':
@ -297,8 +270,6 @@ class DocType(BuyingController):
msgprint("Purchse Order No. required against item %s"%d.item_code)
raise Exception
#check in manage account if purchase receipt required or not.
# ====================================================================================
def pr_required(self):
res = sql("select value from `tabSingles` where doctype = 'Global Defaults' and field = 'pr_required'")
if res and res[0][0] == 'Yes':

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import get_defaults
import webnotes.defaults
from accounts.utils import get_balance_on
@webnotes.whitelist()
@ -16,8 +17,8 @@ def get_companies():
if r["role"] in roles and r["match"]=="company"))
# if match == company is specified and companies are specified in user defaults
if match and webnotes.user.get_defaults().get("company"):
return webnotes.user.get_defaults().get("company")
if match:
return webnotes.defaults.get_user_defaults("company")
else:
return [r[0] for r in webnotes.conn.sql("""select name from tabCompany
where docstatus!=2""")]

View File

@ -16,7 +16,9 @@
#get company
from __future__ import unicode_literals
company = filter_values.get('company') or get_defaults()['company']
import webnotes.defaults
company = filter_values.get('company') or webnotes.defaults.get_user_default('company')
# To date
if not filter_values.get('clearance_date1'):

View File

@ -16,7 +16,9 @@
#get company
from __future__ import unicode_literals
company = filter_values.get('company') or get_defaults()['company']
import webnotes.defaults
company = filter_values.get('company') or webnotes.defaults.get_user_default('company')
#get company letter head
l_head = sql("select letter_head from `tabCompany` where name='%s'" % company)

View File

@ -16,7 +16,9 @@
#get company
from __future__ import unicode_literals
company = filter_values.get('company') or get_defaults()['company']
import webnotes.defaults
company = filter_values.get('company') or webnotes.defaults.get_user_default('company')
#get company letter head
l_head = sql("select letter_head from `tabCompany` where name='%s'" % company)

View File

@ -17,7 +17,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt, get_defaults
from webnotes.utils import cstr, flt
from webnotes.model.doc import addchild
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
@ -32,7 +32,6 @@ class DocType(BuyingController):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.defaults = get_defaults()
self.tname = 'Purchase Order Item'
self.fname = 'po_details'

View File

@ -16,8 +16,9 @@
from __future__ import unicode_literals
import webnotes
import webnotes.defaults
from webnotes.utils import cint, get_defaults
from webnotes.utils import cint
from webnotes import msgprint, _
from webnotes.model.doc import make_autoname
@ -35,7 +36,7 @@ class DocType(TransactionBase):
self.add_communication_list()
def autoname(self):
supp_master_name = get_defaults()['supp_master_name']
supp_master_name = webnotes.defaults.get_global_default('supp_master_name')
if supp_master_name == 'Supplier Name':
if webnotes.conn.exists("Customer", self.doc.supplier_name):
@ -98,7 +99,7 @@ class DocType(TransactionBase):
def validate(self):
#validation for Naming Series mandatory field...
if get_defaults()['supp_master_name'] == 'Naming Series':
if webnotes.defaults.get_global_default('supp_master_name') == 'Naming Series':
if not self.doc.naming_series:
msgprint("Series is Mandatory.", raise_exception=1)
@ -161,7 +162,7 @@ class DocType(TransactionBase):
def on_rename(self, new, old):
#update supplier_name if not naming series
if get_defaults().get('supp_master_name') == 'Supplier Name':
if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name':
update_fields = [
('Supplier', 'name'),
('Address', 'supplier'),

View File

@ -26,7 +26,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){
}
cur_frm.cscript.onload_post_render = function(doc,cdt,cdn){
if(doc.__islocal && doc.employee==user_defaults.employee) {
if(doc.__islocal && doc.employee==wn.defaults.get_user_default("employee")) {
cur_frm.set_value("employee", "");
cur_frm.set_value("employee_name", "")
}

View File

@ -16,8 +16,9 @@
from __future__ import unicode_literals
import webnotes
import webnotes.default
from webnotes.utils import cint, cstr, date_diff, formatdate, get_defaults, getdate, now
from webnotes.utils import cint, cstr, date_diff, formatdate, getdate, now
from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
from webnotes import form, msgprint
@ -30,7 +31,6 @@ class DocType:
def __init__(self,d,dt):
self.doc, self.doclist = d,dt
#==========================================================================
def get_att_list(self):
lst = [['Attendance','','','Please fill columns which are Mandatory.',' Please do not modify the structure','',''],['','','','','','',''],['[Mandatory]','','[Mandatory]','[Mandatory]','[Mandatory]','[Mandatory]','[Mandatory]'],['Employee','Employee Name','Attendance Date','Status','Fiscal Year','Company','Naming Series']]
@ -46,7 +46,6 @@ class DocType:
return lst
#------------------------------------------------------------------------------
# get date list inbetween from date and to date
def date_diff_list(self):
import datetime
@ -65,10 +64,9 @@ class DocType:
return dt
#------------------------------------------------------------------------------
def get_att_data(self):
fy = get_defaults()['fiscal_year'] #get default fiscal year
comp = get_defaults()['company'] #get default company
fy = webnotes.defaults.get_global_default('fiscal_year')
comp = webnotes.defaults.get_user_default('company')
#get naming series of attendance
import webnotes.model.doctype
@ -82,7 +80,6 @@ class DocType:
return {'fy':fy,'comp':comp,'sr':sr}
#=================================================================================
def import_att_data(self):
filename = self.doc.file_list.split(',')

View File

@ -175,4 +175,5 @@ patch_list = [
"patches.february_2013.p02_email_digest",
"patches.february_2013.p03_material_request",
"patches.february_2013.p04_remove_old_doctypes",
"execute:webnotes.delete_doc('DocType', 'Plot Control')"
]

View File

@ -17,9 +17,10 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, get_defaults
from webnotes.utils import cstr
from webnotes.model.doc import Document, make_autoname
from webnotes import msgprint, _
import webnotes.defaults
sql = webnotes.conn.sql
@ -34,7 +35,7 @@ class DocType(TransactionBase):
self.add_communication_list()
def autoname(self):
cust_master_name = get_defaults().get('cust_master_name')
cust_master_name = webnotes.defaults.get_global_default('cust_master_name')
if cust_master_name == 'Customer Name':
if webnotes.conn.exists("Supplier", self.doc.customer_name):
msgprint(_("A Supplier exists with same name"), raise_exception=1)
@ -54,7 +55,7 @@ class DocType(TransactionBase):
return g
def validate_values(self):
if get_defaults().get('cust_master_name') == 'Naming Series' and not self.doc.naming_series:
if webnotes.defaults.get_global_default('cust_master_name') == 'Naming Series' and not self.doc.naming_series:
msgprint("Series is Mandatory.")
raise Exception
@ -217,7 +218,7 @@ class DocType(TransactionBase):
def on_rename(self, new, old):
#update customer_name if not naming series
if get_defaults().get('cust_master_name') == 'Customer Name':
if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name':
update_fields = [
('Customer', 'name'),
('Address', 'customer'),

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1,4 +0,0 @@
[
"Selling",
"Plot Control"
]

View File

@ -1,4 +0,0 @@
{
"Plot Control": "\u0645\u0624\u0627\u0645\u0631\u0629 \u0627\u0644\u062a\u062d\u0643\u0645",
"Selling": "\u0628\u064a\u0639"
}

View File

@ -1,4 +0,0 @@
{
"Plot Control": "Parcela de control",
"Selling": "De venta"
}

View File

@ -1,4 +0,0 @@
{
"Plot Control": "Contr\u00f4le Terrain",
"Selling": "Vente"
}

View File

@ -1,4 +0,0 @@
{
"Plot Control": "\u092a\u094d\u0932\u0949\u091f \u0928\u093f\u092f\u0902\u0924\u094d\u0930\u0923",
"Selling": "\u0935\u093f\u0915\u094d\u0930\u092f"
}

View File

@ -1,4 +0,0 @@
{
"Plot Control": "Zemlji\u0161te kontrola",
"Selling": "Prodaja"
}

View File

@ -1,4 +0,0 @@
{
"Plot Control": "Plot Controle",
"Selling": "Selling"
}

View File

@ -1,4 +0,0 @@
{
"Plot Control": "Controle trama",
"Selling": "Vendendo"
}

View File

@ -1,4 +0,0 @@
{
"Plot Control": "\u041f\u043b\u0430\u0446 \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0430",
"Selling": "\u041f\u0440\u043e\u0434\u0430\u0458\u0430"
}

View File

@ -1,4 +0,0 @@
{
"Plot Control": "\u0b9a\u0ba4\u0bbf \u0b95\u0b9f\u0bcd\u0b9f\u0bc1\u0baa\u0bcd\u0baa\u0bbe\u0b9f\u0bc1",
"Selling": "\u0bb5\u0bbf\u0bb1\u0bcd\u0baa\u0ba9\u0bc8"
}

View File

@ -1,237 +0,0 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, cstr, get_defaults, now
from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
sql = webnotes.conn.sql
class DocType:
def __init__(self,doc,doclist = []):
self.doc ,self.doclist = doc, doclist
#============================get monthly sales====================================================
def get_monthwise_amount(self,lst):
lst = lst.split(',')
if not lst[1]:
ret = webnotes.conn.convert_to_lists(sql("SELECT SUM(grand_total) AMOUNT,CASE MONTH(due_date) WHEN 1 THEN 'JAN' WHEN 2 THEN 'FEB' WHEN 3 THEN 'MAR' WHEN 4 THEN 'APR' WHEN 5 THEN 'MAY' WHEN 6 THEN 'JUN' WHEN 7 THEN 'JUL' WHEN 8 THEN 'AUG' WHEN 9 THEN 'SEP' WHEN 10 THEN 'OCT' WHEN 11 THEN 'NOV' WHEN 12 THEN 'DEC' END MONTHNAME FROM `tabSales Invoice` WHERE docstatus = 1 AND fiscal_year = '%s' GROUP BY MONTH(due_date) ORDER BY MONTH(due_date)"%lst[0]))
else:
ret = webnotes.conn.convert_to_lists(sql("select sum(t2.amount) AMOUNT ,CASE MONTH(t1.due_date) WHEN 1 THEN 'JAN' WHEN 2 THEN 'FEB' WHEN 3 THEN 'MAR' WHEN 4 THEN 'APR' WHEN 5 THEN 'MAY' WHEN 6 THEN 'JUN' WHEN 7 THEN 'JUL' WHEN 8 THEN 'AUG' WHEN 9 THEN 'SEP' WHEN 10 THEN 'OCT' WHEN 11 THEN 'NOV' WHEN 12 THEN 'DEC' END MONTHNAME from `tabSales Invoice` t1,`tabSales Invoice Item` t2 WHERE t1.name = t2.parent and t1.docstatus = 1 and t2.item_group = '%s' AND t1.fiscal_year = '%s' GROUP BY MONTH(t1.due_date) ORDER BY MONTH(t1.due_date)"%(lst[1],lst[0])))
m =cint(sql("select month('%s')"%(get_defaults()['year_start_date']))[0][0])
lst1 = [[1,'JAN'],[2 ,'FEB'], [3,'MAR'],[4,'APR'],[5,'MAY'],[6,'JUN'],[7,'JUL'],[8,'AUG'],[9,'SEP'],[10,'OCT'],[11,'NOV'],[12,'DEC']]
lst2=[]
k=1
for i in range(1,13):
for j in lst1:
if j[0]==m:
lst2.append([k,j[1]])
m +=1
if m==13: m=1
k +=1
return {'msg_data':ret,'x_axis':lst2}
#===============================get weekly sales=================================================
def get_weekwise_amount(self,lst):
lst = lst.split(',')
cases = self.get_week_cases(lst[0],lst[1])
if not lst[2]:
query = "SELECT SUM(grand_total) AMOUNT,CASE WEEK(due_date)"+ cases +"END Weekly FROM `tabSales Invoice` WHERE MONTH(due_date) = %d AND docstatus = 1 AND fiscal_year = '%s' GROUP BY Weekly ORDER BY Weekly"
ret = webnotes.conn.convert_to_lists(sql(query%(cint(lst[0]),lst[1])))
else:
query = "SELECT SUM(t2.amount) AMOUNT,CASE WEEK(t1.due_date)" + cases + "END Weekly FROM `tabSales Invoice` t1, `tabSales Invoice Item` t2 WHERE MONTH(t1.due_date) = %d AND t1.docstatus = 1 AND t1.fiscal_year = '%s' AND t1.name = t2.parent AND t2.item_group ='%s' GROUP BY Weekly ORDER BY Weekly"
ret =webnotes.conn.convert_to_lists(sql(query%(cint(lst[0]),lst[1],lst[2])))
return ret and ret or ''
#================================================================================
def get_week_cases(self,m1,fy):
d1 = self.make_date("%s,%s"%(cstr(m1),fy))
w = sql("select week('%s'),week(last_day('%s'))"%(d1,d1))
w1 = cint(w[0][0])
w2 = cint(w[0][1])
w3 = []
str1 = " "
for i in range(1,7):
if(w1 <= w2):
w3.append(w1)
str1 += "WHEN "+ cstr(w1) +" THEN 'Week"+cstr(i) +"' "
w1 += 1
return str1
#===============================get yearly weekwise sales=================================================
def get_year_weekwise_amount(self,lst):
lst = lst.split(',')
yr_st = get_defaults()['year_start_date']
fy = lst[0]
m1 = cint(yr_st.split('-')[1])
cases = ' '
for i in range(1,13):
cases += self.get_week_cases(m1,fy)
m1 +=1
if(m1 == 13): m1 = 1
if not lst[1]:
query = "SELECT SUM(grand_total) AMOUNT,CASE WEEK(due_date)"+cases+"END Weekly, month(due_date) month FROM `tabSales Invoice` WHERE docstatus = 1 AND fiscal_year = '%s' GROUP BY `month`,weekly ORDER BY `month`,weekly"
ret = webnotes.conn.convert_to_lists(sql(query%lst[0]))
else:
query = "SELECT SUM(t2.amount) AMOUNT,CASE WEEK(t1.due_date)" + cases + "END Weekly, month(due_date) month FROM `tabSales Invoice` t1, `tabSales Invoice Item` t2 WHERE t1.docstatus = 1 AND t1.fiscal_year = '%s' AND t1.name = t2.parent AND t2.item_group ='%s' GROUP BY Weekly ORDER BY Weekly"
ret = webnotes.conn.convert_to_lists(sql(query%(lst[0],lst[1])))
return ret and ret or ''
#====================================make yearly weekwise dates================================================
def yr_wk_dates(self,fy):
from datetime import date
yr_st = get_defaults()['year_start_date']
yr_en = get_defaults()['year_end_date']
fy = fy.split('-')
y1 = yr_st.split('-')
date1 = date(cint(fy[0]),cint(y1[1]),cint(y1[2]))
y2 = yr_en.split('-')
date2 = date(cint(fy[1]),cint(y2[1]),cint(y2[2]))
date_lst = [[1,self.get_months(cint(y1[1]))]]
m1=cint(y1[1])+1
x_axis_lst = [[1,'Week1',cint(y1[1])]]
from datetime import date, timedelta
d =dt= date1
week=k=1
for i in range(0,53):
if dt <= date2:
if(d.weekday()>3):
d = d+timedelta(7-d.weekday())
else:
d = d - timedelta(d.weekday())
dlt = timedelta(days = (week-1)*7)
dt = d + dlt + timedelta(days=6)
m2 = cint(sql("Select month('%s')"%dt)[0][0])
if(m1 == m2):
date_lst.append([i+2,self.get_months(m2)])
x_axis_lst.append([i+2,'Week1',m2])
k=1
m1 += 1
if(m1==13): m1 =1
else:
date_lst.append([i+2,' '])
x_axis_lst.append([i+2,'Week%d'%k,m2])
week += 1
k +=1
return [date_lst,x_axis_lst]
#===================================================================================
def get_months(self,m):
m_lst = {1:'JAN',2:'FEB',3:'MAR',4:'APR',5:'MAY',6:'JUN',7:'JUL',8:'AUG',9:'SEP',10:'OCT',11:'NOV',12:'DEC'}
return m_lst[m]
def get_weekdates(self,lst):
from datetime import date, timedelta
d = dt = self.make_date(lst)
date_lst = [[1,cstr(d.strftime("%d/%m/%y"))]]
week=flag =1
j=1
last_day = sql("select last_day('%s')"%d)[0][0]
lst_m = cint(lst.split(',')[0])
for i in range(2,8):
f=0
if(dt < last_day):
#if(d.weekday()>4):
#d = d+timedelta(7-d.weekday())
#else:
d = d - timedelta(d.weekday()-1)
dlt = timedelta(days = (week-1)*7)
dt = d + dlt + timedelta(days=6)
if(cint(sql("select month('%s')"%dt)[0][0]) == lst_m and dt!=last_day):
for k in date_lst:
if(cstr(dt.strftime("%d/%m/%y")) == k[1]):
f = 1
if f == 0:
date_lst.append([i,cstr(dt.strftime("%d/%m/%y"))])
elif(dt==last_day and flag ==1):
date_lst.append([i,cstr(last_day.strftime("%d/%m/%y"))])
flag = 0
elif(flag == 1):
date_lst.append([i,cstr(last_day.strftime("%d/%m/%y"))])
week += 1
return date_lst and date_lst or ''
def make_date(self,lst):
from datetime import date, timedelta
lst = lst.split(',')
year = lst[1].split('-')
if(len(lst[0])==1): month = '0'+lst[0]
else: month = lst[0]
if(1<=cint(month)<=3): year = year[1]
elif(4<=cint(month)<=12): year = year[0]
d = date(cint(year),cint(month),1)
return d
def get_item_groups(self):
ret = webnotes.conn.convert_to_lists(sql("select name from `tabItem Group` where docstatus != 2 and is_group = 'No'"))
#ret = webnotes.conn.convert_to_lists(sql("select item_group from `tabItem` where is_sales_item='Yes' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now()) and item_group !=''"))
return ret and ret or ''
def get_fiscal_year(self):
ret = webnotes.conn.convert_to_lists(sql("select name from `tabFiscal Year` where docstatus =0"))
return ret and ret or ''

View File

@ -1,23 +0,0 @@
[
{
"owner": "harshada@webnotestech.com",
"docstatus": 0,
"creation": "2012-03-27 14:36:12",
"modified_by": "Administrator",
"modified": "2012-03-27 14:36:12"
},
{
"section_style": "Simple",
"name": "__common__",
"colour": "White:FFF",
"module": "Selling",
"doctype": "DocType",
"version": 215,
"server_code_error": " ",
"issingle": 1
},
{
"name": "Plot Control",
"doctype": "DocType"
}
]

View File

@ -17,9 +17,10 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, get_defaults, set_default
from webnotes.utils import cstr, set_default
from webnotes.model.doc import Document
from webnotes.model.code import get_obj
import webnotes.defaults
sql = webnotes.conn.sql
@ -241,8 +242,7 @@ class DocType:
#delete cost center
sql("delete from `tabCost Center` WHERE company_name = %s order by lft desc, rgt desc", self.doc.name)
#update value as blank for tabDefaultValue defkey=company
sql("update `tabDefaultValue` set defvalue = '' where defkey='company' and defvalue = %s", self.doc.name)
webnotes.defaults.clear_default("company", value=self.doc.name)
#update value as blank for tabSingles Global Defaults
sql("update `tabSingles` set value = '' where doctype='Global Defaults' and field = 'default_company' and value = %s", self.doc.name)
@ -250,8 +250,8 @@ class DocType:
# on rename
# ---------
def on_rename(self,newdn,olddn):
def on_rename(self,newdn,olddn):
sql("update `tabCompany` set company_name = '%s' where name = '%s'" %(newdn,olddn))
sql("update `tabSingles` set value = %s where doctype='Global Defaults' and field = 'default_company' and value = %s", (newdn, olddn))
if get_defaults('company') == olddn:
set_default('company', newdn)
if webnotes.defaults.get_global_default('company') == olddn:
webnotes.defaults.set_global_default('company', newdn)

View File

@ -17,6 +17,7 @@
from __future__ import unicode_literals
"""Global Defaults"""
import webnotes
import webnotes.defaults
from webnotes.utils import cint
keydict = {
@ -82,4 +83,4 @@ class DocType:
def get_defaults(self):
return webnotes.conn.get_defaults()
return webnotes.defaults.get_defaults()

View File

@ -25,6 +25,8 @@ from webnotes.model.code import get_obj
from webnotes import msgprint
sql = webnotes.conn.sql
import webnotes.defaults
class DocType:
def __init__(self, doc, doclist=[]):
@ -97,7 +99,7 @@ class DocType:
def reorder_item(self,doc_type,doc_name):
""" Reorder item if stock reaches reorder level"""
if not hasattr(webnotes, "auto_indent"):
if not hasattr(webnotes, "auto_indent"):
webnotes.auto_indent = webnotes.conn.get_value('Global Defaults', None, 'auto_indent')
if webnotes.auto_indent:
@ -117,10 +119,11 @@ class DocType:
def create_material_request(self, doc_type, doc_name):
""" Create indent on reaching reorder level """
defaults = webnotes.conn.get_defaults()
defaults = webnotes.defaults.get_defaults()
mr = webnotes.bean([{
"doctype": "Material Request",
"company": defaults.company,
"fiscal_year": defaults.fiscal_year,
}])
@ -128,8 +131,6 @@ class DocType:
indent = Document('Material Request')
indent.transaction_date = nowdate()
indent.naming_series = 'IDT'
indent.company = get_defaults()['company']
indent.fiscal_year = get_defaults()['fiscal_year']
indent.remark = """This is an auto generated Material Request.
It was raised because the (actual + ordered + indented - reserved) quantity
reaches re-order level when %s %s was created""" % (doc_type,doc_name)

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt, get_defaults
from webnotes.utils import cstr, flt
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
@ -14,7 +14,6 @@ class DocType(BuyingController):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.defaults = get_defaults()
self.tname = 'Material Request Item'
self.fname = 'indent_details'

View File

@ -17,7 +17,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt, get_defaults
from webnotes.utils import cstr, flt
from webnotes.model.doc import addchild
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
@ -30,7 +30,6 @@ class DocType(BuyingController):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.defaults = get_defaults()
self.tname = 'Purchase Receipt Item'
self.fname = 'purchase_receipt_details'
self.count = 0

View File

@ -18,6 +18,7 @@ import webnotes
from webnotes import msgprint, _
import json
from webnotes.utils import flt, cstr
from webnotes.defaults import get_global_default
def validate_end_of_life(item_code, end_of_life=None, verbose=1):
if not end_of_life:
@ -99,8 +100,7 @@ def get_valuation_method(item_code):
"""get valuation method from item or default"""
val_method = webnotes.conn.get_value('Item', item_code, 'valuation_method')
if not val_method:
from webnotes.utils import get_defaults
val_method = get_defaults().get('valuation_method', 'FIFO')
val_method = get_global_default('valuation_method') or "FIFO"
return val_method
def get_fifo_rate(previous_stock_queue, qty):