fix: Sider and Linter

This commit is contained in:
marination
2022-03-17 15:03:20 +05:30
parent 8aff75f8e8
commit 3e3af95712
4 changed files with 33 additions and 33 deletions

View File

@@ -1,8 +1,8 @@
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt
from typing import Dict, List, Optional from typing import Dict, List, Optional
import click
import click
import frappe import frappe
from frappe import _ from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
@@ -89,39 +89,39 @@ def replace_bom(boms: Dict) -> None:
bom_obj.save_version() bom_obj.save_version()
def update_new_bom(unit_cost: float, current_bom: str, new_bom: str) -> None: def update_new_bom(unit_cost: float, current_bom: str, new_bom: str) -> None:
bom_item = frappe.qb.DocType("BOM Item") bom_item = frappe.qb.DocType("BOM Item")
frappe.qb.update(bom_item).set( frappe.qb.update(bom_item).set(
bom_item.bom_no, new_bom bom_item.bom_no, new_bom
).set( ).set(
bom_item.rate, unit_cost bom_item.rate, unit_cost
).set( ).set(
bom_item.amount, (bom_item.stock_qty * unit_cost) bom_item.amount, (bom_item.stock_qty * unit_cost)
).where( ).where(
(bom_item.bom_no == current_bom) (bom_item.bom_no == current_bom)
& (bom_item.docstatus < 2) & (bom_item.docstatus < 2)
& (bom_item.parenttype == "BOM") & (bom_item.parenttype == "BOM")
).run() ).run()
def get_parent_boms(new_bom: str, bom_list: Optional[List] = None) -> List: def get_parent_boms(new_bom: str, bom_list: Optional[List] = None) -> List:
bom_list = bom_list or [] bom_list = bom_list or []
bom_item = frappe.qb.DocType("BOM Item") bom_item = frappe.qb.DocType("BOM Item")
parents = frappe.qb.from_(bom_item).select( parents = frappe.qb.from_(bom_item).select(
bom_item.parent bom_item.parent
).where( ).where(
(bom_item.bom_no == new_bom) (bom_item.bom_no == new_bom)
& (bom_item.docstatus <2) & (bom_item.docstatus <2)
& (bom_item.parenttype == "BOM") & (bom_item.parenttype == "BOM")
).run(as_dict=True) ).run(as_dict=True)
for d in parents: for d in parents:
if new_bom == d.parent: if new_bom == d.parent:
frappe.throw(_("BOM recursion: {0} cannot be child of {1}").format(new_bom, d.parent)) frappe.throw(_("BOM recursion: {0} cannot be child of {1}").format(new_bom, d.parent))
bom_list.append(d.parent) bom_list.append(d.parent)
get_parent_boms(d.parent, bom_list) 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: def get_new_bom_unit_cost(new_bom: str) -> float:
bom = frappe.qb.DocType("BOM") bom = frappe.qb.DocType("BOM")

View File

@@ -6,7 +6,7 @@ frappe.listview_settings['BOM Update Log'] = {
"In Progress": "blue", "In Progress": "blue",
"Completed": "green", "Completed": "green",
"Failed": "red" "Failed": "red"
} };
return [__(doc.status), status_map[doc.status], "status,=," + doc.status]; return [__(doc.status), status_map[doc.status], "status,=," + doc.status];
} }

View File

@@ -28,13 +28,13 @@ frappe.ui.form.on('BOM Update Tool', {
}, },
current_bom: (frm) => { 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); frm.events.disable_button(frm, "replace", false);
} }
}, },
new_bom: (frm) => { 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); frm.events.disable_button(frm, "replace", false);
} }
}, },
@@ -72,7 +72,7 @@ frappe.ui.form.on('BOM Update Tool', {
}, },
confirm_job_start: (frm, log_data) => { 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({ frappe.msgprint({
"message": __(`BOM Updation is queued and may take a few minutes. Check ${log_link} for progress.`), "message": __(`BOM Updation is queued and may take a few minutes. Check ${log_link} for progress.`),
"title": __("BOM Update Initiated"), "title": __("BOM Update Initiated"),

View File

@@ -2,7 +2,7 @@
# For license information, please see license.txt # For license information, please see license.txt
import json import json
from typing import Dict, List, Optional, TYPE_CHECKING, Union from typing import TYPE_CHECKING, Dict, Optional, Union
if TYPE_CHECKING: if TYPE_CHECKING:
from erpnext.manufacturing.doctype.bom_update_log.bom_update_log import BOMUpdateLog from erpnext.manufacturing.doctype.bom_update_log.bom_update_log import BOMUpdateLog