Frappe | 1dfb5eb | 2021-07-14 12:33:45 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | |
Anuja Pawar | b37ff0d | 2021-07-14 15:06:56 +0530 | [diff] [blame] | 6 | # import frappe, os, json |
Anuja | 5dcd5e4 | 2021-07-29 00:54:48 +0530 | [diff] [blame] | 7 | from frappe.custom.doctype.custom_field.custom_field import create_custom_fields |
Frappe | 1dfb5eb | 2021-07-14 12:33:45 +0530 | [diff] [blame] | 8 | from frappe.permissions import add_permission, update_permission_property |
| 9 | |
Anuja Pawar | abc63cf | 2021-07-26 18:11:38 +0530 | [diff] [blame] | 10 | def setup(company=None, patch=True): |
Frappe | 1dfb5eb | 2021-07-14 12:33:45 +0530 | [diff] [blame] | 11 | add_permissions() |
| 12 | |
Anuja | 5dcd5e4 | 2021-07-29 00:54:48 +0530 | [diff] [blame] | 13 | def make_custom_fields(update=True): |
| 14 | is_zero_rated = dict(fieldname='is_zero_rated', label='Is Zero Rated', |
| 15 | fieldtype='Check', fetch_from='item_code.is_zero_rated', |
| 16 | insert_after='description', print_hide=1) |
| 17 | custom_fields = { |
| 18 | 'Item': [ |
| 19 | dict(fieldname='is_zero_rated', label='Is Zero Rated', |
| 20 | fieldtype='Check', insert_after='item_group', |
| 21 | print_hide=1) |
| 22 | ], |
| 23 | 'Sales Invoice Item': is_zero_rated, |
| 24 | 'Purchase Invoice Item': is_zero_rated |
| 25 | } |
| 26 | |
| 27 | create_custom_fields(custom_fields, update=update) |
| 28 | |
Frappe | 1dfb5eb | 2021-07-14 12:33:45 +0530 | [diff] [blame] | 29 | def add_permissions(): |
| 30 | """Add Permissions for South Africa VAT Settings and South Africa VAT Account""" |
| 31 | for doctype in ('South Africa VAT Settings', 'South Africa VAT Account'): |
| 32 | add_permission(doctype, 'All', 0) |
| 33 | for role in ('Accounts Manager', 'Accounts User', 'System Manager'): |
| 34 | add_permission(doctype, role, 0) |
| 35 | update_permission_property(doctype, role, 0, 'write', 1) |
| 36 | update_permission_property(doctype, role, 0, 'create', 1) |