[fixes] dropship fixes

This commit is contained in:
Saurabh 2015-11-17 22:14:02 +05:30
parent b73f3da02c
commit caf122f015
4 changed files with 1183 additions and 1151 deletions

View File

@ -18,9 +18,25 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
var me = this;
this._super();
// this.frm.dashboard.reset();
var allow_receipt = false;
var allow_delivery = false;
for (var i in cur_frm.doc.items) {
var item = cur_frm.doc.items[i];
if(item.delivered_by_supplier !== 1) {
allow_receipt = true;
}
if(item.delivered_by_supplier === 1) {
allow_delivery = true
}
if(allow_delivery && allow_receipt) {
break;
}
}
if(doc.docstatus == 1 && !in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
if (this.frm.has_perm("submit")) {
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) {
cur_frm.add_custom_button(__('Stop'), this.stop_purchase_order);
@ -29,7 +45,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
cur_frm.add_custom_button(__('Close'), this.close_purchase_order);
}
if(doc.delivered_by_supplier && doc.status!="Delivered"){
if(allow_delivery && doc.status!="Delivered"){
cur_frm.add_custom_button(__('Mark as Delivered'), this.delivered_by_supplier);
}
@ -37,7 +53,12 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry);
}
if(flt(doc.per_received, 2) < 100 && this.frm.doc.__onload.has_stock_item) {
} else if(doc.docstatus===0) {
cur_frm.cscript.add_from_mappers();
}
if(doc.docstatus == 1 && !in_list(["Stopped", "Closed"], doc.status)) {
if(flt(doc.per_received, 2) < 100 && this.frm.doc.__onload.has_stock_item && allow_receipt) {
cur_frm.add_custom_button(__('Receive'), this.make_purchase_receipt).addClass("btn-primary");
if(doc.is_subcontracted==="Yes") {
@ -47,13 +68,9 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
}
if(flt(doc.per_billed, 2) < 100)
cur_frm.add_custom_button(__('Invoice'), this.make_purchase_invoice);
} else if(doc.docstatus===0) {
cur_frm.cscript.add_from_mappers();
cur_frm.add_custom_button(__('Invoice'), this.make_purchase_invoice);
}
if(doc.docstatus == 1 && in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
if (this.frm.has_perm("submit")) {
cur_frm.add_custom_button(__('Re-open'), this.unstop_purchase_order);

View File

@ -330,8 +330,8 @@
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
"collapsible_depends_on": "delivered_by_supplier",
"collapsible": 0,
"collapsible_depends_on": "",
"fieldname": "drop_ship",
"fieldtype": "Section Break",
"hidden": 0,
@ -354,7 +354,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"depends_on": "delivered_by_supplier",
"depends_on": "",
"fieldname": "customer",
"fieldtype": "Link",
"hidden": 0,
@ -378,7 +378,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"depends_on": "delivered_by_supplier",
"depends_on": "",
"fieldname": "customer_name",
"fieldtype": "Data",
"hidden": 0,
@ -397,28 +397,6 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "delivered_by_supplier",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "To be delivered to customer",
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -444,7 +422,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"depends_on": "delivered_by_supplier",
"depends_on": "",
"fieldname": "customer_address",
"fieldtype": "Link",
"hidden": 0,
@ -468,7 +446,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"depends_on": "delivered_by_supplier",
"depends_on": "",
"fieldname": "customer_contact_person",
"fieldtype": "Link",
"hidden": 0,
@ -2283,7 +2261,7 @@
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"modified": "2015-11-04 04:44:22.025827",
"modified": "2015-11-17 14:40:16.374394",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order",

View File

@ -51,6 +51,7 @@ class PurchaseOrder(BuyingController):
self.validate_for_subcontracting()
self.validate_minimum_order_qty()
self.create_raw_materials_supplied("supplied_items")
self.set_received_qtyand_billed_amount_for_drop_ship_items()
def validate_with_previous_doc(self):
super(PurchaseOrder, self).validate_with_previous_doc({
@ -164,13 +165,13 @@ class PurchaseOrder(BuyingController):
clear_doctype_notifications(self)
def on_submit(self):
if self.delivered_by_supplier == 1:
if self.is_drop_ship_item():
self.update_status_updater()
super(PurchaseOrder, self).on_submit()
purchase_controller = frappe.get_doc("Purchase Common")
self.update_prevdoc_status()
self.update_requested_qty()
self.update_ordered_qty()
@ -181,7 +182,7 @@ class PurchaseOrder(BuyingController):
purchase_controller.update_last_purchase_rate(self, is_submit = 1)
def on_cancel(self):
if self.delivered_by_supplier == 1:
if self.is_drop_ship_item():
self.update_status_updater()
pc_obj = frappe.get_doc('Purchase Common')
@ -234,7 +235,7 @@ 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":
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)
@ -244,6 +245,21 @@ class PurchaseOrder(BuyingController):
so.set_status(update=True)
so.notify_update()
def is_drop_ship_item(self):
is_drop_ship = False
for item in self.items:
if item.delivered_by_supplier == 1:
is_drop_ship = True
return is_drop_ship
def set_received_qtyand_billed_amount_for_drop_ship_items(self):
for item in self.items:
if item.delivered_by_supplier == 1:
item.received_qty = item.qty
item.billed_amt = item.amount
@frappe.whitelist()
def stop_or_unstop_purchase_orders(names, status):
if not frappe.has_permission("Purchase Order", "write"):
@ -262,7 +278,6 @@ def stop_or_unstop_purchase_orders(names, status):
frappe.local.message_log = []
def set_missing_values(source, target):
target.ignore_pricing_rule = 1
target.run_method("set_missing_values")
@ -292,7 +307,7 @@ def make_purchase_receipt(source_name, target_doc=None):
"parenttype": "prevdoc_doctype",
},
"postprocess": update_item,
"condition": lambda doc: doc.received_qty < doc.qty
"condition": lambda doc: doc.received_qty < doc.qty and doc.delivered_by_supplier!=1
},
"Purchase Taxes and Charges": {
"doctype": "Purchase Taxes and Charges",
@ -328,7 +343,7 @@ def make_purchase_invoice(source_name, target_doc=None):
"parent": "purchase_order",
},
"postprocess": update_item,
"condition": lambda doc: doc.base_amount==0 or doc.billed_amt < doc.amount
"condition": lambda doc: (doc.base_amount==0 or doc.billed_amt < doc.amount) and doc.delivered_by_supplier!=1
},
"Purchase Taxes and Charges": {
"doctype": "Purchase Taxes and Charges",