[fix] obey no_copy while creating recurring documents
This commit is contained in:
parent
47c2aa179b
commit
39e2c2bb09
@ -1563,7 +1563,7 @@
|
|||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Write Off Account",
|
"label": "Write Off Account",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 1,
|
"no_copy": 0,
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
@ -1588,7 +1588,7 @@
|
|||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Write Off Cost Center",
|
"label": "Write Off Cost Center",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 1,
|
"no_copy": 0,
|
||||||
"options": "Cost Center",
|
"options": "Cost Center",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
@ -2487,7 +2487,7 @@
|
|||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"menu_index": 0,
|
"menu_index": 0,
|
||||||
"modified": "2015-12-17 16:18:58.177334",
|
"modified": "2016-01-25 05:18:57.728258",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice",
|
"name": "Purchase Invoice",
|
||||||
|
@ -454,6 +454,9 @@ class PurchaseInvoice(BuyingController):
|
|||||||
for pr in set(updated_pr):
|
for pr in set(updated_pr):
|
||||||
frappe.get_doc("Purchase Receipt", pr).update_billing_percentage(update_modified=update_modified)
|
frappe.get_doc("Purchase Receipt", pr).update_billing_percentage(update_modified=update_modified)
|
||||||
|
|
||||||
|
def on_recurring(self, reference_doc):
|
||||||
|
self.due_date = None
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
|
def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
|
||||||
from erpnext.controllers.queries import get_match_cond
|
from erpnext.controllers.queries import get_match_cond
|
||||||
|
@ -656,6 +656,12 @@ class SalesInvoice(SellingController):
|
|||||||
for dn in set(updated_delivery_notes):
|
for dn in set(updated_delivery_notes):
|
||||||
frappe.get_doc("Delivery Note", dn).update_billing_percentage(update_modified=update_modified)
|
frappe.get_doc("Delivery Note", dn).update_billing_percentage(update_modified=update_modified)
|
||||||
|
|
||||||
|
def on_recurring(self, reference_doc):
|
||||||
|
for fieldname in ("c_form_applicable", "c_form_no", "write_off_amount"):
|
||||||
|
self.set(fieldname, reference_doc.get(fieldname))
|
||||||
|
|
||||||
|
self.due_date = None
|
||||||
|
|
||||||
def get_list_context(context=None):
|
def get_list_context(context=None):
|
||||||
from erpnext.controllers.website_list_for_contact import get_list_context
|
from erpnext.controllers.website_list_for_contact import get_list_context
|
||||||
list_context = get_list_context(context)
|
list_context = get_list_context(context)
|
||||||
|
@ -219,17 +219,6 @@ class PurchaseOrder(BuyingController):
|
|||||||
def on_update(self):
|
def on_update(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def before_recurring(self):
|
|
||||||
super(PurchaseOrder, self).before_recurring()
|
|
||||||
|
|
||||||
for field in ("per_received", "per_billed"):
|
|
||||||
self.set(field, None)
|
|
||||||
|
|
||||||
for d in self.get("items"):
|
|
||||||
for field in ("received_qty", "billed_amt", "prevdoc_doctype", "prevdoc_docname",
|
|
||||||
"prevdoc_detail_docname", "supplier_quotation", "supplier_quotation_item"):
|
|
||||||
d.set(field, None)
|
|
||||||
|
|
||||||
def update_status_updater(self):
|
def update_status_updater(self):
|
||||||
self.status_updater[0].update({
|
self.status_updater[0].update({
|
||||||
"target_parent_dt": "Sales Order",
|
"target_parent_dt": "Sales Order",
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"custom": 0,
|
"custom": 0,
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
|
"document_type": "Document",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -1155,7 +1156,7 @@
|
|||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "BOM",
|
"label": "BOM",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 1,
|
"no_copy": 0,
|
||||||
"options": "BOM",
|
"options": "BOM",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
@ -1330,7 +1331,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-01-06 02:21:10.407871",
|
"modified": "2016-01-25 05:39:52.405200",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order Item",
|
"name": "Purchase Order Item",
|
||||||
|
@ -60,12 +60,6 @@ class AccountsController(TransactionBase):
|
|||||||
validate_recurring_document(self)
|
validate_recurring_document(self)
|
||||||
convert_to_recurring(self, self.get("posting_date") or self.get("transaction_date"))
|
convert_to_recurring(self, self.get("posting_date") or self.get("transaction_date"))
|
||||||
|
|
||||||
def before_recurring(self):
|
|
||||||
if self.meta.get_field("fiscal_year"):
|
|
||||||
self.fiscal_year = None
|
|
||||||
if self.meta.get_field("due_date"):
|
|
||||||
self.due_date = None
|
|
||||||
|
|
||||||
def set_missing_values(self, for_validate=False):
|
def set_missing_values(self, for_validate=False):
|
||||||
for fieldname in ["posting_date", "transaction_date"]:
|
for fieldname in ["posting_date", "transaction_date"]:
|
||||||
if not self.get(fieldname) and self.meta.get_field(fieldname):
|
if not self.get(fieldname) and self.meta.get_field(fieldname):
|
||||||
|
@ -47,12 +47,9 @@ def manage_recurring_documents(doctype, next_date=None, commit=True):
|
|||||||
where %s=%s and recurring_id=%s and docstatus=1"""
|
where %s=%s and recurring_id=%s and docstatus=1"""
|
||||||
% (doctype, date_field, '%s', '%s'), (next_date, recurring_id)):
|
% (doctype, date_field, '%s', '%s'), (next_date, recurring_id)):
|
||||||
try:
|
try:
|
||||||
ref_wrapper = frappe.get_doc(doctype, ref_document)
|
reference_doc = frappe.get_doc(doctype, ref_document)
|
||||||
if hasattr(ref_wrapper, "before_recurring"):
|
new_doc = make_new_document(reference_doc, date_field, next_date)
|
||||||
ref_wrapper.before_recurring()
|
send_notification(new_doc)
|
||||||
|
|
||||||
new_document_wrapper = make_new_document(ref_wrapper, date_field, next_date)
|
|
||||||
send_notification(new_document_wrapper)
|
|
||||||
if commit:
|
if commit:
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
except:
|
except:
|
||||||
@ -63,8 +60,8 @@ def manage_recurring_documents(doctype, next_date=None, commit=True):
|
|||||||
frappe.db.sql("update `tab%s` \
|
frappe.db.sql("update `tab%s` \
|
||||||
set is_recurring = 0 where name = %s" % (doctype, '%s'),
|
set is_recurring = 0 where name = %s" % (doctype, '%s'),
|
||||||
(ref_document))
|
(ref_document))
|
||||||
notify_errors(ref_document, doctype, ref_wrapper.get("customer") or ref_wrapper.get("supplier"),
|
notify_errors(ref_document, doctype, reference_doc.get("customer") or reference_doc.get("supplier"),
|
||||||
ref_wrapper.owner)
|
reference_doc.owner)
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
exception_list.append(frappe.get_traceback())
|
exception_list.append(frappe.get_traceback())
|
||||||
@ -76,34 +73,42 @@ def manage_recurring_documents(doctype, next_date=None, commit=True):
|
|||||||
exception_message = "\n\n".join([cstr(d) for d in exception_list])
|
exception_message = "\n\n".join([cstr(d) for d in exception_list])
|
||||||
frappe.throw(exception_message)
|
frappe.throw(exception_message)
|
||||||
|
|
||||||
def make_new_document(ref_wrapper, date_field, posting_date):
|
def make_new_document(reference_doc, date_field, posting_date):
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
new_document = frappe.copy_doc(ref_wrapper)
|
new_document = frappe.copy_doc(reference_doc, ignore_no_copy=True)
|
||||||
mcount = month_map[ref_wrapper.recurring_type]
|
mcount = month_map[reference_doc.recurring_type]
|
||||||
|
|
||||||
from_date = get_next_date(ref_wrapper.from_date, mcount)
|
from_date = get_next_date(reference_doc.from_date, mcount)
|
||||||
|
|
||||||
# get last day of the month to maintain period if the from date is first day of its own month
|
# 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
|
# and to date is the last day of its own month
|
||||||
if (cstr(get_first_day(ref_wrapper.from_date)) == cstr(ref_wrapper.from_date)) and \
|
if (cstr(get_first_day(reference_doc.from_date)) == cstr(reference_doc.from_date)) and \
|
||||||
(cstr(get_last_day(ref_wrapper.to_date)) == cstr(ref_wrapper.to_date)):
|
(cstr(get_last_day(reference_doc.to_date)) == cstr(reference_doc.to_date)):
|
||||||
to_date = get_last_day(get_next_date(ref_wrapper.to_date, mcount))
|
to_date = get_last_day(get_next_date(reference_doc.to_date, mcount))
|
||||||
else:
|
else:
|
||||||
to_date = get_next_date(ref_wrapper.to_date, mcount)
|
to_date = get_next_date(reference_doc.to_date, mcount)
|
||||||
|
|
||||||
new_document.update({
|
new_document.update({
|
||||||
date_field: posting_date,
|
date_field: posting_date,
|
||||||
"from_date": from_date,
|
"from_date": from_date,
|
||||||
"to_date": to_date,
|
"to_date": to_date,
|
||||||
"fiscal_year": get_fiscal_year(posting_date)[0],
|
"fiscal_year": get_fiscal_year(posting_date)[0]
|
||||||
"owner": ref_wrapper.owner,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if ref_wrapper.doctype == "Sales Order":
|
# copy document fields
|
||||||
new_document.update({
|
for fieldname in ("owner", "recurring_type", "repeat_on_day_of_month",
|
||||||
"delivery_date": get_next_date(ref_wrapper.delivery_date, mcount,
|
"recurring_id", "notification_email_address", "is_recurring", "end_date",
|
||||||
cint(ref_wrapper.repeat_on_day_of_month))
|
"title", "naming_series", "select_print_heading", "ignore_pricing_rule",
|
||||||
})
|
"posting_time", "remarks"):
|
||||||
|
if new_document.meta.get_field(fieldname):
|
||||||
|
new_document.set(fieldname, reference_doc.get(fieldname))
|
||||||
|
|
||||||
|
# copy item fields
|
||||||
|
for i, item in enumerate(new_document.items):
|
||||||
|
for fieldname in ("page_break",):
|
||||||
|
item.set(fieldname, reference_doc.items[i].get(fieldname))
|
||||||
|
|
||||||
|
new_document.run_method("on_recurring", reference_doc=reference_doc)
|
||||||
|
|
||||||
new_document.submit()
|
new_document.submit()
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ from frappe import _
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty
|
from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty
|
||||||
from frappe.desk.notifications import clear_doctype_notifications
|
from frappe.desk.notifications import clear_doctype_notifications
|
||||||
|
from erpnext.controllers.recurring_document import month_map, get_next_date
|
||||||
|
|
||||||
from erpnext.controllers.selling_controller import SellingController
|
from erpnext.controllers.selling_controller import SellingController
|
||||||
|
|
||||||
@ -303,6 +304,11 @@ class SalesOrder(SellingController):
|
|||||||
self.indicator_color = "green"
|
self.indicator_color = "green"
|
||||||
self.indicator_title = _("Paid")
|
self.indicator_title = _("Paid")
|
||||||
|
|
||||||
|
def on_recurring(self, reference_doc):
|
||||||
|
mcount = month_map[reference_doc.recurring_type]
|
||||||
|
self.set("delivery_date", get_next_date(reference_doc.delivery_date, mcount,
|
||||||
|
cint(reference_doc.repeat_on_day_of_month)))
|
||||||
|
|
||||||
def get_list_context(context=None):
|
def get_list_context(context=None):
|
||||||
from erpnext.controllers.website_list_for_contact import get_list_context
|
from erpnext.controllers.website_list_for_contact import get_list_context
|
||||||
list_context = get_list_context(context)
|
list_context = get_list_context(context)
|
||||||
@ -328,17 +334,6 @@ def stop_or_unstop_sales_orders(names, status):
|
|||||||
|
|
||||||
frappe.local.message_log = []
|
frappe.local.message_log = []
|
||||||
|
|
||||||
def before_recurring(self):
|
|
||||||
super(SalesOrder, self).before_recurring()
|
|
||||||
|
|
||||||
for field in ("delivery_status", "per_delivered", "billing_status", "per_billed"):
|
|
||||||
self.set(field, None)
|
|
||||||
|
|
||||||
for d in self.get("items"):
|
|
||||||
for field in ("delivered_qty", "billed_amt", "planned_qty", "prevdoc_docname"):
|
|
||||||
d.set(field, None)
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_material_request(source_name, target_doc=None):
|
def make_material_request(source_name, target_doc=None):
|
||||||
def postprocess(source, doc):
|
def postprocess(source, doc):
|
||||||
|
Loading…
Reference in New Issue
Block a user