Merge pull request #2022 from nabinhait/hotfix

Fixes for customer / supplier renaming
This commit is contained in:
Rushabh Mehta 2014-08-05 10:42:44 +05:30
commit a8755af0fa
6 changed files with 27 additions and 25 deletions

View File

@ -322,15 +322,21 @@ def get_actual_expense(args):
and fiscal_year='%(fiscal_year)s' and company='%(company)s' %(condition)s and fiscal_year='%(fiscal_year)s' and company='%(company)s' %(condition)s
""" % (args))[0][0] """ % (args))[0][0]
def rename_account_for(dt, olddn, newdn, merge, company): def rename_account_for(dt, olddn, newdn, merge, company=None):
old_account = get_account_for(dt, olddn) if not company:
companies = [d[0] for d in frappe.db.sql("select name from tabCompany")]
else:
companies = [company]
for company in companies:
old_account = get_account_for(dt, olddn, company)
if old_account: if old_account:
new_account = None new_account = None
if not merge: if not merge:
if old_account == add_abbr_if_missing(olddn, company): if old_account == add_abbr_if_missing(olddn, company):
new_account = frappe.rename_doc("Account", old_account, newdn) new_account = frappe.rename_doc("Account", old_account, newdn)
else: else:
existing_new_account = get_account_for(dt, newdn) existing_new_account = get_account_for(dt, newdn, company)
new_account = frappe.rename_doc("Account", old_account, new_account = frappe.rename_doc("Account", old_account,
existing_new_account or newdn, merge=True if existing_new_account else False) existing_new_account or newdn, merge=True if existing_new_account else False)
@ -340,14 +346,14 @@ def add_abbr_if_missing(dn, company):
from erpnext.setup.doctype.company.company import get_name_with_abbr from erpnext.setup.doctype.company.company import get_name_with_abbr
return get_name_with_abbr(dn, company) return get_name_with_abbr(dn, company)
def get_account_for(account_for_doctype, account_for): def get_account_for(account_for_doctype, account_for, company):
if account_for_doctype in ["Customer", "Supplier"]: if account_for_doctype in ["Customer", "Supplier"]:
account_for_field = "master_type" account_for_field = "master_type"
elif account_for_doctype == "Warehouse": elif account_for_doctype == "Warehouse":
account_for_field = "account_type" account_for_field = "account_type"
return frappe.db.get_value("Account", {account_for_field: account_for_doctype, return frappe.db.get_value("Account", {account_for_field: account_for_doctype,
"master_name": account_for}) "master_name": account_for, "company": company})
def get_currency_precision(currency=None): def get_currency_precision(currency=None):
if not currency: if not currency:

View File

@ -88,7 +88,7 @@ class Supplier(TransactionBase):
def before_rename(self, olddn, newdn, merge=False): def before_rename(self, olddn, newdn, merge=False):
from erpnext.accounts.utils import rename_account_for from erpnext.accounts.utils import rename_account_for
rename_account_for("Supplier", olddn, newdn, merge, self.company) rename_account_for("Supplier", olddn, newdn, merge)
def after_rename(self, olddn, newdn, merge=False): def after_rename(self, olddn, newdn, merge=False):
set_field = '' set_field = ''

View File

@ -121,7 +121,7 @@ class Customer(TransactionBase):
def before_rename(self, olddn, newdn, merge=False): def before_rename(self, olddn, newdn, merge=False):
from erpnext.accounts.utils import rename_account_for from erpnext.accounts.utils import rename_account_for
rename_account_for("Customer", olddn, newdn, merge, self.company) rename_account_for("Customer", olddn, newdn, merge)
def after_rename(self, olddn, newdn, merge=False): def after_rename(self, olddn, newdn, merge=False):
set_field = '' set_field = ''

View File

@ -52,11 +52,7 @@ def make_maintenance_visit(source_name, target_doc=None):
target_doc = get_mapped_doc("Customer Issue", source_name, { target_doc = get_mapped_doc("Customer Issue", source_name, {
"Customer Issue": { "Customer Issue": {
"doctype": "Maintenance Visit", "doctype": "Maintenance Visit",
"field_map": { "field_map": {}
"complaint": "description",
"doctype": "prevdoc_doctype",
"name": "prevdoc_docname"
}
} }
}, target_doc) }, target_doc)

View File

@ -22,12 +22,12 @@
{%- endif %} {%- endif %}
{% if (not row.meta.is_print_hide("item_name") and {% if (not row.meta.is_print_hide("item_name") and
(row.meta.is_print_hide("item_code") or row.item_code != row.item_name)) -%} (row.meta.is_print_hide("item_code") or row.item_code != row.item_name)) -%}
<div class="primary">{{ row.item_name }}</div> <div class="primary">{{ row.get_formatted("item_name",as_html=True) }}</div>
{%- endif %} {%- endif %}
{% if (not row.meta.is_print_hide("description") and row.description and {% if (not row.meta.is_print_hide("description") and row.description and
((row.meta.is_print_hide("item_code") and row.meta.is_print_hide("item_name")) ((row.meta.is_print_hide("item_code") and row.meta.is_print_hide("item_name"))
or not (row.item_code == row.item_name == row.description))) -%} or not (row.item_code == row.item_name == row.description))) -%}
<p>{{ row.description }}</p> <p>{{ row.get_formatted("description", as_html=True) }}</p>
{%- endif %} {%- endif %}
{%- for field in visible_columns -%} {%- for field in visible_columns -%}
{%- if (field.fieldname not in std_fields) and {%- if (field.fieldname not in std_fields) and

View File

@ -5,10 +5,10 @@
{%- if not charge.included_in_print_rate -%} {%- if not charge.included_in_print_rate -%}
<div class="row"> <div class="row">
<div class="col-xs-5 text-right"> <div class="col-xs-5 text-right">
<label>{{ charge.description }}</label></div> <label>{{ charge.get_formatted("description", as_html=True) }}</label></div>
<div class="col-xs-7 text-right"> <div class="col-xs-7 text-right">
{{ frappe.format_value(charge.tax_amount / doc.conversion_rate, {{ frappe.format_value(charge.tax_amount / doc.conversion_rate,
table_meta.get_field("tax_amount"), doc) }} table_meta.get_field("tax_amount"), doc, currency=doc.currency) }}
</div> </div>
</div> </div>
{%- endif -%} {%- endif -%}