[fix] add filters and child doc name in previous link mapper
This commit is contained in:
parent
2a0b111726
commit
b6d6b8420d
@ -38,10 +38,20 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
self.prev_link_mapper = {
|
||||
"Purchase Order": {
|
||||
"fieldname": "purchase_order"
|
||||
"fieldname": "purchase_order",
|
||||
"doctype": "Purchase Invoice Item",
|
||||
"filters": [
|
||||
["Purchase Invoice Item", "parent", "=", self.name],
|
||||
["Purchase Invoice Item", "purchase_order", "!=", ""]
|
||||
]
|
||||
},
|
||||
"Purchase Receipt": {
|
||||
"fieldname": "purchase_receipt"
|
||||
"fieldname": "purchase_receipt",
|
||||
"doctype": "Purchase Invoice Item",
|
||||
"filters": [
|
||||
["Purchase Invoice Item", "parent", "=", self.item],
|
||||
["Purchase Invoice Item", "purchase_receipt", "!=", ""]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -672,9 +682,6 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
def on_recurring(self, reference_doc):
|
||||
self.due_date = None
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
return super(PurchaseInvoice, self).get_link_filters(for_doctype)
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_debit_note(source_name, target_doc=None):
|
||||
|
@ -41,10 +41,20 @@ class SalesInvoice(SellingController):
|
||||
|
||||
self.prev_link_mapper = {
|
||||
"Sales Order": {
|
||||
"fieldname": "sales_order"
|
||||
"fieldname": "sales_order",
|
||||
"doctype": "Sales Invoice Item",
|
||||
"filters": [
|
||||
["Sales Invoice Item", "parent", "=", self.name],
|
||||
["Sales Invoice Item", "sales_order", "!=", ""]
|
||||
]
|
||||
},
|
||||
"Delivery Note": {
|
||||
"fieldname": "delivery_note"
|
||||
"fieldname": "delivery_note",
|
||||
"doctype": "Sales Invoice Item",
|
||||
"filters": [
|
||||
["Sales Invoice Item", "parent", "=", self.name],
|
||||
["Sales Invoice Item", "delivery_note", "!=", ""]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -705,9 +715,6 @@ class SalesInvoice(SellingController):
|
||||
self.set(fieldname, reference_doc.get(fieldname))
|
||||
|
||||
self.due_date = None
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
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
|
||||
|
@ -35,7 +35,12 @@ class PurchaseOrder(BuyingController):
|
||||
|
||||
self.prev_link_mapper = {
|
||||
"Supplier Quotation": {
|
||||
"fieldname": "supplier_quotation"
|
||||
"fieldname": "supplier_quotation",
|
||||
"doctype": "Purchase Order Item",
|
||||
"filters": [
|
||||
["Purchase Order Item", "parent", "=", self.name],
|
||||
["Purchase Order Item", "supplier_quotation", "!=", ""]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,9 +246,6 @@ class PurchaseOrder(BuyingController):
|
||||
if item.delivered_by_supplier == 1:
|
||||
item.received_qty = item.qty
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
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"):
|
||||
|
@ -26,7 +26,12 @@ class SalesOrder(SellingController):
|
||||
|
||||
self.prev_link_mapper = {
|
||||
"Quotation": {
|
||||
"fieldname": "prevdoc_docname"
|
||||
"fieldname": "prevdoc_docname",
|
||||
"doctype": "Sales Order Item",
|
||||
"filters": [
|
||||
["Sales Order Item", "parent", "=", self.name],
|
||||
["Sales Order Item", "prevdoc_docname", "!=", ""]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,9 +320,6 @@ class SalesOrder(SellingController):
|
||||
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_link_filters(self, for_doctype):
|
||||
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
|
||||
|
@ -63,7 +63,12 @@ class DeliveryNote(SellingController):
|
||||
|
||||
self.prev_link_mapper = {
|
||||
"Sales Order": {
|
||||
"fieldname": "against_sales_order"
|
||||
"fieldname": "against_sales_order",
|
||||
"doctype": "Delivery Note Item",
|
||||
"filters": [
|
||||
["Delivery Note Item", "parent", "=", self.name],
|
||||
["Delivery Note Item", "against_sales_order", "!=", ""]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,9 +294,6 @@ class DeliveryNote(SellingController):
|
||||
dn_doc.update_billing_percentage(update_modified=update_modified)
|
||||
|
||||
self.load_from_db()
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
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
|
||||
|
@ -48,7 +48,12 @@ class PurchaseReceipt(BuyingController):
|
||||
|
||||
self.prev_link_mapper = {
|
||||
"Purchase Order": {
|
||||
"fieldname": "prevdoc_docname"
|
||||
"fieldname": "prevdoc_docname",
|
||||
"doctype": "Purchase Receipt Item",
|
||||
"filters": [
|
||||
["Purchase Receipt Item", "parent", "=", self.name],
|
||||
["Purchase Receipt Item", "prevdoc_docname", "!=", ""]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,9 +344,6 @@ class PurchaseReceipt(BuyingController):
|
||||
|
||||
self.load_from_db()
|
||||
|
||||
def get_link_filters(self, for_doctype):
|
||||
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`
|
||||
|
@ -108,7 +108,7 @@ class TransactionBase(StatusUpdater):
|
||||
.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):
|
||||
if hasattr(self, "prev_link_mapper") and 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]))
|
||||
|
Loading…
Reference in New Issue
Block a user