Merge branch 'hotfix' into default_warehouse_for_sales_return

This commit is contained in:
sahil28297
2019-05-03 00:05:22 +05:30
committed by GitHub
328 changed files with 33624 additions and 20052 deletions

View File

@@ -1,6 +1,6 @@
[
{
"brand": "_Test Brand",
"brand": "_Test Brand",
"doctype": "Brand"
}
]

View File

@@ -16,6 +16,12 @@ frappe.ui.form.on("Company", {
filters: {"is_additional_component": 1}
}
});
frm.set_query("parent_company", function() {
return {
filters: {"is_group": 1}
}
});
},
company_name: function(frm) {
@@ -28,6 +34,13 @@ frappe.ui.form.on("Company", {
}
},
parent_company: function(frm) {
var bool = frm.doc.parent_company ? true : false;
frm.set_value('create_chart_of_accounts_based_on', bool ? "Existing Company" : "");
frm.set_value('existing_company', bool ? frm.doc.parent_company : "");
disbale_coa_fields(frm, bool);
},
date_of_commencement: function(frm) {
if(frm.doc.date_of_commencement<frm.doc.date_of_incorporation)
{
@@ -39,8 +52,10 @@ frappe.ui.form.on("Company", {
},
refresh: function(frm) {
if(frm.doc.abbr && !frm.doc.__islocal) {
frm.set_df_property("abbr", "read_only", 1);
if(!frm.doc.__islocal) {
frm.doc.abbr && frm.set_df_property("abbr", "read_only", 1);
frm.set_df_property("parent_company", "read_only", 1);
disbale_coa_fields(frm);
}
frm.toggle_display('address_html', !frm.doc.__islocal);
@@ -256,3 +271,9 @@ erpnext.company.set_custom_query = function(frm, v) {
}
});
}
var disbale_coa_fields = function(frm, bool=true) {
frm.set_df_property("create_chart_of_accounts_based_on", "read_only", bool);
frm.set_df_property("chart_of_accounts", "read_only", bool);
frm.set_df_property("existing_company", "read_only", bool);
};

File diff suppressed because it is too large Load Diff

View File

@@ -39,6 +39,7 @@ class Company(NestedSet):
self.validate_coa_input()
self.validate_perpetual_inventory()
self.check_country_change()
self.set_chart_of_accounts()
def validate_abbr(self):
if not self.abbr:
@@ -141,6 +142,7 @@ class Company(NestedSet):
def create_default_accounts(self):
from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts
frappe.local.flags.ignore_root_company_validation = True
create_charts(self.name, self.chart_of_accounts, self.existing_company)
frappe.db.set(self, "default_receivable_account", frappe.db.get_value("Account",
@@ -173,6 +175,12 @@ class Company(NestedSet):
self.country != frappe.get_cached_value('Company', self.name, 'country'):
frappe.flags.country_change = True
def set_chart_of_accounts(self):
''' If parent company is set, chart of accounts will be based on that company '''
if self.parent_company:
self.create_chart_of_accounts_based_on = "Existing Company"
self.existing_company = self.parent_company
def set_default_accounts(self):
self._set_default_account("default_cash_account", "Cash")
self._set_default_account("default_bank_account", "Bank")
@@ -369,7 +377,7 @@ def replace_abbr(company, old, new):
for d in doc:
_rename_record(d)
for dt in ["Warehouse", "Account", "Cost Center", "Department", "Location",
for dt in ["Warehouse", "Account", "Cost Center", "Department",
"Sales Taxes and Charges Template", "Purchase Taxes and Charges Template"]:
_rename_records(dt)
frappe.db.commit()

View File

@@ -4,6 +4,8 @@ from __future__ import unicode_literals
import frappe
import unittest
import json
from frappe import _
from frappe.utils import random_string
from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import get_charts_for_country
@@ -78,7 +80,10 @@ class TestCompany(unittest.TestCase):
if account_type in ["Bank", "Cash"]:
filters["is_group"] = 1
self.assertTrue(frappe.get_all("Account", filters))
has_matching_accounts = frappe.get_all("Account", filters)
error_message = _("No Account matched these filters: {}".format(json.dumps(filters)))
self.assertTrue(has_matching_accounts, msg=error_message)
finally:
self.delete_mode_of_payment(template)
frappe.delete_doc("Company", template)

View File

@@ -1,32 +1,66 @@
[
{
"abbr": "_TC",
"company_name": "_Test Company",
"country": "India",
"default_currency": "INR",
"doctype": "Company",
"domain": "Manufacturing",
"chart_of_accounts": "Standard",
"default_holiday_list": "_Test Holiday List"
},
{
"abbr": "_TC1",
"company_name": "_Test Company 1",
"country": "United States",
"default_currency": "USD",
"doctype": "Company",
"domain": "Retail",
"chart_of_accounts": "Standard",
"default_holiday_list": "_Test Holiday List"
},
{
"abbr": "_TC2",
"company_name": "_Test Company 2",
"default_currency": "EUR",
"country": "Germany",
"doctype": "Company",
"domain": "Retail",
"chart_of_accounts": "Standard",
"default_holiday_list": "_Test Holiday List"
}
{
"abbr": "_TC",
"company_name": "_Test Company",
"country": "India",
"default_currency": "INR",
"doctype": "Company",
"domain": "Manufacturing",
"chart_of_accounts": "Standard",
"default_holiday_list": "_Test Holiday List"
},
{
"abbr": "_TC1",
"company_name": "_Test Company 1",
"country": "United States",
"default_currency": "USD",
"doctype": "Company",
"domain": "Retail",
"chart_of_accounts": "Standard",
"default_holiday_list": "_Test Holiday List"
},
{
"abbr": "_TC2",
"company_name": "_Test Company 2",
"default_currency": "EUR",
"country": "Germany",
"doctype": "Company",
"domain": "Retail",
"chart_of_accounts": "Standard",
"default_holiday_list": "_Test Holiday List"
},
{
"abbr": "_TC3",
"company_name": "_Test Company 3",
"is_group": 1,
"country": "India",
"default_currency": "INR",
"doctype": "Company",
"domain": "Manufacturing",
"chart_of_accounts": "Standard",
"default_holiday_list": "_Test Holiday List"
},
{
"abbr": "_TC4",
"company_name": "_Test Company 4",
"parent_company": "_Test Company 3",
"is_group": 1,
"country": "India",
"default_currency": "INR",
"doctype": "Company",
"domain": "Manufacturing",
"chart_of_accounts": "Standard",
"default_holiday_list": "_Test Holiday List"
},
{
"abbr": "_TC5",
"company_name": "_Test Company 5",
"parent_company": "_Test Company 4",
"country": "India",
"default_currency": "INR",
"doctype": "Company",
"domain": "Manufacturing",
"chart_of_accounts": "Standard",
"default_holiday_list": "_Test Holiday List"
}
]

View File

@@ -12,7 +12,6 @@ from frappe.website.render import clear_cache
from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow
from erpnext.shopping_cart.product_info import set_product_info_for_website
from erpnext.utilities.product import get_qty_in_stock
from frappe.utils.html_utils import clean_html
class ItemGroup(NestedSet, WebsiteGenerator):
nsm_parent_field = 'parent_item_group'
@@ -27,7 +26,6 @@ class ItemGroup(NestedSet, WebsiteGenerator):
def validate(self):
super(ItemGroup, self).validate()
self.description = clean_html(self.description)
self.make_route()
def on_update(self):

View File

@@ -135,7 +135,7 @@ class NamingSeries(Document):
def validate_series_name(self, n):
import re
if not re.match("^[\w\- /.#]*$", n, re.UNICODE):
if not (re.match("^[\w\- /.#]*$", n, re.UNICODE) or re.match("\{(.*?)\}", n, re.UNICODE)):
throw(_('Special Characters except "-", "#", "." and "/" not allowed in naming series'))
def get_options(self, arg=None):

View File

@@ -22,6 +22,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "name_and_employee_id",
"fieldtype": "Section Break",
"hidden": 0,
@@ -54,6 +55,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "sales_person_name",
"fieldtype": "Data",
"hidden": 0,
@@ -88,6 +90,7 @@
"collapsible": 0,
"columns": 0,
"description": "Select company name first.",
"fetch_if_empty": 0,
"fieldname": "parent_sales_person",
"fieldtype": "Link",
"hidden": 0,
@@ -122,6 +125,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "commission_rate",
"fieldtype": "Data",
"hidden": 0,
@@ -154,6 +158,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "is_group",
"fieldtype": "Check",
"hidden": 0,
@@ -189,6 +194,7 @@
"collapsible": 0,
"columns": 0,
"default": "1",
"fetch_if_empty": 0,
"fieldname": "enabled",
"fieldtype": "Check",
"hidden": 0,
@@ -221,6 +227,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "cb0",
"fieldtype": "Column Break",
"hidden": 0,
@@ -251,6 +258,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "employee",
"fieldtype": "Link",
"hidden": 0,
@@ -270,7 +278,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
@@ -284,6 +292,7 @@
"collapsible": 0,
"columns": 0,
"fetch_from": "employee.department",
"fetch_if_empty": 0,
"fieldname": "department",
"fieldtype": "Link",
"hidden": 0,
@@ -317,6 +326,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "lft",
"fieldtype": "Int",
"hidden": 1,
@@ -350,6 +360,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "rgt",
"fieldtype": "Int",
"hidden": 1,
@@ -383,6 +394,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "old_parent",
"fieldtype": "Data",
"hidden": 1,
@@ -417,6 +429,7 @@
"collapsible": 0,
"columns": 0,
"description": "Set targets Item Group-wise for this Sales Person.",
"fetch_if_empty": 0,
"fieldname": "target_details_section_break",
"fieldtype": "Section Break",
"hidden": 0,
@@ -450,6 +463,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "targets",
"fieldtype": "Table",
"hidden": 0,
@@ -485,6 +499,7 @@
"collapsible": 0,
"columns": 0,
"description": "Select Monthly Distribution to unevenly distribute targets across months.",
"fetch_if_empty": 0,
"fieldname": "distribution_id",
"fieldtype": "Link",
"hidden": 0,
@@ -524,7 +539,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2019-01-30 11:28:16.966735",
"modified": "2019-04-09 20:03:35.967037",
"modified_by": "Administrator",
"module": "Setup",
"name": "Sales Person",
@@ -594,7 +609,7 @@
"search_fields": "parent_sales_person",
"show_name_in_global_search": 1,
"sort_order": "ASC",
"track_changes": 1,
"track_changes": 0,
"track_seen": 0,
"track_views": 0
}

View File

@@ -21,18 +21,18 @@ class SalesPerson(NestedSet):
self.load_dashboard_info()
def load_dashboard_info(self):
company_default_currency = get_default_currency()
company_default_currency = get_default_currency()
allocated_amount = frappe.db.sql("""
select sum(allocated_amount)
from `tabSales Team`
from `tabSales Team`
where sales_person = %s and docstatus=1 and parenttype = 'Sales Order'
""",(self.sales_person_name))
info = {}
info["allocated_amount"] = flt(allocated_amount[0][0]) if allocated_amount else 0
info["currency"] = company_default_currency
self.set_onload('dashboard_info', info)
def on_update(self):
@@ -48,10 +48,11 @@ class SalesPerson(NestedSet):
return frappe.db.get_value("User", user, "email") or user
def validate_employee_id(self):
sales_person = frappe.db.get_value("Sales Person", {"employee": self.employee})
if sales_person and sales_person != self.name:
frappe.throw(_("Another Sales Person {0} exists with the same Employee id").format(sales_person))
if self.employee:
sales_person = frappe.db.get_value("Sales Person", {"employee": self.employee})
if sales_person and sales_person != self.name:
frappe.throw(_("Another Sales Person {0} exists with the same Employee id").format(sales_person))
def on_doctype_update():
frappe.db.add_index("Sales Person", ["lft", "rgt"])
@@ -65,7 +66,7 @@ def get_timeline_data(doctype, name):
from
`tabSales Order` dt, `tabSales Team` st
where
st.sales_person = %s and st.parent = dt.name and dt.transaction_date > date_sub(curdate(), interval 1 year)
st.sales_person = %s and st.parent = dt.name and dt.transaction_date > date_sub(curdate(), interval 1 year)
group by dt.transaction_date ''', name)))
sales_invoice = dict(frappe.db.sql('''select
@@ -75,7 +76,7 @@ def get_timeline_data(doctype, name):
where
st.sales_person = %s and st.parent = dt.name and dt.posting_date > date_sub(curdate(), interval 1 year)
group by dt.posting_date ''', name))
for key in sales_invoice:
if out.get(key):
out[key] += sales_invoice[key]
@@ -97,5 +98,3 @@ def get_timeline_data(doctype, name):
out[key] = delivery_note[key]
return out

View File

@@ -33,7 +33,7 @@ def make_sample_data(domains, make_dependent = False):
def make_opportunity(items, customer):
b = frappe.get_doc({
"doctype": "Opportunity",
"enquiry_from": "Customer",
"opportunity_from": "Customer",
"customer": customer,
"opportunity_type": _("Sales"),
"with_items": 1