set the mandatory field in the backend (#12102)

This commit is contained in:
Manas Solanki 2017-12-20 12:03:19 +05:30 committed by Nabin Hait
parent c8ecfa15f3
commit 8413f76c19
2 changed files with 16 additions and 9 deletions

View File

@ -5,7 +5,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _, scrub
from frappe.utils import flt
from frappe.utils import flt, nowdate
from frappe.model.document import Document
@ -69,11 +69,18 @@ class OpeningInvoiceCreationTool(Document):
if not row.qty:
row.qty = 1.0
# set party type if not available
if not row.party_type:
row.party_type = "Customer" if self.invoice_type == "Sales" else "Supplier"
# always mandatory fields for the invoices
if not row.temporary_opening_account:
row.temporary_opening_account = get_temporary_opening_account(self.company)
row.party_type = "Customer" if self.invoice_type == "Sales" else "Supplier"
if not row.item_name:
row.item_name = _("Opening Invoice Item")
if not row.posting_date:
row.posting_date = nowdate()
if not row.due_date:
row.due_date = nowdate()
for d in ("Party", "Posting Date", "Outstanding Amount", "Due Date", "Temporary Opening Account"):
for d in ("Party", "Outstanding Amount", "Temporary Opening Account"):
if not row.get(scrub(d)):
frappe.throw(mandatory_error_msg.format(
idx=row.idx,

View File

@ -161,7 +161,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
@ -192,7 +192,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
@ -284,7 +284,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
@ -360,7 +360,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-12-11 17:49:14.541176",
"modified": "2017-12-19 05:07:01.549918",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Opening Invoice Creation Tool Item",