Merge pull request #17924 from rohitwaghchaure/cost_center_added_in_the_opening_invoice_creation

feat: added cost center in the opening invoice creation tool
This commit is contained in:
rohitwaghchaure 2019-06-13 16:27:18 +05:30 committed by GitHub
commit da0d056a06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 190 additions and 594 deletions

View File

@ -10,6 +10,22 @@ frappe.ui.form.on('Opening Invoice Creation Tool', {
} }
}; };
}); });
frm.set_query('cost_center', 'invoices', function(doc, cdt, cdn) {
return {
filters: {
'company': doc.company
}
};
});
frm.set_query('cost_center', function(doc) {
return {
filters: {
'company': doc.company
}
};
});
}, },
refresh: function(frm) { refresh: function(frm) {
@ -84,6 +100,11 @@ frappe.ui.form.on('Opening Invoice Creation Tool', {
if (!row.temporary_opening_account) { if (!row.temporary_opening_account) {
row.temporary_opening_account = frm.doc.__onload.temporary_opening_account; row.temporary_opening_account = frm.doc.__onload.temporary_opening_account;
} }
if(!row.cost_center) {
row.cost_center = frm.doc.cost_center;
}
row.party_type = frm.doc.invoice_type == "Sales"? "Customer": "Supplier"; row.party_type = frm.doc.invoice_type == "Sales"? "Customer": "Supplier";
}); });
} }

View File

@ -1,244 +1,86 @@
{ {
"allow_copy": 1, "allow_copy": 1,
"allow_guest_to_view": 0, "beta": 1,
"allow_import": 0, "creation": "2017-08-29 02:22:54.947711",
"allow_rename": 0, "doctype": "DocType",
"beta": 1, "editable_grid": 1,
"creation": "2017-08-29 02:22:54.947711", "engine": "InnoDB",
"custom": 0, "field_order": [
"docstatus": 0, "company",
"doctype": "DocType", "create_missing_party",
"document_type": "", "column_break_3",
"editable_grid": 1, "invoice_type",
"engine": "InnoDB", "cost_center",
"section_break_4",
"invoices"
],
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0, "fieldname": "company",
"allow_on_submit": 0, "fieldtype": "Link",
"bold": 0, "in_list_view": 1,
"collapsible": 0, "label": "Company",
"columns": 0, "options": "Company",
"fieldname": "company", "reqd": 1
"fieldtype": "Link", },
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Company",
"length": 0,
"no_copy": 0,
"options": "Company",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "default": "0",
"allow_on_submit": 0, "description": "Create missing customer or supplier.",
"bold": 0, "fieldname": "create_missing_party",
"collapsible": 0, "fieldtype": "Check",
"columns": 0, "label": "Create Missing Party"
"description": "Create missing customer or supplier.", },
"fieldname": "create_missing_party",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Create Missing Party",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "column_break_3",
"allow_on_submit": 0, "fieldtype": "Column Break"
"bold": 0, },
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "invoice_type",
"allow_on_submit": 0, "fieldtype": "Select",
"bold": 0, "in_list_view": 1,
"collapsible": 0, "label": "Invoice Type",
"columns": 0, "options": "Sales\nPurchase",
"fieldname": "invoice_type", "reqd": 1
"fieldtype": "Select", },
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Invoice Type",
"length": 0,
"no_copy": 0,
"options": "Sales\nPurchase",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "section_break_4",
"allow_on_submit": 0, "fieldtype": "Section Break",
"bold": 0, "label": "Invoices"
"collapsible": 0, },
"columns": 0,
"fieldname": "section_break_4",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Invoices",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 1, "allow_bulk_edit": 1,
"allow_on_submit": 0, "fieldname": "invoices",
"bold": 0, "fieldtype": "Table",
"collapsible": 0, "options": "Opening Invoice Creation Tool Item",
"columns": 0, "reqd": 1
"fieldname": "invoices", },
"fieldtype": "Table", {
"hidden": 0, "fieldname": "cost_center",
"ignore_user_permissions": 0, "fieldtype": "Link",
"ignore_xss_filter": 0, "label": "Cost Center",
"in_filter": 0, "options": "Cost Center"
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"options": "Opening Invoice Creation Tool Item",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
} }
], ],
"has_web_view": 0, "hide_toolbar": 1,
"hide_heading": 0, "issingle": 1,
"hide_toolbar": 1, "modified": "2019-06-13 11:45:31.405267",
"idx": 0, "modified_by": "Administrator",
"image_view": 0, "module": "Accounts",
"in_create": 0, "name": "Opening Invoice Creation Tool",
"is_submittable": 0, "owner": "Administrator",
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2018-02-14 17:59:35.269118",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Opening Invoice Creation Tool",
"name_case": "",
"owner": "Administrator",
"permissions": [ "permissions": [
{ {
"amend": 0, "create": 1,
"apply_user_permissions": 0, "email": 1,
"cancel": 0, "print": 1,
"create": 1, "read": 1,
"delete": 0, "role": "System Manager",
"email": 1, "share": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 0,
"role": "System Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1 "write": 1
} }
], ],
"quick_entry": 1, "quick_entry": 1,
"read_only": 0, "sort_field": "modified",
"read_only_onload": 0, "sort_order": "DESC",
"show_name_in_global_search": 0, "track_changes": 1
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
"track_seen": 0
} }

View File

@ -129,7 +129,9 @@ class OpeningInvoiceCreationTool(Document):
def get_invoice_dict(self, row=None): def get_invoice_dict(self, row=None):
def get_item_dict(): def get_item_dict():
default_uom = frappe.db.get_single_value("Stock Settings", "stock_uom") or _("Nos") default_uom = frappe.db.get_single_value("Stock Settings", "stock_uom") or _("Nos")
cost_center = frappe.get_cached_value('Company', self.company, "cost_center") cost_center = row.get('cost_center') or frappe.get_cached_value('Company',
self.company, "cost_center")
if not cost_center: if not cost_center:
frappe.throw( frappe.throw(
_("Please set the Default Cost Center in {0} company.").format(frappe.bold(self.company)) _("Please set the Default Cost Center in {0} company.").format(frappe.bold(self.company))
@ -163,6 +165,7 @@ class OpeningInvoiceCreationTool(Document):
"is_opening": "Yes", "is_opening": "Yes",
"set_posting_time": 1, "set_posting_time": 1,
"company": self.company, "company": self.company,
"cost_center": self.cost_center,
"due_date": row.due_date, "due_date": row.due_date,
"posting_date": row.posting_date, "posting_date": row.posting_date,
frappe.scrub(party_type): row.party, frappe.scrub(party_type): row.party,

View File

@ -1,378 +1,108 @@
{ {
"allow_copy": 0, "creation": "2017-08-29 04:26:36.159247",
"allow_guest_to_view": 0, "doctype": "DocType",
"allow_import": 0, "editable_grid": 1,
"allow_rename": 0, "engine": "InnoDB",
"beta": 0, "field_order": [
"creation": "2017-08-29 04:26:36.159247", "party_type",
"custom": 0, "party",
"docstatus": 0, "temporary_opening_account",
"doctype": "DocType", "column_break_3",
"document_type": "", "posting_date",
"editable_grid": 1, "due_date",
"engine": "InnoDB", "section_break_5",
"item_name",
"outstanding_amount",
"column_break_4",
"qty",
"cost_center"
],
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0, "fieldname": "party_type",
"allow_on_submit": 0, "fieldtype": "Link",
"bold": 0, "hidden": 1,
"collapsible": 0, "label": "Party Type",
"columns": 0, "options": "DocType",
"fieldname": "party_type", "read_only": 1
"fieldtype": "Link", },
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Party Type",
"length": 0,
"no_copy": 0,
"options": "DocType",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "party",
"allow_on_submit": 0, "fieldtype": "Dynamic Link",
"bold": 0, "in_list_view": 1,
"collapsible": 0, "label": "Party",
"columns": 0, "options": "party_type",
"fieldname": "party", "reqd": 1
"fieldtype": "Dynamic Link", },
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Party",
"length": 0,
"no_copy": 0,
"options": "party_type",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "temporary_opening_account",
"allow_on_submit": 0, "fieldtype": "Link",
"bold": 0, "label": "Temporary Opening Account",
"collapsible": 0, "options": "Account"
"columns": 0, },
"fieldname": "temporary_opening_account",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Temporary Opening Account",
"length": 0,
"no_copy": 0,
"options": "Account",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "column_break_3",
"allow_on_submit": 0, "fieldtype": "Column Break"
"bold": 0, },
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "default": "Today",
"allow_on_submit": 0, "fieldname": "posting_date",
"bold": 0, "fieldtype": "Date",
"collapsible": 0, "in_list_view": 1,
"columns": 0, "label": "Posting Date"
"default": "Today", },
"fieldname": "posting_date",
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Posting Date",
"length": 0,
"no_copy": 0,
"options": "",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "default": "Today",
"allow_on_submit": 0, "fieldname": "due_date",
"bold": 0, "fieldtype": "Date",
"collapsible": 0, "in_list_view": 1,
"columns": 0, "label": "Due Date"
"default": "Today", },
"fieldname": "due_date",
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Due Date",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "section_break_5",
"allow_on_submit": 0, "fieldtype": "Section Break"
"bold": 0, },
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_5",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "default": "Opening Invoice Item",
"allow_on_submit": 0, "fieldname": "item_name",
"bold": 0, "fieldtype": "Data",
"collapsible": 0, "in_list_view": 1,
"columns": 0, "label": "Item Name"
"default": "Opening Invoice Item", },
"fieldname": "item_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Item Name",
"length": 0,
"no_copy": 0,
"options": "",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "default": "0",
"allow_on_submit": 0, "fieldname": "outstanding_amount",
"bold": 0, "fieldtype": "Currency",
"collapsible": 0, "in_list_view": 1,
"columns": 0, "label": "Outstanding Amount",
"default": "0", "reqd": 1
"fieldname": "outstanding_amount", },
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Outstanding Amount",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "column_break_4",
"allow_on_submit": 0, "fieldtype": "Column Break"
"bold": 0, },
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_4",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "default": "1",
"allow_on_submit": 0, "fieldname": "qty",
"bold": 0, "fieldtype": "Data",
"collapsible": 0, "label": "Quantity"
"columns": 0, },
"default": "1", {
"fieldname": "qty", "fieldname": "cost_center",
"fieldtype": "Data", "fieldtype": "Link",
"hidden": 0, "label": "Cost Center",
"ignore_user_permissions": 0, "options": "Cost Center"
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Quantity",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
} }
], ],
"has_web_view": 0, "istable": 1,
"hide_heading": 0, "modified": "2019-06-13 11:48:08.324063",
"hide_toolbar": 0, "modified_by": "Administrator",
"idx": 0, "module": "Accounts",
"image_view": 0, "name": "Opening Invoice Creation Tool Item",
"in_create": 0, "owner": "Administrator",
"is_submittable": 0, "permissions": [],
"issingle": 0, "quick_entry": 1,
"istable": 1, "sort_field": "modified",
"max_attachments": 0, "sort_order": "DESC",
"modified": "2017-12-19 05:07:01.549918", "track_changes": 1
"modified_by": "Administrator",
"module": "Accounts",
"name": "Opening Invoice Creation Tool Item",
"name_case": "",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
"track_seen": 0
} }