Merge branch 'hotfix'

This commit is contained in:
Nabin Hait 2016-09-21 13:05:26 +05:30
commit 6835a6fb49
7 changed files with 88 additions and 15 deletions

View File

@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe
__version__ = '7.0.44'
__version__ = '7.0.45'
def get_default_company(user=None):
'''Get default company for user'''

View File

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import flt
from erpnext.accounts.report.sales_register.sales_register import get_mode_of_payments
def execute(filters=None):
if not filters: filters = {}
@ -21,6 +22,7 @@ def execute(filters=None):
"width": 80
})
company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
mode_of_payments = get_mode_of_payments(set([d.parent for d in item_list]))
data = []
for d in item_list:
@ -32,7 +34,8 @@ def execute(filters=None):
from `tabDelivery Note Item` where docstatus=1 and so_detail=%s""", d.so_detail))
row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, d.customer, d.customer_name,
d.customer_group, d.debit_to, d.mode_of_payment, d.territory, d.project, d.company, d.sales_order,
d.customer_group, d.debit_to, ", ".join(mode_of_payments.get(d.parent, [])),
d.territory, d.project, d.company, d.sales_order,
delivery_note, d.income_account, d.cost_center, d.qty, d.base_net_rate, d.base_net_amount]
for tax in tax_accounts:
@ -52,7 +55,7 @@ def get_columns():
_("Posting Date") + ":Date:80", _("Customer") + ":Link/Customer:120",
_("Customer Name") + "::120", _("Customer Group") + ":Link/Customer Group:120",
_("Receivable Account") + ":Link/Account:120",
_("Mode of Payment") + ":Link/Mode of Payment:80", _("Territory") + ":Link/Territory:80",
_("Mode of Payment") + "::120", _("Territory") + ":Link/Territory:80",
_("Project") + ":Link/Project:80", _("Company") + ":Link/Company:100",
_("Sales Order") + ":Link/Sales Order:100", _("Delivery Note") + ":Link/Delivery Note:100",
_("Income Account") + ":Link/Account:140", _("Cost Center") + ":Link/Cost Center:140",
@ -68,11 +71,15 @@ def get_conditions(filters):
("customer", " and si.customer = %(customer)s"),
("item_code", " and si_item.item_code = %(item_code)s"),
("from_date", " and si.posting_date>=%(from_date)s"),
("to_date", " and si.posting_date<=%(to_date)s"),
("mode_of_payment", " and ifnull(mode_of_payment, '') = %(mode_of_payment)s")):
("to_date", " and si.posting_date<=%(to_date)s")):
if filters.get(opts[0]):
conditions += opts[1]
if filters.get("mode_of_payment"):
conditions += """ and exists(select name from `tabSales Invoice Payment`
where parent=si.name
and ifnull(`tabSales Invoice Payment`.mode_of_payment, '') = %(mode_of_payment)s)"""
return conditions
def get_items(filters):
@ -84,7 +91,7 @@ def get_items(filters):
si_item.item_code, si_item.item_name, si_item.item_group, si_item.sales_order,
si_item.delivery_note, si_item.income_account, si_item.cost_center, si_item.qty,
si_item.base_net_rate, si_item.base_net_amount, si.customer_name,
si.customer_group, si_item.so_detail, si.mode_of_payment
si.customer_group, si_item.so_detail
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
where si.name = si_item.parent and si.docstatus = 1 %s
order by si.posting_date desc, si_item.item_code desc""" % conditions, filters, as_dict=1)

View File

@ -23,6 +23,7 @@ def execute(filters=None):
invoice_so_dn_map = get_invoice_so_dn_map(invoice_list)
customer_map = get_customer_deatils(invoice_list)
company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
mode_of_payments = get_mode_of_payments([inv.name for inv in invoice_list])
data = []
for inv in invoice_list:
@ -33,7 +34,7 @@ def execute(filters=None):
row = [inv.name, inv.posting_date, inv.customer, inv.customer_name,
customer_map.get(inv.customer, {}).get("customer_group"),
customer_map.get(inv.customer, {}).get("territory"),
inv.debit_to, inv.mode_of_payment, inv.project, inv.remarks,
inv.debit_to, ", ".join(mode_of_payments.get(inv.name, [])), inv.project, inv.remarks,
", ".join(sales_order), ", ".join(delivery_note), company_currency]
# map income values
@ -68,7 +69,7 @@ def get_columns(invoice_list):
_("Invoice") + ":Link/Sales Invoice:120", _("Posting Date") + ":Date:80",
_("Customer Id") + "::120", _("Customer Name") + "::120",
_("Customer Group") + ":Link/Customer Group:120", _("Territory") + ":Link/Territory:80",
_("Receivable Account") + ":Link/Account:120", _("Mode of Payment") + ":Link/Mode of Payment:80",
_("Receivable Account") + ":Link/Account:120", _("Mode of Payment") + "::120",
_("Project") +":Link/Project:80", _("Remarks") + "::150",
_("Sales Order") + ":Link/Sales Order:100", _("Delivery Note") + ":Link/Delivery Note:100",
{
@ -113,7 +114,10 @@ def get_conditions(filters):
if filters.get("from_date"): conditions += " and posting_date >= %(from_date)s"
if filters.get("to_date"): conditions += " and posting_date <= %(to_date)s"
if filters.get("mode_of_payment"): conditions += " and ifnull(mode_of_payment, '') = %(mode_of_payment)s"
if filters.get("mode_of_payment"):
conditions += """ and exists(select name from `tabSales Invoice Payment`
where parent=`tabSales Invoice`.name
and ifnull(`tabSales Invoice Payment`.mode_of_payment, '') = %(mode_of_payment)s)"""
return conditions
@ -188,3 +192,15 @@ def get_customer_deatils(invoice_list):
customer_map.setdefault(cust.name, cust)
return customer_map
def get_mode_of_payments(invoice_list):
mode_of_payments = {}
inv_mop = frappe.db.sql("""select parent, mode_of_payment
from `tabSales Invoice Payment` where parent in (%s) group by parent, mode_of_payment""" %
', '.join(['%s']*len(invoice_list)), tuple(invoice_list), as_dict=1)
for d in inv_mop:
mode_of_payments.setdefault(d.parent, []).append(d.mode_of_payment)
return mode_of_payments

View File

@ -13,7 +13,7 @@ def execute():
header = frappe.db.get_value('Web Page', website_settings.home_page, 'header')
if header and header.startswith("<div class='hero text-center'>"):
homepage = frappe.get_doc('Homepage', 'Homepage')
homepage.company = erpnext.get_default_company()
homepage.company = erpnext.get_default_company() or frappe.get_all("Company")[0].name
if '<h1>' in header:
homepage.tag_line = header.split('<h1>')[1].split('</h1>')[0] or 'Default Website'
else:

View File

@ -63,7 +63,8 @@ def get_domain(domain):
'Education': {
'desktop_icons': ['Student', 'Program', 'Course', 'Student Group', 'Instructor',
'Fees', 'ToDo', 'Schools'],
'allow_roles': ['Academics User', 'Accounts User', 'Accounts Manager', 'Website Manager'],
'allow_roles': ['Academics User', 'Accounts User', 'Accounts Manager', 'Item Manager',
'Website Manager', 'HR User', 'HR Manager', 'Purchase User', 'Purchase Manager'],
'allow_sidebar_items': ['/announcement', '/course', '/assessment', '/fees']
},
}

View File

@ -15,9 +15,9 @@ from erpnext.controllers.buying_controller import BuyingController
from erpnext.manufacturing.doctype.production_order.production_order import get_item_details
# form_grid_templates = {
# "items": "templates/form_grid/material_request_grid.html"
# }
form_grid_templates = {
"items": "templates/form_grid/material_request_grid.html"
}
class MaterialRequest(BuyingController):
def get_feed(self):

View File

@ -0,0 +1,49 @@
{% var visible_columns = row.get_visible_columns(["item_code", "warehouse",
"item_name", "amount", "stock_uom", "uom", "qty", "schedule_date"]); %}
{% if(!doc) { %}
<div class="row">
<div class="col-sm-4">{%= __("Item") %}</div>
<div class="col-sm-3">{%= __("Required On") %}</div>
<div class="col-sm-3">{%= __("Warehouse") %}</div>
<div class="col-sm-2 text-right">{%= __("Qty") %}</div>
</div>
{% } else { %}
<div class="row">
<div class="col-sm-4">
<span class="indicator {%= (doc.qty<=doc.ordered_qty) ? "green" : "orange" %}">{%= doc.item_code %}</strong>
{% if(doc.item_name != doc.item_code) { %}
<br>{%= doc.item_name %}{% } %}
<!-- {% if(doc.item_name != doc.description) { %}
<p>{%= doc.description %}</p>{% } %} -->
{% include "templates/form_grid/includes/visible_cols.html" %}
</div>
<div class="col-sm-3">
{% if(doc.schedule_date) { %}
<span title="{%= __("Reqd By Date") %}" class="{%=
(frappe.datetime.get_diff(doc.schedule_date, frappe.datetime.get_today()) < 0
&& doc.ordered_qty < doc.qty)
? "text-danger" : "text-muted" %}">
{%= doc.get_formatted("schedule_date") %}</span>
{% } %}
</div>
<!-- warehouse -->
<div class="col-sm-3">
{% if(doc.warehouse) { %}
<span class="label label-default" title="{%= __("For Warehouse") %}"
style="margin-right: 10px;">
{%= doc.warehouse %}
</span>
{% } %}
</div>
<!-- qty -->
<div class="col-sm-2 text-right">
{%= doc.get_formatted("qty") %}
<span class="small">{%= doc.uom || doc.stock_uom %}</span>
</div>
</div>
{% } %}