[enhance] make PO from SO if supplier is specified
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 60fdc1a..11cd5d8 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -668,7 +668,7 @@
"so_detail": "so_detail"
},
"postprocess": update_item,
- "condition": lambda doc: doc.is_drop_ship!=1
+ "condition": lambda doc: (doc.is_drop_ship!=1 and not doc.supplier)
},
"Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges",
diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
index c8a65f5..44f69cb 100644
--- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
+++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
@@ -683,7 +683,8 @@
{
"allow_on_submit": 0,
"bold": 0,
- "collapsible": 0,
+ "collapsible": 1,
+ "collapsible_depends_on": "eval:doc.is_drop_ship==1",
"fieldname": "drop_ship",
"fieldtype": "Section Break",
"hidden": 0,
@@ -1370,8 +1371,8 @@
"is_submittable": 0,
"issingle": 0,
"istable": 1,
- "modified": "2015-10-19 03:04:52.093181",
- "modified_by": "Administrator",
+ "modified": "2015-10-20 15:54:03.318846",
+ "modified_by": "saurabh6790@gmail.com",
"module": "Accounts",
"name": "Sales Invoice Item",
"owner": "Administrator",
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index 0861f37..f7a0939 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -221,7 +221,7 @@
else:
if self.doctype=="Delivery Note":
- args["drop_ship_cond"] = " and is_drop_ship!=1 "
+ args["drop_ship_cond"] = " and is_drop_ship!=1 and supplier = '' "
for name in unique_transactions:
if not name:
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 69ec248..630494a 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -31,6 +31,7 @@
self.validate_uom_is_integer("stock_uom", "qty")
self.validate_for_items()
self.validate_warehouse()
+ self.validate_drop_ship()
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
make_packing_list(self)
@@ -147,6 +148,11 @@
doc.set_status(update=True)
doc.update_opportunity()
+ def validate_drop_ship(self):
+ for d in self.get('items'):
+ if d.is_drop_ship and not d.supplier:
+ frappe.throw(_("#{0} Set Supplier for item {1}").format(d.idx, d.item_code))
+
def on_submit(self):
super(SalesOrder, self).on_submit()
@@ -252,6 +258,9 @@
def on_update(self):
pass
+
+ def before_update_after_submit(self):
+ self.validate_drop_ship()
def get_list_context(context=None):
from erpnext.controllers.website_list_for_contact import get_list_context
@@ -350,7 +359,7 @@
"parent": "against_sales_order",
},
"postprocess": update_item,
- "condition": lambda doc: doc.delivered_qty < doc.qty and doc.is_drop_ship!=1
+ "condition": lambda doc: doc.delivered_qty < doc.qty and (doc.is_drop_ship!=1 and not doc.supplier)
},
"Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges",
@@ -378,6 +387,7 @@
target.run_method("calculate_taxes_and_totals")
def update_item(source, target, source_parent):
+ target.supplier = source.supplier
target.amount = flt(source.amount) - flt(source.billed_amt)
target.base_amount = target.amount * flt(source_parent.conversion_rate)
target.qty = target.amount / flt(source.rate) if (source.rate and source.billed_amt) else source.qty
@@ -538,7 +548,7 @@
["delivery_date", "schedule_date"]
],
"postprocess": update_item,
- "condition": lambda doc: doc.ordered_qty < doc.qty and doc.is_drop_ship==1 and doc.supplier == for_supplier
+ "condition": lambda doc: doc.ordered_qty < doc.qty and doc.supplier == for_supplier or (doc.is_drop_ship==1 and doc.supplier == for_supplier)
},
"Sales Taxes and Charges": {
"doctype": "Purchase Taxes and Charges",