Merge pull request #22987 from frappe/fix-company-field
fix: Consistent capitalization
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 28a6519..2f800bb 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -611,7 +611,7 @@
cond = "posting_date <= '{0}'".format(posting_date)
if company:
- cond += "and company = '{0}'".format(company)
+ cond += "and company = {0}".format(frappe.db.escape(company))
data = frappe.db.sql(""" SELECT party, sum({0}) as amount
FROM `tabGL Entry`
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 89c38c7..66b5f30 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -479,7 +479,11 @@
if d.against_order:
allocated_amount = flt(d.amount)
else:
- amount = self.rounded_total or self.grand_total
+ if self.get('party_account_currency') == self.company_currency:
+ amount = self.get('base_rounded_total') or self.base_grand_total
+ else:
+ amount = self.get('rounded_total') or self.grand_total
+
allocated_amount = min(amount - advance_allocated, d.amount)
advance_allocated += flt(allocated_amount)
@@ -802,10 +806,22 @@
self.payment_terms_template = ''
return
+ party_account_currency = self.get('party_account_currency')
+ if not party_account_currency:
+ party_type, party = self.get_party()
+
+ if party_type and party:
+ party_account_currency = get_party_account_currency(party_type, party, self.company)
+
posting_date = self.get("bill_date") or self.get("posting_date") or self.get("transaction_date")
date = self.get("due_date")
due_date = date or posting_date
- grand_total = self.get("rounded_total") or self.grand_total
+
+ if party_account_currency == self.company_currency:
+ grand_total = self.get("base_rounded_total") or self.base_grand_total
+ else:
+ grand_total = self.get("rounded_total") or self.grand_total
+
if self.doctype in ("Sales Invoice", "Purchase Invoice"):
grand_total = grand_total - flt(self.write_off_amount)
@@ -850,13 +866,25 @@
def validate_payment_schedule_amount(self):
if self.doctype == 'Sales Invoice' and self.is_pos: return
+ party_account_currency = self.get('party_account_currency')
+ if not party_account_currency:
+ party_type, party = self.get_party()
+
+ if party_type and party:
+ party_account_currency = get_party_account_currency(party_type, party, self.company)
+
if self.get("payment_schedule"):
total = 0
for d in self.get("payment_schedule"):
total += flt(d.payment_amount)
- total = flt(total, self.precision("grand_total"))
- grand_total = flt(self.get("rounded_total") or self.grand_total, self.precision('grand_total'))
+ if party_account_currency == self.company_currency:
+ total = flt(total, self.precision("base_grand_total"))
+ grand_total = flt(self.get("base_rounded_total") or self.base_grand_total, self.precision('base_grand_total'))
+ else:
+ total = flt(total, self.precision("grand_total"))
+ grand_total = flt(self.get("rounded_total") or self.grand_total, self.precision('grand_total'))
+
if self.get("total_advance"):
grand_total -= self.get("total_advance")
diff --git a/erpnext/crm/doctype/opportunity/opportunity.json b/erpnext/crm/doctype/opportunity/opportunity.json
index 545e232..219ed89 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.json
+++ b/erpnext/crm/doctype/opportunity/opportunity.json
@@ -16,6 +16,7 @@
"opportunity_from",
"party_name",
"customer_name",
+ "source",
"column_break0",
"title",
"opportunity_type",
@@ -49,7 +50,6 @@
"contact_email",
"contact_mobile",
"more_info",
- "source",
"campaign",
"column_break1",
"company",
@@ -424,7 +424,7 @@
"icon": "fa fa-info-sign",
"idx": 195,
"links": [],
- "modified": "2020-07-14 16:49:15.888503",
+ "modified": "2020-08-11 14:49:13.496297",
"modified_by": "Administrator",
"module": "CRM",
"name": "Opportunity",
diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py
index efaeca0..e152850 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.py
+++ b/erpnext/crm/doctype/opportunity/opportunity.py
@@ -119,11 +119,19 @@
and q.status not in ('Lost', 'Closed')""", self.name)
def has_ordered_quotation(self):
- return frappe.db.sql("""
- select q.name
- from `tabQuotation` q, `tabQuotation Item` qi
- where q.name = qi.parent and q.docstatus=1 and qi.prevdoc_docname =%s
- and q.status = 'Ordered'""", self.name)
+ if not self.with_items:
+ return frappe.get_all('Quotation',
+ {
+ 'opportunity': self.name,
+ 'status': 'Ordered',
+ 'docstatus': 1
+ }, 'name')
+ else:
+ return frappe.db.sql("""
+ select q.name
+ from `tabQuotation` q, `tabQuotation Item` qi
+ where q.name = qi.parent and q.docstatus=1 and qi.prevdoc_docname =%s
+ and q.status = 'Ordered'""", self.name)
def has_lost_quotation(self):
lost_quotation = frappe.db.sql("""
diff --git a/erpnext/payroll/doctype/payroll_entry/payroll_entry.py b/erpnext/payroll/doctype/payroll_entry/payroll_entry.py
index 554484f..30ea432 100644
--- a/erpnext/payroll/doctype/payroll_entry/payroll_entry.py
+++ b/erpnext/payroll/doctype/payroll_entry/payroll_entry.py
@@ -90,7 +90,7 @@
cond = ''
for f in ['company', 'branch', 'department', 'designation']:
if self.get(f):
- cond += " and t1." + f + " = '" + self.get(f).replace("'", "\'") + "'"
+ cond += " and t1." + f + " = " + frappe.db.escape(self.get(f))
return cond
diff --git a/erpnext/public/less/website.less b/erpnext/public/less/website.less
index 57a0a33..ac878de 100644
--- a/erpnext/public/less/website.less
+++ b/erpnext/public/less/website.less
@@ -297,6 +297,10 @@
margin-top: 30px;
}
+.item-group-slideshow {
+ margin-bottom: 1rem;
+}
+
.product-image-img {
border: 1px solid @light-border-color;
border-radius: 3px;
diff --git a/erpnext/templates/generators/item_group.html b/erpnext/templates/generators/item_group.html
index 3f98453..40a064f 100644
--- a/erpnext/templates/generators/item_group.html
+++ b/erpnext/templates/generators/item_group.html
@@ -4,7 +4,7 @@
{% block page_content %}
<div class="item-group-content" itemscope itemtype="http://schema.org/Product">
- <div>
+ <div class="item-group-slideshow">
{% if slideshow %}<!-- slideshow -->
{% include "templates/includes/slideshow.html" %}
{% endif %}