Merge branch 'wsgi' of https://github.com/webnotes/erpnext into i18n

Conflicts:
	accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
	accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
	public/js/complete_setup.js
	selling/doctype/opportunity/opportunity.js
	selling/doctype/quotation/quotation.js
This commit is contained in:
Bárbara Perretti
2013-10-16 15:09:18 -03:00
250 changed files with 5061 additions and 2506 deletions

View File

@@ -8,6 +8,7 @@
wn.provide("erpnext.buying");
wn.require("app/js/transaction.js");
wn.require("app/js/controllers/accounts.js");
erpnext.buying.BuyingController = erpnext.TransactionController.extend({
onload: function() {
@@ -108,8 +109,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
var item = wn.model.get_doc(cdt, cdn);
if(item.item_code) {
if(!this.validate_company_and_party("supplier")) {
item.item_code = null;
refresh_field("item_code", item.name, item.parentfield);
cur_frm.fields_dict[me.frm.cscript.fname].grid.grid_rows[item.idx - 1].remove();
} else {
return this.frm.call({
method: "buying.utils.get_item_details",

View File

@@ -10,7 +10,6 @@ from webnotes import msgprint, _
from buying.utils import get_last_purchase_details
sql = webnotes.conn.sql
from controllers.buying_controller import BuyingController
class DocType(BuyingController):
@@ -23,27 +22,20 @@ class DocType(BuyingController):
msgprint(_("You need to put at least one item in the item table."), raise_exception=True)
def get_supplier_details(self, name = ''):
details = sql("select supplier_name,address from `tabSupplier` where name = '%s' and docstatus != 2" %(name), as_dict = 1)
details = webnotes.conn.sql("select supplier_name,address from `tabSupplier` where name = '%s' and docstatus != 2" %(name), as_dict = 1)
if details:
ret = {
'supplier_name' : details and details[0]['supplier_name'] or '',
'supplier_address' : details and details[0]['address'] or ''
}
# ********** get primary contact details (this is done separately coz. , in case there is no primary contact thn it would not be able to fetch customer details in case of join query)
contact_det = sql("select contact_name, contact_no, email_id from `tabContact` where supplier = '%s' and is_supplier = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), as_dict = 1)
contact_det = webnotes.conn.sql("select contact_name, contact_no, email_id from `tabContact` where supplier = '%s' and is_supplier = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), as_dict = 1)
ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
return ret
else:
msgprint("Supplier : %s does not exists" % (name))
raise Exception
# Get Available Qty at Warehouse
def get_bin_details( self, arg = ''):
arg = eval(arg)
bin = sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (arg['item_code'], arg['warehouse']), as_dict=1)
ret = { 'projected_qty' : bin and flt(bin[0]['projected_qty']) or 0 }
return ret
def update_last_purchase_rate(self, obj, is_submit):
"""updates last_purchase_rate in item table for each item"""
@@ -70,7 +62,7 @@ class DocType(BuyingController):
# update last purchsae rate
if last_purchase_rate:
sql("update `tabItem` set last_purchase_rate = %s where name = %s",
webnotes.conn.sql("update `tabItem` set last_purchase_rate = %s where name = %s",
(flt(last_purchase_rate),d.item_code))
def get_last_purchase_rate(self, obj):
@@ -107,7 +99,7 @@ class DocType(BuyingController):
raise Exception
# udpate with latest quantities
bin = sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
bin = webnotes.conn.sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
f_lst ={'projected_qty': bin and flt(bin[0]['projected_qty']) or 0, 'ordered_qty': 0, 'received_qty' : 0}
if d.doctype == 'Purchase Receipt Item':
@@ -116,7 +108,7 @@ class DocType(BuyingController):
if d.fields.has_key(x):
d.fields[x] = f_lst[x]
item = sql("select is_stock_item, is_purchase_item, is_sub_contracted_item, end_of_life from tabItem where name=%s",
item = webnotes.conn.sql("select is_stock_item, is_purchase_item, is_sub_contracted_item, end_of_life from tabItem where name=%s",
d.item_code)
if not item:
msgprint("Item %s does not exist in Item Master." % cstr(d.item_code), raise_exception=True)
@@ -139,7 +131,7 @@ class DocType(BuyingController):
# if is not stock item
f = [d.schedule_date, d.item_code, d.description]
ch = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
ch = webnotes.conn.sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
if ch and ch[0][0] == 'Yes':
# check for same items
@@ -165,18 +157,18 @@ class DocType(BuyingController):
# but if in Material Request uom KG it can change in PO
get_qty = (transaction == 'Material Request - Purchase Order') and 'qty * conversion_factor' or 'qty'
qty = sql("select sum(%s) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% ( get_qty, curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
qty = webnotes.conn.sql("select sum(%s) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% ( get_qty, curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
qty = qty and flt(qty[0][0]) or 0
# get total qty of ref doctype
#--------------------
max_qty = sql("select qty from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn))
max_qty = webnotes.conn.sql("select qty from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn))
max_qty = max_qty and flt(max_qty[0][0]) or 0
return cstr(qty)+'~~~'+cstr(max_qty)
def check_for_stopped_status(self, doctype, docname):
stopped = sql("select name from `tab%s` where name = '%s' and status = 'Stopped'" %
stopped = webnotes.conn.sql("select name from `tab%s` where name = '%s' and status = 'Stopped'" %
( doctype, docname))
if stopped:
msgprint("One cannot do any transaction against %s : %s, it's status is 'Stopped'" %
@@ -184,7 +176,7 @@ class DocType(BuyingController):
def check_docstatus(self, check, doctype, docname , detail_doctype = ''):
if check == 'Next':
submitted = sql("""select t1.name from `tab%s` t1,`tab%s` t2
submitted = webnotes.conn.sql("""select t1.name from `tab%s` t1,`tab%s` t2
where t1.name = t2.parent and t2.prevdoc_docname = %s and t1.docstatus = 1"""
% (doctype, detail_doctype, '%s'), docname)
if submitted:
@@ -192,23 +184,8 @@ class DocType(BuyingController):
+ _(" has already been submitted."), raise_exception=1)
if check == 'Previous':
submitted = sql("""select name from `tab%s`
submitted = webnotes.conn.sql("""select name from `tab%s`
where docstatus = 1 and name = %s"""% (doctype, '%s'), docname)
if not submitted:
msgprint(cstr(doctype) + ": " + cstr(submitted[0][0])
+ _(" not submitted"), raise_exception=1)
def get_rate(self, arg, obj):
arg = eval(arg)
rate = sql("select account_type, tax_rate from `tabAccount` where name = %s"
, (arg['account_head']), as_dict=1)
return {'rate': rate and (rate[0]['account_type'] == 'Tax' \
and not arg['charge_type'] == 'Actual') and flt(rate[0]['tax_rate']) or 0 }
def get_prevdoc_date(self, obj):
for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname:
dt = sql("select transaction_date from `tab%s` where name = %s"
% (d.prevdoc_doctype, '%s'), (d.prevdoc_docname))
d.prevdoc_date = dt and dt[0][0].strftime('%Y-%m-%d') or ''

View File

@@ -10,6 +10,7 @@ cur_frm.cscript.other_fname = "purchase_tax_details";
wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
wn.require('app/accounts/doctype/sales_invoice/pos.js');
erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
refresh: function(doc, cdt, cdn) {
@@ -184,9 +185,9 @@ cur_frm.pformat.indent_no = function(doc, cdt, cdn){
if(cl[i].prevdoc_doctype == 'Material Request' && cl[i].prevdoc_docname && prevdoc_list.indexOf(cl[i].prevdoc_docname) == -1) {
prevdoc_list.push(cl[i].prevdoc_docname);
if(prevdoc_list.length ==1)
out += make_row(cl[i].prevdoc_doctype, cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
out += make_row(cl[i].prevdoc_doctype, cl[i].prevdoc_docname, null,0);
else
out += make_row('', cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
out += make_row('', cl[i].prevdoc_docname,null,0);
}
}
}

View File

@@ -9,7 +9,6 @@ from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
sql = webnotes.conn.sql
from controllers.buying_controller import BuyingController
class DocType(BuyingController):
@@ -42,7 +41,6 @@ class DocType(BuyingController):
pc_obj = get_obj(dt='Purchase Common')
pc_obj.validate_for_items(self)
pc_obj.get_prevdoc_date(self)
self.check_for_stopped_status(pc_obj)
self.validate_uom_is_integer("uom", "qty")
@@ -66,10 +64,6 @@ class DocType(BuyingController):
}
})
# get available qty at warehouse
def get_bin_details(self, arg = ''):
return get_obj(dt='Purchase Common').get_bin_details(arg)
def get_schedule_dates(self):
for d in getlist(self.doclist, 'po_details'):
if d.prevdoc_detail_docname and not d.schedule_date:
@@ -133,8 +127,8 @@ class DocType(BuyingController):
update_bin(args)
def check_modified_date(self):
mod_db = sql("select modified from `tabPurchase Order` where name = '%s'" % self.doc.name)
date_diff = sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
mod_db = webnotes.conn.sql("select modified from `tabPurchase Order` where name = '%s'" % self.doc.name)
date_diff = webnotes.conn.sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
if date_diff and date_diff[0][0]:
msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ")
@@ -173,7 +167,7 @@ class DocType(BuyingController):
pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Receipt', docname = self.doc.name, detail_doctype = 'Purchase Receipt Item')
# Check if Purchase Invoice has been submitted against current Purchase Order
submitted = sql("select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_order = '%s' and t1.docstatus = 1" % self.doc.name)
submitted = webnotes.conn.sql("select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_order = '%s' and t1.docstatus = 1" % self.doc.name)
if submitted:
msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !")
raise Exception
@@ -186,9 +180,6 @@ class DocType(BuyingController):
def on_update(self):
pass
def get_rate(self,arg):
return get_obj('Purchase Common').get_rate(arg,self)
@webnotes.whitelist()
def make_purchase_receipt(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist

View File

@@ -2,12 +2,13 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
"modified": "2013-09-12 18:34:54",
"modified": "2013-10-02 14:24:49",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 1,
"allow_import": 1,
"autoname": "naming_series:",
"doctype": "DocType",
"document_type": "Transaction",
@@ -132,7 +133,6 @@
"fieldtype": "Date",
"in_filter": 1,
"label": "Purchase Order Date",
"no_copy": 1,
"oldfieldname": "transaction_date",
"oldfieldtype": "Date",
"reqd": 1,

View File

@@ -98,11 +98,11 @@ class TestPurchaseOrder(unittest.TestCase):
self.assertEquals(len(po.doclist.get({"parentfield": "po_raw_material_details"})), 2)
def test_warehouse_company_validation(self):
from controllers.buying_controller import WrongWarehouseCompany
from stock.utils import InvalidWarehouseCompany
po = webnotes.bean(copy=test_records[0])
po.doc.company = "_Test Company 1"
po.doc.conversion_rate = 0.0167
self.assertRaises(WrongWarehouseCompany, po.insert)
self.assertRaises(InvalidWarehouseCompany, po.insert)
def test_uom_integer_validation(self):
from utilities.transaction_base import UOMMustBeIntegerError

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:06",
"docstatus": 0,
"modified": "2013-08-07 14:44:12",
"modified": "2013-10-10 17:01:57",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -306,21 +306,6 @@
"search_index": 1,
"width": "120px"
},
{
"doctype": "DocField",
"fieldname": "prevdoc_date",
"fieldtype": "Date",
"hidden": 1,
"in_filter": 1,
"in_list_view": 0,
"label": "Material Request Date",
"no_copy": 1,
"oldfieldname": "prevdoc_date",
"oldfieldtype": "Date",
"print_hide": 1,
"read_only": 1,
"search_index": 0
},
{
"doctype": "DocField",
"fieldname": "prevdoc_detail_docname",

View File

@@ -9,7 +9,6 @@ from webnotes.utils import cint
from webnotes import msgprint, _
from webnotes.model.doc import make_autoname
sql = webnotes.conn.sql
from utilities.transaction_base import TransactionBase
@@ -29,7 +28,7 @@ class DocType(TransactionBase):
self.doc.name = make_autoname(self.doc.naming_series + '.#####')
def update_credit_days_limit(self):
sql("""update tabAccount set credit_days = %s where name = %s""",
webnotes.conn.sql("""update tabAccount set credit_days = %s where name = %s""",
(cint(self.doc.credit_days), self.doc.name + " - " + self.get_company_abbr()))
def on_update(self):
@@ -43,7 +42,7 @@ class DocType(TransactionBase):
self.update_credit_days_limit()
def get_payables_group(self):
g = sql("select payables_group from tabCompany where name=%s", self.doc.company)
g = webnotes.conn.sql("select payables_group from tabCompany where name=%s", self.doc.company)
g = g and g[0][0] or ''
if not g:
msgprint("Update Company master, assign a default group for Payables")
@@ -65,14 +64,14 @@ class DocType(TransactionBase):
msgprint(_("Created Group ") + ac)
def get_company_abbr(self):
return sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
return webnotes.conn.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
def get_parent_account(self, abbr):
if (not self.doc.supplier_type):
msgprint("Supplier Type is mandatory")
raise Exception
if not sql("select name from tabAccount where name=%s and debit_or_credit = 'Credit' and ifnull(is_pl_account, 'No') = 'No'", (self.doc.supplier_type + " - " + abbr)):
if not webnotes.conn.sql("select name from tabAccount where name=%s and debit_or_credit = 'Credit' and ifnull(is_pl_account, 'No') = 'No'", (self.doc.supplier_type + " - " + abbr)):
# if not group created , create it
self.add_account(self.doc.supplier_type, self.get_payables_group(), abbr)
@@ -90,7 +89,7 @@ class DocType(TransactionBase):
abbr = self.get_company_abbr()
parent_account = self.get_parent_account(abbr)
if not sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)):
if not webnotes.conn.sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)):
ac_bean = webnotes.bean({
"doctype": "Account",
'account_name': self.doc.name,
@@ -121,15 +120,15 @@ class DocType(TransactionBase):
def get_contacts(self,nm):
if nm:
contact_details =webnotes.conn.convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm))
contact_details =webnotes.conn.convert_to_lists(webnotes.conn.sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm))
return contact_details
else:
return ''
def delete_supplier_address(self):
for rec in sql("select * from `tabAddress` where supplier=%s", (self.doc.name,), as_dict=1):
sql("delete from `tabAddress` where name=%s",(rec['name']))
for rec in webnotes.conn.sql("select * from `tabAddress` where supplier=%s", (self.doc.name,), as_dict=1):
webnotes.conn.sql("delete from `tabAddress` where name=%s",(rec['name']))
def delete_supplier_contact(self):
for contact in webnotes.conn.sql_list("""select name from `tabContact`
@@ -138,7 +137,7 @@ class DocType(TransactionBase):
def delete_supplier_account(self):
"""delete supplier's ledger if exist and check balance before deletion"""
acc = sql("select name from `tabAccount` where master_type = 'Supplier' \
acc = webnotes.conn.sql("select name from `tabAccount` where master_type = 'Supplier' \
and master_name = %s and docstatus < 2", self.doc.name)
if acc:
from webnotes.model import delete_doc
@@ -161,7 +160,7 @@ class DocType(TransactionBase):
('Purchase Receipt', 'supplier'),
('Serial No', 'supplier')]
for rec in update_fields:
sql("update `tab%s` set supplier_name = %s where `%s` = %s" % \
webnotes.conn.sql("update `tab%s` set supplier_name = %s where `%s` = %s" % \
(rec[0], '%s', rec[1], '%s'), (new, old))
for account in webnotes.conn.sql("""select name, account_name from

View File

@@ -9,6 +9,7 @@ cur_frm.cscript.other_fname = "purchase_tax_details";
// attach required files
wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
wn.require('app/accounts/doctype/sales_invoice/pos.js');
erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({
refresh: function() {

View File

@@ -54,7 +54,6 @@ class DocType(BuyingController):
def validate_common(self):
pc = get_obj('Purchase Common')
pc.validate_for_items(self)
pc.get_prevdoc_date(self)
@webnotes.whitelist()
def make_purchase_order(source_name, target_doclist=None):

View File

@@ -2,12 +2,13 @@
{
"creation": "2013-05-21 16:16:45",
"docstatus": 0,
"modified": "2013-08-09 14:45:58",
"modified": "2013-10-02 14:24:44",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 1,
"allow_import": 1,
"autoname": "naming_series:",
"doctype": "DocType",
"document_type": "Transaction",

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-22 12:43:10",
"docstatus": 0,
"modified": "2013-08-07 14:44:18",
"modified": "2013-10-10 17:02:11",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -259,21 +259,6 @@
"search_index": 1,
"width": "120px"
},
{
"doctype": "DocField",
"fieldname": "prevdoc_date",
"fieldtype": "Date",
"hidden": 1,
"in_filter": 1,
"in_list_view": 0,
"label": "Material Request Date",
"no_copy": 1,
"oldfieldname": "prevdoc_date",
"oldfieldtype": "Date",
"print_hide": 1,
"read_only": 1,
"search_index": 0
},
{
"doctype": "DocField",
"fieldname": "prevdoc_detail_docname",

View File

@@ -145,6 +145,11 @@ wn.module_page["Buying"] = [
route: "query-report/Purchase Order Trends",
doctype: "Purchase Order"
},
{
"label":wn._("Supplier Addresses And Contacts"),
route: "query-report/Supplier Addresses and Contacts",
doctype: "Supplier"
},
]
}
]

View File

@@ -0,0 +1,22 @@
[
{
"creation": "2013-10-09 10:38:40",
"docstatus": 0,
"modified": "2013-10-09 10:53:52",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"query": "SELECT\n `tabSupplier`.name as \"Supplier:Link/Supplier:120\",\n\t`tabSupplier`.supplier_name as \"Supplier Name::120\",\n\t`tabSupplier`.supplier_type as \"Supplier Type:Link/Supplier Type:120\",\n\tconcat_ws(', ', \n\t\ttrim(',' from `tabAddress`.address_line1), \n\t\ttrim(',' from tabAddress.address_line2), \n\t\ttabAddress.state, tabAddress.pincode, tabAddress.country\n\t) as 'Address::180',\n concat_ws(', ', `tabContact`.first_name, `tabContact`.last_name) as 'Contact Name::180',\n\t`tabContact`.phone as \"Phone\",\n\t`tabContact`.mobile_no as \"Mobile No\",\n\t`tabContact`.email_id as \"Email Id::120\",\n\t`tabContact`.is_primary_contact as \"Is Primary Contact::120\"\nFROM\n\t`tabSupplier`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.supplier=`tabSupplier`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.supplier=`tabSupplier`.name\n\t)\nWHERE\n\t`tabSupplier`.docstatus<2\nORDER BY\n\t`tabSupplier`.name asc",
"ref_doctype": "Supplier",
"report_name": "Supplier Addresses and Contacts",
"report_type": "Query Report"
},
{
"doctype": "Report",
"name": "Supplier Addresses and Contacts"
}
]

View File

@@ -65,7 +65,7 @@ def _get_basic_details(args, item_bean):
out = webnotes._dict({
"description": item.description_html or item.description,
"qty": 0.0,
"qty": 1.0,
"uom": item.stock_uom,
"conversion_factor": 1.0,
"warehouse": args.warehouse or item.default_warehouse,