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

This commit is contained in:
Anand Doshi 2012-12-04 18:02:20 +05:30
commit c80459bb6a
7 changed files with 116 additions and 84 deletions

View File

@ -14,13 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
}
cur_frm.set_query("default_account", function(doc) {
return erpnext.queries.account({
account_type: "Bank or Cash",
company: doc.company
});
});

View File

@ -1,71 +1,71 @@
# DocType, Mode of Payment
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:35:44',
'docstatus': 0,
'modified': '2012-03-27 14:35:44',
'modified_by': u'Administrator',
'owner': u'harshada@webnotestech.com'
},
# These values are common for all DocType
{
'autoname': u'field:mode_of_payment',
'colour': u'White:FFF',
'doctype': 'DocType',
'document_type': u'Master',
'module': u'Accounts',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',
'version': 3
},
# These values are common for all DocField
{
'doctype': u'DocField',
'fieldname': u'mode_of_payment',
'fieldtype': u'Data',
'label': u'Mode of Payment',
'name': '__common__',
'oldfieldname': u'mode_of_payment',
'oldfieldtype': u'Data',
'parent': u'Mode of Payment',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0,
'reqd': 1
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Mode of Payment',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1,
'role': u'Accounts Manager',
'write': 1
},
# DocType, Mode of Payment
{
'doctype': 'DocType',
'name': u'Mode of Payment'
},
# DocPerm
{
'doctype': u'DocPerm'
},
# DocField
{
'doctype': u'DocField'
}
{
"owner": "harshada@webnotestech.com",
"docstatus": 0,
"creation": "2012-07-03 13:30:49",
"modified_by": "Administrator",
"modified": "2012-12-04 16:33:37"
},
{
"autoname": "field:mode_of_payment",
"name": "__common__",
"doctype": "DocType",
"module": "Accounts",
"document_type": "Master"
},
{
"name": "__common__",
"parent": "Mode of Payment",
"doctype": "DocField",
"parenttype": "DocType",
"permlevel": 0,
"parentfield": "fields"
},
{
"parent": "Mode of Payment",
"read": 1,
"cancel": 1,
"name": "__common__",
"amend": 0,
"create": 1,
"doctype": "DocPerm",
"submit": 0,
"write": 1,
"parenttype": "DocType",
"role": "Accounts Manager",
"permlevel": 0,
"parentfield": "permissions"
},
{
"name": "Mode of Payment",
"doctype": "DocType"
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Mode of Payment",
"oldfieldname": "mode_of_payment",
"fieldname": "mode_of_payment",
"fieldtype": "Data",
"reqd": 1
},
{
"doctype": "DocField",
"label": "Company",
"fieldname": "company",
"fieldtype": "Link",
"options": "Company"
},
{
"description": "Default Bank / Cash account will be automatically updated in POS Invoice when this mode is selected.",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Default Account",
"fieldname": "default_account",
"fieldtype": "Link",
"options": "Account"
},
{
"doctype": "DocPerm"
}
]

View File

@ -148,6 +148,12 @@ cur_frm.cscript.is_pos = function(doc,dt,dn,callback){
}
}
cur_frm.cscript.mode_of_payment = function(doc) {
cur_frm.call({
method: "get_bank_cash_account",
args: { mode_of_payment: doc.mode_of_payment }
});
}
cur_frm.cscript.update_stock = function(doc, dt, dn) {
cur_frm.cscript.hide_fields(doc, dt, dn);
@ -387,9 +393,9 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
// Income Account in Details Table
// --------------------------------
cur_frm.fields_dict.entries.grid.get_field("income_account").get_query = function(doc) {
return 'SELECT tabAccount.name FROM tabAccount WHERE (tabAccount.debit_or_credit="Credit" OR tabAccount.account_type = "Income Account") AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"';
}
cur_frm.set_query("income_account", "entries", function(doc) {
return 'SELECT tabAccount.name FROM tabAccount WHERE (tabAccount.debit_or_credit="Credit" OR tabAccount.account_type = "Income Account") AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"';
})
// warehouse in detail table
//----------------------------

View File

@ -322,7 +322,6 @@ class DocType(TransactionBase):
if res:
get_obj('DocType Mapper', 'Project-Sales Invoice').dt_map('Project', 'Sales Invoice', self.doc.project_name, self.doc, self.doclist, "[['Project', 'Sales Invoice']]")
def get_company_abbr(self):
return webnotes.conn.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
@ -899,3 +898,11 @@ def assign_task_to_owner(inv, msg, users):
}
assign_to.add(args)
@webnotes.whitelist()
def get_bank_cash_account(mode_of_payment):
val = webnotes.conn.get_value("Mode of Payment", mode_of_payment, "default_account")
if not val:
webnotes.msgprint("Default Account not set in Mode of Payment: ")
return {
"cash_bank_account": val
}

View File

@ -1,5 +1,6 @@
erpnext.updates = [
["4rd December 2012", [
"POS / Mode of Payment: Select default bank / cash account in Mode of Payment and it will be automatically selected in POS Invoice.",
"Email: Add contact name as 'Dear so-and-so' in Email.",
"Report Builder: Remember last column setup for users",
"Report Builder: Autoset column width (remember)",

View File

@ -82,4 +82,25 @@ erpnext.utils.supplier_query = function() {
case when name like \"%s%%\" then 0 else 1 end, \
case when supplier_name like \"%s%%\" then 0 else 1 end, \
name, supplier_name limit 50";
};
};
wn.provide("erpnext.queries");
erpnext.queries.account = function(opts) {
if(!opts)
opts = {};
if(!opts.group_or_ledger)
opts.group_or_ledger = "Ledger";
conditions = [];
$.each(opts, function(key, val) {
conditions.push("tabAccount.`" + key + "`='"+esc_quotes(val)+"'");
});
return 'SELECT tabAccount.name, tabAccount.parent_account, tabAccount.debit_or_credit \
FROM tabAccount \
WHERE tabAccount.docstatus!=2 \
AND tabAccount.%(key)s LIKE "%s" ' + (conditions
? (" AND " + conditions.join(" AND "))
: "")
}

View File

@ -96,6 +96,7 @@ cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
cur_frm.cscript.customer = function(doc,dt,dn) {
if(doc.customer) {
cur_frm.call({
doc: cur_frm.doc,
method: "get_default_customer_address",
args: { customer: doc.customer },
callback: function(r) {