feat: Return tracking in PR/DN
This commit is contained in:
parent
01e0d50eba
commit
66069df020
@ -1084,7 +1084,7 @@
|
|||||||
"idx": 105,
|
"idx": 105,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-07-18 05:09:33.800633",
|
"modified": "2020-07-31 14:39:44.599294",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order",
|
"name": "Purchase Order",
|
||||||
@ -1135,5 +1135,5 @@
|
|||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"timeline_field": "supplier",
|
"timeline_field": "supplier",
|
||||||
"title_field": "title"
|
"title_field": "supplier"
|
||||||
}
|
}
|
||||||
@ -207,6 +207,7 @@ def make_return_doc(doctype, source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
company = frappe.db.get_value("Delivery Note", source_name, "company")
|
company = frappe.db.get_value("Delivery Note", source_name, "company")
|
||||||
default_warehouse_for_sales_return = frappe.db.get_value("Company", company, "default_warehouse_for_sales_return")
|
default_warehouse_for_sales_return = frappe.db.get_value("Company", company, "default_warehouse_for_sales_return")
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
doc = frappe.get_doc(target)
|
doc = frappe.get_doc(target)
|
||||||
doc.is_return = 1
|
doc.is_return = 1
|
||||||
|
|||||||
@ -65,6 +65,7 @@ status_map = {
|
|||||||
"Purchase Receipt": [
|
"Purchase Receipt": [
|
||||||
["Draft", None],
|
["Draft", None],
|
||||||
["To Bill", "eval:self.per_billed < 100 and self.docstatus == 1"],
|
["To Bill", "eval:self.per_billed < 100 and self.docstatus == 1"],
|
||||||
|
["Return Issued", "eval:self.per_returned == 100 and self.docstatus == 1"],
|
||||||
["Completed", "eval:self.per_billed == 100 and self.docstatus == 1"],
|
["Completed", "eval:self.per_billed == 100 and self.docstatus == 1"],
|
||||||
["Cancelled", "eval:self.docstatus==2"],
|
["Cancelled", "eval:self.docstatus==2"],
|
||||||
["Closed", "eval:self.status=='Closed'"],
|
["Closed", "eval:self.status=='Closed'"],
|
||||||
@ -232,7 +233,7 @@ class StatusUpdater(Document):
|
|||||||
|
|
||||||
self._update_children(args, update_modified)
|
self._update_children(args, update_modified)
|
||||||
|
|
||||||
if "percent_join_field" in args:
|
if "percent_join_field" in args or "percent_join_field_parent" in args:
|
||||||
self._update_percent_field_in_targets(args, update_modified)
|
self._update_percent_field_in_targets(args, update_modified)
|
||||||
|
|
||||||
def _update_children(self, args, update_modified):
|
def _update_children(self, args, update_modified):
|
||||||
@ -272,6 +273,12 @@ class StatusUpdater(Document):
|
|||||||
|
|
||||||
def _update_percent_field_in_targets(self, args, update_modified=True):
|
def _update_percent_field_in_targets(self, args, update_modified=True):
|
||||||
"""Update percent field in parent transaction"""
|
"""Update percent field in parent transaction"""
|
||||||
|
if args.get('percent_join_field_parent'):
|
||||||
|
# if reference to target doc where % is to be updated, is
|
||||||
|
# in source doc's parent form, consider percent_join_field_parent
|
||||||
|
args['name'] = self.get(args['percent_join_field_parent'])
|
||||||
|
self._update_percent_field(args, update_modified)
|
||||||
|
else:
|
||||||
distinct_transactions = set([d.get(args['percent_join_field'])
|
distinct_transactions = set([d.get(args['percent_join_field'])
|
||||||
for d in self.get_all_children(args['source_dt'])])
|
for d in self.get_all_children(args['source_dt'])])
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
"actions": [],
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_workflow": 1,
|
|
||||||
"autoname": "naming_series:",
|
"autoname": "naming_series:",
|
||||||
"creation": "2013-05-21 16:16:39",
|
"creation": "2013-05-21 16:16:39",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
@ -111,6 +110,7 @@
|
|||||||
"range",
|
"range",
|
||||||
"column_break4",
|
"column_break4",
|
||||||
"per_billed",
|
"per_billed",
|
||||||
|
"per_returned",
|
||||||
"is_internal_supplier",
|
"is_internal_supplier",
|
||||||
"inter_company_reference",
|
"inter_company_reference",
|
||||||
"subscription_detail",
|
"subscription_detail",
|
||||||
@ -1104,13 +1104,23 @@
|
|||||||
"fieldtype": "Small Text",
|
"fieldtype": "Small Text",
|
||||||
"label": "Billing Address",
|
"label": "Billing Address",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:!doc.__islocal",
|
||||||
|
"fieldname": "per_returned",
|
||||||
|
"fieldtype": "Percent",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "% Returned",
|
||||||
|
"no_copy": 1,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-truck",
|
"icon": "fa fa-truck",
|
||||||
"idx": 261,
|
"idx": 261,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-07-18 05:19:12.148115",
|
"modified": "2020-07-31 15:16:26.811384",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Purchase Receipt",
|
"name": "Purchase Receipt",
|
||||||
|
|||||||
@ -55,7 +55,8 @@ class PurchaseReceipt(BuyingController):
|
|||||||
'percent_join_field': 'material_request'
|
'percent_join_field': 'material_request'
|
||||||
}]
|
}]
|
||||||
if cint(self.is_return):
|
if cint(self.is_return):
|
||||||
self.status_updater.append({
|
self.status_updater.extend([
|
||||||
|
{
|
||||||
'source_dt': 'Purchase Receipt Item',
|
'source_dt': 'Purchase Receipt Item',
|
||||||
'target_dt': 'Purchase Order Item',
|
'target_dt': 'Purchase Order Item',
|
||||||
'join_field': 'purchase_order_item',
|
'join_field': 'purchase_order_item',
|
||||||
@ -68,7 +69,19 @@ class PurchaseReceipt(BuyingController):
|
|||||||
where name=`tabPurchase Receipt Item`.parent and is_return=1)""",
|
where name=`tabPurchase Receipt Item`.parent and is_return=1)""",
|
||||||
'second_source_extra_cond': """ and exists (select name from `tabPurchase Invoice`
|
'second_source_extra_cond': """ and exists (select name from `tabPurchase Invoice`
|
||||||
where name=`tabPurchase Invoice Item`.parent and is_return=1 and update_stock=1)"""
|
where name=`tabPurchase Invoice Item`.parent and is_return=1 and update_stock=1)"""
|
||||||
})
|
},
|
||||||
|
{
|
||||||
|
'source_dt': 'Purchase Receipt Item',
|
||||||
|
'target_dt': 'Purchase Receipt Item',
|
||||||
|
'join_field': 'purchase_receipt_item',
|
||||||
|
'target_field': 'returned_qty',
|
||||||
|
'target_parent_dt': 'Purchase Receipt',
|
||||||
|
'target_parent_field': 'per_returned',
|
||||||
|
'target_ref_field': 'stock_qty',
|
||||||
|
'source_field': '-1 * stock_qty',
|
||||||
|
'percent_join_field_parent': 'return_against'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_posting_time()
|
self.validate_posting_time()
|
||||||
@ -470,7 +483,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
frappe.db.set_value("Asset", asset.name, "purchase_receipt_amount", flt(valuation_rate))
|
frappe.db.set_value("Asset", asset.name, "purchase_receipt_amount", flt(valuation_rate))
|
||||||
|
|
||||||
def update_status(self, status):
|
def update_status(self, status):
|
||||||
self.set_status(update=True, status = status)
|
self.set_status(update=True, status=status)
|
||||||
self.notify_update()
|
self.notify_update()
|
||||||
clear_doctype_notifications(self)
|
clear_doctype_notifications(self)
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,8 @@ frappe.listview_settings['Purchase Receipt'] = {
|
|||||||
return [__("Return"), "darkgrey", "is_return,=,Yes"];
|
return [__("Return"), "darkgrey", "is_return,=,Yes"];
|
||||||
} else if (doc.status === "Closed") {
|
} else if (doc.status === "Closed") {
|
||||||
return [__("Closed"), "green", "status,=,Closed"];
|
return [__("Closed"), "green", "status,=,Closed"];
|
||||||
|
} else if (flt(doc.per_returned, 2) == 100) {
|
||||||
|
return [__("Return Issued"), "grey", "per_returned,=,100"];
|
||||||
} else if (flt(doc.grand_total) !== 0 && flt(doc.per_billed, 2) < 100) {
|
} else if (flt(doc.grand_total) !== 0 && flt(doc.per_billed, 2) < 100) {
|
||||||
return [__("To Bill"), "orange", "per_billed,<,100"];
|
return [__("To Bill"), "orange", "per_billed,<,100"];
|
||||||
} else if (flt(doc.grand_total) === 0 || flt(doc.per_billed, 2) == 100) {
|
} else if (flt(doc.grand_total) === 0 || flt(doc.per_billed, 2) == 100) {
|
||||||
|
|||||||
@ -28,9 +28,12 @@
|
|||||||
"uom",
|
"uom",
|
||||||
"stock_uom",
|
"stock_uom",
|
||||||
"conversion_factor",
|
"conversion_factor",
|
||||||
"stock_qty",
|
|
||||||
"retain_sample",
|
"retain_sample",
|
||||||
"sample_quantity",
|
"sample_quantity",
|
||||||
|
"tracking_section",
|
||||||
|
"stock_qty",
|
||||||
|
"col_break_tracking_section",
|
||||||
|
"returned_qty",
|
||||||
"rate_and_amount",
|
"rate_and_amount",
|
||||||
"price_list_rate",
|
"price_list_rate",
|
||||||
"discount_percentage",
|
"discount_percentage",
|
||||||
@ -526,7 +529,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "stock_qty",
|
"fieldname": "stock_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "Accepted Qty as per Stock UOM",
|
"label": "Accepted Qty in Stock UOM",
|
||||||
"oldfieldname": "stock_qty",
|
"oldfieldname": "stock_qty",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
@ -834,12 +837,28 @@
|
|||||||
"collapsible": 1,
|
"collapsible": 1,
|
||||||
"fieldname": "image_column",
|
"fieldname": "image_column",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "tracking_section",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "col_break_tracking_section",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "returned_qty",
|
||||||
|
"fieldname": "returned_qty",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Returned Qty in Stock UOM",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-04-28 19:01:21.154963",
|
"modified": "2020-07-30 21:02:17.912628",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Purchase Receipt Item",
|
"name": "Purchase Receipt Item",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user