fix: ignore duplicates explicitly
This commit is contained in:
parent
856d3f63b5
commit
9c7df2eec5
@ -109,7 +109,7 @@ def create_bank_account(bank_name="Citi Bank", account_name="_Test Bank - _TC"):
|
|||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
"doctype": "Bank",
|
"doctype": "Bank",
|
||||||
"bank_name":bank_name,
|
"bank_name":bank_name,
|
||||||
}).insert()
|
}).insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ def create_bank_account(bank_name="Citi Bank", account_name="_Test Bank - _TC"):
|
|||||||
"account_name":"Checking Account",
|
"account_name":"Checking Account",
|
||||||
"bank": bank_name,
|
"bank": bank_name,
|
||||||
"account": account_name
|
"account": account_name
|
||||||
}).insert()
|
}).insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ def add_vouchers():
|
|||||||
"supplier_group":"All Supplier Groups",
|
"supplier_group":"All Supplier Groups",
|
||||||
"supplier_type": "Company",
|
"supplier_type": "Company",
|
||||||
"supplier_name": "Conrad Electronic"
|
"supplier_name": "Conrad Electronic"
|
||||||
}).insert()
|
}).insert(ignore_if_duplicate=True)
|
||||||
|
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
@ -203,7 +203,7 @@ def add_vouchers():
|
|||||||
"supplier_group":"All Supplier Groups",
|
"supplier_group":"All Supplier Groups",
|
||||||
"supplier_type": "Company",
|
"supplier_type": "Company",
|
||||||
"supplier_name": "Mr G"
|
"supplier_name": "Mr G"
|
||||||
}).insert()
|
}).insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ def add_vouchers():
|
|||||||
"supplier_group":"All Supplier Groups",
|
"supplier_group":"All Supplier Groups",
|
||||||
"supplier_type": "Company",
|
"supplier_type": "Company",
|
||||||
"supplier_name": "Poore Simon's"
|
"supplier_name": "Poore Simon's"
|
||||||
}).insert()
|
}).insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ def add_vouchers():
|
|||||||
"customer_group":"All Customer Groups",
|
"customer_group":"All Customer Groups",
|
||||||
"customer_type": "Company",
|
"customer_type": "Company",
|
||||||
"customer_name": "Poore Simon's"
|
"customer_name": "Poore Simon's"
|
||||||
}).insert()
|
}).insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ def add_vouchers():
|
|||||||
"customer_group":"All Customer Groups",
|
"customer_group":"All Customer Groups",
|
||||||
"customer_type": "Company",
|
"customer_type": "Company",
|
||||||
"customer_name": "Fayva"
|
"customer_name": "Fayva"
|
||||||
}).insert()
|
}).insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class TestTaxDetail(unittest.TestCase):
|
|||||||
# Create GL Entries:
|
# Create GL Entries:
|
||||||
db_doc.submit()
|
db_doc.submit()
|
||||||
else:
|
else:
|
||||||
db_doc.insert()
|
db_doc.insert(ignore_if_duplicate=True)
|
||||||
except frappe.exceptions.DuplicateEntryError:
|
except frappe.exceptions.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ def create_payment_gateway_account(gateway, payment_channel="Email"):
|
|||||||
"payment_account": bank_account.name,
|
"payment_account": bank_account.name,
|
||||||
"currency": bank_account.account_currency,
|
"currency": bank_account.account_currency,
|
||||||
"payment_channel": payment_channel
|
"payment_channel": payment_channel
|
||||||
}).insert(ignore_permissions=True)
|
}).insert(ignore_permissions=True, ignore_if_duplicate=True)
|
||||||
|
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
# already exists, due to a reinstall?
|
# already exists, due to a reinstall?
|
||||||
|
@ -1280,7 +1280,7 @@ def create_asset(**args):
|
|||||||
|
|
||||||
if not args.do_not_save:
|
if not args.do_not_save:
|
||||||
try:
|
try:
|
||||||
asset.save()
|
asset.insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -1321,7 +1321,7 @@ def create_fixed_asset_item(item_code=None, auto_create_assets=1, is_grouped_ass
|
|||||||
"is_grouped_asset": is_grouped_asset,
|
"is_grouped_asset": is_grouped_asset,
|
||||||
"asset_naming_series": naming_series
|
"asset_naming_series": naming_series
|
||||||
})
|
})
|
||||||
item.insert()
|
item.insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
return item
|
return item
|
||||||
|
@ -23,7 +23,7 @@ class TestAssetCategory(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
asset_category.insert()
|
asset_category.insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -14,151 +14,150 @@ test_records = frappe.get_test_records('Supplier')
|
|||||||
|
|
||||||
|
|
||||||
class TestSupplier(unittest.TestCase):
|
class TestSupplier(unittest.TestCase):
|
||||||
def test_get_supplier_group_details(self):
|
def test_get_supplier_group_details(self):
|
||||||
doc = frappe.new_doc("Supplier Group")
|
doc = frappe.new_doc("Supplier Group")
|
||||||
doc.supplier_group_name = "_Testing Supplier Group"
|
doc.supplier_group_name = "_Testing Supplier Group"
|
||||||
doc.payment_terms = "_Test Payment Term Template 3"
|
doc.payment_terms = "_Test Payment Term Template 3"
|
||||||
doc.accounts = []
|
doc.accounts = []
|
||||||
test_account_details = {
|
test_account_details = {
|
||||||
"company": "_Test Company",
|
"company": "_Test Company",
|
||||||
"account": "Creditors - _TC",
|
"account": "Creditors - _TC",
|
||||||
}
|
}
|
||||||
doc.append("accounts", test_account_details)
|
doc.append("accounts", test_account_details)
|
||||||
doc.save()
|
doc.save()
|
||||||
s_doc = frappe.new_doc("Supplier")
|
s_doc = frappe.new_doc("Supplier")
|
||||||
s_doc.supplier_name = "Testing Supplier"
|
s_doc.supplier_name = "Testing Supplier"
|
||||||
s_doc.supplier_group = "_Testing Supplier Group"
|
s_doc.supplier_group = "_Testing Supplier Group"
|
||||||
s_doc.payment_terms = ""
|
s_doc.payment_terms = ""
|
||||||
s_doc.accounts = []
|
s_doc.accounts = []
|
||||||
s_doc.insert()
|
s_doc.insert()
|
||||||
s_doc.get_supplier_group_details()
|
s_doc.get_supplier_group_details()
|
||||||
self.assertEqual(s_doc.payment_terms, "_Test Payment Term Template 3")
|
self.assertEqual(s_doc.payment_terms, "_Test Payment Term Template 3")
|
||||||
self.assertEqual(s_doc.accounts[0].company, "_Test Company")
|
self.assertEqual(s_doc.accounts[0].company, "_Test Company")
|
||||||
self.assertEqual(s_doc.accounts[0].account, "Creditors - _TC")
|
self.assertEqual(s_doc.accounts[0].account, "Creditors - _TC")
|
||||||
s_doc.delete()
|
s_doc.delete()
|
||||||
doc.delete()
|
doc.delete()
|
||||||
|
|
||||||
def test_supplier_default_payment_terms(self):
|
def test_supplier_default_payment_terms(self):
|
||||||
# Payment Term based on Days after invoice date
|
# Payment Term based on Days after invoice date
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
"Supplier", "_Test Supplier With Template 1", "payment_terms", "_Test Payment Term Template 3")
|
"Supplier", "_Test Supplier With Template 1", "payment_terms", "_Test Payment Term Template 3")
|
||||||
|
|
||||||
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
self.assertEqual(due_date, "2016-02-21")
|
self.assertEqual(due_date, "2016-02-21")
|
||||||
|
|
||||||
due_date = get_due_date("2017-01-22", "Supplier", "_Test Supplier With Template 1")
|
due_date = get_due_date("2017-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
self.assertEqual(due_date, "2017-02-21")
|
self.assertEqual(due_date, "2017-02-21")
|
||||||
|
|
||||||
# Payment Term based on last day of month
|
# Payment Term based on last day of month
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
"Supplier", "_Test Supplier With Template 1", "payment_terms", "_Test Payment Term Template 1")
|
"Supplier", "_Test Supplier With Template 1", "payment_terms", "_Test Payment Term Template 1")
|
||||||
|
|
||||||
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
self.assertEqual(due_date, "2016-02-29")
|
self.assertEqual(due_date, "2016-02-29")
|
||||||
|
|
||||||
due_date = get_due_date("2017-01-22", "Supplier", "_Test Supplier With Template 1")
|
due_date = get_due_date("2017-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
self.assertEqual(due_date, "2017-02-28")
|
self.assertEqual(due_date, "2017-02-28")
|
||||||
|
|
||||||
frappe.db.set_value("Supplier", "_Test Supplier With Template 1", "payment_terms", "")
|
frappe.db.set_value("Supplier", "_Test Supplier With Template 1", "payment_terms", "")
|
||||||
|
|
||||||
# Set credit limit for the supplier group instead of supplier and evaluate the due date
|
# Set credit limit for the supplier group instead of supplier and evaluate the due date
|
||||||
frappe.db.set_value("Supplier Group", "_Test Supplier Group", "payment_terms", "_Test Payment Term Template 3")
|
frappe.db.set_value("Supplier Group", "_Test Supplier Group", "payment_terms", "_Test Payment Term Template 3")
|
||||||
|
|
||||||
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
self.assertEqual(due_date, "2016-02-21")
|
self.assertEqual(due_date, "2016-02-21")
|
||||||
|
|
||||||
# Payment terms for Supplier Group instead of supplier and evaluate the due date
|
# Payment terms for Supplier Group instead of supplier and evaluate the due date
|
||||||
frappe.db.set_value("Supplier Group", "_Test Supplier Group", "payment_terms", "_Test Payment Term Template 1")
|
frappe.db.set_value("Supplier Group", "_Test Supplier Group", "payment_terms", "_Test Payment Term Template 1")
|
||||||
|
|
||||||
# Leap year
|
# Leap year
|
||||||
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
self.assertEqual(due_date, "2016-02-29")
|
self.assertEqual(due_date, "2016-02-29")
|
||||||
# # Non Leap year
|
# # Non Leap year
|
||||||
due_date = get_due_date("2017-01-22", "Supplier", "_Test Supplier With Template 1")
|
due_date = get_due_date("2017-01-22", "Supplier", "_Test Supplier With Template 1")
|
||||||
self.assertEqual(due_date, "2017-02-28")
|
self.assertEqual(due_date, "2017-02-28")
|
||||||
|
|
||||||
# Supplier with no default Payment Terms Template
|
# Supplier with no default Payment Terms Template
|
||||||
frappe.db.set_value("Supplier Group", "_Test Supplier Group", "payment_terms", "")
|
frappe.db.set_value("Supplier Group", "_Test Supplier Group", "payment_terms", "")
|
||||||
frappe.db.set_value("Supplier", "_Test Supplier", "payment_terms", "")
|
frappe.db.set_value("Supplier", "_Test Supplier", "payment_terms", "")
|
||||||
|
|
||||||
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier")
|
due_date = get_due_date("2016-01-22", "Supplier", "_Test Supplier")
|
||||||
self.assertEqual(due_date, "2016-01-22")
|
self.assertEqual(due_date, "2016-01-22")
|
||||||
# # Non Leap year
|
# # Non Leap year
|
||||||
due_date = get_due_date("2017-01-22", "Supplier", "_Test Supplier")
|
due_date = get_due_date("2017-01-22", "Supplier", "_Test Supplier")
|
||||||
self.assertEqual(due_date, "2017-01-22")
|
self.assertEqual(due_date, "2017-01-22")
|
||||||
|
|
||||||
def test_supplier_disabled(self):
|
def test_supplier_disabled(self):
|
||||||
make_test_records("Item")
|
make_test_records("Item")
|
||||||
|
|
||||||
frappe.db.set_value("Supplier", "_Test Supplier", "disabled", 1)
|
frappe.db.set_value("Supplier", "_Test Supplier", "disabled", 1)
|
||||||
|
|
||||||
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
||||||
|
|
||||||
po = create_purchase_order(do_not_save=True)
|
po = create_purchase_order(do_not_save=True)
|
||||||
|
|
||||||
self.assertRaises(PartyDisabled, po.save)
|
self.assertRaises(PartyDisabled, po.save)
|
||||||
|
|
||||||
frappe.db.set_value("Supplier", "_Test Supplier", "disabled", 0)
|
frappe.db.set_value("Supplier", "_Test Supplier", "disabled", 0)
|
||||||
|
|
||||||
po.save()
|
po.save()
|
||||||
|
|
||||||
def test_supplier_country(self):
|
def test_supplier_country(self):
|
||||||
# Test that country field exists in Supplier DocType
|
# Test that country field exists in Supplier DocType
|
||||||
supplier = frappe.get_doc('Supplier', '_Test Supplier with Country')
|
supplier = frappe.get_doc('Supplier', '_Test Supplier with Country')
|
||||||
self.assertTrue('country' in supplier.as_dict())
|
self.assertTrue('country' in supplier.as_dict())
|
||||||
|
|
||||||
# Test if test supplier field record is 'Greece'
|
# Test if test supplier field record is 'Greece'
|
||||||
self.assertEqual(supplier.country, "Greece")
|
self.assertEqual(supplier.country, "Greece")
|
||||||
|
|
||||||
# Test update Supplier instance country value
|
# Test update Supplier instance country value
|
||||||
supplier = frappe.get_doc('Supplier', '_Test Supplier')
|
supplier = frappe.get_doc('Supplier', '_Test Supplier')
|
||||||
supplier.country = 'Greece'
|
supplier.country = 'Greece'
|
||||||
supplier.save()
|
supplier.save()
|
||||||
self.assertEqual(supplier.country, "Greece")
|
self.assertEqual(supplier.country, "Greece")
|
||||||
|
|
||||||
def test_party_details_tax_category(self):
|
def test_party_details_tax_category(self):
|
||||||
from erpnext.accounts.party import get_party_details
|
from erpnext.accounts.party import get_party_details
|
||||||
|
|
||||||
frappe.delete_doc_if_exists("Address", "_Test Address With Tax Category-Billing")
|
frappe.delete_doc_if_exists("Address", "_Test Address With Tax Category-Billing")
|
||||||
|
|
||||||
# Tax Category without Address
|
# Tax Category without Address
|
||||||
details = get_party_details("_Test Supplier With Tax Category", party_type="Supplier")
|
details = get_party_details("_Test Supplier With Tax Category", party_type="Supplier")
|
||||||
self.assertEqual(details.tax_category, "_Test Tax Category 1")
|
self.assertEqual(details.tax_category, "_Test Tax Category 1")
|
||||||
|
|
||||||
address = frappe.get_doc(dict(
|
address = frappe.get_doc(dict(
|
||||||
doctype='Address',
|
doctype='Address',
|
||||||
address_title='_Test Address With Tax Category',
|
address_title='_Test Address With Tax Category',
|
||||||
tax_category='_Test Tax Category 2',
|
tax_category='_Test Tax Category 2',
|
||||||
address_type='Billing',
|
address_type='Billing',
|
||||||
address_line1='Station Road',
|
address_line1='Station Road',
|
||||||
city='_Test City',
|
city='_Test City',
|
||||||
country='India',
|
country='India',
|
||||||
links=[dict(
|
links=[dict(
|
||||||
link_doctype='Supplier',
|
link_doctype='Supplier',
|
||||||
link_name='_Test Supplier With Tax Category'
|
link_name='_Test Supplier With Tax Category'
|
||||||
)]
|
)]
|
||||||
)).insert()
|
)).insert()
|
||||||
|
|
||||||
# Tax Category with Address
|
# Tax Category with Address
|
||||||
details = get_party_details("_Test Supplier With Tax Category", party_type="Supplier")
|
details = get_party_details("_Test Supplier With Tax Category", party_type="Supplier")
|
||||||
self.assertEqual(details.tax_category, "_Test Tax Category 2")
|
self.assertEqual(details.tax_category, "_Test Tax Category 2")
|
||||||
|
|
||||||
# Rollback
|
# Rollback
|
||||||
address.delete()
|
address.delete()
|
||||||
|
|
||||||
def create_supplier(**args):
|
def create_supplier(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|
||||||
try:
|
if frappe.db.exists("Supplier", args.supplier_name):
|
||||||
doc = frappe.get_doc({
|
return frappe.get_doc("Supplier", args.supplier_name)
|
||||||
"doctype": "Supplier",
|
|
||||||
"supplier_name": args.supplier_name,
|
|
||||||
"supplier_group": args.supplier_group or "Services",
|
|
||||||
"supplier_type": args.supplier_type or "Company",
|
|
||||||
"tax_withholding_category": args.tax_withholding_category
|
|
||||||
}).insert()
|
|
||||||
|
|
||||||
return doc
|
doc = frappe.get_doc({
|
||||||
|
"doctype": "Supplier",
|
||||||
|
"supplier_name": args.supplier_name,
|
||||||
|
"supplier_group": args.supplier_group or "Services",
|
||||||
|
"supplier_type": args.supplier_type or "Company",
|
||||||
|
"tax_withholding_category": args.tax_withholding_category
|
||||||
|
}).insert()
|
||||||
|
|
||||||
except frappe.DuplicateEntryError:
|
return doc
|
||||||
return frappe.get_doc("Supplier", args.supplier_name)
|
|
||||||
|
@ -175,7 +175,7 @@ class TestShoppingCart(unittest.TestCase):
|
|||||||
def create_tax_rule(self):
|
def create_tax_rule(self):
|
||||||
tax_rule = frappe.get_test_records("Tax Rule")[0]
|
tax_rule = frappe.get_test_records("Tax Rule")[0]
|
||||||
try:
|
try:
|
||||||
frappe.get_doc(tax_rule).insert()
|
frappe.get_doc(tax_rule).insert(ignore_if_duplicate=True)
|
||||||
except (frappe.DuplicateEntryError, ConflictingTaxRule):
|
except (frappe.DuplicateEntryError, ConflictingTaxRule):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class TallyMigration(Document):
|
|||||||
"is_private": True
|
"is_private": True
|
||||||
})
|
})
|
||||||
try:
|
try:
|
||||||
f.insert()
|
f.insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
setattr(self, key, f.file_url)
|
setattr(self, key, f.file_url)
|
||||||
|
@ -142,7 +142,7 @@ class Employee(NestedSet):
|
|||||||
"file_url": self.image,
|
"file_url": self.image,
|
||||||
"attached_to_doctype": "User",
|
"attached_to_doctype": "User",
|
||||||
"attached_to_name": self.user_id
|
"attached_to_name": self.user_id
|
||||||
}).insert()
|
}).insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
# already exists
|
# already exists
|
||||||
pass
|
pass
|
||||||
|
@ -128,4 +128,4 @@ def show_email_summary(email_success, email_failure):
|
|||||||
message += _('{0} due to missing email information for employee(s): {1}').format(
|
message += _('{0} due to missing email information for employee(s): {1}').format(
|
||||||
frappe.bold('Sending Failed'), ', '.join(email_failure))
|
frappe.bold('Sending Failed'), ', '.join(email_failure))
|
||||||
|
|
||||||
frappe.msgprint(message, title=_('Exit Questionnaire'), indicator='blue', is_minimizable=True, wide=True)
|
frappe.msgprint(message, title=_('Exit Questionnaire'), indicator='blue', is_minimizable=True, wide=True)
|
||||||
|
@ -82,7 +82,7 @@ def get_vehicle(employee_id):
|
|||||||
"vehicle_value": flt(500000)
|
"vehicle_value": flt(500000)
|
||||||
})
|
})
|
||||||
try:
|
try:
|
||||||
vehicle.insert()
|
vehicle.insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
return license_plate
|
return license_plate
|
||||||
|
@ -21,7 +21,7 @@ class TestHomepageSection(unittest.TestCase):
|
|||||||
{'title': 'Card 2', 'subtitle': 'Subtitle 2', 'content': 'This is test card 2', 'image': 'test.jpg'},
|
{'title': 'Card 2', 'subtitle': 'Subtitle 2', 'content': 'This is test card 2', 'image': 'test.jpg'},
|
||||||
],
|
],
|
||||||
'no_of_columns': 3
|
'no_of_columns': 3
|
||||||
}).insert()
|
}).insert(ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -53,10 +53,7 @@ def create_hsn_codes(data, code_field):
|
|||||||
hsn_code.description = d["description"]
|
hsn_code.description = d["description"]
|
||||||
hsn_code.hsn_code = d[code_field]
|
hsn_code.hsn_code = d[code_field]
|
||||||
hsn_code.name = d[code_field]
|
hsn_code.name = d[code_field]
|
||||||
try:
|
hsn_code.db_insert(ignore_if_duplicate=True)
|
||||||
hsn_code.db_insert()
|
|
||||||
except frappe.DuplicateEntryError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def add_custom_roles_for_reports():
|
def add_custom_roles_for_reports():
|
||||||
for report_name in ('GST Sales Register', 'GST Purchase Register',
|
for report_name in ('GST Sales Register', 'GST Purchase Register',
|
||||||
|
@ -155,7 +155,7 @@ def insert_record(records):
|
|||||||
doc = frappe.new_doc(r.get("doctype"))
|
doc = frappe.new_doc(r.get("doctype"))
|
||||||
doc.update(r)
|
doc.update(r)
|
||||||
try:
|
try:
|
||||||
doc.insert(ignore_permissions=True)
|
doc.insert(ignore_permissions=True, ignore_if_duplicate=True)
|
||||||
except frappe.DuplicateEntryError as e:
|
except frappe.DuplicateEntryError as e:
|
||||||
# pass DuplicateEntryError and continue
|
# pass DuplicateEntryError and continue
|
||||||
if e.args and e.args[0]==doc.doctype and e.args[1]==doc.name:
|
if e.args and e.args[0]==doc.doctype and e.args[1]==doc.name:
|
||||||
|
@ -433,14 +433,13 @@ def create_price_list_for_batch(item_code, batch, rate):
|
|||||||
def make_new_batch(**args):
|
def make_new_batch(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|
||||||
try:
|
if frappe.db.exists("Batch", args.batch_id):
|
||||||
|
batch = frappe.get_doc("Batch", args.batch_id)
|
||||||
|
else:
|
||||||
batch = frappe.get_doc({
|
batch = frappe.get_doc({
|
||||||
"doctype": "Batch",
|
"doctype": "Batch",
|
||||||
"batch_id": args.batch_id,
|
"batch_id": args.batch_id,
|
||||||
"item": args.item_code,
|
"item": args.item_code,
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
except frappe.DuplicateEntryError:
|
|
||||||
batch = frappe.get_doc("Batch", args.batch_id)
|
|
||||||
|
|
||||||
return batch
|
return batch
|
||||||
|
Loading…
x
Reference in New Issue
Block a user