[fix] pos setting link fields validate to specific company
This commit is contained in:
parent
45af0a18b6
commit
734b2aab5c
@ -49,15 +49,9 @@ cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) {
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ Get Print Heading ------------------------------------
|
||||
cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) {
|
||||
return{
|
||||
filters:[
|
||||
['Print Heading', 'docstatus', '!=', 2]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// Expense Account
|
||||
// -----------------------------
|
||||
cur_frm.fields_dict["expense_account"].get_query = function(doc) {
|
||||
return {
|
||||
filters: {
|
||||
@ -69,6 +63,16 @@ cur_frm.fields_dict["expense_account"].get_query = function(doc) {
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ Get Print Heading ------------------------------------
|
||||
cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) {
|
||||
return{
|
||||
filters:[
|
||||
['Print Heading', 'docstatus', '!=', 2]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur_frm.fields_dict.user.get_query = function(doc,cdt,cdn) {
|
||||
return{ query:"controllers.queries.profile_query"}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ class DocType:
|
||||
def validate(self):
|
||||
self.check_for_duplicate()
|
||||
self.validate_expense_account()
|
||||
self.validate_all_link_fields()
|
||||
|
||||
def check_for_duplicate(self):
|
||||
res = webnotes.conn.sql("""select name, user from `tabPOS Setting`
|
||||
@ -38,6 +39,15 @@ class DocType:
|
||||
and not self.doc.expense_account:
|
||||
msgprint(_("Expense Account is mandatory"), raise_exception=1)
|
||||
|
||||
def validate_all_link_fields(self):
|
||||
accounts = {"Account": [self.doc.cash_bank_account, self.doc.income_account, self.doc.expense_account], \
|
||||
"Cost Center": [self.doc.cost_center], "Warehouse": [self.doc.warehouse]}
|
||||
|
||||
for link_dt, dn_list in accounts.items():
|
||||
for link_dn in dn_list:
|
||||
if not webnotes.conn.exists({"doctype": link_dt, "company": self.doc.company, "name": link_dn}):
|
||||
msgprint(link_dn +_(" does not belong to ") + self.doc.company)
|
||||
|
||||
def on_update(self):
|
||||
webnotes.defaults.clear_default("is_pos")
|
||||
|
||||
|
@ -292,10 +292,11 @@ erpnext.POS = Class.extend({
|
||||
|
||||
$.each(taxes, function(i, d) {
|
||||
$(repl('<tr>\
|
||||
<td>%(description)s</td>\
|
||||
<td>%(description)s (%(rate)s%)</td>\
|
||||
<td style="text-align: right;">%(tax_amount)s</td>\
|
||||
<tr>', {
|
||||
description: d.description,
|
||||
rate: d.rate,
|
||||
tax_amount: format_currency(d.tax_amount, me.frm.doc.price_list_currency)
|
||||
})).appendTo(".tax-table tbody");
|
||||
});
|
||||
@ -429,6 +430,7 @@ erpnext.POS = Class.extend({
|
||||
dialog.fields_dict.pay.input.onclick = function() {
|
||||
cur_frm.set_value("mode_of_payment", dialog.get_values().mode_of_payment);
|
||||
cur_frm.set_value("paid_amount", dialog.get_values().total_amount);
|
||||
cur_frm.cscript.mode_of_payment(cur_frm.doc);
|
||||
cur_frm.save();
|
||||
dialog.hide();
|
||||
me.refresh();
|
||||
|
@ -36,8 +36,6 @@ cur_frm.cscript.abbr = function(doc){
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.default_cash_account.get_query = cur_frm.fields_dict.default_bank_account.get_query;
|
||||
|
||||
cur_frm.fields_dict.default_bank_account.get_query = function(doc) {
|
||||
return{
|
||||
filters:{
|
||||
@ -48,7 +46,7 @@ cur_frm.fields_dict.default_bank_account.get_query = function(doc) {
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.payables_group.get_query = cur_frm.fields_dict.receivables_group.get_query;
|
||||
cur_frm.fields_dict.default_cash_account.get_query = cur_frm.fields_dict.default_bank_account.get_query;
|
||||
|
||||
cur_frm.fields_dict.receivables_group.get_query = function(doc) {
|
||||
return{
|
||||
@ -59,6 +57,39 @@ cur_frm.fields_dict.receivables_group.get_query = function(doc) {
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.payables_group.get_query = cur_frm.fields_dict.receivables_group.get_query;
|
||||
|
||||
cur_frm.fields_dict.default_expense_account.get_query = function(doc) {
|
||||
return{
|
||||
filters:{
|
||||
'company': doc.name,
|
||||
'group_or_ledger': "Ledger",
|
||||
'is_pl_account': "Yes",
|
||||
'debit_or_credit': "Debit"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.default_income_account.get_query = function(doc) {
|
||||
return{
|
||||
filters:{
|
||||
'company': doc.name,
|
||||
'group_or_ledger': "Ledger",
|
||||
'is_pl_account': "Yes",
|
||||
'debit_or_credit': "Credit"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.cost_center.get_query = function(doc) {
|
||||
return{
|
||||
filters:{
|
||||
'company': doc.name,
|
||||
'group_or_ledger': "Ledger",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sys_defaults.auto_inventory_accounting) {
|
||||
cur_frm.fields_dict["stock_in_hand_account"].get_query = function(doc) {
|
||||
return {
|
||||
|
@ -48,7 +48,8 @@ class DocType:
|
||||
self.create_default_warehouses()
|
||||
self.create_default_web_page()
|
||||
|
||||
if not self.doc.cost_center:
|
||||
if not webnotes.conn.get_value("Cost Center", {"group_or_ledger": "Ledger",
|
||||
"company": self.doc.name}):
|
||||
self.create_default_cost_center()
|
||||
|
||||
self.set_default_accounts()
|
||||
|
Loading…
x
Reference in New Issue
Block a user