[fix] set previous doc links for document flow
This commit is contained in:
parent
20bedc004e
commit
8f24ecb173
@ -663,6 +663,18 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
def on_recurring(self, reference_doc):
|
||||
self.due_date = None
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
self.prev_link_mapper = {
|
||||
"Purchase Order": {
|
||||
"fieldname": "purchase_order"
|
||||
},
|
||||
"Purchase Receipt": {
|
||||
"fieldname": "purchase_receipt"
|
||||
}
|
||||
}
|
||||
|
||||
return super(PurchaseInvoice, self).get_link_filters(for_doctype)
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_debit_note(source_name, target_doc=None):
|
||||
|
@ -696,6 +696,18 @@ class SalesInvoice(SellingController):
|
||||
self.set(fieldname, reference_doc.get(fieldname))
|
||||
|
||||
self.due_date = None
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
self.prev_link_mapper = {
|
||||
"Sales Order": {
|
||||
"fieldname": "sales_order"
|
||||
},
|
||||
"Delivery Note": {
|
||||
"fieldname": "delivery_note"
|
||||
}
|
||||
}
|
||||
|
||||
return super(SalesInvoice, self).get_link_filters(for_doctype)
|
||||
|
||||
def get_list_context(context=None):
|
||||
from erpnext.controllers.website_list_for_contact import get_list_context
|
||||
|
@ -235,6 +235,15 @@ class PurchaseOrder(BuyingController):
|
||||
if item.delivered_by_supplier == 1:
|
||||
item.received_qty = item.qty
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
self.prev_link_mapper = {
|
||||
"Supplier Quotation": {
|
||||
"fieldname": "supplier_quotation"
|
||||
}
|
||||
}
|
||||
|
||||
return super(PurchaseOrder, self).get_link_filters(for_doctype)
|
||||
|
||||
@frappe.whitelist()
|
||||
def close_or_unclose_purchase_orders(names, status):
|
||||
if not frappe.has_permission("Purchase Order", "write"):
|
||||
|
@ -307,6 +307,15 @@ class SalesOrder(SellingController):
|
||||
self.set("delivery_date", get_next_date(reference_doc.delivery_date, mcount,
|
||||
cint(reference_doc.repeat_on_day_of_month)))
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
self.prev_link_mapper = {
|
||||
"Quotation": {
|
||||
"fieldname": "prevdoc_docname"
|
||||
}
|
||||
}
|
||||
|
||||
return super(SalesOrder, self).get_link_filters(for_doctype)
|
||||
|
||||
def get_list_context(context=None):
|
||||
from erpnext.controllers.website_list_for_contact import get_list_context
|
||||
list_context = get_list_context(context)
|
||||
|
@ -282,6 +282,15 @@ class DeliveryNote(SellingController):
|
||||
dn_doc.update_billing_percentage(update_modified=update_modified)
|
||||
|
||||
self.load_from_db()
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
self.prev_link_mapper = {
|
||||
"Sales Order": {
|
||||
"fieldname": "against_sales_order"
|
||||
}
|
||||
}
|
||||
|
||||
return super(DeliveryNote, self).get_link_filters(for_doctype)
|
||||
|
||||
def update_billed_amount_based_on_so(so_detail, update_modified=True):
|
||||
# Billed against Sales Order directly
|
||||
|
@ -333,6 +333,15 @@ class PurchaseReceipt(BuyingController):
|
||||
|
||||
self.load_from_db()
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
self.prev_link_mapper = {
|
||||
"Purchase Order": {
|
||||
"fieldname": "prevdoc_docname"
|
||||
}
|
||||
}
|
||||
|
||||
return super(PurchaseReceipt, self).get_link_filters(for_doctype)
|
||||
|
||||
def update_billed_amount_based_on_po(po_detail, update_modified=True):
|
||||
# Billed against Sales Order directly
|
||||
billed_against_po = frappe.db.sql("""select sum(amount) from `tabPurchase Invoice Item`
|
||||
|
@ -107,6 +107,24 @@ class TransactionBase(StatusUpdater):
|
||||
frappe.throw(_("Row #{0}: Rate must be same as {1}: {2} ({3} / {4}) ")
|
||||
.format(d.idx, ref_dt, d.get(ref_dn_field), d.rate, ref_rate))
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
if self.prev_link_mapper.get(for_doctype):
|
||||
fieldname = self.prev_link_mapper[for_doctype]["fieldname"]
|
||||
|
||||
values = filter(None, tuple([item.as_dict()[fieldname] for item in self.items]))
|
||||
|
||||
if values:
|
||||
ret = {
|
||||
for_doctype : {
|
||||
"filters": [[for_doctype, "name", "in", values]]
|
||||
}
|
||||
}
|
||||
else:
|
||||
ret = None
|
||||
else:
|
||||
ret = None
|
||||
|
||||
return ret
|
||||
|
||||
def delete_events(ref_type, ref_name):
|
||||
frappe.delete_doc("Event", frappe.db.sql_list("""select name from `tabEvent`
|
||||
|
Loading…
x
Reference in New Issue
Block a user