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 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 4 | |
Nabin Hait | 0357fbc | 2018-03-09 13:19:52 +0530 | [diff] [blame] | 5 | import frappe |
| 6 | from frappe import _ |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 7 | |
Nabin Hait | 0357fbc | 2018-03-09 13:19:52 +0530 | [diff] [blame] | 8 | from erpnext import get_region |
| 9 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 10 | |
Nabin Hait | 0357fbc | 2018-03-09 13:19:52 +0530 | [diff] [blame] | 11 | def check_deletion_permission(doc, method): |
Himanshu Mishra | 35b2627 | 2018-11-13 11:13:04 +0530 | [diff] [blame] | 12 | region = get_region(doc.company) |
Nabin Hait | a334ed8 | 2019-01-22 10:41:50 +0530 | [diff] [blame] | 13 | if region in ["Nepal", "France"] and doc.docstatus != 0: |
Suraj Shetty | 48e9bc3 | 2020-01-29 15:06:18 +0530 | [diff] [blame] | 14 | frappe.throw(_("Deletion is not permitted for country {0}").format(region)) |
Raffael Meyer | edba060 | 2019-11-06 14:37:04 +0100 | [diff] [blame] | 15 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 16 | |
Raffael Meyer | edba060 | 2019-11-06 14:37:04 +0100 | [diff] [blame] | 17 | def create_transaction_log(doc, method): |
| 18 | """ |
| 19 | Appends the transaction to a chain of hashed logs for legal resons. |
| 20 | Called on submit of Sales Invoice and Payment Entry. |
| 21 | """ |
| 22 | region = get_region() |
| 23 | if region not in ["France", "Germany"]: |
| 24 | return |
| 25 | |
| 26 | data = str(doc.as_dict()) |
| 27 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 28 | frappe.get_doc( |
| 29 | { |
| 30 | "doctype": "Transaction Log", |
| 31 | "reference_doctype": doc.doctype, |
| 32 | "document_name": doc.name, |
| 33 | "data": data, |
| 34 | } |
| 35 | ).insert(ignore_permissions=True) |