Merge branch 'master' into cms2
This commit is contained in:
commit
9078f652c3
@ -484,11 +484,13 @@ def manage_recurring_invoices():
|
|||||||
Create recurring invoices on specific date by copying the original one
|
Create recurring invoices on specific date by copying the original one
|
||||||
and notify the concerned people
|
and notify the concerned people
|
||||||
"""
|
"""
|
||||||
rv = webnotes.conn.sql("""select name, recurring_id from `tabSales Invoice` where ifnull(convert_into_recurring_invoice, 0) = 1
|
rv = webnotes.conn.sql("""select name, recurring_id from `tabSales Invoice` \
|
||||||
and next_date = %s and next_date <= ifnull(end_date, '2199-12-31') and docstatus=1""", nowdate())
|
where ifnull(convert_into_recurring_invoice, 0) = 1 and next_date = %s \
|
||||||
|
and next_date <= ifnull(end_date, '2199-12-31') and docstatus=1""", nowdate())
|
||||||
|
|
||||||
for d in rv:
|
for d in rv:
|
||||||
if not webnotes.conn.sql("""select name from `tabSales Invoice` where posting_date = %s and recurring_id = %s and docstatus=1""", (nowdate(), d[1])):
|
if not webnotes.conn.sql("""select name from `tabSales Invoice` \
|
||||||
|
where posting_date = %s and recurring_id = %s and docstatus=1""", (nowdate(), d[1])):
|
||||||
prev_rv = get_obj('Sales Invoice', d[0], with_children=1)
|
prev_rv = get_obj('Sales Invoice', d[0], with_children=1)
|
||||||
new_rv = create_new_invoice(prev_rv)
|
new_rv = create_new_invoice(prev_rv)
|
||||||
|
|
||||||
@ -499,13 +501,16 @@ def create_new_invoice(prev_rv):
|
|||||||
# clone rv
|
# clone rv
|
||||||
new_rv = clone(prev_rv)
|
new_rv = clone(prev_rv)
|
||||||
|
|
||||||
|
mdict = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
|
||||||
|
mcount = mdict[prev_rv.doc.recurring_type]
|
||||||
|
|
||||||
# update new rv
|
# update new rv
|
||||||
|
|
||||||
new_rv.doc.posting_date = new_rv.doc.next_date
|
new_rv.doc.posting_date = new_rv.doc.next_date
|
||||||
new_rv.doc.aging_date = new_rv.doc.next_date
|
new_rv.doc.aging_date = new_rv.doc.next_date
|
||||||
new_rv.doc.due_date = add_days(new_rv.doc.next_date, cint(date_diff(prev_rv.doc.due_date, prev_rv.doc.posting_date)))
|
new_rv.doc.due_date = add_days(new_rv.doc.next_date, cint(date_diff(prev_rv.doc.due_date, prev_rv.doc.posting_date)))
|
||||||
new_rv.doc.invoice_period_from_date = get_next_month_date(new_rv.doc.invoice_period_from_date)
|
new_rv.doc.invoice_period_from_date = get_next_date(new_rv.doc.invoice_period_from_date, mcount)
|
||||||
new_rv.doc.invoice_period_to_date = get_next_month_date(new_rv.doc.invoice_period_to_date)
|
new_rv.doc.invoice_period_to_date = get_next_date(new_rv.doc.invoice_period_to_date, mcount)
|
||||||
new_rv.doc.owner = prev_rv.doc.owner
|
new_rv.doc.owner = prev_rv.doc.owner
|
||||||
new_rv.doc.save()
|
new_rv.doc.save()
|
||||||
|
|
||||||
@ -515,13 +520,13 @@ def create_new_invoice(prev_rv):
|
|||||||
|
|
||||||
return new_rv
|
return new_rv
|
||||||
|
|
||||||
def get_next_month_date(dt):
|
def get_next_date(dt, mcount):
|
||||||
import datetime
|
import datetime
|
||||||
m = getdate(dt).month + 1
|
m = getdate(dt).month + mcount
|
||||||
y = getdate(dt).year
|
y = getdate(dt).year
|
||||||
d = getdate(dt).day
|
d = getdate(dt).day
|
||||||
if m > 12:
|
if m > 12:
|
||||||
m, y = 1, y+1
|
m, y = m-12, y+1
|
||||||
try:
|
try:
|
||||||
next_month_date = datetime.date(y, m, d)
|
next_month_date = datetime.date(y, m, d)
|
||||||
except:
|
except:
|
||||||
|
@ -686,7 +686,9 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
def convert_into_recurring(self):
|
def convert_into_recurring(self):
|
||||||
if self.doc.convert_into_recurring_invoice:
|
if self.doc.convert_into_recurring_invoice:
|
||||||
if not self.doc.invoice_period_from_date or not self.doc.invoice_period_to_date:
|
if not self.doc.recurring_type:
|
||||||
|
msgprint("Please select recurring type", raise_exception=1)
|
||||||
|
elif not self.doc.invoice_period_from_date or not self.doc.invoice_period_to_date:
|
||||||
msgprint("Invoice period from date and to date is mandatory for recurring invoice", raise_exception=1)
|
msgprint("Invoice period from date and to date is mandatory for recurring invoice", raise_exception=1)
|
||||||
self.set_next_date()
|
self.set_next_date()
|
||||||
if not self.doc.recurring_id:
|
if not self.doc.recurring_id:
|
||||||
@ -702,10 +704,11 @@ class DocType(TransactionBase):
|
|||||||
will be generated e.g. 05, 28 etc.""", raise_exception=1)
|
will be generated e.g. 05, 28 etc.""", raise_exception=1)
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
m = getdate(self.doc.posting_date).month + 1
|
mcount = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
|
||||||
|
m = getdate(self.doc.posting_date).month + mcount[self.doc.recurring_type]
|
||||||
y = getdate(self.doc.posting_date).year
|
y = getdate(self.doc.posting_date).year
|
||||||
if m > 12:
|
if m > 12:
|
||||||
m, y = 1, y+1
|
m, y = m-12, y+1
|
||||||
try:
|
try:
|
||||||
next_date = datetime.date(y, m, cint(self.doc.repeat_on_day_of_month))
|
next_date = datetime.date(y, m, cint(self.doc.repeat_on_day_of_month))
|
||||||
except:
|
except:
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
'creation': '2012-04-13 11:56:18',
|
'creation': '2012-06-11 12:09:54',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-06-04 14:40:59',
|
'modified': '2012-06-17 21:37:40',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'Administrator'
|
'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
@ -1480,6 +1480,21 @@
|
|||||||
'trigger': u'Client'
|
'trigger': u'Client'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'allow_on_submit': 1,
|
||||||
|
'depends_on': u'eval:doc.convert_into_recurring_invoice==1',
|
||||||
|
'description': u'Select the period when the invoice will be generated automatically',
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'recurring_type',
|
||||||
|
'fieldtype': u'Select',
|
||||||
|
'label': u'Recurring Type',
|
||||||
|
'no_copy': 1,
|
||||||
|
'options': u'Monthly\nQuarterly\nHalf-yearly\nYearly',
|
||||||
|
'permlevel': 0,
|
||||||
|
'print_hide': 1
|
||||||
|
},
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'allow_on_submit': 1,
|
'allow_on_submit': 1,
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# add expense head columns
|
# add expense head columns
|
||||||
|
from webnotes.utils import flt, cint, cstr
|
||||||
|
|
||||||
expense_acc = [c[0] for c in sql("""select distinct expense_head
|
expense_acc = [c[0] for c in sql("""select distinct expense_head
|
||||||
from `tabPurchase Invoice Item`
|
from `tabPurchase Invoice Item`
|
||||||
where parenttype='Purchase Invoice'
|
where parenttype='Purchase Invoice'
|
||||||
@ -39,7 +41,7 @@ tax_acc = [c[0] for c in sql("""select distinct account_head
|
|||||||
order by account_head asc""")]
|
order by account_head asc""")]
|
||||||
|
|
||||||
tax_acc.append('Total Tax')
|
tax_acc.append('Total Tax')
|
||||||
tax_acc.append('GrandTotal')
|
tax_acc.append('Grand Total')
|
||||||
|
|
||||||
for c in tax_acc:
|
for c in tax_acc:
|
||||||
if c:
|
if c:
|
||||||
@ -58,56 +60,41 @@ for r in res:
|
|||||||
exp_head_amount = sql("""select expense_head, sum(amount)
|
exp_head_amount = sql("""select expense_head, sum(amount)
|
||||||
from `tabPurchase Invoice Item`
|
from `tabPurchase Invoice Item`
|
||||||
where parent = %s and parenttype='Purchase Invoice'
|
where parent = %s and parenttype='Purchase Invoice'
|
||||||
group by expense_head""", (r[col_idx['ID']],))
|
group by expense_head""", (r[col_idx['ID']]))
|
||||||
|
|
||||||
#convert the result to dictionary for easy retrieval
|
#convert the result to dictionary for easy retrieval
|
||||||
exp_head_amount_dict = {}
|
exp_head_amount_dict = {}
|
||||||
for e in exp_head_amount:
|
for e in exp_head_amount:
|
||||||
exp_head_amount_dict[e[0]] = e[1]
|
exp_head_amount_dict[e[0]] = e[1]
|
||||||
|
|
||||||
exp_head_keys = exp_head_amount_dict.keys()
|
net_total = 0
|
||||||
|
|
||||||
net_total = 0
|
|
||||||
|
|
||||||
# get expense amount
|
# get expense amount
|
||||||
for i in expense_acc:
|
for i in expense_acc:
|
||||||
val = 0
|
val = exp_head_amount_dict.get(i, 0)
|
||||||
|
|
||||||
#check if expense head exists in dict
|
|
||||||
if i in exp_head_keys:
|
|
||||||
val = exp_head_amount_dict[i]
|
|
||||||
val = flt(val and val or 0)
|
|
||||||
net_total += val
|
net_total += val
|
||||||
r.append(val)
|
r.append(val)
|
||||||
|
|
||||||
r.append(net_total)
|
r.append(net_total)
|
||||||
|
|
||||||
#Get tax for account heads
|
#Get tax for account heads
|
||||||
acc_head_tax = sql("""select account_head, tax_amount
|
acc_head_tax = sql("""select account_head, sum(tax_amount)
|
||||||
from `tabPurchase Taxes and Charges`
|
from `tabPurchase Taxes and Charges`
|
||||||
where parent = '%s'
|
where parent = '%s'
|
||||||
and parenttype = 'Purchase Invoice'
|
and parenttype = 'Purchase Invoice'
|
||||||
and add_deduct_tax = 'Add'
|
and add_deduct_tax = 'Add'
|
||||||
and category in ('For Total', 'For Both')""" %(r[col_idx['ID']],))
|
and category in ('For Total', 'For Both')
|
||||||
|
group by account_head
|
||||||
|
""" %(r[col_idx['ID']],))
|
||||||
|
|
||||||
#Convert the result to dictionary for easy retrieval
|
#Convert the result to dictionary for easy retrieval
|
||||||
acc_head_tax_dict = {}
|
acc_head_tax_dict = {}
|
||||||
for a in acc_head_tax:
|
for a in acc_head_tax:
|
||||||
acc_head_tax_dict[a[0]] = a[1]
|
acc_head_tax_dict[a[0]] = flt(a[1])
|
||||||
|
|
||||||
acc_head_keys = acc_head_tax_dict.keys()
|
|
||||||
|
|
||||||
# get tax amount
|
# get tax amount
|
||||||
total_tax = 0
|
total_tax = 0
|
||||||
grand_total = 0
|
for c in tax_acc:
|
||||||
for c in tax_acc:
|
val = acc_head_tax_dict.get(c, 0)
|
||||||
val = 0
|
total_tax += val
|
||||||
if c:
|
r.append(val)
|
||||||
#check if account head exists in dict
|
|
||||||
if c in acc_head_keys:
|
|
||||||
val = acc_head_tax_dict[c]
|
|
||||||
val = flt(val and val or 0)
|
|
||||||
total_tax += val
|
|
||||||
r.append(val)
|
|
||||||
r.append(total_tax)
|
r.append(total_tax)
|
||||||
r.append(flt(total_tax)+ flt(net_total)) # grand total
|
r.append(flt(total_tax)+ flt(net_total)) # grand total
|
@ -15,6 +15,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# add additional columns
|
# add additional columns
|
||||||
|
from webnotes.utils import flt, cint, cstr
|
||||||
|
|
||||||
cl = [c[0] for c in sql("""select distinct account_head
|
cl = [c[0] for c in sql("""select distinct account_head
|
||||||
from `tabSales Taxes and Charges`
|
from `tabSales Taxes and Charges`
|
||||||
@ -61,41 +62,30 @@ for r in res:
|
|||||||
#convert the result to dictionary for easy retrieval
|
#convert the result to dictionary for easy retrieval
|
||||||
income_acc_dict = {}
|
income_acc_dict = {}
|
||||||
for ia in income_acc_list:
|
for ia in income_acc_list:
|
||||||
income_acc_dict[ia[0]] = ia[1]
|
income_acc_dict[ia[0]] = flt(ia[1])
|
||||||
|
|
||||||
income_acc_keys = income_acc_dict.keys()
|
|
||||||
|
|
||||||
net_total = 0
|
net_total = 0
|
||||||
for i in income_acc:
|
for i in income_acc:
|
||||||
val = 0
|
val = income_acc_dict.get(i, 0)
|
||||||
#check if income account exists in dict
|
|
||||||
if i in income_acc_keys:
|
|
||||||
val = income_acc_dict[i]
|
|
||||||
val = flt(val and val or 0)
|
|
||||||
net_total += val
|
net_total += val
|
||||||
r.append(val)
|
r.append(val)
|
||||||
r.append(net_total)
|
r.append(net_total)
|
||||||
|
|
||||||
#Get tax for account heads
|
#Get tax for account heads
|
||||||
acc_head_tax = sql("""select account_head, tax_amount
|
acc_head_tax = sql("""select account_head, sum(tax_amount)
|
||||||
from `tabSales Taxes and Charges`
|
from `tabSales Taxes and Charges`
|
||||||
where parent = '%s'
|
where parent = '%s'
|
||||||
and parenttype = 'Sales Invoice'""" %(r[col_idx['ID']],))
|
and parenttype = 'Sales Invoice'
|
||||||
|
group by account_head""" %(r[col_idx['ID']],))
|
||||||
|
|
||||||
#Convert the result to dictionary for easy retrieval
|
#Convert the result to dictionary for easy retrieval
|
||||||
acc_head_tax_dict = {}
|
acc_head_tax_dict = {}
|
||||||
for a in acc_head_tax:
|
for a in acc_head_tax:
|
||||||
acc_head_tax_dict[a[0]] = a[1]
|
acc_head_tax_dict[a[0]] = flt(a[1])
|
||||||
|
|
||||||
acc_head_keys = acc_head_tax_dict.keys()
|
|
||||||
|
|
||||||
total_tax = 0
|
total_tax = 0
|
||||||
for c in cl:
|
for c in cl:
|
||||||
val = 0
|
val = acc_head_tax_dict.get(c, 0)
|
||||||
#check if account head exists in dict
|
|
||||||
if c in acc_head_keys:
|
|
||||||
val = acc_head_tax_dict[c]
|
|
||||||
val = flt(val and val or 0)
|
|
||||||
total_tax += val
|
total_tax += val
|
||||||
r.append(val)
|
r.append(val)
|
||||||
r.append(total_tax)
|
r.append(total_tax)
|
||||||
|
@ -108,7 +108,7 @@ class DocType:
|
|||||||
msgprint("Supplier Type is mandatory")
|
msgprint("Supplier Type is mandatory")
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
if not sql("select name from tabAccount where name=%s", (self.doc.supplier_type + " - " + abbr)):
|
if not sql("select name from tabAccount where name=%s and debit_or_credit = 'Credit' and ifnull(is_pl_account, 'No') = 'No'", (self.doc.supplier_type + " - " + abbr)):
|
||||||
|
|
||||||
# if not group created , create it
|
# if not group created , create it
|
||||||
self.add_account(self.doc.supplier_type, self.get_payables_group(), abbr)
|
self.add_account(self.doc.supplier_type, self.get_payables_group(), abbr)
|
||||||
|
6
erpnext/patches/june_2012/set_recurring_type.py
Normal file
6
erpnext/patches/june_2012/set_recurring_type.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
def execute():
|
||||||
|
import webnotes
|
||||||
|
from webnotes.model.sync import sync
|
||||||
|
sync('accounts', 'sales_invoice')
|
||||||
|
|
||||||
|
webnotes.conn.sql("update `tabSales Invoice` set recurring_type = 'Monthly' where ifnull(convert_into_recurring_invoice, 0) = 1")
|
@ -442,4 +442,9 @@ patch_list = [
|
|||||||
'patch_file': 'series_unique_patch',
|
'patch_file': 'series_unique_patch',
|
||||||
'description': "add unique constraint to series table's name column"
|
'description': "add unique constraint to series table's name column"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'patch_module': 'patches.june_2012',
|
||||||
|
'patch_file': 'set_recurring_type',
|
||||||
|
'description': "set recurring type as monthly in old"
|
||||||
|
},
|
||||||
]
|
]
|
@ -45,15 +45,24 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|||||||
cur_frm.cscript.make_communication_body();
|
cur_frm.cscript.make_communication_body();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.refresh_custom_buttons = function() {
|
||||||
|
cur_frm.clear_custom_buttons();
|
||||||
|
if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) {
|
||||||
|
if (doc.source != 'Existing Customer') {
|
||||||
|
cur_frm.add_custom_button('Create Customer',
|
||||||
|
cur_frm.cscript['Create Customer']);
|
||||||
|
}
|
||||||
|
cur_frm.add_custom_button('Create Opportunity',
|
||||||
|
cur_frm.cscript['Create Opportunity']);
|
||||||
|
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||||
// custom buttons
|
// custom buttons
|
||||||
//---------------
|
//---------------
|
||||||
cur_frm.clear_custom_buttons()
|
cur_frm.cscript.refresh_custom_buttons();
|
||||||
if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) {
|
|
||||||
if (doc.source != 'Existing Customer') cur_frm.add_custom_button('Create Customer', cur_frm.cscript['Create Customer']);
|
|
||||||
cur_frm.add_custom_button('Create Opportunity', cur_frm.cscript['Create Opportunity']);
|
|
||||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
|
||||||
}
|
|
||||||
erpnext.hide_naming_series();
|
erpnext.hide_naming_series();
|
||||||
|
|
||||||
if (!doc.__islocal) cur_frm.cscript.render_communication_list(doc, cdt, cdn);
|
if (!doc.__islocal) cur_frm.cscript.render_communication_list(doc, cdt, cdn);
|
||||||
|
@ -25,7 +25,7 @@ class DocType:
|
|||||||
"""name from title"""
|
"""name from title"""
|
||||||
self.doc.name = website.utils.page_name(self.doc.title)
|
self.doc.name = website.utils.page_name(self.doc.title)
|
||||||
|
|
||||||
def validate(self):
|
def on_update(self):
|
||||||
"""make page for this product"""
|
"""make page for this product"""
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
import os
|
import os
|
||||||
@ -45,6 +45,9 @@ class DocType:
|
|||||||
self.doc.content = Template(f.read()).render(doc=self.doc)
|
self.doc.content = Template(f.read()).render(doc=self.doc)
|
||||||
|
|
||||||
self.cleanup_temp()
|
self.cleanup_temp()
|
||||||
|
|
||||||
|
self.doc.save()
|
||||||
|
|
||||||
self.if_home_clear_cache()
|
self.if_home_clear_cache()
|
||||||
|
|
||||||
def cleanup_temp(self):
|
def cleanup_temp(self):
|
||||||
|
@ -350,7 +350,8 @@ df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.field
|
|||||||
if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
|
if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
|
||||||
if(cond=='like'){val=val+'%';}
|
if(cond=='like'){val=val+'%';}
|
||||||
return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
|
return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
|
||||||
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
|
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype},{fieldname:'docstatus',fieldtype:'Int',label:'Doc Status',parent:me.doctype},];var doctype_obj=locals['DocType'][me.doctype];if(doctype_obj&&cint(doctype_obj.istable)){std_filters=std_filters.concat([{fieldname:'parent',fieldtype:'Data',label:'Parent',parent:me.doctype}]);}
|
||||||
|
if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
|
||||||
$.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
|
$.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
|
||||||
if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}}})
|
if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}}})
|
||||||
/*
|
/*
|
||||||
@ -1744,7 +1745,7 @@ continue;var fn=f.fieldname?f.fieldname:f.label;var fld=make_field(f,this.doctyp
|
|||||||
if(f.fieldtype=='Section Break'){sec=fld;this.sections.push(fld);}
|
if(f.fieldtype=='Section Break'){sec=fld;this.sections.push(fld);}
|
||||||
if((f.fieldtype=='Section Break')&&(fl[i+1])&&(fl[i+1].fieldtype!='Column Break')&&!f.hidden){var c=this.layout.addcell();$y(c.wrapper,{padding:'8px'});}}}
|
if((f.fieldtype=='Section Break')&&(fl[i+1])&&(fl[i+1].fieldtype!='Column Break')&&!f.hidden){var c=this.layout.addcell();$y(c.wrapper,{padding:'8px'});}}}
|
||||||
_f.Frm.prototype.add_custom_button=function(label,fn,icon){this.frm_head.appframe.add_button(label,fn,icon);}
|
_f.Frm.prototype.add_custom_button=function(label,fn,icon){this.frm_head.appframe.add_button(label,fn,icon);}
|
||||||
_f.Frm.prototype.clear_custom_buttons=function(){}
|
_f.Frm.prototype.clear_custom_buttons=function(){this.frm_head.refresh_toolbar()}
|
||||||
_f.Frm.prototype.add_fetch=function(link_field,src_field,tar_field){if(!this.fetch_dict[link_field]){this.fetch_dict[link_field]={'columns':[],'fields':[]}}
|
_f.Frm.prototype.add_fetch=function(link_field,src_field,tar_field){if(!this.fetch_dict[link_field]){this.fetch_dict[link_field]={'columns':[],'fields':[]}}
|
||||||
this.fetch_dict[link_field].columns.push(src_field);this.fetch_dict[link_field].fields.push(tar_field);}
|
this.fetch_dict[link_field].columns.push(src_field);this.fetch_dict[link_field].fields.push(tar_field);}
|
||||||
_f.Frm.prototype.setup_client_script=function(){if(this.meta.client_script_core||this.meta.client_script||this.meta.__js){this.runclientscript('setup',this.doctype,this.docname);}}
|
_f.Frm.prototype.setup_client_script=function(){if(this.meta.client_script_core||this.meta.client_script||this.meta.__js){this.runclientscript('setup',this.doctype,this.docname);}}
|
||||||
@ -2201,7 +2202,7 @@ this.make();}
|
|||||||
wn.widgets.form.sidebar.Attachment=function(parent,filedet,frm){filedet=filedet.split(',')
|
wn.widgets.form.sidebar.Attachment=function(parent,filedet,frm){filedet=filedet.split(',')
|
||||||
this.filename=filedet[0];this.fileid=filedet[1];this.frm=frm;var me=this;this.wrapper=$a(parent,'div','sidebar-comment-message');this.remove_fileid=function(){var doc=locals[me.frm.doctype][me.frm.docname];var fl=doc.file_list.split('\n');new_fl=[];for(var i=0;i<fl.length;i++){if(fl[i].split(',')[1]!=me.fileid)new_fl.push(fl[i]);}
|
this.filename=filedet[0];this.fileid=filedet[1];this.frm=frm;var me=this;this.wrapper=$a(parent,'div','sidebar-comment-message');this.remove_fileid=function(){var doc=locals[me.frm.doctype][me.frm.docname];var fl=doc.file_list.split('\n');new_fl=[];for(var i=0;i<fl.length;i++){if(fl[i].split(',')[1]!=me.fileid)new_fl.push(fl[i]);}
|
||||||
doc.file_list=new_fl.join('\n');}
|
doc.file_list=new_fl.join('\n');}
|
||||||
var display_name=this.fileid;if(this.fileid.substr(0,8)=='FileData')
|
var display_name=this.fileid;if(this.fileid&&this.fileid.substr(0,8)=='FileData')
|
||||||
display_name=this.filename;this.ln=$a(this.wrapper,'a','link_type small',{},display_name);this.ln.href='files/'+this.fileid;this.ln.target='_blank';this.del=$a(this.wrapper,'span','close','','×');this.del.onclick=function(){var yn=confirm("Are you sure you want to delete the attachment?")
|
display_name=this.filename;this.ln=$a(this.wrapper,'a','link_type small',{},display_name);this.ln.href='files/'+this.fileid;this.ln.target='_blank';this.del=$a(this.wrapper,'span','close','','×');this.del.onclick=function(){var yn=confirm("Are you sure you want to delete the attachment?")
|
||||||
if(yn){var callback=function(r,rt){locals[me.frm.doctype][me.frm.docname].modified=r.message;$dh(me.wrapper);me.remove_fileid();frm.refresh();}
|
if(yn){var callback=function(r,rt){locals[me.frm.doctype][me.frm.docname].modified=r.message;$dh(me.wrapper);me.remove_fileid();frm.refresh();}
|
||||||
$c('webnotes.widgets.form.utils.remove_attach',args={'fid':me.fileid,dt:me.frm.doctype,dn:me.frm.docname},callback);}}}
|
$c('webnotes.widgets.form.utils.remove_attach',args={'fid':me.fileid,dt:me.frm.doctype,dn:me.frm.docname},callback);}}}
|
||||||
|
@ -237,7 +237,8 @@ df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.field
|
|||||||
if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
|
if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
|
||||||
if(cond=='like'){val=val+'%';}
|
if(cond=='like'){val=val+'%';}
|
||||||
return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
|
return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
|
||||||
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
|
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype},{fieldname:'docstatus',fieldtype:'Int',label:'Doc Status',parent:me.doctype},];var doctype_obj=locals['DocType'][me.doctype];if(doctype_obj&&cint(doctype_obj.istable)){std_filters=std_filters.concat([{fieldname:'parent',fieldtype:'Data',label:'Parent',parent:me.doctype}]);}
|
||||||
|
if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
|
||||||
$.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
|
$.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
|
||||||
if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}}})
|
if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}}})
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user