blob: faa59129a5aac15be800a60899c7999ba773214f [file] [log] [blame]
Nabin Hait0357fbc2018-03-09 13:19:52 +05301# Copyright (c) 2018, Frappe Technologies and contributors
2# For license information, please see license.txt
3
Aditya Hasef3c22f32019-01-22 18:22:20 +05304from __future__ import unicode_literals
Nabin Hait0357fbc2018-03-09 13:19:52 +05305import frappe
6from frappe import _
7from erpnext import get_region
8
9def check_deletion_permission(doc, method):
Himanshu Mishra35b26272018-11-13 11:13:04 +053010 region = get_region(doc.company)
Nabin Haita334ed82019-01-22 10:41:50 +053011 if region in ["Nepal", "France"] and doc.docstatus != 0:
Suraj Shetty48e9bc32020-01-29 15:06:18 +053012 frappe.throw(_("Deletion is not permitted for country {0}").format(region))
Raffael Meyeredba0602019-11-06 14:37:04 +010013
14def create_transaction_log(doc, method):
15 """
16 Appends the transaction to a chain of hashed logs for legal resons.
17 Called on submit of Sales Invoice and Payment Entry.
18 """
19 region = get_region()
20 if region not in ["France", "Germany"]:
21 return
22
23 data = str(doc.as_dict())
24
25 frappe.get_doc({
26 "doctype": "Transaction Log",
27 "reference_doctype": doc.doctype,
28 "document_name": doc.name,
29 "data": data
30 }).insert(ignore_permissions=True)