change convert_to_recurring() to take recurring_id dynamicaly
This commit is contained in:
parent
b2a3f2d386
commit
b14401c320
@ -265,11 +265,11 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.update_against_document_in_jv()
|
self.update_against_document_in_jv()
|
||||||
self.update_prevdoc_status()
|
self.update_prevdoc_status()
|
||||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||||
convert_to_recurring(self, "RECPI.#####", self.posting_date)
|
convert_to_recurring(self, self.posting_date)
|
||||||
|
|
||||||
def on_update_after_submit(self):
|
def on_update_after_submit(self):
|
||||||
validate_recurring_document(self)
|
validate_recurring_document(self)
|
||||||
convert_to_recurring(self, "RECPI.#####", self.posting_date)
|
convert_to_recurring(self, self.posting_date)
|
||||||
|
|
||||||
def make_gl_entries(self):
|
def make_gl_entries(self):
|
||||||
auto_accounting_for_stock = \
|
auto_accounting_for_stock = \
|
||||||
|
@ -103,7 +103,7 @@ class SalesInvoice(SellingController):
|
|||||||
|
|
||||||
self.update_c_form()
|
self.update_c_form()
|
||||||
self.update_time_log_batch(self.name)
|
self.update_time_log_batch(self.name)
|
||||||
convert_to_recurring(self, "RECINV.#####", self.posting_date)
|
convert_to_recurring(self, self.posting_date)
|
||||||
|
|
||||||
def before_cancel(self):
|
def before_cancel(self):
|
||||||
self.update_time_log_batch(None)
|
self.update_time_log_batch(None)
|
||||||
@ -145,7 +145,7 @@ class SalesInvoice(SellingController):
|
|||||||
|
|
||||||
def on_update_after_submit(self):
|
def on_update_after_submit(self):
|
||||||
validate_recurring_document(self)
|
validate_recurring_document(self)
|
||||||
convert_to_recurring(self, "RECINV.#####", self.posting_date)
|
convert_to_recurring(self, self.posting_date)
|
||||||
|
|
||||||
def get_portal_page(self):
|
def get_portal_page(self):
|
||||||
return "invoice" if self.docstatus==1 else None
|
return "invoice" if self.docstatus==1 else None
|
||||||
|
@ -179,7 +179,7 @@ class PurchaseOrder(BuyingController):
|
|||||||
|
|
||||||
frappe.db.set(self,'status','Submitted')
|
frappe.db.set(self,'status','Submitted')
|
||||||
|
|
||||||
convert_to_recurring(self, "SO/REP/.#####", self.transaction_date)
|
convert_to_recurring(self, self.transaction_date)
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
pc_obj = frappe.get_doc('Purchase Common')
|
pc_obj = frappe.get_doc('Purchase Common')
|
||||||
@ -206,7 +206,7 @@ class PurchaseOrder(BuyingController):
|
|||||||
|
|
||||||
def on_update_after_submit(self):
|
def on_update_after_submit(self):
|
||||||
validate_recurring_document(self)
|
validate_recurring_document(self)
|
||||||
convert_to_recurring(self, "SO/REP/.#####", self.transaction_date)
|
convert_to_recurring(self, self.transaction_date)
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
target.ignore_pricing_rule = 1
|
target.ignore_pricing_rule = 1
|
||||||
|
@ -2,9 +2,14 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import frappe.utils
|
import frappe.utils
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
from frappe.utils import cint, cstr, getdate, nowdate, get_first_day, get_last_day
|
|
||||||
|
from frappe.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, \
|
||||||
|
get_first_day, get_last_day, comma_and
|
||||||
from frappe.model.naming import make_autoname
|
from frappe.model.naming import make_autoname
|
||||||
|
|
||||||
from frappe import _, msgprint, throw
|
from frappe import _, msgprint, throw
|
||||||
|
from erpnext.accounts.party import get_party_account, get_due_date, get_party_details
|
||||||
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
|
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
|
||||||
|
|
||||||
@ -152,18 +157,18 @@ def validate_recurring_document(doc):
|
|||||||
elif not (doc.from_date and doc.to_date):
|
elif not (doc.from_date and doc.to_date):
|
||||||
throw(_("Period From and Period To dates mandatory for recurring %s") % doc.doctype)
|
throw(_("Period From and Period To dates mandatory for recurring %s") % doc.doctype)
|
||||||
|
|
||||||
def convert_to_recurring(doc, autoname, posting_date):
|
#
|
||||||
|
def convert_to_recurring(doc, posting_date):
|
||||||
if doc.is_recurring:
|
if doc.is_recurring:
|
||||||
if not doc.recurring_id:
|
if not doc.recurring_id:
|
||||||
frappe.db.set(doc, "recurring_id",
|
frappe.db.set(doc, "recurring_id", doc.name)
|
||||||
make_autoname(autoname))
|
|
||||||
|
|
||||||
set_next_date(doc, posting_date)
|
set_next_date(doc, posting_date)
|
||||||
|
|
||||||
elif doc.recurring_id:
|
elif doc.recurring_id:
|
||||||
frappe.db.sql("""update `tab%s`
|
frappe.db.sql("""update `tab%s` set is_recurring = 0
|
||||||
set is_recurring = 0
|
|
||||||
where recurring_id = %s""" % (doc.doctype, '%s'), (doc.recurring_id))
|
where recurring_id = %s""" % (doc.doctype, '%s'), (doc.recurring_id))
|
||||||
|
#
|
||||||
|
|
||||||
def validate_notification_email_id(doc):
|
def validate_notification_email_id(doc):
|
||||||
if doc.notification_email_address:
|
if doc.notification_email_address:
|
||||||
|
@ -166,7 +166,7 @@ class SalesOrder(SellingController):
|
|||||||
self.update_prevdoc_status('submit')
|
self.update_prevdoc_status('submit')
|
||||||
frappe.db.set(self, 'status', 'Submitted')
|
frappe.db.set(self, 'status', 'Submitted')
|
||||||
|
|
||||||
convert_to_recurring(self, "SO/REC/.#####", self.transaction_date)
|
convert_to_recurring(self, self.transaction_date)
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
# Cannot cancel stopped SO
|
# Cannot cancel stopped SO
|
||||||
@ -257,7 +257,7 @@ class SalesOrder(SellingController):
|
|||||||
|
|
||||||
def on_update_after_submit(self):
|
def on_update_after_submit(self):
|
||||||
validate_recurring_document(self)
|
validate_recurring_document(self)
|
||||||
convert_to_recurring(self, "SO/REC/.#####", self.transaction_date)
|
convert_to_recurring(self, self.transaction_date)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user