[#2164] New field names in DN, fix field name refs, Patch added

This commit is contained in:
ankitjavalkarwork 2014-10-08 12:46:02 +05:30
parent 9aadb0d95d
commit e69a611991
8 changed files with 28 additions and 14 deletions

View File

@ -131,7 +131,7 @@ class SalesInvoice(SellingController):
'keyword':'Delivered',
'second_source_dt': 'Delivery Note Item',
'second_source_field': 'qty',
'second_join_field': 'prevdoc_detail_docname',
'second_join_field': 'so_detail',
'overflow_type': 'delivery',
'extra_cond': """ and exists(select name from `tabSales Invoice`
where name=`tabSales Invoice Item`.parent and ifnull(update_stock, 0) = 1)"""
@ -633,7 +633,7 @@ def make_delivery_note(source_name, target_doc=None):
"parent": "against_sales_invoice",
"serial_no": "serial_no",
"sales_order": "against_sales_order",
"so_detail": "prevdoc_detail_docname"
"so_detail": "so_detail"
},
"postprocess": update_item
},

View File

@ -334,8 +334,8 @@ class SellingController(StockController):
# But in this case reserved qty should only be reduced by 10 and not 12
already_delivered_qty = self.get_already_delivered_qty(self.name,
d.against_sales_order, d.prevdoc_detail_docname)
so_qty, reserved_warehouse = self.get_so_qty_and_warehouse(d.prevdoc_detail_docname)
d.against_sales_order, d.so_detail)
so_qty, reserved_warehouse = self.get_so_qty_and_warehouse(d.so_detail)
if already_delivered_qty + d.qty > so_qty:
reserved_qty_for_main_item = -(so_qty - already_delivered_qty)
@ -377,7 +377,7 @@ class SellingController(StockController):
def get_already_delivered_qty(self, dn, so, so_detail):
qty = frappe.db.sql("""select sum(qty) from `tabDelivery Note Item`
where prevdoc_detail_docname = %s and docstatus = 1
where so_detail = %s and docstatus = 1
and against_sales_order = %s
and parent != %s""", (so_detail, so, dn))
return qty and flt(qty[0][0]) or 0.0

View File

@ -84,3 +84,4 @@ erpnext.patches.v4_2.cost_of_production_cycle
erpnext.patches.v4_2.seprate_manufacture_and_repack
erpnext.patches.v4_2.party_model
erpnext.patches.v5_0.update_frozen_accounts_permission_role
erpnext.patches.v5_0.update_dn_against_doc_fields

View File

@ -0,0 +1,13 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
def execute():
frappe.reload_doc('stock', 'doctype', 'delivery_note_item')
frappe.db.sql("""update `tabDelivery Note Item` set so_detail = prevdoc_detail_docname
where ifnull(against_sales_order, '') != ''""")
frappe.db.sql("""update `tabDelivery Note Item` set si_detail = prevdoc_detail_docname
where ifnull(against_sales_invoice, '') != ''""")

View File

@ -294,7 +294,7 @@ def make_delivery_note(source_name, target_doc=None):
"doctype": "Delivery Note Item",
"field_map": {
"rate": "rate",
"name": "prevdoc_detail_docname",
"name": "so_detail",
"parent": "against_sales_order",
},
"postprocess": update_item,

View File

@ -85,7 +85,7 @@ class TestSalesOrder(unittest.TestCase):
dn = frappe.get_doc(frappe.copy_doc(dn_test_records[0]))
dn.get("delivery_note_details")[0].item_code = so.get("sales_order_details")[0].item_code
dn.get("delivery_note_details")[0].against_sales_order = so.name
dn.get("delivery_note_details")[0].prevdoc_detail_docname = so.get("sales_order_details")[0].name
dn.get("delivery_note_details")[0].so_detail = so.get("sales_order_details")[0].name
if delivered_qty:
dn.get("delivery_note_details")[0].qty = delivered_qty
dn.insert()

View File

@ -25,7 +25,7 @@ class DeliveryNote(SellingController):
self.status_updater = [{
'source_dt': 'Delivery Note Item',
'target_dt': 'Sales Order Item',
'join_field': 'prevdoc_detail_docname',
'join_field': 'so_detail',
'target_field': 'delivered_qty',
'target_parent_dt': 'Sales Order',
'target_parent_field': 'per_delivered',
@ -129,7 +129,7 @@ class DeliveryNote(SellingController):
if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')):
super(DeliveryNote, self).validate_with_previous_doc(self.tname, {
fn[0] + " Item": {
"ref_dn_field": "prevdoc_detail_docname",
"ref_dn_field": "so_detail",
"compare_fields": [["rate", "="]],
"is_child_table": True
}
@ -328,7 +328,7 @@ def make_sales_invoice(source_name, target_doc=None):
"field_map": {
"name": "dn_detail",
"parent": "delivery_note",
"prevdoc_detail_docname": "so_detail",
"so_detail": "so_detail",
"against_sales_order": "sales_order",
"serial_no": "serial_no"
},

View File

@ -373,11 +373,11 @@
"read_only": 1
},
{
"fieldname": "prevdoc_detail_docname",
"fieldname": "so_detail",
"fieldtype": "Data",
"hidden": 1,
"in_filter": 1,
"label": "Against Document Detail No",
"label": "Against Sales Order Item",
"no_copy": 1,
"oldfieldname": "prevdoc_detail_docname",
"oldfieldtype": "Data",
@ -393,7 +393,7 @@
"fieldtype": "Data",
"hidden": 1,
"in_filter": 1,
"label": "SI Detail",
"label": "Against Sales Invoice Item",
"no_copy": 1,
"permlevel": 0,
"precision": "",
@ -438,7 +438,7 @@
],
"idx": 1,
"istable": 1,
"modified": "2014-10-07 18:18:04.375810",
"modified": "2014-10-08 11:11:59.411329",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note Item",