mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-30 18:34:48 +00:00
updates in purchase cycle's price list
This commit is contained in:
@@ -25,16 +25,61 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({
|
||||
setup: function() {
|
||||
var me = this;
|
||||
|
||||
this.frm.fields_dict.price_list_currency.get_query = function() {
|
||||
return repl("select distinct ref_currency from `tabItem Price` \
|
||||
where price_list_name=\"%(price_list_name)s\" and %(key)s like \"%s%%\"",
|
||||
{price_list_name: me.frm.doc.price_list_name});
|
||||
};
|
||||
if(this.frm.fields_dict.price_list_name) {
|
||||
this.frm.fields_dict.price_list_name.get_query = function() {
|
||||
return repl("select distinct price_list_name from `tabItem Price` \
|
||||
where for_buying = 1 and price_list_name like \"%s%%\"");
|
||||
};
|
||||
}
|
||||
|
||||
if(this.frm.fields_dict.price_list_currency) {
|
||||
this.frm.fields_dict.price_list_currency.get_query = function() {
|
||||
return repl("select distinct ref_currency from `tabItem Price` \
|
||||
where price_list_name=\"%(price_list_name)s\" and for_buying = 1 \
|
||||
and ref_currency like \"%s%%\"",
|
||||
{price_list_name: me.frm.doc.price_list_name});
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
this.frm.clear_custom_buttons();
|
||||
erpnext.hide_naming_series();
|
||||
|
||||
if(this.frm.fields_dict.supplier)
|
||||
this.frm.toggle_display("contact_section", this.frm.doc.supplier);
|
||||
|
||||
if(this.frm.fields_dict.currency)
|
||||
this.set_dynamic_labels();
|
||||
|
||||
// TODO: improve this
|
||||
if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name
|
||||
&& this.frm.doc.price_list_name && this.frm.doc.price_list_currency) {
|
||||
this.price_list_name();
|
||||
}
|
||||
},
|
||||
|
||||
price_list_name: function() {
|
||||
this.frm.toggle_reqd(["price_list_currency", "plc_conversion_rate"],
|
||||
!!this.frm.doc.price_list_name);
|
||||
!!(this.frm.doc.price_list_name));
|
||||
|
||||
var me = this;
|
||||
|
||||
if(this.frm.doc.price_list_name) {
|
||||
// set price list currency
|
||||
this.frm.call({
|
||||
method: "setup.utils.get_price_list_currency",
|
||||
args: {args: {
|
||||
price_list_name: this.frm.doc.price_list_name,
|
||||
use_for: "buying"
|
||||
}},
|
||||
callback: function(r) {
|
||||
if(!r.exc && r.message.price_list_currency) {
|
||||
me.price_list_currency();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
item_code: function(doc, cdt, cdn) {
|
||||
@@ -80,6 +125,118 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({
|
||||
} else {
|
||||
this.load_taxes(doc, dt, dn, callback);
|
||||
}
|
||||
},
|
||||
|
||||
currency: function() {
|
||||
this.set_dynamic_labels();
|
||||
},
|
||||
|
||||
company: function() {
|
||||
this.set_dynamic_labels();
|
||||
},
|
||||
|
||||
price_list_currency: function() {
|
||||
this.set_dynamic_labels();
|
||||
|
||||
if(this.frm.doc.price_list_currency === this.get_company_currency()) {
|
||||
this.frm.set_value("plc_conversion_rate", 1.0);
|
||||
}
|
||||
},
|
||||
|
||||
set_dynamic_labels: function(doc, dt, dn) {
|
||||
var company_currency = this.get_company_currency();
|
||||
|
||||
this.change_form_labels(company_currency);
|
||||
this.change_grid_labels(company_currency);
|
||||
},
|
||||
|
||||
change_form_labels: function(company_currency) {
|
||||
var me = this;
|
||||
var field_label_map = {};
|
||||
|
||||
var setup_field_label_map = function(fields_list, currency) {
|
||||
$.each(fields_list, function(i, fname) {
|
||||
var docfield = wn.meta.get_docfield(me.frm.doc.doctype, fname);
|
||||
if(docfield) {
|
||||
var label = wn._((docfield.label || "")).replace(/\([^\)]*\)/g, "");
|
||||
field_label_map[fname] = label.trim() + " (" + currency + ")";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setup_field_label_map(["net_total", "total_tax", "grand_total", "in_words",
|
||||
"other_charges_added", "other_charges_deducted",
|
||||
"outstanding_amount", "total_advance", "total_amount_to_pay", "rounded_total"],
|
||||
company_currency);
|
||||
|
||||
setup_field_label_map(["net_total_import", "grand_total_import", "in_words_import",
|
||||
"other_charges_added_import", "other_charges_deducted_import"], this.frm.doc.currency);
|
||||
|
||||
setup_field_label_map(["conversion_rate"], "1 " + this.frm.doc.currency
|
||||
+ " = [?] " + company_currency);
|
||||
|
||||
if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) {
|
||||
setup_field_label_map(["plc_conversion_rate"], "1 " + this.frm.doc.price_list_currency
|
||||
+ " = [?] " + company_currency);
|
||||
}
|
||||
|
||||
// toggle fields
|
||||
this.frm.toggle_display(["conversion_rate", "net_total", "grand_total",
|
||||
"in_words", "other_charges_added", "other_charges_deducted"],
|
||||
this.frm.doc.currency != company_currency);
|
||||
|
||||
// set labels
|
||||
$.each(field_label_map, function(fname, label) {
|
||||
me.frm.fields_dict[fname].set_label(label);
|
||||
});
|
||||
},
|
||||
|
||||
change_grid_labels: function(company_currency) {
|
||||
var me = this;
|
||||
var field_label_map = {};
|
||||
|
||||
var setup_field_label_map = function(fields_list, currency, parentfield) {
|
||||
var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype;
|
||||
$.each(fields_list, function(i, fname) {
|
||||
var docfield = wn.meta.get_docfield(grid_doctype, fname);
|
||||
if(docfield) {
|
||||
field_label_map[grid_doctype + "-" + fname] =
|
||||
docfield.label + " (" + currency + ")";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setup_field_label_map(["purchase_rate", "purchase_ref_rate", "amount", "rate"],
|
||||
company_currency, this.fname);
|
||||
|
||||
setup_field_label_map(["import_rate", "import_ref_rate", "import_amount"],
|
||||
this.frm.doc.currency, this.fname);
|
||||
|
||||
setup_field_label_map(["tax_amount", "total"], company_currency, this.other_fname);
|
||||
|
||||
if(this.frm.fields_dict["advance_allocation_details"]) {
|
||||
setup_field_label_map(["advance_amount", "allocated_amount"], company_currency,
|
||||
"advance_allocation_details");
|
||||
}
|
||||
|
||||
// toggle columns
|
||||
var item_grid = this.frm.fields_dict[this.fname].grid;
|
||||
var hide = this.frm.doc.currency == company_currency;
|
||||
$.each(["purchase_rate", "purchase_ref_rate", "amount", "rate"], function(i, fname) {
|
||||
if(wn.meta.get_docfield(item_grid.doctype, fname))
|
||||
item_grid.set_column_disp(fname, hide);
|
||||
});
|
||||
|
||||
// set labels
|
||||
var $wrapper = $(this.frm.wrapper);
|
||||
$.each(field_label_map, function(fname, label) {
|
||||
$wrapper.find('[data-grid-fieldname="'+fname+'"]').text(label);
|
||||
});
|
||||
},
|
||||
|
||||
get_company_currency: function() {
|
||||
return (wn.boot.company[this.frm.doc.company].default_currency ||
|
||||
sys_defaults['currency']);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -89,7 +246,7 @@ $.extend(prev_cscript, cur_frm.cscript);
|
||||
|
||||
cur_frm.cscript = new erpnext.buying.BuyingController({frm: cur_frm});
|
||||
|
||||
// combine new and previous states
|
||||
// for backward compatibility: combine new and previous states
|
||||
$.extend(cur_frm.cscript, prev_cscript);
|
||||
|
||||
|
||||
@@ -139,83 +296,6 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) {
|
||||
cur_frm.cscript.load_taxes(doc, dt, dn, callback);
|
||||
}
|
||||
|
||||
|
||||
var set_dynamic_label_par = function(doc, cdt, cdn, base_curr) {
|
||||
//parent flds
|
||||
par_cols_base = {'net_total': 'Net Total', 'total_tax': 'Total Tax', 'grand_total': 'Grand Total', /*'rounded_total': 'Rounded Total',*/
|
||||
'in_words': 'In Words', 'other_charges_added': 'Taxes and Charges Added', 'other_charges_deducted': 'Taxes and Charges Deducted'}
|
||||
par_cols_import = {'net_total_import': 'Net Total', 'grand_total_import': 'Grand Total', 'in_words_import': 'In Words',
|
||||
'other_charges_added_import': 'Taxes and Charges Added', 'other_charges_deducted_import': 'Taxes and Charges Deducted'};
|
||||
|
||||
for (d in par_cols_base) cur_frm.fields_dict[d].label_area.innerHTML = par_cols_base[d]+' (' + base_curr + ')';
|
||||
for (d in par_cols_import) cur_frm.fields_dict[d].label_area.innerHTML = par_cols_import[d]+' (' + doc.currency + ')';
|
||||
cur_frm.fields_dict['conversion_rate'].label_area.innerHTML = "Conversion Rate (" + doc.currency +' -> '+ base_curr + ')';
|
||||
|
||||
if (doc.doctype == 'Purchase Invoice') {
|
||||
cur_frm.fields_dict['outstanding_amount'].label_area.innerHTML = 'Outstanding Amount (' + base_curr + ')';
|
||||
cur_frm.fields_dict['total_advance'].label_area.innerHTML = 'Total Advance (Incl. TDS) (' + base_curr + ')';
|
||||
cur_frm.fields_dict['total_amount_to_pay'].label_area.innerHTML = 'Total Amount To Pay (' + base_curr + ')';
|
||||
} else cur_frm.fields_dict['rounded_total'].label_area.innerHTML = 'Rounded Total (' + base_curr + ')';
|
||||
|
||||
}
|
||||
|
||||
|
||||
var set_dynamic_label_child = function(doc, cdt, cdn, base_curr) {
|
||||
// item table flds
|
||||
item_cols_base = {'purchase_ref_rate': 'Ref Rate', 'amount': 'Amount'};
|
||||
item_cols_import = {'import_rate': 'Rate', 'import_ref_rate': 'Ref Rate', 'import_amount': 'Amount'};
|
||||
|
||||
for (d in item_cols_base) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_base[d]+' ('+base_curr+')');
|
||||
for (d in item_cols_import) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_import[d]+' ('+doc.currency+')');
|
||||
|
||||
var hide = (doc.currency == sys_defaults['currency']) ? false : true;
|
||||
for (f in item_cols_base) {
|
||||
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(f, hide);
|
||||
}
|
||||
if (doc.doctype == 'Purchase Invoice') {
|
||||
$('[data-grid-fieldname="'+cur_frm.cscript.tname+'-rate"]').html('Rate ('+base_curr+')');
|
||||
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp('rate', hide);
|
||||
// advance table flds
|
||||
adv_cols = {'advance_amount': 'Advance Amount', 'allocated_amount': 'Allocated Amount'}
|
||||
for (d in adv_cols) $('[data-grid-fieldname="Purchase Invoice Advance-'+d+'"]').html(adv_cols[d]+' ('+base_curr+')');
|
||||
}
|
||||
else {
|
||||
$('[data-grid-fieldname="'+cur_frm.cscript.tname+'-purchase_rate"]').html('Rate ('+base_curr+')');
|
||||
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp('purchase_rate', hide);
|
||||
}
|
||||
|
||||
//tax table flds
|
||||
tax_cols = {'tax_amount': 'Amount', 'total': 'Aggregate Total'};
|
||||
for (d in tax_cols) $('[data-grid-fieldname="Purchase Taxes and Charges-'+d+'"]').html(tax_cols[d]+' ('+base_curr+')');
|
||||
}
|
||||
|
||||
// Change label dynamically based on currency
|
||||
//------------------------------------------------------------------
|
||||
|
||||
cur_frm.cscript.dynamic_label = function(doc, cdt, cdn, callback1) {
|
||||
var base_currency = wn.boot.company[doc.company].default_currency || sys_defaults['currency'];
|
||||
if (doc.currency === base_currency) {
|
||||
set_multiple(cdt, cdn, {conversion_rate:1});
|
||||
hide_field(['conversion_rate', 'net_total_import','grand_total_import',
|
||||
'in_words_import', 'other_charges_added_import', 'other_charges_deducted_import']);
|
||||
} else {
|
||||
unhide_field(['conversion_rate', 'net_total_import','grand_total_import',
|
||||
'in_words_import', 'other_charges_added_import', 'other_charges_deducted_import']);
|
||||
}
|
||||
|
||||
set_dynamic_label_par(doc, cdt, cdn, base_currency);
|
||||
set_dynamic_label_child(doc, cdt, cdn, base_currency);
|
||||
|
||||
if (callback1) callback1(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.currency = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.dynamic_label(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.company = cur_frm.cscript.currency;
|
||||
|
||||
|
||||
// ======================== Conversion Rate ==========================================
|
||||
cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) {
|
||||
cur_frm.cscript.calc_amount( doc, 1);
|
||||
@@ -697,10 +777,6 @@ var calculate_outstanding = function(doc) {
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.toggle_contact_section = function(doc) {
|
||||
cur_frm.toggle_display("contact_section", doc.supplier);
|
||||
}
|
||||
|
||||
cur_frm.cscript.project_name = function(doc, cdt, cdn) {
|
||||
var item_doc = locals[cdt][cdn];
|
||||
if (item_doc.project_name) {
|
||||
|
||||
@@ -254,28 +254,6 @@ class DocType(BuyingController):
|
||||
else:
|
||||
chk_dupl_itm.append(f)
|
||||
|
||||
# validate conversion rate
|
||||
def validate_conversion_rate(self, obj):
|
||||
default_currency = super(DocType, self).get_company_currency(obj.doc.company)
|
||||
if not default_currency:
|
||||
msgprint('Message: Please enter default currency in Company Master')
|
||||
raise Exception
|
||||
|
||||
if obj.doc.conversion_rate == 0:
|
||||
msgprint('Conversion Rate cannot be 0', raise_exception=1)
|
||||
elif not obj.doc.conversion_rate:
|
||||
msgprint('Please specify Conversion Rate', raise_exception=1)
|
||||
elif obj.doc.currency == default_currency and \
|
||||
flt(obj.doc.conversion_rate) != 1.00:
|
||||
msgprint("""Conversion Rate should be equal to 1.00, \
|
||||
since the specified Currency and the company's currency \
|
||||
are same""", raise_exception=1)
|
||||
elif obj.doc.currency != default_currency and \
|
||||
flt(obj.doc.conversion_rate) == 1.00:
|
||||
msgprint("""Conversion Rate should not be equal to 1.00, \
|
||||
since the specified Currency and the company's currency \
|
||||
are different""", raise_exception=1)
|
||||
|
||||
# Validate values with reference document
|
||||
#---------------------------------------
|
||||
def validate_reference_value(self, obj):
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
wn.provide("erpnext.buying");
|
||||
|
||||
cur_frm.cscript.tname = "Purchase Order Item";
|
||||
cur_frm.cscript.fname = "po_details";
|
||||
cur_frm.cscript.other_fname = "purchase_tax_details";
|
||||
@@ -22,6 +24,35 @@ wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxe
|
||||
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
||||
wn.require('app/utilities/doctype/sms_control/sms_control.js');
|
||||
|
||||
erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
|
||||
refresh: function(doc, cdt, cdn) {
|
||||
this._super();
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||
if(flt(doc.per_received, 2) < 100) cur_frm.add_custom_button('Make Purchase Receipt', cur_frm.cscript['Make Purchase Receipt']);
|
||||
if(flt(doc.per_billed, 2) < 100) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Purchase Invoice']);
|
||||
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']);
|
||||
|
||||
},
|
||||
|
||||
onload_post_render: function(doc, dt, dn) {
|
||||
var callback = function(doc, dt, dn) {
|
||||
if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
|
||||
}
|
||||
this.update_item_details(doc, dt, dn, callback);
|
||||
}
|
||||
});
|
||||
|
||||
var new_cscript = new erpnext.buying.PurchaseOrderController({frm: cur_frm});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
$.extend(cur_frm.cscript, new_cscript);
|
||||
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
// set missing values in parent doc
|
||||
set_missing_values(doc, {
|
||||
@@ -34,32 +65,6 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
var callback = function(doc, dt, dn) {
|
||||
if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
|
||||
}
|
||||
cur_frm.cscript.update_item_details(doc, dt, dn, callback);
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.clear_custom_buttons();
|
||||
erpnext.hide_naming_series();
|
||||
|
||||
cur_frm.cscript.dynamic_label(doc, cdt, cdn);
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||
if(flt(doc.per_received, 2) < 100) cur_frm.add_custom_button('Make Purchase Receipt', cur_frm.cscript['Make Purchase Receipt']);
|
||||
if(flt(doc.per_billed, 2) < 100) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Purchase Invoice']);
|
||||
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']);
|
||||
|
||||
cur_frm.cscript.toggle_contact_section(doc);
|
||||
}
|
||||
|
||||
cur_frm.cscript.supplier = function(doc,dt,dn) {
|
||||
if (doc.supplier) {
|
||||
get_server_fields('get_default_supplier_address',
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-12-03 17:56:30",
|
||||
"creation": "2013-01-17 11:11:23",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2013-01-15 15:42:21"
|
||||
"modified": "2013-01-17 12:49:14"
|
||||
},
|
||||
{
|
||||
"autoname": "naming_series:",
|
||||
@@ -253,34 +253,11 @@
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Price List and Currency",
|
||||
"label": "Currency & Price List",
|
||||
"fieldname": "price_list_and_currency",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Price List",
|
||||
"options": "link:Price List",
|
||||
"fieldname": "price_list_name",
|
||||
"fieldtype": "Select",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Currency",
|
||||
"options": "Currency",
|
||||
"fieldname": "price_list_currency",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Exchange Rate",
|
||||
"fieldname": "plc_conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cb_currency",
|
||||
@@ -316,6 +293,35 @@
|
||||
"hidden": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cb_price_list",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Price List",
|
||||
"options": "Price List",
|
||||
"fieldname": "price_list_name",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Currency",
|
||||
"options": "Currency",
|
||||
"fieldname": "price_list_currency",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Exchange Rate",
|
||||
"fieldname": "plc_conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"oldfieldtype": "Section Break",
|
||||
|
||||
@@ -19,6 +19,31 @@ cur_frm.cscript.fname = "indent_details";
|
||||
|
||||
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
||||
wn.require('app/utilities/doctype/sms_control/sms_control.js');
|
||||
|
||||
erpnext.buying.PurchaseRequestController = erpnext.buying.BuyingController.extend({
|
||||
refresh: function(doc) {
|
||||
this._super();
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||
cur_frm.add_custom_button("Make Supplier Quotation", cur_frm.cscript.make_supplier_quotation);
|
||||
if(flt(doc.per_ordered, 2) < 100) {
|
||||
cur_frm.add_custom_button('Make Purchase Order', cur_frm.cscript['Make Purchase Order']);
|
||||
cur_frm.add_custom_button('Stop Purchase Request', cur_frm.cscript['Stop Purchase Request']);
|
||||
}
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
||||
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button('Unstop Purchase Request', cur_frm.cscript['Unstop Purchase Request'])
|
||||
}
|
||||
});
|
||||
|
||||
var new_cscript = new erpnext.buying.PurchaseRequestController({frm: cur_frm});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
$.extend(cur_frm.cscript, new_cscript);
|
||||
|
||||
|
||||
//========================== On Load =================================================
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
@@ -43,26 +68,6 @@ cur_frm.cscript.get_item_defaults = function(doc) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//======================= Refresh =====================================
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.clear_custom_buttons();
|
||||
erpnext.hide_naming_series();
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||
cur_frm.add_custom_button("Make Supplier Quotation", cur_frm.cscript.make_supplier_quotation);
|
||||
if(flt(doc.per_ordered, 2) < 100) {
|
||||
cur_frm.add_custom_button('Make Purchase Order', cur_frm.cscript['Make Purchase Order']);
|
||||
cur_frm.add_custom_button('Stop Purchase Request', cur_frm.cscript['Stop Purchase Request']);
|
||||
}
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
||||
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button('Unstop Purchase Request', cur_frm.cscript['Unstop Purchase Request'])
|
||||
}
|
||||
|
||||
//======================= transaction date =============================
|
||||
cur_frm.cscript.transaction_date = function(doc,cdt,cdn){
|
||||
if(doc.__islocal){
|
||||
|
||||
@@ -23,6 +23,24 @@ cur_frm.cscript.other_fname = "purchase_tax_details";
|
||||
wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
|
||||
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
||||
|
||||
erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({
|
||||
refresh: function() {
|
||||
this._super();
|
||||
|
||||
cur_frm.cscript.load_taxes(this.frm.doc);
|
||||
|
||||
if (this.frm.doc.docstatus === 1) {
|
||||
cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var new_cscript = new erpnext.buying.SupplierQuotationController({frm: cur_frm});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
$.extend(cur_frm.cscript, new_cscript);
|
||||
|
||||
|
||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||
// set missing values in parent doc
|
||||
set_missing_values(doc, {
|
||||
@@ -35,19 +53,6 @@ cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
erpnext.hide_naming_series();
|
||||
cur_frm.cscript.dynamic_label(doc, dt, dn);
|
||||
cur_frm.cscript.load_taxes(doc, dt, dn);
|
||||
|
||||
cur_frm.cscript.toggle_contact_section(doc);
|
||||
|
||||
cur_frm.clear_custom_buttons();
|
||||
if (doc.docstatus === 1) {
|
||||
cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.make_purchase_order = function() {
|
||||
var new_po_name = wn.model.make_new_doc_and_get_name("Purchase Order");
|
||||
$c("dt_map", {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-12-20 12:50:48",
|
||||
"creation": "2013-01-17 11:11:23",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2013-01-15 15:38:38"
|
||||
"modified": "2013-01-17 19:56:48"
|
||||
},
|
||||
{
|
||||
"autoname": "naming_series:",
|
||||
@@ -37,15 +37,6 @@
|
||||
"name": "Supplier Quotation",
|
||||
"doctype": "DocType"
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "To manage multiple series please go to Setup > Manage Series",
|
||||
@@ -166,37 +157,6 @@
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break2",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total*",
|
||||
"oldfieldname": "net_total",
|
||||
"fieldname": "net_total",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 0,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total (Import)",
|
||||
"oldfieldname": "net_total_import",
|
||||
"fieldname": "net_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
@@ -206,40 +166,10 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Supplier's currency",
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Currency",
|
||||
"oldfieldname": "currency",
|
||||
"permlevel": 0,
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Select",
|
||||
"reqd": 1,
|
||||
"options": "link:Currency"
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Rate at which supplier's currency is converted to company's base currency",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Conversion Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"default": "1",
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 1,
|
||||
"hidden": 0,
|
||||
"options": "Simple",
|
||||
"fieldname": "section_break_14",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
@@ -266,6 +196,73 @@
|
||||
"hidden": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Currency & Price List",
|
||||
"fieldname": "currency_price_list",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Supplier's currency",
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Currency",
|
||||
"oldfieldname": "currency",
|
||||
"permlevel": 0,
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Select",
|
||||
"reqd": 1,
|
||||
"options": "link:Currency"
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Rate at which supplier's currency is converted to company's base currency",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Exchange Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"default": "1",
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 1,
|
||||
"hidden": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "cb_price_list",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Price List",
|
||||
"options": "Price List",
|
||||
"fieldname": "price_list_name",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Currency",
|
||||
"options": "Currency",
|
||||
"fieldname": "price_list_currency",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Exchange Rate",
|
||||
"fieldname": "plc_conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
@@ -327,6 +324,113 @@
|
||||
"fieldtype": "HTML",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
"label": "Totals",
|
||||
"fieldname": "totals",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total (Import)",
|
||||
"oldfieldname": "net_total_import",
|
||||
"fieldname": "net_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added (Import)",
|
||||
"oldfieldname": "other_charges_added_import",
|
||||
"fieldname": "other_charges_added_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted (Import)",
|
||||
"oldfieldname": "other_charges_deducted_import",
|
||||
"fieldname": "other_charges_deducted_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total (Import)",
|
||||
"oldfieldname": "grand_total_import",
|
||||
"fieldname": "grand_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words(Import)",
|
||||
"oldfieldname": "in_words_import",
|
||||
"fieldname": "in_words_import",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break4",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total*",
|
||||
"oldfieldname": "net_total",
|
||||
"fieldname": "net_total",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 0,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added",
|
||||
"oldfieldname": "other_charges_added",
|
||||
"fieldname": "other_charges_added",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted",
|
||||
"oldfieldname": "other_charges_deducted",
|
||||
"fieldname": "other_charges_deducted",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
@@ -338,14 +442,6 @@
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
"label": "Totals",
|
||||
"fieldname": "totals",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
@@ -378,82 +474,6 @@
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added",
|
||||
"oldfieldname": "other_charges_added",
|
||||
"fieldname": "other_charges_added",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted",
|
||||
"oldfieldname": "other_charges_deducted",
|
||||
"fieldname": "other_charges_deducted",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break4",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total (Import)",
|
||||
"oldfieldname": "grand_total_import",
|
||||
"fieldname": "grand_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words(Import)",
|
||||
"oldfieldname": "in_words_import",
|
||||
"fieldname": "in_words_import",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added (Import)",
|
||||
"oldfieldname": "other_charges_added_import",
|
||||
"fieldname": "other_charges_added_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted (Import)",
|
||||
"oldfieldname": "other_charges_deducted_import",
|
||||
"fieldname": "other_charges_deducted_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
@@ -464,8 +484,8 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"allow_on_submit": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Letter Head",
|
||||
"oldfieldname": "letter_head",
|
||||
|
||||
@@ -82,7 +82,7 @@ def get_item_details(args):
|
||||
|
||||
if args.doctype in ["Purchase Order", "Purchase Invoice", "Purchase Receipt"]:
|
||||
# try fetching from price list
|
||||
if args.price_list_name:
|
||||
if args.price_list_name and args.price_list_currency:
|
||||
rates_as_per_price_list = get_rates_as_per_price_list(args, item_wrapper.doclist)
|
||||
if rates_as_per_price_list:
|
||||
out.update(rates_as_per_price_list)
|
||||
|
||||
Reference in New Issue
Block a user