fix: not able to save BOM (duplicate key error) (backport #39620) (#39623)

fix: not able to save BOM (duplicate key error) (#39620)

(cherry picked from commit 4e182b89ce66db9bfb97c332c0132c12e6a83b57)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
mergify[bot] 2024-01-29 21:22:34 +05:30 committed by GitHub
parent 960443d268
commit 53c705506b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -176,8 +176,10 @@ class BOM(WebsiteGenerator):
def autoname(self):
# ignore amended documents while calculating current index
search_key = f"{self.doctype}-{self.item}%"
existing_boms = frappe.get_all(
"BOM", filters={"item": self.item, "amended_from": ["is", "not set"]}, pluck="name"
"BOM", filters={"name": ("like", search_key), "amended_from": ["is", "not set"]}, pluck="name"
)
if existing_boms: