Merge branch 'hotfix'

This commit is contained in:
Sahil Khan
2019-05-30 12:09:35 +05:30
6 changed files with 113 additions and 76 deletions

View File

@@ -1,20 +0,0 @@
include MANIFEST.in
include requirements.txt
include *.json
include *.md
include *.py
include *.txt
include .travis.yml
recursive-include erpnext *.txt
recursive-include erpnext *.css
recursive-include erpnext *.csv
recursive-include erpnext *.html
recursive-include erpnext *.ico
recursive-include erpnext *.js
recursive-include erpnext *.json
recursive-include erpnext *.md
recursive-include erpnext *.png
recursive-include erpnext *.py
recursive-include erpnext *.svg
recursive-include erpnext/public *
recursive-exclude * *.pyc

View File

@@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides from erpnext.hooks import regional_overrides
from frappe.utils import getdate from frappe.utils import getdate
__version__ = '11.1.34' __version__ = '11.1.35'
def get_default_company(user=None): def get_default_company(user=None):
'''Get default company for user''' '''Get default company for user'''

View File

@@ -288,14 +288,18 @@ def copy_attributes_to_variant(item, variant):
variant.variant_of = item.name variant.variant_of = item.name
if not variant.description:
variant.description = ""
if 'description' not in allow_fields: if 'description' not in allow_fields:
if item.variant_based_on == 'Item Attribute' and not variant.description: if not variant.description:
variant.description = "<div><b>" + item.name + "</b></div>" variant.description = ""
for d in variant.attributes:
variant.description += "<div><b>" + d.attribute + "</b>: " + cstr(d.attribute_value) + "</div>" if item.variant_based_on=='Item Attribute':
if variant.attributes:
attributes_description = item.description + " "
for d in variant.attributes:
attributes_description += "<div>" + d.attribute + ": " + cstr(d.attribute_value) + "</div>"
if attributes_description not in variant.description:
variant.description += attributes_description
def make_variant_item_code(template_item_code, template_item_name, variant): def make_variant_item_code(template_item_code, template_item_name, variant):
"""Uses template's item code and abbreviations to make variant's item code""" """Uses template's item code and abbreviations to make variant's item code"""

View File

@@ -316,19 +316,27 @@ class StatusUpdater(Document):
.format(frappe.db.escape(frappe.session.user)) .format(frappe.db.escape(frappe.session.user))
def update_billing_status_for_zero_amount_refdoc(self, ref_dt): def update_billing_status_for_zero_amount_refdoc(self, ref_dt):
ref_fieldname = ref_dt.lower().replace(" ", "_") ref_fieldname = frappe.scrub(ref_dt)
zero_amount_refdoc = []
all_zero_amount_refdoc = frappe.db.sql_list("""select name from `tab%s`
where docstatus=1 and base_net_total = 0""" % ref_dt)
for item in self.get("items"): ref_docs = [item.get(ref_fieldname) for item in (self.get('items') or []) if item.get(ref_fieldname)]
if item.get(ref_fieldname) \ if not ref_docs:
and item.get(ref_fieldname) in all_zero_amount_refdoc \ return
and item.get(ref_fieldname) not in zero_amount_refdoc:
zero_amount_refdoc.append(item.get(ref_fieldname))
if zero_amount_refdoc: zero_amount_refdocs = frappe.db.sql_list("""
self.update_billing_status(zero_amount_refdoc, ref_dt, ref_fieldname) SELECT
name
from
`tab{ref_dt}`
where
docstatus = 1
and base_net_total = 0
and name in %(ref_docs)s
""".format(ref_dt=ref_dt), {
'ref_docs': ref_docs
})
if zero_amount_refdocs:
self.update_billing_status(zero_amount_refdocs, ref_dt, ref_fieldname)
def update_billing_status(self, zero_amount_refdoc, ref_dt, ref_fieldname): def update_billing_status(self, zero_amount_refdoc, ref_dt, ref_fieldname):
for ref_dn in zero_amount_refdoc: for ref_dn in zero_amount_refdoc:

View File

@@ -115,21 +115,21 @@ def get_filter_conditions(filters):
def get_lead_quotation_count(leads): def get_lead_quotation_count(leads):
return frappe.db.sql("""select count(name) from `tabQuotation` return frappe.db.sql("""select count(name) from `tabQuotation`
where lead in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0] where quotation_to = 'Lead' and party_name in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0] #nosec
def get_lead_opp_count(leads): def get_lead_opp_count(leads):
return frappe.db.sql("""select count(name) from `tabOpportunity` return frappe.db.sql("""select count(name) from `tabOpportunity`
where lead in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0] where opportunity_from = 'Lead' and party_name in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0]
def get_quotation_ordered_count(leads): def get_quotation_ordered_count(leads):
return frappe.db.sql("""select count(name) return frappe.db.sql("""select count(name)
from `tabQuotation` where status = 'Ordered' from `tabQuotation` where status = 'Ordered' and quotation_to = 'Lead'
and lead in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0] and party_name in (%s)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0]
def get_order_amount(leads): def get_order_amount(leads):
return frappe.db.sql("""select sum(base_net_amount) return frappe.db.sql("""select sum(base_net_amount)
from `tabSales Order Item` from `tabSales Order Item`
where prevdoc_docname in ( where prevdoc_docname in (
select name from `tabQuotation` where status = 'Ordered' select name from `tabQuotation` where status = 'Ordered'
and lead in (%s) and quotation_to = 'Lead' and party_name in (%s)
)""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0] )""" % ', '.join(["%s"]*len(leads)), tuple(leads))[0][0]

View File

@@ -14,13 +14,58 @@ def execute(filters=None):
def get_columns(): def get_columns():
return [ return [
_("Lead Owner") + ":Data:130", {
_("Lead Count") + ":Int:80", "fieldname": "lead_owner",
_("Opp Count") + ":Int:80", "label": _("Lead Owner"),
_("Quot Count") + ":Int:80", "fieldtype": "Data",
_("Order Count") + ":Int:100", "width": "130"
_("Order Value") + ":Float:100", },
_("Opp/Lead %") + ":Float:100", {
_("Quot/Lead %") + ":Float:100", "fieldname": "lead_count",
_("Order/Quot %") + ":Float:100" "label": _("Lead Count"),
"fieldtype": "Int",
"width": "80"
},
{
"fieldname": "opp_count",
"label": _("Opp Count"),
"fieldtype": "Int",
"width": "80"
},
{
"fieldname": "quot_count",
"label": _("Quot Count"),
"fieldtype": "Int",
"width": "80"
},
{
"fieldname": "order_count",
"label": _("Order Count"),
"fieldtype": "Int",
"width": "100"
},
{
"fieldname": "order_value",
"label": _("Order Value"),
"fieldtype": "Float",
"width": "100"
},
{
"fieldname": "opp_lead",
"label": _("Opp/Lead %"),
"fieldtype": "Float",
"width": "100"
},
{
"fieldname": "quot_lead",
"label": _("Quot/Lead %"),
"fieldtype": "Float",
"width": "100"
},
{
"fieldname": "order_quot",
"label": _("Order/Quot %"),
"fieldtype": "Float",
"width": "100"
}
] ]