Merge branch 'master' into develop

This commit is contained in:
Saurabh 2018-01-15 18:36:35 +05:30
commit 4b0dd8a159
19 changed files with 151 additions and 56 deletions

View File

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

View File

@ -252,7 +252,7 @@ def add_ac(args=None):
if not ac.parent_account:
ac.parent_account = args.get("parent")
if ac.is_root:
if getattr(ac, 'is_root', None):
ac.parent_account=''
ac.old_parent = ""

View File

@ -54,6 +54,7 @@ class AccountsController(TransactionBase):
if self.meta.get_field("taxes_and_charges"):
self.validate_enabled_taxes_and_charges()
self.validate_tax_account_company()
self.validate_party()
self.validate_currency()
@ -255,6 +256,14 @@ class AccountsController(TransactionBase):
if frappe.db.get_value(taxes_and_charges_doctype, self.taxes_and_charges, "disabled"):
frappe.throw(_("{0} '{1}' is disabled").format(taxes_and_charges_doctype, self.taxes_and_charges))
def validate_tax_account_company(self):
for d in self.get("taxes"):
if d.account_head:
tax_account_company = frappe.db.get_value("Account", d.account_head, "company")
if tax_account_company != self.company:
frappe.throw(_("Row #{0}: Account {1} does not belong to company {2}")
.format(d.idx, d.account_head, self.company))
def get_gl_dict(self, args, account_currency=None):
"""this method populates the common properties of a gl entry record"""
@ -722,11 +731,15 @@ def get_tax_rate(account_head):
return frappe.db.get_value("Account", account_head, ["tax_rate", "account_name"], as_dict=True)
@frappe.whitelist()
def get_default_taxes_and_charges(master_doctype, company=None):
def get_default_taxes_and_charges(master_doctype, tax_template=None, company=None):
if not company: return {}
default_tax = frappe.db.get_value(master_doctype,
{"is_default": 1, "company": company})
if tax_template and company:
tax_template_company = frappe.db.get_value(master_doctype, tax_template, "company")
if tax_template_company == company:
return
default_tax = frappe.db.get_value(master_doctype, {"is_default": 1, "company": company})
return {
'taxes_and_charges': default_tax,

View File

@ -232,7 +232,7 @@ def make_quotation(source_name, target_doc=None):
quotation.conversion_rate = exchange_rate
# get default taxes
taxes = get_default_taxes_and_charges("Sales Taxes and Charges Template", quotation.company)
taxes = get_default_taxes_and_charges("Sales Taxes and Charges Template", company=quotation.company)
if taxes.get('taxes'):
quotation.update(taxes)

View File

@ -35,4 +35,16 @@ def get_list_context(context):
context.title = 'All Chapters'
context.no_breadcrumbs = True
context.order_by = 'creation desc'
context.introduction = '<p>All Chapters</p>'
context.introduction = '<p>All Chapters</p>'
@frappe.whitelist()
def leave(title, user_id, leave_reason):
chapter = frappe.get_doc("Chapter", title)
for member in chapter.members:
if member.user == user_id:
member.enabled = 0
member.leave_reason = leave_reason
chapter.save(ignore_permissions=1)
frappe.db.commit()
return "Thank you for Feedback"

View File

@ -5,34 +5,39 @@
<h3>Details</h3>
<p>{{ introduction }}</p>
{% if meetup_embed_html %}
{{ meetup_embed_html }}
{{ meetup_embed_html }}
{% endif %}
<h3>List of Members</h3>
{% if members %}
{% if members %}
<table class="table table-bordered small" style="max-width: 500px;">
<tr>
<th width="15%" ></th>
<th>Member Details</th>
</tr>
{% set index = [1] %}
{% for user in members %}
<tr>
<td>{{ loop.index }}</td>
<td>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">{{ frappe.db.get_value('User', user.user, 'full_name') }}</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
{% if user.website_url %}
<a href="{{ user.website_url }}">{{ user.website_url or '' }}</a>
{% if user.enabled == 1 %}
<tr>
<td>{{ index|length }}</td>
<td>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">{{ frappe.db.get_value('User', user.user, 'full_name') }}</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
{% if user.website_url %}
<a href="{{ user.website_url }}">{{ user.website_url or '' }}</a>
{% endif %}
</div>
<div class="col-lg-12">
{% if user.introduction %}
{{ user.introduction }}
{% endif %}
</div>
</div>
<div class="col-lg-12">
{% if user.introduction %}
{{ user.introduction }}
{% endif %}
</div>
</div>
</td>
</tr>
</td>
</tr>
{% set __ = index.append(1) %}
{% endif %}
{% endfor %}
</table>
{% else %}

View File

@ -1,21 +1,30 @@
{% if doc.published %}
<div style="margin-bottom: 30px; max-width: 600px" class="with-border clickable">
<a href="/{{ doc.route }}">
<a href={{ route }}>
<h3>{{ doc.name }}</h3>
<p>
<span class="label">{{ frappe.db.get_value('User', chapter_head, 'full_name') }}</span>
<span class="label"> Chapter Head : {{ frappe.db.get_value('User', chapter_head, 'full_name') }} </span>
<span class="label">
{% if members %}
Members: {{ members|length }}
{% set index = [] %}
{% for user in members %}
{% if user.enabled == 1 %}
{% set __ = index.append(1) %}
{% endif %}
{% endfor %}
Members: {{ index|length }}
{% else %}
Members: 0
{% endif %}
</span>
</span>
<!-- Assignment of value to global variable not working in jinja -->
</p>
<p>{{ html2text(doc.introduction[:200]) }}{% if introduction|len > 200 %}...{% endif %}</p>
</a>
</div>
{% endif %}
<!-- this is a sample default list template -->
<style type="text/css">
.label {

View File

@ -132,6 +132,36 @@
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "leave_reason",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Leave Reason",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"has_web_view": 0,
@ -144,7 +174,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-12-06 11:33:34.300252",
"modified": "2018-01-12 12:16:10.591039",
"modified_by": "Administrator",
"module": "Non Profit",
"name": "Chapter Member",

View File

@ -295,7 +295,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-12-05 07:02:06.690416",
"modified": "2018-01-15 09:40:41.153561",
"modified_by": "Administrator",
"module": "Non Profit",
"name": "Donor",
@ -330,6 +330,7 @@
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "donor_name",
"track_changes": 1,
"track_seen": 0
}

View File

@ -325,7 +325,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-12-05 07:03:21.606732",
"modified": "2018-01-15 09:38:41.878167",
"modified_by": "Administrator",
"module": "Non Profit",
"name": "Member",
@ -380,6 +380,7 @@
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "member_name",
"track_changes": 1,
"track_seen": 0
}

View File

@ -506,7 +506,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-12-06 12:03:08.624579",
"modified": "2018-01-15 09:40:25.229551",
"modified_by": "Administrator",
"module": "Non Profit",
"name": "Volunteer",
@ -540,6 +540,7 @@
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "volunteer_name",
"track_changes": 1,
"track_seen": 0
}

View File

@ -244,10 +244,11 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
method: "erpnext.controllers.accounts_controller.get_default_taxes_and_charges",
args: {
"master_doctype": taxes_and_charges_field.options,
"tax_template": me.frm.doc.taxes_and_charges,
"company": me.frm.doc.company
},
callback: function(r) {
if(!r.exc) {
if(!r.exc && r.message) {
frappe.run_serially([
() => {
// directly set in doc, so as not to call triggers

View File

@ -204,7 +204,6 @@ def _get_cart_quotation(party=None):
"status": "Draft",
"docstatus": 0,
"__islocal": 1,
"payment_terms_template": "_Test Payment Term Template",
(party.doctype.lower()): party.name
})

View File

@ -9,7 +9,7 @@ from erpnext.shopping_cart.cart import _get_cart_quotation, update_cart, get_par
from erpnext.tests.utils import create_test_contact_and_address
test_dependencies = ['Payment Terms Template']
# test_dependencies = ['Payment Terms Template']
class TestShoppingCart(unittest.TestCase):
"""

View File

@ -11,18 +11,18 @@
<p><a href="/login?redirect-to=/{{ chapter.route }}" class='btn btn-primary'>Login</a></p>
{% else %}
{% if already_member %}
<p>You are already a member of {{ chapter.title }}!</p>
<p>You are already a member of {{ chapter.name }}!</p>
{{ chapter_button() }}
<p><a href="">Leave Chapter</a></p>
{% else %}
{% if frappe.local.request.method=='POST' %}
<p>Welcome to chapter {{ chapter.title }}!</p>
<p>Welcome to chapter {{ chapter.name }}!</p>
{{ chapter_button() }}
{% else %}
<div style="padding: 20px 0;">
<div class="row">
<div class="col-lg-8 col-md-8">
<form name="user-intro" action="/join-chapter" method='POST'>
<form name="user-intro" action="/non_profit/join-chapter" method='POST'>
<div class="form-group">
<input name="name" class="hidden form-control" type="text"
value="{{chapter.name}}">

View File

@ -4,7 +4,7 @@ def get_context(context):
context.no_cache = True
chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
if frappe.session.user!='Guest':
if frappe.session.user in [d.user for d in chapter.members]:
if frappe.session.user in [d.user for d in chapter.members if d.enabled == 1]:
context.already_member = True
else:
if frappe.request.method=='GET':

View File

@ -1,16 +1,42 @@
{% extends "templates/web.html" %}
<!--
{% macro chapter_button() %}
<p><a href="/{{ chapter.route }}" class='btn btn-primary'>
Go to Chapter Page</a></p>
{% endmacro %}
-->
{% block page_content %}
{% if member_deleted %}
<p>You are not a member of {{ chapter.title }}!</p>
<p>You are not a member of {{ chapter.name }}!</p>
<div>
<form>
<div class="form-group">
<label for="leave">Why do you want to leave this chapter</label>
<input type="text" name="leave" class="form-control" id="leave">
</div>
<button type="button" class="btn btn-default btn-leave" data-title= "{{ chapter.name }}" id="btn-leave">Submit
</button>
</form>
</div>
<p>Please signup and login to join this chapter</p>
<p><a href="/join-chapter?name={{ chapter.name }}" class='btn btn-primary'>Become Member agian</a></p>
{% endif %}
<script>
frappe.ready(function() {
$(".btn-leave").on("click", function() {
var leave = $("#leave").val();
var user_id = frappe.session.user;
var title = $(this).attr("data-title");
frappe.call({
method: "erpnext.non_profit.doctype.chapter.chapter.leave",
args: {
leave_reason: leave,
user_id: user_id,
title: title
},
callback: function(r) {
if(r.message) {
frappe.msgprint(r.message)
}
}
})
});
})
</script>
{% endblock %}

View File

@ -3,13 +3,5 @@ import frappe
def get_context(context):
context.no_cache = True
chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
# if frappe.session.user!='Guest':
if frappe.session.user in [d.user for d in chapter.members]:
user = frappe.session.user
parent = frappe.form_dict.name
frappe.db.sql("""delete from `tabChapter Member` where parent = %s and user = %s """, (parent, user))
frappe.db.commit()
context.member_deleted = True
context.chapter = chapter

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe
import frappe.share
from frappe import _
from frappe.utils import cstr, now_datetime, cint, flt
from frappe.utils import cstr, now_datetime, cint, flt, get_time
from erpnext.controllers.status_updater import StatusUpdater
class UOMMustBeIntegerError(frappe.ValidationError): pass
@ -26,6 +26,11 @@ class TransactionBase(StatusUpdater):
now = now_datetime()
self.posting_date = now.strftime('%Y-%m-%d')
self.posting_time = now.strftime('%H:%M:%S.%f')
else:
try:
get_time(self.posting_time)
except ValueError:
frappe.throw(_('Invalid Posting Time'))
def add_calendar_event(self, opts, force=False):
if cstr(self.contact_by) != cstr(self._prev.contact_by) or \