Commit 95377f1b authored by Charles-Henri Decultot's avatar Charles-Henri Decultot
Browse files

Merge branch 'staging'

parents b3d2cc0d 081cbf8d
......@@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides
from frappe.utils import getdate
__version__ = '1.3.14'
__version__ = '1.3.15'
def get_default_company(user=None):
'''Get default company for user'''
......
......@@ -481,11 +481,11 @@ def make_payment_request(**args):
if args.order_type == "Shopping Cart" or args.mute_email:
pr.flags.mute_email = True
gateway_account = get_gateway_details(args) or frappe._dict()
pr.update({
"payment_gateway_account": gateway_account.get("name"),
"payment_gateway": gateway_account.get("payment_gateway")
})
gateway_account = get_gateway_details(args) or frappe._dict()
pr.update({
"payment_gateway_account": gateway_account.get("name"),
"payment_gateway": gateway_account.get("payment_gateway")
})
if args.submit_doc:
pr.insert(ignore_permissions=True)
......
......@@ -437,7 +437,9 @@ class Subscription(Document):
def get_current_documents(self, doctype):
events = frappe.get_all("Subscription Event",
filters={"subscription": self.name, "document_type": doctype, "event_type": f"{doctype.capitalize()} created"},
filters={"subscription": self.name, "document_type": doctype,
"period_start": self.current_invoice_start, "period_end": self.current_invoice_end,
"event_type": f"{doctype.capitalize()} created"},
fields=["document_name"])
if events:
return [x.document_name for x in events]
......@@ -788,9 +790,10 @@ def check_gateway_payments():
"party_type": "Customer",
"party": doc.customer,
"submit_doc": True,
"mute_email": True
"mute_email": True,
"payment_gateway": doc.payment_gateway
})
if pr.get("payment_gateways") and float(pr.get("grand_total")) > 0:
if pr.get("payment_gateway_account") and float(pr.get("grand_total")) > 0:
doc = frappe.get_doc("Payment Request", pr.get("name"))
doc.run_method("process_payment_immediately")
......@@ -21,6 +21,7 @@ status_map = {
["Converted", "has_customer"],
],
"Opportunity": [
["Open", None],
["Lost", "eval:self.status=='Lost'"],
["Lost", "has_lost_quotation"],
["Quotation", "has_active_quotation"],
......
......@@ -104,20 +104,21 @@ class Opportunity(TransactionBase):
frappe.throw(_("Cannot declare as lost, because Quotation has been made."))
def has_active_quotation(self):
if not self.with_items:
return frappe.get_all('Quotation',
{
'opportunity': self.name,
'status': ("not in", ['Lost', 'Closed']),
'docstatus': 1
}, 'name')
else:
return frappe.db.sql("""
output = frappe.get_all('Quotation',
{
'opportunity': self.name,
'status': ("not in", ['Lost', 'Closed']),
'docstatus': 1
}, 'name')
if not output:
output = 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 not in ('Lost', 'Closed')""", self.name)
return output
def has_ordered_quotation(self):
return frappe.db.sql("""
select q.name
......
......@@ -275,7 +275,9 @@ scheduler_events = {
"erpnext.erpnext_integrations.doctype.gocardless_settings.gocardless_settings.check_integrated_documents",
"erpnext.projects.doctype.project.project.hourly_reminder",
"erpnext.projects.doctype.project.project.collect_project_status",
"erpnext.hr.doctype.shift_type.shift_type.process_auto_attendance_for_all_shifts"
"erpnext.hr.doctype.shift_type.shift_type.process_auto_attendance_for_all_shifts",
"erpnext.accounts.doctype.subscription.subscription.update_grand_total",
"erpnext.accounts.doctype.subscription.subscription.check_gateway_payments"
],
"daily": [
"erpnext.stock.reorder_item.reorder_item",
......@@ -305,9 +307,7 @@ scheduler_events = {
"erpnext.manufacturing.doctype.bom_update_tool.bom_update_tool.update_latest_price_in_all_boms",
"erpnext.hr.doctype.leave_ledger_entry.leave_ledger_entry.process_expired_allocation",
"erpnext.hr.utils.generate_leave_encashment",
"erpnext.projects.doctype.project.project.update_project_sales_billing",
"erpnext.accounts.doctype.subscription.subscription.update_grand_total",
"erpnext.accounts.doctype.subscription.subscription.check_gateway_payments"
"erpnext.projects.doctype.project.project.update_project_sales_billing"
],
"monthly_long": [
"erpnext.accounts.deferred_revenue.convert_deferred_revenue_to_income",
......
......@@ -73,7 +73,6 @@ class Quotation(SellingController):
opportunity = self.opportunity
opp = frappe.get_doc("Opportunity", opportunity)
opp.status = None
opp.set_status(update=True)
def declare_enquiry_lost(self, lost_reasons_list, detailed_reason=None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment