Merge pull request #5641 from rohitwaghchaure/rename_prevdoc_fields
Rename prevdoc field in purchase order and purchase receipt doctype
This commit is contained in:
commit
f1439c8f78
@ -23,13 +23,13 @@ class PurchaseOrder(BuyingController):
|
||||
self.status_updater = [{
|
||||
'source_dt': 'Purchase Order Item',
|
||||
'target_dt': 'Material Request Item',
|
||||
'join_field': 'prevdoc_detail_docname',
|
||||
'join_field': 'material_request_item',
|
||||
'target_field': 'ordered_qty',
|
||||
'target_parent_dt': 'Material Request',
|
||||
'target_parent_field': 'per_ordered',
|
||||
'target_ref_field': 'qty',
|
||||
'source_field': 'stock_qty',
|
||||
'percent_join_field': 'prevdoc_docname',
|
||||
'percent_join_field': 'material_request',
|
||||
'overflow_type': 'order'
|
||||
}]
|
||||
|
||||
@ -92,9 +92,9 @@ class PurchaseOrder(BuyingController):
|
||||
|
||||
def get_schedule_dates(self):
|
||||
for d in self.get('items'):
|
||||
if d.prevdoc_detail_docname and not d.schedule_date:
|
||||
if d.material_request_item and not d.schedule_date:
|
||||
d.schedule_date = frappe.db.get_value("Material Request Item",
|
||||
d.prevdoc_detail_docname, "schedule_date")
|
||||
d.material_request_item, "schedule_date")
|
||||
|
||||
|
||||
def get_last_purchase_rate(self):
|
||||
@ -125,15 +125,15 @@ class PurchaseOrder(BuyingController):
|
||||
def check_for_closed_status(self, pc_obj):
|
||||
check_list =[]
|
||||
for d in self.get('items'):
|
||||
if d.meta.get_field('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
|
||||
check_list.append(d.prevdoc_docname)
|
||||
pc_obj.check_for_closed_status( d.prevdoc_doctype, d.prevdoc_docname)
|
||||
if d.meta.get_field('material_request') and d.material_request and d.material_request not in check_list:
|
||||
check_list.append(d.material_request)
|
||||
pc_obj.check_for_closed_status('Material Request', d.material_request)
|
||||
|
||||
def update_requested_qty(self):
|
||||
material_request_map = {}
|
||||
for d in self.get("items"):
|
||||
if d.prevdoc_doctype and d.prevdoc_doctype == "Material Request" and d.prevdoc_detail_docname:
|
||||
material_request_map.setdefault(d.prevdoc_docname, []).append(d.prevdoc_detail_docname)
|
||||
if d.material_request_item:
|
||||
material_request_map.setdefault(d.material_request, []).append(d.material_request_item)
|
||||
|
||||
for mr, mr_item_rows in material_request_map.items():
|
||||
if mr and mr_item_rows:
|
||||
@ -225,9 +225,9 @@ class PurchaseOrder(BuyingController):
|
||||
"""Update delivered qty in Sales Order for drop ship"""
|
||||
sales_orders_to_update = []
|
||||
for item in self.items:
|
||||
if item.prevdoc_doctype == "Sales Order" and item.delivered_by_supplier == 1:
|
||||
if item.prevdoc_docname not in sales_orders_to_update:
|
||||
sales_orders_to_update.append(item.prevdoc_docname)
|
||||
if item.sales_order and item.delivered_by_supplier == 1:
|
||||
if item.sales_order not in sales_orders_to_update:
|
||||
sales_orders_to_update.append(item.sales_order)
|
||||
|
||||
for so_name in sales_orders_to_update:
|
||||
so = frappe.get_doc("Sales Order", so_name)
|
||||
@ -239,7 +239,7 @@ class PurchaseOrder(BuyingController):
|
||||
return any([d.delivered_by_supplier for d in self.items])
|
||||
|
||||
def is_against_so(self):
|
||||
return any([d.prevdoc_doctype for d in self.items if d.prevdoc_doctype=="Sales Order"])
|
||||
return any([d.sales_order for d in self.items if d.sales_order])
|
||||
|
||||
def set_received_qty_for_drop_ship_items(self):
|
||||
for item in self.items:
|
||||
@ -288,9 +288,8 @@ def make_purchase_receipt(source_name, target_doc=None):
|
||||
"Purchase Order Item": {
|
||||
"doctype": "Purchase Receipt Item",
|
||||
"field_map": {
|
||||
"name": "prevdoc_detail_docname",
|
||||
"parent": "prevdoc_docname",
|
||||
"parenttype": "prevdoc_doctype",
|
||||
"name": "purchase_order_item",
|
||||
"parent": "purchase_order",
|
||||
},
|
||||
"postprocess": update_item,
|
||||
"condition": lambda doc: abs(doc.received_qty) < abs(doc.qty) and doc.delivered_by_supplier!=1
|
||||
|
@ -3,6 +3,7 @@
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"autoname": "hash",
|
||||
"beta": 0,
|
||||
"creation": "2013-05-24 19:29:06",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
@ -959,46 +960,19 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "prevdoc_doctype",
|
||||
"fieldname": "material_request",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Reference Document Type",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "prevdoc_doctype",
|
||||
"oldfieldtype": "Data",
|
||||
"options": "DocType",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "prevdoc_docname",
|
||||
"fieldtype": "Dynamic Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Reference Name",
|
||||
"label": "Material Request",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "prevdoc_docname",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "prevdoc_doctype",
|
||||
"options": "Material Request",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
@ -1015,14 +989,14 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "prevdoc_detail_docname",
|
||||
"fieldname": "material_request_item",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Material Request Detail No",
|
||||
"label": "Material Request Item",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "prevdoc_detail_docname",
|
||||
@ -1037,6 +1011,57 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "sales_order",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Sales Order",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"options": "Sales Order",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 1,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "sales_order_item",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Sales Order Item",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 1,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
@ -1378,20 +1403,23 @@
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"idx": 1,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"in_dialog": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-03-18 05:08:54.505417",
|
||||
"modified": "2016-07-04 16:29:19.624908",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Purchase Order Item",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"quick_entry": 1,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
"sort_order": "DESC",
|
||||
"track_seen": 0
|
||||
}
|
@ -78,9 +78,8 @@ def make_purchase_order(source_name, target_doc=None):
|
||||
["parent", "supplier_quotation"],
|
||||
["uom", "stock_uom"],
|
||||
["uom", "uom"],
|
||||
["prevdoc_detail_docname", "prevdoc_detail_docname"],
|
||||
["prevdoc_doctype", "prevdoc_doctype"],
|
||||
["prevdoc_docname", "prevdoc_docname"]
|
||||
["material_request", "material_request"],
|
||||
["material_request_item", "material_request_item"]
|
||||
],
|
||||
"postprocess": update_item
|
||||
},
|
||||
|
@ -366,8 +366,8 @@ class BuyingController(StockController):
|
||||
po_map = {}
|
||||
for d in self.get("items"):
|
||||
if self.doctype=="Purchase Receipt" \
|
||||
and d.prevdoc_doctype=="Purchase Order" and d.prevdoc_detail_docname:
|
||||
po_map.setdefault(d.prevdoc_docname, []).append(d.prevdoc_detail_docname)
|
||||
and d.purchase_order:
|
||||
po_map.setdefault(d.purchase_order, []).append(d.purchase_order_item)
|
||||
|
||||
elif self.doctype=="Purchase Invoice" and d.purchase_order and d.po_detail:
|
||||
po_map.setdefault(d.purchase_order, []).append(d.po_detail)
|
||||
|
@ -286,4 +286,5 @@ erpnext.patches.v7_0.set_is_group_for_warehouse
|
||||
erpnext.patches.v7_0.update_maintenance_module_in_doctype
|
||||
erpnext.patches.v7_0.update_prevdoc_values_for_supplier_quotation_item
|
||||
erpnext.patches.v7_0.rename_advance_table_fields
|
||||
erpnext.patches.v7_0.rename_salary_components
|
||||
erpnext.patches.v7_0.rename_salary_components
|
||||
erpnext.patches.v7_0.rename_prevdoc_fields
|
||||
|
75
erpnext/patches/v7_0/rename_prevdoc_fields.py
Normal file
75
erpnext/patches/v7_0/rename_prevdoc_fields.py
Normal file
@ -0,0 +1,75 @@
|
||||
import frappe
|
||||
import json
|
||||
from frappe.model.utils.rename_field import update_reports, rename_field, update_property_setters
|
||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||
|
||||
def execute():
|
||||
frappe.reload_doctype('Purchase Order Item')
|
||||
frappe.reload_doctype('Purchase Receipt Item')
|
||||
update_po_fields()
|
||||
update_prop_setters_reports_print_format_for_po()
|
||||
set_sales_order_field()
|
||||
rename_pr_fields()
|
||||
|
||||
def update_po_fields():
|
||||
for data in frappe.db.sql(""" select prevdoc_docname, prevdoc_detail_docname, name, prevdoc_doctype
|
||||
from `tabPurchase Order Item` where prevdoc_doctype is not null""", as_dict=True):
|
||||
if data.prevdoc_doctype == 'Material Request':
|
||||
frappe.db.set_value("Purchase Order Item", data.name, "material_request", data.prevdoc_docname, update_modified=False)
|
||||
frappe.db.set_value("Purchase Order Item", data.name, "material_request_item", data.prevdoc_detail_docname, update_modified=False)
|
||||
elif data.prevdoc_doctype == 'Sales Order':
|
||||
frappe.db.set_value("Purchase Order Item", data.name, "sales_order", data.prevdoc_docname, update_modified=False)
|
||||
frappe.db.set_value("Purchase Order Item", data.name, "sales_order_item", data.prevdoc_detail_docname, update_modified=False)
|
||||
|
||||
def get_columns():
|
||||
return {
|
||||
'prevdoc_docname': 'material_request',
|
||||
'prevdoc_detail_docname': 'material_request_item'
|
||||
}
|
||||
|
||||
def update_prop_setters_reports_print_format_for_po():
|
||||
for key, val in get_columns().items():
|
||||
update_property_setters('Purchase Order Item', key, val)
|
||||
update_reports('Purchase Order Item', key, val)
|
||||
update_print_format_for_po(key, val, 'Purchase Order')
|
||||
|
||||
def update_print_format_for_po(old_fieldname, new_fieldname, doc_type):
|
||||
column_mapper = get_columns()
|
||||
|
||||
for data in frappe.db.sql(""" select name, format_data from `tabPrint Format` where
|
||||
format_data like %(old_fieldname)s and doc_type = %(doc_type)s""",
|
||||
{'old_fieldname': '%%%s%%'%(old_fieldname), 'doc_type': doc_type}, as_dict=True):
|
||||
|
||||
update_print_format_fields(old_fieldname, new_fieldname, data)
|
||||
|
||||
def update_print_format_fields(old_fieldname, new_fieldname, args):
|
||||
report_dict = json.loads(args.format_data)
|
||||
update = False
|
||||
|
||||
for col in report_dict:
|
||||
if col.get('fieldname') and col.get('fieldname') == old_fieldname:
|
||||
col['fieldname'] = new_fieldname
|
||||
update = True
|
||||
|
||||
if col.get('visible_columns'):
|
||||
for key in col.get('visible_columns'):
|
||||
if key.get('fieldname') == old_fieldname:
|
||||
key['fieldname'] = new_fieldname
|
||||
update = True
|
||||
|
||||
if update:
|
||||
val = json.dumps(report_dict)
|
||||
frappe.db.sql("""update `tabPrint Format` set `format_data`=%s where name=%s""", (val, args.name))
|
||||
|
||||
def set_sales_order_field():
|
||||
for data in frappe.db.sql("""select doc_type, field_name, property, value, property_type
|
||||
from `tabProperty Setter` where doc_type = 'Purchase Order Item'
|
||||
and field_name in('material_request', 'material_request_item')""", as_dict=True):
|
||||
if data.field_name == 'material_request':
|
||||
make_property_setter(data.doc_type, 'sales_order', data.property, data.value, data.property_type)
|
||||
else:
|
||||
make_property_setter(data.doc_type, 'sales_order_item', data.property, data.value, data.property_type)
|
||||
|
||||
def rename_pr_fields():
|
||||
rename_field("Purchase Receipt Item", "prevdoc_docname", "purchase_order")
|
||||
rename_field("Purchase Receipt Item", "prevdoc_detail_docname", "purchase_order_item")
|
@ -286,8 +286,7 @@ class SalesOrder(SellingController):
|
||||
if item.delivered_by_supplier:
|
||||
item_delivered_qty = frappe.db.sql("""select sum(qty)
|
||||
from `tabPurchase Order Item` poi, `tabPurchase Order` po
|
||||
where poi.prevdoc_detail_docname = %s
|
||||
and poi.prevdoc_doctype = 'Sales Order'
|
||||
where poi.sales_order_item = %s
|
||||
and poi.item_code = %s
|
||||
and poi.parent = po.name
|
||||
and po.docstatus = 1
|
||||
@ -611,9 +610,8 @@ def make_purchase_order_for_drop_shipment(source_name, for_supplier, target_doc=
|
||||
"Sales Order Item": {
|
||||
"doctype": "Purchase Order Item",
|
||||
"field_map": [
|
||||
["name", "prevdoc_detail_docname"],
|
||||
["parent", "prevdoc_docname"],
|
||||
["parenttype", "prevdoc_doctype"],
|
||||
["name", "sales_order_item"],
|
||||
["parent", "sales_order"],
|
||||
["uom", "stock_uom"],
|
||||
["delivery_date", "schedule_date"]
|
||||
],
|
||||
|
@ -376,8 +376,7 @@ class TestSalesOrder(unittest.TestCase):
|
||||
dn = create_dn_against_so(so.name, delivered_qty=1)
|
||||
|
||||
self.assertEquals(so.customer, po.customer)
|
||||
self.assertEquals(po.items[0].prevdoc_doctype, "Sales Order")
|
||||
self.assertEquals(po.items[0].prevdoc_docname, so.name)
|
||||
self.assertEquals(po.items[0].sales_order, so.name)
|
||||
self.assertEquals(po.items[0].item_code, po_item.item_code)
|
||||
self.assertEquals(dn.items[0].item_code, dn_item.item_code)
|
||||
|
||||
|
@ -50,7 +50,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped') {
|
||||
|
||||
this.frm.dashboard.show_dashboard();
|
||||
// this.frm.dashboard.show_dashboard();
|
||||
|
||||
if(flt(doc.per_ordered, 2) < 100) {
|
||||
// make
|
||||
|
@ -213,9 +213,8 @@ def make_purchase_order(source_name, target_doc=None):
|
||||
"Material Request Item": {
|
||||
"doctype": "Purchase Order Item",
|
||||
"field_map": [
|
||||
["name", "prevdoc_detail_docname"],
|
||||
["parent", "prevdoc_docname"],
|
||||
["parenttype", "prevdoc_doctype"],
|
||||
["name", "material_request_item"],
|
||||
["parent", "material_request"],
|
||||
["uom", "stock_uom"],
|
||||
["uom", "uom"]
|
||||
],
|
||||
@ -274,9 +273,8 @@ def make_purchase_order_based_on_supplier(source_name, target_doc=None):
|
||||
"Material Request Item": {
|
||||
"doctype": "Purchase Order Item",
|
||||
"field_map": [
|
||||
["name", "prevdoc_detail_docname"],
|
||||
["parent", "prevdoc_docname"],
|
||||
["parenttype", "prevdoc_doctype"],
|
||||
["name", "material_request_item"],
|
||||
["parent", "material_request"],
|
||||
["uom", "stock_uom"],
|
||||
["uom", "uom"]
|
||||
],
|
||||
|
@ -23,36 +23,35 @@ class PurchaseReceipt(BuyingController):
|
||||
self.status_updater = [{
|
||||
'source_dt': 'Purchase Receipt Item',
|
||||
'target_dt': 'Purchase Order Item',
|
||||
'join_field': 'prevdoc_detail_docname',
|
||||
'join_field': 'purchase_order_item',
|
||||
'target_field': 'received_qty',
|
||||
'target_parent_dt': 'Purchase Order',
|
||||
'target_parent_field': 'per_received',
|
||||
'target_ref_field': 'qty',
|
||||
'source_field': 'qty',
|
||||
'percent_join_field': 'prevdoc_docname',
|
||||
'percent_join_field': 'purchase_order',
|
||||
'overflow_type': 'receipt'
|
||||
},
|
||||
{
|
||||
'source_dt': 'Purchase Receipt Item',
|
||||
'target_dt': 'Purchase Order Item',
|
||||
'join_field': 'prevdoc_detail_docname',
|
||||
'join_field': 'purchase_order_item',
|
||||
'target_field': 'returned_qty',
|
||||
'target_parent_dt': 'Purchase Order',
|
||||
# 'target_parent_field': 'per_received',
|
||||
# 'target_ref_field': 'qty',
|
||||
'source_field': '-1 * qty',
|
||||
# 'percent_join_field': 'prevdoc_docname',
|
||||
# 'overflow_type': 'receipt',
|
||||
'extra_cond': """ and exists (select name from `tabPurchase Receipt` where name=`tabPurchase Receipt Item`.parent and is_return=1)"""
|
||||
}]
|
||||
|
||||
self.prev_link_mapper = {
|
||||
"Purchase Order": {
|
||||
"fieldname": "prevdoc_docname",
|
||||
"fieldname": "purchase_order",
|
||||
"doctype": "Purchase Receipt Item",
|
||||
"filters": [
|
||||
["Purchase Receipt Item", "parent", "=", self.name],
|
||||
["Purchase Receipt Item", "prevdoc_docname", "!=", ""]
|
||||
["Purchase Receipt Item", "purchase_order", "!=", ""]
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -73,29 +72,29 @@ class PurchaseReceipt(BuyingController):
|
||||
def validate_with_previous_doc(self):
|
||||
super(PurchaseReceipt, self).validate_with_previous_doc({
|
||||
"Purchase Order": {
|
||||
"ref_dn_field": "prevdoc_docname",
|
||||
"ref_dn_field": "purchase_order",
|
||||
"compare_fields": [["supplier", "="], ["company", "="], ["currency", "="]],
|
||||
},
|
||||
"Purchase Order Item": {
|
||||
"ref_dn_field": "prevdoc_detail_docname",
|
||||
"ref_dn_field": "purchase_order_item",
|
||||
"compare_fields": [["project", "="], ["uom", "="], ["item_code", "="]],
|
||||
"is_child_table": True
|
||||
}
|
||||
})
|
||||
|
||||
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')) and not self.is_return:
|
||||
self.validate_rate_with_reference_doc([["Purchase Order", "prevdoc_docname", "prevdoc_detail_docname"]])
|
||||
self.validate_rate_with_reference_doc([["Purchase Order", "purchase_order", "purchase_order_item"]])
|
||||
|
||||
def po_required(self):
|
||||
if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':
|
||||
for d in self.get('items'):
|
||||
if not d.prevdoc_docname:
|
||||
if not d.purchase_order:
|
||||
frappe.throw(_("Purchase Order number required for Item {0}").format(d.item_code))
|
||||
|
||||
def get_already_received_qty(self, po, po_detail):
|
||||
qty = frappe.db.sql("""select sum(qty) from `tabPurchase Receipt Item`
|
||||
where prevdoc_detail_docname = %s and docstatus = 1
|
||||
and prevdoc_doctype='Purchase Order' and prevdoc_docname=%s
|
||||
where purchase_order_item = %s and docstatus = 1
|
||||
and purchase_order=%s
|
||||
and parent != %s""", (po_detail, po, self.name))
|
||||
return qty and flt(qty[0][0]) or 0.0
|
||||
|
||||
@ -115,9 +114,9 @@ class PurchaseReceipt(BuyingController):
|
||||
def check_for_closed_status(self, pc_obj):
|
||||
check_list =[]
|
||||
for d in self.get('items'):
|
||||
if d.meta.get_field('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
|
||||
check_list.append(d.prevdoc_docname)
|
||||
pc_obj.check_for_closed_status(d.prevdoc_doctype, d.prevdoc_docname)
|
||||
if d.meta.get_field('purchase_order') and d.purchase_order and d.purchase_order not in check_list:
|
||||
check_list.append(d.purchase_order)
|
||||
pc_obj.check_for_closed_status('Purchase Order', d.purchase_order)
|
||||
|
||||
# on submit
|
||||
def on_submit(self):
|
||||
@ -335,8 +334,8 @@ class PurchaseReceipt(BuyingController):
|
||||
def update_billing_status(self, update_modified=True):
|
||||
updated_pr = [self.name]
|
||||
for d in self.get("items"):
|
||||
if d.prevdoc_detail_docname:
|
||||
updated_pr += update_billed_amount_based_on_po(d.prevdoc_detail_docname, update_modified)
|
||||
if d.purchase_order_item:
|
||||
updated_pr += update_billed_amount_based_on_po(d.purchase_order_item, update_modified)
|
||||
|
||||
for pr in set(updated_pr):
|
||||
pr_doc = self if (pr == self.name) else frappe.get_doc("Purchase Receipt", pr)
|
||||
@ -353,7 +352,7 @@ def update_billed_amount_based_on_po(po_detail, update_modified=True):
|
||||
# Get all Delivery Note Item rows against the Sales Order Item row
|
||||
pr_details = frappe.db.sql("""select pr_item.name, pr_item.amount, pr_item.parent
|
||||
from `tabPurchase Receipt Item` pr_item, `tabPurchase Receipt` pr
|
||||
where pr.name=pr_item.parent and pr_item.prevdoc_detail_docname=%s
|
||||
where pr.name=pr_item.parent and pr_item.purchase_order_item=%s
|
||||
and pr.docstatus=1 and pr.is_return = 0
|
||||
order by pr.posting_date asc, pr.posting_time asc, pr.name asc""", po_detail, as_dict=1)
|
||||
|
||||
@ -409,8 +408,8 @@ def make_purchase_invoice(source_name, target_doc=None):
|
||||
"field_map": {
|
||||
"name": "pr_detail",
|
||||
"parent": "purchase_receipt",
|
||||
"prevdoc_detail_docname": "po_detail",
|
||||
"prevdoc_docname": "purchase_order",
|
||||
"purchase_order_item": "po_detail",
|
||||
"purchase_order": "purchase_order",
|
||||
},
|
||||
"postprocess": update_item,
|
||||
"filter": lambda d: abs(d.qty) - abs(invoiced_qty_map.get(d.name, 0))<=0
|
||||
|
@ -3,6 +3,7 @@
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"autoname": "hash",
|
||||
"beta": 0,
|
||||
"creation": "2013-05-24 19:29:10",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
@ -1077,7 +1078,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "prevdoc_docname",
|
||||
"fieldname": "purchase_order",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
@ -1362,40 +1363,14 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "prevdoc_doctype",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Prevdoc Doctype",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "prevdoc_doctype",
|
||||
"oldfieldtype": "Data",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "prevdoc_detail_docname",
|
||||
"fieldname": "purchase_order_item",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Purchase Order Item No",
|
||||
"label": "Purchase Order Item",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "prevdoc_detail_docname",
|
||||
@ -1709,20 +1684,23 @@
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"idx": 1,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"in_dialog": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-03-18 05:11:15.937267",
|
||||
"modified": "2016-07-04 17:56:02.163486",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Purchase Receipt Item",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"quick_entry": 1,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
"sort_order": "DESC",
|
||||
"track_seen": 0
|
||||
}
|
Loading…
Reference in New Issue
Block a user