Fixed merge conflict

This commit is contained in:
Nabin Hait 2018-04-04 11:40:16 +05:30
commit 2b682c82e8
18 changed files with 65 additions and 35 deletions

View File

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

View File

@ -48,5 +48,10 @@ frappe.treeview_settings["Cost Center"] = {
}, __('Budget')); }, __('Budget'));
}, },
onrender: function(node) {
if(node.is_root){
node.hide_add = true;
}
}
} }

View File

@ -769,6 +769,8 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount=
party_account = doc.receivable_account party_account = doc.receivable_account
elif dt == "Employee Advance": elif dt == "Employee Advance":
party_account = doc.advance_account party_account = doc.advance_account
elif dt == "Expense Claim":
party_account = doc.payable_account
else: else:
party_account = get_party_account(party_type, doc.get(party_type.lower()), doc.company) party_account = get_party_account(party_type, doc.get(party_type.lower()), doc.company)

View File

@ -667,7 +667,9 @@ class AccountsController(TransactionBase):
self.remove(item) self.remove(item)
def set_payment_schedule(self): def set_payment_schedule(self):
if self.doctype == 'Sales Invoice' and self.is_pos: return if self.doctype == 'Sales Invoice' and self.is_pos:
self.payment_terms_template = ''
return
posting_date = self.get("bill_date") or self.get("posting_date") or self.get("transaction_date") posting_date = self.get("bill_date") or self.get("posting_date") or self.get("transaction_date")
date = self.get("due_date") date = self.get("due_date")

View File

@ -152,6 +152,11 @@ def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=False): def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=False):
conditions = [] conditions = []
description_cond = ''
if frappe.db.count('Item', cache=True) < 50000:
# scan description only if items are less than 50000
description_cond = 'or tabItem.description LIKE %(txt)s'
return frappe.db.sql("""select tabItem.name, tabItem.item_group, return frappe.db.sql("""select tabItem.name, tabItem.item_group,
if(length(tabItem.item_name) > 40, if(length(tabItem.item_name) > 40,
concat(substr(tabItem.item_name, 1, 40), "..."), item_name) as item_name, concat(substr(tabItem.item_name, 1, 40), "..."), item_name) as item_name,
@ -165,8 +170,8 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
and (tabItem.`{key}` LIKE %(txt)s and (tabItem.`{key}` LIKE %(txt)s
or tabItem.item_group LIKE %(txt)s or tabItem.item_group LIKE %(txt)s
or tabItem.item_name LIKE %(txt)s or tabItem.item_name LIKE %(txt)s
or tabItem.description LIKE %(txt)s) or tabItem.item_code IN (select parent from `tabItem Barcode` where barcode LIKE %(txt)s
or tabItem.item_code IN (select parent from `tabItem Barcode` where barcode LIKE %(txt)s) {description_cond})
{fcond} {mcond} {fcond} {mcond}
order by order by
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
@ -176,7 +181,8 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
limit %(start)s, %(page_len)s """.format( limit %(start)s, %(page_len)s """.format(
key=searchfield, key=searchfield,
fcond=get_filters_cond(doctype, filters, conditions).replace('%', '%%'), fcond=get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
mcond=get_match_cond(doctype).replace('%', '%%')), mcond=get_match_cond(doctype).replace('%', '%%'),
description_cond = description_cond),
{ {
"today": nowdate(), "today": nowdate(),
"txt": "%%%s%%" % txt, "txt": "%%%s%%" % txt,

View File

@ -34,14 +34,14 @@ def work():
payroll_entry.salary_slip_based_on_timesheet = 0 payroll_entry.salary_slip_based_on_timesheet = 0
payroll_entry.create_salary_slips() payroll_entry.create_salary_slips()
payroll_entry.submit_salary_slips() payroll_entry.submit_salary_slips()
payroll_entry.make_accural_jv_entry() payroll_entry.make_accrual_jv_entry()
# payroll_entry.make_journal_entry(reference_date=frappe.flags.current_date, # payroll_entry.make_journal_entry(reference_date=frappe.flags.current_date,
# reference_number=random_string(10)) # reference_number=random_string(10))
payroll_entry.salary_slip_based_on_timesheet = 1 payroll_entry.salary_slip_based_on_timesheet = 1
payroll_entry.create_salary_slips() payroll_entry.create_salary_slips()
payroll_entry.submit_salary_slips() payroll_entry.submit_salary_slips()
payroll_entry.make_accural_jv_entry() payroll_entry.make_accrual_jv_entry()
# payroll_entry.make_journal_entry(reference_date=frappe.flags.current_date, # payroll_entry.make_journal_entry(reference_date=frappe.flags.current_date,
# reference_number=random_string(10)) # reference_number=random_string(10))

View File

@ -24,7 +24,7 @@ In the document, you can select multiple Purchase Receipts and fetch all items f
<img class="screenshot" alt="Landed Cost Vouher" src="{{docs_base_url}}/assets/img/stock/landed-cost.png"> <img class="screenshot" alt="Landed Cost Vouher" src="{{docs_base_url}}/assets/img/stock/landed-cost.png">
### What happend on submission? ### What happens on submission?
1. On submission of Landed Cost Voucher, the applicable landed cost charges are updated in Purchase Receipt Item table. 1. On submission of Landed Cost Voucher, the applicable landed cost charges are updated in Purchase Receipt Item table.

View File

@ -26,7 +26,7 @@ class ProgramEnrollmentTool(Document):
elif self.get_students_from == "Program Enrollment": elif self.get_students_from == "Program Enrollment":
condition2 = 'and student_batch_name=%(student_batch)s' if self.student_batch else " " condition2 = 'and student_batch_name=%(student_batch)s' if self.student_batch else " "
students = frappe.db.sql('''select student, student_name, student_batch_name from `tabProgram Enrollment` students = frappe.db.sql('''select student, student_name, student_batch_name from `tabProgram Enrollment`
where program=%(program)s and academic_year=%(academic_year)s {0} {1}''' where program=%(program)s and academic_year=%(academic_year)s {0} {1} and docstatus != 2'''
.format(condition, condition2), self.as_dict(), as_dict=1) .format(condition, condition2), self.as_dict(), as_dict=1)
student_list = [d.student for d in students] student_list = [d.student for d in students]

View File

@ -199,7 +199,6 @@ doc_events = {
"validate": "erpnext.portal.doctype.products_settings.products_settings.home_page_is_products" "validate": "erpnext.portal.doctype.products_settings.products_settings.home_page_is_products"
}, },
"Sales Invoice": { "Sales Invoice": {
'validate': 'erpnext.regional.india.utils.set_place_of_supply',
"on_submit": "erpnext.regional.france.utils.create_transaction_log", "on_submit": "erpnext.regional.france.utils.create_transaction_log",
"on_trash": "erpnext.regional.check_deletion_permission" "on_trash": "erpnext.regional.check_deletion_permission"
}, },
@ -210,7 +209,7 @@ doc_events = {
'Address': { 'Address': {
'validate': 'erpnext.regional.india.utils.validate_gstin_for_india' 'validate': 'erpnext.regional.india.utils.validate_gstin_for_india'
}, },
'Purchase Invoice': { ('Sales Invoice', 'Purchase Invoice', 'Delivery Note'): {
'validate': 'erpnext.regional.india.utils.set_place_of_supply' 'validate': 'erpnext.regional.india.utils.set_place_of_supply'
} }
} }

View File

@ -82,9 +82,9 @@ cur_frm.cscript.refresh = function(doc) {
if (cint(doc.total_amount_reimbursed) > 0 && frappe.model.can_read(entry_doctype)) { if (cint(doc.total_amount_reimbursed) > 0 && frappe.model.can_read(entry_doctype)) {
cur_frm.add_custom_button(__('Bank Entries'), function() { cur_frm.add_custom_button(__('Bank Entries'), function() {
frappe.route_options = { frappe.route_options = {
entry_route_doctype: me.frm.doc.doctype, party_type: "Employee",
entry_route_name: me.frm.doc.name, party: doc.employee,
company: me.frm.doc.company company: doc.company
}; };
frappe.set_route("List", entry_doctype); frappe.set_route("List", entry_doctype);
}, __("View")); }, __("View"));
@ -181,7 +181,7 @@ frappe.ui.form.on("Expense Claim", {
make_payment_entry: function(frm) { make_payment_entry: function(frm) {
var method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry"; var method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry";
if(frm.doc.__onload && frm.doc.__onload.make_payment_via_journal_entry) { if(frm.doc.__onload && frm.doc.__onload.make_payment_via_journal_entry) {
method = "erpnext.hr.doctype.expense_claim.expense_claim.make_bank_entry" method = "erpnext.hr.doctype.expense_claim.expense_claim.make_bank_entry";
} }
return frappe.call({ return frappe.call({
method: method, method: method,

View File

@ -164,7 +164,7 @@ class PayrollEntry(Document):
except frappe.ValidationError: except frappe.ValidationError:
not_submitted_ss.append(ss_dict) not_submitted_ss.append(ss_dict)
if submitted_ss: if submitted_ss:
jv_name = self.make_accural_jv_entry() jv_name = self.make_accrual_jv_entry()
frappe.msgprint(_("Salary Slip submitted for period from {0} to {1}") frappe.msgprint(_("Salary Slip submitted for period from {0} to {1}")
.format(ss_obj.start_date, ss_obj.end_date)) .format(ss_obj.start_date, ss_obj.end_date))
@ -237,7 +237,7 @@ class PayrollEntry(Document):
return payroll_payable_account return payroll_payable_account
def make_accural_jv_entry(self): def make_accrual_jv_entry(self):
self.check_permission('write') self.check_permission('write')
earnings = self.get_salary_component_total(component_type = "earnings") or {} earnings = self.get_salary_component_total(component_type = "earnings") or {}
deductions = self.get_salary_component_total(component_type = "deductions") or {} deductions = self.get_salary_component_total(component_type = "deductions") or {}
@ -249,7 +249,7 @@ class PayrollEntry(Document):
if earnings or deductions: if earnings or deductions:
journal_entry = frappe.new_doc('Journal Entry') journal_entry = frappe.new_doc('Journal Entry')
journal_entry.voucher_type = 'Journal Entry' journal_entry.voucher_type = 'Journal Entry'
journal_entry.user_remark = _('Accural Journal Entry for salaries from {0} to {1}')\ journal_entry.user_remark = _('Accrual Journal Entry for salaries from {0} to {1}')\
.format(self.start_date, self.end_date) .format(self.start_date, self.end_date)
journal_entry.company = self.company journal_entry.company = self.company
journal_entry.posting_date = self.posting_date journal_entry.posting_date = self.posting_date

View File

@ -17,6 +17,5 @@ class SalaryComponent(Document):
self.salary_component.split()]).upper() self.salary_component.split()]).upper()
self.salary_component_abbr = self.salary_component_abbr.strip() self.salary_component_abbr = self.salary_component_abbr.strip()
self.salary_component_abbr = append_number_if_name_exists('Salary Component', self.salary_component_abbr,
self.salary_component_abbr = append_number_if_name_exists('Salary Component', 'salary_component_abbr', separator='_', filters={"name": ["!=", self.name]})
self.salary_component_abbr, 'salary_component_abbr', separator='_')

View File

@ -39,6 +39,16 @@ frappe.ui.form.on('Salary Structure', {
} }
} }
}); });
frm.set_query("payment_account", function () {
var account_types = ["Bank", "Cash"];
return {
filters: {
"account_type": ["in", account_types],
"is_group": 0,
"company": frm.doc.company
}
};
});
}, },
refresh: function(frm) { refresh: function(frm) {

View File

@ -106,7 +106,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
} }
if( if(
this.frm.fields_dict["payment_terms_template"] this.frm.docstatus < 2
&& this.frm.fields_dict["payment_terms_template"]
&& this.frm.fields_dict["payment_schedule"] && this.frm.fields_dict["payment_schedule"]
&& this.frm.doc.payment_terms_template && this.frm.doc.payment_terms_template
&& !this.frm.doc.payment_schedule.length && !this.frm.doc.payment_schedule.length

View File

@ -64,7 +64,7 @@ def get_itemised_tax_breakup_data(doc):
def set_place_of_supply(doc, method): def set_place_of_supply(doc, method):
if not frappe.get_meta('Address').has_field('gst_state'): return if not frappe.get_meta('Address').has_field('gst_state'): return
if doc.doctype == "Sales Invoice": if doc.doctype in ("Sales Invoice", "Delivery Note"):
address_name = doc.shipping_address_name or doc.customer_address address_name = doc.shipping_address_name or doc.customer_address
elif doc.doctype == "Purchase Invoice": elif doc.doctype == "Purchase Invoice":
address_name = doc.shipping_address or doc.supplier_address address_name = doc.shipping_address or doc.supplier_address

View File

@ -85,7 +85,7 @@ def delete_lead_addresses(company_name):
in ({leads})""".format(leads=",".join(leads))) in ({leads})""".format(leads=",".join(leads)))
if addresses: if addresses:
addresses = ["'%s'"%addr for addr in addresses] addresses = ["'%s'"%frappe.db.escape(addr) for addr in addresses]
frappe.db.sql("""delete from tabAddress where name in ({addresses}) and frappe.db.sql("""delete from tabAddress where name in ({addresses}) and
name not in (select distinct dl1.parent from `tabDynamic Link` dl1 name not in (select distinct dl1.parent from `tabDynamic Link` dl1

View File

@ -7,8 +7,9 @@ from frappe import _
def execute(filters=None): def execute(filters=None):
columns = get_columns() columns = get_columns()
sl_entries = get_stock_ledger_entries(filters) item_conditions = get_item_conditions(filters)
item_details = get_item_details(filters) item_details = get_item_details(filters, item_conditions)
sl_entries = get_stock_ledger_entries(filters, item_conditions, item_details)
opening_row = get_opening_balance(filters, columns) opening_row = get_opening_balance(filters, columns)
data = [] data = []
@ -52,7 +53,12 @@ def get_columns():
return columns return columns
def get_stock_ledger_entries(filters): def get_stock_ledger_entries(filters, item_conditions, item_details):
item_conditions_sql = ''
if item_conditions:
items = ['"' + frappe.db.escape(i) + '"' for i in item_details.keys()]
if items:
item_conditions_sql = 'and sle.item_code in ({})'.format(', '.join(items))
return frappe.db.sql("""select concat_ws(" ", posting_date, posting_time) as date, return frappe.db.sql("""select concat_ws(" ", posting_date, posting_time) as date,
item_code, warehouse, actual_qty, qty_after_transaction, incoming_rate, valuation_rate, item_code, warehouse, actual_qty, qty_after_transaction, incoming_rate, valuation_rate,
stock_value, voucher_type, voucher_no, batch_no, serial_no, company, project stock_value, voucher_type, voucher_no, batch_no, serial_no, company, project
@ -60,14 +66,18 @@ def get_stock_ledger_entries(filters):
where company = %(company)s and where company = %(company)s and
posting_date between %(from_date)s and %(to_date)s posting_date between %(from_date)s and %(to_date)s
{sle_conditions} {sle_conditions}
{item_conditions_sql}
order by posting_date asc, posting_time asc, name asc"""\ order by posting_date asc, posting_time asc, name asc"""\
.format(sle_conditions=get_sle_conditions(filters)), filters, as_dict=1) .format(
sle_conditions=get_sle_conditions(filters),
item_conditions_sql = item_conditions_sql
), filters, as_dict=1)
def get_item_details(filters): def get_item_details(filters, item_conditions):
item_details = {} item_details = {}
for item in frappe.db.sql("""select name, item_name, description, item_group, for item in frappe.db.sql("""select name, item_name, description, item_group,
brand, stock_uom from `tabItem` item {item_conditions}"""\ brand, stock_uom from `tabItem` item {item_conditions}"""\
.format(item_conditions=get_item_conditions(filters)), filters, as_dict=1): .format(item_conditions=item_conditions), filters, as_dict=1):
item_details.setdefault(item.name, item) item_details.setdefault(item.name, item)
return item_details return item_details
@ -85,10 +95,6 @@ def get_item_conditions(filters):
def get_sle_conditions(filters): def get_sle_conditions(filters):
conditions = [] conditions = []
item_conditions=get_item_conditions(filters)
if item_conditions:
conditions.append("""sle.item_code in (select item.name from tabItem item
{item_conditions})""".format(item_conditions=item_conditions))
if filters.get("warehouse"): if filters.get("warehouse"):
warehouse_condition = get_warehouse_condition(filters.get("warehouse")) warehouse_condition = get_warehouse_condition(filters.get("warehouse"))
if warehouse_condition: if warehouse_condition:

View File

@ -444,7 +444,7 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
last_valuation_rate = frappe.db.sql("""select valuation_rate last_valuation_rate = frappe.db.sql("""select valuation_rate
from `tabStock Ledger Entry` from `tabStock Ledger Entry`
where item_code = %s and warehouse = %s where item_code = %s and warehouse = %s
and valuation_rate > 0 and valuation_rate >= 0
order by posting_date desc, posting_time desc, name desc limit 1""", (item_code, warehouse)) order by posting_date desc, posting_time desc, name desc limit 1""", (item_code, warehouse))
if not last_valuation_rate: if not last_valuation_rate: