Skip to content

Commit

Permalink
fix: don't fail if record exists
Browse files Browse the repository at this point in the history
Resolves #48 (comment)
  • Loading branch information
barredterra committed Nov 7, 2024
1 parent 8648074 commit 6e4a8ed
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion erpnext_germany/install.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import contextlib
from csv import DictReader

import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
from frappe.exceptions import DuplicateEntryError

from .custom_fields import get_custom_fields


Expand Down Expand Up @@ -32,11 +35,14 @@ def import_csv(doctype, path):
reader = DictReader(csvfile)
for row in reader:
if frappe.db.exists(doctype, row):
# This doesn't catch all duplicates, because it expects all
# fields to match, not (only) the primary key.
continue

doc = frappe.new_doc(doctype)
doc.update(row)
doc.insert()
with contextlib.suppress(DuplicateEntryError):
doc.insert()


def make_property_setters():
Expand Down

0 comments on commit 6e4a8ed

Please sign in to comment.