Merge pull request #21985 from marination/import-italian-invoice-dev
chore: Added Italian Import Supplier Invoice to Desk
diff --git a/erpnext/buying/desk_page/buying/buying.json b/erpnext/buying/desk_page/buying/buying.json
index d31602b..31b26d4 100644
--- a/erpnext/buying/desk_page/buying/buying.json
+++ b/erpnext/buying/desk_page/buying/buying.json
@@ -34,6 +34,11 @@
"hidden": 0,
"label": "Other Reports",
"links": "[\n {\n \"is_query_report\": true,\n \"label\": \"Items To Be Requested\",\n \"name\": \"Items To Be Requested\",\n \"onboard\": 1,\n \"reference_doctype\": \"Item\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Item-wise Purchase History\",\n \"name\": \"Item-wise Purchase History\",\n \"onboard\": 1,\n \"reference_doctype\": \"Item\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Subcontracted Raw Materials To Be Transferred\",\n \"name\": \"Subcontracted Raw Materials To Be Transferred\",\n \"reference_doctype\": \"Purchase Order\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Subcontracted Item To Be Received\",\n \"name\": \"Subcontracted Item To Be Received\",\n \"reference_doctype\": \"Purchase Order\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Quoted Item Comparison\",\n \"name\": \"Quoted Item Comparison\",\n \"onboard\": 1,\n \"reference_doctype\": \"Supplier Quotation\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Material Requests for which Supplier Quotations are not created\",\n \"name\": \"Material Requests for which Supplier Quotations are not created\",\n \"reference_doctype\": \"Material Request\",\n \"type\": \"report\"\n },\n {\n \"is_query_report\": true,\n \"label\": \"Supplier Addresses And Contacts\",\n \"name\": \"Address And Contacts\",\n \"reference_doctype\": \"Address\",\n \"route_options\": {\n \"party_type\": \"Supplier\"\n },\n \"type\": \"report\"\n }\n]"
+ },
+ {
+ "hidden": 0,
+ "label": "Regional",
+ "links": "[\n {\n \"description\": \"Import Italian Purchase Invoices\",\n \"label\": \"Import Supplier Invoice\",\n \"name\": \"Import Supplier Invoice\",\n \"type\": \"doctype\"\n } \n]"
}
],
"cards_label": "Masters & Reports ",
@@ -55,7 +60,7 @@
"idx": 0,
"is_standard": 1,
"label": "Buying",
- "modified": "2020-05-27 19:55:22.407528",
+ "modified": "2020-05-27 22:23:38.529720",
"modified_by": "Administrator",
"module": "Buying",
"name": "Buying",
diff --git a/erpnext/config/buying.py b/erpnext/config/buying.py
index 16b49a1..b06bb76 100644
--- a/erpnext/config/buying.py
+++ b/erpnext/config/buying.py
@@ -1,8 +1,9 @@
from __future__ import unicode_literals
+import frappe
from frappe import _
def get_data():
- return [
+ config = [
{
"label": _("Purchasing"),
"icon": "fa fa-star",
@@ -243,3 +244,21 @@
},
]
+
+ regional = {
+ "label": _("Regional"),
+ "items": [
+ {
+ "type": "doctype",
+ "name": "Import Supplier Invoice",
+ "description": _("Import Italian Supplier Invoice."),
+ "onboard": 1,
+ }
+ ]
+ }
+
+ countries = frappe.get_all("Company", fields="country")
+ countries = [country["country"] for country in countries]
+ if "Italy" in countries:
+ config.append(regional)
+ return config
\ No newline at end of file
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index b0b224f..b0421f4 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -694,3 +694,4 @@
execute:frappe.rename_doc("Desk Page", "Loan Management", "Loan", force=True)
erpnext.patches.v12_0.update_uom_conversion_factor
erpnext.patches.v13_0.delete_old_purchase_reports
+erpnext.patches.v12_0.set_italian_import_supplier_invoice_permissions
\ No newline at end of file
diff --git a/erpnext/patches/v12_0/set_italian_import_supplier_invoice_permissions.py b/erpnext/patches/v12_0/set_italian_import_supplier_invoice_permissions.py
new file mode 100644
index 0000000..a6011c4
--- /dev/null
+++ b/erpnext/patches/v12_0/set_italian_import_supplier_invoice_permissions.py
@@ -0,0 +1,12 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from erpnext.regional.italy.setup import add_permissions
+
+def execute():
+ countries = frappe.get_all("Company", fields="country")
+ countries = [country["country"] for country in countries]
+ if "Italy" in countries:
+ add_permissions()
\ No newline at end of file
diff --git a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json
index 59e955c..c1680c4 100644
--- a/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json
+++ b/erpnext/regional/doctype/import_supplier_invoice/import_supplier_invoice.json
@@ -1,5 +1,4 @@
{
- "actions": [],
"creation": "2019-10-15 12:33:21.845329",
"doctype": "DocType",
"editable_grid": 1,
@@ -92,8 +91,7 @@
"label": "Upload XML Invoices"
}
],
- "links": [],
- "modified": "2019-12-10 16:37:26.793398",
+ "modified": "2020-05-25 21:32:49.064579",
"modified_by": "Administrator",
"module": "Regional",
"name": "Import Supplier Invoice",
diff --git a/erpnext/regional/italy/setup.py b/erpnext/regional/italy/setup.py
index 2d0ad66..6ab7341 100644
--- a/erpnext/regional/italy/setup.py
+++ b/erpnext/regional/italy/setup.py
@@ -7,11 +7,13 @@
import frappe
from frappe import _
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
+from frappe.permissions import add_permission, update_permission_property
from erpnext.regional.italy import fiscal_regimes, tax_exemption_reasons, mode_of_payment_codes, vat_collectability_options
def setup(company=None, patch=True):
make_custom_fields()
setup_report()
+ add_permissions()
def make_custom_fields(update=True):
invoice_item_fields = [
@@ -200,3 +202,21 @@
dict(role='Accounts Manager')
]
)).insert()
+
+def add_permissions():
+ doctype = 'Import Supplier Invoice'
+ add_permission(doctype, 'All', 0)
+
+ for role in ('Accounts Manager', 'Accounts User','Purchase User', 'Auditor'):
+ add_permission(doctype, role, 0)
+ update_permission_property(doctype, role, 0, 'print', 1)
+ update_permission_property(doctype, role, 0, 'report', 1)
+
+ if role in ('Accounts Manager', 'Accounts User'):
+ update_permission_property(doctype, role, 0, 'write', 1)
+ update_permission_property(doctype, role, 0, 'create', 1)
+
+ update_permission_property(doctype, 'Accounts Manager', 0, 'delete', 1)
+ add_permission(doctype, 'Accounts Manager', 1)
+ update_permission_property(doctype, 'Accounts Manager', 1, 'write', 1)
+ update_permission_property(doctype, 'Accounts Manager', 1, 'create', 1)
\ No newline at end of file