Merge branch 'sla_fix' of https://github.com/hrwx/erpnext into sla_fix

This commit is contained in:
Himanshu Warekar 2019-06-27 01:29:25 +05:30
commit 5ebdf76669
21 changed files with 1057 additions and 3565 deletions

View File

@ -49,7 +49,7 @@ The ERPNext code is licensed as GNU General Public License (v3) and the Document
## Contributing ## Contributing
1. [Issue Guidelines](https://github.com/frappe/erpnext/wiki/Issue-Guidelines) 1. [Issue Guidelines](https://github.com/frappe/erpnext/wiki/Issue-Guidelines)
1. [Report Security Vulnerabilities](https://erpnext.com/report) 1. [Report Security Vulnerabilities](https://erpnext.com/security)
1. [Pull Request Requirements](https://github.com/frappe/erpnext/wiki/Contribution-Guidelines) 1. [Pull Request Requirements](https://github.com/frappe/erpnext/wiki/Contribution-Guidelines)
1. [Translations](https://translate.erpnext.com) 1. [Translations](https://translate.erpnext.com)
1. [Chart of Accounts](https://charts.erpnext.com) 1. [Chart of Accounts](https://charts.erpnext.com)

View File

@ -485,7 +485,7 @@ class SalesInvoice(SellingController):
"""Set against account for debit to account""" """Set against account for debit to account"""
against_acc = [] against_acc = []
for d in self.get('items'): for d in self.get('items'):
if d.income_account not in against_acc: if d.income_account and d.income_account not in against_acc:
against_acc.append(d.income_account) against_acc.append(d.income_account)
self.against_income_account = ','.join(against_acc) self.against_income_account = ','.join(against_acc)

View File

@ -25,7 +25,8 @@ def get_ordered_to_be_billed_data(args):
from from
`{parent_tab}`, `{child_tab}` `{parent_tab}`, `{child_tab}`
where where
`{parent_tab}`.name = `{child_tab}`.parent and `{parent_tab}`.docstatus = 1 and `{parent_tab}`.status != 'Closed' `{parent_tab}`.name = `{child_tab}`.parent and `{parent_tab}`.docstatus = 1
and `{parent_tab}`.status not in ('Closed', 'Completed')
and `{child_tab}`.amount > 0 and round(`{child_tab}`.billed_amt * and `{child_tab}`.amount > 0 and round(`{child_tab}`.billed_amt *
ifnull(`{parent_tab}`.conversion_rate, 1), {precision}) < `{child_tab}`.base_amount ifnull(`{parent_tab}`.conversion_rate, 1), {precision}) < `{child_tab}`.base_amount
order by order by

View File

@ -107,7 +107,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
if(doc.docstatus == 1) { if(doc.docstatus == 1) {
if(!in_list(["Closed", "Delivered"], doc.status)) { if(!in_list(["Closed", "Delivered"], doc.status)) {
if (this.frm.has_perm("submit")) { if (this.frm.has_perm("submit")) {
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) { if(flt(doc.per_billed, 6) < 100 || flt(doc.per_received, 6) < 100) {
if (doc.status != "On Hold") { if (doc.status != "On Hold") {
this.frm.add_custom_button(__('Hold'), () => this.hold_purchase_order(), __("Status")); this.frm.add_custom_button(__('Hold'), () => this.hold_purchase_order(), __("Status"));
} else{ } else{

View File

@ -40,17 +40,6 @@ def get_data():
"description": _("Tree of financial accounts."), "description": _("Tree of financial accounts."),
"onboard": 1, "onboard": 1,
}, },
{
"type": "doctype",
"name": "Journal Entry",
"description": _("Accounting journal entries."),
"onboard": 1,
},
{
"type": "doctype",
"name": "Opening Invoice Creation Tool",
"description": _("Create Opening Sales and Purchase Invoices")
},
] ]
}, },
{ {
@ -73,11 +62,6 @@ def get_data():
"name": "Payment Request", "name": "Payment Request",
"description": _("Payment Request"), "description": _("Payment Request"),
}, },
{
"type": "doctype",
"name": "Payment Entry",
"description": _("Bank/Cash transactions against party or for internal transfer")
},
{ {
"type": "doctype", "type": "doctype",
"name": "Payment Term", "name": "Payment Term",
@ -179,6 +163,26 @@ def get_data():
"name": "Accounting Dimension", "name": "Accounting Dimension",
"description": _("Setup custom dimensions for accounting") "description": _("Setup custom dimensions for accounting")
}, },
{
"type": "doctype",
"name": "Opening Invoice Creation Tool",
"description": _("Create Opening Sales and Purchase Invoices")
},
]
},
{
"label": _("Accounting Entries"),
"items": [
{
"type": "doctype",
"name": "Payment Entry",
"description": _("Bank/Cash transactions against party or for internal transfer")
},
{
"type": "doctype",
"name": "Journal Entry",
"description": _("Accounting journal entries.")
},
] ]
}, },
{ {

View File

@ -428,8 +428,9 @@ class BuyingController(StockController):
elif not flt(d.rejected_qty): elif not flt(d.rejected_qty):
d.rejected_qty = flt(d.received_qty) - flt(d.qty) d.rejected_qty = flt(d.received_qty) - flt(d.qty)
val = flt(d.qty) + flt(d.rejected_qty)
# Check Received Qty = Accepted Qty + Rejected Qty # Check Received Qty = Accepted Qty + Rejected Qty
if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)): if (flt(val, d.precision("received_qty")) != flt(d.received_qty, d.precision("received_qty"))):
frappe.throw(_("Accepted + Rejected Qty must be equal to Received quantity for Item {0}").format(d.item_code)) frappe.throw(_("Accepted + Rejected Qty must be equal to Received quantity for Item {0}").format(d.item_code))
def validate_negative_quantity(self, item_row, field_list): def validate_negative_quantity(self, item_row, field_list):

View File

@ -27,7 +27,7 @@ status_map = {
], ],
"Quotation": [ "Quotation": [
["Draft", None], ["Draft", None],
["Submitted", "eval:self.docstatus==1"], ["Open", "eval:self.docstatus==1"],
["Lost", "eval:self.status=='Lost'"], ["Lost", "eval:self.status=='Lost'"],
["Ordered", "has_sales_order"], ["Ordered", "has_sales_order"],
["Cancelled", "eval:self.docstatus==2"], ["Cancelled", "eval:self.docstatus==2"],

View File

@ -22,7 +22,16 @@ def verify_request():
frappe.set_user(woocommerce_settings.creation_user) frappe.set_user(woocommerce_settings.creation_user)
@frappe.whitelist(allow_guest=True) @frappe.whitelist(allow_guest=True)
def order(): def order(*args, **kwargs):
try:
_order(*args, **kwargs)
except Exception:
error_message = frappe.get_traceback()+"\n\n Request Data: \n"+json.loads(frappe.request.data).__str__()
frappe.log_error(error_message, "WooCommerce Error")
raise
def _order(*args, **kwargs):
woocommerce_settings = frappe.get_doc("Woocommerce Settings") woocommerce_settings = frappe.get_doc("Woocommerce Settings")
if frappe.flags.woocomm_test_order_data: if frappe.flags.woocomm_test_order_data:
fd = frappe.flags.woocomm_test_order_data fd = frappe.flags.woocomm_test_order_data

View File

@ -46,7 +46,7 @@ update_and_get_user_progress = "erpnext.utilities.user_progress_utils.update_def
on_session_creation = "erpnext.shopping_cart.utils.set_cart_count" on_session_creation = "erpnext.shopping_cart.utils.set_cart_count"
on_logout = "erpnext.shopping_cart.utils.clear_cart_count" on_logout = "erpnext.shopping_cart.utils.clear_cart_count"
treeviews = ['Account', 'Cost Center', 'Warehouse', 'Item Group', 'Customer Group', 'Sales Person', 'Territory', 'Assessment Group'] treeviews = ['Account', 'Cost Center', 'Warehouse', 'Item Group', 'Customer Group', 'Sales Person', 'Territory', 'Assessment Group', 'Department']
# website # website
update_website_context = ["erpnext.shopping_cart.utils.update_website_context", "erpnext.education.doctype.education_settings.education_settings.update_website_context"] update_website_context = ["erpnext.shopping_cart.utils.update_website_context", "erpnext.education.doctype.education_settings.education_settings.update_website_context"]

View File

@ -2,8 +2,8 @@
// For license information, please see license.txt // For license information, please see license.txt
frappe.views.calendar["Attendance"] = { frappe.views.calendar["Attendance"] = {
field_map: { field_map: {
"start": "date", "start": "attendance_date",
"end": "date", "end": "attendance_date",
"id": "name", "id": "name",
"docstatus": 1 "docstatus": 1
}, },

View File

@ -4,7 +4,7 @@
frappe.ui.form.on('Department', { frappe.ui.form.on('Department', {
refresh: function(frm) { refresh: function(frm) {
// read-only for root department // read-only for root department
if(!frm.doc.parent_department) { if(!frm.doc.parent_department && !frm.is_new()) {
frm.set_read_only(); frm.set_read_only();
frm.set_intro(__("This is a root department and cannot be edited.")); frm.set_intro(__("This is a root department and cannot be edited."));
} }

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0, "allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
@ -19,6 +20,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "department_name", "fieldname": "department_name",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@ -52,6 +54,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "parent_department", "fieldname": "parent_department",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -85,6 +88,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "company", "fieldname": "company",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -118,6 +122,7 @@
"bold": 1, "bold": 1,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "is_group", "fieldname": "is_group",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@ -150,6 +155,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "disabled", "fieldname": "disabled",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@ -182,6 +188,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "section_break_4", "fieldname": "section_break_4",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@ -214,6 +221,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "Days for which Holidays are blocked for this department.", "description": "Days for which Holidays are blocked for this department.",
"fetch_if_empty": 0,
"fieldname": "leave_block_list", "fieldname": "leave_block_list",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -246,6 +254,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "leave_section", "fieldname": "leave_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@ -279,6 +288,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "The first Leave Approver in the list will be set as the default Leave Approver.", "description": "The first Leave Approver in the list will be set as the default Leave Approver.",
"fetch_if_empty": 0,
"fieldname": "leave_approvers", "fieldname": "leave_approvers",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
@ -312,6 +322,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "expense_section", "fieldname": "expense_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@ -345,6 +356,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "The first Expense Approver in the list will be set as the default Expense Approver.", "description": "The first Expense Approver in the list will be set as the default Expense Approver.",
"fetch_if_empty": 0,
"fieldname": "expense_approvers", "fieldname": "expense_approvers",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
@ -378,6 +390,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "lft", "fieldname": "lft",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 1, "hidden": 1,
@ -410,6 +423,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "rgt", "fieldname": "rgt",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 1, "hidden": 1,
@ -442,6 +456,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "old_parent", "fieldname": "old_parent",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
@ -479,7 +494,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-08-29 06:26:12.995703", "modified": "2019-06-25 18:43:05.550387",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Department", "name": "Department",
@ -543,7 +558,7 @@
"write": 1 "write": 1
} }
], ],
"quick_entry": 1, "quick_entry": 0,
"read_only": 0, "read_only": 0,
"read_only_onload": 0, "read_only_onload": 0,
"show_name_in_global_search": 1, "show_name_in_global_search": 1,

View File

@ -25,5 +25,13 @@ frappe.ui.form.on("Job Applicant", {
} }
} }
frm.set_query("job_title", function() {
return {
filters: {
'status': 'Open'
}
};
});
} }
}); });

View File

@ -605,4 +605,5 @@ erpnext.patches.v11_1.delete_scheduling_tool
erpnext.patches.v12_0.make_custom_fields_for_bank_remittance #14-06-2019 erpnext.patches.v12_0.make_custom_fields_for_bank_remittance #14-06-2019
execute:frappe.delete_doc_if_exists("Page", "support-analytics") execute:frappe.delete_doc_if_exists("Page", "support-analytics")
erpnext.patches.v12_0.make_item_manufacturer erpnext.patches.v12_0.make_item_manufacturer
erpnext.patches.v12_0.set_quotation_status
erpnext.patches.v12_0.set_priority_for_support erpnext.patches.v12_0.set_priority_for_support

View File

@ -0,0 +1,7 @@
from __future__ import unicode_literals
import frappe
def execute():
frappe.db.sql(""" UPDATE `tabQuotation` set status = 'Open'
where docstatus = 1 and status = 'Submitted' """)

File diff suppressed because it is too large Load Diff

View File

@ -2,11 +2,11 @@ frappe.listview_settings['Quotation'] = {
add_fields: ["customer_name", "base_grand_total", "status", add_fields: ["customer_name", "base_grand_total", "status",
"company", "currency", 'valid_till'], "company", "currency", 'valid_till'],
get_indicator: function(doc) { get_indicator: function(doc) {
if(doc.status==="Submitted") { if(doc.status==="Open") {
if (doc.valid_till && doc.valid_till < frappe.datetime.nowdate()) { if (doc.valid_till && doc.valid_till < frappe.datetime.nowdate()) {
return [__("Expired"), "darkgrey", "valid_till,<," + frappe.datetime.nowdate()]; return [__("Expired"), "darkgrey", "valid_till,<," + frappe.datetime.nowdate()];
} else { } else {
return [__("Submitted"), "blue", "status,=,Submitted"]; return [__("Open"), "orange", "status,=,Open"];
} }
} else if(doc.status==="Ordered") { } else if(doc.status==="Ordered") {
return [__("Ordered"), "green", "status,=,Ordered"]; return [__("Ordered"), "green", "status,=,Ordered"];

View File

@ -34,7 +34,7 @@ frappe.ui.form.on("Sales Order", {
}, },
refresh: function(frm) { refresh: function(frm) {
if(frm.doc.docstatus === 1 && frm.doc.status !== 'Closed' if(frm.doc.docstatus === 1 && frm.doc.status !== 'Closed'
&& flt(frm.doc.per_delivered) < 100 && flt(frm.doc.per_billed) < 100) { && flt(frm.doc.per_delivered, 6) < 100 && flt(frm.doc.per_billed, 6) < 100) {
frm.add_custom_button(__('Update Items'), () => { frm.add_custom_button(__('Update Items'), () => {
erpnext.utils.update_child_items({ erpnext.utils.update_child_items({
frm: frm, frm: frm,

View File

@ -90,70 +90,31 @@ erpnext.SalesFunnel = class SalesFunnel {
get_data(btn) { get_data(btn) {
var me = this; var me = this;
if (me.options.chart == 'sales_funnel'){ const method_map = {
frappe.call({ "sales_funnel": "erpnext.selling.page.sales_funnel.sales_funnel.get_funnel_data",
method: "erpnext.selling.page.sales_funnel.sales_funnel.get_funnel_data", "opp_by_lead_source": "erpnext.selling.page.sales_funnel.sales_funnel.get_opp_by_lead_source",
args: { "sales_pipeline": "erpnext.selling.page.sales_funnel.sales_funnel.get_pipeline_data"
from_date: this.options.from_date, };
to_date: this.options.to_date, frappe.call({
company: this.company method: method_map[this.options.chart],
}, args: {
btn: btn, from_date: this.options.from_date,
callback: function(r) { to_date: this.options.to_date,
if(!r.exc) { company: this.company
me.options.data = r.message; },
if (me.options.data=='empty') { btn: btn,
const $parent = me.elements.funnel_wrapper; callback: function(r) {
$parent.html(__('No data for this period')); if(!r.exc) {
} else { me.options.data = r.message;
me.render_funnel(); if (me.options.data=='empty') {
} const $parent = me.elements.funnel_wrapper;
$parent.html(__('No data for this period'));
} else {
me.render();
} }
} }
}); }
} else if (me.options.chart == 'opp_by_lead_source'){ });
frappe.call({
method: "erpnext.selling.page.sales_funnel.sales_funnel.get_opp_by_lead_source",
args: {
from_date: this.options.from_date,
to_date: this.options.to_date,
company: this.company
},
btn: btn,
callback: function(r) {
if(!r.exc) {
me.options.data = r.message;
if (me.options.data=='empty') {
const $parent = me.elements.funnel_wrapper;
$parent.html(__('No data for this period'));
} else {
me.render_opp_by_lead_source();
}
}
}
});
} else if (me.options.chart == 'sales_pipeline'){
frappe.call({
method: "erpnext.selling.page.sales_funnel.sales_funnel.get_pipeline_data",
args: {
from_date: this.options.from_date,
to_date: this.options.to_date,
company: this.company
},
btn: btn,
callback: function(r) {
if(!r.exc) {
me.options.data = r.message;
if (me.options.data=='empty') {
const $parent = me.elements.funnel_wrapper;
$parent.html(__('No data for this period'));
} else {
me.render_pipeline();
}
}
}
});
}
} }
render() { render() {
@ -161,9 +122,9 @@ erpnext.SalesFunnel = class SalesFunnel {
if (me.options.chart == 'sales_funnel'){ if (me.options.chart == 'sales_funnel'){
me.render_funnel(); me.render_funnel();
} else if (me.options.chart == 'opp_by_lead_source'){ } else if (me.options.chart == 'opp_by_lead_source'){
me.render_opp_by_lead_source(); me.render_chart("Sales Opportunities by Source");
} else if (me.options.chart == 'sales_pipeline'){ } else if (me.options.chart == 'sales_pipeline'){
me.render_pipeline(); me.render_chart("Sales Pipeline by Stage");
} }
} }
@ -270,15 +231,15 @@ erpnext.SalesFunnel = class SalesFunnel {
context.fillText(__(title), width + 20, y_mid); context.fillText(__(title), width + 20, y_mid);
} }
render_opp_by_lead_source() { render_chart(title) {
let me = this; let me = this;
let currency = frappe.defaults.get_default("currency"); let currency = frappe.defaults.get_default("currency");
let chart_data = me.options.data ? me.options.data : null; let chart_data = me.options.data ? me.options.data : null;
const parent = me.elements.funnel_wrapper[0]; const parent = me.elements.funnel_wrapper[0];
this.chart = new Chart(parent, { this.chart = new frappe.Chart(parent, {
title: __("Sales Opportunities by Source"), title: title,
height: 400, height: 400,
data: chart_data, data: chart_data,
type: 'bar', type: 'bar',
@ -290,23 +251,4 @@ erpnext.SalesFunnel = class SalesFunnel {
} }
}); });
} }
render_pipeline() {
let me = this;
let currency = frappe.defaults.get_default("currency");
let chart_data = me.options.data ? me.options.data : null;
const parent = me.elements.funnel_wrapper[0];
this.chart = new Chart(parent, {
title: __("Sales Pipeline by Stage"),
height: 400,
data: chart_data,
type: 'bar',
tooltipOptions: {
formatTooltipY: d => format_currency(d, currency),
},
colors: ['light-green', 'green']
});
}
}; };

View File

@ -419,6 +419,8 @@ def get_returned_qty_map(delivery_note):
@frappe.whitelist() @frappe.whitelist()
def make_sales_invoice(source_name, target_doc=None): def make_sales_invoice(source_name, target_doc=None):
doc = frappe.get_doc('Delivery Note', source_name) doc = frappe.get_doc('Delivery Note', source_name)
to_make_invoice_qty_map = {}
returned_qty_map = get_returned_qty_map(source_name) returned_qty_map = get_returned_qty_map(source_name)
invoiced_qty_map = get_invoiced_qty_map(source_name) invoiced_qty_map = get_invoiced_qty_map(source_name)
@ -439,8 +441,7 @@ def make_sales_invoice(source_name, target_doc=None):
target.update(get_fetch_values("Sales Invoice", 'company_address', target.company_address)) target.update(get_fetch_values("Sales Invoice", 'company_address', target.company_address))
def update_item(source_doc, target_doc, source_parent): def update_item(source_doc, target_doc, source_parent):
target_doc.qty, returned_qty = get_pending_qty(source_doc) target_doc.qty = to_make_invoice_qty_map[source_doc.name]
returned_qty_map[source_doc.item_code] = returned_qty
if source_doc.serial_no and source_parent.per_billed > 0: if source_doc.serial_no and source_parent.per_billed > 0:
target_doc.serial_no = get_delivery_note_serial_no(source_doc.item_code, target_doc.serial_no = get_delivery_note_serial_no(source_doc.item_code,
@ -448,7 +449,12 @@ def make_sales_invoice(source_name, target_doc=None):
def get_pending_qty(item_row): def get_pending_qty(item_row):
pending_qty = item_row.qty - invoiced_qty_map.get(item_row.name, 0) pending_qty = item_row.qty - invoiced_qty_map.get(item_row.name, 0)
returned_qty = flt(returned_qty_map.get(item_row.item_code, 0))
returned_qty = 0
if returned_qty_map.get(item_row.item_code, 0) > 0:
returned_qty = flt(returned_qty_map.get(item_row.item_code, 0))
returned_qty_map[item_row.item_code] -= pending_qty
if returned_qty: if returned_qty:
if returned_qty >= pending_qty: if returned_qty >= pending_qty:
pending_qty = 0 pending_qty = 0
@ -456,7 +462,10 @@ def make_sales_invoice(source_name, target_doc=None):
else: else:
pending_qty -= returned_qty pending_qty -= returned_qty
returned_qty = 0 returned_qty = 0
return pending_qty, returned_qty
to_make_invoice_qty_map[item_row.name] = pending_qty
return pending_qty
doc = get_mapped_doc("Delivery Note", source_name, { doc = get_mapped_doc("Delivery Note", source_name, {
"Delivery Note": { "Delivery Note": {
@ -476,7 +485,7 @@ def make_sales_invoice(source_name, target_doc=None):
"cost_center": "cost_center" "cost_center": "cost_center"
}, },
"postprocess": update_item, "postprocess": update_item,
"filter": lambda d: get_pending_qty(d)[0] <= 0 if not doc.get("is_return") else get_pending_qty(d)[0] > 0 "filter": lambda d: get_pending_qty(d) <= 0 if not doc.get("is_return") else get_pending_qty(d) > 0
}, },
"Sales Taxes and Charges": { "Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges", "doctype": "Sales Taxes and Charges",

View File

@ -1,60 +1,23 @@
{ {
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 0, "allow_rename": 1,
"autoname": "Prompt", "autoname": "Prompt",
"beta": 0,
"creation": "2017-10-06 12:53:34.714153", "creation": "2017-10-06 12:53:34.714153",
"custom": 0,
"docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Setup", "document_type": "Setup",
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [
"description"
],
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "description", "fieldname": "description",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "label": "Description"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Description",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
} }
], ],
"has_web_view": 0, "modified": "2019-06-26 16:56:39.863392",
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-11-15 17:27:19.796807",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Support", "module": "Support",
"name": "Issue Type", "name": "Issue Type",
@ -62,54 +25,32 @@
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "System Manager", "role": "System Manager",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
}, },
{ {
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Support Team", "role": "Support Team",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
} }
], ],
"quick_entry": 1, "quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"search_fields": "",
"show_name_in_global_search": 0,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"title_field": "", "track_changes": 1
"track_changes": 1,
"track_seen": 0
} }