mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
Merge branch 'wsgi' of https://github.com/webnotes/erpnext into i18n
Conflicts: accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js public/js/complete_setup.js selling/doctype/opportunity/opportunity.js selling/doctype/quotation/quotation.js
This commit is contained in:
@@ -11,6 +11,7 @@ cur_frm.cscript.sales_team_fname = "sales_team";
|
||||
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
|
||||
wn.require('app/utilities/doctype/sms_control/sms_control.js');
|
||||
wn.require('app/selling/doctype/sales_common/sales_common.js');
|
||||
wn.require('app/accounts/doctype/sales_invoice/pos.js');
|
||||
|
||||
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
onload: function(doc, dt, dn) {
|
||||
@@ -23,20 +24,18 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
},
|
||||
refresh: function(doc, dt, dn) {
|
||||
this._super(doc, dt, dn);
|
||||
|
||||
cur_frm.dashboard.reset(doc);
|
||||
if(!doc.__islocal) {
|
||||
if(doc.status=="Converted" || doc.status=="Order Confirmed") {
|
||||
cur_frm.dashboard.set_headline_alert(wn._(doc.status), "alert-success", "icon-ok-sign");
|
||||
} else if(doc.status==="Order Lost") {
|
||||
cur_frm.dashboard.set_headline_alert(wn._(doc.status), "alert-danger", "icon-exclamation-sign");
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
if(doc.docstatus == 1 && doc.status!=='Order Lost') {
|
||||
cur_frm.add_custom_button(wn._('Make Sales Order'), cur_frm.cscript['Make Sales Order']);
|
||||
if(doc.status!=="Order Confirmed") {
|
||||
cur_frm.add_custom_button(wn._('Set as Lost'), cur_frm.cscript['Declare Order Lost']);
|
||||
=======
|
||||
if(doc.docstatus == 1 && doc.status!=='Lost') {
|
||||
cur_frm.add_custom_button('Make Sales Order', cur_frm.cscript['Make Sales Order']);
|
||||
if(doc.status!=="Ordered") {
|
||||
cur_frm.add_custom_button('Set as Lost', cur_frm.cscript['Declare Order Lost']);
|
||||
>>>>>>> f146e8b7f52a3e46e335c0fefd92c347717b370b
|
||||
}
|
||||
cur_frm.add_custom_button(wn._('Send SMS'), cur_frm.cscript.send_sms);
|
||||
}
|
||||
@@ -82,12 +81,12 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
},
|
||||
|
||||
validate_company_and_party: function(party_field) {
|
||||
if(this.frm.doc.quotation_to == "Lead") {
|
||||
return true;
|
||||
} else if(!this.frm.doc.quotation_to) {
|
||||
if(!this.frm.doc.quotation_to) {
|
||||
msgprint(wn._("Please select a value for" + " " + wn.meta.get_label(this.frm.doc.doctype,
|
||||
"quotation_to", this.frm.doc.name)));
|
||||
return false;
|
||||
} else if (this.frm.doc.quotation_to == "Lead") {
|
||||
return true;
|
||||
} else {
|
||||
return this._super(party_field);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cstr, getdate
|
||||
from webnotes.utils import cstr
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import _, msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
from controllers.selling_controller import SellingController
|
||||
@@ -48,17 +47,16 @@ class DocType(SellingController):
|
||||
if not doc.fields.get(r):
|
||||
doc.fields[r] = res[r]
|
||||
|
||||
|
||||
def has_sales_order(self):
|
||||
return webnotes.conn.get_value("Sales Order Item", {"prevdoc_docname": self.doc.name, "docstatus": 1})
|
||||
|
||||
|
||||
# Re-calculates Basic Rate & amount based on Price List Selected
|
||||
# --------------------------------------------------------------
|
||||
def get_adj_percent(self, arg=''):
|
||||
get_obj('Sales Common').get_adj_percent(self)
|
||||
|
||||
|
||||
# Get Tax rate if account type is TAX
|
||||
# -----------------------------------
|
||||
def get_rate(self,arg):
|
||||
return get_obj('Sales Common').get_rate(arg)
|
||||
|
||||
# Does not allow same item code to be entered twice
|
||||
# -------------------------------------------------
|
||||
def validate_for_items(self):
|
||||
@@ -78,7 +76,7 @@ class DocType(SellingController):
|
||||
|
||||
if self.doc.order_type in ['Maintenance', 'Service']:
|
||||
for d in getlist(self.doclist, 'quotation_details'):
|
||||
is_service_item = sql("select is_service_item from `tabItem` where name=%s", d.item_code)
|
||||
is_service_item = webnotes.conn.sql("select is_service_item from `tabItem` where name=%s", d.item_code)
|
||||
is_service_item = is_service_item and is_service_item[0][0] or 'No'
|
||||
|
||||
if is_service_item == 'No':
|
||||
@@ -86,37 +84,16 @@ class DocType(SellingController):
|
||||
raise Exception
|
||||
else:
|
||||
for d in getlist(self.doclist, 'quotation_details'):
|
||||
is_sales_item = sql("select is_sales_item from `tabItem` where name=%s", d.item_code)
|
||||
is_sales_item = webnotes.conn.sql("select is_sales_item from `tabItem` where name=%s", d.item_code)
|
||||
is_sales_item = is_sales_item and is_sales_item[0][0] or 'No'
|
||||
|
||||
if is_sales_item == 'No':
|
||||
msgprint("You can not select non sales item "+d.item_code+" in Sales Quotation")
|
||||
raise Exception
|
||||
|
||||
#--------------Validation For Last Contact Date-----------------
|
||||
# ====================================================================================================================
|
||||
def set_last_contact_date(self):
|
||||
#if not self.doc.contact_date_ref:
|
||||
#self.doc.contact_date_ref=self.doc.contact_date
|
||||
#self.doc.last_contact_date=self.doc.contact_date_ref
|
||||
if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date:
|
||||
if getdate(self.doc.contact_date_ref) < getdate(self.doc.contact_date):
|
||||
self.doc.last_contact_date=self.doc.contact_date_ref
|
||||
else:
|
||||
msgprint("Contact Date Cannot be before Last Contact Date")
|
||||
raise Exception
|
||||
|
||||
def validate(self):
|
||||
super(DocType, self).validate()
|
||||
|
||||
import utilities
|
||||
if not self.doc.status:
|
||||
self.doc.status = "Draft"
|
||||
else:
|
||||
utilities.validate_status(self.doc.status, ["Draft", "Submitted",
|
||||
"Order Confirmed", "Order Lost", "Cancelled"])
|
||||
|
||||
self.set_last_contact_date()
|
||||
self.set_status()
|
||||
self.validate_order_type()
|
||||
self.validate_for_items()
|
||||
|
||||
@@ -126,42 +103,22 @@ class DocType(SellingController):
|
||||
sales_com_obj.check_active_sales_items(self)
|
||||
sales_com_obj.validate_max_discount(self,'quotation_details')
|
||||
sales_com_obj.check_conversion_rate(self)
|
||||
|
||||
|
||||
def on_update(self):
|
||||
# Set Quotation Status
|
||||
webnotes.conn.set(self.doc, 'status', 'Draft')
|
||||
|
||||
|
||||
#update enquiry
|
||||
#------------------
|
||||
def update_enquiry(self, flag):
|
||||
prevdoc=''
|
||||
for d in getlist(self.doclist, 'quotation_details'):
|
||||
if d.prevdoc_docname:
|
||||
prevdoc = d.prevdoc_docname
|
||||
|
||||
if prevdoc:
|
||||
if flag == 'submit': #on submit
|
||||
sql("update `tabOpportunity` set status = 'Quotation Sent' where name = %s", prevdoc)
|
||||
elif flag == 'cancel': #on cancel
|
||||
sql("update `tabOpportunity` set status = 'Open' where name = %s", prevdoc)
|
||||
elif flag == 'order lost': #order lost
|
||||
sql("update `tabOpportunity` set status = 'Opportunity Lost' where name=%s", prevdoc)
|
||||
elif flag == 'order confirm': #order confirm
|
||||
sql("update `tabOpportunity` set status='Order Confirmed' where name=%s", prevdoc)
|
||||
def update_opportunity(self):
|
||||
for opportunity in self.doclist.get_distinct_values("prevdoc_docname"):
|
||||
webnotes.bean("Opportunity", opportunity).get_controller().set_status(update=True)
|
||||
|
||||
# declare as order lost
|
||||
#-------------------------
|
||||
def declare_order_lost(self, arg):
|
||||
chk = sql("select t1.name from `tabSales Order` t1, `tabSales Order Item` t2 where t2.parent = t1.name and t1.docstatus=1 and t2.prevdoc_docname = %s",self.doc.name)
|
||||
if chk:
|
||||
msgprint("Sales Order No. "+cstr(chk[0][0])+" is submitted against this Quotation. Thus 'Order Lost' can not be declared against it.")
|
||||
raise Exception
|
||||
else:
|
||||
webnotes.conn.set(self.doc, 'status', 'Order Lost')
|
||||
if not self.has_sales_order():
|
||||
webnotes.conn.set(self.doc, 'status', 'Lost')
|
||||
webnotes.conn.set(self.doc, 'order_lost_reason', arg)
|
||||
self.update_enquiry('order lost')
|
||||
return 'true'
|
||||
self.update_opportunity()
|
||||
else:
|
||||
webnotes.throw(_("Cannot set as Lost as Sales Order is made."))
|
||||
|
||||
#check if value entered in item table
|
||||
#--------------------------------------
|
||||
@@ -177,21 +134,17 @@ class DocType(SellingController):
|
||||
|
||||
# Check for Approving Authority
|
||||
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total, self)
|
||||
|
||||
# Set Quotation Status
|
||||
webnotes.conn.set(self.doc, 'status', 'Submitted')
|
||||
|
||||
|
||||
#update enquiry status
|
||||
self.update_enquiry('submit')
|
||||
self.update_opportunity()
|
||||
|
||||
|
||||
# ON CANCEL
|
||||
# ==========================================================================
|
||||
def on_cancel(self):
|
||||
#update enquiry status
|
||||
self.update_enquiry('cancel')
|
||||
|
||||
webnotes.conn.set(self.doc,'status','Cancelled')
|
||||
self.set_status()
|
||||
self.update_opportunity()
|
||||
|
||||
# Print other charges
|
||||
# ===========================================================================
|
||||
@@ -203,6 +156,7 @@ class DocType(SellingController):
|
||||
lst1.append(d.total)
|
||||
print_lst.append(lst1)
|
||||
return print_lst
|
||||
|
||||
|
||||
@webnotes.whitelist()
|
||||
def make_sales_order(source_name, target_doclist=None):
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:08",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-09-10 10:46:33",
|
||||
"modified": "2013-10-11 13:21:07",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
"allow_email": 0,
|
||||
"allow_import": 1,
|
||||
"autoname": "naming_series:",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Transaction",
|
||||
@@ -257,7 +258,6 @@
|
||||
"width": "100px"
|
||||
},
|
||||
{
|
||||
"default": "1.00",
|
||||
"description": "Rate at which customer's currency is converted to company's base currency",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "conversion_rate",
|
||||
@@ -733,7 +733,7 @@
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "status",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "\nDraft\nSubmitted\nOrder Confirmed\nOrder Lost\nCancelled",
|
||||
"options": "Draft\nSubmitted\nOrdered\nLost\nCancelled",
|
||||
"print_hide": 1,
|
||||
"read_only": 1,
|
||||
"reqd": 1,
|
||||
@@ -841,8 +841,7 @@
|
||||
"fieldtype": "Table",
|
||||
"hidden": 1,
|
||||
"label": "Communications",
|
||||
"options": "Communication",
|
||||
"print_hide": 1
|
||||
"options": "Communication"
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
|
||||
@@ -11,17 +11,19 @@ class TestQuotation(unittest.TestCase):
|
||||
def test_make_sales_order(self):
|
||||
from selling.doctype.quotation.quotation import make_sales_order
|
||||
|
||||
self.assertRaises(webnotes.ValidationError, make_sales_order, "_T-Quotation-00001")
|
||||
quotation = webnotes.bean(copy=test_records[0])
|
||||
quotation.insert()
|
||||
|
||||
self.assertRaises(webnotes.ValidationError, make_sales_order, quotation.doc.name)
|
||||
|
||||
quotation = webnotes.bean("Quotation","_T-Quotation-00001")
|
||||
quotation.submit()
|
||||
|
||||
sales_order = make_sales_order("_T-Quotation-00001")
|
||||
sales_order = make_sales_order(quotation.doc.name)
|
||||
|
||||
self.assertEquals(sales_order[0]["doctype"], "Sales Order")
|
||||
self.assertEquals(len(sales_order), 2)
|
||||
self.assertEquals(sales_order[1]["doctype"], "Sales Order Item")
|
||||
self.assertEquals(sales_order[1]["prevdoc_docname"], "_T-Quotation-00001")
|
||||
self.assertEquals(sales_order[1]["prevdoc_docname"], quotation.doc.name)
|
||||
self.assertEquals(sales_order[0]["customer"], "_Test Customer")
|
||||
|
||||
sales_order[0]["delivery_date"] = "2014-01-01"
|
||||
|
||||
Reference in New Issue
Block a user