diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 680c6a0bbd..90f463a38d 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -232,7 +232,6 @@ cur_frm.fields_dict['entries'].grid.get_field('project_name').get_query = functi } } -//added by sambhaji cur_frm.cscript.is_recurring = function(doc, dt, dn) { @@ -267,7 +266,7 @@ cur_frm.cscript.from_date = function(doc, dt, dn) { } } -//end of added by sambhajii + cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ if(doc.select_print_heading){ diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index ea3eb8a0a5..e29d3d91d7 100755 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -800,6 +800,7 @@ }, { "allow_on_submit": 1, + "depends_on": "eval:doc.is_recurring==1", "description": "Select the period when the invoice will be generated automatically", "fieldname": "recurring_type", "fieldtype": "Select", diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 7d35f41c96..77c7ea97d1 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -265,11 +265,11 @@ class PurchaseInvoice(BuyingController): self.update_against_document_in_jv() self.update_prevdoc_status() self.update_billing_status_for_zero_amount_refdoc("Purchase Order") - convert_to_recurring(self, "RECINV.#####", self.posting_date) + convert_to_recurring(self, "RECPI.#####", self.posting_date) def on_update_after_submit(self): validate_recurring_document(self) - convert_to_recurring(self, "RECINV.#####", self.posting_date) + convert_to_recurring(self, "RECPI.#####", self.posting_date) def make_gl_entries(self): auto_accounting_for_stock = \ diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index 071d622cdd..549584500f 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -205,7 +205,7 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { cur_frm.email_doc(frappe.boot.notification_settings.purchase_order_message); } } -//added by sambhaji + cur_frm.cscript.is_recurring = function(doc, dt, dn) { // set default values for recurring orders @@ -238,7 +238,7 @@ cur_frm.cscript.from_date = function(doc, dt, dn) { } } -//end of added by sambhaji + 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/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index beebf0b1fb..66083be53b 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -179,7 +179,7 @@ class PurchaseOrder(BuyingController): frappe.db.set(self,'status','Submitted') - convert_to_recurring(self, "SO/REC/.#####", self.transaction_date) + convert_to_recurring(self, "SO/REP/.#####", self.transaction_date) def on_cancel(self): pc_obj = frappe.get_doc('Purchase Common') @@ -204,9 +204,9 @@ class PurchaseOrder(BuyingController): def on_update(self): pass -def on_update_after_submit(self): + def on_update_after_submit(self): validate_recurring_document(self) - convert_to_recurring(self, "SO/REC/.#####", self.transaction_date) + convert_to_recurring(self, "SO/REP/.#####", self.transaction_date) def set_missing_values(source, target): target.ignore_pricing_rule = 1 diff --git a/erpnext/controllers/tests/test_recurring_document.py b/erpnext/controllers/tests/test_recurring_document.py index 0e7cb1bc5e..1051082488 100644 --- a/erpnext/controllers/tests/test_recurring_document.py +++ b/erpnext/controllers/tests/test_recurring_document.py @@ -41,6 +41,20 @@ def test_recurring_document(obj, test_records): date_field = "transaction_date" elif base_doc.doctype == "Sales Invoice": date_field = "posting_date" + #for Purchase order/purchase invoice + if base_doc.doctype == "Purchase Order": + base_doc.update({ + "transaction_date": today + }) + elif base_doc.doctype == "Purchase Invoice": + base_doc.update({ + "posting_date": today + }) + + if base_doc.doctype == "Purchase Order": + date_field = "transaction_date" + elif base_doc.doctype == "Purchase Invoice": + date_field = "posting_date" # monthly doc1 = frappe.copy_doc(base_doc)