Merge pull request #5009 from saurabh6790/cart_fixes-1.0
[fixes] return debtors account name
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index 9bfc5be..c2628c9 100755
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -2472,7 +2472,7 @@
"unique": 0
},
{
- "allow_on_submit": 0,
+ "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"depends_on": "eval:doc.is_recurring && doc.recurring_id === doc.name",
@@ -2655,7 +2655,7 @@
"unique": 0
},
{
- "allow_on_submit": 1,
+ "allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"depends_on": "is_recurring",
@@ -2673,7 +2673,7 @@
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,
- "read_only": 1,
+ "read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -2692,7 +2692,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2016-03-16 15:02:51.511069",
+ "modified": "2016-03-18 13:13:43.694604",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice",
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index bbb0cf7..180831e 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -234,8 +234,6 @@
reconcile_against_document(lst)
def on_submit(self):
- super(PurchaseInvoice, self).on_submit()
-
self.check_prev_docstatus()
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index e640ad2..598cfb8 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -3171,7 +3171,7 @@
"unique": 0
},
{
- "allow_on_submit": 0,
+ "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"depends_on": "eval:doc.is_recurring && doc.recurring_id === doc.name",
@@ -3355,7 +3355,7 @@
"unique": 0
},
{
- "allow_on_submit": 1,
+ "allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"depends_on": "is_recurring",
@@ -3373,7 +3373,7 @@
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,
- "read_only": 1,
+ "read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -3418,7 +3418,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2016-03-15 19:02:25.882750",
+ "modified": "2016-03-18 13:12:12.430038",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 5a29424..2d45abe 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -81,8 +81,6 @@
self.update_packing_list()
def on_submit(self):
- super(SalesInvoice, self).on_submit()
-
if cint(self.update_stock) == 1:
self.update_stock_ledger()
else:
@@ -473,7 +471,7 @@
frappe.db.set(self,'paid_amount',0)
frappe.db.set(self, 'base_paid_amount',
- flt(self.paid_amount*self.conversion_rate, self.precision("base_paid_amount")))
+ flt(self.paid_amount*self.conversion_rate, self.precision("base_paid_amount")))
def check_prev_docstatus(self):
for d in self.get('items'):
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json
index 6c2fc79..055f059 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.json
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.json
@@ -2474,7 +2474,7 @@
"unique": 0
},
{
- "allow_on_submit": 0,
+ "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"depends_on": "eval:doc.is_recurring && doc.recurring_id === doc.name",
@@ -2657,7 +2657,7 @@
"unique": 0
},
{
- "allow_on_submit": 1,
+ "allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"depends_on": "is_recurring",
@@ -2675,7 +2675,7 @@
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,
- "read_only": 1,
+ "read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -2693,7 +2693,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-03-16 15:35:21.382861",
+ "modified": "2016-03-18 13:13:07.334625",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order",
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 47b5922..5dd59e8 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -171,8 +171,6 @@
if self.is_against_so():
self.update_status_updater()
- super(PurchaseOrder, self).on_submit()
-
purchase_controller = frappe.get_doc("Purchase Common")
self.update_prevdoc_status()
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index ae225d2..bcaa9fb 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -42,17 +42,14 @@
if self.doctype in ("Sales Invoice", "Purchase Invoice") and not self.is_return:
self.validate_due_date()
- if self.meta.get_field("is_recurring"):
- validate_recurring_document(self)
-
if self.meta.get_field("taxes_and_charges"):
self.validate_enabled_taxes_and_charges()
self.validate_party()
self.validate_currency()
-
- def on_submit(self):
- if self.meta.get_field("is_recurring"):
+
+ if self.meta.get_field("is_recurring") and not self.get("__islocal"):
+ validate_recurring_document(self)
convert_to_recurring(self, self.get("posting_date") or self.get("transaction_date"))
def on_update_after_submit(self):
diff --git a/erpnext/controllers/recurring_document.py b/erpnext/controllers/recurring_document.py
index f83df2b..2df7352 100644
--- a/erpnext/controllers/recurring_document.py
+++ b/erpnext/controllers/recurring_document.py
@@ -72,7 +72,7 @@
frappe.throw(exception_message)
def make_new_document(reference_doc, date_field, posting_date):
- new_document = frappe.copy_doc(reference_doc, ignore_no_copy=True)
+ new_document = frappe.copy_doc(reference_doc, ignore_no_copy=False)
mcount = month_map[reference_doc.recurring_type]
from_date = get_next_date(reference_doc.from_date, mcount)
@@ -89,7 +89,7 @@
date_field: posting_date,
"from_date": from_date,
"to_date": to_date,
- "next_date": get_next_date(from_date, mcount,cint(reference_doc.repeat_on_day_of_month))
+ "next_date": get_next_date(reference_doc.next_date, mcount,cint(reference_doc.repeat_on_day_of_month))
})
# copy document fields
@@ -108,6 +108,7 @@
new_document.run_method("on_recurring", reference_doc=reference_doc)
if reference_doc.submit_on_creation:
+ new_document.insert()
new_document.submit()
else:
new_document.docstatus=0
@@ -160,26 +161,33 @@
def validate_recurring_document(doc):
if doc.is_recurring:
validate_notification_email_id(doc)
-
- if not doc.recurring_id and not doc.is_new():
- doc.recurring_id = doc.name
-
if not doc.recurring_type:
- msgprint(_("Please select {0}").format(doc.meta.get_label("recurring_type")),
- raise_exception=1)
+ frappe.throw(_("Please select {0}").format(doc.meta.get_label("recurring_type")))
elif not (doc.from_date and doc.to_date):
- throw(_("Period From and Period To dates mandatory for recurring {0}").format(doc.doctype))
+ frappe.throw(_("Period From and Period To dates mandatory for recurring {0}").format(doc.doctype))
+
+def validate_recurring_next_date(doc):
+ posting_date = doc.get("posting_date") or doc.get("transaction_date")
+ if getdate(posting_date) > getdate(doc.next_date):
+ frappe.throw(_("Next Date must be greater than Posting Date"))
-#
+ if getdate(doc.next_date).day != doc.repeat_on_day_of_month:
+ frappe.throw(_("Next Date's day and Repeat on Day of Month must be equal"))
+
def convert_to_recurring(doc, posting_date):
- if doc.is_recurring:
- set_next_date(doc, posting_date)
+ if doc.is_recurring:
+ if not doc.recurring_id:
+ doc.db_set("recurring_id", doc.name)
- elif doc.recurring_id:
- frappe.db.sql("""update `tab%s` set is_recurring = 0
- where recurring_id = %s""" % (doc.doctype, '%s'), (doc.recurring_id))
-#
+ set_next_date(doc, posting_date)
+
+ elif doc.recurring_id:
+ frappe.db.sql("""update `tab%s` set is_recurring = 0
+ where recurring_id = %s""" % (doc.doctype, '%s'), (doc.recurring_id))
+
+ if doc.next_date:
+ validate_recurring_next_date(doc)
def validate_notification_email_id(doc):
if doc.notify_by_email:
@@ -198,13 +206,12 @@
def set_next_date(doc, posting_date):
""" Set next date on which recurring document will be created"""
-
if not doc.repeat_on_day_of_month:
msgprint(_("Please enter 'Repeat on Day of Month' field value"), raise_exception=1)
- next_date = doc.next_date or get_next_date(doc.from_date, month_map[doc.recurring_type],
+ next_date = get_next_date(posting_date, month_map[doc.recurring_type],
cint(doc.repeat_on_day_of_month))
- frappe.db.set(doc, 'next_date', next_date)
+ doc.db_set('next_date', next_date)
msgprint(_("Next Recurring {0} will be created on {1}").format(doc.doctype, next_date))
diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json
index e6e0cd2..a9d4e29 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.json
+++ b/erpnext/selling/doctype/sales_order/sales_order.json
@@ -2799,7 +2799,7 @@
"unique": 0
},
{
- "allow_on_submit": 0,
+ "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"depends_on": "eval:doc.is_recurring && doc.recurring_id === doc.name",
@@ -2935,32 +2935,6 @@
"collapsible": 0,
"depends_on": "is_recurring",
"description": "",
- "fieldname": "to_date",
- "fieldtype": "Date",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "To Date",
- "length": 0,
- "no_copy": 1,
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 1,
- "bold": 0,
- "collapsible": 0,
- "depends_on": "is_recurring",
- "description": "",
"fieldname": "from_date",
"fieldtype": "Date",
"hidden": 0,
@@ -2987,6 +2961,32 @@
"collapsible": 0,
"depends_on": "is_recurring",
"description": "",
+ "fieldname": "to_date",
+ "fieldtype": "Date",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "To Date",
+ "length": 0,
+ "no_copy": 1,
+ "permlevel": 0,
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "depends_on": "is_recurring",
+ "description": "",
"fieldname": "next_date",
"fieldtype": "Date",
"hidden": 0,
@@ -3000,7 +3000,7 @@
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,
- "read_only": 1,
+ "read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -3018,7 +3018,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-03-14 18:36:19.317513",
+ "modified": "2016-03-18 13:11:32.654873",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order",
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 2aff7c5..529c17c 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -150,8 +150,6 @@
frappe.throw(_("Row #{0}: Set Supplier for item {1}").format(d.idx, d.item_code))
def on_submit(self):
- super(SalesOrder, self).on_submit()
-
self.check_credit_limit()
self.update_reserved_qty()