diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 4b33f104f01..7ad50d50e58 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -64,6 +64,7 @@ class SalesInvoice(SellingController):
self.validate_pos()
if cint(self.update_stock):
+ self.validate_dropship_item()
self.validate_item_code()
self.validate_warehouse()
self.update_current_stock()
@@ -409,6 +410,12 @@ class SalesInvoice(SellingController):
if self.c_form_applicable == 'Yes' and self.c_form_no:
msgprint(_("Please remove this Invoice {0} from C-Form {1}")
.format(self.name, self.c_form_no), raise_exception = 1)
+
+ def validate_dropship_item(self):
+ for item in self.items:
+ if item.sales_order:
+ if frappe.db.get_value("Sales Order Item", item.so_detail, "delivered_by_supplier"):
+ frappe.throw(_("Could not update stock, invoice contains drop shipping item."))
def update_current_stock(self):
for d in self.get('items'):
diff --git a/erpnext/buying/print_format/drop_shipping/drop_shipping.json b/erpnext/buying/print_format/drop_shipping/drop_shipping.json
deleted file mode 100644
index 0af9a2425c3..00000000000
--- a/erpnext/buying/print_format/drop_shipping/drop_shipping.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "creation": "2015-10-20 16:46:39.382799",
- "custom_format": 0,
- "disabled": 0,
- "doc_type": "Purchase Order",
- "docstatus": 0,
- "doctype": "Print Format",
- "font": "Default",
- "format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"HTML\", \"options\": \"
\n
\n\t\t
Purchase Order
\n\t {{doc.name}}\n
\n \n
\n
\n
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t{{doc.supplier_name}}\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t{% if doc.address_display %}\n\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t{{doc.address_display}}\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t{%- endif -%}\n\t\t\t\t{% if doc.contact_display %}\n\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t{{doc.contact_display}}\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t{%- endif -%}\n\t\t\t\t{% if doc.contact_mobile %}\n\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t{{doc.contact_mobile}}\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t{%- endif -%}\n
\n \n
\n
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t{{doc.transaction_date}}\n\t\t\t\t
\n\t\t\t
\n
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t{{doc.customer_name}}\n\t\t\t\t
\n\t\t\t
\n\t\t\t{% if doc.customer_address_display %}\n\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t{{doc.customer_address_display}}\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t{%- endif -%}\n\t\t\t{% if doc.customer_contact_display %}\n\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t{{doc.customer_contact_display}}\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t{%- endif -%}\n\t\t\t{% if doc.customer_contact_mobile %}\n\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t{{doc.customer_contact_mobile}}\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t{%- endif -%}\n
\n
\n\t
\n\t\t\n\t\t\t\n\t\t\t\t| Sr | \n\t\t\t\tItem Name | \n\t\t\t\tDescription | \n\t\t\t\tQty | \n\t\t\t\tRate | \n\t\t\t\tAmount | \n\t\t\t
\n\t\t\t{%- for row in doc.items -%}\n\t\t\t\n\t\t\t\t| {{ row.idx }} | \n\t\t\t\t\n\t\t\t\t\t{{ row.item_name }}\n\t\t\t\t\t{% if row.item_code != row.item_name -%}\n\t\t\t\t\t Item Code: {{ row.item_code}}\n\t\t\t\t\t{%- endif %}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t {{ row.description }} | \n\t\t\t\t{{ row.qty }} {{ row.uom or row.stock_uom }} | \n\t\t\t\t{{\n\t\t\t\t\trow.get_formatted(\"rate\", doc) }} | \n\t\t\t\t{{\n\t\t\t\t\trow.get_formatted(\"amount\", doc) }} | \n\t\t\t
\n\t\t\t{%- endfor -%}\n\t\t\n\t
\n
\n
\n
\n
\n
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t{{doc.total}}\n\t\t\t\t\t
\n\t\t\t\t
\n
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t{{doc.grand_total}}\n\t\t\t\t\t
\n\t\t\t\t
\n
\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t{{doc.in_words}}\n\t\t\t\t\t
\n\t\t\t\t
\n
\n
\n
",
+ "idx": 0,
+ "modified": "2015-12-04 13:47:55.157482",
+ "modified_by": "Administrator",
+ "name": "Drop Shipping Format",
+ "owner": "Administrator",
+ "print_format_builder": 0,
+ "print_format_type": "Server",
+ "standard": "Yes"
+}
\ No newline at end of file
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 66ca31e916d..05cb50c5218 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -531,8 +531,14 @@ def make_purchase_order_for_drop_shipment(source_name, for_supplier, target_doc=
default_price_list = frappe.get_value("Supplier", for_supplier, "default_price_list")
if default_price_list:
target.buying_price_list = default_price_list
+
+ if source.shipping_address_name:
+ target.customer_address = source.shipping_address_name
+ target.customer_address_display = source.shipping_address
+ else:
+ target.customer_address = source.customer_address
+ target.customer_address_display = source.address_display
- target.delivered_by_supplier = 1
target.run_method("set_missing_values")
target.run_method("calculate_taxes_and_totals")
@@ -544,9 +550,7 @@ def make_purchase_order_for_drop_shipment(source_name, for_supplier, target_doc=
"Sales Order": {
"doctype": "Purchase Order",
"field_map": {
- "customer_address": "customer_address",
"contact_person": "customer_contact_person",
- "address_display": "customer_address_display",
"contact_display": "customer_contact_display",
"contact_mobile": "customer_contact_mobile",
"contact_email": "customer_contact_email",