refactor(treewide): formatting and ruff fixes, + manually enabled F401
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
@@ -56,9 +56,7 @@ def make_variant_based_on_manufacturer(template, manufacturer, manufacturer_part
|
||||
variant.flags.ignore_mandatory = True
|
||||
variant.save()
|
||||
|
||||
if not frappe.db.exists(
|
||||
"Item Manufacturer", {"item_code": variant.name, "manufacturer": manufacturer}
|
||||
):
|
||||
if not frappe.db.exists("Item Manufacturer", {"item_code": variant.name, "manufacturer": manufacturer}):
|
||||
manufacturer_doc = frappe.new_doc("Item Manufacturer")
|
||||
manufacturer_doc.update(
|
||||
{
|
||||
@@ -122,9 +120,7 @@ def validate_is_incremental(numeric_attribute, attribute, value, item):
|
||||
)
|
||||
|
||||
|
||||
def validate_item_attribute_value(
|
||||
attributes_list, attribute, attribute_value, item, from_variant=True
|
||||
):
|
||||
def validate_item_attribute_value(attributes_list, attribute, attribute_value, item, from_variant=True):
|
||||
allow_rename_attribute_value = frappe.db.get_single_value(
|
||||
"Item Variant Settings", "allow_rename_attribute_value"
|
||||
)
|
||||
@@ -172,7 +168,7 @@ def get_attribute_values(item):
|
||||
|
||||
def find_variant(template, args, variant_item_code=None):
|
||||
conditions = [
|
||||
"""(iv_attribute.attribute={0} and iv_attribute.attribute_value={1})""".format(
|
||||
"""(iv_attribute.attribute={} and iv_attribute.attribute_value={})""".format(
|
||||
frappe.db.escape(key), frappe.db.escape(cstr(value))
|
||||
)
|
||||
for key, value in args.items()
|
||||
@@ -182,9 +178,7 @@ def find_variant(template, args, variant_item_code=None):
|
||||
|
||||
from erpnext.e_commerce.variant_selector.utils import get_item_codes_by_attributes
|
||||
|
||||
possible_variants = [
|
||||
i for i in get_item_codes_by_attributes(args, template) if i != variant_item_code
|
||||
]
|
||||
possible_variants = [i for i in get_item_codes_by_attributes(args, template) if i != variant_item_code]
|
||||
|
||||
for variant in possible_variants:
|
||||
variant = frappe.get_doc("Item", variant)
|
||||
@@ -360,7 +354,9 @@ def copy_attributes_to_variant(item, variant):
|
||||
if variant.attributes:
|
||||
attributes_description = item.description + " "
|
||||
for d in variant.attributes:
|
||||
attributes_description += "<div>" + d.attribute + ": " + cstr(d.attribute_value) + "</div>"
|
||||
attributes_description += (
|
||||
"<div>" + d.attribute + ": " + cstr(d.attribute_value) + "</div>"
|
||||
)
|
||||
|
||||
if attributes_description not in variant.description:
|
||||
variant.description = attributes_description
|
||||
@@ -394,8 +390,8 @@ def make_variant_item_code(template_item_code, template_item_name, variant):
|
||||
abbreviations.append(abbr_or_value)
|
||||
|
||||
if abbreviations:
|
||||
variant.item_code = "{0}-{1}".format(template_item_code, "-".join(abbreviations))
|
||||
variant.item_name = "{0}-{1}".format(template_item_name, "-".join(abbreviations))
|
||||
variant.item_code = "{}-{}".format(template_item_code, "-".join(abbreviations))
|
||||
variant.item_name = "{}-{}".format(template_item_name, "-".join(abbreviations))
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
Reference in New Issue
Block a user