Merge branch 'develop' into better-logging-for-membership

This commit is contained in:
Shivam Mishra 2020-09-30 12:01:54 +05:30 committed by GitHub
commit b04b53c613
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 83 additions and 49 deletions

View File

@ -12,9 +12,10 @@ frappe.ui.form.on('Payment Entry', {
setup: function(frm) { setup: function(frm) {
frm.set_query("paid_from", function() { frm.set_query("paid_from", function() {
frm.events.validate_company(frm);
var account_types = in_list(["Pay", "Internal Transfer"], frm.doc.payment_type) ? var account_types = in_list(["Pay", "Internal Transfer"], frm.doc.payment_type) ?
["Bank", "Cash"] : [frappe.boot.party_account_types[frm.doc.party_type]]; ["Bank", "Cash"] : [frappe.boot.party_account_types[frm.doc.party_type]];
return { return {
filters: { filters: {
"account_type": ["in", account_types], "account_type": ["in", account_types],
@ -23,13 +24,16 @@ frappe.ui.form.on('Payment Entry', {
} }
} }
}); });
frm.set_query("party_type", function() { frm.set_query("party_type", function() {
frm.events.validate_company(frm);
return{ return{
filters: { filters: {
"name": ["in", Object.keys(frappe.boot.party_account_types)], "name": ["in", Object.keys(frappe.boot.party_account_types)],
} }
} }
}); });
frm.set_query("party_bank_account", function() { frm.set_query("party_bank_account", function() {
return { return {
filters: { filters: {
@ -39,6 +43,7 @@ frappe.ui.form.on('Payment Entry', {
} }
} }
}); });
frm.set_query("bank_account", function() { frm.set_query("bank_account", function() {
return { return {
filters: { filters: {
@ -47,6 +52,7 @@ frappe.ui.form.on('Payment Entry', {
} }
} }
}); });
frm.set_query("contact_person", function() { frm.set_query("contact_person", function() {
if (frm.doc.party) { if (frm.doc.party) {
return { return {
@ -58,10 +64,12 @@ frappe.ui.form.on('Payment Entry', {
}; };
} }
}); });
frm.set_query("paid_to", function() { frm.set_query("paid_to", function() {
frm.events.validate_company(frm);
var account_types = in_list(["Receive", "Internal Transfer"], frm.doc.payment_type) ? var account_types = in_list(["Receive", "Internal Transfer"], frm.doc.payment_type) ?
["Bank", "Cash"] : [frappe.boot.party_account_types[frm.doc.party_type]]; ["Bank", "Cash"] : [frappe.boot.party_account_types[frm.doc.party_type]];
return { return {
filters: { filters: {
"account_type": ["in", account_types], "account_type": ["in", account_types],
@ -150,6 +158,12 @@ frappe.ui.form.on('Payment Entry', {
frm.events.show_general_ledger(frm); frm.events.show_general_ledger(frm);
}, },
validate_company: (frm) => {
if (!frm.doc.company){
frappe.throw({message:__("Please select a Company first."), title: __("Mandatory")});
}
},
company: function(frm) { company: function(frm) {
frm.events.hide_unhide_fields(frm); frm.events.hide_unhide_fields(frm);
frm.events.set_dynamic_labels(frm); frm.events.set_dynamic_labels(frm);

View File

@ -6,7 +6,7 @@ from __future__ import unicode_literals
import frappe, erpnext, math, json import frappe, erpnext, math, json
from frappe import _ from frappe import _
from six import string_types from six import string_types
from frappe.utils import flt, add_months, cint, nowdate, getdate, today, date_diff, month_diff, add_days, get_last_day from frappe.utils import flt, add_months, cint, nowdate, getdate, today, date_diff, month_diff, add_days, get_last_day, get_datetime
from frappe.model.document import Document from frappe.model.document import Document
from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account
from erpnext.assets.doctype.asset.depreciation \ from erpnext.assets.doctype.asset.depreciation \
@ -140,6 +140,10 @@ class Asset(AccountsController):
def make_asset_movement(self): def make_asset_movement(self):
reference_doctype = 'Purchase Receipt' if self.purchase_receipt else 'Purchase Invoice' reference_doctype = 'Purchase Receipt' if self.purchase_receipt else 'Purchase Invoice'
reference_docname = self.purchase_receipt or self.purchase_invoice reference_docname = self.purchase_receipt or self.purchase_invoice
transaction_date = getdate(self.purchase_date)
if reference_docname:
posting_date, posting_time = frappe.db.get_value(reference_doctype, reference_docname, ["posting_date", "posting_time"])
transaction_date = get_datetime("{} {}".format(posting_date, posting_time))
assets = [{ assets = [{
'asset': self.name, 'asset': self.name,
'asset_name': self.asset_name, 'asset_name': self.asset_name,
@ -151,7 +155,7 @@ class Asset(AccountsController):
'assets': assets, 'assets': assets,
'purpose': 'Receipt', 'purpose': 'Receipt',
'company': self.company, 'company': self.company,
'transaction_date': getdate(self.purchase_date), 'transaction_date': transaction_date,
'reference_doctype': reference_doctype, 'reference_doctype': reference_doctype,
'reference_name': reference_docname 'reference_name': reference_docname
}).insert() }).insert()

View File

@ -25,7 +25,7 @@ def get_transaction_list(doctype, txt=None, filters=None, limit_start=0, limit_p
if not filters: filters = [] if not filters: filters = []
if doctype in ['Supplier Quotation', 'Purchase Invoice']: if doctype in ['Supplier Quotation', 'Purchase Invoice', 'Quotation']:
filters.append((doctype, 'docstatus', '<', 2)) filters.append((doctype, 'docstatus', '<', 2))
else: else:
filters.append((doctype, 'docstatus', '=', 1)) filters.append((doctype, 'docstatus', '=', 1))

View File

@ -27,9 +27,6 @@ class Lead(SellingController):
def after_insert(self): def after_insert(self):
self.update_links() self.update_links()
# after the address and contact are created, flush the field values
# to avoid inconsistent reporting in case the documents are changed
self.flush_address_and_contact_fields()
def validate(self): def validate(self):
self.set_lead_name() self.set_lead_name()
@ -210,14 +207,6 @@ class Lead(SellingController):
}) })
self.contact_doc.save() self.contact_doc.save()
def flush_address_and_contact_fields(self):
fields = ['address_type', 'address_line1', 'address_line2', 'address_title',
'city', 'county', 'country', 'fax', 'pincode', 'state']
for field in fields:
self.set(field, None)
@frappe.whitelist() @frappe.whitelist()
def make_customer(source_name, target_doc=None): def make_customer(source_name, target_doc=None):
return _make_customer(source_name, target_doc) return _make_customer(source_name, target_doc)
@ -376,3 +365,8 @@ def get_lead_with_phone_number(number):
lead = leads[0].name if leads else None lead = leads[0].name if leads else None
return lead return lead
def daily_open_lead():
leads = frappe.get_all("Lead", filters = [["contact_date", "Between", [nowdate(), nowdate()]]])
for lead in leads:
frappe.db.set_value("Lead", lead.name, "status", "Open")

View File

@ -13,7 +13,7 @@
"fields": [ "fields": [
{ {
"fieldname": "question", "fieldname": "question",
"fieldtype": "Small Text", "fieldtype": "Text Editor",
"in_list_view": 1, "in_list_view": 1,
"label": "Question", "label": "Question",
"reqd": 1 "reqd": 1
@ -34,7 +34,7 @@
"read_only": 1 "read_only": 1
} }
], ],
"modified": "2019-05-30 18:39:21.880974", "modified": "2020-09-24 18:39:21.880974",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Education", "module": "Education",
"name": "Question", "name": "Question",

View File

@ -20,14 +20,14 @@
{ {
"fetch_from": "question_link.question", "fetch_from": "question_link.question",
"fieldname": "question", "fieldname": "question",
"fieldtype": "Data", "fieldtype": "Text Editor",
"in_list_view": 1, "in_list_view": 1,
"label": "Question", "label": "Question",
"read_only": 1 "read_only": 1
} }
], ],
"istable": 1, "istable": 1,
"modified": "2019-06-12 12:24:02.312577", "modified": "2020-09-24 12:24:02.312577",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Education", "module": "Education",
"name": "Quiz Question", "name": "Quiz Question",

View File

@ -6,7 +6,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
import json import json
from frappe.utils import getdate, get_time from frappe.utils import getdate, get_time, flt
from frappe.model.mapper import get_mapped_doc from frappe.model.mapper import get_mapped_doc
from frappe import _ from frappe import _
import datetime import datetime
@ -45,7 +45,7 @@ class PatientAppointment(Document):
def validate_overlaps(self): def validate_overlaps(self):
end_time = datetime.datetime.combine(getdate(self.appointment_date), get_time(self.appointment_time)) \ end_time = datetime.datetime.combine(getdate(self.appointment_date), get_time(self.appointment_time)) \
+ datetime.timedelta(minutes=float(self.duration)) + datetime.timedelta(minutes=flt(self.duration))
overlaps = frappe.db.sql(""" overlaps = frappe.db.sql("""
select select

View File

@ -336,7 +336,8 @@ scheduler_events = {
"erpnext.hr.doctype.leave_ledger_entry.leave_ledger_entry.process_expired_allocation", "erpnext.hr.doctype.leave_ledger_entry.leave_ledger_entry.process_expired_allocation",
"erpnext.hr.utils.generate_leave_encashment", "erpnext.hr.utils.generate_leave_encashment",
"erpnext.loan_management.doctype.loan_security_shortfall.loan_security_shortfall.create_process_loan_security_shortfall", "erpnext.loan_management.doctype.loan_security_shortfall.loan_security_shortfall.create_process_loan_security_shortfall",
"erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual.process_loan_interest_accrual_for_term_loans" "erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual.process_loan_interest_accrual_for_term_loans",
"erpnext.crm.doctype.lead.lead.daily_open_lead"
], ],
"monthly_long": [ "monthly_long": [
"erpnext.accounts.deferred_revenue.process_deferred_accounting", "erpnext.accounts.deferred_revenue.process_deferred_accounting",

View File

@ -120,7 +120,7 @@ frappe.ui.form.on('Salary Structure', {
var get_payment_mode_account = function(frm, mode_of_payment, callback) { var get_payment_mode_account = function(frm, mode_of_payment, callback) {
if(!frm.doc.company) { if(!frm.doc.company) {
frappe.throw(__("Please select the Company first")); frappe.throw({message:__("Please select a Company first."), title: __("Mandatory")});
} }
if(!mode_of_payment) { if(!mode_of_payment) {

View File

@ -140,7 +140,7 @@ class Question {
make_question() { make_question() {
let question_wrapper = document.createElement('h5'); let question_wrapper = document.createElement('h5');
question_wrapper.classList.add('mt-3'); question_wrapper.classList.add('mt-3');
question_wrapper.innerText = this.question; question_wrapper.innerHTML = this.question;
this.wrapper.appendChild(question_wrapper); this.wrapper.appendChild(question_wrapper);
} }

View File

@ -677,6 +677,7 @@ erpnext.utils.map_current_doc = function(opts) {
date_field: opts.date_field || undefined, date_field: opts.date_field || undefined,
setters: opts.setters, setters: opts.setters,
get_query: opts.get_query, get_query: opts.get_query,
add_filters_group: 1,
action: function(selections, args) { action: function(selections, args) {
let values = selections; let values = selections;
if(values.length === 0){ if(values.length === 0){

View File

@ -96,6 +96,8 @@ def place_order():
def request_for_quotation(): def request_for_quotation():
quotation = _get_cart_quotation() quotation = _get_cart_quotation()
quotation.flags.ignore_permissions = True quotation.flags.ignore_permissions = True
quotation.save()
if not get_shopping_cart_settings().save_quotations_as_draft:
quotation.submit() quotation.submit()
return quotation.name return quotation.name

View File

@ -27,6 +27,7 @@
"enable_checkout", "enable_checkout",
"payment_success_url", "payment_success_url",
"column_break_11", "column_break_11",
"save_quotations_as_draft",
"payment_gateway_account" "payment_gateway_account"
], ],
"fields": [ "fields": [
@ -166,13 +167,20 @@
"fieldname": "enable_variants", "fieldname": "enable_variants",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Enable Variants" "label": "Enable Variants"
},
{
"default": "0",
"depends_on": "eval: doc.enable_checkout == 0",
"fieldname": "save_quotations_as_draft",
"fieldtype": "Check",
"label": "Save Quotations as Draft"
} }
], ],
"icon": "fa fa-shopping-cart", "icon": "fa fa-shopping-cart",
"idx": 1, "idx": 1,
"issingle": 1, "issingle": 1,
"links": [], "links": [],
"modified": "2020-08-02 18:21:43.873303", "modified": "2020-09-24 16:28:07.192525",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Shopping Cart", "module": "Shopping Cart",
"name": "Shopping Cart Settings", "name": "Shopping Cart Settings",

View File

@ -156,6 +156,7 @@ frappe.ui.form.on('Stock Entry', {
mr_item.item_code = item.item_code; mr_item.item_code = item.item_code;
mr_item.item_name = item.item_name; mr_item.item_name = item.item_name;
mr_item.uom = item.uom; mr_item.uom = item.uom;
mr_item.stock_uom = item.stock_uom;
mr_item.conversion_factor = item.conversion_factor; mr_item.conversion_factor = item.conversion_factor;
mr_item.item_group = item.item_group; mr_item.item_group = item.item_group;
mr_item.description = item.description; mr_item.description = item.description;

View File

@ -10,7 +10,10 @@
{{ product_info.price.formatted_price_sales_uom }} {{ product_info.price.formatted_price_sales_uom }}
<small class="text-muted">({{ product_info.price.formatted_price }} / {{ product_info.uom }})</small> <small class="text-muted">({{ product_info.price.formatted_price }} / {{ product_info.uom }})</small>
</h4> </h4>
{% else %}
{{ _("Unit of Measurement") }} : {{ product_info.uom }}
{% endif %} {% endif %}
{% if cart_settings.show_stock_availability %} {% if cart_settings.show_stock_availability %}
<div> <div>
{% if product_info.in_stock == 0 %} {% if product_info.in_stock == 0 %}

View File

@ -14,7 +14,11 @@
</div> </div>
</div> </div>
<div class="col-sm-3 text-right bold"> <div class="col-sm-3 text-right bold">
{% if doc.doctype == "Quotation" and not doc.docstatus %}
{{ _("Pending") }}
{% else %}
{{ doc.get_formatted("grand_total") }} {{ doc.get_formatted("grand_total") }}
{% endif %}
</div> </div>
</div> </div>
<a class="transaction-item-link" href="/{{ pathname }}/{{ doc.name }}">Link</a> <a class="transaction-item-link" href="/{{ pathname }}/{{ doc.name }}">Link</a>

View File

@ -12,7 +12,7 @@
{% endblock %} {% endblock %}
{% block header_actions %} {% block header_actions %}
<div class="dropdown"> <div class="dropdown">
<button class="btn btn-outline-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> <button class="btn btn-outline-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span>{{ _('Actions') }}</span> <span>{{ _('Actions') }}</span>
<b class="caret"></b> <b class="caret"></b>
@ -26,8 +26,7 @@
{{ _("Print") }} {{ _("Print") }}
</a> </a>
</ul> </ul>
</div> </div>
{% endblock %} {% endblock %}
{% block page_content %} {% block page_content %}
@ -35,7 +34,11 @@
<div class="row transaction-subheading"> <div class="row transaction-subheading">
<div class="col-6"> <div class="col-6">
<span class="indicator {{ doc.indicator_color or ("blue" if doc.docstatus==1 else "darkgrey") }}"> <span class="indicator {{ doc.indicator_color or ("blue" if doc.docstatus==1 else "darkgrey") }}">
{% if doc.doctype == "Quotation" and not doc.docstatus %}
{{ _("Pending") }}
{% else %}
{{ _(doc.get('indicator_title')) or _(doc.status) or _("Submitted") }} {{ _(doc.get('indicator_title')) or _(doc.status) or _("Submitted") }}
{% endif %}
</span> </span>
</div> </div>
<div class="col-6 text-muted text-right small"> <div class="col-6 text-muted text-right small">
@ -95,7 +98,6 @@
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<!-- taxes --> <!-- taxes -->
<div class="order-taxes d-flex justify-content-end"> <div class="order-taxes d-flex justify-content-end">
<table> <table>