Fix minor errors, fix patch, call in hooks, move from account_controller to recurring_document
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 5228b0e..73832ce 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -228,7 +228,7 @@
par_flds = ['project_name', 'due_date', 'is_opening', 'source', 'total_advance', 'gross_profit',
'gross_profit_percent', 'get_advances_received',
'advance_adjustment_details', 'sales_partner', 'commission_rate',
- 'total_commission', 'advances', 'period_from', 'period_to'];
+ 'total_commission', 'advances', 'from_date', 'to_date'];
item_flds_normal = ['sales_order', 'delivery_note']
@@ -399,9 +399,9 @@
})
}
-cur_frm.cscript.convert_into_recurring_invoice = function(doc, dt, dn) {
+cur_frm.cscript.is_recurring = function(doc, dt, dn) {
// set default values for recurring invoices
- if(doc.convert_into_recurring_invoice) {
+ if(doc.is_recurring) {
var owner_email = doc.owner=="Administrator"
? frappe.user_info("Administrator").email
: doc.owner;
@@ -414,18 +414,18 @@
refresh_many(["notification_email_address", "repeat_on_day_of_month"]);
}
-cur_frm.cscript.period_from = function(doc, dt, dn) {
- // set period_to
- if(doc.period_from) {
+cur_frm.cscript.from_date = function(doc, dt, dn) {
+ // set to_date
+ if(doc.from_date) {
var recurring_type_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6,
'Yearly': 12};
var months = recurring_type_map[doc.recurring_type];
if(months) {
- var to_date = frappe.datetime.add_months(doc.period_from,
+ var to_date = frappe.datetime.add_months(doc.from_date,
months);
- doc.period_to = frappe.datetime.add_days(to_date, -1);
- refresh_field('period_to');
+ doc.to_date = frappe.datetime.add_days(to_date, -1);
+ refresh_field('to_date');
}
}
}
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 7cab4c2..c26583b 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -173,9 +173,9 @@
"allow_on_submit": 1,
"depends_on": "",
"description": "Start date of current invoice's period",
- "fieldname": "period_from",
+ "fieldname": "from_date",
"fieldtype": "Date",
- "label": "Invoice Period From",
+ "label": "From",
"no_copy": 1,
"permlevel": 0,
"print_hide": 0,
@@ -185,9 +185,9 @@
"allow_on_submit": 1,
"depends_on": "",
"description": "End date of current invoice's period",
- "fieldname": "period_to",
+ "fieldname": "to_date",
"fieldtype": "Date",
- "label": "Invoice Period To",
+ "label": "To",
"no_copy": 1,
"permlevel": 0,
"print_hide": 0,
@@ -1088,9 +1088,9 @@
"allow_on_submit": 1,
"depends_on": "eval:doc.docstatus<2",
"description": "Check if recurring invoice, uncheck to stop recurring or put proper End Date",
- "fieldname": "convert_into_recurring",
+ "fieldname": "is_recurring",
"fieldtype": "Check",
- "label": "Convert into Recurring Invoice",
+ "label": "Is Recurring",
"no_copy": 1,
"permlevel": 0,
"print_hide": 1,
@@ -1098,7 +1098,7 @@
},
{
"allow_on_submit": 1,
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"description": "Select the period when the invoice will be generated automatically",
"fieldname": "recurring_type",
"fieldtype": "Select",
@@ -1111,7 +1111,7 @@
},
{
"allow_on_submit": 1,
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"description": "The day of the month on which auto invoice will be generated e.g. 05, 28 etc ",
"fieldname": "repeat_on_day_of_month",
"fieldtype": "Int",
@@ -1122,7 +1122,7 @@
"read_only": 0
},
{
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"description": "The date on which next invoice will be generated. It is generated on submit.\n",
"fieldname": "next_date",
"fieldtype": "Date",
@@ -1134,7 +1134,7 @@
},
{
"allow_on_submit": 1,
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"description": "The date on which recurring invoice will be stop",
"fieldname": "end_date",
"fieldtype": "Date",
@@ -1154,7 +1154,7 @@
"width": "50%"
},
{
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"description": "The unique id for tracking all recurring invoices.\u00a0It is generated on submit.",
"fieldname": "recurring_id",
"fieldtype": "Data",
@@ -1166,7 +1166,7 @@
},
{
"allow_on_submit": 1,
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"description": "Enter email id separated by commas, invoice will be mailed automatically on particular date",
"fieldname": "notification_email_address",
"fieldtype": "Small Text",
@@ -1193,7 +1193,7 @@
"icon": "icon-file-text",
"idx": 1,
"is_submittable": 1,
- "modified": "2014-08-25 17:41:35.367233",
+ "modified": "2014-08-28 11:21:00.726344",
"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 fc72562..a20d906 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -14,7 +14,7 @@
from erpnext.controllers.stock_controller import update_gl_entries_after
from frappe.model.mapper import get_mapped_doc
-month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
+from erpnext.controllers.recurring_document import *
from erpnext.controllers.selling_controller import SellingController
@@ -75,7 +75,7 @@
self.set_against_income_account()
self.validate_c_form()
self.validate_time_logs_are_submitted()
- self.validate_recurring_document()
+ validate_recurring_document(self)
self.validate_multiple_billing("Delivery Note", "dn_detail", "amount",
"delivery_note_details")
@@ -103,7 +103,7 @@
self.update_c_form()
self.update_time_log_batch(self.name)
- self.convert_to_recurring("RECINV.#####", self.posting_date)
+ convert_to_recurring(self, "RECINV.#####", self.posting_date)
def before_cancel(self):
self.update_time_log_batch(None)
@@ -144,8 +144,8 @@
})
def on_update_after_submit(self):
- self.validate_recurring_document()
- self.convert_to_recurring("RECINV.#####", self.posting_date)
+ validate_recurring_document(self)
+ convert_to_recurring(self, "RECINV.#####", self.posting_date)
def get_portal_page(self):
return "invoice" if self.docstatus==1 else None
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 4a23673..4af9f5e 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -430,30 +430,6 @@
return stock_items
- def validate_recurring_document(self):
- if self.convert_into_recurring:
- self.validate_notification_email_id()
-
- if not self.recurring_type:
- msgprint(_("Please select {0}").format(self.meta.get_label("recurring_type")),
- raise_exception=1)
-
- elif not (self.period_from and self.period_to):
- throw(_("Period From and Period To dates mandatory for recurring %s") % self.doctype)
-
- def convert_to_recurring(self, autoname, posting_date):
- if self.convert_into_recurring:
- if not self.recurring_id:
- frappe.db.set(self, "recurring_id",
- make_autoname(autoname))
-
- self.set_next_date(posting_date)
-
- elif self.recurring_id:
- frappe.db.sql("""update `tab%s`
- set convert_into_recurring = 0
- where recurring_id = %s""" % (self.doctype, '%s'), (self.recurring_id))
-
@property
def company_abbr(self):
if not hasattr(self, "_abbr"):
@@ -470,36 +446,6 @@
if total_outstanding:
frappe.get_doc('Account', account).check_credit_limit(total_outstanding)
- def validate_notification_email_id(self):
- if self.notification_email_address:
- email_list = filter(None, [cstr(email).strip() for email in
- self.notification_email_address.replace("\n", "").split(",")])
-
- from frappe.utils import validate_email_add
- for email in email_list:
- if not validate_email_add(email):
- throw(_("{0} is an invalid email address in 'Notification \
- Email Address'").format(email))
-
- else:
- frappe.throw(_("'Notification Email Addresses' not specified for recurring %s") \
- % self.doctype)
-
- def set_next_date(self, posting_date):
- """ Set next date on which recurring document will be created"""
- from erpnext.controllers.recurring_document import get_next_date
-
- month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
-
- if not self.repeat_on_day_of_month:
- msgprint(_("Please enter 'Repeat on Day of Month' field value"), raise_exception=1)
-
- next_date = get_next_date(posting_date, month_map[self.recurring_type],
- cint(self.repeat_on_day_of_month))
-
- frappe.db.set(self, 'next_date', next_date)
-
-
@frappe.whitelist()
def get_tax_rate(account_head):
return frappe.db.get_value("Account", account_head, "tax_rate")
diff --git a/erpnext/controllers/recurring_document.py b/erpnext/controllers/recurring_document.py
index d3c7809..d932679 100644
--- a/erpnext/controllers/recurring_document.py
+++ b/erpnext/controllers/recurring_document.py
@@ -13,6 +13,10 @@
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
+def create_recurring_documents():
+ manage_recurring_documents("Sales Order")
+ manage_recurring_documents("Sales Invoice")
+
def manage_recurring_documents(doctype, next_date=None, commit=True):
"""
Create recurring documents on specific date by copying the original one
@@ -26,9 +30,9 @@
date_field = "posting_date"
recurring_documents = frappe.db.sql("""select name, recurring_id
- from `tab%s` where ifnull(convert_into_recurring, 0)=1
- and docstatus=1 and next_date=%s
- and next_date <= ifnull(end_date, '2199-12-31')""" % (doctype, '%s'), (next_date))
+ from `tab{}` where ifnull(is_recurring, 0)=1
+ and docstatus=1 and next_date='{}'
+ and next_date <= ifnull(end_date, '2199-12-31')""".format(doctype, next_date))
exception_list = []
for ref_document, recurring_id in recurring_documents:
@@ -47,7 +51,7 @@
frappe.db.begin()
frappe.db.sql("update `tab%s` \
- set convert_into_recurring = 0 where name = %s" % (doctype, '%s'),
+ set is_recurring = 0 where name = %s" % (doctype, '%s'),
(ref_document))
notify_errors(ref_document, doctype, ref_wrapper.customer, ref_wrapper.owner)
frappe.db.commit()
@@ -66,23 +70,23 @@
new_document = frappe.copy_doc(ref_wrapper)
mcount = month_map[ref_wrapper.recurring_type]
- period_from = get_next_date(ref_wrapper.period_from, mcount)
+ from_date = get_next_date(ref_wrapper.from_date, mcount)
# get last day of the month to maintain period if the from date is first day of its own month
# and to date is the last day of its own month
- if (cstr(get_first_day(ref_wrapper.period_from)) == \
- cstr(ref_wrapper.period_from)) and \
- (cstr(get_last_day(ref_wrapper.period_to)) == \
- cstr(ref_wrapper.period_to)):
- period_to = get_last_day(get_next_date(ref_wrapper.period_to,
+ if (cstr(get_first_day(ref_wrapper.from_date)) == \
+ cstr(ref_wrapper.from_date)) and \
+ (cstr(get_last_day(ref_wrapper.to_date)) == \
+ cstr(ref_wrapper.to_date)):
+ to_date = get_last_day(get_next_date(ref_wrapper.to_date,
mcount))
else:
- period_to = get_next_date(ref_wrapper.period_to, mcount)
+ to_date = get_next_date(ref_wrapper.to_date, mcount)
new_document.update({
date_field: posting_date,
- "period_from": period_from,
- "period_to": period_to,
+ "from_date": from_date,
+ "to_date": to_date,
"fiscal_year": get_fiscal_year(posting_date)[0],
"owner": ref_wrapper.owner,
})
@@ -112,7 +116,7 @@
message = _("Please find attached {0} #{1}").format(new_rv.doctype, new_rv.name),
attachments = [{
"fname": new_rv.name + ".pdf",
- "fcontent": frappe.get_print_format(new_rv.doctype, new_rv.name, as_pdf=True)
+ "fcontent": frappe.get_print_format(new_rv.doctype, new_rv.name, as_pdf=True).encode('utf-8')
}])
def notify_errors(doc, doctype, customer, owner):
@@ -121,7 +125,7 @@
frappe.sendmail(recipients + [frappe.db.get_value("User", owner, "email")],
subject="[Urgent] Error while creating recurring %s for %s" % (doctype, doc),
- message = frappe.get_template("templates/emails/recurring_sales_invoice_failed.html").render({
+ message = frappe.get_template("templates/emails/recurring_document_failed.html").render({
"type": doctype,
"name": doc,
"customer": customer
@@ -139,4 +143,55 @@
'description' : msg,
'priority' : 'High'
}
- assign_to.add(args)
\ No newline at end of file
+ assign_to.add(args)
+
+def validate_recurring_document(doc):
+ if doc.is_recurring:
+ validate_notification_email_id(doc)
+
+ if not doc.recurring_type:
+ msgprint(_("Please select {0}").format(doc.meta.get_label("recurring_type")),
+ raise_exception=1)
+
+ elif not (doc.from_date and doc.to_date):
+ throw(_("Period From and Period To dates mandatory for recurring %s") % doc.doctype)
+
+def convert_to_recurring(doc, autoname, posting_date):
+ if doc.is_recurring:
+ if not doc.recurring_id:
+ frappe.db.set(doc, "recurring_id",
+ make_autoname(autoname))
+
+ 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))
+
+def validate_notification_email_id(doc):
+ if doc.notification_email_address:
+ email_list = filter(None, [cstr(email).strip() for email in
+ doc.notification_email_address.replace("\n", "").split(",")])
+
+ from frappe.utils import validate_email_add
+ for email in email_list:
+ if not validate_email_add(email):
+ throw(_("{0} is an invalid email address in 'Notification \
+ Email Address'").format(email))
+
+ else:
+ frappe.throw(_("'Notification Email Addresses' not specified for recurring %s") \
+ % doc.doctype)
+
+def set_next_date(doc, posting_date):
+ """ Set next date on which recurring document will be created"""
+ from erpnext.controllers.recurring_document import get_next_date
+
+ if not doc.repeat_on_day_of_month:
+ msgprint(_("Please enter 'Repeat on Day of Month' field value"), raise_exception=1)
+
+ 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)
\ No newline at end of file
diff --git a/erpnext/controllers/tests/test_recurring_document.py b/erpnext/controllers/tests/test_recurring_document.py
index d31f632..5332ae0 100644
--- a/erpnext/controllers/tests/test_recurring_document.py
+++ b/erpnext/controllers/tests/test_recurring_document.py
@@ -16,14 +16,14 @@
base_doc = frappe.copy_doc(test_records[0])
base_doc.update({
- "convert_into_recurring": 1,
+ "is_recurring": 1,
"recurring_type": "Monthly",
"notification_email_address": "test@example.com, test1@example.com, test2@example.com",
"repeat_on_day_of_month": getdate(today).day,
"due_date": None,
"fiscal_year": get_fiscal_year(today)[0],
- "period_from": get_first_day(today),
- "period_to": get_last_day(today)
+ "from_date": get_first_day(today),
+ "to_date": get_last_day(today)
})
if base_doc.doctype == "Sales Order":
@@ -50,8 +50,8 @@
# monthly without a first and last day period
doc2 = frappe.copy_doc(base_doc)
doc2.update({
- "period_from": today,
- "period_to": add_to_date(today, days=30)
+ "from_date": today,
+ "to_date": add_to_date(today, days=30)
})
doc2.insert()
doc2.submit()
@@ -61,8 +61,8 @@
doc3 = frappe.copy_doc(base_doc)
doc3.update({
"recurring_type": "Quarterly",
- "period_from": get_first_day(today),
- "period_to": get_last_day(add_to_date(today, months=3))
+ "from_date": get_first_day(today),
+ "to_date": get_last_day(add_to_date(today, months=3))
})
doc3.insert()
doc3.submit()
@@ -72,8 +72,8 @@
doc4 = frappe.copy_doc(base_doc)
doc4.update({
"recurring_type": "Quarterly",
- "period_from": today,
- "period_to": add_to_date(today, months=3)
+ "from_date": today,
+ "to_date": add_to_date(today, months=3)
})
doc4.insert()
doc4.submit()
@@ -83,8 +83,8 @@
doc5 = frappe.copy_doc(base_doc)
doc5.update({
"recurring_type": "Yearly",
- "period_from": get_first_day(today),
- "period_to": get_last_day(add_to_date(today, years=1))
+ "from_date": get_first_day(today),
+ "to_date": get_last_day(add_to_date(today, years=1))
})
doc5.insert()
doc5.submit()
@@ -94,8 +94,8 @@
doc6 = frappe.copy_doc(base_doc)
doc6.update({
"recurring_type": "Yearly",
- "period_from": today,
- "period_to": add_to_date(today, years=1)
+ "from_date": today,
+ "to_date": add_to_date(today, years=1)
})
doc6.insert()
doc6.submit()
@@ -138,23 +138,23 @@
new_doc = frappe.get_doc(base_doc.doctype, recurred_documents[0][0])
- for fieldname in ["convert_into_recurring", "recurring_type",
+ for fieldname in ["is_recurring", "recurring_type",
"repeat_on_day_of_month", "notification_email_address"]:
obj.assertEquals(base_doc.get(fieldname),
new_doc.get(fieldname))
obj.assertEquals(new_doc.get(date_field), unicode(next_date))
- obj.assertEquals(new_doc.period_from,
- unicode(add_months(base_doc.period_from, no_of_months)))
+ obj.assertEquals(new_doc.from_date,
+ unicode(add_months(base_doc.from_date, no_of_months)))
if first_and_last_day:
- obj.assertEquals(new_doc.period_to,
- unicode(get_last_day(add_months(base_doc.period_to,
+ obj.assertEquals(new_doc.to_date,
+ unicode(get_last_day(add_months(base_doc.to_date,
no_of_months))))
else:
- obj.assertEquals(new_doc.period_to,
- unicode(add_months(base_doc.period_to, no_of_months)))
+ obj.assertEquals(new_doc.to_date,
+ unicode(add_months(base_doc.to_date, no_of_months)))
return new_doc
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 5466f2a..b9e8451 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -64,7 +64,7 @@
"erpnext.selling.doctype.lead.get_leads.get_leads"
],
"daily": [
- "erpnext.controllers.recurring_document.manage_recurring_documents"
+ "erpnext.controllers.recurring_document.create_recurring_documents"
"erpnext.stock.utils.reorder_item",
"erpnext.setup.doctype.email_digest.email_digest.send",
"erpnext.support.doctype.support_ticket.support_ticket.auto_close_tickets"
diff --git a/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py b/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py
index 1ae3eb0..a8303a0 100644
--- a/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py
+++ b/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py
@@ -1,6 +1,6 @@
import frappe
def execute():
- frappe.reload_doc('selling', 'doctype', 'sales_order')
- frappe.db.sql("""update `tabSales Invoice` set period_from = order_period_from,
- period_to = order_period_to, convert_into_recurring = convert_into_recurring_order""")
+ frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
+ frappe.db.sql("""update `tabSales Invoice` set from_date = invoice_period_from_date,
+ to_date = invoice_period_to_date, is_recurring = convert_into_recurring_invoice""")
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 628e43e..4797230 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -195,6 +195,37 @@
}
};
+cur_frm.cscript.is_recurring = function(doc, dt, dn) {
+ // set default values for recurring orders
+ if(doc.is_recurring) {
+ var owner_email = doc.owner=="Administrator"
+ ? frappe.user_info("Administrator").email
+ : doc.owner;
+
+ doc.notification_email_address = $.map([cstr(owner_email),
+ cstr(doc.contact_email)], function(v) { return v || null; }).join(", ");
+ doc.repeat_on_day_of_month = frappe.datetime.str_to_obj(doc.posting_date).getDate();
+ }
+
+ refresh_many(["notification_email_address", "repeat_on_day_of_month"]);
+}
+
+cur_frm.cscript.from_date = function(doc, dt, dn) {
+ // set to_date
+ if(doc.from_date) {
+ var recurring_type_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6,
+ 'Yearly': 12};
+
+ var months = recurring_type_map[doc.recurring_type];
+ if(months) {
+ var to_date = frappe.datetime.add_months(doc.from_date,
+ months);
+ doc.to_date = frappe.datetime.add_days(to_date, -1);
+ refresh_field('to_date');
+ }
+ }
+}
+
cur_frm.cscript.send_sms = function() {
frappe.require("assets/erpnext/js/sms_manager.js");
var sms_man = new SMSManager(cur_frm.doc);
diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json
index e418ee9..a4b00ff 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.json
+++ b/erpnext/selling/doctype/sales_order/sales_order.json
@@ -173,18 +173,18 @@
{
"allow_on_submit": 1,
"description": "Start date of current order's period",
- "fieldname": "period_from",
+ "fieldname": "from_date",
"fieldtype": "Date",
- "label": "Order Period From",
+ "label": "From",
"no_copy": 1,
"permlevel": 0
},
{
"allow_on_submit": 1,
"description": "End date of current order's period",
- "fieldname": "period_to",
+ "fieldname": "to_date",
"fieldtype": "Date",
- "label": "Order Period To",
+ "label": "To",
"no_copy": 1,
"permlevel": 0
},
@@ -925,16 +925,16 @@
"allow_on_submit": 1,
"depends_on": "eval:doc.docstatus<2",
"description": "Check if recurring order, uncheck to stop recurring or put proper End Date",
- "fieldname": "convert_into_recurring",
+ "fieldname": "is_recurring",
"fieldtype": "Check",
- "label": "Convert into Recurring Order",
+ "label": "Is Recurring",
"no_copy": 1,
"permlevel": 0,
"print_hide": 1
},
{
"allow_on_submit": 1,
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"description": "Select the period when the invoice will be generated automatically",
"fieldname": "recurring_type",
"fieldtype": "Select",
@@ -946,7 +946,7 @@
},
{
"allow_on_submit": 1,
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"description": "The day of the month on which auto order will be generated e.g. 05, 28 etc ",
"fieldname": "repeat_on_day_of_month",
"fieldtype": "Int",
@@ -956,7 +956,7 @@
"print_hide": 1
},
{
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"description": "The date on which next invoice will be generated. It is generated on submit.",
"fieldname": "next_date",
"fieldtype": "Date",
@@ -968,7 +968,7 @@
},
{
"allow_on_submit": 1,
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"description": "The date on which recurring order will be stop",
"fieldname": "end_date",
"fieldtype": "Date",
@@ -985,7 +985,7 @@
"print_hide": 1
},
{
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"fieldname": "recurring_id",
"fieldtype": "Data",
"label": "Recurring Id",
@@ -996,7 +996,7 @@
},
{
"allow_on_submit": 1,
- "depends_on": "eval:doc.convert_into_recurring==1",
+ "depends_on": "eval:doc.is_recurring==1",
"description": "Enter email id separated by commas, order will be mailed automatically on particular date",
"fieldname": "notification_email_address",
"fieldtype": "Small Text",
@@ -1021,7 +1021,7 @@
"idx": 1,
"is_submittable": 1,
"issingle": 0,
- "modified": "2014-08-25 17:41:39.456399",
+ "modified": "2014-08-28 11:22:10.959416",
"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 37aca0a..ff14f9d 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -10,6 +10,8 @@
from frappe import _
from frappe.model.mapper import get_mapped_doc
+from erpnext.controllers.recurring_document import convert_to_recurring, validate_recurring_document
+
from erpnext.controllers.selling_controller import SellingController
form_grid_templates = {
@@ -120,7 +122,7 @@
if not self.billing_status: self.billing_status = 'Not Billed'
if not self.delivery_status: self.delivery_status = 'Not Delivered'
- self.validate_recurring_document()
+ validate_recurring_document(self)
def validate_warehouse(self):
from erpnext.stock.utils import validate_warehouse_company
@@ -164,7 +166,7 @@
self.update_prevdoc_status('submit')
frappe.db.set(self, 'status', 'Submitted')
- self.convert_to_recurring("SO/REC/.#####", self.transaction_date)
+ convert_to_recurring(self, "SO/REC/.#####", self.transaction_date)
def on_cancel(self):
# Cannot cancel stopped SO
@@ -254,8 +256,8 @@
return "order" if self.docstatus==1 else None
def on_update_after_submit(self):
- self.validate_recurring_document()
- self.convert_to_recurring("SO/REC/.#####", self.transaction_date)
+ validate_recurring_document(self)
+ convert_to_recurring(self, "SO/REC/.#####", self.transaction_date)
@frappe.whitelist()