Merge branch 'develop' into prateekkaramchandani/develop

This commit is contained in:
Ankush Menat
2023-03-14 18:39:06 +05:30
150 changed files with 6941 additions and 6349 deletions

View File

@@ -8,7 +8,6 @@ from frappe.permissions import (
get_doc_permissions,
has_permission,
remove_user_permission,
set_user_permission_if_allowed,
)
from frappe.utils import cstr, getdate, today, validate_email_address
from frappe.utils.nestedset import NestedSet
@@ -96,7 +95,7 @@ class Employee(NestedSet):
return
add_user_permission("Employee", self.name, self.user_id)
set_user_permission_if_allowed("Company", self.company, self.user_id)
add_user_permission("Company", self.company, self.user_id)
def update_user(self):
# add employee role if missing

View File

@@ -3,13 +3,17 @@
import frappe
from frappe import _
from frappe import _, qb
from frappe.desk.notifications import clear_notifications
from frappe.model.document import Document
from frappe.utils import cint
from frappe.utils import cint, create_batch
class TransactionDeletionRecord(Document):
def __init__(self, *args, **kwargs):
super(TransactionDeletionRecord, self).__init__(*args, **kwargs)
self.batch_size = 5000
def validate(self):
frappe.only_for("System Manager")
self.validate_doctypes_to_be_ignored()
@@ -155,8 +159,9 @@ class TransactionDeletionRecord(Document):
"DocField", filters={"fieldtype": "Table", "parent": doctype}, pluck="options"
)
for table in child_tables:
frappe.db.delete(table, {"parent": ["in", parent_docs_to_be_deleted]})
for batch in create_batch(parent_docs_to_be_deleted, self.batch_size):
for table in child_tables:
frappe.db.delete(table, {"parent": ["in", batch]})
def delete_docs_linked_with_specified_company(self, doctype, company_fieldname):
frappe.db.delete(doctype, {company_fieldname: self.company})
@@ -181,13 +186,16 @@ class TransactionDeletionRecord(Document):
frappe.db.sql("""update `tabSeries` set current = %s where name=%s""", (last, prefix))
def delete_version_log(self, doctype, company_fieldname):
frappe.db.sql(
"""delete from `tabVersion` where ref_doctype=%s and docname in
(select name from `tab{0}` where `{1}`=%s)""".format(
doctype, company_fieldname
),
(doctype, self.company),
)
dt = qb.DocType(doctype)
names = qb.from_(dt).select(dt.name).where(dt[company_fieldname] == self.company).run(as_list=1)
names = [x[0] for x in names]
if names:
versions = qb.DocType("Version")
for batch in create_batch(names, self.batch_size):
qb.from_(versions).delete().where(
(versions.ref_doctype == doctype) & (versions.docname.isin(batch))
).run()
def delete_communications(self, doctype, company_fieldname):
reference_docs = frappe.get_all(doctype, filters={company_fieldname: self.company})
@@ -199,7 +207,8 @@ class TransactionDeletionRecord(Document):
)
communication_names = [c.name for c in communications]
frappe.delete_doc("Communication", communication_names, ignore_permissions=True)
for batch in create_batch(communication_names, self.batch_size):
frappe.delete_doc("Communication", batch, ignore_permissions=True)
@frappe.whitelist()

View File

@@ -4015,34 +4015,6 @@
"tax_rate": 18.00
}
},
"Saudi Arabia": {
"KSA VAT 15%": {
"account_name": "VAT 15%",
"tax_rate": 15.00
},
"KSA VAT 5%": {
"account_name": "VAT 5%",
"tax_rate": 5.00
},
"KSA VAT Zero": {
"account_name": "VAT Zero",
"tax_rate": 0.00
},
"KSA VAT Exempted": {
"account_name": "VAT Exempted",
"tax_rate": 0.00
},
"KSA Excise 50%": {
"account_name": "Excise 50%",
"tax_rate": 50.00
},
"KSA Excise 100%": {
"account_name": "Excise 100%",
"tax_rate": 100.00
}
},
"Serbia": {
"Serbia Tax": {
"account_name": "VAT",