fix: Sider and Linter
This commit is contained in:
parent
8aff75f8e8
commit
3e3af95712
@ -1,8 +1,8 @@
|
||||
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
from typing import Dict, List, Optional
|
||||
import click
|
||||
|
||||
import click
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
@ -89,39 +89,39 @@ def replace_bom(boms: Dict) -> None:
|
||||
bom_obj.save_version()
|
||||
|
||||
def update_new_bom(unit_cost: float, current_bom: str, new_bom: str) -> None:
|
||||
bom_item = frappe.qb.DocType("BOM Item")
|
||||
frappe.qb.update(bom_item).set(
|
||||
bom_item.bom_no, new_bom
|
||||
).set(
|
||||
bom_item.rate, unit_cost
|
||||
).set(
|
||||
bom_item.amount, (bom_item.stock_qty * unit_cost)
|
||||
).where(
|
||||
(bom_item.bom_no == current_bom)
|
||||
& (bom_item.docstatus < 2)
|
||||
& (bom_item.parenttype == "BOM")
|
||||
).run()
|
||||
bom_item = frappe.qb.DocType("BOM Item")
|
||||
frappe.qb.update(bom_item).set(
|
||||
bom_item.bom_no, new_bom
|
||||
).set(
|
||||
bom_item.rate, unit_cost
|
||||
).set(
|
||||
bom_item.amount, (bom_item.stock_qty * unit_cost)
|
||||
).where(
|
||||
(bom_item.bom_no == current_bom)
|
||||
& (bom_item.docstatus < 2)
|
||||
& (bom_item.parenttype == "BOM")
|
||||
).run()
|
||||
|
||||
def get_parent_boms(new_bom: str, bom_list: Optional[List] = None) -> List:
|
||||
bom_list = bom_list or []
|
||||
bom_item = frappe.qb.DocType("BOM Item")
|
||||
bom_list = bom_list or []
|
||||
bom_item = frappe.qb.DocType("BOM Item")
|
||||
|
||||
parents = frappe.qb.from_(bom_item).select(
|
||||
bom_item.parent
|
||||
).where(
|
||||
(bom_item.bom_no == new_bom)
|
||||
& (bom_item.docstatus <2)
|
||||
& (bom_item.parenttype == "BOM")
|
||||
).run(as_dict=True)
|
||||
parents = frappe.qb.from_(bom_item).select(
|
||||
bom_item.parent
|
||||
).where(
|
||||
(bom_item.bom_no == new_bom)
|
||||
& (bom_item.docstatus <2)
|
||||
& (bom_item.parenttype == "BOM")
|
||||
).run(as_dict=True)
|
||||
|
||||
for d in parents:
|
||||
if new_bom == d.parent:
|
||||
frappe.throw(_("BOM recursion: {0} cannot be child of {1}").format(new_bom, d.parent))
|
||||
for d in parents:
|
||||
if new_bom == d.parent:
|
||||
frappe.throw(_("BOM recursion: {0} cannot be child of {1}").format(new_bom, d.parent))
|
||||
|
||||
bom_list.append(d.parent)
|
||||
get_parent_boms(d.parent, bom_list)
|
||||
bom_list.append(d.parent)
|
||||
get_parent_boms(d.parent, bom_list)
|
||||
|
||||
return list(set(bom_list))
|
||||
return list(set(bom_list))
|
||||
|
||||
def get_new_bom_unit_cost(new_bom: str) -> float:
|
||||
bom = frappe.qb.DocType("BOM")
|
||||
|
@ -6,7 +6,7 @@ frappe.listview_settings['BOM Update Log'] = {
|
||||
"In Progress": "blue",
|
||||
"Completed": "green",
|
||||
"Failed": "red"
|
||||
}
|
||||
};
|
||||
|
||||
return [__(doc.status), status_map[doc.status], "status,=," + doc.status];
|
||||
}
|
||||
|
@ -28,13 +28,13 @@ frappe.ui.form.on('BOM Update Tool', {
|
||||
},
|
||||
|
||||
current_bom: (frm) => {
|
||||
if (frm.doc.current_bom && frm.doc.new_bom){
|
||||
if (frm.doc.current_bom && frm.doc.new_bom) {
|
||||
frm.events.disable_button(frm, "replace", false);
|
||||
}
|
||||
},
|
||||
|
||||
new_bom: (frm) => {
|
||||
if (frm.doc.current_bom && frm.doc.new_bom){
|
||||
if (frm.doc.current_bom && frm.doc.new_bom) {
|
||||
frm.events.disable_button(frm, "replace", false);
|
||||
}
|
||||
},
|
||||
@ -72,7 +72,7 @@ frappe.ui.form.on('BOM Update Tool', {
|
||||
},
|
||||
|
||||
confirm_job_start: (frm, log_data) => {
|
||||
let log_link = frappe.utils.get_form_link("BOM Update Log", log_data.name, true)
|
||||
let log_link = frappe.utils.get_form_link("BOM Update Log", log_data.name, true);
|
||||
frappe.msgprint({
|
||||
"message": __(`BOM Updation is queued and may take a few minutes. Check ${log_link} for progress.`),
|
||||
"title": __("BOM Update Initiated"),
|
||||
|
@ -2,7 +2,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
import json
|
||||
from typing import Dict, List, Optional, TYPE_CHECKING, Union
|
||||
from typing import TYPE_CHECKING, Dict, Optional, Union
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from erpnext.manufacturing.doctype.bom_update_log.bom_update_log import BOMUpdateLog
|
||||
|
Loading…
x
Reference in New Issue
Block a user