Merge branch 'develop' of github.com:frappe/erpnext into call-summary-dialog
This commit is contained in:
@@ -11,9 +11,6 @@ $(document).bind('toolbar_setup', function() {
|
||||
href="https://discuss.erpnext.com">Feedback</a></p>'
|
||||
|
||||
|
||||
$('.navbar-home').html('<img class="erpnext-icon" src="'+
|
||||
frappe.urllib.get_base_url()+'/assets/erpnext/images/erp-icon.svg" />');
|
||||
|
||||
$('[data-link="docs"]').attr("href", "https://erpnext.com/docs")
|
||||
$('[data-link="issues"]').attr("href", "https://github.com/frappe/erpnext/issues")
|
||||
|
||||
@@ -41,7 +38,8 @@ $.extend(frappe.create_routes, {
|
||||
"Item Group": "Tree/Item Group",
|
||||
"Sales Person": "Tree/Sales Person",
|
||||
"Account": "Tree/Account",
|
||||
"Cost Center": "Tree/Cost Center"
|
||||
"Cost Center": "Tree/Cost Center",
|
||||
"Department": "Tree/Department",
|
||||
});
|
||||
|
||||
// preferred modules for breadcrumbs
|
||||
|
||||
@@ -144,7 +144,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
item.discount_amount = flt(item_rate) * flt(item.discount_percentage) / 100;
|
||||
}
|
||||
|
||||
item.rate = flt((item.price_list_rate) - (item.discount_amount), precision('rate', item));
|
||||
if (item.discount_amount) {
|
||||
item.rate = flt((item.price_list_rate) - (item.discount_amount), precision('rate', item));
|
||||
}
|
||||
|
||||
this.calculate_taxes_and_totals();
|
||||
},
|
||||
|
||||
@@ -118,34 +118,13 @@ function get_filters(){
|
||||
"options": erpnext.get_presentation_currency_list()
|
||||
},
|
||||
{
|
||||
"fieldname":"cost_center",
|
||||
"fieldname": "cost_center",
|
||||
"label": __("Cost Center"),
|
||||
"fieldtype": "MultiSelect",
|
||||
get_data: function() {
|
||||
var cost_centers = frappe.query_report.get_filter_value("cost_center") || "";
|
||||
|
||||
const values = cost_centers.split(/\s*,\s*/).filter(d => d);
|
||||
const txt = cost_centers.match(/[^,\s*]*$/)[0] || '';
|
||||
let data = [];
|
||||
|
||||
frappe.call({
|
||||
type: "GET",
|
||||
method:'frappe.desk.search.search_link',
|
||||
async: false,
|
||||
no_spinner: true,
|
||||
args: {
|
||||
doctype: "Cost Center",
|
||||
txt: txt,
|
||||
filters: {
|
||||
"company": frappe.query_report.get_filter_value("company"),
|
||||
"name": ["not in", values]
|
||||
}
|
||||
},
|
||||
callback: function(r) {
|
||||
data = r.results;
|
||||
}
|
||||
"fieldtype": "MultiSelectList",
|
||||
get_data: function(txt) {
|
||||
return frappe.db.get_link_options('Cost Center', txt, {
|
||||
company: frappe.query_report.get_filter_value("company")
|
||||
});
|
||||
return data;
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -65,6 +65,9 @@ $.extend(erpnext, {
|
||||
},
|
||||
|
||||
get_dimension_filters: async function() {
|
||||
if (!frappe.model.can_read('Accounting Dimension')) {
|
||||
return [];
|
||||
}
|
||||
let dimensions = await frappe.db.get_list('Accounting Dimension', {
|
||||
fields: ['label', 'fieldname', 'document_type'],
|
||||
filters: {
|
||||
@@ -560,6 +563,7 @@ erpnext.utils.map_current_doc = function(opts) {
|
||||
if(!r.exc) {
|
||||
var doc = frappe.model.sync(r.message);
|
||||
cur_frm.dirty();
|
||||
erpnext.utils.clear_duplicates();
|
||||
cur_frm.refresh();
|
||||
}
|
||||
}
|
||||
@@ -590,6 +594,27 @@ erpnext.utils.map_current_doc = function(opts) {
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.utils.clear_duplicates = function() {
|
||||
const unique_items = new Map();
|
||||
/*
|
||||
Create a Map of items with
|
||||
item_code => [qty, warehouse, batch_no]
|
||||
*/
|
||||
let items = [];
|
||||
|
||||
for (let item of cur_frm.doc.items) {
|
||||
if (!(unique_items.has(item.item_code) && unique_items.get(item.item_code)[0] === item.qty &&
|
||||
unique_items.get(item.item_code)[1] === item.warehouse && unique_items.get(item.item_code)[2] === item.batch_no &&
|
||||
unique_items.get(item.item_code)[3] === item.delivery_date && unique_items.get(item.item_code)[4] === item.required_date &&
|
||||
unique_items.get(item.item_code)[5] === item.rate)) {
|
||||
|
||||
unique_items.set(item.item_code, [item.qty, item.warehouse, item.batch_no, item.delivery_date, item.required_date, item.rate]);
|
||||
items.push(item);
|
||||
}
|
||||
}
|
||||
cur_frm.doc.items = items;
|
||||
}
|
||||
|
||||
frappe.form.link_formatters['Item'] = function(value, doc) {
|
||||
if(doc && doc.item_name && doc.item_name !== value) {
|
||||
return value? value + ': ' + doc.item_name: doc.item_name;
|
||||
|
||||
@@ -44,6 +44,13 @@ erpnext.SerialNoBatchSelector = Class.extend({
|
||||
label: __(me.warehouse_details.type),
|
||||
default: me.warehouse_details.name,
|
||||
onchange: function(e) {
|
||||
|
||||
if(me.has_batch) {
|
||||
fields = fields.concat(me.get_batch_fields());
|
||||
} else {
|
||||
fields = fields.concat(me.get_serial_no_fields());
|
||||
}
|
||||
|
||||
me.warehouse_details.name = this.get_value();
|
||||
var batches = this.layout.fields_dict.batches;
|
||||
if(batches) {
|
||||
@@ -263,6 +270,15 @@ erpnext.SerialNoBatchSelector = Class.extend({
|
||||
|
||||
get_batch_fields: function() {
|
||||
var me = this;
|
||||
|
||||
let filters = {
|
||||
item_code: me.item_code
|
||||
}
|
||||
|
||||
if (me.warehouse || me.warehouse_details.name) {
|
||||
filters['warehouse'] = me.warehouse || me.warehouse_details.name;
|
||||
}
|
||||
|
||||
return [
|
||||
{fieldtype:'Section Break', label: __('Batches')},
|
||||
{fieldname: 'batches', fieldtype: 'Table', label: __('Batch Entries'),
|
||||
@@ -276,8 +292,8 @@ erpnext.SerialNoBatchSelector = Class.extend({
|
||||
'in_list_view': 1,
|
||||
get_query: function () {
|
||||
return {
|
||||
filters: { item: me.item_code },
|
||||
query: 'erpnext.controllers.queries.get_batch_numbers'
|
||||
filters: filters,
|
||||
query: 'erpnext.controllers.queries.get_batch_no'
|
||||
};
|
||||
},
|
||||
change: function () {
|
||||
|
||||
Reference in New Issue
Block a user