From f6e93f084aadf82f444edb112cc9832b53294b15 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Mon, 20 Nov 2023 10:23:35 +0530 Subject: [PATCH 1/7] fix: TypeError in Subcontracting Receipt --- .../doctype/serial_and_batch_bundle/serial_and_batch_bundle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py index 0a4cae7b34b3..4b8d9657af89 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py @@ -406,7 +406,7 @@ def validate_quantity(self, row, qty_field=None): if abs(abs(flt(self.total_qty, precision)) - abs(flt(row.get(qty_field), precision))) > 0.01: self.throw_error_message( - f"Total quantity {abs(self.total_qty)} in the Serial and Batch Bundle {bold(self.name)} does not match with the quantity {abs(row.get(qty_field))} for the Item {bold(self.item_code)} in the {self.voucher_type} # {self.voucher_no}" + f"Total quantity {abs(flt(self.total_qty))} in the Serial and Batch Bundle {bold(self.name)} does not match with the quantity {abs(flt(row.get(qty_field)))} for the Item {bold(self.item_code)} in the {self.voucher_type} # {self.voucher_no}" ) def set_is_outward(self): From 331ad62f3c27a54e9d6bb49f1b70b169b633b3a6 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Mon, 20 Nov 2023 12:03:54 +0530 Subject: [PATCH 2/7] fix(ux): enable `Quick Entry` for `Task` --- erpnext/projects/doctype/task/task.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/projects/doctype/task/task.json b/erpnext/projects/doctype/task/task.json index 25a5455ac158..4d2d22524230 100644 --- a/erpnext/projects/doctype/task/task.json +++ b/erpnext/projects/doctype/task/task.json @@ -57,6 +57,7 @@ ], "fields": [ { + "allow_in_quick_entry": 1, "fieldname": "subject", "fieldtype": "Data", "in_global_search": 1, @@ -66,6 +67,7 @@ "search_index": 1 }, { + "allow_in_quick_entry": 1, "bold": 1, "fieldname": "project", "fieldtype": "Link", @@ -396,7 +398,7 @@ "is_tree": 1, "links": [], "max_attachments": 5, - "modified": "2023-09-28 13:52:05.861175", + "modified": "2023-11-20 11:42:41.884069", "modified_by": "Administrator", "module": "Projects", "name": "Task", @@ -416,6 +418,7 @@ "write": 1 } ], + "quick_entry": 1, "search_fields": "subject", "show_name_in_global_search": 1, "show_preview_popup": 1, From 2f3fc12c08218ca06fbb911781090e619a88cf22 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Mon, 20 Nov 2023 12:05:25 +0530 Subject: [PATCH 3/7] fix: add route options for new `Task` --- erpnext/projects/doctype/timesheet/timesheet.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index d1d07a79d678..eb7a97e615ee 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -111,6 +111,7 @@ frappe.ui.form.on("Timesheet", { frm.trigger('setup_filters'); frm.trigger('set_dynamic_field_label'); + frm.trigger('set_route_options_for_new_task'); }, customer: function(frm) { @@ -172,6 +173,14 @@ frappe.ui.form.on("Timesheet", { frm.refresh_fields(); }, + set_route_options_for_new_task: (frm) => { + let task_field = frm.get_docfield('time_logs', 'task'); + + if (task_field) { + task_field.get_route_options_for_new_doc = (row) => ({'project': row.doc.project}); + } + }, + make_invoice: function(frm) { let fields = [{ "fieldtype": "Link", From ee0c64215d160f0bd493bcefc9e94a5a90d318d2 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 20 Nov 2023 11:52:26 +0530 Subject: [PATCH 4/7] refactor: set default for 'update_billed_amount_in_delivery_note' --- erpnext/accounts/doctype/sales_invoice/sales_invoice.json | 4 ++-- erpnext/controllers/sales_and_purchase_return.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index cd725b986228..d1677832ed97 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -2156,7 +2156,7 @@ "label": "Use Company default Cost Center for Round off" }, { - "default": "0", + "default": "1", "depends_on": "eval: doc.is_return", "fieldname": "update_billed_amount_in_delivery_note", "fieldtype": "Check", @@ -2173,7 +2173,7 @@ "link_fieldname": "consolidated_invoice" } ], - "modified": "2023-11-03 14:39:38.012346", + "modified": "2023-11-20 11:51:43.555197", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 165e17b2d77a..e91212b03133 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -356,6 +356,7 @@ def set_missing_values(source, target): if doc.doctype == "Sales Invoice" or doc.doctype == "POS Invoice": doc.consolidated_invoice = "" doc.set("payments", []) + doc.update_billed_amount_in_delivery_note = True for data in source.payments: paid_amount = 0.00 base_paid_amount = 0.00 From 83a13e22b7f4aa8ba2c406389af4e7fa8aad55d0 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 20 Nov 2023 12:27:43 +0530 Subject: [PATCH 5/7] refactor: add flag to POS Invoice --- erpnext/accounts/doctype/pos_invoice/pos_invoice.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.json b/erpnext/accounts/doctype/pos_invoice/pos_invoice.json index f6047079ff8d..955b66a1b812 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.json +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.json @@ -18,6 +18,7 @@ "is_pos", "is_return", "update_billed_amount_in_sales_order", + "update_billed_amount_in_delivery_note", "column_break1", "company", "posting_date", @@ -1550,12 +1551,19 @@ "fieldtype": "Currency", "label": "Amount Eligible for Commission", "read_only": 1 + }, + { + "default": "1", + "depends_on": "eval: doc.is_return && doc.return_against", + "fieldname": "update_billed_amount_in_delivery_note", + "fieldtype": "Check", + "label": "Update Billed Amount in Delivery Note" } ], "icon": "fa fa-file-text", "is_submittable": 1, "links": [], - "modified": "2023-06-03 16:23:41.083409", + "modified": "2023-11-20 12:27:12.848149", "modified_by": "Administrator", "module": "Accounts", "name": "POS Invoice", From fb06ad7330fd31bf1def7b87a6c3b787650f1555 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 20 Nov 2023 13:26:02 +0530 Subject: [PATCH 6/7] refactor: update scheduled job for bulk transaction --- erpnext/hooks.py | 2 +- erpnext/utilities/bulk_transaction.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 5483a10b5790..b22a3f76cb26 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -421,7 +421,7 @@ "hourly_long": [ "erpnext.accounts.doctype.process_subscription.process_subscription.create_subscription_process", "erpnext.stock.doctype.repost_item_valuation.repost_item_valuation.repost_entries", - "erpnext.bulk_transaction.doctype.bulk_transaction_log.bulk_transaction_log.retry_failing_transaction", + "erpnext.utilities.bulk_transaction.retry", ], "daily": [ "erpnext.support.doctype.issue.issue.auto_close_tickets", diff --git a/erpnext/utilities/bulk_transaction.py b/erpnext/utilities/bulk_transaction.py index 57c2f9d78762..df21b61139a2 100644 --- a/erpnext/utilities/bulk_transaction.py +++ b/erpnext/utilities/bulk_transaction.py @@ -30,7 +30,10 @@ def transaction_processing(data, from_doctype, to_doctype): @frappe.whitelist() -def retry(date: str | None): +def retry(date: str | None = None): + if not date: + date = today() + if date: failed_docs = frappe.db.get_all( "Bulk Transaction Log Detail", From 9903049c7ac7310ca9e3f69c30dc355c2e13bfd5 Mon Sep 17 00:00:00 2001 From: Anand Baburajan Date: Mon, 20 Nov 2023 22:27:16 +0530 Subject: [PATCH 7/7] fix: set default asset quantity as 1 [dev] (#38223) * fix: make default asset quantity as 1 * fix: get rate_of_depreciation from asset category for asset auto-creation * chore: create asset depr schedules on PR submit, not asset submit * fix: set default asset quantity as 1 * chore: move patch from v15 to v14 --- erpnext/assets/doctype/asset/asset.json | 3 +- erpnext/assets/doctype/asset/asset.py | 33 +++++++++++-------- erpnext/controllers/buying_controller.py | 2 +- erpnext/patches.txt | 1 + .../v14_0/update_zero_asset_quantity_field.py | 6 ++++ 5 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 erpnext/patches/v14_0/update_zero_asset_quantity_field.py diff --git a/erpnext/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json index d6b9c461cb24..540a4f5549f3 100644 --- a/erpnext/assets/doctype/asset/asset.json +++ b/erpnext/assets/doctype/asset/asset.json @@ -481,6 +481,7 @@ "read_only": 1 }, { + "default": "1", "fieldname": "asset_quantity", "fieldtype": "Int", "label": "Asset Quantity", @@ -571,7 +572,7 @@ "link_fieldname": "target_asset" } ], - "modified": "2023-11-15 17:40:17.315203", + "modified": "2023-11-20 20:57:37.010467", "modified_by": "Administrator", "module": "Assets", "name": "Asset", diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 3c570d1af0fe..7b7953b6ce6b 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -46,12 +46,28 @@ def validate(self): self.validate_item() self.validate_cost_center() self.set_missing_values() + self.validate_gross_and_purchase_amount() + self.validate_expected_value_after_useful_life() self.validate_finance_books() + if not self.split_from: self.prepare_depreciation_data() - update_draft_asset_depr_schedules(self) - self.validate_gross_and_purchase_amount() - self.validate_expected_value_after_useful_life() + + if self.calculate_depreciation: + update_draft_asset_depr_schedules(self) + + if frappe.db.exists("Asset", self.name): + asset_depr_schedules_names = make_draft_asset_depr_schedules_if_not_present(self) + + if asset_depr_schedules_names: + asset_depr_schedules_links = get_comma_separated_links( + asset_depr_schedules_names, "Asset Depreciation Schedule" + ) + frappe.msgprint( + _( + "Asset Depreciation Schedules created:
{0}

Please check, edit if needed, and submit the Asset." + ).format(asset_depr_schedules_links) + ) self.status = self.get_status() @@ -61,17 +77,7 @@ def on_submit(self): if not self.booked_fixed_asset and self.validate_make_gl_entry(): self.make_gl_entries() if self.calculate_depreciation and not self.split_from: - asset_depr_schedules_names = make_draft_asset_depr_schedules_if_not_present(self) convert_draft_asset_depr_schedules_into_active(self) - if asset_depr_schedules_names: - asset_depr_schedules_links = get_comma_separated_links( - asset_depr_schedules_names, "Asset Depreciation Schedule" - ) - frappe.msgprint( - _( - "Asset Depreciation Schedules created:
{0}

Please check, edit if needed, and submit the Asset." - ).format(asset_depr_schedules_links) - ) self.set_status() add_asset_activity(self.name, _("Asset submitted")) @@ -823,6 +829,7 @@ def get_item_details(item_code, asset_category, gross_purchase_amount): "expected_value_after_useful_life": flt(gross_purchase_amount) * flt(d.salvage_value_percentage / 100), "depreciation_start_date": d.depreciation_start_date or nowdate(), + "rate_of_depreciation": d.rate_of_depreciation, } ) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index a470b47a456d..68ad97d7ba45 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -758,7 +758,7 @@ def make_asset(self, row, is_grouped_asset=False): "calculate_depreciation": 0, "purchase_receipt_amount": purchase_amount, "gross_purchase_amount": purchase_amount, - "asset_quantity": row.qty if is_grouped_asset else 0, + "asset_quantity": row.qty if is_grouped_asset else 1, "purchase_receipt": self.name if self.doctype == "Purchase Receipt" else None, "purchase_invoice": self.name if self.doctype == "Purchase Invoice" else None, } diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 6c10dd9bbb42..0badab56ea31 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -351,5 +351,6 @@ erpnext.patches.v15_0.rename_daily_depreciation_to_depreciation_amount_based_on_ erpnext.patches.v15_0.rename_depreciation_amount_based_on_num_days_in_month_to_daily_prorata_based erpnext.patches.v15_0.set_reserved_stock_in_bin erpnext.patches.v14_0.create_accounting_dimensions_in_supplier_quotation +erpnext.patches.v14_0.update_zero_asset_quantity_field # below migration patch should always run last erpnext.patches.v14_0.migrate_gl_to_payment_ledger diff --git a/erpnext/patches/v14_0/update_zero_asset_quantity_field.py b/erpnext/patches/v14_0/update_zero_asset_quantity_field.py new file mode 100644 index 000000000000..0480f9b7aade --- /dev/null +++ b/erpnext/patches/v14_0/update_zero_asset_quantity_field.py @@ -0,0 +1,6 @@ +import frappe + + +def execute(): + asset = frappe.qb.DocType("Asset") + frappe.qb.update(asset).set(asset.asset_quantity, 1).where(asset.asset_quantity == 0).run()