mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-10 05:48:15 +00:00
feat: read public key file
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
"client_id",
|
||||
"client_secret",
|
||||
"public_key_file",
|
||||
"public_key",
|
||||
"column_break_3",
|
||||
"gstin",
|
||||
"username",
|
||||
@@ -54,12 +55,18 @@
|
||||
"fieldtype": "Password",
|
||||
"label": "Password",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "public_key",
|
||||
"fieldtype": "Long Text",
|
||||
"hidden": 1,
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2020-09-25 21:19:17.159664",
|
||||
"modified": "2020-09-25 21:24:00.404460",
|
||||
"modified_by": "Administrator",
|
||||
"module": "ERPNext Integrations",
|
||||
"name": "E Invoice Settings",
|
||||
|
||||
@@ -3,8 +3,19 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
# import frappe
|
||||
import frappe
|
||||
from frappe.utils import cstr
|
||||
from frappe.model.document import Document
|
||||
|
||||
class EInvoiceSettings(Document):
|
||||
pass
|
||||
def validate(self):
|
||||
pass
|
||||
|
||||
def before_save(self):
|
||||
if not self.public_key or self.has_value_changed('public_key_file'):
|
||||
self.public_key = self.read_key_file()
|
||||
|
||||
def read_key_file(self):
|
||||
key_file = frappe.get_doc('File', dict(attached_to_name=self.doctype, attached_to_field='public_key_file'))
|
||||
with open(key_file.get_full_path(), 'rb') as f:
|
||||
return cstr(f.read())
|
||||
|
||||
Reference in New Issue
Block a user