diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js index 4ddc057c681cb57c40230d212bcc16a4a4ad4c9c..71de0d7f3edd1a758fd94766930cb457e28a9d77 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js @@ -116,11 +116,9 @@ frappe.ui.form.on('Repost Item Valuation', { frappe.call({ method: "restart_reposting", doc: frm.doc, - callback: function(r) { - if (!r.exc) { - frm.refresh(); - } - } + callback: function (r) { + frm.reload_doc(); + }, }); } }); diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.json b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.json index 67b0d1bf6f3595966db706ab0b831ae55376fc7d..25783876bcc88d0b7aac4ede21f2d4c9a94ba2d4 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.json +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.json @@ -1,279 +1,280 @@ { - "actions": [], - "autoname": "hash", - "creation": "2020-10-22 22:27:07.742161", - "doctype": "DocType", - "editable_grid": 1, - "engine": "InnoDB", - "field_order": [ - "based_on", - "voucher_type", - "voucher_no", - "item_code", - "warehouse", - "posting_date", - "posting_time", - "column_break_5", - "status", - "company", - "allow_negative_stock", - "via_landed_cost_voucher", - "allow_zero_rate", - "amended_from", - "error_section", - "error_log", - "reposting_info_section", - "reposting_data_file", - "items_to_be_repost", - "distinct_item_and_warehouse", - "column_break_o1sj", - "total_reposting_count", - "current_index", - "gl_reposting_index", - "affected_transactions" - ], - "fields": [ - { - "depends_on": "eval:doc.based_on=='Item and Warehouse'", - "fieldname": "item_code", - "fieldtype": "Link", - "label": "Item Code", - "mandatory_depends_on": "eval:doc.based_on=='Item and Warehouse'", - "options": "Item" - }, - { - "depends_on": "eval:doc.based_on=='Item and Warehouse'", - "fieldname": "warehouse", - "fieldtype": "Link", - "label": "Warehouse", - "mandatory_depends_on": "eval:doc.based_on=='Item and Warehouse'", - "options": "Warehouse" - }, - { - "fetch_from": "voucher_no.posting_date", - "fieldname": "posting_date", - "fieldtype": "Date", - "label": "Posting Date", - "read_only_depends_on": "eval: doc.based_on == \"Transaction\"", - "reqd": 1 - }, - { - "fetch_from": "voucher_no.posting_time", - "fieldname": "posting_time", - "fieldtype": "Time", - "label": "Posting Time", - "read_only_depends_on": "eval: doc.based_on == \"Transaction\"" - }, - { - "default": "Queued", - "fieldname": "status", - "fieldtype": "Select", - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Status", - "no_copy": 1, - "options": "Queued\nIn Progress\nCompleted\nSkipped\nFailed", - "read_only": 1 - }, - { - "fieldname": "amended_from", - "fieldtype": "Link", - "label": "Amended From", - "no_copy": 1, - "options": "Repost Item Valuation", - "print_hide": 1, - "read_only": 1 - }, - { - "fieldname": "column_break_5", - "fieldtype": "Column Break" - }, - { - "depends_on": "eval:doc.status=='Failed'", - "fieldname": "error_section", - "fieldtype": "Section Break", - "label": "Error" - }, - { - "fieldname": "error_log", - "fieldtype": "Long Text", - "label": "Error Log", - "no_copy": 1, - "read_only": 1 - }, - { - "fetch_from": "warehouse.company", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company" - }, - { - "depends_on": "eval:doc.based_on=='Transaction'", - "fieldname": "voucher_type", - "fieldtype": "Link", - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Voucher Type", - "mandatory_depends_on": "eval:doc.based_on=='Transaction'", - "options": "DocType" - }, - { - "depends_on": "eval:doc.based_on=='Transaction'", - "fieldname": "voucher_no", - "fieldtype": "Dynamic Link", - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Voucher No", - "mandatory_depends_on": "eval:doc.based_on=='Transaction'", - "options": "voucher_type" - }, - { - "default": "Transaction", - "fieldname": "based_on", - "fieldtype": "Select", - "label": "Based On", - "options": "Transaction\nItem and Warehouse", - "reqd": 1 - }, - { - "default": "1", - "fieldname": "allow_negative_stock", - "fieldtype": "Check", - "label": "Allow Negative Stock" - }, - { - "default": "0", - "fieldname": "via_landed_cost_voucher", - "fieldtype": "Check", - "label": "Via Landed Cost Voucher" - }, - { - "default": "0", - "fieldname": "allow_zero_rate", - "fieldtype": "Check", - "label": "Allow Zero Rate" - }, - { - "fieldname": "items_to_be_repost", - "fieldtype": "Code", - "hidden": 1, - "label": "Items to Be Repost", - "no_copy": 1, - "print_hide": 1, - "read_only": 1 - }, - { - "fieldname": "distinct_item_and_warehouse", - "fieldtype": "Code", - "hidden": 1, - "label": "Distinct Item and Warehouse", - "no_copy": 1, - "print_hide": 1, - "read_only": 1 - }, - { - "fieldname": "current_index", - "fieldtype": "Int", - "hidden": 1, - "label": "Current Index", - "no_copy": 1, - "print_hide": 1, - "read_only": 1 - }, - { - "fieldname": "affected_transactions", - "fieldtype": "Code", - "hidden": 1, - "label": "Affected Transactions", - "no_copy": 1, - "read_only": 1 - }, - { - "default": "0", - "fieldname": "gl_reposting_index", - "fieldtype": "Int", - "hidden": 1, - "label": "GL reposting index", - "no_copy": 1, - "read_only": 1 - }, - { - "fieldname": "reposting_info_section", - "fieldtype": "Section Break", - "label": "Reposting Info" - }, - { - "fieldname": "column_break_o1sj", - "fieldtype": "Column Break" - }, - { - "fieldname": "total_reposting_count", - "fieldtype": "Int", - "label": "Total Reposting Count", - "no_copy": 1, - "read_only": 1 - }, - { - "fieldname": "reposting_data_file", - "fieldtype": "Attach", - "label": "Reposting Data File", - "read_only": 1 - } - ], - "index_web_pages_for_search": 1, - "is_submittable": 1, - "links": [], - "modified": "2023-05-31 12:48:57.138693", - "modified_by": "Administrator", - "module": "Stock", - "name": "Repost Item Valuation", - "naming_rule": "Random", - "owner": "Administrator", - "permissions": [ - { - "cancel": 1, - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "share": 1, - "submit": 1, - "write": 1 - }, - { - "cancel": 1, - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "Stock Manager", - "share": 1, - "submit": 1, - "write": 1 - }, - { - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "Accounts Manager", - "share": 1, - "submit": 1, - "write": 1 - } - ], - "sort_field": "modified", - "sort_order": "DESC", - "states": [] + "actions": [], + "autoname": "hash", + "creation": "2022-01-11 15:03:38.273179", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "based_on", + "voucher_type", + "voucher_no", + "item_code", + "warehouse", + "posting_date", + "posting_time", + "column_break_5", + "status", + "company", + "allow_negative_stock", + "via_landed_cost_voucher", + "allow_zero_rate", + "amended_from", + "error_section", + "error_log", + "reposting_info_section", + "reposting_data_file", + "items_to_be_repost", + "distinct_item_and_warehouse", + "column_break_o1sj", + "total_reposting_count", + "current_index", + "gl_reposting_index", + "affected_transactions" + ], + "fields": [ + { + "depends_on": "eval:doc.based_on=='Item and Warehouse'", + "fieldname": "item_code", + "fieldtype": "Link", + "label": "Item Code", + "mandatory_depends_on": "eval:doc.based_on=='Item and Warehouse'", + "options": "Item" + }, + { + "depends_on": "eval:doc.based_on=='Item and Warehouse'", + "fieldname": "warehouse", + "fieldtype": "Link", + "label": "Warehouse", + "mandatory_depends_on": "eval:doc.based_on=='Item and Warehouse'", + "options": "Warehouse" + }, + { + "fetch_from": "voucher_no.posting_date", + "fieldname": "posting_date", + "fieldtype": "Date", + "label": "Posting Date", + "read_only_depends_on": "eval: doc.based_on == \"Transaction\"", + "reqd": 1 + }, + { + "fetch_from": "voucher_no.posting_time", + "fieldname": "posting_time", + "fieldtype": "Time", + "label": "Posting Time", + "read_only_depends_on": "eval: doc.based_on == \"Transaction\"" + }, + { + "default": "Queued", + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Status", + "no_copy": 1, + "options": "Queued\nIn Progress\nCompleted\nSkipped\nFailed", + "read_only": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "label": "Amended From", + "no_copy": 1, + "options": "Repost Item Valuation", + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_5", + "fieldtype": "Column Break" + }, + { + "depends_on": "eval:doc.status=='Failed'", + "fieldname": "error_section", + "fieldtype": "Section Break", + "label": "Error" + }, + { + "fieldname": "error_log", + "fieldtype": "Long Text", + "label": "Error Log", + "no_copy": 1, + "read_only": 1 + }, + { + "fetch_from": "warehouse.company", + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company" + }, + { + "depends_on": "eval:doc.based_on=='Transaction'", + "fieldname": "voucher_type", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Voucher Type", + "mandatory_depends_on": "eval:doc.based_on=='Transaction'", + "options": "DocType" + }, + { + "depends_on": "eval:doc.based_on=='Transaction'", + "fieldname": "voucher_no", + "fieldtype": "Dynamic Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Voucher No", + "mandatory_depends_on": "eval:doc.based_on=='Transaction'", + "options": "voucher_type" + }, + { + "default": "Transaction", + "fieldname": "based_on", + "fieldtype": "Select", + "label": "Based On", + "options": "Transaction\nItem and Warehouse", + "reqd": 1 + }, + { + "default": "1", + "fieldname": "allow_negative_stock", + "fieldtype": "Check", + "label": "Allow Negative Stock" + }, + { + "default": "0", + "fieldname": "via_landed_cost_voucher", + "fieldtype": "Check", + "label": "Via Landed Cost Voucher" + }, + { + "default": "0", + "fieldname": "allow_zero_rate", + "fieldtype": "Check", + "label": "Allow Zero Rate" + }, + { + "fieldname": "items_to_be_repost", + "fieldtype": "Code", + "hidden": 1, + "label": "Items to Be Repost", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "distinct_item_and_warehouse", + "fieldtype": "Code", + "hidden": 1, + "label": "Distinct Item and Warehouse", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "current_index", + "fieldtype": "Int", + "hidden": 1, + "label": "Current Index", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "affected_transactions", + "fieldtype": "Code", + "hidden": 1, + "label": "Affected Transactions", + "no_copy": 1, + "read_only": 1 + }, + { + "default": "0", + "fieldname": "gl_reposting_index", + "fieldtype": "Int", + "hidden": 1, + "label": "GL reposting index", + "no_copy": 1, + "read_only": 1 + }, + { + "fieldname": "reposting_info_section", + "fieldtype": "Section Break", + "label": "Reposting Info" + }, + { + "fieldname": "column_break_o1sj", + "fieldtype": "Column Break" + }, + { + "fieldname": "total_reposting_count", + "fieldtype": "Int", + "label": "Total Reposting Count", + "no_copy": 1, + "read_only": 1 + }, + { + "fieldname": "reposting_data_file", + "fieldtype": "Attach", + "label": "Reposting Data File", + "no_copy": 1, + "read_only": 1 + } + ], + "index_web_pages_for_search": 1, + "is_submittable": 1, + "links": [], + "modified": "2024-06-27 16:55:23.150146", + "modified_by": "Administrator", + "module": "Stock", + "name": "Repost Item Valuation", + "naming_rule": "Random", + "owner": "Administrator", + "permissions": [ + { + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "submit": 1, + "write": 1 + }, + { + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Stock Manager", + "share": 1, + "submit": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "share": 1, + "submit": 1, + "write": 1 + } + ], + "sort_field": "creation", + "sort_order": "DESC", + "states": [] } diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py index e06765ed81b2dcadbfabf6dcecd18e18f0573803..3fb31ca46ad050f3e814950c81cdb933958de9b9 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py @@ -159,7 +159,7 @@ class RepostItemValuation(Document): def clear_attachment(self): if attachments := get_attachments(self.doctype, self.name): attachment = attachments[0] - frappe.delete_doc("File", attachment.name) + frappe.delete_doc("File", attachment.name, ignore_permissions=True) if self.reposting_data_file: self.db_set("reposting_data_file", None) @@ -197,6 +197,7 @@ class RepostItemValuation(Document): self.distinct_item_and_warehouse = None self.items_to_be_repost = None self.gl_reposting_index = 0 + self.clear_attachment() self.db_update() def deduplicate_similar_repost(self): @@ -249,6 +250,7 @@ def repost(doc): repost_gl_entries(doc) doc.set_status("Completed") + doc.db_set("reposting_data_file", None) remove_attached_file(doc.name) except Exception as e: @@ -293,7 +295,7 @@ def remove_attached_file(docname): if file_name := frappe.db.get_value( "File", {"attached_to_name": docname, "attached_to_doctype": "Repost Item Valuation"}, "name" ): - frappe.delete_doc("File", file_name, delete_permanently=True) + frappe.delete_doc("File", file_name, ignore_permissions=True, delete_permanently=True) def repost_sl_entries(doc):