chore: remove unwanted fields

This commit is contained in:
Saqib Ansari
2020-11-04 11:19:50 +05:30
parent 86f87e9b53
commit 54405a4b64
2 changed files with 9 additions and 42 deletions

View File

@@ -9,13 +9,11 @@
"section_break_2",
"client_id",
"client_secret",
"public_key_file",
"public_key",
"column_break_3",
"gstin",
"username",
"password",
"auto_refresh_token",
"auth_token",
"token_expiry",
"sek"
@@ -45,12 +43,6 @@
"label": "Client Secret",
"reqd": 1
},
{
"fieldname": "public_key_file",
"fieldtype": "Attach",
"label": "Public Key",
"reqd": 1
},
{
"fieldname": "public_key",
"fieldtype": "Long Text",
@@ -79,36 +71,30 @@
"label": "Password",
"reqd": 1
},
{
"default": "0",
"description": "Token will be automatically refreshed 10 mins before expiry",
"fieldname": "auto_refresh_token",
"fieldtype": "Check",
"label": "Auto Refresh Token"
},
{
"fieldname": "auth_token",
"fieldtype": "Data",
"hidden": 1,
"read_only": 1
},
{
"fieldname": "token_expiry",
"fieldtype": "Datetime",
"hidden": 1,
"read_only": 1
},
{
"fieldname": "sek",
"fieldtype": "Data",
"hidden": 1,
"read_only": 1
},
{
"default": "0",
"fieldname": "token_expiry",
"fieldtype": "Datetime",
"hidden": 1,
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2020-10-23 19:55:11.417161",
"modified": "2020-11-03 21:23:50.277305",
"modified_by": "Administrator",
"module": "Regional",
"name": "E Invoice Settings",

View File

@@ -3,26 +3,7 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils.data import cstr
from frappe.model.document import Document
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
class EInvoiceSettings(Document):
def validate(self):
mandatory_fields = ['client_id', 'client_secret', 'gstin', 'username', 'password', 'public_key_file']
for d in mandatory_fields:
if not self.get(d):
frappe.throw(_("{} is required").format(frappe.unscrub(d)), title=_("Missing Values"))
def before_save(self):
previous = self.get_doc_before_save()
public_file_changed = previous.get('public_key_file') != self.get('public_key_file') if previous else True
if not self.public_key or public_file_changed:
self.public_key = self.read_key_file()
def read_key_file(self):
key_file = frappe.get_doc('File', dict(attached_to_name=self.doctype))
with open(key_file.get_full_path(), 'rb') as f:
return cstr(f.read())
pass