fix: total weight not set for free items

This commit is contained in:
Rohit Waghchaure 2021-03-22 23:36:48 +05:30
parent 77add49c6a
commit bde159a77d
2 changed files with 8 additions and 2 deletions

View File

@ -26,7 +26,8 @@ from erpnext.controllers.print_settings import set_print_templates_for_item_tabl
class AccountMissingError(frappe.ValidationError): pass class AccountMissingError(frappe.ValidationError): pass
force_item_fields = ("item_group", "brand", "stock_uom", "is_fixed_asset", "item_tax_rate", "pricing_rules") force_item_fields = ("item_group", "brand", "stock_uom", "is_fixed_asset", "item_tax_rate",
"pricing_rules", "weight_per_unit", "weight_uom", "total_weight")
class AccountsController(TransactionBase): class AccountsController(TransactionBase):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):

View File

@ -314,7 +314,9 @@ def get_basic_details(args, item, overwrite_warehouse=True):
"last_purchase_rate": item.last_purchase_rate if args.get("doctype") in ["Purchase Order"] else 0, "last_purchase_rate": item.last_purchase_rate if args.get("doctype") in ["Purchase Order"] else 0,
"transaction_date": args.get("transaction_date"), "transaction_date": args.get("transaction_date"),
"against_blanket_order": args.get("against_blanket_order"), "against_blanket_order": args.get("against_blanket_order"),
"bom_no": item.get("default_bom") "bom_no": item.get("default_bom"),
"weight_per_unit": args.get("weight_per_unit") or item.get("weight_per_unit"),
"weight_uom": args.get("weight_uom") or item.get("weight_uom")
}) })
if item.get("enable_deferred_revenue") or item.get("enable_deferred_expense"): if item.get("enable_deferred_revenue") or item.get("enable_deferred_expense"):
@ -369,6 +371,9 @@ def get_basic_details(args, item, overwrite_warehouse=True):
if meta.get_field("barcode"): if meta.get_field("barcode"):
update_barcode_value(out) update_barcode_value(out)
if out.get("weight_per_unit"):
out['total_weight'] = out.weight_per_unit * out.stock_qty
return out return out
def get_item_warehouse(item, args, overwrite_warehouse, defaults={}): def get_item_warehouse(item, args, overwrite_warehouse, defaults={}):