[fix] Validate Party in not present in Party Type (#12910)
* [fix] Validate Party in not present in Party Type * [fix] Minor Changes * [fix] Valid Customer and Supplier fetch * [WIP] Allow and prevent for creating party * [fix] minor changes * [fix] Requested Changes * [fix] Codacy issue * Update opening_invoice_creation_tool.py
This commit is contained in:
parent
3a9eec2e92
commit
1e0ae07bff
@ -43,6 +43,66 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"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,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"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,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -145,7 +205,7 @@
|
|||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-09-05 01:30:33.235664",
|
"modified": "2018-02-14 17:59:35.269118",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Opening Invoice Creation Tool",
|
"name": "Opening Invoice Creation Tool",
|
||||||
|
@ -73,6 +73,14 @@ class OpeningInvoiceCreationTool(Document):
|
|||||||
if not row.temporary_opening_account:
|
if not row.temporary_opening_account:
|
||||||
row.temporary_opening_account = get_temporary_opening_account(self.company)
|
row.temporary_opening_account = get_temporary_opening_account(self.company)
|
||||||
row.party_type = "Customer" if self.invoice_type == "Sales" else "Supplier"
|
row.party_type = "Customer" if self.invoice_type == "Sales" else "Supplier"
|
||||||
|
|
||||||
|
# Allow to create invoice even if no party present in customer or supplier.
|
||||||
|
if not frappe.db.exists(row.party_type, row.party):
|
||||||
|
if self.create_missing_party:
|
||||||
|
self.add_party(row.party_type, row.party)
|
||||||
|
else:
|
||||||
|
frappe.throw(_("{0} {1} does not exist.").format(frappe.bold(row.party_type), frappe.bold(row.party)))
|
||||||
|
|
||||||
if not row.item_name:
|
if not row.item_name:
|
||||||
row.item_name = _("Opening Invoice Item")
|
row.item_name = _("Opening Invoice Item")
|
||||||
if not row.posting_date:
|
if not row.posting_date:
|
||||||
@ -107,13 +115,28 @@ class OpeningInvoiceCreationTool(Document):
|
|||||||
|
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
def add_party(self, party_type, party):
|
||||||
|
party_doc = frappe.new_doc(party_type)
|
||||||
|
if party_type == "Customer":
|
||||||
|
party_doc.customer_name = party
|
||||||
|
else:
|
||||||
|
supplier_type = frappe.db.get_single_value("Buying Settings", "supplier_type")
|
||||||
|
if not supplier_type:
|
||||||
|
frappe.throw(_("Please Set Supplier Type in Buying Settings."))
|
||||||
|
|
||||||
|
party_doc.supplier_name = party
|
||||||
|
party_doc.supplier_type = supplier_type
|
||||||
|
|
||||||
|
party_doc.flags.ignore_mandatory = True
|
||||||
|
party_doc.save(ignore_permissions=True)
|
||||||
|
|
||||||
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.db.get_value("Company", self.company, "cost_center")
|
cost_center = frappe.db.get_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))
|
||||||
)
|
)
|
||||||
rate = flt(row.outstanding_amount) / flt(row.qty)
|
rate = flt(row.outstanding_amount) / flt(row.qty)
|
||||||
|
|
||||||
@ -163,3 +186,5 @@ def get_temporary_opening_account(company=None):
|
|||||||
frappe.throw(_("Please add a Temporary Opening account in Chart of Accounts"))
|
frappe.throw(_("Please add a Temporary Opening account in Chart of Accounts"))
|
||||||
|
|
||||||
return accounts[0].name
|
return accounts[0].name
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user