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

This commit is contained in:
Rushabh Mehta 2013-07-26 11:22:09 +05:30
commit dea6e51929
13 changed files with 29 additions and 37 deletions

View File

@ -120,6 +120,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
} }
// TODO toggle display of fields // TODO toggle display of fields
cur_frm.cscript.hide_fields(this.frm.doc);
}, },
debit_to: function() { debit_to: function() {
@ -162,7 +163,7 @@ $.extend(cur_frm.cscript, new erpnext.accounts.SalesInvoiceController({frm: cur_
// Hide Fields // Hide Fields
// ------------ // ------------
cur_frm.cscript.hide_fields = function(doc, cdt, cdn) { cur_frm.cscript.hide_fields = function(doc) {
par_flds = ['project_name', 'due_date', 'is_opening', 'conversion_rate', par_flds = ['project_name', 'due_date', 'is_opening', 'conversion_rate',
'source', 'total_advance', 'gross_profit', 'source', 'total_advance', 'gross_profit',
'gross_profit_percent', 'get_advances_received', 'gross_profit_percent', 'get_advances_received',
@ -176,18 +177,21 @@ cur_frm.cscript.hide_fields = function(doc, cdt, cdn) {
if(cint(doc.is_pos) == 1) { if(cint(doc.is_pos) == 1) {
hide_field(par_flds); hide_field(par_flds);
unhide_field('payments_section'); unhide_field('payments_section');
for(f in item_flds_normal) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal[f], false); cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal, false);
} else { } else {
hide_field('payments_section'); hide_field('payments_section');
unhide_field(par_flds); unhide_field(par_flds);
for(f in item_flds_normal) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal[f], true); cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal, true);
} }
for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], (cint(doc.update_stock)==1?true:false));
cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos, (cint(doc.update_stock)==1?true:false));
// India related fields // India related fields
var cp = wn.control_panel; var cp = wn.control_panel;
if (cp.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']); if (cp.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']);
else hide_field(['c_form_applicable', 'c_form_no']); else hide_field(['c_form_applicable', 'c_form_no']);
cur_frm.refresh_fields();
} }

View File

@ -90,7 +90,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
freeze: true, freeze: true,
callback: function(r) { callback: function(r) {
if(!r.exc) { if(!r.exc) {
me.frm.refresh_fields();
if(me.frm.doc.price_list_name !== price_list_name) me.price_list_name(); if(me.frm.doc.price_list_name !== price_list_name) me.price_list_name();
} }
} }
@ -485,12 +484,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
// toggle columns // toggle columns
var item_grid = this.frm.fields_dict[this.fname].grid; var item_grid = this.frm.fields_dict[this.fname].grid;
var show = this.frm.doc.currency != company_currency; var fieldnames = $.map(["purchase_rate", "purchase_ref_rate", "amount", "rate"], function(fname) {
$.each(["purchase_rate", "purchase_ref_rate", "amount", "rate"], function(i, fname) { return wn.meta.get_docfield(item_grid.doctype, fname, me.frm.docname) ? fname : null;
if(wn.meta.get_docfield(item_grid.doctype, fname))
item_grid.set_column_disp(fname, show);
}); });
item_grid.set_column_disp(fieldnames, this.frm.doc.currency != company_currency);
// set labels // set labels
var $wrapper = $(this.frm.wrapper); var $wrapper = $(this.frm.wrapper);
$.each(field_label_map, function(fname, label) { $.each(field_label_map, function(fname, label) {

View File

@ -33,6 +33,8 @@ class AccountsController(TransactionBase):
self.validate_value("grand_total", ">=", 0) self.validate_value("grand_total", ">=", 0)
self.set_total_in_words() self.set_total_in_words()
self.validate_for_freezed_account()
def set_missing_values(self, for_validate=False): def set_missing_values(self, for_validate=False):
for fieldname in ["posting_date", "transaction_date"]: for fieldname in ["posting_date", "transaction_date"]:
if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname): if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
@ -51,6 +53,18 @@ class AccountsController(TransactionBase):
if date_field and self.doc.fields[date_field]: if date_field and self.doc.fields[date_field]:
validate_fiscal_year(self.doc.fields[date_field], self.doc.fiscal_year, validate_fiscal_year(self.doc.fields[date_field], self.doc.fiscal_year,
label=self.meta.get_label(date_field)) label=self.meta.get_label(date_field))
def validate_for_freezed_account(self):
for fld in ["customer", "supplier"]:
if self.meta.get_field(fld):
accounts = webnotes.conn.get_values("Account", {"master_type": fld.upper(),
"master_name": self.doc.fields[fld], "company": self.doc.company},
"freeze_account", as_dict=1)
if accounts:
if not filter(lambda x: cstr(x.freeze_account) in ["", "No"], accounts):
msgprint(_("Account for this ") + fld + _(" has been freezed. ") +
self.doc.doctype + _(" can not be made."), raise_exception=1)
def set_price_list_currency(self, buying_or_selling): def set_price_list_currency(self, buying_or_selling):
# TODO - change this, since price list now has only one currency allowed # TODO - change this, since price list now has only one currency allowed

View File

@ -209,8 +209,7 @@ $(document).bind('form_refresh', function() {
if(fort=='fields') { if(fort=='fields') {
hide_field(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]); hide_field(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]);
} else if(cur_frm.fields_dict[fort]) { } else if(cur_frm.fields_dict[fort]) {
for(grid_field in pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]) cur_frm.fields_dict[fort].grid.set_column_disp(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort], false);
cur_frm.fields_dict[fort].grid.set_column_disp(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort][grid_field], false);
} else { } else {
msgprint('Grid "'+fort+'" does not exists'); msgprint('Grid "'+fort+'" does not exists');
} }

View File

@ -81,9 +81,6 @@ erpnext.selling.InstallationNote = wn.ui.form.Controller.extend({
this.frm.call({ this.frm.call({
doc: this.frm.doc, doc: this.frm.doc,
method: "set_customer_defaults", method: "set_customer_defaults",
callback: function(r) {
if(!r.exc) me.frm.refresh_fields();
}
}); });
// TODO shift this to depends_on // TODO shift this to depends_on
@ -105,9 +102,6 @@ erpnext.selling.InstallationNote = wn.ui.form.Controller.extend({
}, },
method: "get_customer_address", method: "get_customer_address",
freeze: true, freeze: true,
callback: function(r) {
me.frm.refresh_fields();
}
}); });
} }
}, },

View File

@ -89,9 +89,6 @@ erpnext.selling.Opportunity = wn.ui.form.Controller.extend({
this.frm.call({ this.frm.call({
doc: this.frm.doc, doc: this.frm.doc,
method: "set_customer_defaults", method: "set_customer_defaults",
callback: function(r) {
if(!r.exc) me.frm.refresh_fields();
}
}); });
// TODO shift this to depends_on // TODO shift this to depends_on
@ -208,7 +205,6 @@ cur_frm.cscript['Declare Opportunity Lost'] = function(){
return; return;
} }
dialog.hide(); dialog.hide();
cur_frm.refresh();
}, },
btn: this btn: this
}) })

View File

@ -142,7 +142,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
freeze: true, freeze: true,
callback: function(r) { callback: function(r) {
if(!r.exc) { if(!r.exc) {
me.frm.refresh_fields();
(me.frm.doc.price_list_name !== price_list_name) ? (me.frm.doc.price_list_name !== price_list_name) ?
me.price_list_name() : me.price_list_name() :
me.price_list_currency(); me.price_list_currency();

View File

@ -256,7 +256,7 @@ def create_territories():
if name and not webnotes.conn.exists("Territory", name): if name and not webnotes.conn.exists("Territory", name):
webnotes.bean({ webnotes.bean({
"doctype": "Territory", "doctype": "Territory",
"territory_name": name, "territory_name": name.replace("'", ""),
"parent_territory": root_territory, "parent_territory": root_territory,
"is_group": "No" "is_group": "No"
}).insert() }).insert()

View File

@ -46,8 +46,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
// unhide expense_account and cost_center is auto_inventory_accounting enabled // unhide expense_account and cost_center is auto_inventory_accounting enabled
var aii_enabled = cint(sys_defaults.auto_inventory_accounting) var aii_enabled = cint(sys_defaults.auto_inventory_accounting)
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("expense_account", aii_enabled); cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(["expense_account", "cost_center"], aii_enabled);
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("cost_center", aii_enabled);
if (this.frm.doc.docstatus===0) { if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(wn._('From Sales Order'), cur_frm.add_custom_button(wn._('From Sales Order'),

View File

@ -29,9 +29,6 @@ erpnext.support.CustomerIssue = wn.ui.form.Controller.extend({
this.frm.call({ this.frm.call({
doc: this.frm.doc, doc: this.frm.doc,
method: "set_customer_defaults", method: "set_customer_defaults",
callback: function(r) {
if(!r.exc) me.frm.refresh_fields();
}
}); });
// TODO shift this to depends_on // TODO shift this to depends_on

View File

@ -47,9 +47,6 @@ erpnext.support.MaintenanceSchedule = wn.ui.form.Controller.extend({
this.frm.call({ this.frm.call({
doc: this.frm.doc, doc: this.frm.doc,
method: "set_customer_defaults", method: "set_customer_defaults",
callback: function(r) {
if(!r.exc) me.frm.refresh_fields();
}
}); });
} }
}, },

View File

@ -65,9 +65,6 @@ erpnext.support.MaintenanceVisit = wn.ui.form.Controller.extend({
this.frm.call({ this.frm.call({
doc: this.frm.doc, doc: this.frm.doc,
method: "set_customer_defaults", method: "set_customer_defaults",
callback: function(r) {
if(!r.exc) me.frm.refresh_fields();
}
}); });
// TODO shift this to depends_on // TODO shift this to depends_on

View File

@ -26,9 +26,6 @@ erpnext.support.CustomerIssue = wn.ui.form.Controller.extend({
this.frm.call({ this.frm.call({
doc: this.frm.doc, doc: this.frm.doc,
method: "set_customer_defaults", method: "set_customer_defaults",
callback: function(r) {
if(!r.exc) me.frm.refresh_fields();
}
}); });
} }
} }