Nabin Hait | 0357fbc | 2018-03-09 13:19:52 +0530 | [diff] [blame] | 1 | # Copyright (c) 2018, Frappe Technologies and contributors |
| 2 | # For license information, please see license.txt |
| 3 | |
Aditya Hase | f3c22f3 | 2019-01-22 18:22:20 +0530 | [diff] [blame] | 4 | from __future__ import unicode_literals |
Nabin Hait | 0357fbc | 2018-03-09 13:19:52 +0530 | [diff] [blame] | 5 | import frappe |
| 6 | from frappe import _ |
| 7 | from erpnext import get_region |
| 8 | |
| 9 | def check_deletion_permission(doc, method): |
Himanshu Mishra | 35b2627 | 2018-11-13 11:13:04 +0530 | [diff] [blame] | 10 | region = get_region(doc.company) |
Nabin Hait | a334ed8 | 2019-01-22 10:41:50 +0530 | [diff] [blame] | 11 | if region in ["Nepal", "France"] and doc.docstatus != 0: |
Suraj Shetty | 48e9bc3 | 2020-01-29 15:06:18 +0530 | [diff] [blame] | 12 | frappe.throw(_("Deletion is not permitted for country {0}").format(region)) |
Raffael Meyer | edba060 | 2019-11-06 14:37:04 +0100 | [diff] [blame] | 13 | |
| 14 | def 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) |