mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-12 14:58:24 +00:00
chore: remove unwanted fields
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user