Merge branch 'hotfix'

This commit is contained in:
Nabin Hait 2016-08-29 11:47:30 +05:30
commit 51a236f38b
7 changed files with 261 additions and 224 deletions

View File

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

View File

@ -23,7 +23,8 @@ def get_pos_data():
frappe.msgprint('<a href="#List/POS Profile">' frappe.msgprint('<a href="#List/POS Profile">'
+ _("Welcome to POS: Create your POS Profile") + '</a>'); + _("Welcome to POS: Create your POS Profile") + '</a>');
update_pos_profile_data(doc, pos_profile) company_data = get_company_data(doc.company)
update_pos_profile_data(doc, pos_profile, company_data)
update_multi_mode_option(doc, pos_profile) update_multi_mode_option(doc, pos_profile)
default_print_format = pos_profile.get('print_format') or "Point of Sale" default_print_format = pos_profile.get('print_format') or "Point of Sale"
print_template = frappe.db.get_value('Print Format', default_print_format, 'html') print_template = frappe.db.get_value('Print Format', default_print_format, 'html')
@ -32,7 +33,7 @@ def get_pos_data():
'doc': doc, 'doc': doc,
'default_customer': pos_profile.get('customer'), 'default_customer': pos_profile.get('customer'),
'items': get_items(doc, pos_profile), 'items': get_items(doc, pos_profile),
'customers': get_customers(pos_profile, doc), 'customers': get_customers(pos_profile, doc, company_data.default_currency),
'pricing_rules': get_pricing_rules(doc), 'pricing_rules': get_pricing_rules(doc),
'print_template': print_template, 'print_template': print_template,
'meta': { 'meta': {
@ -42,8 +43,10 @@ def get_pos_data():
} }
} }
def update_pos_profile_data(doc, pos_profile): def get_company_data(company):
company_data = frappe.db.get_value('Company', doc.company, '*', as_dict=1) return frappe.get_all('Company', fields = ["*"], filters= {'name': company})[0]
def update_pos_profile_data(doc, pos_profile, company_data):
doc.campaign = pos_profile.get('campaign') doc.campaign = pos_profile.get('campaign')
doc.write_off_account = pos_profile.get('write_off_account') or \ doc.write_off_account = pos_profile.get('write_off_account') or \
@ -148,14 +151,14 @@ def get_serial_nos(item, pos_profile, company):
return serial_no_list return serial_no_list
def get_customers(pos_profile, doc): def get_customers(pos_profile, doc, company_currency):
filters = {'disabled': 0} filters = {'disabled': 0}
customer_list = [] customer_list = []
customers = frappe.get_all("Customer", fields=["*"], filters = filters) customers = frappe.get_all("Customer", fields=["*"], filters = filters)
for customer in customers: for customer in customers:
customer_currency = get_party_account_currency('Customer', customer.name, doc.company) or doc.currency customer_currency = get_party_account_currency('Customer', customer.name, doc.company) or doc.currency
if customer_currency == doc.currency: if customer_currency == doc.currency or customer_currency == company_currency:
customer_list.append(customer) customer_list.append(customer)
return customer_list return customer_list

View File

@ -57,6 +57,8 @@ class ProcessPayroll(Document):
Creates salary slip for selected employees if already not created Creates salary slip for selected employees if already not created
""" """
self.check_permission('write')
emp_list = self.get_emp_list() emp_list = self.get_emp_list()
ss_list = [] ss_list = []
for emp in emp_list: for emp in emp_list:
@ -102,6 +104,8 @@ class ProcessPayroll(Document):
""" """
Submit all salary slips based on selected criteria Submit all salary slips based on selected criteria
""" """
self.check_permission('write')
ss_list = self.get_sal_slip_list() ss_list = self.get_sal_slip_list()
not_submitted_ss = [] not_submitted_ss = []
for ss in ss_list: for ss in ss_list:
@ -159,6 +163,8 @@ class ProcessPayroll(Document):
def make_journal_entry(self, salary_account = None): def make_journal_entry(self, salary_account = None):
self.check_permission('write')
amount = self.get_total_salary() amount = self.get_total_salary()
default_bank_account = frappe.db.get_value("Company", self.company, default_bank_account = frappe.db.get_value("Company", self.company,
"default_bank_account") "default_bank_account")

View File

@ -1,236 +1,262 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_import": 0, "allow_import": 0,
"allow_rename": 0, "allow_rename": 0,
"autoname": "", "autoname": "",
"beta": 1, "beta": 1,
"creation": "2016-04-22 05:27:52.109319", "creation": "2016-04-22 05:27:52.109319",
"custom": 0, "custom": 0,
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Setup", "document_type": "Setup",
"editable_grid": 0, "editable_grid": 0,
"fields": [ "fields": [
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "company", "fieldname": "company",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Company", "label": "Company",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "Company", "options": "Company",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "title", "fieldname": "title",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "TItle", "label": "TItle",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"description": "Company Tagline for website homepage", "description": "Company Tagline for website homepage",
"fieldname": "tag_line", "fieldname": "tag_line",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Tag Line", "label": "Tag Line",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"description": "Company Description for website homepage", "description": "Company Description for website homepage",
"fieldname": "description", "fieldname": "description",
"fieldtype": "Text", "fieldtype": "Text",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Description", "label": "Description",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "products_section", "fieldname": "products_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Products", "label": "Products",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"description": "Products to be shown on website homepage", "default": "/products",
"fieldname": "products", "fieldname": "products_url",
"fieldtype": "Table", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Products", "label": "URL for \"All Products\"",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "Homepage Featured Product", "permlevel": 0,
"permlevel": 0, "precision": "",
"precision": "", "print_hide": 0,
"print_hide": 0, "print_hide_if_no_value": 0,
"print_hide_if_no_value": 0, "read_only": 0,
"read_only": 0, "report_hide": 0,
"report_hide": 0, "reqd": 0,
"reqd": 0, "search_index": 0,
"search_index": 0, "set_only_once": 0,
"set_only_once": 0, "unique": 0
"unique": 0, },
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"description": "Products to be shown on website homepage",
"fieldname": "products",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Products",
"length": 0,
"no_copy": 0,
"options": "Homepage Featured Product",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0,
"width": "40px" "width": "40px"
} }
], ],
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"idx": 0, "idx": 0,
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0, "in_dialog": 0,
"is_submittable": 0, "is_submittable": 0,
"issingle": 1, "issingle": 1,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-08-09 05:01:30.287861", "modified": "2016-08-29 01:28:00.961623",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Portal", "module": "Portal",
"name": "Homepage", "name": "Homepage",
"name_case": "", "name_case": "",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
"amend": 0, "amend": 0,
"apply_user_permissions": 0, "apply_user_permissions": 0,
"cancel": 0, "cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 0, "export": 0,
"if_owner": 0, "if_owner": 0,
"import": 0, "import": 0,
"permlevel": 0, "permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 0, "report": 0,
"role": "System Manager", "role": "System Manager",
"set_user_permissions": 0, "set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0, "submit": 0,
"write": 1 "write": 1
}, },
{ {
"amend": 0, "amend": 0,
"apply_user_permissions": 0, "apply_user_permissions": 0,
"cancel": 0, "cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 0, "export": 0,
"if_owner": 0, "if_owner": 0,
"import": 0, "import": 0,
"permlevel": 0, "permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 0, "report": 0,
"role": "Administrator", "role": "Administrator",
"set_user_permissions": 0, "set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0, "submit": 0,
"write": 1 "write": 1
} }
], ],
"quick_entry": 0, "quick_entry": 0,
"read_only": 0, "read_only": 0,
"read_only_onload": 0, "read_only_onload": 0,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"title_field": "company", "title_field": "company",
"track_seen": 0 "track_seen": 0
} }

View File

@ -5,6 +5,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
from frappe.website.utils import delete_page_cache
class Homepage(Document): class Homepage(Document):
def validate(self): def validate(self):
@ -12,6 +13,7 @@ class Homepage(Document):
self.setup_items() self.setup_items()
if not self.description: if not self.description:
self.description = frappe._("This is an example website auto-generated from ERPNext") self.description = frappe._("This is an example website auto-generated from ERPNext")
delete_page_cache('home')
def setup_items(self): def setup_items(self):
for d in frappe.get_all('Item', fields=['name', 'item_name', 'description', 'image'], for d in frappe.get_all('Item', fields=['name', 'item_name', 'description', 'image'],

View File

@ -586,7 +586,8 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)){ if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)){
$.each(this.frm.doc['payments'] || [], function(index, data){ $.each(this.frm.doc['payments'] || [], function(index, data){
if(data.type == "Cash" && payment_status) { if(data.type == "Cash" && payment_status) {
data.amount = total_amount_to_pay; data.base_amount = flt(total_amount_to_pay, precision("base_amount"));
data.amount = flt(total_amount_to_pay / me.frm.doc.conversion_rate, precision("amount"));
payment_status = false; payment_status = false;
}else if(me.frm.doc.paid_amount){ }else if(me.frm.doc.paid_amount){
data.amount = 0.0; data.amount = 0.0;
@ -599,7 +600,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
var me = this; var me = this;
var paid_amount = base_paid_amount = 0.0; var paid_amount = base_paid_amount = 0.0;
$.each(this.frm.doc['payments'] || [], function(index, data){ $.each(this.frm.doc['payments'] || [], function(index, data){
data.base_amount = flt(data.amount * me.frm.doc.conversion_rate); data.base_amount = flt(data.amount * me.frm.doc.conversion_rate, precision("base_amount"));
paid_amount += data.amount; paid_amount += data.amount;
base_paid_amount += data.base_amount; base_paid_amount += data.base_amount;
}) })

View File

@ -26,9 +26,8 @@
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
<!-- TODO: remove hardcoding of /products -->
<div class="text-center padding"> <div class="text-center padding">
<a href="/products" class="btn btn-primary all-products"> <a href="{{ homepage.products_url or "/products" }}" class="btn btn-primary all-products">
{{ _("View All Products") }}</a></div> {{ _("View All Products") }}</a></div>
</div> </div>
{% endif %} {% endif %}