mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 19:19:17 +00:00
Merge branch 'master' of github.com:webnotes/erpnext into edge
This commit is contained in:
@@ -1,3 +1,31 @@
|
||||
// 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/>.
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
cur_frm.toggle_enable('year_start_date', doc.__islocal)
|
||||
|
||||
if (!doc.__islocal && (doc.name != sys_defaults.fiscal_year)) {
|
||||
cur_frm.add_custom_button("Set as Default", cur_frm.cscript.set_as_default);
|
||||
cur_frm.set_intro("To set this Fiscal Year as Deafult, click on 'Set as Default'");
|
||||
} else cur_frm.set_intro("");
|
||||
}
|
||||
|
||||
cur_frm.cscript.set_as_default = function() {
|
||||
wn.call({
|
||||
doc: cur_frm.doc,
|
||||
method: "set_as_default"
|
||||
});
|
||||
}
|
||||
@@ -16,7 +16,18 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint, _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def set_as_default(self):
|
||||
webnotes.conn.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name)
|
||||
webnotes.get_obj("Global Defaults").on_update()
|
||||
|
||||
# clear cache
|
||||
webnotes.clear_cache()
|
||||
|
||||
msgprint(self.doc.name + _(""" is now the default Fiscal Year. \
|
||||
Please refresh your browser for the change to take effect."""))
|
||||
@@ -193,7 +193,7 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
|
||||
return return erpnext.queries.item({
|
||||
return erpnext.queries.item({
|
||||
'ifnull(tabItem.is_purchase_item, "No")': 'Yes'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -94,8 +94,7 @@ cur_frm.cscript.hide_fields = function(doc, cdt, cdn) {
|
||||
for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], false);
|
||||
}
|
||||
|
||||
if(doc.customer) unhide_field('contact_section');
|
||||
else hide_field('contact_section');
|
||||
cur_frm.toggle_display("contact_section", doc.customer);
|
||||
|
||||
// India related fields
|
||||
var cp = wn.control_panel;
|
||||
@@ -173,6 +172,8 @@ cur_frm.cscript.warehouse = function(doc, cdt , cdn) {
|
||||
|
||||
//Customer
|
||||
cur_frm.cscript.customer = function(doc,dt,dn,onload) {
|
||||
cur_frm.toggle_display("contact_section", doc.customer);
|
||||
|
||||
var pl = doc.price_list_name;
|
||||
var callback = function(r,rt) {
|
||||
var callback2 = function(doc, dt, dn) {
|
||||
@@ -191,8 +192,6 @@ cur_frm.cscript.customer = function(doc,dt,dn,onload) {
|
||||
}
|
||||
var args = onload ? 'onload':''
|
||||
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', args, callback);
|
||||
|
||||
if(doc.customer) unhide_field('contact_section');
|
||||
|
||||
}
|
||||
|
||||
@@ -202,25 +201,6 @@ cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc
|
||||
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.customer_address.on_new = function(dn) {
|
||||
locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
|
||||
locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.contact_person.on_new = function(dn) {
|
||||
locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
|
||||
locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
// Set Due Date = posting date + credit days
|
||||
cur_frm.cscript.debit_to = function(doc,dt,dn) {
|
||||
|
||||
@@ -232,7 +212,8 @@ cur_frm.cscript.debit_to = function(doc,dt,dn) {
|
||||
var callback = function(r,rt) {
|
||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
if(doc.customer) $c_obj(make_doclist(dt,dn), 'get_default_customer_address', '', callback2);
|
||||
if(doc.customer) unhide_field('contact_section');
|
||||
cur_frm.toggle_display("contact_section", doc.customer);
|
||||
|
||||
cur_frm.refresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ def get_fiscal_year(date, verbose=1):
|
||||
subdate(adddate(year_start_date, interval 1 year), interval 1 day)
|
||||
as year_end_date
|
||||
from `tabFiscal Year`
|
||||
where %s >= year_start_date and %s < adddate(year_start_date, interval 1 year)""",
|
||||
(date, date))
|
||||
where %s >= year_start_date and %s < adddate(year_start_date, interval 1 year)
|
||||
order by year_start_date desc""", (date, date))
|
||||
|
||||
if not fy:
|
||||
error_msg = """%s not in any Fiscal Year""" % formatdate(date)
|
||||
|
||||
Reference in New Issue
Block a user