added client side functions and mode_of_payment defaults
This commit is contained in:
parent
705fed3df9
commit
bbd5ea32d1
@ -14,13 +14,9 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
cur_frm.set_query("default_account", function(doc) {
|
||||||
|
return erpnext.queries.account({
|
||||||
//--------- ONLOAD -------------
|
account_type: "Bank or Cash",
|
||||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
company: doc.company
|
||||||
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|
||||||
|
|
||||||
}
|
|
@ -1,71 +1,71 @@
|
|||||||
# DocType, Mode of Payment
|
|
||||||
[
|
[
|
||||||
|
{
|
||||||
# These values are common in all dictionaries
|
"owner": "harshada@webnotestech.com",
|
||||||
{
|
"docstatus": 0,
|
||||||
'creation': '2012-03-27 14:35:44',
|
"creation": "2012-07-03 13:30:49",
|
||||||
'docstatus': 0,
|
"modified_by": "Administrator",
|
||||||
'modified': '2012-03-27 14:35:44',
|
"modified": "2012-12-04 16:31:20"
|
||||||
'modified_by': u'Administrator',
|
},
|
||||||
'owner': u'harshada@webnotestech.com'
|
{
|
||||||
},
|
"autoname": "field:mode_of_payment",
|
||||||
|
"name": "__common__",
|
||||||
# These values are common for all DocType
|
"doctype": "DocType",
|
||||||
{
|
"module": "Accounts",
|
||||||
'autoname': u'field:mode_of_payment',
|
"document_type": "Master"
|
||||||
'colour': u'White:FFF',
|
},
|
||||||
'doctype': 'DocType',
|
{
|
||||||
'document_type': u'Master',
|
"name": "__common__",
|
||||||
'module': u'Accounts',
|
"parent": "Mode of Payment",
|
||||||
'name': '__common__',
|
"doctype": "DocField",
|
||||||
'section_style': u'Simple',
|
"parenttype": "DocType",
|
||||||
'server_code_error': u' ',
|
"permlevel": 0,
|
||||||
'version': 3
|
"parentfield": "fields"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
# These values are common for all DocField
|
"parent": "Mode of Payment",
|
||||||
{
|
"read": 1,
|
||||||
'doctype': u'DocField',
|
"cancel": 1,
|
||||||
'fieldname': u'mode_of_payment',
|
"name": "__common__",
|
||||||
'fieldtype': u'Data',
|
"amend": 0,
|
||||||
'label': u'Mode of Payment',
|
"create": 1,
|
||||||
'name': '__common__',
|
"doctype": "DocPerm",
|
||||||
'oldfieldname': u'mode_of_payment',
|
"submit": 0,
|
||||||
'oldfieldtype': u'Data',
|
"write": 1,
|
||||||
'parent': u'Mode of Payment',
|
"parenttype": "DocType",
|
||||||
'parentfield': u'fields',
|
"role": "Accounts Manager",
|
||||||
'parenttype': u'DocType',
|
"permlevel": 0,
|
||||||
'permlevel': 0,
|
"parentfield": "permissions"
|
||||||
'reqd': 1
|
},
|
||||||
},
|
{
|
||||||
|
"name": "Mode of Payment",
|
||||||
# These values are common for all DocPerm
|
"doctype": "DocType"
|
||||||
{
|
},
|
||||||
'create': 1,
|
{
|
||||||
'doctype': u'DocPerm',
|
"oldfieldtype": "Data",
|
||||||
'name': '__common__',
|
"doctype": "DocField",
|
||||||
'parent': u'Mode of Payment',
|
"label": "Mode of Payment",
|
||||||
'parentfield': u'permissions',
|
"oldfieldname": "mode_of_payment",
|
||||||
'parenttype': u'DocType',
|
"fieldname": "mode_of_payment",
|
||||||
'permlevel': 0,
|
"fieldtype": "Data",
|
||||||
'read': 1,
|
"reqd": 1
|
||||||
'role': u'Accounts Manager',
|
},
|
||||||
'write': 1
|
{
|
||||||
},
|
"doctype": "DocField",
|
||||||
|
"label": "Company",
|
||||||
# DocType, Mode of Payment
|
"fieldname": "company",
|
||||||
{
|
"fieldtype": "Link",
|
||||||
'doctype': 'DocType',
|
"options": "Company"
|
||||||
'name': u'Mode of Payment'
|
},
|
||||||
},
|
{
|
||||||
|
"description": "Will be automatically updated in POS Invoice when this mode is selected.",
|
||||||
# DocPerm
|
"colour": "White:FFF",
|
||||||
{
|
"doctype": "DocField",
|
||||||
'doctype': u'DocPerm'
|
"label": "Default Account",
|
||||||
},
|
"fieldname": "default_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
# DocField
|
"options": "Account"
|
||||||
{
|
},
|
||||||
'doctype': u'DocField'
|
{
|
||||||
}
|
"doctype": "DocPerm"
|
||||||
|
}
|
||||||
]
|
]
|
@ -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.update_stock = function(doc, dt, dn) {
|
||||||
cur_frm.cscript.hide_fields(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
|
// Income Account in Details Table
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
cur_frm.fields_dict.entries.grid.get_field("income_account").get_query = function(doc) {
|
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"';
|
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
|
// warehouse in detail table
|
||||||
//----------------------------
|
//----------------------------
|
||||||
|
@ -322,7 +322,6 @@ class DocType(TransactionBase):
|
|||||||
if res:
|
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']]")
|
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):
|
def get_company_abbr(self):
|
||||||
return webnotes.conn.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]
|
||||||
|
|
||||||
@ -899,3 +898,9 @@ def assign_task_to_owner(inv, msg, users):
|
|||||||
}
|
}
|
||||||
assign_to.add(args)
|
assign_to.add(args)
|
||||||
|
|
||||||
|
@webnotes.whitelist()
|
||||||
|
def get_bank_cash_account(mode_of_payment):
|
||||||
|
return {
|
||||||
|
"cash_bank_account": webnotes.conn.get_value("Mode of Payment",
|
||||||
|
mode_of_payment, "default_account")
|
||||||
|
}
|
@ -82,4 +82,25 @@ erpnext.utils.supplier_query = function() {
|
|||||||
case when name like \"%s%%\" then 0 else 1 end, \
|
case when name like \"%s%%\" then 0 else 1 end, \
|
||||||
case when supplier_name like \"%s%%\" then 0 else 1 end, \
|
case when supplier_name like \"%s%%\" then 0 else 1 end, \
|
||||||
name, supplier_name limit 50";
|
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 "))
|
||||||
|
: "")
|
||||||
|
}
|
@ -96,6 +96,7 @@ cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
|
|||||||
cur_frm.cscript.customer = function(doc,dt,dn) {
|
cur_frm.cscript.customer = function(doc,dt,dn) {
|
||||||
if(doc.customer) {
|
if(doc.customer) {
|
||||||
cur_frm.call({
|
cur_frm.call({
|
||||||
|
doc: cur_frm.doc,
|
||||||
method: "get_default_customer_address",
|
method: "get_default_customer_address",
|
||||||
args: { customer: doc.customer },
|
args: { customer: doc.customer },
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user