[fixes] dropship fixes
This commit is contained in:
parent
b73f3da02c
commit
caf122f015
@ -18,9 +18,25 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
var me = this;
|
var me = this;
|
||||||
this._super();
|
this._super();
|
||||||
// this.frm.dashboard.reset();
|
// 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(doc.docstatus == 1 && !in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
|
||||||
|
|
||||||
if (this.frm.has_perm("submit")) {
|
if (this.frm.has_perm("submit")) {
|
||||||
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) {
|
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) {
|
||||||
cur_frm.add_custom_button(__('Stop'), this.stop_purchase_order);
|
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);
|
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);
|
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);
|
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");
|
cur_frm.add_custom_button(__('Receive'), this.make_purchase_receipt).addClass("btn-primary");
|
||||||
|
|
||||||
if(doc.is_subcontracted==="Yes") {
|
if(doc.is_subcontracted==="Yes") {
|
||||||
@ -48,10 +69,6 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
|
|
||||||
if(flt(doc.per_billed, 2) < 100)
|
if(flt(doc.per_billed, 2) < 100)
|
||||||
cur_frm.add_custom_button(__('Invoice'), this.make_purchase_invoice);
|
cur_frm.add_custom_button(__('Invoice'), this.make_purchase_invoice);
|
||||||
|
|
||||||
|
|
||||||
} else if(doc.docstatus===0) {
|
|
||||||
cur_frm.cscript.add_from_mappers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.docstatus == 1 && in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
|
if(doc.docstatus == 1 && in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
|
||||||
|
@ -330,8 +330,8 @@
|
|||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 1,
|
"collapsible": 0,
|
||||||
"collapsible_depends_on": "delivered_by_supplier",
|
"collapsible_depends_on": "",
|
||||||
"fieldname": "drop_ship",
|
"fieldname": "drop_ship",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -354,7 +354,7 @@
|
|||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"depends_on": "delivered_by_supplier",
|
"depends_on": "",
|
||||||
"fieldname": "customer",
|
"fieldname": "customer",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -378,7 +378,7 @@
|
|||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"depends_on": "delivered_by_supplier",
|
"depends_on": "",
|
||||||
"fieldname": "customer_name",
|
"fieldname": "customer_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -397,28 +397,6 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 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,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -444,7 +422,7 @@
|
|||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"depends_on": "delivered_by_supplier",
|
"depends_on": "",
|
||||||
"fieldname": "customer_address",
|
"fieldname": "customer_address",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -468,7 +446,7 @@
|
|||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"depends_on": "delivered_by_supplier",
|
"depends_on": "",
|
||||||
"fieldname": "customer_contact_person",
|
"fieldname": "customer_contact_person",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -2283,7 +2261,7 @@
|
|||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"modified": "2015-11-04 04:44:22.025827",
|
"modified": "2015-11-17 14:40:16.374394",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order",
|
"name": "Purchase Order",
|
||||||
|
@ -51,6 +51,7 @@ class PurchaseOrder(BuyingController):
|
|||||||
self.validate_for_subcontracting()
|
self.validate_for_subcontracting()
|
||||||
self.validate_minimum_order_qty()
|
self.validate_minimum_order_qty()
|
||||||
self.create_raw_materials_supplied("supplied_items")
|
self.create_raw_materials_supplied("supplied_items")
|
||||||
|
self.set_received_qtyand_billed_amount_for_drop_ship_items()
|
||||||
|
|
||||||
def validate_with_previous_doc(self):
|
def validate_with_previous_doc(self):
|
||||||
super(PurchaseOrder, self).validate_with_previous_doc({
|
super(PurchaseOrder, self).validate_with_previous_doc({
|
||||||
@ -164,7 +165,7 @@ class PurchaseOrder(BuyingController):
|
|||||||
clear_doctype_notifications(self)
|
clear_doctype_notifications(self)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if self.delivered_by_supplier == 1:
|
if self.is_drop_ship_item():
|
||||||
self.update_status_updater()
|
self.update_status_updater()
|
||||||
|
|
||||||
super(PurchaseOrder, self).on_submit()
|
super(PurchaseOrder, self).on_submit()
|
||||||
@ -181,7 +182,7 @@ class PurchaseOrder(BuyingController):
|
|||||||
purchase_controller.update_last_purchase_rate(self, is_submit = 1)
|
purchase_controller.update_last_purchase_rate(self, is_submit = 1)
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
if self.delivered_by_supplier == 1:
|
if self.is_drop_ship_item():
|
||||||
self.update_status_updater()
|
self.update_status_updater()
|
||||||
|
|
||||||
pc_obj = frappe.get_doc('Purchase Common')
|
pc_obj = frappe.get_doc('Purchase Common')
|
||||||
@ -234,7 +235,7 @@ class PurchaseOrder(BuyingController):
|
|||||||
"""Update delivered qty in Sales Order for drop ship"""
|
"""Update delivered qty in Sales Order for drop ship"""
|
||||||
sales_orders_to_update = []
|
sales_orders_to_update = []
|
||||||
for item in self.items:
|
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:
|
if item.prevdoc_docname not in sales_orders_to_update:
|
||||||
sales_orders_to_update.append(item.prevdoc_docname)
|
sales_orders_to_update.append(item.prevdoc_docname)
|
||||||
|
|
||||||
@ -244,6 +245,21 @@ class PurchaseOrder(BuyingController):
|
|||||||
so.set_status(update=True)
|
so.set_status(update=True)
|
||||||
so.notify_update()
|
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()
|
@frappe.whitelist()
|
||||||
def stop_or_unstop_purchase_orders(names, status):
|
def stop_or_unstop_purchase_orders(names, status):
|
||||||
if not frappe.has_permission("Purchase Order", "write"):
|
if not frappe.has_permission("Purchase Order", "write"):
|
||||||
@ -262,7 +278,6 @@ def stop_or_unstop_purchase_orders(names, status):
|
|||||||
|
|
||||||
frappe.local.message_log = []
|
frappe.local.message_log = []
|
||||||
|
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
target.ignore_pricing_rule = 1
|
target.ignore_pricing_rule = 1
|
||||||
target.run_method("set_missing_values")
|
target.run_method("set_missing_values")
|
||||||
@ -292,7 +307,7 @@ def make_purchase_receipt(source_name, target_doc=None):
|
|||||||
"parenttype": "prevdoc_doctype",
|
"parenttype": "prevdoc_doctype",
|
||||||
},
|
},
|
||||||
"postprocess": update_item,
|
"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": {
|
"Purchase Taxes and Charges": {
|
||||||
"doctype": "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",
|
"parent": "purchase_order",
|
||||||
},
|
},
|
||||||
"postprocess": update_item,
|
"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": {
|
"Purchase Taxes and Charges": {
|
||||||
"doctype": "Purchase Taxes and Charges",
|
"doctype": "Purchase Taxes and Charges",
|
||||||
|
@ -960,6 +960,28 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 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,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -1201,7 +1223,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-10-19 03:04:51.773012",
|
"modified": "2015-11-17 14:38:10.984627",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order Item",
|
"name": "Purchase Order Item",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user