Skip to content

Commit

Permalink
feat: status fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishBarvaliya committed Aug 16, 2024
1 parent 5cd1814 commit 885b785
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 58 deletions.
56 changes: 0 additions & 56 deletions d2h/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ def short_close_purchase_order(purchase_order):
if item.qty > item.received_qty:
item.custom_short_close_qty = item.qty - item.received_qty - item.custom_good_in_transit_qty

purchase_order.status = "Closed"
purchase_order.save(ignore_permissions=True)

return "OK"

def set_missing_values(source, target):
Expand Down Expand Up @@ -103,56 +100,6 @@ def update_item(obj, target, source_parent):
)
doc.save(ignore_permissions=True)

# purchase_receipt = frappe.get_doc({
# "doctype": "Purchase Receipt",
# "supplier": purchase_order.supplier,
# "currency": purchase_order.currency,
# "conversion_rate": purchase_order.conversion_rate,
# "buying_price_list": purchase_order.buying_price_list,
# "price_list_currency": purchase_order.price_list_currency,
# "items": []
# })

# for item in items_list:
# new_item = purchase_receipt.append("items", {})
# new_item.item_code = item["item_code"]
# new_item.item_name = item["item_name"]
# new_item.qty = item["qty"]
# new_item.uom = item["uom"]
# new_item.purchase_order = purchase_order.name
# new_item.purchase_order_item = item["name"]
# new_item.scheduled_date = purchase_order.schedule_date
# new_item.supplier_part_no = item.get("supplier_part_no")
# new_item.product_bundle = item.get("product_bundle")
# new_item.item_group = item.get("item_group")
# new_item.brand = item.get("brand")
# new_item.stock_uom = item.get("stock_uom")
# new_item.conversion_factor = item.get("conversion_factor")
# new_item.description = item.get("description")
# new_item.image = item.get("image")
# new_item.price_list_rate = item.get("price_list_rate")
# new_item.base_price_list_rate = item.get("base_price_list_rate")
# new_item.margin_type = item.get("margin_type")
# new_item.margin_rate_or_amount = item.get("margin_rate_or_amount")
# new_item.rate_with_margin = item.get("rate_with_margin")
# new_item.base_rate_with_margin = item.get("base_rate_with_margin")
# new_item.amount = item["qty"] * (item.get("rate") or 0)
# new_item.rate = item.get("rate")
# new_item.stock_qty = item["qty"] * (item.get("conversion_factor") or 0)
# new_item.base_rate = item.get("base_rate")
# new_item.base_amount = item["qty"] * (item.get("base_rate") or 0)
# new_item.discount_percentage = item.get("discount_percentage")
# new_item.discount_amount = item.get("discount_amount")
# new_item.base_discount_amount = item.get("base_discount_amount")
# new_item.net_rate = item.get("net_rate")
# new_item.net_amount = item.get("net_amount")
# new_item.base_net_rate = item.get("base_net_rate")
# new_item.base_net_amount = item.get("base_net_amount")
# new_item.tax_rate = item.get("tax_rate")


# purchase_receipt.insert(ignore_permissions=True)

for item in purchase_order.items:
found_item = next((itm for itm in items_list if itm['name'] == item.name), None)
if found_item:
Expand Down Expand Up @@ -181,9 +128,6 @@ def short_close_sales_order(sales_order):
if item.qty > item.delivered_qty:
item.custom_short_close_qty = item.qty - item.delivered_qty - item.custom_good_in_transit_qty

sales_order.status = "Closed"
sales_order.save(ignore_permissions=True)

return "OK"

@frappe.whitelist()
Expand Down
5 changes: 3 additions & 2 deletions d2h/public/js/purchase_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ frappe.ui.form.on("Purchase Order", {
.hide();
$(`[data-label='Status%20%3E%20Close'].menu-item-label`).parent().hide();
$(`[data-label='Status%20%3E%20Hold'].menu-item-label`).parent().hide();
}, 200);
}, 400);
},
onload: function (frm) {
setTimeout(() => {
Expand All @@ -50,7 +50,7 @@ frappe.ui.form.on("Purchase Order", {
.hide();
$(`[data-label='Status%20%3E%20Close'].menu-item-label`).parent().hide();
$(`[data-label='Status%20%3E%20Hold'].menu-item-label`).parent().hide();
}, 200);
}, 400);
},
});

Expand Down Expand Up @@ -166,6 +166,7 @@ function show_confirm_dialog(frm) {
frappe.msgprint(
__(`Purchase Order ${frm.doc.name} has been short closed.`)
);
cur_frm.cscript.update_status("Close", "Closed");
frm.refresh();
d.hide();
},
Expand Down
2 changes: 2 additions & 0 deletions d2h/public/js/sales_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ function show_confirm_dialog(frm) {
frappe.msgprint(
__(`Sales Order ${frm.doc.name} has been short closed.`)
);
cur_frm.cscript.update_status("Close", "Closed");

frm.refresh();
d.hide();
},
Expand Down

0 comments on commit 885b785

Please sign in to comment.