From 580e9f6e10e21dab07080ac2884d0095412239b1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 5 Jan 2024 17:12:08 +0530 Subject: [PATCH 1/3] fix: improved validation message (cherry picked from commit fe43dab4d78091e626ddfb6432b2d69f84793d92) --- erpnext/assets/doctype/asset_category/asset_category.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/assets/doctype/asset_category/asset_category.py b/erpnext/assets/doctype/asset_category/asset_category.py index 8d351412ca8..2a204e11477 100644 --- a/erpnext/assets/doctype/asset_category/asset_category.py +++ b/erpnext/assets/doctype/asset_category/asset_category.py @@ -67,12 +67,12 @@ class AssetCategory(Document): if selected_key_type not in expected_key_types: frappe.throw( _( - "Row #{}: {} of {} should be {}. Please modify the account or select a different account." + "Row #{0}: {1} of {2} should be {3}. Please update the {1} or select a different account." ).format( d.idx, frappe.unscrub(key_to_match), frappe.bold(selected_account), - frappe.bold(expected_key_types), + frappe.bold(" or ".join(expected_key_types)), ), title=_("Invalid Account"), ) From 0f6477a253844d6e1fc530cbc5d0f7a38eaf0aa4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 5 Jan 2024 17:38:51 +0530 Subject: [PATCH 2/3] fix: Purchase date and amount is not mandatory for composite asset creation (cherry picked from commit c34f09c503b367f6ea1eee5e24f8aa6e94976e01) # Conflicts: # erpnext/assets/doctype/asset/asset.py --- erpnext/assets/doctype/asset/asset.json | 12 ++-- erpnext/assets/doctype/asset/asset.py | 91 ++++++++++++++++++++++++- 2 files changed, 96 insertions(+), 7 deletions(-) diff --git a/erpnext/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json index 91ae62bfad7..cdccf81507b 100644 --- a/erpnext/assets/doctype/asset/asset.json +++ b/erpnext/assets/doctype/asset/asset.json @@ -202,9 +202,9 @@ "fieldname": "purchase_date", "fieldtype": "Date", "label": "Purchase Date", + "mandatory_depends_on": "eval:!doc.is_existing_asset", "read_only": 1, - "read_only_depends_on": "eval:!doc.is_existing_asset && !doc.is_composite_asset", - "reqd": 1 + "read_only_depends_on": "eval:!doc.is_existing_asset && !doc.is_composite_asset" }, { "fieldname": "disposal_date", @@ -227,15 +227,15 @@ "fieldname": "gross_purchase_amount", "fieldtype": "Currency", "label": "Gross Purchase Amount", + "mandatory_depends_on": "eval:(!doc.is_composite_asset || doc.docstatus==1)", "options": "Company:company:default_currency", - "read_only_depends_on": "eval:!doc.is_existing_asset", - "reqd": 1 + "read_only_depends_on": "eval:!doc.is_existing_asset" }, { "fieldname": "available_for_use_date", "fieldtype": "Date", "label": "Available-for-use Date", - "reqd": 1 + "mandatory_depends_on": "eval:(!doc.is_composite_asset || doc.docstatus==1)" }, { "default": "0", @@ -583,7 +583,7 @@ "link_fieldname": "target_asset" } ], - "modified": "2023-12-21 16:46:20.732869", + "modified": "2024-01-05 17:36:53.131512", "modified_by": "Administrator", "module": "Assets", "name": "Asset", diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index f83d7071aa7..300d95d37ee 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -34,6 +34,86 @@ from erpnext.controllers.accounts_controller import AccountsController class Asset(AccountsController): +<<<<<<< HEAD +======= + # begin: auto-generated types + # This code is auto-generated. Do not modify anything in this block. + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from frappe.types import DF + + from erpnext.assets.doctype.asset_finance_book.asset_finance_book import AssetFinanceBook + + additional_asset_cost: DF.Currency + amended_from: DF.Link | None + asset_category: DF.Link | None + asset_name: DF.Data + asset_owner: DF.Literal["", "Company", "Supplier", "Customer"] + asset_owner_company: DF.Link | None + asset_quantity: DF.Int + available_for_use_date: DF.Date | None + booked_fixed_asset: DF.Check + calculate_depreciation: DF.Check + capitalized_in: DF.Link | None + company: DF.Link + comprehensive_insurance: DF.Data | None + cost_center: DF.Link | None + custodian: DF.Link | None + customer: DF.Link | None + default_finance_book: DF.Link | None + department: DF.Link | None + depr_entry_posting_status: DF.Literal["", "Successful", "Failed"] + depreciation_method: DF.Literal["", "Straight Line", "Double Declining Balance", "Manual"] + disposal_date: DF.Date | None + finance_books: DF.Table[AssetFinanceBook] + frequency_of_depreciation: DF.Int + gross_purchase_amount: DF.Currency + image: DF.AttachImage | None + insurance_end_date: DF.Date | None + insurance_start_date: DF.Date | None + insured_value: DF.Data | None + insurer: DF.Data | None + is_composite_asset: DF.Check + is_existing_asset: DF.Check + is_fully_depreciated: DF.Check + item_code: DF.Link + item_name: DF.ReadOnly | None + journal_entry_for_scrap: DF.Link | None + location: DF.Link + maintenance_required: DF.Check + naming_series: DF.Literal["ACC-ASS-.YYYY.-"] + next_depreciation_date: DF.Date | None + number_of_depreciations_booked: DF.Int + opening_accumulated_depreciation: DF.Currency + policy_number: DF.Data | None + purchase_date: DF.Date | None + purchase_invoice: DF.Link | None + purchase_receipt: DF.Link | None + purchase_receipt_amount: DF.Currency + split_from: DF.Link | None + status: DF.Literal[ + "Draft", + "Submitted", + "Partially Depreciated", + "Fully Depreciated", + "Sold", + "Scrapped", + "In Maintenance", + "Out of Order", + "Issue", + "Receipt", + "Capitalized", + "Decapitalized", + ] + supplier: DF.Link | None + total_asset_cost: DF.Currency + total_number_of_depreciations: DF.Int + value_after_depreciation: DF.Currency + # end: auto-generated types + +>>>>>>> c34f09c503 (fix: Purchase date and amount is not mandatory for composite asset creation) def validate(self): self.validate_asset_values() self.validate_asset_and_reference() @@ -247,7 +327,16 @@ class Asset(AccountsController): frappe.throw(_("Gross Purchase Amount is mandatory"), frappe.MandatoryError) if is_cwip_accounting_enabled(self.asset_category): +<<<<<<< HEAD if not self.is_existing_asset and not (self.purchase_receipt or self.purchase_invoice): +======= + if ( + not self.is_existing_asset + and not self.is_composite_asset + and not self.purchase_receipt + and not self.purchase_invoice + ): +>>>>>>> c34f09c503 (fix: Purchase date and amount is not mandatory for composite asset creation) frappe.throw( _("Please create purchase receipt or purchase invoice for the item {0}").format( self.item_code @@ -260,7 +349,7 @@ class Asset(AccountsController): and not frappe.db.get_value("Purchase Invoice", self.purchase_invoice, "update_stock") ): frappe.throw( - _("Update stock must be enable for the purchase invoice {0}").format(self.purchase_invoice) + _("Update stock must be enabled for the purchase invoice {0}").format(self.purchase_invoice) ) if not self.calculate_depreciation: From b52988389750e6d18eb5407ec18bf84b63d783d4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 10 Jan 2024 12:01:32 +0530 Subject: [PATCH 3/3] fix: resolved conflict --- erpnext/assets/doctype/asset/asset.py | 84 --------------------------- 1 file changed, 84 deletions(-) diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 300d95d37ee..3397f7708f5 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -34,86 +34,6 @@ from erpnext.controllers.accounts_controller import AccountsController class Asset(AccountsController): -<<<<<<< HEAD -======= - # begin: auto-generated types - # This code is auto-generated. Do not modify anything in this block. - - from typing import TYPE_CHECKING - - if TYPE_CHECKING: - from frappe.types import DF - - from erpnext.assets.doctype.asset_finance_book.asset_finance_book import AssetFinanceBook - - additional_asset_cost: DF.Currency - amended_from: DF.Link | None - asset_category: DF.Link | None - asset_name: DF.Data - asset_owner: DF.Literal["", "Company", "Supplier", "Customer"] - asset_owner_company: DF.Link | None - asset_quantity: DF.Int - available_for_use_date: DF.Date | None - booked_fixed_asset: DF.Check - calculate_depreciation: DF.Check - capitalized_in: DF.Link | None - company: DF.Link - comprehensive_insurance: DF.Data | None - cost_center: DF.Link | None - custodian: DF.Link | None - customer: DF.Link | None - default_finance_book: DF.Link | None - department: DF.Link | None - depr_entry_posting_status: DF.Literal["", "Successful", "Failed"] - depreciation_method: DF.Literal["", "Straight Line", "Double Declining Balance", "Manual"] - disposal_date: DF.Date | None - finance_books: DF.Table[AssetFinanceBook] - frequency_of_depreciation: DF.Int - gross_purchase_amount: DF.Currency - image: DF.AttachImage | None - insurance_end_date: DF.Date | None - insurance_start_date: DF.Date | None - insured_value: DF.Data | None - insurer: DF.Data | None - is_composite_asset: DF.Check - is_existing_asset: DF.Check - is_fully_depreciated: DF.Check - item_code: DF.Link - item_name: DF.ReadOnly | None - journal_entry_for_scrap: DF.Link | None - location: DF.Link - maintenance_required: DF.Check - naming_series: DF.Literal["ACC-ASS-.YYYY.-"] - next_depreciation_date: DF.Date | None - number_of_depreciations_booked: DF.Int - opening_accumulated_depreciation: DF.Currency - policy_number: DF.Data | None - purchase_date: DF.Date | None - purchase_invoice: DF.Link | None - purchase_receipt: DF.Link | None - purchase_receipt_amount: DF.Currency - split_from: DF.Link | None - status: DF.Literal[ - "Draft", - "Submitted", - "Partially Depreciated", - "Fully Depreciated", - "Sold", - "Scrapped", - "In Maintenance", - "Out of Order", - "Issue", - "Receipt", - "Capitalized", - "Decapitalized", - ] - supplier: DF.Link | None - total_asset_cost: DF.Currency - total_number_of_depreciations: DF.Int - value_after_depreciation: DF.Currency - # end: auto-generated types - ->>>>>>> c34f09c503 (fix: Purchase date and amount is not mandatory for composite asset creation) def validate(self): self.validate_asset_values() self.validate_asset_and_reference() @@ -327,16 +247,12 @@ class Asset(AccountsController): frappe.throw(_("Gross Purchase Amount is mandatory"), frappe.MandatoryError) if is_cwip_accounting_enabled(self.asset_category): -<<<<<<< HEAD - if not self.is_existing_asset and not (self.purchase_receipt or self.purchase_invoice): -======= if ( not self.is_existing_asset and not self.is_composite_asset and not self.purchase_receipt and not self.purchase_invoice ): ->>>>>>> c34f09c503 (fix: Purchase date and amount is not mandatory for composite asset creation) frappe.throw( _("Please create purchase receipt or purchase invoice for the item {0}").format( self.item_code