mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 19:49:18 +00:00
feat: read public key file
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
"client_id",
|
"client_id",
|
||||||
"client_secret",
|
"client_secret",
|
||||||
"public_key_file",
|
"public_key_file",
|
||||||
|
"public_key",
|
||||||
"column_break_3",
|
"column_break_3",
|
||||||
"gstin",
|
"gstin",
|
||||||
"username",
|
"username",
|
||||||
@@ -54,12 +55,18 @@
|
|||||||
"fieldtype": "Password",
|
"fieldtype": "Password",
|
||||||
"label": "Password",
|
"label": "Password",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "public_key",
|
||||||
|
"fieldtype": "Long Text",
|
||||||
|
"hidden": 1,
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-09-25 21:19:17.159664",
|
"modified": "2020-09-25 21:24:00.404460",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "ERPNext Integrations",
|
"module": "ERPNext Integrations",
|
||||||
"name": "E Invoice Settings",
|
"name": "E Invoice Settings",
|
||||||
|
|||||||
@@ -3,8 +3,19 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
# import frappe
|
import frappe
|
||||||
|
from frappe.utils import cstr
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class EInvoiceSettings(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