mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 20:59:11 +00:00
Merge branch 'version-11-hotfix' into v11-work-order-bugs
This commit is contained in:
@@ -70,6 +70,7 @@ def _execute(filters, additional_table_columns=None, additional_query_columns=No
|
|||||||
if tax_acc not in income_accounts:
|
if tax_acc not in income_accounts:
|
||||||
tax_amount_precision = get_field_precision(frappe.get_meta("Sales Taxes and Charges").get_field("tax_amount"), currency=company_currency) or 2
|
tax_amount_precision = get_field_precision(frappe.get_meta("Sales Taxes and Charges").get_field("tax_amount"), currency=company_currency) or 2
|
||||||
tax_amount = flt(invoice_tax_map.get(inv.name, {}).get(tax_acc), tax_amount_precision)
|
tax_amount = flt(invoice_tax_map.get(inv.name, {}).get(tax_acc), tax_amount_precision)
|
||||||
|
total_tax += tax_amount
|
||||||
row.append(tax_amount)
|
row.append(tax_amount)
|
||||||
|
|
||||||
# total tax, grand total, outstanding amount & rounded total
|
# total tax, grand total, outstanding amount & rounded total
|
||||||
|
|||||||
@@ -1097,6 +1097,8 @@ def get_supplier_block_status(party_name):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name):
|
def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name):
|
||||||
data = json.loads(trans_items)
|
data = json.loads(trans_items)
|
||||||
|
sales_doctypes = ['Sales Order', 'Sales Invoice', 'Delivery Note', 'Quotation']
|
||||||
|
|
||||||
for d in data:
|
for d in data:
|
||||||
child_item = frappe.get_doc(parent_doctype + ' Item', d.get("docname"))
|
child_item = frappe.get_doc(parent_doctype + ' Item', d.get("docname"))
|
||||||
|
|
||||||
@@ -1118,18 +1120,22 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name):
|
|||||||
# if rate is greater than price_list_rate, set margin
|
# if rate is greater than price_list_rate, set margin
|
||||||
# or set discount
|
# or set discount
|
||||||
child_item.discount_percentage = 0
|
child_item.discount_percentage = 0
|
||||||
child_item.margin_type = "Amount"
|
|
||||||
child_item.margin_rate_or_amount = flt(child_item.rate - child_item.price_list_rate,
|
if parent_doctype in sales_doctypes:
|
||||||
child_item.precision("margin_rate_or_amount"))
|
child_item.margin_type = "Amount"
|
||||||
child_item.rate_with_margin = child_item.rate
|
child_item.margin_rate_or_amount = flt(child_item.rate - child_item.price_list_rate,
|
||||||
|
child_item.precision("margin_rate_or_amount"))
|
||||||
|
child_item.rate_with_margin = child_item.rate
|
||||||
else:
|
else:
|
||||||
child_item.discount_percentage = flt((1 - flt(child_item.rate) / flt(child_item.price_list_rate)) * 100.0,
|
child_item.discount_percentage = flt((1 - flt(child_item.rate) / flt(child_item.price_list_rate)) * 100.0,
|
||||||
child_item.precision("discount_percentage"))
|
child_item.precision("discount_percentage"))
|
||||||
child_item.discount_amount = flt(
|
child_item.discount_amount = flt(
|
||||||
child_item.price_list_rate) - flt(child_item.rate)
|
child_item.price_list_rate) - flt(child_item.rate)
|
||||||
child_item.margin_type = ""
|
|
||||||
child_item.margin_rate_or_amount = 0
|
if parent_doctype in sales_doctypes:
|
||||||
child_item.rate_with_margin = 0
|
child_item.margin_type = ""
|
||||||
|
child_item.margin_rate_or_amount = 0
|
||||||
|
child_item.rate_with_margin = 0
|
||||||
|
|
||||||
child_item.flags.ignore_validate_update_after_submit = True
|
child_item.flags.ignore_validate_update_after_submit = True
|
||||||
child_item.save()
|
child_item.save()
|
||||||
|
|||||||
@@ -152,6 +152,20 @@ def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=False):
|
def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=False):
|
||||||
conditions = []
|
conditions = []
|
||||||
|
|
||||||
|
#Get searchfields from meta and use in Item Link field query
|
||||||
|
meta = frappe.get_meta("Item", cached=True)
|
||||||
|
searchfields = meta.get_search_fields()
|
||||||
|
|
||||||
|
if "description" in searchfields:
|
||||||
|
searchfields.remove("description")
|
||||||
|
|
||||||
|
columns = [field for field in searchfields if not field in ["name", "item_group", "description"]]
|
||||||
|
columns = ", ".join(columns)
|
||||||
|
|
||||||
|
searchfields = searchfields + [field for field in[searchfield or "name", "item_code", "item_group", "item_name"]
|
||||||
|
if not field in searchfields]
|
||||||
|
searchfields = " or ".join([field + " like %(txt)s" for field in searchfields])
|
||||||
|
|
||||||
description_cond = ''
|
description_cond = ''
|
||||||
if frappe.db.count('Item', cache=True) < 50000:
|
if frappe.db.count('Item', cache=True) < 50000:
|
||||||
# scan description only if items are less than 50000
|
# scan description only if items are less than 50000
|
||||||
@@ -162,17 +176,14 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
|||||||
concat(substr(tabItem.item_name, 1, 40), "..."), item_name) as item_name,
|
concat(substr(tabItem.item_name, 1, 40), "..."), item_name) as item_name,
|
||||||
tabItem.item_group,
|
tabItem.item_group,
|
||||||
if(length(tabItem.description) > 40, \
|
if(length(tabItem.description) > 40, \
|
||||||
concat(substr(tabItem.description, 1, 40), "..."), description) as decription
|
concat(substr(tabItem.description, 1, 40), "..."), description) as description,
|
||||||
|
{columns}
|
||||||
from tabItem
|
from tabItem
|
||||||
where tabItem.docstatus < 2
|
where tabItem.docstatus < 2
|
||||||
and tabItem.has_variants=0
|
and tabItem.has_variants=0
|
||||||
and tabItem.disabled=0
|
and tabItem.disabled=0
|
||||||
and (tabItem.end_of_life > %(today)s or ifnull(tabItem.end_of_life, '0000-00-00')='0000-00-00')
|
and (tabItem.end_of_life > %(today)s or ifnull(tabItem.end_of_life, '0000-00-00')='0000-00-00')
|
||||||
and (tabItem.`{key}` LIKE %(txt)s
|
and ({scond} or tabItem.item_code IN (select parent from `tabItem Barcode` where barcode LIKE %(txt)s)
|
||||||
or tabItem.item_code LIKE %(txt)s
|
|
||||||
or tabItem.item_group LIKE %(txt)s
|
|
||||||
or tabItem.item_name LIKE %(txt)s
|
|
||||||
or tabItem.item_code IN (select parent from `tabItem Barcode` where barcode LIKE %(txt)s)
|
|
||||||
{description_cond})
|
{description_cond})
|
||||||
{fcond} {mcond}
|
{fcond} {mcond}
|
||||||
order by
|
order by
|
||||||
@@ -182,6 +193,8 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
|||||||
name, item_name
|
name, item_name
|
||||||
limit %(start)s, %(page_len)s """.format(
|
limit %(start)s, %(page_len)s """.format(
|
||||||
key=searchfield,
|
key=searchfield,
|
||||||
|
columns=columns,
|
||||||
|
scond=searchfields,
|
||||||
fcond=get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
|
fcond=get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
|
||||||
mcond=get_match_cond(doctype).replace('%', '%%'),
|
mcond=get_match_cond(doctype).replace('%', '%%'),
|
||||||
description_cond = description_cond),
|
description_cond = description_cond),
|
||||||
@@ -280,22 +293,31 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
"page_len": page_len
|
"page_len": page_len
|
||||||
}
|
}
|
||||||
|
|
||||||
|
having_clause = "having sum(sle.actual_qty) > 0"
|
||||||
|
if filters.get("is_return"):
|
||||||
|
having_clause = ""
|
||||||
|
|
||||||
if args.get('warehouse'):
|
if args.get('warehouse'):
|
||||||
batch_nos = frappe.db.sql("""select sle.batch_no, round(sum(sle.actual_qty),2), sle.stock_uom, concat('MFG-',batch.manufacturing_date), concat('EXP-',batch.expiry_date)
|
batch_nos = frappe.db.sql("""select sle.batch_no, round(sum(sle.actual_qty),2), sle.stock_uom,
|
||||||
from `tabStock Ledger Entry` sle
|
concat('MFG-',batch.manufacturing_date), concat('EXP-',batch.expiry_date)
|
||||||
INNER JOIN `tabBatch` batch on sle.batch_no = batch.name
|
from `tabStock Ledger Entry` sle
|
||||||
where
|
INNER JOIN `tabBatch` batch on sle.batch_no = batch.name
|
||||||
batch.disabled = 0
|
where
|
||||||
and sle.item_code = %(item_code)s
|
batch.disabled = 0
|
||||||
and sle.warehouse = %(warehouse)s
|
and sle.item_code = %(item_code)s
|
||||||
and (sle.batch_no like %(txt)s
|
and sle.warehouse = %(warehouse)s
|
||||||
or batch.manufacturing_date like %(txt)s)
|
and (sle.batch_no like %(txt)s
|
||||||
and batch.docstatus < 2
|
or batch.manufacturing_date like %(txt)s)
|
||||||
{0}
|
and batch.docstatus < 2
|
||||||
{match_conditions}
|
{cond}
|
||||||
group by batch_no having sum(sle.actual_qty) > 0
|
{match_conditions}
|
||||||
order by batch.expiry_date, sle.batch_no desc
|
group by batch_no {having_clause}
|
||||||
limit %(start)s, %(page_len)s""".format(cond, match_conditions=get_match_cond(doctype)), args)
|
order by batch.expiry_date, sle.batch_no desc
|
||||||
|
limit %(start)s, %(page_len)s""".format(
|
||||||
|
cond=cond,
|
||||||
|
match_conditions=get_match_cond(doctype),
|
||||||
|
having_clause = having_clause
|
||||||
|
), args)
|
||||||
|
|
||||||
return batch_nos
|
return batch_nos
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -233,7 +233,6 @@ scheduler_events = {
|
|||||||
],
|
],
|
||||||
"daily": [
|
"daily": [
|
||||||
"erpnext.stock.reorder_item.reorder_item",
|
"erpnext.stock.reorder_item.reorder_item",
|
||||||
"erpnext.setup.doctype.email_digest.email_digest.send",
|
|
||||||
"erpnext.support.doctype.issue.issue.auto_close_tickets",
|
"erpnext.support.doctype.issue.issue.auto_close_tickets",
|
||||||
"erpnext.crm.doctype.opportunity.opportunity.auto_close_opportunity",
|
"erpnext.crm.doctype.opportunity.opportunity.auto_close_opportunity",
|
||||||
"erpnext.controllers.accounts_controller.update_invoice_status",
|
"erpnext.controllers.accounts_controller.update_invoice_status",
|
||||||
@@ -252,6 +251,7 @@ scheduler_events = {
|
|||||||
"erpnext.projects.doctype.project.project.send_project_status_email_to_users"
|
"erpnext.projects.doctype.project.project.send_project_status_email_to_users"
|
||||||
],
|
],
|
||||||
"daily_long": [
|
"daily_long": [
|
||||||
|
"erpnext.setup.doctype.email_digest.email_digest.send",
|
||||||
"erpnext.manufacturing.doctype.bom_update_tool.bom_update_tool.update_latest_price_in_all_boms"
|
"erpnext.manufacturing.doctype.bom_update_tool.bom_update_tool.update_latest_price_in_all_boms"
|
||||||
],
|
],
|
||||||
"monthly_long": [
|
"monthly_long": [
|
||||||
|
|||||||
@@ -38,9 +38,11 @@ class BOM(WebsiteGenerator):
|
|||||||
names = [d[-1][1:] for d in filter(lambda x: len(x) > 1 and x[-1], names)]
|
names = [d[-1][1:] for d in filter(lambda x: len(x) > 1 and x[-1], names)]
|
||||||
|
|
||||||
# split by (-) if cancelled
|
# split by (-) if cancelled
|
||||||
names = [cint(name.split('-')[-1]) for name in names]
|
if names:
|
||||||
|
names = [cint(name.split('-')[-1]) for name in names]
|
||||||
idx = max(names) + 1
|
idx = max(names) + 1
|
||||||
|
else:
|
||||||
|
idx = 1
|
||||||
else:
|
else:
|
||||||
idx = 1
|
idx = 1
|
||||||
|
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ frappe.ui.form.on("Work Order", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
project: function(frm) {
|
project: function(frm) {
|
||||||
if(!erpnext.in_production_item_onchange) {
|
if(!erpnext.in_production_item_onchange && !frm.doc.bom_no) {
|
||||||
frm.trigger("production_item");
|
frm.trigger("production_item");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -713,7 +713,7 @@
|
|||||||
"depends_on": "",
|
"depends_on": "",
|
||||||
"fetch_if_empty": 0,
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "depends_on_tasks",
|
"fieldname": "depends_on_tasks",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Long Text",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
|
|||||||
@@ -1422,6 +1422,11 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
'item_code': item.item_code,
|
'item_code': item.item_code,
|
||||||
'posting_date': me.frm.doc.posting_date || frappe.datetime.nowdate(),
|
'posting_date': me.frm.doc.posting_date || frappe.datetime.nowdate(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (doc.is_return) {
|
||||||
|
filters["is_return"] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (item.warehouse) filters["warehouse"] = item.warehouse;
|
if (item.warehouse) filters["warehouse"] = item.warehouse;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
|||||||
|
|
||||||
// delivery note
|
// delivery note
|
||||||
if(flt(doc.per_delivered, 6) < 100 && allow_delivery) {
|
if(flt(doc.per_delivered, 6) < 100 && allow_delivery) {
|
||||||
this.frm.add_custom_button(__('Delivery'),
|
this.frm.add_custom_button(__('Delivery Note'),
|
||||||
function() { me.make_delivery_note_based_on_delivery_date(); }, __("Make"));
|
function() { me.make_delivery_note_based_on_delivery_date(); }, __("Make"));
|
||||||
|
|
||||||
if(["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1){
|
if(["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1){
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ frappe.listview_settings['Delivery Note'] = {
|
|||||||
return [__("Return"), "darkgrey", "is_return,=,Yes"];
|
return [__("Return"), "darkgrey", "is_return,=,Yes"];
|
||||||
} else if (doc.status === "Closed") {
|
} else if (doc.status === "Closed") {
|
||||||
return [__("Closed"), "green", "status,=,Closed"];
|
return [__("Closed"), "green", "status,=,Closed"];
|
||||||
} else if (doc.grand_total !== 0 && flt(doc.per_billed, 2) < 100) {
|
} else if (flt(doc.per_billed, 2) < 100) {
|
||||||
return [__("To Bill"), "orange", "per_billed,<,100"];
|
return [__("To Bill"), "orange", "per_billed,<,100"];
|
||||||
} else if (doc.grand_total === 0 || flt(doc.per_billed, 2) == 100) {
|
} else if (flt(doc.per_billed, 2) == 100) {
|
||||||
return [__("Completed"), "green", "per_billed,=,100"];
|
return [__("Completed"), "green", "per_billed,=,100"];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user