-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add purchase order history in purcahse order
- Loading branch information
Showing
5 changed files
with
350 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,282 @@ | ||
[ | ||
{ | ||
"allow_in_quick_entry": 0, | ||
"allow_on_submit": 0, | ||
"bold": 0, | ||
"collapsible": 1, | ||
"collapsible_depends_on": null, | ||
"columns": 0, | ||
"default": null, | ||
"depends_on": null, | ||
"description": null, | ||
"docstatus": 0, | ||
"doctype": "Custom Field", | ||
"dt": "Purchase Order Item", | ||
"fetch_from": null, | ||
"fetch_if_empty": 0, | ||
"fieldname": "custom_recent_order", | ||
"fieldtype": "Section Break", | ||
"hidden": 0, | ||
"hide_border": 0, | ||
"hide_days": 0, | ||
"hide_seconds": 0, | ||
"ignore_user_permissions": 0, | ||
"ignore_xss_filter": 0, | ||
"in_global_search": 0, | ||
"in_list_view": 0, | ||
"in_preview": 0, | ||
"in_standard_filter": 0, | ||
"insert_after": "stock_qty", | ||
"is_system_generated": 0, | ||
"is_virtual": 0, | ||
"label": "Recent Order", | ||
"length": 0, | ||
"link_filters": null, | ||
"mandatory_depends_on": null, | ||
"modified": "2024-07-24 13:06:15.955365", | ||
"module": "Inn Hotels", | ||
"name": "Purchase Order Item-custom_recent_order", | ||
"no_copy": 0, | ||
"non_negative": 0, | ||
"options": null, | ||
"permlevel": 0, | ||
"precision": "", | ||
"print_hide": 0, | ||
"print_hide_if_no_value": 0, | ||
"print_width": null, | ||
"read_only": 0, | ||
"read_only_depends_on": null, | ||
"report_hide": 0, | ||
"reqd": 0, | ||
"search_index": 0, | ||
"show_dashboard": 0, | ||
"sort_options": 0, | ||
"translatable": 0, | ||
"unique": 0, | ||
"width": null | ||
}, | ||
{ | ||
"allow_in_quick_entry": 0, | ||
"allow_on_submit": 0, | ||
"bold": 0, | ||
"collapsible": 1, | ||
"collapsible_depends_on": null, | ||
"columns": 0, | ||
"default": null, | ||
"depends_on": null, | ||
"description": null, | ||
"docstatus": 0, | ||
"doctype": "Custom Field", | ||
"dt": "Purchase Order Item", | ||
"fetch_from": null, | ||
"fetch_if_empty": 0, | ||
"fieldname": "custom_last_purchased_quantity", | ||
"fieldtype": "Int", | ||
"hidden": 0, | ||
"hide_border": 0, | ||
"hide_days": 0, | ||
"hide_seconds": 0, | ||
"ignore_user_permissions": 0, | ||
"ignore_xss_filter": 0, | ||
"in_global_search": 0, | ||
"in_list_view": 0, | ||
"in_preview": 0, | ||
"in_standard_filter": 0, | ||
"insert_after": "custom_recent_order", | ||
"is_system_generated": 0, | ||
"is_virtual": 0, | ||
"label": "Last Purchased Quantity", | ||
"length": 0, | ||
"link_filters": null, | ||
"mandatory_depends_on": null, | ||
"modified": "2024-07-24 13:08:10.741623", | ||
"module": "Inn Hotels", | ||
"name": "Purchase Order Item-custom_last_purchased_quantity", | ||
"no_copy": 0, | ||
"non_negative": 0, | ||
"options": null, | ||
"permlevel": 0, | ||
"precision": "", | ||
"print_hide": 0, | ||
"print_hide_if_no_value": 0, | ||
"print_width": null, | ||
"read_only": 1, | ||
"read_only_depends_on": null, | ||
"report_hide": 0, | ||
"reqd": 0, | ||
"search_index": 0, | ||
"show_dashboard": 0, | ||
"sort_options": 0, | ||
"translatable": 0, | ||
"unique": 0, | ||
"width": null | ||
}, | ||
{ | ||
"allow_in_quick_entry": 0, | ||
"allow_on_submit": 0, | ||
"bold": 0, | ||
"collapsible": 1, | ||
"collapsible_depends_on": null, | ||
"columns": 0, | ||
"default": null, | ||
"depends_on": null, | ||
"description": null, | ||
"docstatus": 0, | ||
"doctype": "Custom Field", | ||
"dt": "Purchase Order Item", | ||
"fetch_from": null, | ||
"fetch_if_empty": 0, | ||
"fieldname": "custom_col_br1", | ||
"fieldtype": "Column Break", | ||
"hidden": 0, | ||
"hide_border": 0, | ||
"hide_days": 0, | ||
"hide_seconds": 0, | ||
"ignore_user_permissions": 0, | ||
"ignore_xss_filter": 0, | ||
"in_global_search": 0, | ||
"in_list_view": 0, | ||
"in_preview": 0, | ||
"in_standard_filter": 0, | ||
"insert_after": "custom_last_purchased_quantity", | ||
"is_system_generated": 0, | ||
"is_virtual": 0, | ||
"label": "", | ||
"length": 0, | ||
"link_filters": null, | ||
"mandatory_depends_on": null, | ||
"modified": "2024-07-24 13:11:53.292843", | ||
"module": "Inn Hotels", | ||
"name": "Purchase Order Item-custom_col_br1", | ||
"no_copy": 0, | ||
"non_negative": 0, | ||
"options": "", | ||
"permlevel": 0, | ||
"precision": "", | ||
"print_hide": 0, | ||
"print_hide_if_no_value": 0, | ||
"print_width": null, | ||
"read_only": 0, | ||
"read_only_depends_on": null, | ||
"report_hide": 0, | ||
"reqd": 0, | ||
"search_index": 0, | ||
"show_dashboard": 0, | ||
"sort_options": 0, | ||
"translatable": 0, | ||
"unique": 0, | ||
"width": null | ||
}, | ||
{ | ||
"allow_in_quick_entry": 0, | ||
"allow_on_submit": 0, | ||
"bold": 0, | ||
"collapsible": 1, | ||
"collapsible_depends_on": null, | ||
"columns": 0, | ||
"default": null, | ||
"depends_on": null, | ||
"description": null, | ||
"docstatus": 0, | ||
"doctype": "Custom Field", | ||
"dt": "Purchase Order Item", | ||
"fetch_from": null, | ||
"fetch_if_empty": 0, | ||
"fieldname": "custom_last_purchase_order", | ||
"fieldtype": "Link", | ||
"hidden": 0, | ||
"hide_border": 0, | ||
"hide_days": 0, | ||
"hide_seconds": 0, | ||
"ignore_user_permissions": 0, | ||
"ignore_xss_filter": 0, | ||
"in_global_search": 0, | ||
"in_list_view": 0, | ||
"in_preview": 0, | ||
"in_standard_filter": 0, | ||
"insert_after": "custom_col_br1", | ||
"is_system_generated": 0, | ||
"is_virtual": 0, | ||
"label": "Last Purchase Order", | ||
"length": 0, | ||
"link_filters": null, | ||
"mandatory_depends_on": null, | ||
"modified": "2024-07-24 13:14:00.775785", | ||
"module": "Inn Hotels", | ||
"name": "Purchase Order Item-custom_last_purchase_order", | ||
"no_copy": 0, | ||
"non_negative": 0, | ||
"options": "Purchase Order", | ||
"permlevel": 0, | ||
"precision": "", | ||
"print_hide": 0, | ||
"print_hide_if_no_value": 0, | ||
"print_width": null, | ||
"read_only": 1, | ||
"read_only_depends_on": null, | ||
"report_hide": 0, | ||
"reqd": 0, | ||
"search_index": 0, | ||
"show_dashboard": 0, | ||
"sort_options": 0, | ||
"translatable": 0, | ||
"unique": 0, | ||
"width": null | ||
}, | ||
{ | ||
"allow_in_quick_entry": 0, | ||
"allow_on_submit": 0, | ||
"bold": 0, | ||
"collapsible": 1, | ||
"collapsible_depends_on": null, | ||
"columns": 0, | ||
"default": null, | ||
"depends_on": null, | ||
"description": null, | ||
"docstatus": 0, | ||
"doctype": "Custom Field", | ||
"dt": "Purchase Order Item", | ||
"fetch_from": null, | ||
"fetch_if_empty": 0, | ||
"fieldname": "custom_last_purchase_date", | ||
"fieldtype": "Date", | ||
"hidden": 0, | ||
"hide_border": 0, | ||
"hide_days": 0, | ||
"hide_seconds": 0, | ||
"ignore_user_permissions": 0, | ||
"ignore_xss_filter": 0, | ||
"in_global_search": 0, | ||
"in_list_view": 0, | ||
"in_preview": 0, | ||
"in_standard_filter": 0, | ||
"insert_after": "custom_last_purchase_order", | ||
"is_system_generated": 0, | ||
"is_virtual": 0, | ||
"label": "Last Purchase Date", | ||
"length": 0, | ||
"link_filters": null, | ||
"mandatory_depends_on": null, | ||
"modified": "2024-07-24 13:46:45.136947", | ||
"module": "Inn Hotels", | ||
"name": "Purchase Order Item-custom_last_purchase_date", | ||
"no_copy": 0, | ||
"non_negative": 0, | ||
"options": "", | ||
"permlevel": 0, | ||
"precision": "", | ||
"print_hide": 0, | ||
"print_hide_if_no_value": 0, | ||
"print_width": null, | ||
"read_only": 1, | ||
"read_only_depends_on": null, | ||
"report_hide": 0, | ||
"reqd": 0, | ||
"search_index": 0, | ||
"show_dashboard": 0, | ||
"sort_options": 0, | ||
"translatable": 0, | ||
"unique": 0, | ||
"width": null | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
33 changes: 33 additions & 0 deletions
33
inn/overrides/erpnext/accounts/purchase_order/purchase_order.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import frappe | ||
|
||
|
||
@frappe.whitelist() | ||
def get_last_purchase_request(item_code): | ||
result = { | ||
"last_purchased_quantity": 0, | ||
"last_purchase_order": "", | ||
"transaction_date": "" | ||
} | ||
if not frappe.db.exists("Item", item_code, cache=True): | ||
return result | ||
|
||
query = f''' | ||
select tpoi.parent as parent, tpoi.qty as qty, tpo.transaction_date as transaction_date | ||
from `tabPurchase Order Item` tpoi | ||
left join `tabPurchase Order` tpo | ||
on tpo.name = tpoi.parent | ||
where tpoi.item_code = '{item_code}' | ||
and tpo.status != 'Draft' | ||
order by tpo.transaction_date desc | ||
limit 1 | ||
''' | ||
|
||
last = frappe.db.sql(query, as_dict=1) | ||
if len(last) == 0: | ||
return result | ||
last = last[0] | ||
|
||
result["last_purchased_quantity"] = last.qty | ||
result["last_purchase_order"] = last.parent | ||
result["transaction_date"] = last.transaction_date | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
frappe.ui.form.on("Purchase Order Item", { | ||
|
||
item_code: async function (frm, cdt, cdn) { | ||
var row = locals[cdt][cdn] | ||
console.log("called") | ||
|
||
let result = await frappe.call({ | ||
method: "inn.overrides.erpnext.accounts.purchase_order.purchase_order.get_last_purchase_request", | ||
args: { | ||
item_code: row.item_code | ||
} | ||
}) | ||
result = result.message | ||
row.custom_last_purchased_quantity = result.last_purchased_quantity | ||
row.custom_last_purchase_order = result.last_purchase_order | ||
row.custom_last_purchase_date = result.transaction_date | ||
refresh_field("items") | ||
} | ||
}) |