Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Nabin Hait
2013-02-21 14:53:42 +05:30
417 changed files with 3228 additions and 1987 deletions

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

@@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import cstr, getdate
from webnotes.model import db_exists
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.bean import getlist, copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint
from stock.utils import get_valid_serial_nos

View File

@@ -23,7 +23,7 @@ from core.doctype.communication.communication import make
def add_sales_communication(subject, content, sender, real_name, mail=None,
status="Open", date=None):
def set_status(doctype, name):
w = webnotes.model_wrapper(doctype, name)
w = webnotes.bean(doctype, name)
w.ignore_permissions = True
w.doc.status = is_system_user and "Replied" or status
w.doc.save()
@@ -36,7 +36,7 @@ def add_sales_communication(subject, content, sender, real_name, mail=None,
if not (lead_name or contact_name):
# none, create a new Lead
lead = webnotes.model_wrapper({
lead = webnotes.bean({
"doctype":"Lead",
"lead_name": real_name or sender,
"email_id": sender,

View File

@@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import add_days, cstr, getdate
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild
from webnotes.model.wrapper import getlist
from webnotes.model.bean import getlist
from webnotes import msgprint
sql = webnotes.conn.sql

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.wrapper 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

@@ -18,7 +18,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, getdate
from webnotes.model.wrapper import getlist
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint

View File

@@ -19,7 +19,7 @@ import webnotes
from webnotes.utils import cint, cstr, flt, getdate, nowdate, formatdate
from webnotes.model.doc import addchild
from webnotes.model.wrapper import getlist
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint, _
from setup.utils import get_company_currency

View File

@@ -78,7 +78,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
// indent
if(!doc.order_type || (doc.order_type == 'Sales'))
cur_frm.add_custom_button('Make ' + wn._('Purchase Request'), cur_frm.cscript['Make Purchase Request']);
cur_frm.add_custom_button('Make ' + wn._('Material Request'), cur_frm.cscript['Make Material Request']);
// sales invoice
if(flt(doc.per_billed, 2) < 100)
@@ -246,19 +246,19 @@ cur_frm.cscript.make_maintenance_visit = function() {
}
}
cur_frm.cscript['Make Purchase Request'] = function() {
cur_frm.cscript['Make Material Request'] = function() {
var doc = cur_frm.doc;
if (doc.docstatus == 1) {
n = wn.model.make_new_doc_and_get_name("Purchase Request");
n = wn.model.make_new_doc_and_get_name("Material Request");
$c('dt_map', args={
'docs':wn.model.compress([locals["Purchase Request"][n]]),
'docs':wn.model.compress([locals["Material Request"][n]]),
'from_doctype':'Sales Order',
'to_doctype':'Purchase Request',
'to_doctype':'Material Request',
'from_docname':doc.name,
'from_to_list':"[['Sales Order', 'Purchase Request'], ['Sales Order Item', 'Purchase Request Item']]"
'from_to_list':"[['Sales Order', 'Material Request'], ['Sales Order Item', 'Material Request Item']]"
}
, function(r,rt) {
loaddoc("Purchase Request", n);
loaddoc("Material Request", n);
}
);
}

View File

@@ -18,7 +18,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt, getdate
from webnotes.model.wrapper import getlist
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint

View File

@@ -19,7 +19,7 @@ import webnotes
from webnotes.utils import cstr
from webnotes.model import db_exists
from webnotes.model.wrapper import copy_doclist
from webnotes.model.bean import copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint

View File

@@ -30,4 +30,4 @@ def add_node():
parent_field: webnotes.form_dict['parent'],
"is_group": webnotes.form_dict['is_group']
}]
webnotes.model_wrapper(doclist).save()
webnotes.bean(doclist).save()