Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2026, Enfono and contributors
// For license information, please see license.txt

// frappe.ui.form.on("Branch Configuration", {
// refresh(frm) {

// },
// });
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

{
"actions": [],
"allow_rename": 1,
"autoname": "field:branch",
"naming_rule": "By fieldname",
"creation": "2026-03-05 12:22:51.812112",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"branch",
"section_break_tzxx",
"warehouse",
"cost_center",
"user"
],
"fields": [
{
"fieldname": "branch",
"fieldtype": "Link",
"label": "Branch",
"options": "Branch",
"reqd": 1,
"in_list_view": 1
},
{
"fieldname": "section_break_tzxx",
"fieldtype": "Section Break"
},
{
"fieldname": "warehouse",
"fieldtype": "Table",
"label": "Warehouse",
"options": "Branch Configuration Warehouse"
},
{
"fieldname": "cost_center",
"fieldtype": "Table",
"label": "Cost Center",
"options": "Branch Configuration Cost Center"
},
{
"fieldname": "user",
"fieldtype": "Table",
"label": "User",
"options": "Branch Configuration User"
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2026-03-05 12:26:24.845956",
"modified_by": "Administrator",
"module": "Rmax Custom",
"name": "Branch Configuration",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"row_format": "Dynamic",
"rows_threshold_for_grid_search": 20,
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#user permissions are created for branch, warehouse and cost center.

import frappe
from frappe.model.document import Document


class BranchConfiguration(Document):

def before_save(self):

if self.is_new():
return

old_doc = self.get_doc_before_save()

old_users = {d.user for d in old_doc.user}
new_users = {d.user for d in self.user}

removed_users = old_users - new_users

for user in removed_users:

delete_permission(user, "Branch", old_doc.branch)

for w in old_doc.warehouse:
delete_permission(user, "Warehouse", w.warehouse)

for c in old_doc.cost_center:
delete_permission(user, "Cost Center", c.cost_center)

def on_update(self):
self.create_permissions()

def create_permissions(self):

for u in self.user:

create_permission(u.user, "Branch", self.branch)

for w in self.warehouse:
create_permission(u.user, "Warehouse", w.warehouse)

for c in self.cost_center:
create_permission(u.user, "Cost Center", c.cost_center)

def create_permission(user, allow, value):

if not value:
return

if not frappe.db.exists("User Permission", {
"user": user,
"allow": allow,
"for_value": value
}):

doc = frappe.new_doc("User Permission")
doc.user = user
doc.allow = allow
doc.for_value = value
doc.apply_to_all_doctypes = 1
doc.insert(ignore_permissions=True)


def delete_permission(user, allow, value):

if not value:
return

perms = frappe.get_all(
"User Permission",
filters={
"user": user,
"allow": allow,
"for_value": value
},
pluck="name"
)

for p in perms:
frappe.delete_doc("User Permission", p, ignore_permissions=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2026, Enfono and Contributors
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase


class TestBranchConfiguration(FrappeTestCase):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2026-03-05 12:19:10.865575",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"cost_center"
],
"fields": [
{
"fieldname": "cost_center",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Cost Center",
"options": "Cost Center"
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2026-03-05 12:21:00.361306",
"modified_by": "Administrator",
"module": "Rmax Custom",
"name": "Branch Configuration Cost Center",
"owner": "Administrator",
"permissions": [],
"row_format": "Dynamic",
"rows_threshold_for_grid_search": 20,
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2026, Enfono and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class BranchConfigurationCostCenter(Document):
pass
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2026-03-05 12:20:16.705104",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"user"
],
"fields": [
{
"fieldname": "user",
"fieldtype": "Link",
"in_list_view": 1,
"label": "User",
"options": "User"
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2026-03-05 12:20:44.460491",
"modified_by": "Administrator",
"module": "Rmax Custom",
"name": "Branch Configuration User",
"owner": "Administrator",
"permissions": [],
"row_format": "Dynamic",
"rows_threshold_for_grid_search": 20,
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2026, Enfono and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class BranchConfigurationUser(Document):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2026-03-05 12:17:55.385600",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"warehouse"
],
"fields": [
{
"fieldname": "warehouse",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Warehouse",
"options": "Warehouse"
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2026-03-05 12:21:12.868254",
"modified_by": "Administrator",
"module": "Rmax Custom",
"name": "Branch Configuration Warehouse",
"owner": "Administrator",
"permissions": [],
"row_format": "Dynamic",
"rows_threshold_for_grid_search": 20,
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2026, Enfono and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class BranchConfigurationWarehouse(Document):
pass
Loading