[enhancement] default terms in company, fixes #3231
This commit is contained in:
parent
1a84d8ecd2
commit
5495bc54a5
@ -421,8 +421,3 @@ def get_outstanding_invoices(amount_query, account, party_type, party):
|
||||
})
|
||||
|
||||
return all_outstanding_vouchers
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_letter_head(company):
|
||||
return frappe.db.get_value("Company",company,"default_letter_head")
|
||||
|
||||
|
@ -194,6 +194,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
var fn = function() {
|
||||
if(me.frm.doc.company && me.frm.fields_dict.currency) {
|
||||
var company_currency = me.get_company_currency();
|
||||
var company_doc = frappe.get_doc(":Company", me.frm.doc.company);
|
||||
if (!me.frm.doc.currency) {
|
||||
me.frm.set_value("currency", company_currency);
|
||||
}
|
||||
@ -204,6 +205,12 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
if (me.frm.doc.price_list_currency == company_currency) {
|
||||
me.frm.set_value('plc_conversion_rate', 1.0);
|
||||
}
|
||||
if (company_doc.default_letter_head) {
|
||||
me.frm.set_value("letter_head", company_doc.default_letter_head);
|
||||
}
|
||||
if (company_doc.default_terms) {
|
||||
me.frm.set_value("tc_name", company_doc.default_terms);
|
||||
}
|
||||
|
||||
me.frm.script_manager.trigger("currency");
|
||||
me.apply_pricing_rule();
|
||||
@ -213,7 +220,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
if (this.frm.doc.posting_date) var date = this.frm.doc.posting_date;
|
||||
else var date = this.frm.doc.transaction_date;
|
||||
erpnext.get_fiscal_year(this.frm.doc.company, date, fn);
|
||||
erpnext.get_letter_head(this.frm.doc.company);
|
||||
|
||||
if(this.frm.doc.company) {
|
||||
erpnext.last_selected_company = this.frm.doc.company;
|
||||
|
@ -105,21 +105,7 @@ $.extend(erpnext, {
|
||||
|
||||
d.show();
|
||||
});
|
||||
},
|
||||
|
||||
get_letter_head: function(company) {
|
||||
frappe.call({
|
||||
type:"GET",
|
||||
method: "erpnext.accounts.utils.get_letter_head",
|
||||
args: {
|
||||
"company": company
|
||||
},
|
||||
callback: function(r) {
|
||||
if (!r.exe) cur_frm.set_value("letter_head", r.message);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@ -52,14 +52,6 @@
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "default_letter_head",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Letter Head",
|
||||
"options": "Letter Head",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "domain",
|
||||
"fieldtype": "Select",
|
||||
@ -72,9 +64,17 @@
|
||||
"fieldname": "charts_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"label": "Country Settings",
|
||||
"label": "Default Values",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "default_letter_head",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Letter Head",
|
||||
"options": "Letter Head",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "default_holiday_list",
|
||||
"fieldtype": "Link",
|
||||
@ -117,10 +117,18 @@
|
||||
"options": "",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "default_terms",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Terms",
|
||||
"options": "Terms and Conditions",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "default_settings",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Default Settings",
|
||||
"label": "Accounts Settings",
|
||||
"oldfieldtype": "Section Break",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
@ -406,7 +414,7 @@
|
||||
],
|
||||
"icon": "icon-building",
|
||||
"idx": 1,
|
||||
"modified": "2015-05-04 11:22:42.116328",
|
||||
"modified": "2015-05-19 02:00:41.055138",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Company",
|
||||
|
@ -63,6 +63,8 @@ class Company(Document):
|
||||
if self.default_currency:
|
||||
frappe.db.set_value("Currency", self.default_currency, "enabled", 1)
|
||||
|
||||
frappe.clear_cache()
|
||||
|
||||
def install_country_fixtures(self):
|
||||
if os.path.exists(os.path.join(os.path.dirname(__file__), "fixtures", self.country.lower())):
|
||||
frappe.get_attr("erpnext.setup.doctype.company.fixtures.{0}.install".format(self.country.lower()))(self)
|
||||
@ -167,7 +169,7 @@ class Company(Document):
|
||||
where defkey='Company' and defvalue=%s""", (newdn, olddn))
|
||||
|
||||
frappe.defaults.clear_cache()
|
||||
|
||||
|
||||
def on_trash(self):
|
||||
"""
|
||||
Trash accounts and cost centers for this company if no gl entry exists
|
||||
@ -178,7 +180,7 @@ class Company(Document):
|
||||
frappe.db.sql("delete from `tabAccount` where company = %s", self.name)
|
||||
|
||||
# delete cost center child table - budget detail
|
||||
frappe.db.sql("""delete bd.* from `tabBudget Detail` bd, `tabCost Center` cc
|
||||
frappe.db.sql("""delete bd.* from `tabBudget Detail` bd, `tabCost Center` cc
|
||||
where bd.parent = cc.name and cc.company = %s""", self.name)
|
||||
#delete cost center
|
||||
frappe.db.sql("delete from `tabCost Center` WHERE company = %s", self.name)
|
||||
|
@ -29,8 +29,9 @@ def boot_session(bootinfo):
|
||||
bootinfo.setup_complete = frappe.db.sql("""select name from
|
||||
tabCompany limit 1""") and 'Yes' or 'No'
|
||||
|
||||
bootinfo.docs += frappe.db.sql("""select name, default_currency, cost_center
|
||||
from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
|
||||
bootinfo.docs += frappe.db.sql("""select name, default_currency, cost_center,
|
||||
default_terms, default_letter_head from `tabCompany`""",
|
||||
as_dict=1, update={"doctype":":Company"})
|
||||
|
||||
def load_country_and_currency(bootinfo):
|
||||
country = frappe.db.get_default("country")
|
||||
|
Loading…
x
Reference in New Issue
Block a user