mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 19:29:10 +00:00
Merge branch 'master' of github.com:webnotes/erpnext into cms2
This commit is contained in:
@@ -169,6 +169,13 @@ class DocType:
|
|||||||
get_obj('Account', self.doc.parent_account).update_balance(fy, period_det, flag)
|
get_obj('Account', self.doc.parent_account).update_balance(fy, period_det, flag)
|
||||||
msgprint('Balances updated')
|
msgprint('Balances updated')
|
||||||
|
|
||||||
|
def validate_mandatory(self):
|
||||||
|
if not self.doc.debit_or_credit:
|
||||||
|
msgprint("Debit or Credit field is mandatory", raise_exception=1)
|
||||||
|
if not self.doc.is_pl_account:
|
||||||
|
msgprint("Is PL Account field is mandatory", raise_exception=1)
|
||||||
|
|
||||||
|
|
||||||
# VALIDATE
|
# VALIDATE
|
||||||
# ==================================================================
|
# ==================================================================
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@@ -177,6 +184,7 @@ class DocType:
|
|||||||
self.validate_parent()
|
self.validate_parent()
|
||||||
self.validate_duplicate_account()
|
self.validate_duplicate_account()
|
||||||
self.validate_root_details()
|
self.validate_root_details()
|
||||||
|
self.validate_mandatory()
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
if not self.doc.parent_account:
|
if not self.doc.parent_account:
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class DocType:
|
|||||||
|
|
||||||
dl = sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and (t1.cheque_no is not null or t1.cheque_no != '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date))
|
dl = sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and (t1.cheque_no is not null or t1.cheque_no != '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date))
|
||||||
|
|
||||||
self.doc.clear_table(self.doclist, 'entries')
|
self.doclist = self.doc.clear_table(self.doclist, 'entries')
|
||||||
self.doc.total_amount = 0.0
|
self.doc.total_amount = 0.0
|
||||||
|
|
||||||
for d in dl:
|
for d in dl:
|
||||||
|
|||||||
@@ -20,6 +20,6 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){
|
|||||||
refresh_field('budget_distribution_details');
|
refresh_field('budget_distribution_details');
|
||||||
}
|
}
|
||||||
|
|
||||||
$c('runserverobj',args={'method' : 'get_months', 'docs' : compress_doclist([doc])},callback1);
|
$c('runserverobj',args={'method' : 'get_months', 'docs' : compress_doclist(make_doclist(doc.doctype, doc.name))},callback1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ class DocType(TransactionBase):
|
|||||||
# Get TDS Return acknowledgement
|
# Get TDS Return acknowledgement
|
||||||
#-------------------------------
|
#-------------------------------
|
||||||
def get_return_ack_details(self):
|
def get_return_ack_details(self):
|
||||||
self.doc.clear_table(self.doclist, 'form_16A_ack_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'form_16A_ack_details')
|
||||||
if not (self.doc.from_date and self.doc.to_date):
|
if not (self.doc.from_date and self.doc.to_date):
|
||||||
msgprint("Please enter From Date, To Date")
|
msgprint("Please enter From Date, To Date")
|
||||||
else:
|
else:
|
||||||
@@ -90,7 +90,7 @@ class DocType(TransactionBase):
|
|||||||
# Get tds payment details
|
# Get tds payment details
|
||||||
#-------------------------------
|
#-------------------------------
|
||||||
def get_tds(self):
|
def get_tds(self):
|
||||||
self.doc.clear_table(self.doclist,'form_16A_tax_details')
|
self.doclist = self.doc.clear_table(self.doclist,'form_16A_tax_details')
|
||||||
import datetime
|
import datetime
|
||||||
if self.doc.from_date and self.doc.to_date and self.doc.tds_category:
|
if self.doc.from_date and self.doc.to_date and self.doc.tds_category:
|
||||||
tot=0.0
|
tot=0.0
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ class DocType:
|
|||||||
def get_advances(self, obj, account_head, table_name,table_field_name, dr_or_cr):
|
def get_advances(self, obj, account_head, table_name,table_field_name, dr_or_cr):
|
||||||
jv_detail = webnotes.conn.sql("select t1.name, t1.remark, t2.%s, t2.name, t1.ded_amount from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and (t2.against_voucher is null or t2.against_voucher = '') and (t2.against_invoice is null or t2.against_invoice = '') and (t2.against_jv is null or t2.against_jv = '') and t2.account = '%s' and t2.is_advance = 'Yes' and t1.docstatus = 1 order by t1.voucher_date " % (dr_or_cr,account_head))
|
jv_detail = webnotes.conn.sql("select t1.name, t1.remark, t2.%s, t2.name, t1.ded_amount from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and (t2.against_voucher is null or t2.against_voucher = '') and (t2.against_invoice is null or t2.against_invoice = '') and (t2.against_jv is null or t2.against_jv = '') and t2.account = '%s' and t2.is_advance = 'Yes' and t1.docstatus = 1 order by t1.voucher_date " % (dr_or_cr,account_head))
|
||||||
# clear advance table
|
# clear advance table
|
||||||
obj.doc.clear_table(obj.doclist,table_field_name)
|
obj.doclist = obj.doc.clear_table(obj.doclist,table_field_name)
|
||||||
# Create advance table
|
# Create advance table
|
||||||
for d in jv_detail:
|
for d in jv_detail:
|
||||||
add = addchild(obj.doc, table_field_name, table_name, 1, obj.doclist)
|
add = addchild(obj.doc, table_field_name, table_name, 1, obj.doclist)
|
||||||
@@ -300,6 +300,8 @@ class DocType:
|
|||||||
add.allocate_amount = 0
|
add.allocate_amount = 0
|
||||||
if table_name == 'Purchase Invoice Advance':
|
if table_name == 'Purchase Invoice Advance':
|
||||||
add.tds_amount = flt(d[4])
|
add.tds_amount = flt(d[4])
|
||||||
|
|
||||||
|
return obj.doclist
|
||||||
|
|
||||||
# Clear rows which is not adjusted
|
# Clear rows which is not adjusted
|
||||||
#-------------------------------------
|
#-------------------------------------
|
||||||
|
|||||||
@@ -179,11 +179,7 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
|
|||||||
|
|
||||||
/****************** Get Accounting Entry *****************/
|
/****************** Get Accounting Entry *****************/
|
||||||
cur_frm.cscript.view_ledger_entry = function(doc,cdt,cdn){
|
cur_frm.cscript.view_ledger_entry = function(doc,cdt,cdn){
|
||||||
var callback = function(report){
|
wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name);
|
||||||
report.set_filter('GL Entry', 'Voucher No',doc.name);
|
|
||||||
report.dt.run();
|
|
||||||
}
|
|
||||||
loadreport('GL Entry','General Ledger', callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ class DocType:
|
|||||||
# get outstanding invoices
|
# get outstanding invoices
|
||||||
# -------------------------
|
# -------------------------
|
||||||
def get_outstanding_invoices(self):
|
def get_outstanding_invoices(self):
|
||||||
self.doc.clear_table(self.doclist, 'entries')
|
self.doclist = self.doc.clear_table(self.doclist, 'entries')
|
||||||
total = 0
|
total = 0
|
||||||
for d in self.get_values():
|
for d in self.get_values():
|
||||||
total += flt(d[2])
|
total += flt(d[2])
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class DocType:
|
|||||||
Payment entry will be decided based on account type (Dr/Cr)
|
Payment entry will be decided based on account type (Dr/Cr)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.doc.clear_table(self.doclist, 'ir_payment_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'ir_payment_details')
|
||||||
gle = self.get_gl_entries()
|
gle = self.get_gl_entries()
|
||||||
self.create_payment_table(gle)
|
self.create_payment_table(gle)
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ wn.doclistviews['Purchase Invoice'] = wn.views.ListView.extend({
|
|||||||
this._super(d);
|
this._super(d);
|
||||||
this.fields = this.fields.concat([
|
this.fields = this.fields.concat([
|
||||||
'`tabPurchase Invoice`.supplier_name',
|
'`tabPurchase Invoice`.supplier_name',
|
||||||
|
'`tabPurchase Invoice`.credit_to',
|
||||||
'`tabPurchase Invoice`.currency',
|
'`tabPurchase Invoice`.currency',
|
||||||
'IFNULL(`tabPurchase Invoice`.grand_total_import, 0) as grand_total_import',
|
'IFNULL(`tabPurchase Invoice`.grand_total_import, 0) as grand_total_import',
|
||||||
'IFNULL(`tabPurchase Invoice`.grand_total, 0) as grand_total',
|
'IFNULL(`tabPurchase Invoice`.grand_total, 0) as grand_total',
|
||||||
@@ -24,7 +25,13 @@ wn.doclistviews['Purchase Invoice'] = wn.views.ListView.extend({
|
|||||||
{width: '5%', content: 'avatar'},
|
{width: '5%', content: 'avatar'},
|
||||||
{width: '3%', content: 'docstatus'},
|
{width: '3%', content: 'docstatus'},
|
||||||
{width: '15%', content: 'name'},
|
{width: '15%', content: 'name'},
|
||||||
{width: '34%', content: 'supplier_name+tags', css: {color: '#222'}},
|
{
|
||||||
|
width: '34%',
|
||||||
|
content: function(parent, data) {
|
||||||
|
$(parent).html(data.supplier_name?data.supplier_name:data.credit_to)
|
||||||
|
},
|
||||||
|
css: {color: '#222'}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
width: '18%',
|
width: '18%',
|
||||||
content: function(parent, data) {
|
content: function(parent, data) {
|
||||||
|
|||||||
@@ -397,9 +397,5 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
|
|||||||
|
|
||||||
/****************** Get Accounting Entry *****************/
|
/****************** Get Accounting Entry *****************/
|
||||||
cur_frm.cscript.view_ledger_entry = function(){
|
cur_frm.cscript.view_ledger_entry = function(){
|
||||||
var callback = function(report){
|
wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name);
|
||||||
report.set_filter('GL Entry', 'Voucher No',cur_frm.doc.name);
|
|
||||||
report.dt.run();
|
|
||||||
}
|
|
||||||
loadreport('GL Entry','General Ledger', callback);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ class DocType(TransactionBase):
|
|||||||
# Advance Allocation
|
# Advance Allocation
|
||||||
# -------------------
|
# -------------------
|
||||||
def get_advances(self):
|
def get_advances(self):
|
||||||
get_obj('GL Control').get_advances( self, self.doc.credit_to, 'Purchase Invoice Advance','advance_allocation_details','debit')
|
self.doclist = get_obj('GL Control').get_advances(self, self.doc.credit_to, 'Purchase Invoice Advance','advance_allocation_details','debit')
|
||||||
|
|
||||||
|
|
||||||
# ============= OTHER CHARGES ====================
|
# ============= OTHER CHARGES ====================
|
||||||
@@ -183,7 +183,7 @@ class DocType(TransactionBase):
|
|||||||
# Get Purchase Taxes and Charges Master
|
# Get Purchase Taxes and Charges Master
|
||||||
# -----------------------------------------------------------
|
# -----------------------------------------------------------
|
||||||
def get_purchase_tax_details(self):
|
def get_purchase_tax_details(self):
|
||||||
return get_obj('Purchase Common').get_purchase_tax_details(self)
|
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
|
||||||
|
|
||||||
|
|
||||||
def get_rate1(self,acc):
|
def get_rate1(self,acc):
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ wn.doclistviews['Sales Invoice'] = wn.views.ListView.extend({
|
|||||||
this._super(d);
|
this._super(d);
|
||||||
this.fields = this.fields.concat([
|
this.fields = this.fields.concat([
|
||||||
"`tabSales Invoice`.customer_name",
|
"`tabSales Invoice`.customer_name",
|
||||||
|
"`tabSales Invoice`.debit_to",
|
||||||
"ifnull(`tabSales Invoice`.outstanding_amount,0) as outstanding_amount",
|
"ifnull(`tabSales Invoice`.outstanding_amount,0) as outstanding_amount",
|
||||||
"ifnull(`tabSales Invoice`.grand_total,0) as grand_total",
|
"ifnull(`tabSales Invoice`.grand_total,0) as grand_total",
|
||||||
"`tabSales Invoice`.currency",
|
"`tabSales Invoice`.currency",
|
||||||
@@ -19,7 +20,13 @@ wn.doclistviews['Sales Invoice'] = wn.views.ListView.extend({
|
|||||||
{width: '5%', content: 'avatar'},
|
{width: '5%', content: 'avatar'},
|
||||||
{width: '3%', content: 'docstatus'},
|
{width: '3%', content: 'docstatus'},
|
||||||
{width: '15%', content: 'name'},
|
{width: '15%', content: 'name'},
|
||||||
{width: '34%', content: 'customer_name+tags', css: {color:'#222'}},
|
{
|
||||||
|
width: '34%',
|
||||||
|
content: function(parent, data) {
|
||||||
|
$(parent).html(data.customer_name?data.customer_name:data.debit_to)
|
||||||
|
},
|
||||||
|
css: {color: '#222'}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
width: '18%',
|
width: '18%',
|
||||||
content: function(parent, data) {
|
content: function(parent, data) {
|
||||||
|
|||||||
@@ -494,12 +494,8 @@ cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) {
|
|||||||
|
|
||||||
|
|
||||||
/****************** Get Accounting Entry *****************/
|
/****************** Get Accounting Entry *****************/
|
||||||
cur_frm.cscript.view_ledger_entry = function(){
|
cur_frm.cscript.view_ledger_entry = function(){
|
||||||
var callback = function(report){
|
wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name);
|
||||||
report.set_filter('GL Entry', 'Voucher No',cur_frm.doc.name);
|
|
||||||
report.dt.run();
|
|
||||||
}
|
|
||||||
loadreport('GL Entry','General Ledger', callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default values for recurring invoices
|
// Default values for recurring invoices
|
||||||
|
|||||||
@@ -140,13 +140,13 @@ class DocType(TransactionBase):
|
|||||||
# Delivery Note
|
# Delivery Note
|
||||||
if self.doc.delivery_note_main:
|
if self.doc.delivery_note_main:
|
||||||
self.validate_prev_docname('delivery note')
|
self.validate_prev_docname('delivery note')
|
||||||
self.doc.clear_table(self.doclist,'other_charges')
|
self.doclist = self.doc.clear_table(self.doclist,'other_charges')
|
||||||
self.doclist = get_obj('DocType Mapper', 'Delivery Note-Sales Invoice').dt_map('Delivery Note', 'Sales Invoice', self.doc.delivery_note_main, self.doc, self.doclist, "[['Delivery Note', 'Sales Invoice'],['Delivery Note Item', 'Sales Invoice Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]")
|
self.doclist = get_obj('DocType Mapper', 'Delivery Note-Sales Invoice').dt_map('Delivery Note', 'Sales Invoice', self.doc.delivery_note_main, self.doc, self.doclist, "[['Delivery Note', 'Sales Invoice'],['Delivery Note Item', 'Sales Invoice Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]")
|
||||||
self.get_income_account('entries')
|
self.get_income_account('entries')
|
||||||
# Sales Order
|
# Sales Order
|
||||||
elif self.doc.sales_order_main:
|
elif self.doc.sales_order_main:
|
||||||
self.validate_prev_docname('sales order')
|
self.validate_prev_docname('sales order')
|
||||||
self.doc.clear_table(self.doclist,'other_charges')
|
self.doclist = self.doc.clear_table(self.doclist,'other_charges')
|
||||||
get_obj('DocType Mapper', 'Sales Order-Sales Invoice').dt_map('Sales Order', 'Sales Invoice', self.doc.sales_order_main, self.doc, self.doclist, "[['Sales Order', 'Sales Invoice'],['Sales Order Item', 'Sales Invoice Item'],['Sales Taxes and Charges','Sales Taxes and Charges'], ['Sales Team', 'Sales Team']]")
|
get_obj('DocType Mapper', 'Sales Order-Sales Invoice').dt_map('Sales Order', 'Sales Invoice', self.doc.sales_order_main, self.doc, self.doclist, "[['Sales Order', 'Sales Invoice'],['Sales Order Item', 'Sales Invoice Item'],['Sales Taxes and Charges','Sales Taxes and Charges'], ['Sales Team', 'Sales Team']]")
|
||||||
self.get_income_account('entries')
|
self.get_income_account('entries')
|
||||||
|
|
||||||
@@ -240,18 +240,17 @@ class DocType(TransactionBase):
|
|||||||
# Load Default Charges
|
# Load Default Charges
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
def load_default_taxes(self):
|
def load_default_taxes(self):
|
||||||
return get_obj('Sales Common').load_default_taxes(self)
|
self.doclist = get_obj('Sales Common').load_default_taxes(self)
|
||||||
|
|
||||||
# Get Sales Taxes and Charges Master Details
|
# Get Sales Taxes and Charges Master Details
|
||||||
# --------------------------
|
# --------------------------
|
||||||
def get_other_charges(self):
|
def get_other_charges(self):
|
||||||
return get_obj('Sales Common').get_other_charges(self)
|
self.doclist = get_obj('Sales Common').get_other_charges(self)
|
||||||
|
|
||||||
|
|
||||||
# Get Advances
|
# Get Advances
|
||||||
# -------------
|
# -------------
|
||||||
def get_advances(self):
|
def get_advances(self):
|
||||||
get_obj('GL Control').get_advances(self, self.doc.debit_to, 'Sales Invoice Advance', 'advance_adjustment_details', 'credit')
|
self.doclist = get_obj('GL Control').get_advances(self, self.doc.debit_to, 'Sales Invoice Advance', 'advance_adjustment_details', 'credit')
|
||||||
|
|
||||||
#pull project customer
|
#pull project customer
|
||||||
#-------------------------
|
#-------------------------
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class DocType:
|
|||||||
# Fetch voucherwise tds details
|
# Fetch voucherwise tds details
|
||||||
#-------------------------------
|
#-------------------------------
|
||||||
def get_tds_list(self):
|
def get_tds_list(self):
|
||||||
self.doc.clear_table(self.doclist,'tds_payment_details')
|
self.doclist = self.doc.clear_table(self.doclist,'tds_payment_details')
|
||||||
self.doc.total_tds = 0
|
self.doc.total_tds = 0
|
||||||
import datetime
|
import datetime
|
||||||
if not self.doc.tds_category:
|
if not self.doc.tds_category:
|
||||||
|
|||||||
@@ -101,8 +101,11 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
onrender: function(treenode) {
|
onrender: function(treenode) {
|
||||||
if (ctype == 'Account') {
|
if (ctype == 'Account') {
|
||||||
var bal = treenode.data && treenode.data.balance.split(' ') || ['',''];
|
var bal = treenode.data && treenode.data.balance.split(' ') || ['',''];
|
||||||
treenode.parent.append('<span class="balance-area"><span style="color: #aaa">'+ bal[0] + '</span> '
|
if (bal && flt(bal[1])) {
|
||||||
+ bal[1] + '</span>');
|
treenode.parent.append('<span class="balance-area">\
|
||||||
|
<span style="color: #aaa">'+ bal[0] + '</span> '
|
||||||
|
+ fmt_money(bal[1]) + '</span>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -48,11 +48,6 @@
|
|||||||
title="Export multiple Account Ledgers (GL) to spreadsheet (csv)"
|
title="Export multiple Account Ledgers (GL) to spreadsheet (csv)"
|
||||||
href="#!Form/Multi Ledger Report/Multi Ledger Report">Export Multiple Ledgers (GL)</a>
|
href="#!Form/Multi Ledger Report/Multi Ledger Report">Export Multiple Ledgers (GL)</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-item">
|
|
||||||
<a class="section-link"
|
|
||||||
title="Lease Agreements"
|
|
||||||
href="#!List/Lease Agreement">Lease Agreements</a>
|
|
||||||
</div>
|
|
||||||
<div class="section-item">
|
<div class="section-item">
|
||||||
<a class="section-link"
|
<a class="section-link"
|
||||||
title = "Helper for managing return of goods (sales or purchase)"
|
title = "Helper for managing return of goods (sales or purchase)"
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
# -----------
|
# -----------
|
||||||
row_list = [['Cost Center','Data','160px'],
|
row_list = [['Cost Center','Data','160px'],
|
||||||
['Account','Data','160px'],
|
['Account','Data','160px'],
|
||||||
['Debit','Data','120px'],
|
['Debit','Currency','120px'],
|
||||||
['Credit','Data','120px'],
|
['Credit','Currency','120px'],
|
||||||
['Expense','Currency','120px']]
|
['Expense','Currency','120px']]
|
||||||
|
|
||||||
for r in row_list:
|
for r in row_list:
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
SELECT `tabGL Entry`.`cost_center`,`tabAccount`.`parent_account`,sum(`tabGL Entry`.`debit`),sum(`tabGL Entry`.`credit`),sum(`tabGL Entry`.`debit`)-sum(`tabGL Entry`.`credit`)
|
SELECT
|
||||||
FROM `tabGL Entry`,`tabAccount`
|
`tabGL Entry`.`cost_center`,
|
||||||
WHERE `tabGL Entry`.`account`=`tabAccount`.`name`
|
`tabAccount`.`parent_account`,
|
||||||
AND ifnull(`tabGL Entry`.`is_cancelled`,'No')='No'
|
sum(ifnull(`tabGL Entry`.`debit`, 0)),
|
||||||
AND `tabAccount`.is_pl_account='Yes'
|
sum(ifnull(`tabGL Entry`.`credit`, 0)),
|
||||||
AND `tabAccount`.debit_or_credit='Debit'
|
sum(ifnull(`tabGL Entry`.`debit`,0))-sum(ifnull(`tabGL Entry`.`credit`, 0))
|
||||||
AND `tabGL Entry`.`posting_date`>='%(posting_date)s'
|
FROM
|
||||||
AND `tabGL Entry`.`posting_date`<='%(posting_date1)s'
|
`tabGL Entry`,`tabAccount`
|
||||||
AND `tabGL Entry`.`company` LIKE '%(company)s%%'
|
WHERE
|
||||||
AND `tabAccount`.`parent_account` LIKE '%(account)s%%'
|
`tabGL Entry`.`account`=`tabAccount`.`name`
|
||||||
AND `tabGL Entry`.`cost_center` LIKE '%(cost_center)s%%'
|
AND ifnull(`tabGL Entry`.`is_cancelled`,'No')='No'
|
||||||
GROUP BY `tabGL Entry`.`cost_center` , `tabAccount`.`parent_account`
|
AND `tabAccount`.is_pl_account='Yes'
|
||||||
|
AND `tabAccount`.debit_or_credit='Debit'
|
||||||
|
AND `tabGL Entry`.`posting_date`>='%(posting_date)s'
|
||||||
|
AND `tabGL Entry`.`posting_date`<='%(posting_date1)s'
|
||||||
|
AND `tabGL Entry`.`company` LIKE '%(company)s%%'
|
||||||
|
AND `tabAccount`.`parent_account` LIKE '%(account)s%%'
|
||||||
|
AND `tabGL Entry`.`cost_center` LIKE '%(cost_center)s%%'
|
||||||
|
GROUP BY
|
||||||
|
`tabGL Entry`.`cost_center` , `tabAccount`.`parent_account`
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
{
|
{
|
||||||
'creation': '2010-08-08 17:09:34',
|
'creation': '2010-08-08 17:09:34',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-04-03 12:49:50',
|
'modified': '2012-07-02 11:12:28',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'Administrator'
|
'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
@@ -22,7 +22,6 @@
|
|||||||
# These values are common for all Field Mapper Detail
|
# These values are common for all Field Mapper Detail
|
||||||
{
|
{
|
||||||
'doctype': u'Field Mapper Detail',
|
'doctype': u'Field Mapper Detail',
|
||||||
'map': u'Yes',
|
|
||||||
'name': '__common__',
|
'name': '__common__',
|
||||||
'parent': u'Purchase Request-Purchase Order',
|
'parent': u'Purchase Request-Purchase Order',
|
||||||
'parentfield': u'field_mapper_details',
|
'parentfield': u'field_mapper_details',
|
||||||
@@ -50,6 +49,7 @@
|
|||||||
'checking_operator': u'=',
|
'checking_operator': u'=',
|
||||||
'doctype': u'Field Mapper Detail',
|
'doctype': u'Field Mapper Detail',
|
||||||
'from_field': u'company',
|
'from_field': u'company',
|
||||||
|
'map': u'Yes',
|
||||||
'match_id': 0,
|
'match_id': 0,
|
||||||
'to_field': u'company'
|
'to_field': u'company'
|
||||||
},
|
},
|
||||||
@@ -58,6 +58,7 @@
|
|||||||
{
|
{
|
||||||
'doctype': u'Field Mapper Detail',
|
'doctype': u'Field Mapper Detail',
|
||||||
'from_field': u'parenttype',
|
'from_field': u'parenttype',
|
||||||
|
'map': u'Yes',
|
||||||
'match_id': 1,
|
'match_id': 1,
|
||||||
'to_field': u'prevdoc_doctype'
|
'to_field': u'prevdoc_doctype'
|
||||||
},
|
},
|
||||||
@@ -66,6 +67,7 @@
|
|||||||
{
|
{
|
||||||
'doctype': u'Field Mapper Detail',
|
'doctype': u'Field Mapper Detail',
|
||||||
'from_field': u'parent',
|
'from_field': u'parent',
|
||||||
|
'map': u'Yes',
|
||||||
'match_id': 1,
|
'match_id': 1,
|
||||||
'to_field': u'prevdoc_docname'
|
'to_field': u'prevdoc_docname'
|
||||||
},
|
},
|
||||||
@@ -74,6 +76,7 @@
|
|||||||
{
|
{
|
||||||
'doctype': u'Field Mapper Detail',
|
'doctype': u'Field Mapper Detail',
|
||||||
'from_field': u'name',
|
'from_field': u'name',
|
||||||
|
'map': u'Yes',
|
||||||
'match_id': 1,
|
'match_id': 1,
|
||||||
'to_field': u'prevdoc_detail_docname'
|
'to_field': u'prevdoc_detail_docname'
|
||||||
},
|
},
|
||||||
@@ -82,6 +85,7 @@
|
|||||||
{
|
{
|
||||||
'doctype': u'Field Mapper Detail',
|
'doctype': u'Field Mapper Detail',
|
||||||
'from_field': u'uom',
|
'from_field': u'uom',
|
||||||
|
'map': u'Yes',
|
||||||
'match_id': 1,
|
'match_id': 1,
|
||||||
'to_field': u'stock_uom'
|
'to_field': u'stock_uom'
|
||||||
},
|
},
|
||||||
@@ -90,6 +94,7 @@
|
|||||||
{
|
{
|
||||||
'doctype': u'Field Mapper Detail',
|
'doctype': u'Field Mapper Detail',
|
||||||
'from_field': u'eval:flt(1)',
|
'from_field': u'eval:flt(1)',
|
||||||
|
'map': u'Yes',
|
||||||
'match_id': 1,
|
'match_id': 1,
|
||||||
'to_field': u'conversion_factor'
|
'to_field': u'conversion_factor'
|
||||||
},
|
},
|
||||||
@@ -98,6 +103,7 @@
|
|||||||
{
|
{
|
||||||
'doctype': u'Field Mapper Detail',
|
'doctype': u'Field Mapper Detail',
|
||||||
'from_field': u'eval:flt(obj.qty) - flt(obj.ordered_qty)',
|
'from_field': u'eval:flt(obj.qty) - flt(obj.ordered_qty)',
|
||||||
|
'map': u'Yes',
|
||||||
'match_id': 1,
|
'match_id': 1,
|
||||||
'to_field': u'stock_qty'
|
'to_field': u'stock_qty'
|
||||||
},
|
},
|
||||||
@@ -106,6 +112,7 @@
|
|||||||
{
|
{
|
||||||
'doctype': u'Field Mapper Detail',
|
'doctype': u'Field Mapper Detail',
|
||||||
'from_field': u'eval:flt(obj.qty) - flt(obj.ordered_qty)',
|
'from_field': u'eval:flt(obj.qty) - flt(obj.ordered_qty)',
|
||||||
|
'map': u'Yes',
|
||||||
'match_id': 1,
|
'match_id': 1,
|
||||||
'to_field': u'qty'
|
'to_field': u'qty'
|
||||||
},
|
},
|
||||||
@@ -114,10 +121,21 @@
|
|||||||
{
|
{
|
||||||
'doctype': u'Field Mapper Detail',
|
'doctype': u'Field Mapper Detail',
|
||||||
'from_field': u'schedule_date',
|
'from_field': u'schedule_date',
|
||||||
|
'map': u'Yes',
|
||||||
'match_id': 1,
|
'match_id': 1,
|
||||||
'to_field': u'schedule_date'
|
'to_field': u'schedule_date'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# Field Mapper Detail
|
||||||
|
{
|
||||||
|
'checking_operator': u'>=',
|
||||||
|
'doctype': u'Field Mapper Detail',
|
||||||
|
'from_field': u'transaction_date',
|
||||||
|
'map': u'No',
|
||||||
|
'match_id': 0,
|
||||||
|
'to_field': u'transaction_date'
|
||||||
|
},
|
||||||
|
|
||||||
# Table Mapper Detail
|
# Table Mapper Detail
|
||||||
{
|
{
|
||||||
'doctype': u'Table Mapper Detail',
|
'doctype': u'Table Mapper Detail',
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class DocType(TransactionBase):
|
|||||||
'warehouse': wh,
|
'warehouse': wh,
|
||||||
'item_tax_rate': json.dumps(t),
|
'item_tax_rate': json.dumps(t),
|
||||||
'batch_no': '',
|
'batch_no': '',
|
||||||
'discount_rate': 0
|
'discount_rate': 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# get min_order_qty from item
|
# get min_order_qty from item
|
||||||
@@ -170,6 +170,14 @@ class DocType(TransactionBase):
|
|||||||
'import_rate': 0,
|
'import_rate': 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if obj.doc.doctype == 'Purchase Order':
|
||||||
|
supplier_part_no = webnotes.conn.sql("""\
|
||||||
|
select supplier_part_no from `tabItem Supplier`
|
||||||
|
where parent = %s and parenttype = 'Item' and
|
||||||
|
supplier = %s""", (arg['item_code'], obj.doc.supplier))
|
||||||
|
if supplier_part_no and supplier_part_no[0][0]:
|
||||||
|
ret['supplier_part_no'] = supplier_part_no[0][0]
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# Get Available Qty at Warehouse
|
# Get Available Qty at Warehouse
|
||||||
@@ -621,7 +629,7 @@ class DocType(TransactionBase):
|
|||||||
# Get other charges from Master
|
# Get other charges from Master
|
||||||
# =================================================================================
|
# =================================================================================
|
||||||
def get_purchase_tax_details(self,obj):
|
def get_purchase_tax_details(self,obj):
|
||||||
self.doc.clear_table(obj.doclist,'purchase_tax_details')
|
obj.doclist = self.doc.clear_table(obj.doclist,'purchase_tax_details')
|
||||||
idx = 0
|
idx = 0
|
||||||
other_charge = sql("select category, add_deduct_tax, charge_type,row_id,description,account_head,rate,tax_amount from `tabPurchase Taxes and Charges` where parent = '%s' order by idx" %(obj.doc.purchase_other_charges), as_dict = 1)
|
other_charge = sql("select category, add_deduct_tax, charge_type,row_id,description,account_head,rate,tax_amount from `tabPurchase Taxes and Charges` where parent = '%s' order by idx" %(obj.doc.purchase_other_charges), as_dict = 1)
|
||||||
for other in other_charge:
|
for other in other_charge:
|
||||||
@@ -636,6 +644,7 @@ class DocType(TransactionBase):
|
|||||||
d.tax_amount = flt(other['tax_amount'])
|
d.tax_amount = flt(other['tax_amount'])
|
||||||
d.idx = idx
|
d.idx = idx
|
||||||
idx += 1
|
idx += 1
|
||||||
|
return obj.doclist
|
||||||
|
|
||||||
|
|
||||||
# Get Tax rate if account type is TAX
|
# Get Tax rate if account type is TAX
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ class DocType(TransactionBase):
|
|||||||
if self.doc.is_subcontracted == 'Yes':
|
if self.doc.is_subcontracted == 'Yes':
|
||||||
self.add_bom(d)
|
self.add_bom(d)
|
||||||
else:
|
else:
|
||||||
self.doc.clear_table(self.doclist,'po_raw_material_details',1)
|
self.doclist = self.doc.clear_table(self.doclist,'po_raw_material_details',1)
|
||||||
self.doc.save()
|
self.doc.save()
|
||||||
elif item_det[0][1] == 'No':
|
elif item_det[0][1] == 'No':
|
||||||
self.add_bom(d)
|
self.add_bom(d)
|
||||||
@@ -371,4 +371,4 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
# **** Pull details from other charges master (Get Other Charges) ****
|
# **** Pull details from other charges master (Get Other Charges) ****
|
||||||
def get_purchase_tax_details(self):
|
def get_purchase_tax_details(self):
|
||||||
return get_obj('Purchase Common').get_purchase_tax_details(self)
|
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
'creation': '2012-03-27 14:35:50',
|
'creation': '2012-05-15 12:14:38',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-03-27 14:35:50',
|
'modified': '2012-06-29 13:05:33',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'Administrator'
|
'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
'section_style': u'Tray',
|
'section_style': u'Tray',
|
||||||
'server_code_error': u' ',
|
'server_code_error': u' ',
|
||||||
'show_in_menu': 0,
|
'show_in_menu': 0,
|
||||||
'version': 65
|
'version': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# These values are common for all DocField
|
# These values are common for all DocField
|
||||||
@@ -74,6 +74,19 @@
|
|||||||
'trigger': u'Client'
|
'trigger': u'Client'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'colour': u'White:FFF',
|
||||||
|
'description': u'If Supplier Part Number exists for given Item, it gets stored here',
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'supplier_part_no',
|
||||||
|
'fieldtype': u'Data',
|
||||||
|
'hidden': 1,
|
||||||
|
'label': u'Supplier Part Number',
|
||||||
|
'permlevel': 1,
|
||||||
|
'print_hide': 1
|
||||||
|
},
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
@@ -453,4 +466,4 @@
|
|||||||
'permlevel': 0,
|
'permlevel': 0,
|
||||||
'print_hide': 1
|
'print_hide': 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -8,11 +8,11 @@
|
|||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Please edit this list and import only required elements
|
# Please edit this list and import only required elements
|
||||||
import webnotes
|
import webnotes
|
||||||
@@ -34,30 +34,35 @@ convert_to_lists = webnotes.conn.convert_to_lists
|
|||||||
|
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, doc, doclist=[]):
|
def __init__(self, doc, doclist=[]):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
self.doclist = doclist
|
self.doclist = doclist
|
||||||
|
|
||||||
# Autoname
|
# Autoname
|
||||||
# ---------
|
# ---------
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
|
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
|
||||||
|
|
||||||
|
|
||||||
def get_item_specification_details(self):
|
def get_item_specification_details(self):
|
||||||
self.doc.clear_table(self.doclist, 'qa_specification_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'qa_specification_details')
|
||||||
specification = sql("select specification, value from `tabItem Quality Inspection Parameter` where parent = '%s' order by idx" % (self.doc.item_code))
|
specification = sql("select specification, value from `tabItem Quality Inspection Parameter` \
|
||||||
for d in specification:
|
where parent = '%s' order by idx" % (self.doc.item_code))
|
||||||
child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', 1, self.doclist)
|
for d in specification:
|
||||||
child.specification = d[0]
|
child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', 1, self.doclist)
|
||||||
child.value = d[1]
|
child.specification = d[0]
|
||||||
child.status = 'Accepted'
|
child.value = d[1]
|
||||||
|
child.status = 'Accepted'
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if self.doc.purchase_receipt_no:
|
if self.doc.purchase_receipt_no:
|
||||||
sql("update `tabPurchase Receipt Item` set qa_no = '%s' where parent = '%s' and item_code = '%s'" % (self.doc.name, self.doc.purchase_receipt_no, self.doc.item_code))
|
sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '%s', t2.modified = '%s' \
|
||||||
|
where t1.parent = '%s' and t1.item_code = '%s' and t1.parent = t2.name" \
|
||||||
|
% (self.doc.name, self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code))
|
||||||
|
|
||||||
|
|
||||||
|
def on_cancel(self):
|
||||||
def on_cancel(self):
|
if self.doc.purchase_receipt_no:
|
||||||
if self.doc.purchase_receipt_no:
|
sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '', t2.modified = '%s' \
|
||||||
sql("update `tabPurchase Receipt Item` set qa_no = '' where parent = '%s' and item_code = '%s'" % (self.doc.purchase_receipt_no, self.doc.item_code))
|
where t1.parent = '%s' and t1.item_code = '%s' and t1.parent = t2.name" \
|
||||||
|
% (self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code))
|
||||||
|
|||||||
@@ -62,24 +62,9 @@ cur_frm.cscript.make_address = function() {
|
|||||||
},
|
},
|
||||||
as_dict: 1,
|
as_dict: 1,
|
||||||
no_results_message: 'No addresses created',
|
no_results_message: 'No addresses created',
|
||||||
render_row: function(wrapper, data) {
|
render_row: cur_frm.cscript.render_address_row,
|
||||||
$(wrapper).css('padding','5px 0px');
|
|
||||||
var link = $ln(wrapper,cstr(data.name), function() { loaddoc("Address", this.dn); }, {fontWeight:'bold'});
|
|
||||||
link.dn = data.name
|
|
||||||
|
|
||||||
$a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_address ? '[Primary]' : '') + (data.is_shipping_address ? '[Shipping]' : ''));
|
|
||||||
$a(wrapper,'div','',{marginTop:'5px', color:'#555'},
|
|
||||||
(data.address_line1 ? data.address_line1 + '<br />' : '') +
|
|
||||||
(data.address_line2 ? data.address_line2 + '<br />' : '') +
|
|
||||||
(data.city ? data.city + '<br />' : '') +
|
|
||||||
(data.state ? data.state + ', ' : '') +
|
|
||||||
(data.country ? data.country + '<br />' : '') +
|
|
||||||
(data.pincode ? 'Pincode: ' + data.pincode + '<br />' : '') +
|
|
||||||
(data.phone ? 'Phone: ' + data.phone + '<br />' : '') +
|
|
||||||
(data.fax ? 'Fax: ' + data.fax + '<br />' : '') +
|
|
||||||
(data.email_id ? 'Email: ' + data.email_id + '<br />' : ''));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
// note: render_address_row is defined in contact_control.js
|
||||||
}
|
}
|
||||||
cur_frm.address_list.run();
|
cur_frm.address_list.run();
|
||||||
}
|
}
|
||||||
@@ -95,15 +80,9 @@ cur_frm.cscript.make_contact = function() {
|
|||||||
},
|
},
|
||||||
as_dict: 1,
|
as_dict: 1,
|
||||||
no_results_message: 'No contacts created',
|
no_results_message: 'No contacts created',
|
||||||
render_row: function(wrapper, data) {
|
render_row: cur_frm.cscript.render_contact_row,
|
||||||
$(wrapper).css('padding', '5px 0px');
|
|
||||||
var link = $ln(wrapper, cstr(data.name), function() { loaddoc("Contact", this.dn); }, {fontWeight:'bold'});
|
|
||||||
link.dn = data.name
|
|
||||||
|
|
||||||
$a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_contact ? '[Primary]' : ''));
|
|
||||||
$a(wrapper,'div', '',{marginTop:'5px', color:'#555'}, data.first_name + (data.last_name ? ' ' + data.last_name + '<br />' : '<br>') + (data.phone ? 'Tel: ' + data.phone + '<br />' : '') + (data.mobile_no ? 'Mobile: ' + data.mobile_no + '<br />' : '') + (data.email_id ? 'Email: ' + data.email_id + '<br />' : '') + (data.department ? 'Department: ' + data.department + '<br />' : '') + (data.designation ? 'Designation: ' + data.designation + '<br />' : ''));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
// note: render_contact_row is defined in contact_control.js
|
||||||
}
|
}
|
||||||
cur_frm.contact_list.run();
|
cur_frm.contact_list.run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,10 +163,21 @@ class DocType:
|
|||||||
delete from `tabCommunication`
|
delete from `tabCommunication`
|
||||||
where supplier = %s and customer is null""", self.doc.name)
|
where supplier = %s and customer is null""", self.doc.name)
|
||||||
|
|
||||||
|
def delete_supplier_account(self):
|
||||||
|
"""delete supplier's ledger if exist and check balance before deletion"""
|
||||||
|
acc = sql("select name from `tabAccount` where master_type = 'Supplier' \
|
||||||
|
and master_name = %s and docstatus < 2", self.doc.name)
|
||||||
|
if acc:
|
||||||
|
from webnotes.model import delete_doc
|
||||||
|
delete_doc('Account', acc[0][0])
|
||||||
|
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
self.delete_supplier_address()
|
self.delete_supplier_address()
|
||||||
self.delete_supplier_contact()
|
self.delete_supplier_contact()
|
||||||
self.delete_supplier_communication()
|
self.delete_supplier_communication()
|
||||||
|
self.delete_supplier_account()
|
||||||
|
|
||||||
|
|
||||||
# on rename
|
# on rename
|
||||||
# ---------
|
# ---------
|
||||||
|
|||||||
@@ -14,6 +14,12 @@
|
|||||||
<br>
|
<br>
|
||||||
<h4><a href="#!List/Item">Item</a></h4>
|
<h4><a href="#!List/Item">Item</a></h4>
|
||||||
<p class="help">Item Master</p>
|
<p class="help">Item Master</p>
|
||||||
|
<br>
|
||||||
|
<h4><a href="#!List/Contact">Contact</a></h4>
|
||||||
|
<p class="help">Contact Master</p>
|
||||||
|
<br>
|
||||||
|
<h4><a href="#!List/Address">Address</a></h4>
|
||||||
|
<p class="help">Address Master</p>
|
||||||
</div>
|
</div>
|
||||||
<div style="clear: both"></div>
|
<div style="clear: both"></div>
|
||||||
<hr>
|
<hr>
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class DocType:
|
|||||||
if not self.doc.kra_template:
|
if not self.doc.kra_template:
|
||||||
msgprint("Please select Appraisal Template to be be fetched")
|
msgprint("Please select Appraisal Template to be be fetched")
|
||||||
raise Exception
|
raise Exception
|
||||||
self.doc.clear_table(self.doclist,'appraisal_details')
|
self.doclist = self.doc.clear_table(self.doclist,'appraisal_details')
|
||||||
get_obj('DocType Mapper', 'Appraisal Template-Appraisal').dt_map('Appraisal Template', 'Appraisal', self.doc.kra_template, self.doc, self.doclist, "[['Appraisal Template','Appraisal'],['Appraisal Template Goal', 'Appraisal Goal']]")
|
get_obj('DocType Mapper', 'Appraisal Template-Appraisal').dt_map('Appraisal Template', 'Appraisal', self.doc.kra_template, self.doc, self.doclist, "[['Appraisal Template','Appraisal'],['Appraisal Template Goal', 'Appraisal Goal']]")
|
||||||
|
|
||||||
def validate_dates(self):
|
def validate_dates(self):
|
||||||
|
|||||||
@@ -12,8 +12,9 @@ wn.doclistviews['Employee'] = wn.views.ListView.extend({
|
|||||||
"`tabEmployee`.company",
|
"`tabEmployee`.company",
|
||||||
"`tabEmployee`.reports_to",
|
"`tabEmployee`.reports_to",
|
||||||
"`tabEmployee`.date_of_joining",
|
"`tabEmployee`.date_of_joining",
|
||||||
|
"`tabEmployee`.status",
|
||||||
]);
|
]);
|
||||||
this.stats = this.stats.concat(['company']);
|
this.stats = this.stats.concat(['status', 'company']);
|
||||||
},
|
},
|
||||||
|
|
||||||
prepare_data: function(data) {
|
prepare_data: function(data) {
|
||||||
@@ -32,14 +33,22 @@ wn.doclistviews['Employee'] = wn.views.ListView.extend({
|
|||||||
data.company && concat_list.push(data.company);
|
data.company && concat_list.push(data.company);
|
||||||
data.branch && concat_list.push(data.branch);
|
data.branch && concat_list.push(data.branch);
|
||||||
data.description = concat_list.join(", ");
|
data.description = concat_list.join(", ");
|
||||||
|
|
||||||
|
if(data.status=='Left') {
|
||||||
|
data.label_type = 'important';
|
||||||
|
} else if(data.status=='Active') {
|
||||||
|
data.label_type = 'success';
|
||||||
|
}
|
||||||
|
data.status_html = repl('<span class="label label-%(label_type)s" \
|
||||||
|
support_list_status="%(status)s">%(status)s</span>', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
columns: [
|
columns: [
|
||||||
{width: '3%', content: 'check'},
|
{width: '3%', content: 'check'},
|
||||||
{width: '3%', content: 'docstatus'},
|
|
||||||
{width: '12%', content: 'name'},
|
{width: '12%', content: 'name'},
|
||||||
{width: '25%', content: 'employee_name'},
|
{width: '25%', content: 'employee_name'},
|
||||||
{width: '45%', content: 'description+tags',
|
{width: '10%', content: 'status_html'},
|
||||||
|
{width: '38%', content: 'description+tags',
|
||||||
css: {'color': '#aaa'}},
|
css: {'color': '#aaa'}},
|
||||||
{width: '12%', content:'date_of_joining',
|
{width: '12%', content:'date_of_joining',
|
||||||
css: {'text-align': 'right', 'color': '#777'}},
|
css: {'text-align': 'right', 'color': '#777'}},
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ class DocType:
|
|||||||
# clear table
|
# clear table
|
||||||
# ------------
|
# ------------
|
||||||
def clear_table(self):
|
def clear_table(self):
|
||||||
self.doc.clear_table(self.doclist,'holiday_list_details')
|
self.doclist = self.doc.clear_table(self.doclist,'holiday_list_details')
|
||||||
|
|
||||||
|
|
||||||
# ***************************************** validate *************************************************
|
# ***************************************** validate *************************************************
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ cur_frm.cscript.onload = function(doc,dt,dn){
|
|||||||
// Validation For To Date
|
// Validation For To Date
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
cur_frm.cscript.to_date = function(doc, cdt, cdn) {
|
cur_frm.cscript.to_date = function(doc, cdt, cdn) {
|
||||||
$c('runserverobj', args={'method':'to_date_validation','docs':compress_doclist([doc])},
|
$c('runserverobj', args={'method':'to_date_validation','docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
|
||||||
function(r, rt) {
|
function(r, rt) {
|
||||||
var doc = locals[cdt][cdn];
|
var doc = locals[cdt][cdn];
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ class DocType(TransactionBase):
|
|||||||
# Pull struct details
|
# Pull struct details
|
||||||
#=======================================================
|
#=======================================================
|
||||||
def pull_sal_struct(self, struct):
|
def pull_sal_struct(self, struct):
|
||||||
self.doc.clear_table(self.doclist, 'earning_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'earning_details')
|
||||||
self.doc.clear_table(self.doclist, 'deduction_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'deduction_details')
|
||||||
|
|
||||||
get_obj('DocType Mapper', 'Salary Structure-Salary Slip').dt_map('Salary Structure', 'Salary Slip', struct, self.doc, self.doclist, "[['Salary Structure', 'Salary Slip'],['Salary Structure Earning', 'Salary Slip Earning'],['Salary Structure Deduction','Salary Slip Deduction']]")
|
get_obj('DocType Mapper', 'Salary Structure-Salary Slip').dt_map('Salary Structure', 'Salary Slip', struct, self.doc, self.doclist, "[['Salary Structure', 'Salary Slip'],['Salary Structure Earning', 'Salary Slip Earning'],['Salary Structure Deduction','Salary Slip Deduction']]")
|
||||||
|
|
||||||
|
|||||||
0
erpnext/patches/july_2012/__init__.py
Normal file
0
erpnext/patches/july_2012/__init__.py
Normal file
11
erpnext/patches/july_2012/address_contact_perms.py
Normal file
11
erpnext/patches/july_2012/address_contact_perms.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
def execute():
|
||||||
|
import webnotes
|
||||||
|
webnotes.conn.sql("""\
|
||||||
|
delete from `tabDocPerm`
|
||||||
|
where parent in ('Address', 'Contact')""")
|
||||||
|
webnotes.conn.commit()
|
||||||
|
|
||||||
|
import webnotes.model.sync
|
||||||
|
webnotes.model.sync.sync('utilities', 'address')
|
||||||
|
webnotes.model.sync.sync('utilities', 'contact')
|
||||||
|
webnotes.conn.begin()
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
def execute():
|
||||||
|
import webnotes
|
||||||
|
from webnotes.utils import flt
|
||||||
|
wrong_plist = webnotes.conn.sql("""
|
||||||
|
select dnpi.name, dnpi.parent, dnpi.docstatus, dnpi.serial_no
|
||||||
|
from `tabDelivery Note Packing Item` dnpi
|
||||||
|
where ifnull(dnpi.parent, '') != ''
|
||||||
|
and ifnull(dnpi.parent, '') not like 'old_par%'
|
||||||
|
and dnpi.parenttype = 'Delivery Note'
|
||||||
|
and not exists (
|
||||||
|
select * from `tabDelivery Note Item` dni
|
||||||
|
where dni.item_code = dnpi.parent_item and
|
||||||
|
dni.name = dnpi.parent_detail_docname and
|
||||||
|
dni.parent = dnpi.parent
|
||||||
|
)
|
||||||
|
""", as_dict=1)
|
||||||
|
|
||||||
|
for d in wrong_plist:
|
||||||
|
if d['docstatus'] == 2 and d['serial_no']:
|
||||||
|
for s in d['serial_no'].splitlines():
|
||||||
|
sle = webnotes.conn.sql("""
|
||||||
|
select actual_qty, warehouse, voucher_no
|
||||||
|
from `tabStock Ledger Entry`
|
||||||
|
where (
|
||||||
|
serial_no like '%s\n%%'
|
||||||
|
or serial_no like '%%\n%s'
|
||||||
|
or serial_no like '%%\n%s\n%%'
|
||||||
|
or serial_no = '%s'
|
||||||
|
)
|
||||||
|
and voucher_no != '%s'
|
||||||
|
and ifnull(is_cancelled, 'No') = 'No'
|
||||||
|
order by name desc
|
||||||
|
limit 1
|
||||||
|
"""% (s, s, s, s, d['parent']), as_dict=1)
|
||||||
|
|
||||||
|
status = 'Not in Use'
|
||||||
|
if sle and flt(sle[0]['actual_qty']) > 0:
|
||||||
|
status = 'In Store'
|
||||||
|
elif sle and flt(sle[0]['actual_qty']) < 0:
|
||||||
|
status = 'Delivered'
|
||||||
|
|
||||||
|
webnotes.conn.sql("update `tabSerial No` set status = %s, warehouse = %s where name = %s", (status, sle[0]['warehouse'], s))
|
||||||
|
|
||||||
|
webnotes.conn.sql("delete from `tabDelivery Note Packing Item` where name = %s", d['name'])
|
||||||
4
erpnext/patches/july_2012/reload_pr_po_mapper.py
Normal file
4
erpnext/patches/july_2012/reload_pr_po_mapper.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
def execute():
|
||||||
|
import webnotes
|
||||||
|
from webnotes.modules import reload_doc
|
||||||
|
reload_doc('buying', 'DocType Mapper', 'Purchase Request-Purchase Order')
|
||||||
5
erpnext/patches/june_2012/alter_tabsessions.py
Normal file
5
erpnext/patches/june_2012/alter_tabsessions.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
def execute():
|
||||||
|
import webnotes
|
||||||
|
webnotes.conn.commit()
|
||||||
|
webnotes.conn.sql("alter table `tabSessions` modify user varchar(180)")
|
||||||
|
webnotes.conn.begin()
|
||||||
11
erpnext/patches/june_2012/cache_item_table.py
Normal file
11
erpnext/patches/june_2012/cache_item_table.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
def execute():
|
||||||
|
"""drop and create __CacheItem table again"""
|
||||||
|
import webnotes
|
||||||
|
webnotes.conn.commit()
|
||||||
|
webnotes.conn.sql("drop table __CacheItem")
|
||||||
|
webnotes.conn.sql("""create table __CacheItem(
|
||||||
|
`key` VARCHAR(180) NOT NULL PRIMARY KEY,
|
||||||
|
`value` LONGTEXT,
|
||||||
|
`expires_on` DATETIME
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8""")
|
||||||
|
webnotes.conn.begin()
|
||||||
17
erpnext/patches/june_2012/delete_old_parent_entries.py
Normal file
17
erpnext/patches/june_2012/delete_old_parent_entries.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
def execute():
|
||||||
|
"""delete entries of child table having parent like old_par%% or ''"""
|
||||||
|
import webnotes
|
||||||
|
res = webnotes.conn.sql("""\
|
||||||
|
select dt.name from `tabDocType` dt
|
||||||
|
where ifnull(dt.istable, 0)=1 and
|
||||||
|
exists (
|
||||||
|
select * from `tabDocField` df
|
||||||
|
where df.fieldtype='Table' and
|
||||||
|
df.options=dt.name
|
||||||
|
)""")
|
||||||
|
for r in res:
|
||||||
|
if r[0]:
|
||||||
|
webnotes.conn.sql("""\
|
||||||
|
delete from `tab%s`
|
||||||
|
where (ifnull(parent, '')='' or parent like "old_par%%") and
|
||||||
|
ifnull(parenttype, '')!=''""" % r[0])
|
||||||
@@ -447,4 +447,39 @@ patch_list = [
|
|||||||
'patch_file': 'set_recurring_type',
|
'patch_file': 'set_recurring_type',
|
||||||
'description': "set recurring type as monthly in old"
|
'description': "set recurring type as monthly in old"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'patch_module': 'patches.june_2012',
|
||||||
|
'patch_file': 'alter_tabsessions',
|
||||||
|
'description': "alter tabsessions to change user column definition"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'patch_module': 'patches.june_2012',
|
||||||
|
'patch_file': 'delete_old_parent_entries',
|
||||||
|
'description': "delete entries of child table having parent like old_par%% or ''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'patch_module': 'patches.april_2012',
|
||||||
|
'patch_file': 'delete_about_contact',
|
||||||
|
'description': "delete depracated doctypes of website module"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'patch_module': 'patches.june_2012',
|
||||||
|
'patch_file': 'cache_item_table',
|
||||||
|
'description': "create cache item table again"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'patch_module': 'patches.july_2012',
|
||||||
|
'patch_file': 'reload_pr_po_mapper',
|
||||||
|
'description': "order date should be greater than equal to request date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'patch_module': 'patches.july_2012',
|
||||||
|
'patch_file': 'address_contact_perms',
|
||||||
|
'description': "sync address contact perms"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'patch_module': 'patches.july_2012',
|
||||||
|
'patch_file': 'packing_list_cleanup_and_serial_no',
|
||||||
|
'description': "packing list cleanup and serial no status update"
|
||||||
|
},
|
||||||
]
|
]
|
||||||
@@ -322,7 +322,7 @@ class DocType:
|
|||||||
|
|
||||||
def add_to_flat_bom_detail(self, is_submit = 0):
|
def add_to_flat_bom_detail(self, is_submit = 0):
|
||||||
"Add items to Flat BOM table"
|
"Add items to Flat BOM table"
|
||||||
self.doc.clear_table(self.doclist, 'flat_bom_details', 1)
|
self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details', 1)
|
||||||
for d in self.cur_flat_bom_items:
|
for d in self.cur_flat_bom_items:
|
||||||
ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', 1, self.doclist)
|
ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', 1, self.doclist)
|
||||||
for i in d.keys():
|
for i in d.keys():
|
||||||
|
|||||||
@@ -58,13 +58,13 @@ class DocType:
|
|||||||
|
|
||||||
def clear_so_table(self):
|
def clear_so_table(self):
|
||||||
""" Clears sales order table"""
|
""" Clears sales order table"""
|
||||||
self.doc.clear_table(self.doclist, 'pp_so_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'pp_so_details')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def clear_item_table(self):
|
def clear_item_table(self):
|
||||||
""" Clears item table"""
|
""" Clears item table"""
|
||||||
self.doc.clear_table(self.doclist, 'pp_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'pp_details')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -95,5 +95,5 @@ cur_frm.cscript.add = function(doc, dt, dn) {
|
|||||||
cur_frm.mylist.run();
|
cur_frm.mylist.run();
|
||||||
|
|
||||||
}
|
}
|
||||||
$c_obj([doc],'add_update','',callback);
|
$c_obj(make_doclist(doc.doctype, doc.name),'add_update','',callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,24 +81,9 @@ cur_frm.cscript.make_address = function() {
|
|||||||
},
|
},
|
||||||
as_dict: 1,
|
as_dict: 1,
|
||||||
no_results_message: 'No addresses created',
|
no_results_message: 'No addresses created',
|
||||||
render_row: function(wrapper, data) {
|
render_row: cur_frm.cscript.render_address_row,
|
||||||
$(wrapper).css('padding','5px 0px');
|
|
||||||
var link = $ln(wrapper,cstr(data.name), function() { loaddoc("Address", this.dn); }, {fontWeight:'bold'});
|
|
||||||
link.dn = data.name
|
|
||||||
|
|
||||||
$a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_address ? '[Primary]' : '') + (data.is_shipping_address ? '[Shipping]' : ''));
|
|
||||||
$a(wrapper,'div','',{marginTop:'5px', color:'#555'},
|
|
||||||
(data.address_line1 ? data.address_line1 + '<br />' : '') +
|
|
||||||
(data.address_line2 ? data.address_line2 + '<br />' : '') +
|
|
||||||
(data.city ? data.city + '<br />' : '') +
|
|
||||||
(data.state ? data.state + ', ' : '') +
|
|
||||||
(data.country ? data.country + '<br />' : '') +
|
|
||||||
(data.pincode ? 'Pincode: ' + data.pincode + '<br />' : '') +
|
|
||||||
(data.phone ? 'Phone: ' + data.phone + '<br />' : '') +
|
|
||||||
(data.fax ? 'Fax: ' + data.fax + '<br />' : '') +
|
|
||||||
(data.email_id ? 'Email: ' + data.email_id + '<br />' : ''));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
// note: render_address_row is defined in contact_control.js
|
||||||
}
|
}
|
||||||
cur_frm.address_list.run();
|
cur_frm.address_list.run();
|
||||||
}
|
}
|
||||||
@@ -114,15 +99,9 @@ cur_frm.cscript.make_contact = function() {
|
|||||||
},
|
},
|
||||||
as_dict: 1,
|
as_dict: 1,
|
||||||
no_results_message: 'No contacts created',
|
no_results_message: 'No contacts created',
|
||||||
render_row: function(wrapper, data) {
|
render_row: cur_frm.cscript.render_contact_row,
|
||||||
$(wrapper).css('padding', '5px 0px');
|
|
||||||
var link = $ln(wrapper, cstr(data.name), function() { loaddoc("Contact", this.dn); }, {fontWeight:'bold'});
|
|
||||||
link.dn = data.name
|
|
||||||
|
|
||||||
$a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_contact ? '[Primary]' : ''));
|
|
||||||
$a(wrapper,'div', '',{marginTop:'5px', color:'#555'}, data.first_name + (data.last_name ? ' ' + data.last_name + '<br />' : '<br>') + (data.phone ? 'Tel: ' + data.phone + '<br />' : '') + (data.mobile_no ? 'Mobile: ' + data.mobile_no + '<br />' : '') + (data.email_id ? 'Email: ' + data.email_id + '<br />' : '') + (data.department ? 'Department: ' + data.department + '<br />' : '') + (data.designation ? 'Designation: ' + data.designation + '<br />' : ''));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
// note: render_contact_row is defined in contact_control.js
|
||||||
}
|
}
|
||||||
cur_frm.contact_list.run();
|
cur_frm.contact_list.run();
|
||||||
|
|
||||||
|
|||||||
@@ -239,12 +239,20 @@ class DocType:
|
|||||||
webnotes.conn.sql("""\
|
webnotes.conn.sql("""\
|
||||||
delete from `tabCommunication`
|
delete from `tabCommunication`
|
||||||
where customer = %s and supplier is null""", self.doc.name)
|
where customer = %s and supplier is null""", self.doc.name)
|
||||||
|
|
||||||
# ******************************************************* on trash *********************************************************
|
def delete_customer_account(self):
|
||||||
|
"""delete customer's ledger if exist and check balance before deletion"""
|
||||||
|
acc = sql("select name from `tabAccount` where master_type = 'Customer' \
|
||||||
|
and master_name = %s and docstatus < 2", self.doc.name)
|
||||||
|
if acc:
|
||||||
|
from webnotes.model import delete_doc
|
||||||
|
delete_doc('Account', acc[0][0])
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
self.delete_customer_address()
|
self.delete_customer_address()
|
||||||
self.delete_customer_contact()
|
self.delete_customer_contact()
|
||||||
self.delete_customer_communication()
|
self.delete_customer_communication()
|
||||||
|
self.delete_customer_account()
|
||||||
if self.doc.lead_name:
|
if self.doc.lead_name:
|
||||||
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
|
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ cur_frm.cscript.item_code=function(doc,cdt,cdn){
|
|||||||
// ===============================================================
|
// ===============================================================
|
||||||
cur_frm.cscript['Create Customer'] = function(){
|
cur_frm.cscript['Create Customer'] = function(){
|
||||||
var doc = cur_frm.doc;
|
var doc = cur_frm.doc;
|
||||||
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])},
|
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
|
||||||
function(r,rt){
|
function(r,rt){
|
||||||
if(r.message == 'Converted'){
|
if(r.message == 'Converted'){
|
||||||
msgprint("This lead is already converted to customer");
|
msgprint("This lead is already converted to customer");
|
||||||
@@ -124,7 +124,7 @@ cur_frm.cscript.send_email = function(doc,cdt,cdn){
|
|||||||
// ===============================================================
|
// ===============================================================
|
||||||
cur_frm.cscript['Create Opportunity'] = function(){
|
cur_frm.cscript['Create Opportunity'] = function(){
|
||||||
var doc = cur_frm.doc;
|
var doc = cur_frm.doc;
|
||||||
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])},
|
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
|
||||||
function(r,rt){
|
function(r,rt){
|
||||||
if(r.message == 'Converted'){
|
if(r.message == 'Converted'){
|
||||||
msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer");
|
msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer");
|
||||||
|
|||||||
@@ -50,10 +50,9 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur_frm.cscript.make_communication_body();
|
cur_frm.cscript.make_communication_body();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||||
var callback = function(doc, dt, dn) {
|
var callback = function(doc, dt, dn) {
|
||||||
// defined in sales_common.js
|
// defined in sales_common.js
|
||||||
cur_frm.cscript.update_item_details(doc, dt, dn);
|
cur_frm.cscript.update_item_details(doc, dt, dn);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class DocType(TransactionBase):
|
|||||||
# Pull Opportunity Details
|
# Pull Opportunity Details
|
||||||
# --------------------
|
# --------------------
|
||||||
def pull_enq_details(self):
|
def pull_enq_details(self):
|
||||||
self.doc.clear_table(self.doclist, 'quotation_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'quotation_details')
|
||||||
get_obj('DocType Mapper', 'Opportunity-Quotation').dt_map('Opportunity', 'Quotation', self.doc.enq_no, self.doc, self.doclist, "[['Opportunity', 'Quotation'],['Opportunity Item', 'Quotation Item']]")
|
get_obj('DocType Mapper', 'Opportunity-Quotation').dt_map('Opportunity', 'Quotation', self.doc.enq_no, self.doc, self.doclist, "[['Opportunity', 'Quotation'],['Opportunity Item', 'Quotation Item']]")
|
||||||
|
|
||||||
self.get_adj_percent()
|
self.get_adj_percent()
|
||||||
@@ -81,12 +81,19 @@ class DocType(TransactionBase):
|
|||||||
obj = get_obj('Sales Common')
|
obj = get_obj('Sales Common')
|
||||||
for doc in self.doclist:
|
for doc in self.doclist:
|
||||||
if doc.fields.get('item_code'):
|
if doc.fields.get('item_code'):
|
||||||
arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'),
|
arg = {
|
||||||
'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
|
'item_code': doc.fields.get('item_code'),
|
||||||
ret = obj.get_item_defaults(arg)
|
'income_account': doc.fields.get('income_account'),
|
||||||
for r in ret:
|
'cost_center': doc.fields.get('cost_center'),
|
||||||
if not doc.fields.get(r):
|
'warehouse': doc.fields.get('warehouse')
|
||||||
doc.fields[r] = ret[r]
|
}
|
||||||
|
fields_dict = obj.get_item_details(arg, self)
|
||||||
|
if fields_dict:
|
||||||
|
doc.fields.update(fields_dict)
|
||||||
|
#ret = obj.get_item_defaults(arg)
|
||||||
|
#for r in ret:
|
||||||
|
# if not doc.fields.get(r):
|
||||||
|
# doc.fields[r] = ret[r]
|
||||||
|
|
||||||
|
|
||||||
# Re-calculates Basic Rate & amount based on Price List Selected
|
# Re-calculates Basic Rate & amount based on Price List Selected
|
||||||
@@ -108,12 +115,12 @@ class DocType(TransactionBase):
|
|||||||
# Load Default Charges
|
# Load Default Charges
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
def load_default_taxes(self):
|
def load_default_taxes(self):
|
||||||
return get_obj('Sales Common').load_default_taxes(self)
|
self.doclist = get_obj('Sales Common').load_default_taxes(self)
|
||||||
|
|
||||||
# Pull details from other charges master (Get Sales Taxes and Charges Master)
|
# Pull details from other charges master (Get Sales Taxes and Charges Master)
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
def get_other_charges(self):
|
def get_other_charges(self):
|
||||||
return get_obj('Sales Common').get_other_charges(self)
|
self.doclist = get_obj('Sales Common').get_other_charges(self)
|
||||||
|
|
||||||
|
|
||||||
# GET TERMS AND CONDITIONS
|
# GET TERMS AND CONDITIONS
|
||||||
|
|||||||
@@ -72,9 +72,11 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
# Get Sales Person Details
|
# Get Sales Person Details
|
||||||
# ==========================
|
# ==========================
|
||||||
|
|
||||||
|
# TODO: To be deprecated if not in use
|
||||||
def get_sales_person_details(self, obj):
|
def get_sales_person_details(self, obj):
|
||||||
if obj.doc.doctype != 'Quotation':
|
if obj.doc.doctype != 'Quotation':
|
||||||
obj.doc.clear_table(obj.doclist,'sales_team')
|
obj.doclist = obj.doc.clear_table(obj.doclist,'sales_team')
|
||||||
idx = 0
|
idx = 0
|
||||||
for d in webnotes.conn.sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % obj.doc.customer):
|
for d in webnotes.conn.sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % obj.doc.customer):
|
||||||
ch = addchild(obj.doc, 'sales_team', 'Sales Team', 1, obj.doclist)
|
ch = addchild(obj.doc, 'sales_team', 'Sales Team', 1, obj.doclist)
|
||||||
@@ -84,6 +86,7 @@ class DocType(TransactionBase):
|
|||||||
ch.incentives = d and flt(d[3]) or 0
|
ch.incentives = d and flt(d[3]) or 0
|
||||||
ch.idx = idx
|
ch.idx = idx
|
||||||
idx += 1
|
idx += 1
|
||||||
|
return obj.doclist
|
||||||
|
|
||||||
|
|
||||||
# Get customer's contact person details
|
# Get customer's contact person details
|
||||||
@@ -156,6 +159,10 @@ class DocType(TransactionBase):
|
|||||||
ret['export_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
|
ret['export_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
|
||||||
ret['base_ref_rate'] = flt(base_ref_rate)
|
ret['base_ref_rate'] = flt(base_ref_rate)
|
||||||
ret['basic_rate'] = flt(base_ref_rate)
|
ret['basic_rate'] = flt(base_ref_rate)
|
||||||
|
|
||||||
|
if ret['warehouse'] or ret['reserved_warehouse']:
|
||||||
|
av_qty = self.get_available_qty({'item_code': args['item_code'], 'warehouse': ret['warehouse'] or ret['reserved_warehouse']})
|
||||||
|
ret.update(av_qty)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
@@ -172,6 +179,14 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def get_available_qty(self,args):
|
||||||
|
tot_avail_qty = webnotes.conn.sql("select projected_qty, actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1)
|
||||||
|
ret = {
|
||||||
|
'projected_qty' : tot_avail_qty and flt(tot_avail_qty[0]['projected_qty']) or 0,
|
||||||
|
'actual_qty' : tot_avail_qty and flt(tot_avail_qty[0]['actual_qty']) or 0
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
# ***************** Get Ref rate as entered in Item Master ********************
|
# ***************** Get Ref rate as entered in Item Master ********************
|
||||||
def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate):
|
def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate):
|
||||||
@@ -215,15 +230,15 @@ class DocType(TransactionBase):
|
|||||||
# ====================
|
# ====================
|
||||||
def load_default_taxes(self, obj):
|
def load_default_taxes(self, obj):
|
||||||
if cstr(obj.doc.charge):
|
if cstr(obj.doc.charge):
|
||||||
self.get_other_charges(obj)
|
return self.get_other_charges(obj)
|
||||||
else:
|
else:
|
||||||
self.get_other_charges(obj, 1)
|
return self.get_other_charges(obj, 1)
|
||||||
|
|
||||||
|
|
||||||
# Get other charges from Master
|
# Get other charges from Master
|
||||||
# =================================================================================
|
# =================================================================================
|
||||||
def get_other_charges(self,obj, default=0):
|
def get_other_charges(self,obj, default=0):
|
||||||
obj.doc.clear_table(obj.doclist,'other_charges')
|
obj.doclist = obj.doc.clear_table(obj.doclist, 'other_charges')
|
||||||
if not getlist(obj.doclist, 'other_charges'):
|
if not getlist(obj.doclist, 'other_charges'):
|
||||||
if default: add_cond = 'ifnull(t2.is_default,0) = 1'
|
if default: add_cond = 'ifnull(t2.is_default,0) = 1'
|
||||||
else: add_cond = 't1.parent = "'+cstr(obj.doc.charge)+'"'
|
else: add_cond = 't1.parent = "'+cstr(obj.doc.charge)+'"'
|
||||||
@@ -253,6 +268,7 @@ class DocType(TransactionBase):
|
|||||||
d.included_in_print_rate = cint(d.included_in_print_rate)
|
d.included_in_print_rate = cint(d.included_in_print_rate)
|
||||||
d.idx = idx
|
d.idx = idx
|
||||||
idx += 1
|
idx += 1
|
||||||
|
return obj.doclist
|
||||||
|
|
||||||
# Get TERMS AND CONDITIONS
|
# Get TERMS AND CONDITIONS
|
||||||
# =======================================================================================
|
# =======================================================================================
|
||||||
@@ -358,46 +374,64 @@ class DocType(TransactionBase):
|
|||||||
'rate' : rate and flt(rate[0]['tax_rate']) or 0
|
'rate' : rate and flt(rate[0]['tax_rate']) or 0
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# --------------
|
|
||||||
# get item list
|
|
||||||
# --------------
|
|
||||||
def get_item_list(self, obj, is_stopped):
|
def get_item_list(self, obj, is_stopped):
|
||||||
|
"""get item list"""
|
||||||
il = []
|
il = []
|
||||||
for d in getlist(obj.doclist,obj.fname):
|
for d in getlist(obj.doclist,obj.fname):
|
||||||
reserved_qty = 0 # used for delivery note
|
reserved_wh, reserved_qty = '', 0 # used for delivery note
|
||||||
qty = flt(d.qty)
|
qty = flt(d.qty)
|
||||||
if is_stopped:
|
if is_stopped:
|
||||||
qty = flt(d.qty) > flt(d.delivered_qty) and flt(flt(d.qty) - flt(d.delivered_qty)) or 0
|
qty = flt(d.qty) > flt(d.delivered_qty) and flt(flt(d.qty) - flt(d.delivered_qty)) or 0
|
||||||
|
|
||||||
if d.prevdoc_doctype == 'Sales Order': # used in delivery note to reduce reserved_qty
|
if d.prevdoc_doctype == 'Sales Order':
|
||||||
|
# used in delivery note to reduce reserved_qty
|
||||||
# Eg.: if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12.
|
# Eg.: if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12.
|
||||||
# But in this case reserved qty should only be reduced by 10 and not 12.
|
# But in this case reserved qty should only be reduced by 10 and not 12.
|
||||||
|
|
||||||
tot_qty, max_qty, tot_amt, max_amt = self.get_curr_and_ref_doc_details(d.doctype, 'prevdoc_detail_docname', d.prevdoc_detail_docname, 'Sales Order Item', obj.doc.name, obj.doc.doctype)
|
tot_qty, max_qty, tot_amt, max_amt, reserved_wh = self.get_curr_and_ref_doc_details(d.doctype, 'prevdoc_detail_docname', d.prevdoc_detail_docname, obj.doc.name, obj.doc.doctype)
|
||||||
if((flt(tot_qty) + flt(qty) > flt(max_qty))):
|
if((flt(tot_qty) + flt(qty) > flt(max_qty))):
|
||||||
reserved_qty = -(flt(max_qty)-flt(tot_qty))
|
reserved_qty = -(flt(max_qty)-flt(tot_qty))
|
||||||
else:
|
else:
|
||||||
reserved_qty = - flt(qty)
|
reserved_qty = - flt(qty)
|
||||||
|
|
||||||
warehouse = (obj.fname == "sales_order_details") and d.reserved_warehouse or d.warehouse
|
if obj.doc.doctype == 'Sales Order':
|
||||||
|
reserved_wh = d.reserved_warehouse
|
||||||
|
|
||||||
if self.has_sales_bom(d.item_code):
|
if self.has_sales_bom(d.item_code):
|
||||||
for p in getlist(obj.doclist, 'packing_details'):
|
for p in getlist(obj.doclist, 'packing_details'):
|
||||||
#if p.parent_item == d.item_code: -- this fails when item with same name appears more than once in delivery note item table
|
|
||||||
if p.parent_detail_docname == d.name:
|
if p.parent_detail_docname == d.name:
|
||||||
# the packing details table's qty is already multiplied with parent's qty
|
# the packing details table's qty is already multiplied with parent's qty
|
||||||
il.append([warehouse, p.item_code, flt(p.qty), (flt(p.qty)/qty)*(reserved_qty), p.uom, p.batch_no, p.serial_no])
|
il.append({
|
||||||
|
'warehouse': d.warehouse,
|
||||||
|
'reserved_warehouse': reserved_wh,
|
||||||
|
'item_code': p.item_code,
|
||||||
|
'qty': flt(p.qty),
|
||||||
|
'reserved_qty': (flt(p.qty)/qty)*(reserved_qty),
|
||||||
|
'uom': p.uom,
|
||||||
|
'batch_no': p.batch_no,
|
||||||
|
'serial_no': p.serial_no
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
il.append([warehouse, d.item_code, qty, reserved_qty, d.stock_uom, d.batch_no, d.serial_no])
|
il.append({
|
||||||
|
'warehouse': d.warehouse,
|
||||||
|
'reserved_warehouse': reserved_wh,
|
||||||
|
'item_code': d.item_code,
|
||||||
|
'qty': qty,
|
||||||
|
'reserved_qty': reserved_qty,
|
||||||
|
'uom': d.stock_uom,
|
||||||
|
'batch_no': d.batch_no,
|
||||||
|
'serial_no': d.serial_no
|
||||||
|
})
|
||||||
return il
|
return il
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------------------------
|
|
||||||
# get qty, amount already billed or delivered against curr line item for current doctype
|
def get_curr_and_ref_doc_details(self, curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name, curr_parent_doctype):
|
||||||
# For Eg: SO-RV get total qty, amount from SO and also total qty, amount against that SO in RV
|
""" Get qty, amount already billed or delivered against curr line item for current doctype
|
||||||
# ---------------------------------------------------------------------------------------------
|
For Eg: SO-RV get total qty, amount from SO and also total qty, amount against that SO in RV
|
||||||
def get_curr_and_ref_doc_details(self, curr_doctype, ref_tab_fname, ref_tab_dn, ref_doc_tname, curr_parent_name, curr_parent_doctype):
|
"""
|
||||||
# Get total qty, amt of current doctype (eg RV) except for qty, amt of this transaction
|
#Get total qty, amt of current doctype (eg RV) except for qty, amt of this transaction
|
||||||
if curr_parent_doctype == 'Installation Note':
|
if curr_parent_doctype == 'Installation Note':
|
||||||
curr_det = webnotes.conn.sql("select sum(qty) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
|
curr_det = webnotes.conn.sql("select sum(qty) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
|
||||||
qty, amt = curr_det and flt(curr_det[0][0]) or 0, 0
|
qty, amt = curr_det and flt(curr_det[0][0]) or 0, 0
|
||||||
@@ -406,10 +440,9 @@ class DocType(TransactionBase):
|
|||||||
qty, amt = curr_det and flt(curr_det[0][0]) or 0, curr_det and flt(curr_det[0][1]) or 0
|
qty, amt = curr_det and flt(curr_det[0][0]) or 0, curr_det and flt(curr_det[0][1]) or 0
|
||||||
|
|
||||||
# get total qty of ref doctype
|
# get total qty of ref doctype
|
||||||
ref_det = webnotes.conn.sql("select qty, amount from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn))
|
so_det = webnotes.conn.sql("select qty, amount, reserved_warehouse from `tabSales Order Item` where name = '%s' and docstatus = 1"% ref_tab_dn)
|
||||||
max_qty, max_amt = ref_det and flt(ref_det[0][0]) or 0, ref_det and flt(ref_det[0][1]) or 0
|
max_qty, max_amt, res_wh = so_det and flt(so_det[0][0]) or 0, so_det and flt(so_det[0][1]) or 0, so_det and cstr(so_det[0][2]) or ''
|
||||||
|
return qty, max_qty, amt, max_amt, res_wh
|
||||||
return qty, max_qty, amt, max_amt
|
|
||||||
|
|
||||||
|
|
||||||
# Make Packing List from Sales BOM
|
# Make Packing List from Sales BOM
|
||||||
@@ -484,11 +517,22 @@ class DocType(TransactionBase):
|
|||||||
self.cleanup_packing_list(obj, parent_items)
|
self.cleanup_packing_list(obj, parent_items)
|
||||||
|
|
||||||
def cleanup_packing_list(self, obj, parent_items):
|
def cleanup_packing_list(self, obj, parent_items):
|
||||||
"""Remove all those parent items which are no longer present in main item table"""
|
"""Remove all those child items which are no longer present in main item table"""
|
||||||
|
delete_list = []
|
||||||
for d in getlist(obj.doclist, 'packing_details'):
|
for d in getlist(obj.doclist, 'packing_details'):
|
||||||
if [d.parent_item, d.parent_detail_docname] not in parent_items:
|
if [d.parent_item, d.parent_detail_docname] not in parent_items:
|
||||||
d.parent = ''
|
# mark for deletion from doclist
|
||||||
|
delete_list.append(d.name)
|
||||||
|
|
||||||
|
if not delete_list: return
|
||||||
|
|
||||||
|
# delete from doclist
|
||||||
|
obj.doclist = filter(lambda d: d.name not in delete_list, obj.doclist)
|
||||||
|
|
||||||
|
# delete from db
|
||||||
|
webnotes.conn.sql("""\
|
||||||
|
delete from `tabDelivery Note Packing Item`
|
||||||
|
where name in ("%s")""" % '", "'.join(delete_list))
|
||||||
|
|
||||||
# Get total in words
|
# Get total in words
|
||||||
# ==================================================================
|
# ==================================================================
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ convert_to_lists = webnotes.conn.convert_to_lists
|
|||||||
from utilities.transaction_base import TransactionBase
|
from utilities.transaction_base import TransactionBase
|
||||||
|
|
||||||
class DocType(TransactionBase):
|
class DocType(TransactionBase):
|
||||||
def __init__(self, doc, doclist=[]):
|
def __init__(self, doc, doclist=None):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
|
if not doclist: doclist = []
|
||||||
self.doclist = doclist
|
self.doclist = doclist
|
||||||
self.tname = 'Sales Order Item'
|
self.tname = 'Sales Order Item'
|
||||||
self.fname = 'sales_order_details'
|
self.fname = 'sales_order_details'
|
||||||
@@ -55,10 +56,10 @@ class DocType(TransactionBase):
|
|||||||
# Pull Quotation Items
|
# Pull Quotation Items
|
||||||
# -----------------------
|
# -----------------------
|
||||||
def pull_quotation_details(self):
|
def pull_quotation_details(self):
|
||||||
self.doc.clear_table(self.doclist, 'other_charges')
|
self.doclist = self.doc.clear_table(self.doclist, 'other_charges')
|
||||||
self.doc.clear_table(self.doclist, 'sales_order_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'sales_order_details')
|
||||||
self.doc.clear_table(self.doclist, 'sales_team')
|
self.doclist = self.doc.clear_table(self.doclist, 'sales_team')
|
||||||
self.doc.clear_table(self.doclist, 'tc_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'tc_details')
|
||||||
if self.doc.quotation_no:
|
if self.doc.quotation_no:
|
||||||
get_obj('DocType Mapper', 'Quotation-Sales Order').dt_map('Quotation', 'Sales Order', self.doc.quotation_no, self.doc, self.doclist, "[['Quotation', 'Sales Order'],['Quotation Item', 'Sales Order Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team'],['TC Detail','TC Detail']]")
|
get_obj('DocType Mapper', 'Quotation-Sales Order').dt_map('Quotation', 'Sales Order', self.doc.quotation_no, self.doc, self.doclist, "[['Quotation', 'Sales Order'],['Quotation Item', 'Sales Order Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team'],['TC Detail','TC Detail']]")
|
||||||
else:
|
else:
|
||||||
@@ -116,13 +117,7 @@ class DocType(TransactionBase):
|
|||||||
# Get projected qty of item based on warehouse selected
|
# Get projected qty of item based on warehouse selected
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
def get_available_qty(self,args):
|
def get_available_qty(self,args):
|
||||||
args = eval(args)
|
return get_obj('Sales Common').get_available_qty(eval(args))
|
||||||
tot_avail_qty = sql("select projected_qty, actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1)
|
|
||||||
ret = {
|
|
||||||
'projected_qty' : tot_avail_qty and flt(tot_avail_qty[0]['projected_qty']) or 0,
|
|
||||||
'actual_qty' : tot_avail_qty and flt(tot_avail_qty[0]['actual_qty']) or 0
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
|
|
||||||
# OTHER CHARGES TRIGGER FUNCTIONS
|
# OTHER CHARGES TRIGGER FUNCTIONS
|
||||||
# ====================================================================================
|
# ====================================================================================
|
||||||
@@ -135,12 +130,12 @@ class DocType(TransactionBase):
|
|||||||
# Load Default Charges
|
# Load Default Charges
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
def load_default_taxes(self):
|
def load_default_taxes(self):
|
||||||
return get_obj('Sales Common').load_default_taxes(self)
|
self.doclist = get_obj('Sales Common').load_default_taxes(self)
|
||||||
|
|
||||||
# Pull details from other charges master (Get Sales Taxes and Charges Master)
|
# Pull details from other charges master (Get Sales Taxes and Charges Master)
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
def get_other_charges(self):
|
def get_other_charges(self):
|
||||||
return get_obj('Sales Common').get_other_charges(self)
|
self.doclist = get_obj('Sales Common').get_other_charges(self)
|
||||||
|
|
||||||
|
|
||||||
# GET TERMS & CONDITIONS
|
# GET TERMS & CONDITIONS
|
||||||
@@ -322,7 +317,7 @@ class DocType(TransactionBase):
|
|||||||
# this is to verify that the allocated % of sales persons is 100%
|
# this is to verify that the allocated % of sales persons is 100%
|
||||||
sales_com_obj.get_allocated_sum(self)
|
sales_com_obj.get_allocated_sum(self)
|
||||||
sales_com_obj.make_packing_list(self,'sales_order_details')
|
sales_com_obj.make_packing_list(self,'sales_order_details')
|
||||||
|
|
||||||
# get total in words
|
# get total in words
|
||||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||||
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
|
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
|
||||||
@@ -457,12 +452,15 @@ class DocType(TransactionBase):
|
|||||||
# ===============================================================================================
|
# ===============================================================================================
|
||||||
def update_stock_ledger(self, update_stock, clear = 0):
|
def update_stock_ledger(self, update_stock, clear = 0):
|
||||||
for d in self.get_item_list(clear):
|
for d in self.get_item_list(clear):
|
||||||
stock_item = sql("SELECT is_stock_item FROM tabItem where name = '%s'"%(d[1]),as_dict = 1) # stock ledger will be updated only if it is a stock item
|
stock_item = sql("SELECT is_stock_item FROM tabItem where name = '%s'"%(d['item_code']),as_dict = 1)
|
||||||
|
# stock ledger will be updated only if it is a stock item
|
||||||
if stock_item and stock_item[0]['is_stock_item'] == "Yes":
|
if stock_item and stock_item[0]['is_stock_item'] == "Yes":
|
||||||
if not d[0]:
|
if not d['reserved_warehouse']:
|
||||||
msgprint("Message: Please enter Reserved Warehouse for item %s as it is stock item."% d[1])
|
msgprint("Message: Please enter Reserved Warehouse for item %s as it is stock item."% d['item_code'])
|
||||||
raise Exception
|
raise Exception
|
||||||
bin = get_obj('Warehouse', d[0]).update_bin( 0, flt(update_stock) * flt(d[2]), 0, 0, 0, d[1], self.doc.transaction_date,doc_type=self.doc.doctype,doc_name=self.doc.name, is_amended = (self.doc.amended_from and 'Yes' or 'No'))
|
bin = get_obj('Warehouse', d['reserved_warehouse']).update_bin( 0, flt(update_stock) * flt(d['qty']), \
|
||||||
|
0, 0, 0, d['item_code'], self.doc.transaction_date,doc_type=self.doc.doctype,\
|
||||||
|
doc_name=self.doc.name, is_amended = (self.doc.amended_from and 'Yes' or 'No'))
|
||||||
|
|
||||||
# Gets Items from packing list
|
# Gets Items from packing list
|
||||||
#=================================
|
#=================================
|
||||||
|
|||||||
@@ -20,6 +20,12 @@
|
|||||||
<br>
|
<br>
|
||||||
<h4><a href="#!List/Item">Item</a></h4>
|
<h4><a href="#!List/Item">Item</a></h4>
|
||||||
<p class="help">Item Master</p>
|
<p class="help">Item Master</p>
|
||||||
|
<br>
|
||||||
|
<h4><a href="#!List/Contact">Contact</a></h4>
|
||||||
|
<p class="help">Contact Master</p>
|
||||||
|
<br>
|
||||||
|
<h4><a href="#!List/Address">Address</a></h4>
|
||||||
|
<p class="help">Address Master</p>
|
||||||
</div>
|
</div>
|
||||||
<div style="clear: both"></div>
|
<div style="clear: both"></div>
|
||||||
<hr>
|
<hr>
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ cur_frm.cscript.make_history_list = function(parent,doc){
|
|||||||
// get sates on country trigger
|
// get sates on country trigger
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
cur_frm.cscript.get_states=function(doc,dt,dn){
|
cur_frm.cscript.get_states=function(doc,dt,dn){
|
||||||
$c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])},
|
$c('runserverobj', args={'method':'check_state', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
|
||||||
function(r,rt){
|
function(r,rt){
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
set_field_options('state', r.message);
|
set_field_options('state', r.message);
|
||||||
@@ -77,3 +77,140 @@ if(cur_frm.fields_dict['territory']){
|
|||||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.render_contact_row = function(wrapper, data) {
|
||||||
|
// prepare data
|
||||||
|
data.fullname = (data.first_name || '')
|
||||||
|
+ (data.last_name ? ' ' + data.last_name : '');
|
||||||
|
data.primary = data.is_primary_contact ? ' [Primary]' : '';
|
||||||
|
|
||||||
|
// prepare description
|
||||||
|
var description = [];
|
||||||
|
$.each([
|
||||||
|
['phone', 'Tel'],
|
||||||
|
['mobile_no', 'Mobile'],
|
||||||
|
['email_id', 'Email'],
|
||||||
|
['department', 'Department'],
|
||||||
|
['designation', 'Designation']],
|
||||||
|
function(i, v) {
|
||||||
|
if(v[0] && data[v[0]]) {
|
||||||
|
description.push(repl('<h6>%(label)s:</h6> %(value)s', {
|
||||||
|
label: v[1],
|
||||||
|
value: data[v[0]],
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
data.description = description.join('<br />');
|
||||||
|
|
||||||
|
cur_frm.cscript.render_row_in_wrapper(wrapper, data, 'Contact');
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.render_address_row = function(wrapper, data) {
|
||||||
|
// prepare data
|
||||||
|
data.fullname = data.address_type;
|
||||||
|
data.primary = '';
|
||||||
|
if (data.is_primary_address) data.primary += ' [Primary]';
|
||||||
|
if (data.is_shipping_address) data.primary += ' [Shipping]';
|
||||||
|
|
||||||
|
// prepare address
|
||||||
|
var address = [];
|
||||||
|
$.each(['address_line1', 'address_line2', 'city', 'state', 'country', 'pincode'],
|
||||||
|
function(i, v) {
|
||||||
|
if(data[v]) address.push(data[v]);
|
||||||
|
});
|
||||||
|
|
||||||
|
data.address = address.join('<br />');
|
||||||
|
data.address = "<p class='address-list'>" + data.address + "</p>";
|
||||||
|
|
||||||
|
// prepare description
|
||||||
|
var description = [];
|
||||||
|
$.each([
|
||||||
|
['address', 'Address'],
|
||||||
|
['phone', 'Tel'],
|
||||||
|
['fax', 'Fax'],
|
||||||
|
['email_id', 'Email']],
|
||||||
|
function(i, v) {
|
||||||
|
if(data[v[0]]) {
|
||||||
|
description.push(repl('<h6>%(label)s:</h6> %(value)s', {
|
||||||
|
label: v[1],
|
||||||
|
value: data[v[0]],
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
data.description = description.join('<br />');
|
||||||
|
|
||||||
|
cur_frm.cscript.render_row_in_wrapper(wrapper, data, 'Address');
|
||||||
|
|
||||||
|
$(wrapper).find('p.address-list').css({
|
||||||
|
'padding-left': '10px',
|
||||||
|
'margin-bottom': '-10px'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.render_row_in_wrapper = function(wrapper, data, doctype) {
|
||||||
|
// render
|
||||||
|
var $wrapper = $(wrapper);
|
||||||
|
|
||||||
|
data.doctype = doctype.toLowerCase();
|
||||||
|
|
||||||
|
$wrapper.append(repl("\
|
||||||
|
<h4><a class='link_type'>%(fullname)s</a>%(primary)s</h4>\
|
||||||
|
<div class='description'>\
|
||||||
|
%(description)s\
|
||||||
|
<p><a class='delete link_type'>delete this %(doctype)s</a></p>\
|
||||||
|
</div>", data));
|
||||||
|
|
||||||
|
// make link
|
||||||
|
$wrapper.find('h4 a.link_type').click(function() {
|
||||||
|
loaddoc(doctype, data.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
// css
|
||||||
|
$wrapper.css({ 'padding': '5px 0px' });
|
||||||
|
$wrapper.find('div.description').css({
|
||||||
|
'padding': '5px 2px',
|
||||||
|
'line-height': '150%',
|
||||||
|
});
|
||||||
|
$wrapper.find('h6').css({ 'display': 'inline-block' });
|
||||||
|
|
||||||
|
// show delete
|
||||||
|
var $delete_doc = $wrapper.find('a.delete');
|
||||||
|
if (wn.model.can_delete(doctype)) {
|
||||||
|
$delete_doc.toggle(true);
|
||||||
|
} else {
|
||||||
|
$delete_doc.toggle(false);
|
||||||
|
}
|
||||||
|
$delete_doc.css({
|
||||||
|
'padding-left': '0px'
|
||||||
|
});
|
||||||
|
|
||||||
|
$delete_doc.click(function() {
|
||||||
|
cur_frm.cscript.delete_doc(doctype, data.name);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.delete_doc = function(doctype, name) {
|
||||||
|
// confirm deletion
|
||||||
|
var go_ahead = confirm(repl('Delete %(doctype)s "%(name)s"', {
|
||||||
|
doctype: doctype,
|
||||||
|
name: name
|
||||||
|
}));
|
||||||
|
if (!go_ahead) return;
|
||||||
|
|
||||||
|
wn.call({
|
||||||
|
method: 'webnotes.model.delete_doc',
|
||||||
|
args: {
|
||||||
|
dt: doctype,
|
||||||
|
dn: name
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
//console.log(r);
|
||||||
|
if (!r.exc) {
|
||||||
|
// run the correct list
|
||||||
|
var list_name = doctype.toLowerCase() + '_list';
|
||||||
|
cur_frm[list_name].run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn){
|
|||||||
var callback = function(r, rt){
|
var callback = function(r, rt){
|
||||||
set_field_options('select_doc_for_series', r.message);
|
set_field_options('select_doc_for_series', r.message);
|
||||||
}
|
}
|
||||||
$c_obj([doc],'get_transactions','',callback);
|
$c_obj(make_doclist(doc.doctype, doc.name),'get_transactions','',callback);
|
||||||
cur_frm.cscript.refresh();
|
cur_frm.cscript.refresh();
|
||||||
// add page head
|
// add page head
|
||||||
//var ph = new PageHeader(cur_frm.fields_dict['head_html'].wrapper, 'Setup Series', 'Set prefix for numbering series on your transactions');
|
//var ph = new PageHeader(cur_frm.fields_dict['head_html'].wrapper, 'Setup Series', 'Set prefix for numbering series on your transactions');
|
||||||
@@ -36,5 +36,5 @@ cur_frm.cscript.select_doc_for_series = function(doc, cdt, cdn) {
|
|||||||
refresh_field('set_options');
|
refresh_field('set_options');
|
||||||
}
|
}
|
||||||
|
|
||||||
$c_obj([doc],'get_options','',callback)
|
$c_obj(make_doclist(doc.doctype, doc.name),'get_options','',callback)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,10 +43,11 @@ class DocType:
|
|||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
def get_doctype_list(self):
|
def get_doctype_list(self):
|
||||||
ret = sql("""SELECT `name` FROM tabDocType
|
ret = sql("""SELECT `name` FROM tabDocType
|
||||||
WHERE ifnull(docstatus,0)=0
|
WHERE ifnull(docstatus,0)=0
|
||||||
AND ifnull(istable,0)=0
|
AND ifnull(istable,0)=0
|
||||||
AND ifnull(issingle,0)=0
|
AND ifnull(issingle,0)=0
|
||||||
AND `module` NOT IN ('System','Utilities','Setup Masters','Roles','Recycle Bin','Mapper','Application Internal','Development', 'Core')
|
AND (`module` NOT IN ('System','Utilities','Setup Masters','Roles','Recycle Bin','Mapper','Application Internal','Development', 'Core')
|
||||||
|
OR name IN ('Contact', 'Address'))
|
||||||
ORDER BY `name` ASC""")
|
ORDER BY `name` ASC""")
|
||||||
|
|
||||||
rl = [''] + [a[0] for a in sql("select name from tabRole where ifnull(docstatus,0)=0")]
|
rl = [''] + [a[0] for a in sql("select name from tabRole where ifnull(docstatus,0)=0")]
|
||||||
|
|||||||
@@ -32,6 +32,6 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
|
|
||||||
cur_frm.cscript.clear_prices = function(doc, cdt, cdn) {
|
cur_frm.cscript.clear_prices = function(doc, cdt, cdn) {
|
||||||
if(confirm("This action will clear all rates for '"+ doc.name +"' from the Item Master and cannot be un-done. Are you sure you want to continue?")) {
|
if(confirm("This action will clear all rates for '"+ doc.name +"' from the Item Master and cannot be un-done. Are you sure you want to continue?")) {
|
||||||
$c_obj([doc], 'clear_prices', '', function(r, rt) { });
|
$c_obj(make_doclist(doc.doctype, doc.name), 'clear_prices', '', function(r, rt) { });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class DocType:
|
|||||||
updated = 0
|
updated = 0
|
||||||
|
|
||||||
for line in data:
|
for line in data:
|
||||||
if len(line)==3:
|
if line and len(line)==3:
|
||||||
# if item exists
|
# if item exists
|
||||||
if sql("select name from tabItem where name=%s", line[0]):
|
if sql("select name from tabItem where name=%s", line[0]):
|
||||||
if self.is_currency_valid(line[2]):
|
if self.is_currency_valid(line[2]):
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
'creation': '2012-03-27 14:36:22',
|
'creation': '2012-05-15 12:15:02',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-03-27 14:36:22',
|
'modified': '2012-06-22 10:51:23',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'Administrator'
|
'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
@@ -19,12 +19,13 @@
|
|||||||
'colour': u'White:FFF',
|
'colour': u'White:FFF',
|
||||||
'doctype': 'DocType',
|
'doctype': 'DocType',
|
||||||
'document_type': u'Master',
|
'document_type': u'Master',
|
||||||
|
'max_attachments': 1,
|
||||||
'module': u'Setup',
|
'module': u'Setup',
|
||||||
'name': '__common__',
|
'name': '__common__',
|
||||||
'section_style': u'Simple',
|
'section_style': u'Simple',
|
||||||
'server_code_error': u' ',
|
'server_code_error': u' ',
|
||||||
'show_in_menu': 0,
|
'show_in_menu': 0,
|
||||||
'version': 6
|
'version': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# These values are common for all DocField
|
# These values are common for all DocField
|
||||||
@@ -54,6 +55,46 @@
|
|||||||
'name': u'Price List'
|
'name': u'Price List'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 0,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 1,
|
||||||
|
'role': u'Sales Manager',
|
||||||
|
'write': 0
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 0,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Sales Manager',
|
||||||
|
'write': 0
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 0,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 1,
|
||||||
|
'role': u'Sales User',
|
||||||
|
'write': 0
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 0,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Sales User',
|
||||||
|
'write': 0
|
||||||
|
},
|
||||||
|
|
||||||
# DocPerm
|
# DocPerm
|
||||||
{
|
{
|
||||||
'cancel': 1,
|
'cancel': 1,
|
||||||
@@ -64,46 +105,6 @@
|
|||||||
'write': 1
|
'write': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'cancel': 0,
|
|
||||||
'create': 0,
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'permlevel': 1,
|
|
||||||
'role': u'Sales Manager',
|
|
||||||
'write': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'cancel': 0,
|
|
||||||
'create': 0,
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'permlevel': 0,
|
|
||||||
'role': u'Sales Manager',
|
|
||||||
'write': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'cancel': 0,
|
|
||||||
'create': 0,
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'permlevel': 1,
|
|
||||||
'role': u'Sales User',
|
|
||||||
'write': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'cancel': 0,
|
|
||||||
'create': 0,
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'permlevel': 0,
|
|
||||||
'role': u'Sales User',
|
|
||||||
'write': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ cur_frm.cscript.onload = function(){
|
|||||||
}
|
}
|
||||||
cur_frm.cscript.country = function(doc, cdt, cdn) {
|
cur_frm.cscript.country = function(doc, cdt, cdn) {
|
||||||
var mydoc=doc;
|
var mydoc=doc;
|
||||||
$c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])},
|
$c('runserverobj', args={'method':'check_state', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
|
||||||
function(r,rt){
|
function(r,rt){
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
var doc = locals[mydoc.doctype][mydoc.name];
|
var doc = locals[mydoc.doctype][mydoc.name];
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ class DocType:
|
|||||||
self.set_cp_defaults(**cp_args)
|
self.set_cp_defaults(**cp_args)
|
||||||
|
|
||||||
self.create_feed_and_todo()
|
self.create_feed_and_todo()
|
||||||
|
|
||||||
|
self.create_email_digest()
|
||||||
|
|
||||||
webnotes.clear_cache()
|
webnotes.clear_cache()
|
||||||
msgprint("Company setup is complete")
|
msgprint("Company setup is complete")
|
||||||
@@ -127,6 +129,44 @@ class DocType:
|
|||||||
d.reference_type = 'Supplier'
|
d.reference_type = 'Supplier'
|
||||||
d.save(1)
|
d.save(1)
|
||||||
|
|
||||||
|
def create_email_digest(self):
|
||||||
|
"""
|
||||||
|
create a default weekly email digest
|
||||||
|
* Weekly Digest
|
||||||
|
* For all companies
|
||||||
|
* Recipients: System Managers
|
||||||
|
* Full content
|
||||||
|
* Enabled by default
|
||||||
|
"""
|
||||||
|
import webnotes
|
||||||
|
companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1)
|
||||||
|
|
||||||
|
import webnotes.utils
|
||||||
|
system_managers = webnotes.utils.get_system_managers_list()
|
||||||
|
if not system_managers: return
|
||||||
|
|
||||||
|
from webnotes.model.doc import Document
|
||||||
|
for company in companies_list:
|
||||||
|
if company and company[0]:
|
||||||
|
edigest = Document('Email Digest')
|
||||||
|
edigest.name = "Default Weekly Digest - " + company[0]
|
||||||
|
edigest.company = company[0]
|
||||||
|
edigest.frequency = 'Weekly'
|
||||||
|
edigest.recipient_list = "\n".join(system_managers)
|
||||||
|
for f in ['new_leads', 'new_enquiries', 'new_quotations',
|
||||||
|
'new_sales_orders', 'new_purchase_orders',
|
||||||
|
'new_transactions', 'payables', 'payments',
|
||||||
|
'expenses_booked', 'invoiced_amount', 'collections',
|
||||||
|
'income', 'bank_balance', 'stock_below_rl',
|
||||||
|
'income_year_to_date', 'enabled']:
|
||||||
|
edigest.fields[f] = 1
|
||||||
|
exists = webnotes.conn.sql("""\
|
||||||
|
SELECT name FROM `tabEmail Digest`
|
||||||
|
WHERE name = %s""", edigest.name)
|
||||||
|
if (exists and exists[0]) and exists[0][0]:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
edigest.save(1)
|
||||||
|
|
||||||
# Get Fiscal year Details
|
# Get Fiscal year Details
|
||||||
# ------------------------
|
# ------------------------
|
||||||
|
|||||||
@@ -160,13 +160,9 @@ cur_frm.fields_dict['sales_order_no'].get_query = function(doc) {
|
|||||||
var cond = '';
|
var cond = '';
|
||||||
|
|
||||||
if(doc.customer) {
|
if(doc.customer) {
|
||||||
if(doc.currency) cond = '`tabSales Order`.customer = "'+doc.customer+'" and `tabSales Order`.currency = "'+doc.currency+'" and';
|
cond = '`tabSales Order`.customer = "'+doc.customer+'" and';
|
||||||
else cond = '`tabSales Order`.customer = "'+doc.customer+'" and';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(doc.currency) cond = '`tabSales Order`.currency = "'+doc.currency+'" and';
|
|
||||||
else cond = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.project_name){
|
if(doc.project_name){
|
||||||
cond += '`tabSales Order`.project_name ="'+doc.project_name+'"';
|
cond += '`tabSales Order`.project_name ="'+doc.project_name+'"';
|
||||||
}
|
}
|
||||||
@@ -179,7 +175,7 @@ cur_frm.cscript.delivery_type = function(doc, cdt, cdn) {
|
|||||||
if (doc.delivery_type = 'Sample') cfn_set_fields(doc, cdt, cdn);
|
if (doc.delivery_type = 'Sample') cfn_set_fields(doc, cdt, cdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.serial_no = function(doc, cdt , cdn) {
|
cur_frm.cscript.serial_no = function(doc, cdt, cdn) {
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
if (d.serial_no) {
|
if (d.serial_no) {
|
||||||
get_server_fields('get_serial_details',d.serial_no,'delivery_note_details',doc,cdt,cdn,1);
|
get_server_fields('get_serial_details',d.serial_no,'delivery_note_details',doc,cdt,cdn,1);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class DocType(TransactionBase):
|
|||||||
# *************** Pull Sales Order Items ************************
|
# *************** Pull Sales Order Items ************************
|
||||||
def pull_sales_order_details(self):
|
def pull_sales_order_details(self):
|
||||||
self.validate_prev_docname()
|
self.validate_prev_docname()
|
||||||
self.doc.clear_table(self.doclist,'other_charges')
|
self.doclist = self.doc.clear_table(self.doclist,'other_charges')
|
||||||
|
|
||||||
if self.doc.sales_order_no:
|
if self.doc.sales_order_no:
|
||||||
get_obj('DocType Mapper', 'Sales Order-Delivery Note').dt_map('Sales Order', 'Delivery Note', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Delivery Note'],['Sales Order Item', 'Delivery Note Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]")
|
get_obj('DocType Mapper', 'Sales Order-Delivery Note').dt_map('Sales Order', 'Delivery Note', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Delivery Note'],['Sales Order Item', 'Delivery Note Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]")
|
||||||
@@ -133,12 +133,7 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
# ********** Get Actual Qty of item in warehouse selected *************
|
# ********** Get Actual Qty of item in warehouse selected *************
|
||||||
def get_actual_qty(self,args):
|
def get_actual_qty(self,args):
|
||||||
args = eval(args)
|
return get_obj('Sales Common').get_available_qty(eval(args))
|
||||||
actual_qty = sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1)
|
|
||||||
ret = {
|
|
||||||
'actual_qty' : actual_qty and flt(actual_qty[0]['actual_qty']) or 0
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
|
|
||||||
|
|
||||||
# OTHER CHARGES TRIGGER FUNCTIONS
|
# OTHER CHARGES TRIGGER FUNCTIONS
|
||||||
@@ -151,12 +146,12 @@ class DocType(TransactionBase):
|
|||||||
# Load Default Charges
|
# Load Default Charges
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
def load_default_taxes(self):
|
def load_default_taxes(self):
|
||||||
return get_obj('Sales Common').load_default_taxes(self)
|
self.doclist = get_obj('Sales Common').load_default_taxes(self)
|
||||||
|
|
||||||
|
|
||||||
# **** Pull details from other charges master (Get Sales Taxes and Charges Master) ****
|
# **** Pull details from other charges master (Get Sales Taxes and Charges Master) ****
|
||||||
def get_other_charges(self):
|
def get_other_charges(self):
|
||||||
return get_obj('Sales Common').get_other_charges(self)
|
self.doclist = get_obj('Sales Common').get_other_charges(self)
|
||||||
|
|
||||||
|
|
||||||
#check in manage account if sales order required or not.
|
#check in manage account if sales order required or not.
|
||||||
@@ -297,13 +292,13 @@ class DocType(TransactionBase):
|
|||||||
# check if same item, warehouse present in prevdoc
|
# check if same item, warehouse present in prevdoc
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
def validate_items_with_prevdoc(self, d):
|
def validate_items_with_prevdoc(self, d):
|
||||||
if d.prevdoc_doctype == 'Sales Order':
|
prev_item_dt = (d.prevdoc_doctype == 'Sales Order') and 'Sales Order Item' or 'Purchase Receipt Item'
|
||||||
data = sql("select item_code, reserved_warehouse from `tabSales Order Item` where parent = '%s' and name = '%s'" % (d.prevdoc_docname, d.prevdoc_detail_docname))
|
data = sql("select item_code from `tab%s` where parent = '%s' and name = '%s'"\
|
||||||
if d.prevdoc_doctype == 'Purchase Receipt':
|
% (prev_item_dt, d.prevdoc_docname, d.prevdoc_detail_docname))
|
||||||
data = sql("select item_code, rejected_warehouse from `tabPurchase Receipt Item` where parent = '%s' and name = '%s'" % (d.prevdoc_docname, d.prevdoc_detail_docname))
|
if not data or data[0][0] != d.item_code:
|
||||||
if not data or data[0][0] != d.item_code or data[0][1] != d.warehouse:
|
msgprint("Item: %s is not matching with Sales Order: %s. Sales Order might be modified after \
|
||||||
msgprint("Item: %s / Warehouse: %s is not matching with Sales Order: %s. Sales Order might be modified after fetching data from it. Please delete items and fetch again." % (d.item_code, d.warehouse, d.prevdoc_docname))
|
fetching data from it. Please delete items and fetch again." \
|
||||||
raise Exception
|
% (d.item_code, d.prevdoc_docname), raise_exception=1)
|
||||||
|
|
||||||
|
|
||||||
# ********* UPDATE CURRENT STOCK *****************************
|
# ********* UPDATE CURRENT STOCK *****************************
|
||||||
@@ -413,16 +408,19 @@ class DocType(TransactionBase):
|
|||||||
def update_stock_ledger(self, update_stock, is_stopped = 0):
|
def update_stock_ledger(self, update_stock, is_stopped = 0):
|
||||||
self.values = []
|
self.values = []
|
||||||
for d in self.get_item_list(is_stopped):
|
for d in self.get_item_list(is_stopped):
|
||||||
stock_item = sql("SELECT is_stock_item, is_sample_item FROM tabItem where name = '%s'"%(d[1]), as_dict = 1) # stock ledger will be updated only if it is a stock item
|
stock_item = sql("SELECT is_stock_item, is_sample_item FROM tabItem where name = '%s'"%(d['item_code']), as_dict = 1) # stock ledger will be updated only if it is a stock item
|
||||||
if stock_item[0]['is_stock_item'] == "Yes":
|
if stock_item[0]['is_stock_item'] == "Yes":
|
||||||
if not d[0]:
|
if not d['warehouse']:
|
||||||
msgprint("Message: Please enter Warehouse for item %s as it is stock item."% d[1])
|
msgprint("Message: Please enter Warehouse for item %s as it is stock item."% d['item_code'])
|
||||||
raise Exception
|
raise Exception
|
||||||
if d[3] < 0 :
|
if d['reserved_qty'] < 0 :
|
||||||
# Reduce Reserved Qty from warehouse
|
# Reduce reserved qty from reserved warehouse mentioned in so
|
||||||
bin = get_obj('Warehouse', d[0]).update_bin(0, flt(update_stock) * flt(d[3]), 0, 0, 0, d[1], self.doc.transaction_date,doc_type=self.doc.doctype,doc_name=self.doc.name, is_amended = (self.doc.amended_from and 'Yes' or 'No'))
|
bin = get_obj('Warehouse', d['reserved_warehouse']).update_bin(0, flt(update_stock) * flt(d['reserved_qty']), \
|
||||||
|
0, 0, 0, d['item_code'], self.doc.transaction_date,doc_type=self.doc.doctype, \
|
||||||
|
doc_name=self.doc.name, is_amended = (self.doc.amended_from and 'Yes' or 'No'))
|
||||||
|
|
||||||
# Reduce actual qty from warehouse
|
# Reduce actual qty from warehouse
|
||||||
self.make_sl_entry(d, d[0], - flt(d[2]) , 0, update_stock)
|
self.make_sl_entry(d, d['warehouse'], - flt(d['qty']) , 0, update_stock)
|
||||||
get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values)
|
get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values)
|
||||||
|
|
||||||
|
|
||||||
@@ -434,22 +432,22 @@ class DocType(TransactionBase):
|
|||||||
# ********************** Make Stock Entry ************************************
|
# ********************** Make Stock Entry ************************************
|
||||||
def make_sl_entry(self, d, wh, qty, in_value, update_stock):
|
def make_sl_entry(self, d, wh, qty, in_value, update_stock):
|
||||||
self.values.append({
|
self.values.append({
|
||||||
'item_code' : d[1],
|
'item_code' : d['item_code'],
|
||||||
'warehouse' : wh,
|
'warehouse' : wh,
|
||||||
'transaction_date' : getdate(self.doc.modified).strftime('%Y-%m-%d'),
|
'transaction_date' : getdate(self.doc.modified).strftime('%Y-%m-%d'),
|
||||||
'posting_date' : self.doc.posting_date,
|
'posting_date' : self.doc.posting_date,
|
||||||
'posting_time' : self.doc.posting_time,
|
'posting_time' : self.doc.posting_time,
|
||||||
'voucher_type' : 'Delivery Note',
|
'voucher_type' : 'Delivery Note',
|
||||||
'voucher_no' : self.doc.name,
|
'voucher_no' : self.doc.name,
|
||||||
'voucher_detail_no' : '',
|
'voucher_detail_no' : '',
|
||||||
'actual_qty' : qty,
|
'actual_qty' : qty,
|
||||||
'stock_uom' : d[4],
|
'stock_uom' : d['uom'],
|
||||||
'incoming_rate' : in_value,
|
'incoming_rate' : in_value,
|
||||||
'company' : self.doc.company,
|
'company' : self.doc.company,
|
||||||
'fiscal_year' : self.doc.fiscal_year,
|
'fiscal_year' : self.doc.fiscal_year,
|
||||||
'is_cancelled' : (update_stock==1) and 'No' or 'Yes',
|
'is_cancelled' : (update_stock==1) and 'No' or 'Yes',
|
||||||
'batch_no' : d[5],
|
'batch_no' : d['batch_no'],
|
||||||
'serial_no' : d[6]
|
'serial_no' : d['serial_no']
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class DocType:
|
|||||||
def get_purchase_receipts(self):
|
def get_purchase_receipts(self):
|
||||||
""" Get purchase receipts for given period """
|
""" Get purchase receipts for given period """
|
||||||
|
|
||||||
self.doc.clear_table(self.doclist,'lc_pr_details',1)
|
self.doclist = self.doc.clear_table(self.doclist,'lc_pr_details',1)
|
||||||
self.check_mandatory()
|
self.check_mandatory()
|
||||||
|
|
||||||
pr = sql("select name from `tabPurchase Receipt` where docstatus = 1 and posting_date >= '%s' and posting_date <= '%s' and currency = '%s' order by name " % (self.doc.from_pr_date, self.doc.to_pr_date, self.doc.currency), as_dict = 1)
|
pr = sql("select name from `tabPurchase Receipt` where docstatus = 1 and posting_date >= '%s' and posting_date <= '%s' and currency = '%s' order by name " % (self.doc.from_pr_date, self.doc.to_pr_date, self.doc.currency), as_dict = 1)
|
||||||
@@ -58,7 +58,7 @@ class DocType:
|
|||||||
|
|
||||||
def get_landed_cost_master_details(self):
|
def get_landed_cost_master_details(self):
|
||||||
""" pull details from landed cost master"""
|
""" pull details from landed cost master"""
|
||||||
self.doc.clear_table(self.doclist, 'landed_cost_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'landed_cost_details')
|
||||||
idx = 0
|
idx = 0
|
||||||
landed_cost = sql("select account_head, description from `tabLanded Cost Master Detail` where parent=%s", (self.doc.landed_cost), as_dict = 1)
|
landed_cost = sql("select account_head, description from `tabLanded Cost Master Detail` where parent=%s", (self.doc.landed_cost), as_dict = 1)
|
||||||
for cost in landed_cost:
|
for cost in landed_cost:
|
||||||
|
|||||||
@@ -52,6 +52,14 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||||
|
if(!doc.amended_from) {
|
||||||
|
hide_field('misc_details');
|
||||||
|
} else {
|
||||||
|
unhide_field('misc_details');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.update_item_details = function(doc) {
|
cur_frm.cscript.update_item_details = function(doc) {
|
||||||
$c_obj(make_doclist(doc.doctype, doc.name), 'update_item_details', '', function(r, rt) {
|
$c_obj(make_doclist(doc.doctype, doc.name), 'update_item_details', '', function(r, rt) {
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
'creation': '2012-03-27 14:36:34',
|
'creation': '2012-05-15 12:15:08',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-03-27 14:45:49',
|
'modified': '2012-06-29 12:24:16',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'Administrator'
|
'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
'_last_update': u'1328091392',
|
'_last_update': u'1328091392',
|
||||||
'autoname': u'PS.#######',
|
'autoname': u'PS.#######',
|
||||||
'colour': u'White:FFF',
|
'colour': u'White:FFF',
|
||||||
|
'description': u'Generate packing slips for packages to be delivered. Used to notify package number, package contents and its weight.',
|
||||||
'doctype': 'DocType',
|
'doctype': 'DocType',
|
||||||
'document_type': u'Transaction',
|
'document_type': u'Transaction',
|
||||||
'is_submittable': 1,
|
'is_submittable': 1,
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
'section_style': u'Simple',
|
'section_style': u'Simple',
|
||||||
'show_in_menu': 0,
|
'show_in_menu': 0,
|
||||||
'subject': u'[%(delivery_note)s] Case Nos: %(from_case_no)s - %(to_case_no)s | Net Weight: %(net_weight_pkg)s %(net_weight_uom)s | Gross Weight: %(gross_weight_pkg)s %(gross_weight_uom)s',
|
'subject': u'[%(delivery_note)s] Case Nos: %(from_case_no)s - %(to_case_no)s | Net Weight: %(net_weight_pkg)s %(net_weight_uom)s | Gross Weight: %(gross_weight_pkg)s %(gross_weight_uom)s',
|
||||||
'version': 40
|
'version': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# These values are common for all DocField
|
# These values are common for all DocField
|
||||||
@@ -140,6 +141,8 @@
|
|||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
|
'colour': u'White:FFF',
|
||||||
|
'description': u'Indicates that the package is a part of this delivery',
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'delivery_note',
|
'fieldname': u'delivery_note',
|
||||||
'fieldtype': u'Link',
|
'fieldtype': u'Link',
|
||||||
@@ -190,10 +193,11 @@
|
|||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'colour': u'White:FFF',
|
'colour': u'White:FFF',
|
||||||
|
'description': u'Identification of the package for the delivery (for print)',
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'from_case_no',
|
'fieldname': u'from_case_no',
|
||||||
'fieldtype': u'Data',
|
'fieldtype': u'Data',
|
||||||
'label': u'From Case No.',
|
'label': u'From Package No.',
|
||||||
'no_copy': 1,
|
'no_copy': 1,
|
||||||
'permlevel': 0,
|
'permlevel': 0,
|
||||||
'reqd': 1,
|
'reqd': 1,
|
||||||
@@ -211,10 +215,11 @@
|
|||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'colour': u'White:FFF',
|
'colour': u'White:FFF',
|
||||||
|
'description': u'If more than one package of the same type (for print)',
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'to_case_no',
|
'fieldname': u'to_case_no',
|
||||||
'fieldtype': u'Data',
|
'fieldtype': u'Data',
|
||||||
'label': u'To Case No.',
|
'label': u'To Package No.',
|
||||||
'no_copy': 1,
|
'no_copy': 1,
|
||||||
'permlevel': 0,
|
'permlevel': 0,
|
||||||
'width': u'50px'
|
'width': u'50px'
|
||||||
@@ -251,6 +256,7 @@
|
|||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'colour': u'White:FFF',
|
'colour': u'White:FFF',
|
||||||
|
'description': u'The net weight of this package. (calculated automatically as sum of net weight of items)',
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'net_weight_pkg',
|
'fieldname': u'net_weight_pkg',
|
||||||
'fieldtype': u'Currency',
|
'fieldtype': u'Currency',
|
||||||
@@ -281,6 +287,7 @@
|
|||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'colour': u'White:FFF',
|
'colour': u'White:FFF',
|
||||||
|
'description': u'The gross weight of the package. Usually net weight + packaging material weight. (for print)',
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'gross_weight_pkg',
|
'fieldname': u'gross_weight_pkg',
|
||||||
'fieldtype': u'Currency',
|
'fieldtype': u'Currency',
|
||||||
@@ -303,7 +310,7 @@
|
|||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'depends_on': u'eval:doc.amended_from',
|
'colour': u'White:FFF',
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'misc_details',
|
'fieldname': u'misc_details',
|
||||||
'fieldtype': u'Section Break',
|
'fieldtype': u'Section Break',
|
||||||
|
|||||||
@@ -4,16 +4,27 @@ wn.doclistviews['Purchase Receipt'] = wn.views.ListView.extend({
|
|||||||
this._super(d);
|
this._super(d);
|
||||||
this.fields = this.fields.concat([
|
this.fields = this.fields.concat([
|
||||||
"`tabPurchase Receipt`.supplier_name",
|
"`tabPurchase Receipt`.supplier_name",
|
||||||
"`tabPurchase Receipt`.purchase_order_no"
|
"group_concat(`tabPurchase Receipt Item`.prevdoc_docname) as purchase_order_no",
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
prepare_data: function(data) {
|
||||||
|
this._super(data);
|
||||||
|
if(data.purchase_order_no) {
|
||||||
|
data.purchase_order_no = data.purchase_order_no.split(",");
|
||||||
|
var po_list = [];
|
||||||
|
$.each(data.purchase_order_no, function(i, v){
|
||||||
|
if(po_list.indexOf(v)==-1) po_list.push(v);
|
||||||
|
});
|
||||||
|
data.purchase_order_no = po_list.join(", ");
|
||||||
|
}
|
||||||
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{width: '3%', content: 'check'},
|
{width: '3%', content: 'check'},
|
||||||
{width: '5%', content:'avatar'},
|
{width: '5%', content:'avatar'},
|
||||||
{width: '3%', content:'docstatus'},
|
{width: '3%', content:'docstatus'},
|
||||||
{width: '15%', content:'name'},
|
{width: '15%', content:'name'},
|
||||||
{width: '47%', content:'supplier_name+tags', css: {color:'#222'}},
|
{width: '32%', content:'supplier_name+tags', css: {color:'#222'}},
|
||||||
{width: '15%', content:'purchase_order_no', type:'link', doctype:'Purchase Order Order'},
|
{width: '30%', content:'purchase_order_no'},
|
||||||
{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
|
{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ class DocType(TransactionBase):
|
|||||||
raise Exception
|
raise Exception
|
||||||
self.add_bom(d)
|
self.add_bom(d)
|
||||||
else:
|
else:
|
||||||
self.doc.clear_table(self.doclist,'pr_raw_material_details',1)
|
self.doclist = self.doc.clear_table(self.doclist,'pr_raw_material_details',1)
|
||||||
self.doc.save()
|
self.doc.save()
|
||||||
elif item_det[0][1] == 'No':
|
elif item_det[0][1] == 'No':
|
||||||
if not self.doc.supplier_warehouse:
|
if not self.doc.supplier_warehouse:
|
||||||
@@ -479,4 +479,4 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
# **** Pull details from other charges master (Get Other Charges) ****
|
# **** Pull details from other charges master (Get Other Charges) ****
|
||||||
def get_purchase_tax_details(self):
|
def get_purchase_tax_details(self):
|
||||||
return get_obj('Purchase Common').get_purchase_tax_details(self)
|
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class DocType :
|
|||||||
# Create Item Table
|
# Create Item Table
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
def create_item_table(self, det):
|
def create_item_table(self, det):
|
||||||
self.doc.clear_table(self.doclist, 'return_details', 1)
|
self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1)
|
||||||
for i in det:
|
for i in det:
|
||||||
ch = addchild(self.doc, 'return_details', 'Sales and Purchase Return Item', 1, self.doclist)
|
ch = addchild(self.doc, 'return_details', 'Sales and Purchase Return Item', 1, self.doclist)
|
||||||
ch.detail_name = i and i[0] or ''
|
ch.detail_name = i and i[0] or ''
|
||||||
@@ -73,5 +73,5 @@ class DocType :
|
|||||||
# Clear return table
|
# Clear return table
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
def clear_return_table(self):
|
def clear_return_table(self):
|
||||||
self.doc.clear_table(self.doclist, 'return_details', 1)
|
self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1)
|
||||||
self.doc.save()
|
self.doc.save()
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class DocType(TransactionBase):
|
|||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
if self.doc.status == 'Delivered':
|
if self.doc.status == 'Delivered':
|
||||||
msgprint("Cannot trash Serial No : %s as it is already Delivered" % (self.doc.name), raise_exception = 1)
|
msgprint("Cannot trash Serial No : %s as it is already Delivered" % (self.doc.name), raise_exception = 1)
|
||||||
else:
|
elif self.doc.status == 'In Store':
|
||||||
webnotes.conn.set(self.doc, 'status', 'Not in Use')
|
webnotes.conn.set(self.doc, 'status', 'Not in Use')
|
||||||
self.make_stock_ledger_entry(-1)
|
self.make_stock_ledger_entry(-1)
|
||||||
|
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ class DocType(TransactionBase):
|
|||||||
consider_sa_items_as_rm = self.doc.consider_sa_items_as_raw_materials
|
consider_sa_items_as_rm = self.doc.consider_sa_items_as_raw_materials
|
||||||
|
|
||||||
self.get_raw_materials(bom_no, fg_qty, consider_sa_items_as_rm)
|
self.get_raw_materials(bom_no, fg_qty, consider_sa_items_as_rm)
|
||||||
self.doc.clear_table(self.doclist, 'mtn_details', 1)
|
self.doclist = self.doc.clear_table(self.doclist, 'mtn_details', 1)
|
||||||
|
|
||||||
sw = (self.doc.process == 'Backflush') and cstr(pro_obj.doc.wip_warehouse) or ''
|
sw = (self.doc.process == 'Backflush') and cstr(pro_obj.doc.wip_warehouse) or ''
|
||||||
tw = (self.doc.process == 'Material Transfer') and cstr(pro_obj.doc.wip_warehouse) or ''
|
tw = (self.doc.process == 'Material Transfer') and cstr(pro_obj.doc.wip_warehouse) or ''
|
||||||
|
|||||||
@@ -60,7 +60,12 @@ class DocType:
|
|||||||
count = 1
|
count = 1
|
||||||
for s in data:
|
for s in data:
|
||||||
count += 1
|
count += 1
|
||||||
if count == 2: continue
|
if count == 2:
|
||||||
|
if s[0] != 'Item Code' or s[1] != 'Warehouse':
|
||||||
|
msgprint("First row of the attachment always should be same as template(Item Code, Warehouse, Quantity \
|
||||||
|
and Valuation Rate/Incoming Rate)", raise_exception=1)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
# validate
|
# validate
|
||||||
if (submit and len(s) != 4) or (not submit and len(s) != 6):
|
if (submit and len(s) != 4) or (not submit and len(s) != 6):
|
||||||
msgprint("Data entered at Row No " + cstr(count) + " in Attachment File is not in correct format.", raise_exception=1)
|
msgprint("Data entered at Row No " + cstr(count) + " in Attachment File is not in correct format.", raise_exception=1)
|
||||||
@@ -172,6 +177,7 @@ class DocType:
|
|||||||
Make stock entry of qty diff, calculate incoming rate to maintain valuation rate.
|
Make stock entry of qty diff, calculate incoming rate to maintain valuation rate.
|
||||||
If no qty diff, but diff in valuation rate, make (+1,-1) entry to update valuation
|
If no qty diff, but diff in valuation rate, make (+1,-1) entry to update valuation
|
||||||
"""
|
"""
|
||||||
|
self.diff_info = ''
|
||||||
for row in self.data:
|
for row in self.data:
|
||||||
# Get qty as per system
|
# Get qty as per system
|
||||||
sys_stock = self.get_system_stock(row[0],row[1])
|
sys_stock = self.get_system_stock(row[0],row[1])
|
||||||
@@ -190,29 +196,28 @@ class DocType:
|
|||||||
self.make_entry_for_valuation(row, sys_stock, is_submit)
|
self.make_entry_for_valuation(row, sys_stock, is_submit)
|
||||||
|
|
||||||
if is_submit == 1:
|
if is_submit == 1:
|
||||||
self.store_diff_info(qty_diff, rate_diff)
|
r = [cstr(i) for i in row] + [cstr(qty_diff), cstr(rate_diff)]
|
||||||
|
self.store_diff_info(r)
|
||||||
|
|
||||||
msgprint("Stock Reconciliation Completed Successfully...")
|
msgprint("Stock Reconciliation Completed Successfully...")
|
||||||
|
|
||||||
|
|
||||||
def store_diff_info(self, qty_diff, rate_diff):
|
def store_diff_info(self, r):
|
||||||
"""Add diffs column in attached file"""
|
"""Add diffs column in attached file"""
|
||||||
|
|
||||||
# add header
|
# add header
|
||||||
if self.val_method == 'Moving Average':
|
if not self.diff_info:
|
||||||
out = "Item Code, Warehouse, Qty, Valuation Rate, Qty Diff, Rate Diff"
|
if self.val_method == 'Moving Average':
|
||||||
else:
|
self.diff_info += "Item Code, Warehouse, Qty, Valuation Rate, Qty Diff, Rate Diff"
|
||||||
out = "Item Code, Warehouse, Qty, Incoming Rate, Qty Diff, Rate Diff"
|
else:
|
||||||
|
self.diff_info += "Item Code, Warehouse, Qty, Incoming Rate, Qty Diff, Rate Diff"
|
||||||
|
|
||||||
|
|
||||||
# add data
|
# add data
|
||||||
for d in self.data:
|
self.diff_info += "\n" + ','.join(r)
|
||||||
s = [cstr(i) for i in d] + [cstr(qty_diff), cstr(rate_diff)]
|
|
||||||
out += "\n" + ','.join(s)
|
webnotes.conn.set(self.doc, 'diff_info', self.diff_info)
|
||||||
|
|
||||||
webnotes.conn.set(self.doc, 'diff_info', out)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if not self.doc.file_list:
|
if not self.doc.file_list:
|
||||||
@@ -221,7 +226,6 @@ class DocType:
|
|||||||
self.do_stock_reco(is_submit = 1)
|
self.do_stock_reco(is_submit = 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
self.get_reconciliation_data(submit = 0)
|
self.get_reconciliation_data(submit = 0)
|
||||||
self.do_stock_reco(is_submit = -1)
|
self.do_stock_reco(is_submit = -1)
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
cur_frm.cscript.country = function(doc, cdt, cdn) {
|
cur_frm.cscript.country = function(doc, cdt, cdn) {
|
||||||
var mydoc=doc;
|
var mydoc=doc;
|
||||||
$c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])},
|
$c('runserverobj', args={'method':'check_state', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
|
||||||
function(r,rt){
|
function(r,rt){
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
var doc = locals[mydoc.doctype][mydoc.name];
|
var doc = locals[mydoc.doctype][mydoc.name];
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
# DocType Mapper, Maintenance Schedule-Maintenance Visit
|
||||||
|
[
|
||||||
|
|
||||||
|
# These values are common in all dictionaries
|
||||||
|
{
|
||||||
|
'creation': '2012-06-27 13:18:25',
|
||||||
|
'docstatus': 0,
|
||||||
|
'modified': '2012-06-27 13:18:25',
|
||||||
|
'modified_by': u'Administrator',
|
||||||
|
'owner': u'Administrator'
|
||||||
|
},
|
||||||
|
|
||||||
|
# These values are common for all Table Mapper Detail
|
||||||
|
{
|
||||||
|
'doctype': u'Table Mapper Detail',
|
||||||
|
'name': '__common__',
|
||||||
|
'parent': u'Maintenance Schedule-Maintenance Visit',
|
||||||
|
'parentfield': u'table_mapper_details',
|
||||||
|
'parenttype': u'DocType Mapper',
|
||||||
|
'validation_logic': u'docstatus=1'
|
||||||
|
},
|
||||||
|
|
||||||
|
# These values are common for all Field Mapper Detail
|
||||||
|
{
|
||||||
|
'doctype': u'Field Mapper Detail',
|
||||||
|
'map': u'Yes',
|
||||||
|
'name': '__common__',
|
||||||
|
'parent': u'Maintenance Schedule-Maintenance Visit',
|
||||||
|
'parentfield': u'field_mapper_details',
|
||||||
|
'parenttype': u'DocType Mapper'
|
||||||
|
},
|
||||||
|
|
||||||
|
# These values are common for all DocType Mapper
|
||||||
|
{
|
||||||
|
'doctype': u'DocType Mapper',
|
||||||
|
'from_doctype': u'Maintenance Schedule',
|
||||||
|
'module': u'Support',
|
||||||
|
'name': '__common__',
|
||||||
|
'ref_doc_submitted': 1,
|
||||||
|
'to_doctype': u'Maintenance Visit'
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocType Mapper, Maintenance Schedule-Maintenance Visit
|
||||||
|
{
|
||||||
|
'doctype': u'DocType Mapper',
|
||||||
|
'name': u'Maintenance Schedule-Maintenance Visit'
|
||||||
|
},
|
||||||
|
|
||||||
|
# Field Mapper Detail
|
||||||
|
{
|
||||||
|
'checking_operator': u'=',
|
||||||
|
'doctype': u'Field Mapper Detail',
|
||||||
|
'from_field': u'customer',
|
||||||
|
'match_id': 0,
|
||||||
|
'to_field': u'customer'
|
||||||
|
},
|
||||||
|
|
||||||
|
# Field Mapper Detail
|
||||||
|
{
|
||||||
|
'doctype': u'Field Mapper Detail',
|
||||||
|
'from_field': u'name',
|
||||||
|
'match_id': 0,
|
||||||
|
'to_field': u'maintenance_schedule'
|
||||||
|
},
|
||||||
|
|
||||||
|
# Field Mapper Detail
|
||||||
|
{
|
||||||
|
'doctype': u'Field Mapper Detail',
|
||||||
|
'from_field': u'parent',
|
||||||
|
'match_id': 1,
|
||||||
|
'to_field': u'prevdoc_docname'
|
||||||
|
},
|
||||||
|
|
||||||
|
# Field Mapper Detail
|
||||||
|
{
|
||||||
|
'doctype': u'Field Mapper Detail',
|
||||||
|
'from_field': u'parenttype',
|
||||||
|
'match_id': 1,
|
||||||
|
'to_field': u'prevdoc_doctype'
|
||||||
|
},
|
||||||
|
|
||||||
|
# Table Mapper Detail
|
||||||
|
{
|
||||||
|
'doctype': u'Table Mapper Detail',
|
||||||
|
'from_field': u'item_maintenance_detail',
|
||||||
|
'from_table': u'Maintenance Schedule Item',
|
||||||
|
'match_id': 1,
|
||||||
|
'to_field': u'maintenance_visit_details',
|
||||||
|
'to_table': u'Maintenance Visit Purpose'
|
||||||
|
},
|
||||||
|
|
||||||
|
# Table Mapper Detail
|
||||||
|
{
|
||||||
|
'doctype': u'Table Mapper Detail',
|
||||||
|
'from_table': u'Maintenance Schedule',
|
||||||
|
'match_id': 0,
|
||||||
|
'to_table': u'Maintenance Visit'
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -36,7 +36,7 @@ cur_frm.cscript.render_communication_list = function(doc, dt, dn) {
|
|||||||
|
|
||||||
prepare_data: function(data) {
|
prepare_data: function(data) {
|
||||||
this._super(data);
|
this._super(data);
|
||||||
data.creation = wn.datetime.str_to_user(data.communication_date);
|
this.prepare_when(data, data.creation);
|
||||||
|
|
||||||
// escape double quote
|
// escape double quote
|
||||||
data.content = cstr(data.subject).replace(/"/gi, '\"')
|
data.content = cstr(data.subject).replace(/"/gi, '\"')
|
||||||
@@ -54,7 +54,7 @@ cur_frm.cscript.render_communication_list = function(doc, dt, dn) {
|
|||||||
{width: '15%', content: 'name'},
|
{width: '15%', content: 'name'},
|
||||||
{width: '15%', content: 'category'},
|
{width: '15%', content: 'category'},
|
||||||
{width: '55%', content: 'content'},
|
{width: '55%', content: 'content'},
|
||||||
{width: '12%', content:'communication_date',
|
{width: '12%', content:'when',
|
||||||
css: {'text-align': 'right', 'color':'#777'}}
|
css: {'text-align': 'right', 'color':'#777'}}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,13 @@ wn.doclistviews['Communication'] = wn.views.ListView.extend({
|
|||||||
|
|
||||||
prepare_data: function(data) {
|
prepare_data: function(data) {
|
||||||
this._super(data);
|
this._super(data);
|
||||||
data.creation = wn.datetime.only_date(data.creation);
|
this.prepare_when(data, data.creation);
|
||||||
|
|
||||||
// escape double quote
|
// escape double quote
|
||||||
data.content = cstr(data.subject).replace(/"/gi, '\"')
|
data.content = cstr(data.subject)
|
||||||
+ " | " + cstr(data.content).replace(/"/gi, '\"');
|
+ " | " + cstr(data.content);
|
||||||
|
data.content = data.content.replace(/"/gi, '\"')
|
||||||
|
.replace(/</gi, '<').replace(/>/gi, '>');
|
||||||
|
|
||||||
if(data.content && data.content.length > 50) {
|
if(data.content && data.content.length > 50) {
|
||||||
data.content = '<span title="'+data.content+'">' +
|
data.content = '<span title="'+data.content+'">' +
|
||||||
@@ -26,12 +28,12 @@ wn.doclistviews['Communication'] = wn.views.ListView.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
columns: [
|
columns: [
|
||||||
|
{width: '3%', content: 'check'},
|
||||||
{width: '5%', content: 'avatar'},
|
{width: '5%', content: 'avatar'},
|
||||||
{width: '3%', content: 'docstatus'},
|
|
||||||
{width: '15%', content: 'name'},
|
{width: '15%', content: 'name'},
|
||||||
{width: '15%', content: 'category'},
|
{width: '15%', content: 'category'},
|
||||||
{width: '55%', content: 'content+tags'},
|
{width: '55%', content: 'content+tags'},
|
||||||
{width: '12%', content:'creation',
|
{width: '12%', content:'when',
|
||||||
css: {'text-align': 'right', 'color':'#777'}}
|
css: {'text-align': 'right', 'color':'#777'}}
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@@ -42,8 +42,8 @@ class DocType(TransactionBase):
|
|||||||
# pull sales order details
|
# pull sales order details
|
||||||
#--------------------------
|
#--------------------------
|
||||||
def pull_sales_order_detail(self):
|
def pull_sales_order_detail(self):
|
||||||
self.doc.clear_table(self.doclist, 'item_maintenance_detail')
|
self.doclist = self.doc.clear_table(self.doclist, 'item_maintenance_detail')
|
||||||
self.doc.clear_table(self.doclist, 'maintenance_schedule_detail')
|
self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail')
|
||||||
self.doclist = get_obj('DocType Mapper', 'Sales Order-Maintenance Schedule').dt_map('Sales Order', 'Maintenance Schedule', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Maintenance Schedule'],['Sales Order Item', 'Maintenance Schedule Item']]")
|
self.doclist = get_obj('DocType Mapper', 'Sales Order-Maintenance Schedule').dt_map('Sales Order', 'Maintenance Schedule', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Maintenance Schedule'],['Sales Order Item', 'Maintenance Schedule Item']]")
|
||||||
|
|
||||||
#pull item details
|
#pull item details
|
||||||
@@ -60,7 +60,7 @@ class DocType(TransactionBase):
|
|||||||
#-------------------------------------
|
#-------------------------------------
|
||||||
def generate_schedule(self):
|
def generate_schedule(self):
|
||||||
import datetime
|
import datetime
|
||||||
self.doc.clear_table(self.doclist, 'maintenance_schedule_detail')
|
self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail')
|
||||||
count = 0
|
count = 0
|
||||||
sql("delete from `tabMaintenance Schedule Detail` where parent='%s'" %(self.doc.name))
|
sql("delete from `tabMaintenance Schedule Detail` where parent='%s'" %(self.doc.name))
|
||||||
for d in getlist(self.doclist, 'item_maintenance_detail'):
|
for d in getlist(self.doclist, 'item_maintenance_detail'):
|
||||||
|
|||||||
@@ -16,16 +16,19 @@
|
|||||||
|
|
||||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||||
if(!doc.status) set_multiple(dt,dn,{status:'Draft'});
|
if(!doc.status) set_multiple(dt,dn,{status:'Draft'});
|
||||||
if(doc.customer) cur_frm.cscript.customer(doc,cdt,cdn);
|
if(doc.__islocal) set_multiple(dt,dn,{mntc_date:get_today()});
|
||||||
|
hide_contact_info(doc);
|
||||||
if(doc.__islocal){
|
|
||||||
set_multiple(dt,dn,{mntc_date:get_today()});
|
|
||||||
hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
|
|
||||||
}
|
|
||||||
|
|
||||||
//if(doc.maintenance_type) cur_frm.cscript.maintenance_type(doc,cdt,cdn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hide_contact_info = function(doc) {
|
||||||
|
if(doc.customer) $(cur_frm.fields_dict.contact_info_section.row.wrapper).toggle(true);
|
||||||
|
else $(cur_frm.fields_dict.contact_info_section.row.wrapper).toggle(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.refresh = function(doc) {
|
||||||
|
hide_contact_info(doc);
|
||||||
|
}
|
||||||
|
|
||||||
//customer
|
//customer
|
||||||
cur_frm.cscript.customer = function(doc,dt,dn) {
|
cur_frm.cscript.customer = function(doc,dt,dn) {
|
||||||
@@ -35,7 +38,7 @@ cur_frm.cscript.customer = function(doc,dt,dn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
|
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
|
||||||
if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
|
hide_contact_info(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
|
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
|
||||||
@@ -62,36 +65,12 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
|||||||
|
|
||||||
cur_frm.cscript.get_items = function(doc, dt, dn) {
|
cur_frm.cscript.get_items = function(doc, dt, dn) {
|
||||||
var callback = function(r,rt) {
|
var callback = function(r,rt) {
|
||||||
unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
|
hide_contact_info(doc);
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
}
|
}
|
||||||
get_server_fields('fetch_items','','',doc, dt, dn,1,callback);
|
get_server_fields('fetch_items','','',doc, dt, dn,1,callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
cur_frm.cscript.maintenance_type = function(doc,cdt,cdn){
|
|
||||||
if(doc.maintenance_type == 'Scheduled') {
|
|
||||||
hide_field('sales_order_no');
|
|
||||||
hide_field('customer_issue_no');
|
|
||||||
hide_field('Get Items');
|
|
||||||
doc.customer_issue_no = '';
|
|
||||||
doc.sales_order_no = '';
|
|
||||||
}
|
|
||||||
else if(doc.maintenance_type == 'Unscheduled') {
|
|
||||||
unhide_field('sales_order_no');
|
|
||||||
hide_field('customer_issue_no');
|
|
||||||
unhide_field('Get Items');
|
|
||||||
doc.customer_issue_no = '';
|
|
||||||
}
|
|
||||||
else if(doc.maintenance_type == 'Breakdown') {
|
|
||||||
hide_field('sales_order_no');
|
|
||||||
unhide_field('customer_issue_no');
|
|
||||||
unhide_field('Get Items');
|
|
||||||
doc.sales_order_no = '';
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
cur_frm.fields_dict['maintenance_visit_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
|
cur_frm.fields_dict['maintenance_visit_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
|
||||||
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50';
|
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50';
|
||||||
}
|
}
|
||||||
@@ -110,7 +89,6 @@ cur_frm.fields_dict['sales_order_no'].get_query = function(doc) {
|
|||||||
if(doc.customer) {
|
if(doc.customer) {
|
||||||
cond = '`tabSales Order`.customer = "'+doc.customer+'" AND';
|
cond = '`tabSales Order`.customer = "'+doc.customer+'" AND';
|
||||||
}
|
}
|
||||||
//return repl('SELECT DISTINCT `tabSales Order`.name FROM `tabSales Order`, `tabSales Order Item` WHERE `tabSales Order`.company = "%(company)s" AND `tabSales Order`.docstatus = 1 AND %(cond)s `tabSales Order`.name LIKE "%s" ORDER BY `tabSales Order`.name DESC LIMIT 50', {company:doc.company, cond:cond});
|
|
||||||
return repl('SELECT DISTINCT `tabSales Order`.name FROM `tabSales Order`, `tabSales Order Item`, `tabItem` WHERE `tabSales Order`.company = "%(company)s" AND `tabSales Order`.docstatus = 1 AND `tabSales Order Item`.parent = `tabSales Order`.name AND `tabSales Order Item`.item_code = `tabItem`.name AND `tabItem`.is_service_item = "Yes" AND %(cond)s `tabSales Order`.name LIKE "%s" ORDER BY `tabSales Order`.name DESC LIMIT 50', {company:doc.company, cond:cond});
|
return repl('SELECT DISTINCT `tabSales Order`.name FROM `tabSales Order`, `tabSales Order Item`, `tabItem` WHERE `tabSales Order`.company = "%(company)s" AND `tabSales Order`.docstatus = 1 AND `tabSales Order Item`.parent = `tabSales Order`.name AND `tabSales Order Item`.item_code = `tabItem`.name AND `tabItem`.is_service_item = "Yes" AND %(cond)s `tabSales Order`.name LIKE "%s" ORDER BY `tabSales Order`.name DESC LIMIT 50', {company:doc.company, cond:cond});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +101,16 @@ cur_frm.fields_dict['customer_issue_no'].get_query = function(doc) {
|
|||||||
return repl('SELECT `tabCustomer Issue`.name FROM `tabCustomer Issue` WHERE `tabCustomer Issue`.company = "%(company)s" AND %(cond)s `tabCustomer Issue`.docstatus = 1 AND (`tabCustomer Issue`.status = "Open" OR `tabCustomer Issue`.status = "Work In Progress") AND `tabCustomer Issue`.name LIKE "%s" ORDER BY `tabCustomer Issue`.name DESC LIMIT 50', {company:doc.company, cond:cond});
|
return repl('SELECT `tabCustomer Issue`.name FROM `tabCustomer Issue` WHERE `tabCustomer Issue`.company = "%(company)s" AND %(cond)s `tabCustomer Issue`.docstatus = 1 AND (`tabCustomer Issue`.status = "Open" OR `tabCustomer Issue`.status = "Work In Progress") AND `tabCustomer Issue`.name LIKE "%s" ORDER BY `tabCustomer Issue`.name DESC LIMIT 50', {company:doc.company, cond:cond});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict['maintenance_schedule'].get_query = function(doc) {
|
||||||
|
doc = locals[this.doctype][this.docname];
|
||||||
|
var cond = '';
|
||||||
|
if(doc.customer) {
|
||||||
|
cond = '`tabMaintenance Schedule`.customer = "'+doc.customer+'" AND';
|
||||||
|
}
|
||||||
|
return repl('SELECT `tabMaintenance Schedule`.name FROM `tabMaintenance Schedule` WHERE `tabMaintenance Schedule`.company = "%(company)s" AND %(cond)s `tabMaintenance Schedule`.docstatus = 1 AND `tabMaintenance Schedule`.name LIKE "%s" ORDER BY `tabMaintenance Schedule`.name DESC LIMIT 50', {company:doc.company, cond:cond});
|
||||||
|
}
|
||||||
|
|
||||||
//get query select Territory
|
//get query select Territory
|
||||||
//=======================================================================================================================
|
|
||||||
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Please edit this list and import only required elements
|
# Please edit this list and import only required elements
|
||||||
import webnotes
|
import webnotes
|
||||||
@@ -35,130 +35,129 @@ convert_to_lists = webnotes.conn.convert_to_lists
|
|||||||
from utilities.transaction_base import TransactionBase
|
from utilities.transaction_base import TransactionBase
|
||||||
|
|
||||||
class DocType(TransactionBase):
|
class DocType(TransactionBase):
|
||||||
def __init__(self, doc, doclist=[]):
|
def __init__(self, doc, doclist=[]):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
self.doclist = doclist
|
self.doclist = doclist
|
||||||
|
|
||||||
#get item details
|
#get item details
|
||||||
#------------------
|
#------------------
|
||||||
def get_item_details(self, item_code):
|
def get_item_details(self, item_code):
|
||||||
item = sql("select item_name,description from `tabItem` where name = '%s'" %(item_code), as_dict=1)
|
item = sql("select item_name,description from `tabItem` where name = '%s'" %(item_code), as_dict=1)
|
||||||
ret = {
|
ret = {
|
||||||
'item_name' : item and item[0]['item_name'] or '',
|
'item_name' : item and item[0]['item_name'] or '',
|
||||||
'description' : item and item[0]['description'] or ''
|
'description' : item and item[0]['description'] or ''
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# fetch details of resp Sales order or customer issue
|
# fetch details of resp Sales order or customer issue
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
def fetch_items(self):
|
def fetch_items(self):
|
||||||
if self.doc.sales_order_no and self.doc.customer_issue_no:
|
if self.doc.sales_order_no and self.doc.customer_issue_no :
|
||||||
msgprint("You can not fetch details of both, Sales Order and Customer Issue, in same Maintenance Visit")
|
msgprint("You can not fetch details of both, Sales Order and Customer Issue, in same Maintenance Visit")
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
self.doc.clear_table(self.doclist, 'maintenance_visit_details')
|
self.doclist = self.doc.clear_table(self.doclist, 'maintenance_visit_details')
|
||||||
|
|
||||||
if self.doc.sales_order_no:
|
if self.doc.sales_order_no:
|
||||||
self.doclist = get_obj('DocType Mapper', 'Sales Order-Maintenance Visit').dt_map('Sales Order', 'Maintenance Visit', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Maintenance Visit'],['Sales Order Item', 'Maintenance Visit Purpose']]")
|
self.doclist = get_obj('DocType Mapper', 'Sales Order-Maintenance Visit').dt_map('Sales Order', \
|
||||||
|
'Maintenance Visit', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Maintenance Visit'],\
|
||||||
elif self.doc.customer_issue_no:
|
['Sales Order Item', 'Maintenance Visit Purpose']]")
|
||||||
self.doclist = get_obj('DocType Mapper', 'Customer Issue-Maintenance Visit').dt_map('Customer Issue', 'Maintenance Visit', self.doc.customer_issue_no, self.doc, self.doclist, "[['Customer Issue', 'Maintenance Visit'],['Customer Issue', 'Maintenance Visit Purpose']]")
|
elif self.doc.customer_issue_no:
|
||||||
|
self.doclist = get_obj('DocType Mapper', 'Customer Issue-Maintenance Visit').dt_map('Customer Issue', \
|
||||||
#validate reference value using doctype mapper
|
'Maintenance Visit', self.doc.customer_issue_no, self.doc, self.doclist, "[['Customer Issue', 'Maintenance Visit'],\
|
||||||
#-----------------------------------------------------
|
['Customer Issue', 'Maintenance Visit Purpose']]")
|
||||||
def validate_reference_value(self, check_for):
|
elif self.doc.maintenance_schedule:
|
||||||
if check_for == 'Sales Order':
|
self.doclist = get_obj('DocType Mapper', 'Maintenance Schedule-Maintenance Visit').dt_map('Maintenance Schedule',\
|
||||||
get_obj('DocType Mapper', 'Sales Order-Maintenance Visit', with_children = 1).validate_reference_value(self, self.doc.name)
|
'Maintenance Visit', self.doc.maintenance_schedule, self.doc, self.doclist, "[['Maintenance Schedule', \
|
||||||
elif check_for == 'Customer Issue':
|
'Maintenance Visit'], ['Maintenance Schedule Item', 'Maintenance Visit Purpose']]")
|
||||||
get_obj('DocType Mapper', 'Customer Issue-Maintenance Visit', with_children = 1).validate_reference_value(self, self.doc.name)
|
|
||||||
|
#validate reference value using doctype mapper
|
||||||
#check if serial no exist in system
|
#-----------------------------------------------------
|
||||||
#--------------------------------------
|
def validate_reference_value(self, check_for):
|
||||||
def validate_serial_no(self):
|
if check_for == 'Sales Order':
|
||||||
for d in getlist(self.doclist, 'maintenance_visit_details'):
|
get_obj('DocType Mapper', 'Sales Order-Maintenance Visit', with_children = 1).validate_reference_value(self, self.doc.name)
|
||||||
if d.serial_no and not sql("select name from `tabSerial No` where name = '%s' and docstatus != 2" % d.serial_no):
|
elif check_for == 'Customer Issue':
|
||||||
msgprint("Serial No: "+ d.serial_no + " not exists in the system")
|
get_obj('DocType Mapper', 'Customer Issue-Maintenance Visit', with_children = 1).validate_reference_value(self, self.doc.name)
|
||||||
raise Exception
|
|
||||||
#elif not d.serial_no and d.item_code:
|
#check if serial no exist in system
|
||||||
# ser = sql("select has_serial_no from tabItem where name = '%s'" % d.item_code)
|
#--------------------------------------
|
||||||
# ser = ser and ser[0][0] or 'No'
|
def validate_serial_no(self):
|
||||||
# if ser == 'Yes':
|
for d in getlist(self.doclist, 'maintenance_visit_details'):
|
||||||
# msgprint("Serial No is mandatory for item: " + d.item_code)
|
if d.serial_no and not sql("select name from `tabSerial No` where name = '%s' and docstatus != 2" % d.serial_no):
|
||||||
# raise Exception
|
msgprint("Serial No: "+ d.serial_no + " not exists in the system")
|
||||||
|
raise Exception
|
||||||
def validate(self):
|
|
||||||
if not getlist(self.doclist, 'maintenance_visit_details'):
|
|
||||||
msgprint("Please enter maintenance details")
|
|
||||||
raise Exception
|
|
||||||
|
|
||||||
for d in getlist(self.doclist, 'maintenance_visit_details'):
|
|
||||||
if d.prevdoc_doctype == 'Sales Order':
|
|
||||||
check_for = 'Sales Order'
|
|
||||||
elif d.prevdoc_doctype == 'Customer Issue':
|
|
||||||
check_for = 'Customer Issue'
|
|
||||||
else:
|
|
||||||
msgprint("Maintenance Visit must be created either against Sales Order or against Customer Issue")
|
|
||||||
raise Exception
|
|
||||||
|
|
||||||
if check_for:
|
|
||||||
self.validate_reference_value(check_for)
|
|
||||||
|
|
||||||
self.validate_serial_no()
|
|
||||||
|
def validate(self):
|
||||||
def update_customer_issue(self, flag):
|
if not getlist(self.doclist, 'maintenance_visit_details'):
|
||||||
for d in getlist(self.doclist, 'maintenance_visit_details'):
|
msgprint("Please enter maintenance details")
|
||||||
if d.prevdoc_docname and d.prevdoc_doctype == 'Customer Issue' :
|
raise Exception
|
||||||
if flag==1:
|
|
||||||
mntc_date = self.doc.mntc_date
|
check_for = ''
|
||||||
service_person = d.service_person
|
for d in getlist(self.doclist, 'maintenance_visit_details'):
|
||||||
work_done = d.work_done
|
if d.prevdoc_doctype == 'Sales Order':
|
||||||
if self.doc.completion_status == 'Fully Completed':
|
check_for = 'Sales Order'
|
||||||
status = 'Closed'
|
elif d.prevdoc_doctype == 'Customer Issue':
|
||||||
elif self.doc.completion_status == 'Partially Completed':
|
check_for = 'Customer Issue'
|
||||||
status = 'Work In Progress'
|
|
||||||
else:
|
if check_for:
|
||||||
nm = sql("select t1.name, t1.mntc_date, t2.service_person, t2.work_done from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.completion_status = 'Partially Completed' and t2.prevdoc_docname = %s and t1.name!=%s and t1.docstatus = 1 order by t1.name desc limit 1", (d.prevdoc_docname, self.doc.name))
|
self.validate_reference_value(check_for)
|
||||||
|
|
||||||
if nm:
|
|
||||||
status = 'Work In Progress'
|
|
||||||
mntc_date = nm and nm[0][1] or ''
|
|
||||||
service_person = nm and nm[0][2] or ''
|
|
||||||
work_done = nm and nm[0][3] or ''
|
|
||||||
else:
|
|
||||||
status = 'Open'
|
|
||||||
mntc_date = ''
|
|
||||||
service_person = ''
|
|
||||||
work_done = ''
|
|
||||||
|
|
||||||
sql("update `tabCustomer Issue` set resolution_date=%s, resolved_by=%s, resolution_details=%s, status=%s where name =%s",(mntc_date,service_person,work_done,status,d.prevdoc_docname))
|
|
||||||
|
|
||||||
# check if last maintenance visit against same sales order/ customer issue
|
|
||||||
#-----------------------------------------------------------------------------------
|
|
||||||
def check_if_last_visit(self):
|
|
||||||
for d in getlist(self.doclist, 'maintenance_visit_details'):
|
|
||||||
if d.prevdoc_docname:
|
|
||||||
check_for_docname = d.prevdoc_docname
|
|
||||||
check_for_doctype = d.prevdoc_doctype
|
|
||||||
|
|
||||||
if check_for_docname:
|
|
||||||
check = sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.name!=%s and t2.prevdoc_docname=%s and t1.docstatus = 1 and (t1.mntc_date > %s or (t1.mntc_date = %s and t1.mntc_time > %s))", (self.doc.name, check_for_docname, self.doc.mntc_date, self.doc.mntc_date, self.doc.mntc_time))
|
|
||||||
|
|
||||||
if check:
|
|
||||||
check_lst = [x[0] for x in check]
|
|
||||||
check_lst =','.join(check_lst)
|
|
||||||
msgprint("To cancel this, you need to cancel Maintenance Visit(s) "+cstr(check_lst)+" created after this maintenance visit against same "+check_for_doctype)
|
|
||||||
raise Exception
|
|
||||||
else:
|
|
||||||
self.update_customer_issue(0)
|
|
||||||
|
|
||||||
def on_submit(self):
|
|
||||||
self.update_customer_issue(1)
|
|
||||||
set(self.doc, 'status', 'Submitted')
|
|
||||||
|
|
||||||
def on_cancel(self):
|
|
||||||
self.check_if_last_visit()
|
|
||||||
set(self.doc, 'status', 'Cancelled')
|
|
||||||
|
|
||||||
def on_update(self):
|
self.validate_serial_no()
|
||||||
pass
|
|
||||||
|
def update_customer_issue(self, flag):
|
||||||
|
for d in getlist(self.doclist, 'maintenance_visit_details'):
|
||||||
|
if d.prevdoc_docname and d.prevdoc_doctype == 'Customer Issue' :
|
||||||
|
if flag==1:
|
||||||
|
mntc_date = self.doc.mntc_date
|
||||||
|
service_person = d.service_person
|
||||||
|
work_done = d.work_done
|
||||||
|
if self.doc.completion_status == 'Fully Completed':
|
||||||
|
status = 'Closed'
|
||||||
|
elif self.doc.completion_status == 'Partially Completed':
|
||||||
|
status = 'Work In Progress'
|
||||||
|
else:
|
||||||
|
nm = sql("select t1.name, t1.mntc_date, t2.service_person, t2.work_done from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.completion_status = 'Partially Completed' and t2.prevdoc_docname = %s and t1.name!=%s and t1.docstatus = 1 order by t1.name desc limit 1", (d.prevdoc_docname, self.doc.name))
|
||||||
|
|
||||||
|
if nm:
|
||||||
|
status = 'Work In Progress'
|
||||||
|
mntc_date = nm and nm[0][1] or ''
|
||||||
|
service_person = nm and nm[0][2] or ''
|
||||||
|
work_done = nm and nm[0][3] or ''
|
||||||
|
else:
|
||||||
|
status = 'Open'
|
||||||
|
mntc_date = ''
|
||||||
|
service_person = ''
|
||||||
|
work_done = ''
|
||||||
|
|
||||||
|
sql("update `tabCustomer Issue` set resolution_date=%s, resolved_by=%s, resolution_details=%s, status=%s where name =%s",(mntc_date,service_person,work_done,status,d.prevdoc_docname))
|
||||||
|
|
||||||
|
|
||||||
|
def check_if_last_visit(self):
|
||||||
|
"""check if last maintenance visit against same sales order/ customer issue"""
|
||||||
|
for d in getlist(self.doclist, 'maintenance_visit_details'):
|
||||||
|
if d.prevdoc_docname:
|
||||||
|
check_for_docname = d.prevdoc_docname
|
||||||
|
check_for_doctype = d.prevdoc_doctype
|
||||||
|
|
||||||
|
if check_for_docname:
|
||||||
|
check = sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.name!=%s and t2.prevdoc_docname=%s and t1.docstatus = 1 and (t1.mntc_date > %s or (t1.mntc_date = %s and t1.mntc_time > %s))", (self.doc.name, check_for_docname, self.doc.mntc_date, self.doc.mntc_date, self.doc.mntc_time))
|
||||||
|
|
||||||
|
if check:
|
||||||
|
check_lst = [x[0] for x in check]
|
||||||
|
check_lst =','.join(check_lst)
|
||||||
|
msgprint("To cancel this, you need to cancel Maintenance Visit(s) "+cstr(check_lst)+" created after this maintenance visit against same "+check_for_doctype)
|
||||||
|
raise Exception
|
||||||
|
else:
|
||||||
|
self.update_customer_issue(0)
|
||||||
|
|
||||||
|
def on_submit(self):
|
||||||
|
self.update_customer_issue(1)
|
||||||
|
set(self.doc, 'status', 'Submitted')
|
||||||
|
|
||||||
|
def on_cancel(self):
|
||||||
|
self.check_if_last_visit()
|
||||||
|
set(self.doc, 'status', 'Cancelled')
|
||||||
|
|
||||||
|
def on_update(self):
|
||||||
|
pass
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
'creation': '2012-03-27 14:36:42',
|
'creation': '2012-06-11 12:10:15',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-03-27 14:45:49',
|
'modified': '2012-06-27 12:50:00',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'ashwini@webnotestech.com'
|
'owner': u'ashwini@webnotestech.com'
|
||||||
},
|
},
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
'show_in_menu': 0,
|
'show_in_menu': 0,
|
||||||
'subject': u'To %(customer_name)s on %(mntc_date)s',
|
'subject': u'To %(customer_name)s on %(mntc_date)s',
|
||||||
'tag_fields': u'completion_status,maintenance_type',
|
'tag_fields': u'completion_status,maintenance_type',
|
||||||
'version': 95
|
'version': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# These values are common for all DocField
|
# These values are common for all DocField
|
||||||
@@ -144,38 +144,17 @@
|
|||||||
'permlevel': 0,
|
'permlevel': 0,
|
||||||
'print_hide': 1,
|
'print_hide': 1,
|
||||||
'reqd': 1,
|
'reqd': 1,
|
||||||
'search_index': 1,
|
'search_index': 0,
|
||||||
'trigger': u'Client'
|
'trigger': u'Client'
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'customer_address',
|
|
||||||
'fieldtype': u'Link',
|
|
||||||
'label': u'Customer Address',
|
|
||||||
'options': u'Address',
|
|
||||||
'permlevel': 0,
|
|
||||||
'print_hide': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'contact_person',
|
|
||||||
'fieldtype': u'Link',
|
|
||||||
'label': u'Contact Person',
|
|
||||||
'options': u'Contact',
|
|
||||||
'permlevel': 0,
|
|
||||||
'print_hide': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'customer_name',
|
'fieldname': u'customer_name',
|
||||||
'fieldtype': u'Data',
|
'fieldtype': u'Data',
|
||||||
'label': u'Name',
|
'hidden': 1,
|
||||||
|
'label': u'Customer Name',
|
||||||
'permlevel': 1
|
'permlevel': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -184,6 +163,7 @@
|
|||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'address_display',
|
'fieldname': u'address_display',
|
||||||
'fieldtype': u'Small Text',
|
'fieldtype': u'Small Text',
|
||||||
|
'hidden': 1,
|
||||||
'label': u'Address',
|
'label': u'Address',
|
||||||
'permlevel': 1
|
'permlevel': 1
|
||||||
},
|
},
|
||||||
@@ -193,6 +173,7 @@
|
|||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'contact_display',
|
'fieldname': u'contact_display',
|
||||||
'fieldtype': u'Small Text',
|
'fieldtype': u'Small Text',
|
||||||
|
'hidden': 1,
|
||||||
'label': u'Contact',
|
'label': u'Contact',
|
||||||
'permlevel': 1
|
'permlevel': 1
|
||||||
},
|
},
|
||||||
@@ -202,6 +183,7 @@
|
|||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'contact_mobile',
|
'fieldname': u'contact_mobile',
|
||||||
'fieldtype': u'Data',
|
'fieldtype': u'Data',
|
||||||
|
'hidden': 1,
|
||||||
'label': u'Mobile No',
|
'label': u'Mobile No',
|
||||||
'permlevel': 1
|
'permlevel': 1
|
||||||
},
|
},
|
||||||
@@ -211,42 +193,11 @@
|
|||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'contact_email',
|
'fieldname': u'contact_email',
|
||||||
'fieldtype': u'Data',
|
'fieldtype': u'Data',
|
||||||
|
'hidden': 1,
|
||||||
'label': u'Contact Email',
|
'label': u'Contact Email',
|
||||||
'permlevel': 1
|
'permlevel': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'company',
|
|
||||||
'fieldtype': u'Select',
|
|
||||||
'in_filter': 1,
|
|
||||||
'label': u'Company',
|
|
||||||
'oldfieldname': u'company',
|
|
||||||
'oldfieldtype': u'Select',
|
|
||||||
'options': u'link:Company',
|
|
||||||
'permlevel': 0,
|
|
||||||
'print_hide': 1,
|
|
||||||
'reqd': 1,
|
|
||||||
'search_index': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'fiscal_year',
|
|
||||||
'fieldtype': u'Select',
|
|
||||||
'in_filter': 1,
|
|
||||||
'label': u'Fiscal Year',
|
|
||||||
'oldfieldname': u'fiscal_year',
|
|
||||||
'oldfieldtype': u'Select',
|
|
||||||
'options': u'link:Fiscal Year',
|
|
||||||
'permlevel': 0,
|
|
||||||
'print_hide': 1,
|
|
||||||
'reqd': 1,
|
|
||||||
'search_index': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
@@ -283,72 +234,6 @@
|
|||||||
'permlevel': 0
|
'permlevel': 0
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'colour': u'White:FFF',
|
|
||||||
'default': u'Draft',
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'status',
|
|
||||||
'fieldtype': u'Data',
|
|
||||||
'label': u'Status',
|
|
||||||
'no_copy': 1,
|
|
||||||
'oldfieldname': u'status',
|
|
||||||
'oldfieldtype': u'Data',
|
|
||||||
'options': u'\nDraft\nCancelled\nSubmitted',
|
|
||||||
'permlevel': 1,
|
|
||||||
'reqd': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'amended_from',
|
|
||||||
'fieldtype': u'Data',
|
|
||||||
'label': u'Amended From',
|
|
||||||
'no_copy': 1,
|
|
||||||
'oldfieldname': u'amended_from',
|
|
||||||
'oldfieldtype': u'Data',
|
|
||||||
'permlevel': 1,
|
|
||||||
'print_hide': 1,
|
|
||||||
'width': u'150px'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'amendment_date',
|
|
||||||
'fieldtype': u'Date',
|
|
||||||
'label': u'Amendment Date',
|
|
||||||
'no_copy': 1,
|
|
||||||
'oldfieldname': u'amendment_date',
|
|
||||||
'oldfieldtype': u'Date',
|
|
||||||
'permlevel': 0,
|
|
||||||
'print_hide': 1,
|
|
||||||
'width': u'100px'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'territory',
|
|
||||||
'fieldtype': u'Link',
|
|
||||||
'label': u'Territory',
|
|
||||||
'options': u'Territory',
|
|
||||||
'permlevel': 0,
|
|
||||||
'print_hide': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'customer_group',
|
|
||||||
'fieldtype': u'Link',
|
|
||||||
'label': u'Customer Group',
|
|
||||||
'options': u'Customer Group',
|
|
||||||
'permlevel': 0,
|
|
||||||
'print_hide': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
@@ -432,6 +317,17 @@
|
|||||||
'trigger': u'Client'
|
'trigger': u'Client'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'maintenance_schedule',
|
||||||
|
'fieldtype': u'Link',
|
||||||
|
'in_filter': 1,
|
||||||
|
'label': u'Maintenance Schedule',
|
||||||
|
'options': u'Maintenance Schedule',
|
||||||
|
'permlevel': 0
|
||||||
|
},
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
@@ -470,9 +366,9 @@
|
|||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
'fieldname': u'feedback',
|
'fieldname': u'more_info',
|
||||||
'fieldtype': u'Section Break',
|
'fieldtype': u'Section Break',
|
||||||
'label': u'Feedback',
|
'label': u'More Info',
|
||||||
'oldfieldtype': u'Section Break',
|
'oldfieldtype': u'Section Break',
|
||||||
'permlevel': 0
|
'permlevel': 0
|
||||||
},
|
},
|
||||||
@@ -486,5 +382,150 @@
|
|||||||
'oldfieldname': u'customer_feedback',
|
'oldfieldname': u'customer_feedback',
|
||||||
'oldfieldtype': u'Small Text',
|
'oldfieldtype': u'Small Text',
|
||||||
'permlevel': 0
|
'permlevel': 0
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'col_break3',
|
||||||
|
'fieldtype': u'Column Break',
|
||||||
|
'permlevel': 0
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'colour': u'White:FFF',
|
||||||
|
'default': u'Draft',
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'status',
|
||||||
|
'fieldtype': u'Data',
|
||||||
|
'label': u'Status',
|
||||||
|
'no_copy': 1,
|
||||||
|
'oldfieldname': u'status',
|
||||||
|
'oldfieldtype': u'Data',
|
||||||
|
'options': u'\nDraft\nCancelled\nSubmitted',
|
||||||
|
'permlevel': 1,
|
||||||
|
'reqd': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'amended_from',
|
||||||
|
'fieldtype': u'Data',
|
||||||
|
'label': u'Amended From',
|
||||||
|
'no_copy': 1,
|
||||||
|
'oldfieldname': u'amended_from',
|
||||||
|
'oldfieldtype': u'Data',
|
||||||
|
'permlevel': 1,
|
||||||
|
'print_hide': 1,
|
||||||
|
'width': u'150px'
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'amendment_date',
|
||||||
|
'fieldtype': u'Date',
|
||||||
|
'label': u'Amendment Date',
|
||||||
|
'no_copy': 1,
|
||||||
|
'oldfieldname': u'amendment_date',
|
||||||
|
'oldfieldtype': u'Date',
|
||||||
|
'permlevel': 0,
|
||||||
|
'print_hide': 1,
|
||||||
|
'width': u'100px'
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'company',
|
||||||
|
'fieldtype': u'Select',
|
||||||
|
'in_filter': 1,
|
||||||
|
'label': u'Company',
|
||||||
|
'oldfieldname': u'company',
|
||||||
|
'oldfieldtype': u'Select',
|
||||||
|
'options': u'link:Company',
|
||||||
|
'permlevel': 0,
|
||||||
|
'print_hide': 1,
|
||||||
|
'reqd': 1,
|
||||||
|
'search_index': 0
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'fiscal_year',
|
||||||
|
'fieldtype': u'Select',
|
||||||
|
'in_filter': 1,
|
||||||
|
'label': u'Fiscal Year',
|
||||||
|
'oldfieldname': u'fiscal_year',
|
||||||
|
'oldfieldtype': u'Select',
|
||||||
|
'options': u'link:Fiscal Year',
|
||||||
|
'permlevel': 0,
|
||||||
|
'print_hide': 1,
|
||||||
|
'reqd': 1,
|
||||||
|
'search_index': 0
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'contact_info_section',
|
||||||
|
'fieldtype': u'Section Break',
|
||||||
|
'label': u'Contact Info',
|
||||||
|
'permlevel': 0
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'customer_address',
|
||||||
|
'fieldtype': u'Link',
|
||||||
|
'label': u'Customer Address',
|
||||||
|
'options': u'Address',
|
||||||
|
'permlevel': 0,
|
||||||
|
'print_hide': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'contact_person',
|
||||||
|
'fieldtype': u'Link',
|
||||||
|
'label': u'Contact Person',
|
||||||
|
'options': u'Contact',
|
||||||
|
'permlevel': 0,
|
||||||
|
'print_hide': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'col_break4',
|
||||||
|
'fieldtype': u'Column Break',
|
||||||
|
'permlevel': 0
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'territory',
|
||||||
|
'fieldtype': u'Link',
|
||||||
|
'label': u'Territory',
|
||||||
|
'options': u'Territory',
|
||||||
|
'permlevel': 0,
|
||||||
|
'print_hide': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'customer_group',
|
||||||
|
'fieldtype': u'Link',
|
||||||
|
'label': u'Customer Group',
|
||||||
|
'options': u'Customer Group',
|
||||||
|
'permlevel': 0,
|
||||||
|
'print_hide': 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -29,14 +29,14 @@ wn.doclistviews['Support Ticket'] = wn.views.ListView.extend({
|
|||||||
data.status = 'Waiting'
|
data.status = 'Waiting'
|
||||||
}
|
}
|
||||||
data.status_html = repl('<span class="label label-%(label_type)s">%(status)s</span>', data);
|
data.status_html = repl('<span class="label label-%(label_type)s">%(status)s</span>', data);
|
||||||
var a = $(data.status_html).click(function() {
|
|
||||||
me.set_filter('status', $(this).text());
|
|
||||||
});
|
|
||||||
|
|
||||||
// escape double quotes
|
// escape double quotes
|
||||||
data.description = cstr(data.subject).replace(/"/gi, '\"')
|
data.description = cstr(data.subject)
|
||||||
+ " | " + cstr(data.description).replace(/"/gi, '\"');
|
+ " | " + cstr(data.description);
|
||||||
|
|
||||||
|
data.description = data.description.replace(/"/gi, '\"')
|
||||||
|
.replace(/</gi, '<').replace(/>/gi, '>');
|
||||||
|
|
||||||
// description
|
// description
|
||||||
if(data.description && data.description.length > 50) {
|
if(data.description && data.description.length > 50) {
|
||||||
data.description = '<span title="'+data.description+'">' + data.description.substr(0,50) + '...</span>';
|
data.description = '<span title="'+data.description+'">' + data.description.substr(0,50) + '...</span>';
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ $.extend(cur_frm.cscript, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
send: function(doc, dt, dn) {
|
send: function(doc, dt, dn) {
|
||||||
$c_obj([doc], 'send_response', '', function(r,rt) {
|
$c_obj(make_doclist(doc.doctype, doc.name), 'send_response', '', function(r,rt) {
|
||||||
locals[dt][dn].new_response = '';
|
locals[dt][dn].new_response = '';
|
||||||
if(!(r.exc || r.server_messages)) {
|
if(!(r.exc || r.server_messages)) {
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
@@ -124,7 +124,7 @@ $.extend(cur_frm.cscript, {
|
|||||||
var answer = confirm("Close Ticket "+doc.name+"?\n\nAllocated To: "+doc.allocated_to+"\n\nSubject: "+doc.subject+"");
|
var answer = confirm("Close Ticket "+doc.name+"?\n\nAllocated To: "+doc.allocated_to+"\n\nSubject: "+doc.subject+"");
|
||||||
if(answer) {
|
if(answer) {
|
||||||
if(doc.name)
|
if(doc.name)
|
||||||
$c_obj([doc],'close_ticket','',function(r,rt) {
|
$c_obj(make_doclist(doc.doctype, doc.name),'close_ticket','',function(r,rt) {
|
||||||
if(!r.exc) {
|
if(!r.exc) {
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ $.extend(cur_frm.cscript, {
|
|||||||
var answer = confirm("Re-Open Ticket "+doc.name+"?\n\nAllocated To: "+doc.allocated_to+"\n\nSubject: "+doc.subject+"");
|
var answer = confirm("Re-Open Ticket "+doc.name+"?\n\nAllocated To: "+doc.allocated_to+"\n\nSubject: "+doc.subject+"");
|
||||||
if(answer) {
|
if(answer) {
|
||||||
if(doc.name)
|
if(doc.name)
|
||||||
$c_obj([doc],'reopen_ticket','',function(r,rt) {
|
$c_obj(make_doclist(doc.doctype, doc.name),'reopen_ticket','',function(r,rt) {
|
||||||
if(!r.exc) {
|
if(!r.exc) {
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ from webnotes.model.doc import Document
|
|||||||
from webnotes import session, form, msgprint, errprint
|
from webnotes import session, form, msgprint, errprint
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, doc, doclist=[]):
|
def __init__(self, doc, doclist=[]):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
'creation': '2012-03-27 14:36:45',
|
'creation': '2012-07-02 19:57:47',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-03-27 14:36:45',
|
'modified': '2012-07-02 20:24:15',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'Administrator'
|
'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
'search_fields': u'customer, supplier, sales_partner, country, state',
|
'search_fields': u'customer, supplier, sales_partner, country, state',
|
||||||
'section_style': u'Simple',
|
'section_style': u'Simple',
|
||||||
'show_in_menu': 0,
|
'show_in_menu': 0,
|
||||||
'version': 43
|
'version': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# These values are common for all DocField
|
# These values are common for all DocField
|
||||||
@@ -38,17 +38,12 @@
|
|||||||
|
|
||||||
# These values are common for all DocPerm
|
# These values are common for all DocPerm
|
||||||
{
|
{
|
||||||
'cancel': 1,
|
|
||||||
'create': 1,
|
|
||||||
'doctype': u'DocPerm',
|
'doctype': u'DocPerm',
|
||||||
'name': '__common__',
|
'name': '__common__',
|
||||||
'parent': u'Address',
|
'parent': u'Address',
|
||||||
'parentfield': u'permissions',
|
'parentfield': u'permissions',
|
||||||
'parenttype': u'DocType',
|
'parenttype': u'DocType',
|
||||||
'permlevel': 0,
|
'read': 1
|
||||||
'read': 1,
|
|
||||||
'role': u'All',
|
|
||||||
'write': 1
|
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocType, Address
|
# DocType, Address
|
||||||
@@ -59,7 +54,116 @@
|
|||||||
|
|
||||||
# DocPerm
|
# DocPerm
|
||||||
{
|
{
|
||||||
'doctype': u'DocPerm'
|
'cancel': 1,
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'System Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 1,
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Sales Master Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 1,
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Purchase Master Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Maintenance Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Accounts Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Sales Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Purchase Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Sales User',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Purchase User',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Maintenance User',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Accounts User',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 0,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 1,
|
||||||
|
'role': u'All',
|
||||||
|
'write': 0
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
|
|||||||
55
erpnext/utilities/doctype/address/listview.js
Normal file
55
erpnext/utilities/doctype/address/listview.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
wn.doclistviews['Address'] = wn.views.ListView.extend({
|
||||||
|
init: function(d) {
|
||||||
|
this._super(d)
|
||||||
|
this.fields = this.fields.concat([
|
||||||
|
"`tabAddress`.customer_name",
|
||||||
|
"`tabAddress`.supplier",
|
||||||
|
"`tabAddress`.supplier_name",
|
||||||
|
"`tabAddress`.sales_partner",
|
||||||
|
"`tabAddress`.city",
|
||||||
|
"`tabAddress`.country",
|
||||||
|
"ifnull(`tabAddress`.is_shipping_address, 0) as is_shipping_address",
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
|
prepare_data: function(data) {
|
||||||
|
this._super(data);
|
||||||
|
|
||||||
|
// prepare address
|
||||||
|
var address = []
|
||||||
|
$.each(['city', 'country'], function(i, v) {
|
||||||
|
if(data[v]) address.push(data[v]);
|
||||||
|
});
|
||||||
|
data.address = address.join(", ");
|
||||||
|
|
||||||
|
// prepare shipping tag
|
||||||
|
if(data.is_shipping_address) {
|
||||||
|
data.shipping = '<span class="label label-info">Shipping</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// prepare description
|
||||||
|
if(data.customer) {
|
||||||
|
data.description = (data.customer_name || data.customer);
|
||||||
|
data.contact_type = 'Customer';
|
||||||
|
} else if (data.supplier) {
|
||||||
|
data.description = (data.supplier_name || data.supplier);
|
||||||
|
data.contact_type = 'Supplier';
|
||||||
|
} else if (data.sales_partner) {
|
||||||
|
data.description = data.sales_partner;
|
||||||
|
data.contact_type = 'Sales Partner'
|
||||||
|
} else {
|
||||||
|
data.description = '';
|
||||||
|
data.contact_type = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
{width: '3%', content: 'check'},
|
||||||
|
{width: '20%', content: 'name'},
|
||||||
|
{width: '15%', content: 'contact_type'},
|
||||||
|
{width: '20%', content: 'description'},
|
||||||
|
{width: '30%', content: 'address+shipping+tags', css: {'padding': '2px 0px'}},
|
||||||
|
{width: '12%', content: 'modified', css: {'text-align': 'right', 'color':'#777'}}
|
||||||
|
]
|
||||||
|
});
|
||||||
@@ -21,7 +21,6 @@ from webnotes.model.doc import Document
|
|||||||
from webnotes import session, form, msgprint, errprint
|
from webnotes import session, form, msgprint, errprint
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, doc, doclist=[]):
|
def __init__(self, doc, doclist=[]):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
'creation': '2012-03-27 14:36:46',
|
'creation': '2012-07-02 19:57:48',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-03-27 14:36:46',
|
'modified': '2012-07-03 12:54:52',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'Administrator'
|
'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
'server_code_error': u' ',
|
'server_code_error': u' ',
|
||||||
'show_in_menu': 0,
|
'show_in_menu': 0,
|
||||||
'subject': u'%(first_name)s %(last_name)s - Email: %(email_id)s | Contact: %(phone)s | Mobile: %(mobile_no)s',
|
'subject': u'%(first_name)s %(last_name)s - Email: %(email_id)s | Contact: %(phone)s | Mobile: %(mobile_no)s',
|
||||||
'version': 245
|
'version': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# These values are common for all DocField
|
# These values are common for all DocField
|
||||||
@@ -54,6 +54,16 @@
|
|||||||
'name': u'Contact'
|
'name': u'Contact'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 1,
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'System Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
# DocPerm
|
# DocPerm
|
||||||
{
|
{
|
||||||
'amend': 0,
|
'amend': 0,
|
||||||
@@ -66,21 +76,6 @@
|
|||||||
'write': 1
|
'write': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'permlevel': 1,
|
|
||||||
'role': u'All',
|
|
||||||
'write': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'permlevel': 2,
|
|
||||||
'role': u'All'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
# DocPerm
|
||||||
{
|
{
|
||||||
'cancel': 1,
|
'cancel': 1,
|
||||||
@@ -93,26 +88,81 @@
|
|||||||
|
|
||||||
# DocPerm
|
# DocPerm
|
||||||
{
|
{
|
||||||
'cancel': 1,
|
|
||||||
'create': 1,
|
'create': 1,
|
||||||
'doctype': u'DocPerm',
|
'doctype': u'DocPerm',
|
||||||
'permlevel': 0,
|
'permlevel': 0,
|
||||||
'role': u'System Manager',
|
'role': u'Sales Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Purchase Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Maintenance Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Accounts Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Sales User',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Purchase User',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Maintenance User',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'create': 1,
|
||||||
|
'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Accounts User',
|
||||||
'write': 1
|
'write': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocPerm
|
# DocPerm
|
||||||
{
|
{
|
||||||
'doctype': u'DocPerm',
|
'doctype': u'DocPerm',
|
||||||
'permlevel': 0,
|
'permlevel': 1,
|
||||||
'role': u'Sales User'
|
'role': u'All'
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'permlevel': 0,
|
|
||||||
'role': u'Purchase User'
|
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
|
|||||||
50
erpnext/utilities/doctype/contact/listview.js
Normal file
50
erpnext/utilities/doctype/contact/listview.js
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
wn.doclistviews['Contact'] = wn.views.ListView.extend({
|
||||||
|
init: function(d) {
|
||||||
|
this._super(d)
|
||||||
|
this.fields = this.fields.concat([
|
||||||
|
"`tabContact`.first_name",
|
||||||
|
"`tabContact`.last_name",
|
||||||
|
"`tabContact`.customer",
|
||||||
|
"`tabContact`.customer_name",
|
||||||
|
"`tabContact`.supplier",
|
||||||
|
"`tabContact`.supplier_name",
|
||||||
|
"`tabContact`.sales_partner",
|
||||||
|
"`tabContact`.email_id",
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
|
prepare_data: function(data) {
|
||||||
|
this._super(data);
|
||||||
|
|
||||||
|
// prepare fullname
|
||||||
|
data.fullname = (data.first_name || '') +
|
||||||
|
(data.last_name ? ' ' + data.last_name : '');
|
||||||
|
if(!data.fullname) data.fullname = data.name;
|
||||||
|
data.fullname = repl("<a href='#!Form/Contact/%(name)s'>%(fullname)s\
|
||||||
|
</a>", data);
|
||||||
|
|
||||||
|
// prepare description
|
||||||
|
if(data.customer) {
|
||||||
|
data.description = (data.customer_name || data.customer);
|
||||||
|
data.contact_type = 'Customer';
|
||||||
|
} else if (data.supplier) {
|
||||||
|
data.description = (data.supplier_name || data.supplier);
|
||||||
|
data.contact_type = 'Supplier';
|
||||||
|
} else if (data.sales_partner) {
|
||||||
|
data.description = data.sales_partner;
|
||||||
|
data.contact_type = 'Sales Partner'
|
||||||
|
} else {
|
||||||
|
data.description = '';
|
||||||
|
data.contact_type = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
{width: '3%', content: 'check'},
|
||||||
|
{width: '20%', content: 'fullname'},
|
||||||
|
{width: '15%', content: 'contact_type'},
|
||||||
|
{width: '20%', content: 'description+tags'},
|
||||||
|
{width: '30%', content: 'email_id'},
|
||||||
|
{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
|
||||||
|
]
|
||||||
|
});
|
||||||
@@ -81,6 +81,10 @@ def update_security(args=''):
|
|||||||
webnotes.conn.set_value('Profile', args['user'], 'login_after', args.get('login_after') or None)
|
webnotes.conn.set_value('Profile', args['user'], 'login_after', args.get('login_after') or None)
|
||||||
webnotes.conn.set_value('Profile', args['user'], 'login_before', args.get('login_before') or None)
|
webnotes.conn.set_value('Profile', args['user'], 'login_before', args.get('login_before') or None)
|
||||||
webnotes.conn.set_value('Profile', args['user'], 'enabled', int(args.get('enabled',0)) or 0)
|
webnotes.conn.set_value('Profile', args['user'], 'enabled', int(args.get('enabled',0)) or 0)
|
||||||
|
|
||||||
|
# logout a disabled user
|
||||||
|
if not int(args.get('enabled',0) or 0):
|
||||||
|
webnotes.login_manager.logout(user=args['user'])
|
||||||
|
|
||||||
if args.get('new_password') and args.get('sys_admin_pwd'):
|
if args.get('new_password') and args.get('sys_admin_pwd'):
|
||||||
from webnotes.utils import cint
|
from webnotes.utils import cint
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ class TransactionBase:
|
|||||||
# Get Sales Person Details of Customer
|
# Get Sales Person Details of Customer
|
||||||
# ------------------------------------
|
# ------------------------------------
|
||||||
def get_sales_person(self, name):
|
def get_sales_person(self, name):
|
||||||
self.doc.clear_table(self.doclist,'sales_team')
|
self.doclist = self.doc.clear_table(self.doclist,'sales_team')
|
||||||
idx = 0
|
idx = 0
|
||||||
for d in webnotes.conn.sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % name):
|
for d in webnotes.conn.sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % name):
|
||||||
ch = addchild(self.doc, 'sales_team', 'Sales Team', 1, self.doclist)
|
ch = addchild(self.doc, 'sales_team', 'Sales Team', 1, self.doclist)
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(op
|
|||||||
return;}
|
return;}
|
||||||
if(r.server_messages)msgprint(r.server_messages)
|
if(r.server_messages)msgprint(r.server_messages)
|
||||||
if(r.exc){console.log(r.exc);};if(r['403']){wn.container.change_to('403');}
|
if(r.exc){console.log(r.exc);};if(r['403']){wn.container.change_to('403');}
|
||||||
if(r.docs)LocalDB.sync(r.docs);}
|
if(r.docs){LocalDB.sync(r.docs);}}
|
||||||
wn.request.call=function(opts){wn.request.prepare(opts);$.ajax({url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus)
|
wn.request.call=function(opts){wn.request.prepare(opts);$.ajax({url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus)
|
||||||
if(opts.error)opts.error(xhr)}})}
|
if(opts.error)opts.error(xhr)}})}
|
||||||
wn.call=function(opts){var args=$.extend({},opts.args)
|
wn.call=function(opts){var args=$.extend({},opts.args)
|
||||||
@@ -734,19 +734,20 @@ return v;};function LinkField(){}LinkField.prototype=new Field();LinkField.proto
|
|||||||
$(me.btn2).css('display','inline-block');else $dh(me.btn2);}}
|
$(me.btn2).css('display','inline-block');else $dh(me.btn2);}}
|
||||||
me.txt.field_object=this;me.input.set_input=function(val){if(val==undefined)val='';me.txt.value=val;}
|
me.txt.field_object=this;me.input.set_input=function(val){if(val==undefined)val='';me.txt.value=val;}
|
||||||
me.get_value=function(){return me.txt.value;}
|
me.get_value=function(){return me.txt.value;}
|
||||||
$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('<li></li>').data('item.autocomplete',item).append(repl('<a>%(label)s<br><span style="font-size:10px">%(info)s</span></a>',item)).appendTo(ul);};$(this.txt).change(function(){if(!$(this).val()){if(selector&&selector.display)
|
$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('<li></li>').data('item.autocomplete',item).append(repl('<a>%(label)s<br><span style="font-size:10px">%(info)s</span></a>',item)).appendTo(ul);};$(this.txt).change(function(){var val=$(this).val();me.set_input_value_executed=false;if(!val){if(selector&&selector.display)
|
||||||
return;me.set_input_value('');}})}
|
return;me.set_input_value('');}else{setTimeout(function(){if(!me.set_input_value_executed){me.set_input_value(val);}},100);}})}
|
||||||
LinkField.prototype.get_custom_query=function(){this.set_get_query();if(this.get_query){if(cur_frm)
|
LinkField.prototype.get_custom_query=function(){this.set_get_query();if(this.get_query){if(cur_frm)
|
||||||
var doc=locals[cur_frm.doctype][cur_frm.docname];return this.get_query(doc,this.doctype,this.docname);}}
|
var doc=locals[cur_frm.doctype][cur_frm.docname];return this.get_query(doc,this.doctype,this.docname);}}
|
||||||
LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);}
|
LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);}
|
||||||
if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}}
|
if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}}
|
||||||
me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}}
|
me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}}
|
||||||
_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
|
_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
|
||||||
LinkField.prototype.set_input_value=function(val){var me=this;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;}
|
LinkField.prototype.set_input_value=function(val){var me=this;me.set_input_value_executed=true;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;}
|
||||||
if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}}
|
if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}}
|
||||||
me.set(val);if(_f.cur_grid_cell)
|
me.set(val);if(_f.cur_grid_cell)
|
||||||
_f.cur_grid_cell.grid.cell_deselect();if(locals[me.doctype][me.docname][me.df.fieldname]&&!val){me.run_trigger();return;}
|
_f.cur_grid_cell.grid.cell_deselect();if(locals[me.doctype][me.docname][me.df.fieldname]&&!val){me.run_trigger();return;}
|
||||||
var fetch='';if(cur_frm.fetch_dict[me.df.fieldname])
|
me.validate_link(val,from_selector);}
|
||||||
|
LinkField.prototype.validate_link=function(val,from_selector){var me=this;var fetch='';if(cur_frm.fetch_dict[me.df.fieldname])
|
||||||
fetch=cur_frm.fetch_dict[me.df.fieldname].columns.join(', ');$c('webnotes.widgets.form.utils.validate_link',{'value':val,'options':me.df.options,'fetch':fetch},function(r,rt){if(r.message=='Ok'){if($(me.txt).val()!=val){if((me.grid&&!from_selector)||(!me.grid)){$(me.txt).val(val);}}
|
fetch=cur_frm.fetch_dict[me.df.fieldname].columns.join(', ');$c('webnotes.widgets.form.utils.validate_link',{'value':val,'options':me.df.options,'fetch':fetch},function(r,rt){if(r.message=='Ok'){if($(me.txt).val()!=val){if((me.grid&&!from_selector)||(!me.grid)){$(me.txt).val(val);}}
|
||||||
if(r.fetch_values)
|
if(r.fetch_values)
|
||||||
me.set_fetch_values(r.fetch_values);me.run_trigger();}else{var astr='';if(in_list(profile.can_create,me.df.options))astr=repl('<br><br><span class="link_type" onclick="newdoc(\'%(dt)s\')">Click here</span> to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)})
|
me.set_fetch_values(r.fetch_values);me.run_trigger();}else{var astr='';if(in_list(profile.can_create,me.df.options))astr=repl('<br><br><span class="link_type" onclick="newdoc(\'%(dt)s\')">Click here</span> to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)})
|
||||||
@@ -966,13 +967,13 @@ wn.views.DocListView=wn.ui.Listing.extend({init:function(doctype){this.doctype=d
|
|||||||
<div style="clear: both"></div>\
|
<div style="clear: both"></div>\
|
||||||
</div>');this.appframe=new wn.ui.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs($('<span class="breadcrumb-area">').appendTo(this.appframe.$titlebar),locals.DocType[this.doctype].module,this.doctype);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.make_report_button();me.add_delete_option();},make_report_button:function(){var me=this;if(wn.boot.profile.can_get_report.indexOf(this.doctype)!=-1){this.appframe.add_button('Build Report',function(){wn.set_route('Report2',me.doctype);},'icon-th')}},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1
|
</div>');this.appframe=new wn.ui.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs($('<span class="breadcrumb-area">').appendTo(this.appframe.$titlebar),locals.DocType[this.doctype].module,this.doctype);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.make_report_button();me.add_delete_option();},make_report_button:function(){var me=this;if(wn.boot.profile.can_get_report.indexOf(this.doctype)!=-1){this.appframe.add_button('Build Report',function(){wn.set_route('Report2',me.doctype);},'icon-th')}},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1
|
||||||
else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);}
|
else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);}
|
||||||
this.listview.parent=this;this.wrapper=this.$page.find('.wnlist-area');this.page_length=20;this.allow_delete=true;},init_list:function(auto_run){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.wrapper,start:0,page_length:this.page_length,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:this.allow_delete,no_result_message:this.make_no_result(),columns:this.listview.fields});if((auto_run!==false)&&(auto_run!==0))this.run();},make_no_result:function(){return repl('<div class="well"><p>No %(doctype_label)s found</p>\
|
this.listview.parent=this;this.wrapper=this.$page.find('.wnlist-area');this.page_length=20;this.allow_delete=true;},init_list:function(auto_run){var me=this;this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.wrapper,start:0,page_length:this.page_length,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:this.allow_delete,no_result_message:this.make_no_result(),columns:this.listview.fields});$(this.wrapper).find('button[list_view_doc="'+me.doctype+'"]').click(function(){me.make_new_doc(me.doctype);});if((auto_run!==false)&&(auto_run!==0))this.run();},make_no_result:function(){var no_result_message=repl('<div class="well">\
|
||||||
|
<p>No %(doctype_label)s found</p>\
|
||||||
%(description)s\
|
%(description)s\
|
||||||
<hr>\
|
<hr>\
|
||||||
<p><button class="btn btn-info btn-small"\
|
<p><button class="btn btn-info btn-small" list_view_doc="%(doctype)s">\
|
||||||
onclick="newdoc(\'%(doctype)s\');"\
|
Make a new %(doctype_label)s</button>\
|
||||||
>Make a new %(doctype_label)s</button>\
|
</p></div>',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||''),});return no_result_message;},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[],order_by:this.listview.order_by||undefined,}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length)
|
||||||
</p></div>',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||'')});},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[],order_by:this.listview.order_by||undefined,}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length)
|
|
||||||
return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;}
|
return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;}
|
||||||
me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this
|
me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this
|
||||||
wn.call({method:'webnotes.widgets.doclistview.get_stats',args:{stats:me.listview.stats,doctype:me.doctype},callback:function(r){$.each(me.listview.stats,function(i,v){me.render_stat(v,r.message[v]);});if(me.listview.stats.length){$('<button class="btn btn-small"><i class="refresh"></i> Refresh</button>').click(function(){me.reload_stats();}).appendTo($('<div class="stat-wrapper">').appendTo(me.$page.find('.layout-side-section')))}}});},render_stat:function(field,stat){var me=this;if(!stat||!stat.length){if(field=='_user_tags'){this.$page.find('.layout-side-section').append('<div class="stat-wrapper"><h4>Tags</h4>\
|
wn.call({method:'webnotes.widgets.doclistview.get_stats',args:{stats:me.listview.stats,doctype:me.doctype},callback:function(r){$.each(me.listview.stats,function(i,v){me.render_stat(v,r.message[v]);});if(me.listview.stats.length){$('<button class="btn btn-small"><i class="refresh"></i> Refresh</button>').click(function(){me.reload_stats();}).appendTo($('<div class="stat-wrapper">').appendTo(me.$page.find('.layout-side-section')))}}});},render_stat:function(field,stat){var me=this;if(!stat||!stat.length){if(field=='_user_tags'){this.$page.find('.layout-side-section').append('<div class="stat-wrapper"><h4>Tags</h4>\
|
||||||
@@ -1013,11 +1014,10 @@ $(parent).append(repl('<span class="bar-outer" style="width: 30px; float: right"
|
|||||||
else if(opts.type=='link'&&opts.doctype){$(parent).append(repl('<a href="#!Form/'+opts.doctype+'/'
|
else if(opts.type=='link'&&opts.doctype){$(parent).append(repl('<a href="#!Form/'+opts.doctype+'/'
|
||||||
+data[opts.content]+'">'+data[opts.content]+'</a>',data));}
|
+data[opts.content]+'">'+data[opts.content]+'</a>',data));}
|
||||||
else if(opts.template){$(parent).append(repl(opts.template,data));}
|
else if(opts.template){$(parent).append(repl(opts.template,data));}
|
||||||
else if(data[opts.content]){$(parent).append(' '+data[opts.content]);}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('<td style="width: %(width)s"></td>',v);});var tr=$(row).html('<table><tbody><tr>'+rowhtml+'</tr></tbody></table>').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;data.when=dateutil.str_to_user(data.modified).split(' ')[0];var diff=dateutil.get_diff(dateutil.get_today(),data.modified.split(' ')[0]);if(diff==0){data.when=dateutil.comment_when(data.modified);}
|
else if(data[opts.content]){$(parent).append(' '+data[opts.content]);}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('<td style="width: %(width)s"></td>',v);});var tr=$(row).html('<table><tbody><tr>'+rowhtml+'</tr></tbody></table>').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;this.prepare_when(data,data.modified);if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';}
|
||||||
|
for(key in data){if(data[key]==null){data[key]='';}}},prepare_when:function(data,date_str){if(!date_str)date_str=data.modified;data.when=dateutil.str_to_user(date_str).split(' ')[0];var diff=dateutil.get_diff(dateutil.get_today(),date_str.split(' ')[0]);if(diff==0){data.when=dateutil.comment_when(date_str);}
|
||||||
if(diff==1){data.when='Yesterday'}
|
if(diff==1){data.when='Yesterday'}
|
||||||
if(diff==2){data.when='2 days ago'}
|
if(diff==2){data.when='2 days ago'}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){if($(parent).html().length>0){$(parent).append('<br />');}
|
||||||
if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';}
|
|
||||||
for(key in data){if(data[key]==null){data[key]='';}}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){if($(parent).html().length>0){$(parent).append('<br />');}
|
|
||||||
$.each(data._user_tags.split(','),function(i,t){if(t){$('<span class="label label-info" style="cursor: pointer; line-height: 200%">'
|
$.each(data._user_tags.split(','),function(i,t){if(t){$('<span class="label label-info" style="cursor: pointer; line-height: 200%">'
|
||||||
+strip(t)+'</span>').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}});wn.provide('wn.views.RecordListView');wn.views.RecordListView=wn.views.DocListView.extend({init:function(doctype,wrapper,ListView){this.doctype=doctype;this.wrapper=wrapper;this.listview=new ListView(this);this.listview.parent=this;this.setup();},setup:function(){var me=this;me.page_length=10;$(me.wrapper).empty();me.init_list();},get_args:function(){var args=this._super();$.each((this.default_filters||[]),function(i,f){args.filters.push(f);});args.docstatus=args.docstatus.concat((this.default_docstatus||[]));return args;},});
|
+strip(t)+'</span>').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}});wn.provide('wn.views.RecordListView');wn.views.RecordListView=wn.views.DocListView.extend({init:function(doctype,wrapper,ListView){this.doctype=doctype;this.wrapper=wrapper;this.listview=new ListView(this);this.listview.parent=this;this.setup();},setup:function(){var me=this;me.page_length=10;$(me.wrapper).empty();me.init_list();},get_args:function(){var args=this._super();$.each((this.default_filters||[]),function(i,f){args.filters.push(f);});args.docstatus=args.docstatus.concat((this.default_docstatus||[]));return args;},});
|
||||||
/*
|
/*
|
||||||
@@ -1025,21 +1025,22 @@ $.each(data._user_tags.split(','),function(i,t){if(t){$('<span class="label labe
|
|||||||
*/
|
*/
|
||||||
wn.provide('wn.views.formview');wn.views.formview={show:function(dt,dn){if(wn.model.new_names[dn])
|
wn.provide('wn.views.formview');wn.views.formview={show:function(dt,dn){if(wn.model.new_names[dn])
|
||||||
dn=wn.model.new_names[dn];wn.model.with_doctype(dt,function(){wn.model.with_doc(dt,dn,function(dn,r){if(r&&r['403'])return;if(!(locals[dt]&&locals[dt][dn])){wn.container.change_to('404');return;}
|
dn=wn.model.new_names[dn];wn.model.with_doctype(dt,function(){wn.model.with_doc(dt,dn,function(dn,r){if(r&&r['403'])return;if(!(locals[dt]&&locals[dt][dn])){wn.container.change_to('404');return;}
|
||||||
if(!wn.views.formview[dt]){wn.views.formview[dt]=wn.container.add_page('Form - '+dt);wn.views.formview[dt].frm=new _f.Frm(dt,wn.views.formview[dt]);}
|
if(!wn.views.formview[dt]){wn.views.formview[dt]=wn.container.add_page('Form - '+dt);wn.views.formview[dt].frm=new _f.Frm(dt,wn.views.formview[dt],true);}
|
||||||
wn.container.change_to('Form - '+dt);wn.views.formview[dt].frm.refresh(dn);});})},create:function(dt){var new_name=LocalDB.create(dt);wn.set_route('Form',dt,new_name);}}
|
wn.container.change_to('Form - '+dt);wn.views.formview[dt].frm.refresh(dn);});})},create:function(dt){var new_name=LocalDB.create(dt);wn.set_route('Form',dt,new_name);}}
|
||||||
/*
|
/*
|
||||||
* lib/js/wn/views/reportview.js
|
* lib/js/wn/views/reportview.js
|
||||||
*/
|
*/
|
||||||
wn.views.reportview={show:function(dt,rep_name){wn.require('js/report-legacy.js');dt=get_label_doctype(dt);if(!_r.rb_con){_r.rb_con=new _r.ReportContainer();}
|
wn.views.reportview={show:function(dt,rep_name){wn.require('js/report-legacy.js');dt=get_label_doctype(dt);if(!_r.rb_con){_r.rb_con=new _r.ReportContainer();}
|
||||||
_r.rb_con.set_dt(dt,function(rb){if(rep_name){var t=rb.current_loaded;rb.load_criteria(rep_name);if((rb.dt)&&(!rb.dt.has_data()||rb.current_loaded!=t)){rb.dt.run();}}
|
_r.rb_con.set_dt(dt,function(rb){if(rep_name){var route_changed=(rb.current_route!=wn.get_route_str())
|
||||||
|
rb.load_criteria(rep_name);if(rb.dt&&route_changed){rb.dt.run();}}
|
||||||
if(!rb.forbidden){wn.container.change_to('Report Builder');}});}}
|
if(!rb.forbidden){wn.container.change_to('Report Builder');}});}}
|
||||||
wn.views.reportview2={show:function(dt){var page_name=wn.get_route_str();if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{var route=wn.get_route();if(route[1]){new wn.views.ReportViewPage(route[1],route[2]);}else{wn.set_route('404');}}}}
|
wn.views.reportview2={show:function(dt){var page_name=wn.get_route_str();if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{var route=wn.get_route();if(route[1]){new wn.views.ReportViewPage(route[1],route[2]);}else{wn.set_route('404');}}}}
|
||||||
wn.views.ReportViewPage=Class.extend({init:function(doctype,docname){this.doctype=doctype;this.docname=docname;this.page_name=wn.get_route_str();this.make_page();var me=this;wn.model.with_doctype(doctype,function(){me.make_report_view();if(docname){wn.model.with_doc('Report',docname,function(r){me.reportview.set_columns_and_filters(JSON.parse(locals['Report'][docname].json));me.reportview.run();});}else{me.reportview.run();}});},make_page:function(){this.page=wn.container.add_page(this.page_name);wn.ui.make_app_page({parent:this.page,single_column:true});wn.container.change_to(this.page_name);},make_report_view:function(){wn.views.breadcrumbs($('<span>').appendTo(this.page.appframe.$titlebar),locals.DocType[this.doctype].module);this.reportview=new wn.views.ReportView(this.doctype,this.docname,this.page)}})
|
wn.views.ReportViewPage=Class.extend({init:function(doctype,docname){this.doctype=doctype;this.docname=docname;this.page_name=wn.get_route_str();this.make_page();var me=this;wn.model.with_doctype(doctype,function(){me.make_report_view();if(docname){wn.model.with_doc('Report',docname,function(r){me.reportview.set_columns_and_filters(JSON.parse(locals['Report'][docname].json));me.reportview.run();});}else{me.reportview.run();}});},make_page:function(){this.page=wn.container.add_page(this.page_name);wn.ui.make_app_page({parent:this.page,single_column:true});wn.container.change_to(this.page_name);},make_report_view:function(){wn.views.breadcrumbs($('<span>').appendTo(this.page.appframe.$titlebar),locals.DocType[this.doctype].module);this.reportview=new wn.views.ReportView(this.doctype,this.docname,this.page)}})
|
||||||
wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype,docname,page){var me=this;$(page).find('.layout-main').html('Loading Report...');this.import_slickgrid();$(page).find('.layout-main').empty();this.doctype=doctype;this.docname=docname;this.page=page;this.tab_name='`tab'+doctype+'`';this.setup();},import_slickgrid:function(){wn.require('js/lib/slickgrid/slick.grid.css');wn.require('js/lib/slickgrid/slick-default-theme.css');wn.require('js/lib/slickgrid/jquery.event.drag.min.js');wn.require('js/lib/slickgrid/slick.core.js');wn.require('js/lib/slickgrid/slick.grid.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');},set_init_columns:function(){var columns=[['name'],['owner']];$.each(wn.meta.docfield_list[this.doctype],function(i,df){if(df.in_filter&&df.fieldname!='naming_series'&&df.fieldtype!='Table'){columns.push([df.fieldname]);}});this.columns=columns;},setup:function(){var me=this;this.make({title:'Report: '+(this.docname?(this.doctype+' - '+this.docname):this.doctype),appframe:this.page.appframe,method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:$(this.page).find('.layout-main'),start:0,page_length:20,show_filters:true,new_doctype:this.doctype,allow_delete:true,});this.make_column_picker();this.make_sorter();this.make_export();this.set_init_columns();this.make_save();},set_columns_and_filters:function(opts){var me=this;if(opts.columns)this.columns=opts.columns;if(opts.filters)$.each(opts.filters,function(i,f){me.filter_list.add_filter(f[1],f[2],f[3]);});if(opts.sort_by)this.sort_by_select.val(opts.sort_by);if(opts.sort_order)this.sort_order_select.val(opts.sort_order);if(opts.sort_by_next)this.sort_by_next_select.val(opts.sort_by_next);if(opts.sort_order_next)this.sort_order_next_select.val(opts.sort_order_next);},get_args:function(){var me=this;return{doctype:this.doctype,fields:$.map(this.columns,function(v){return me.get_full_column_name(v)}),order_by:this.get_order_by(),filters:this.filter_list.get_filters(),docstatus:['0','1','2']}},get_order_by:function(){var order_by=this.get_full_column_name([this.sort_by_select.val()])
|
wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype,docname,page){var me=this;$(page).find('.layout-main').html('Loading Report...');this.import_slickgrid();$(page).find('.layout-main').empty();this.doctype=doctype;this.docname=docname;this.page=page;this.tab_name='`tab'+doctype+'`';this.setup();},import_slickgrid:function(){wn.require('js/lib/slickgrid/slick.grid.css');wn.require('js/lib/slickgrid/slick-default-theme.css');wn.require('js/lib/slickgrid/jquery.event.drag.min.js');wn.require('js/lib/slickgrid/slick.core.js');wn.require('js/lib/slickgrid/slick.grid.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');},set_init_columns:function(){var columns=[['name'],['owner']];$.each(wn.meta.docfield_list[this.doctype],function(i,df){if(df.in_filter&&df.fieldname!='naming_series'&&df.fieldtype!='Table'){columns.push([df.fieldname]);}});this.columns=columns;},setup:function(){var me=this;this.make({title:'Report: '+(this.docname?(this.doctype+' - '+this.docname):this.doctype),appframe:this.page.appframe,method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:$(this.page).find('.layout-main'),start:0,page_length:20,show_filters:true,new_doctype:this.doctype,allow_delete:true,});this.make_column_picker();this.make_sorter();this.make_export();this.set_init_columns();this.make_save();},set_columns_and_filters:function(opts){var me=this;if(opts.columns)this.columns=opts.columns;if(opts.filters)$.each(opts.filters,function(i,f){me.filter_list.add_filter(f[1],f[2],f[3]);});if(opts.sort_by)this.sort_by_select.val(opts.sort_by);if(opts.sort_order)this.sort_order_select.val(opts.sort_order);if(opts.sort_by_next)this.sort_by_next_select.val(opts.sort_by_next);if(opts.sort_order_next)this.sort_order_next_select.val(opts.sort_order_next);},get_args:function(){var me=this;return{doctype:this.doctype,fields:$.map(this.columns,function(v){return me.get_full_column_name(v)}),order_by:this.get_order_by(),filters:this.filter_list.get_filters(),docstatus:['0','1','2']}},get_order_by:function(){var order_by=this.get_selected_table_and_column(this.sort_by_select)
|
||||||
+' '+this.sort_order_select.val()
|
+' '+this.sort_order_select.val()
|
||||||
if(this.sort_by_next_select.val()){order_by+=', '+this.get_full_column_name([this.sort_by_next_select.val()])
|
if(this.sort_by_next_select.val()){order_by+=', '+this.get_selected_table_and_column(this.sort_by_next_select)
|
||||||
+' '+this.sort_order_next_select.val()}
|
+' '+this.sort_order_next_select.val()}
|
||||||
return order_by;},get_full_column_name:function(v){return(v[1]?('`tab'+v[1]+'`'):this.tab_name)+'.'+v[0];},build_columns:function(){var me=this;return $.map(this.columns,function(c){var docfield=wn.meta.docfield_map[c[1]||me.doctype][c[0]];coldef={id:c[0],field:c[0],docfield:docfield,name:(docfield?docfield.label:toTitle(c[0])),width:(docfield?cint(docfield.width):120)||120}
|
return order_by;},get_selected_table_and_column:function($select){return this.get_full_column_name([$select.val(),$select.find('option:selected').attr('table')])},get_full_column_name:function(v){return(v[1]?('`tab'+v[1]+'`'):this.tab_name)+'.'+v[0];},build_columns:function(){var me=this;return $.map(this.columns,function(c){var docfield=wn.meta.docfield_map[c[1]||me.doctype][c[0]];coldef={id:c[0],field:c[0],docfield:docfield,name:(docfield?docfield.label:toTitle(c[0])),width:(docfield?cint(docfield.width):120)||120}
|
||||||
if(c[0]=='name'){coldef.formatter=function(row,cell,value,columnDef,dataContext){return repl("<a href='#!Form/%(doctype)s/%(name)s'>%(name)s</a>",{doctype:me.doctype,name:value});}}else if(docfield&&docfield.fieldtype=='Link'){coldef.formatter=function(row,cell,value,columnDef,dataContext){if(value){return repl("<a href='#!Form/%(doctype)s/%(name)s'>%(name)s</a>",{doctype:columnDef.docfield.options,name:value});}else{return'';}}}
|
if(c[0]=='name'){coldef.formatter=function(row,cell,value,columnDef,dataContext){return repl("<a href='#!Form/%(doctype)s/%(name)s'>%(name)s</a>",{doctype:me.doctype,name:value});}}else if(docfield&&docfield.fieldtype=='Link'){coldef.formatter=function(row,cell,value,columnDef,dataContext){if(value){return repl("<a href='#!Form/%(doctype)s/%(name)s'>%(name)s</a>",{doctype:columnDef.docfield.options,name:value});}else{return'';}}}
|
||||||
return coldef;});},render_list:function(){var me=this;var columns=[{id:'_idx',field:'_idx',name:'Sr.',width:40}].concat(this.build_columns());$.each(this.data,function(i,v){v._idx=i+1;});var options={enableCellNavigation:true,enableColumnReorder:false};var grid=new Slick.Grid(this.$w.find('.result-list').css('border','1px solid grey').css('height','500px').get(0),this.data,columns,options);},make_column_picker:function(){var me=this;this.column_picker=new wn.ui.ColumnPicker(this);this.page.appframe.add_button('Pick Columns',function(){me.column_picker.show(me.columns);},'icon-th-list');},make_sorter:function(){var me=this;this.sort_dialog=new wn.ui.Dialog({title:'Sorting Preferences'});$(this.sort_dialog.body).html('<p class="help">Sort By</p>\
|
return coldef;});},render_list:function(){var me=this;var columns=[{id:'_idx',field:'_idx',name:'Sr.',width:40}].concat(this.build_columns());$.each(this.data,function(i,v){v._idx=i+1;});var options={enableCellNavigation:true,enableColumnReorder:false};var grid=new Slick.Grid(this.$w.find('.result-list').css('border','1px solid grey').css('height','500px').get(0),this.data,columns,options);},make_column_picker:function(){var me=this;this.column_picker=new wn.ui.ColumnPicker(this);this.page.appframe.add_button('Pick Columns',function(){me.column_picker.show(me.columns);},'icon-th-list');},make_sorter:function(){var me=this;this.sort_dialog=new wn.ui.Dialog({title:'Sorting Preferences'});$(this.sort_dialog.body).html('<p class="help">Sort By</p>\
|
||||||
<div class="sort-column"></div>\
|
<div class="sort-column"></div>\
|
||||||
@@ -1311,8 +1312,10 @@ LocalDB.add=function(dt,dn){if(!locals[dt])locals[dt]={};if(locals[dt][dn])delet
|
|||||||
LocalDB.delete_doc=function(dt,dn){var doc=get_local(dt,dn);for(var ndt in locals){if(locals[ndt]){for(var ndn in locals[ndt]){var doc=locals[ndt][ndn];if(doc&&doc.parenttype==dt&&(doc.parent==dn||doc.__oldparent==dn)){delete locals[ndt][ndn];}}}}
|
LocalDB.delete_doc=function(dt,dn){var doc=get_local(dt,dn);for(var ndt in locals){if(locals[ndt]){for(var ndn in locals[ndt]){var doc=locals[ndt][ndn];if(doc&&doc.parenttype==dt&&(doc.parent==dn||doc.__oldparent==dn)){delete locals[ndt][ndn];}}}}
|
||||||
delete locals[dt][dn];}
|
delete locals[dt][dn];}
|
||||||
function get_local(dt,dn){return locals[dt]?locals[dt][dn]:null;}
|
function get_local(dt,dn){return locals[dt]?locals[dt][dn]:null;}
|
||||||
LocalDB.sync=function(list){if(list._kl)list=expand_doclist(list);for(var i=0;i<list.length;i++){var d=list[i];if(!d.name)
|
LocalDB.sync=function(list){if(list._kl)list=expand_doclist(list);if(list){LocalDB.clear_locals(list[0].doctype,list[0].name);}
|
||||||
|
for(var i=0;i<list.length;i++){var d=list[i];if(!d.name)
|
||||||
d.name=LocalDB.get_localname(d.doctype);LocalDB.add(d.doctype,d.name);locals[d.doctype][d.name]=d;if(d.doctype=='DocField')wn.meta.add_field(d);if(d.localname){wn.model.new_names[d.localname]=d.name;$(document).trigger('rename',[d.doctype,d.localname,d.name]);delete locals[d.doctype][d.localname];}}}
|
d.name=LocalDB.get_localname(d.doctype);LocalDB.add(d.doctype,d.name);locals[d.doctype][d.name]=d;if(d.doctype=='DocField')wn.meta.add_field(d);if(d.localname){wn.model.new_names[d.localname]=d.name;$(document).trigger('rename',[d.doctype,d.localname,d.name]);delete locals[d.doctype][d.localname];}}}
|
||||||
|
LocalDB.clear_locals=function(dt,dn){var doclist=make_doclist(dt,dn,1);$.each(doclist,function(i,v){v&&delete locals[v.doctype][v.name];});}
|
||||||
local_name_idx={};LocalDB.get_localname=function(doctype){if(!local_name_idx[doctype])local_name_idx[doctype]=1;var n='New '+get_doctype_label(doctype)+' '+local_name_idx[doctype];local_name_idx[doctype]++;return n;}
|
local_name_idx={};LocalDB.get_localname=function(doctype){if(!local_name_idx[doctype])local_name_idx[doctype]=1;var n='New '+get_doctype_label(doctype)+' '+local_name_idx[doctype];local_name_idx[doctype]++;return n;}
|
||||||
LocalDB.set_default_values=function(doc){var doctype=doc.doctype;var docfields=wn.meta.docfield_list[doctype];if(!docfields){return;}
|
LocalDB.set_default_values=function(doc){var doctype=doc.doctype;var docfields=wn.meta.docfield_list[doctype];if(!docfields){return;}
|
||||||
var fields_to_refresh=[];for(var fid=0;fid<docfields.length;fid++){var f=docfields[fid];if(!in_list(no_value_fields,f.fieldtype)&&doc[f.fieldname]==null){var v=LocalDB.get_default_value(f.fieldname,f.fieldtype,f['default']);if(v){doc[f.fieldname]=v;fields_to_refresh.push(f.fieldname);}}}
|
var fields_to_refresh=[];for(var fid=0;fid<docfields.length;fid++){var f=docfields[fid];if(!in_list(no_value_fields,f.fieldtype)&&doc[f.fieldname]==null){var v=LocalDB.get_default_value(f.fieldname,f.fieldtype,f['default']);if(v){doc[f.fieldname]=v;fields_to_refresh.push(f.fieldname);}}}
|
||||||
@@ -1342,7 +1345,8 @@ return sys_defaults[fn];}
|
|||||||
LocalDB.add_child=function(doc,childtype,parentfield){var n=LocalDB.create(childtype);var d=locals[childtype][n];d.parent=doc.name;d.parentfield=parentfield;d.parenttype=doc.doctype;return d;}
|
LocalDB.add_child=function(doc,childtype,parentfield){var n=LocalDB.create(childtype);var d=locals[childtype][n];d.parent=doc.name;d.parentfield=parentfield;d.parenttype=doc.doctype;return d;}
|
||||||
LocalDB.no_copy_list=['amended_from','amendment_date','cancel_reason'];LocalDB.copy=function(dt,dn,from_amend){var newdoc=LocalDB.create(dt);for(var key in locals[dt][dn]){var df=get_field(dt,key);if(key!=='name'&&key.substr(0,2)!='__'&&!(df&&((!from_amend&&cint(df.no_copy)==1)||in_list(LocalDB.no_copy_list,df.fieldname)))){locals[dt][newdoc][key]=locals[dt][dn][key];}}
|
LocalDB.no_copy_list=['amended_from','amendment_date','cancel_reason'];LocalDB.copy=function(dt,dn,from_amend){var newdoc=LocalDB.create(dt);for(var key in locals[dt][dn]){var df=get_field(dt,key);if(key!=='name'&&key.substr(0,2)!='__'&&!(df&&((!from_amend&&cint(df.no_copy)==1)||in_list(LocalDB.no_copy_list,df.fieldname)))){locals[dt][newdoc][key]=locals[dt][dn][key];}}
|
||||||
return locals[dt][newdoc];}
|
return locals[dt][newdoc];}
|
||||||
function make_doclist(dt,dn,deleted){var dl=[];dl[0]=locals[dt][dn];for(var ndt in locals){if(locals[ndt]){for(var ndn in locals[ndt]){var doc=locals[ndt][ndn];if(doc&&doc.parenttype==dt&&(doc.parent==dn||(deleted&&doc.__oldparent==dn))){dl[dl.length]=doc;}}}}
|
function make_doclist(dt,dn,deleted){if(!locals[dt]){return[];}
|
||||||
|
var dl=[];dl[0]=locals[dt][dn];for(var ndt in locals){if(locals[ndt]){for(var ndn in locals[ndt]){var doc=locals[ndt][ndn];if(doc&&doc.parenttype==dt&&(doc.parent==dn||(deleted&&doc.__oldparent==dn))){dl[dl.length]=doc;}}}}
|
||||||
return dl;}
|
return dl;}
|
||||||
var Meta={};var local_dt={};Meta.make_local_dt=function(dt,dn){var dl=make_doclist('DocType',dt);if(!local_dt[dt])local_dt[dt]={};if(!local_dt[dt][dn])local_dt[dt][dn]={};for(var i=0;i<dl.length;i++){var d=dl[i];if(d.doctype=='DocField'){var key=d.fieldname?d.fieldname:d.label;local_dt[dt][dn][key]=copy_dict(d);}}}
|
var Meta={};var local_dt={};Meta.make_local_dt=function(dt,dn){var dl=make_doclist('DocType',dt);if(!local_dt[dt])local_dt[dt]={};if(!local_dt[dt][dn])local_dt[dt][dn]={};for(var i=0;i<dl.length;i++){var d=dl[i];if(d.doctype=='DocField'){var key=d.fieldname?d.fieldname:d.label;local_dt[dt][dn][key]=copy_dict(d);}}}
|
||||||
Meta.get_field=function(dt,fn,dn){if(dn&&local_dt[dt]&&local_dt[dt][dn]){return local_dt[dt][dn][fn];}else{if(wn.meta.docfield_map[dt])var d=wn.meta.docfield_map[dt][fn];if(d)return d;}
|
Meta.get_field=function(dt,fn,dn){if(dn&&local_dt[dt]&&local_dt[dt][dn]){return local_dt[dt][dn][fn];}else{if(wn.meta.docfield_map[dt])var d=wn.meta.docfield_map[dt][fn];if(d)return d;}
|
||||||
@@ -1557,19 +1561,20 @@ return v;};function LinkField(){}LinkField.prototype=new Field();LinkField.proto
|
|||||||
$(me.btn2).css('display','inline-block');else $dh(me.btn2);}}
|
$(me.btn2).css('display','inline-block');else $dh(me.btn2);}}
|
||||||
me.txt.field_object=this;me.input.set_input=function(val){if(val==undefined)val='';me.txt.value=val;}
|
me.txt.field_object=this;me.input.set_input=function(val){if(val==undefined)val='';me.txt.value=val;}
|
||||||
me.get_value=function(){return me.txt.value;}
|
me.get_value=function(){return me.txt.value;}
|
||||||
$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('<li></li>').data('item.autocomplete',item).append(repl('<a>%(label)s<br><span style="font-size:10px">%(info)s</span></a>',item)).appendTo(ul);};$(this.txt).change(function(){if(!$(this).val()){if(selector&&selector.display)
|
$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('<li></li>').data('item.autocomplete',item).append(repl('<a>%(label)s<br><span style="font-size:10px">%(info)s</span></a>',item)).appendTo(ul);};$(this.txt).change(function(){var val=$(this).val();me.set_input_value_executed=false;if(!val){if(selector&&selector.display)
|
||||||
return;me.set_input_value('');}})}
|
return;me.set_input_value('');}else{setTimeout(function(){if(!me.set_input_value_executed){me.set_input_value(val);}},100);}})}
|
||||||
LinkField.prototype.get_custom_query=function(){this.set_get_query();if(this.get_query){if(cur_frm)
|
LinkField.prototype.get_custom_query=function(){this.set_get_query();if(this.get_query){if(cur_frm)
|
||||||
var doc=locals[cur_frm.doctype][cur_frm.docname];return this.get_query(doc,this.doctype,this.docname);}}
|
var doc=locals[cur_frm.doctype][cur_frm.docname];return this.get_query(doc,this.doctype,this.docname);}}
|
||||||
LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);}
|
LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);}
|
||||||
if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}}
|
if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}}
|
||||||
me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}}
|
me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}}
|
||||||
_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
|
_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
|
||||||
LinkField.prototype.set_input_value=function(val){var me=this;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;}
|
LinkField.prototype.set_input_value=function(val){var me=this;me.set_input_value_executed=true;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;}
|
||||||
if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}}
|
if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}}
|
||||||
me.set(val);if(_f.cur_grid_cell)
|
me.set(val);if(_f.cur_grid_cell)
|
||||||
_f.cur_grid_cell.grid.cell_deselect();if(locals[me.doctype][me.docname][me.df.fieldname]&&!val){me.run_trigger();return;}
|
_f.cur_grid_cell.grid.cell_deselect();if(locals[me.doctype][me.docname][me.df.fieldname]&&!val){me.run_trigger();return;}
|
||||||
var fetch='';if(cur_frm.fetch_dict[me.df.fieldname])
|
me.validate_link(val,from_selector);}
|
||||||
|
LinkField.prototype.validate_link=function(val,from_selector){var me=this;var fetch='';if(cur_frm.fetch_dict[me.df.fieldname])
|
||||||
fetch=cur_frm.fetch_dict[me.df.fieldname].columns.join(', ');$c('webnotes.widgets.form.utils.validate_link',{'value':val,'options':me.df.options,'fetch':fetch},function(r,rt){if(r.message=='Ok'){if($(me.txt).val()!=val){if((me.grid&&!from_selector)||(!me.grid)){$(me.txt).val(val);}}
|
fetch=cur_frm.fetch_dict[me.df.fieldname].columns.join(', ');$c('webnotes.widgets.form.utils.validate_link',{'value':val,'options':me.df.options,'fetch':fetch},function(r,rt){if(r.message=='Ok'){if($(me.txt).val()!=val){if((me.grid&&!from_selector)||(!me.grid)){$(me.txt).val(val);}}
|
||||||
if(r.fetch_values)
|
if(r.fetch_values)
|
||||||
me.set_fetch_values(r.fetch_values);me.run_trigger();}else{var astr='';if(in_list(profile.can_create,me.df.options))astr=repl('<br><br><span class="link_type" onclick="newdoc(\'%(dt)s\')">Click here</span> to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)})
|
me.set_fetch_values(r.fetch_values);me.run_trigger();}else{var astr='';if(in_list(profile.can_create,me.df.options))astr=repl('<br><br><span class="link_type" onclick="newdoc(\'%(dt)s\')">Click here</span> to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)})
|
||||||
@@ -1705,7 +1710,7 @@ this.appframe.add_button('Amend',function(){cur_frm.amend_doc()},'icon-pencil');
|
|||||||
/*
|
/*
|
||||||
* lib/js/legacy/widgets/form/form.js
|
* lib/js/legacy/widgets/form/form.js
|
||||||
*/
|
*/
|
||||||
wn.provide('_f');_f.frms={};_f.Frm=function(doctype,parent){this.docname='';this.doctype=doctype;this.display=0;var me=this;this.is_editable={};this.opendocs={};this.sections=[];this.grids=[];this.cscript={};this.pformat={};this.fetch_dict={};this.parent=parent;this.tinymce_id_list=[];this.setup_meta(doctype);var me=this;$(document).bind('rename',function(event,dt,old_name,new_name){if(dt==me.doctype)
|
wn.provide('_f');_f.frms={};_f.Frm=function(doctype,parent,in_form){this.docname='';this.doctype=doctype;this.display=0;var me=this;this.is_editable={};this.opendocs={};this.sections=[];this.grids=[];this.cscript={};this.pformat={};this.fetch_dict={};this.parent=parent;this.tinymce_id_list=[];this.setup_meta(doctype);this.in_form=in_form?true:false;var me=this;$(document).bind('rename',function(event,dt,old_name,new_name){if(dt==me.doctype)
|
||||||
me.rename_notify(dt,old_name,new_name)});}
|
me.rename_notify(dt,old_name,new_name)});}
|
||||||
_f.Frm.prototype.check_doctype_conflict=function(docname){var me=this;if(this.doctype=='DocType'&&docname=='DocType'){msgprint('Allowing DocType, DocType. Be careful!')}else if(this.doctype=='DocType'){if(wn.views.formview[docname]){msgprint("Cannot open DocType when its instance is open")
|
_f.Frm.prototype.check_doctype_conflict=function(docname){var me=this;if(this.doctype=='DocType'&&docname=='DocType'){msgprint('Allowing DocType, DocType. Be careful!')}else if(this.doctype=='DocType'){if(wn.views.formview[docname]){msgprint("Cannot open DocType when its instance is open")
|
||||||
throw'doctype open conflict'}}else{if(wn.views.formview.DocType&&wn.views.formview.DocType.frm.opendocs[this.doctype]){msgprint("Cannot open instance when its DocType is open")
|
throw'doctype open conflict'}}else{if(wn.views.formview.DocType&&wn.views.formview.DocType.frm.opendocs[this.doctype]){msgprint("Cannot open instance when its DocType is open")
|
||||||
@@ -1713,9 +1718,9 @@ throw'doctype open conflict'}}}
|
|||||||
_f.Frm.prototype.setup=function(){var me=this;this.fields=[];this.fields_dict={};this.wrapper=this.parent;this.setup_print_layout();this.saved_wrapper=$a(this.wrapper,'div');this.setup_std_layout();this.setup_client_script();this.setup_done=true;}
|
_f.Frm.prototype.setup=function(){var me=this;this.fields=[];this.fields_dict={};this.wrapper=this.parent;this.setup_print_layout();this.saved_wrapper=$a(this.wrapper,'div');this.setup_std_layout();this.setup_client_script();this.setup_done=true;}
|
||||||
_f.Frm.prototype.setup_print_layout=function(){this.print_wrapper=$a(this.wrapper,'div');this.print_head=$a(this.print_wrapper,'div');this.print_body=$a(this.print_wrapper,'div','layout_wrapper',{padding:'23px',minHeight:'800px'});var t=make_table(this.print_head,1,2,'100%',[],{padding:'6px'});this.view_btn_wrapper=$a($td(t,0,0),'span','green_buttons');this.view_btn=$btn(this.view_btn_wrapper,'View Details',function(){cur_frm.edit_doc()},{marginRight:'4px'},'green');this.print_btn=$btn($td(t,0,0),'Print',function(){cur_frm.print_doc()});$y($td(t,0,1),{textAlign:'right'});this.print_close_btn=$btn($td(t,0,1),'Close',function(){window.history.back();});}
|
_f.Frm.prototype.setup_print_layout=function(){this.print_wrapper=$a(this.wrapper,'div');this.print_head=$a(this.print_wrapper,'div');this.print_body=$a(this.print_wrapper,'div','layout_wrapper',{padding:'23px',minHeight:'800px'});var t=make_table(this.print_head,1,2,'100%',[],{padding:'6px'});this.view_btn_wrapper=$a($td(t,0,0),'span','green_buttons');this.view_btn=$btn(this.view_btn_wrapper,'View Details',function(){cur_frm.edit_doc()},{marginRight:'4px'},'green');this.print_btn=$btn($td(t,0,0),'Print',function(){cur_frm.print_doc()});$y($td(t,0,1),{textAlign:'right'});this.print_close_btn=$btn($td(t,0,1),'Close',function(){window.history.back();});}
|
||||||
_f.Frm.prototype.onhide=function(){if(_f.cur_grid_cell)_f.cur_grid_cell.grid.cell_deselect();}
|
_f.Frm.prototype.onhide=function(){if(_f.cur_grid_cell)_f.cur_grid_cell.grid.cell_deselect();}
|
||||||
_f.Frm.prototype.setup_std_layout=function(){this.page_layout=new wn.PageLayout({parent:this.wrapper,main_width:this.meta.in_dialog?'100%':'75%',sidebar_width:this.meta.in_dialog?'0%':'25%'})
|
_f.Frm.prototype.setup_std_layout=function(){this.page_layout=new wn.PageLayout({parent:this.wrapper,main_width:(this.meta.in_dialog&&!this.in_form)?'100%':'75%',sidebar_width:(this.meta.in_dialog&&!this.in_form)?'0%':'25%'})
|
||||||
this.meta.section_style='Simple';this.layout=new Layout(this.page_layout.body,'100%');if(this.meta.in_dialog){$(this.page_layout.wrapper).removeClass('layout-wrapper-background');$(this.page_layout.main).removeClass('layout-main-section');$(this.page_layout.sidebar_area).toggle(false);}else{this.setup_sidebar();}
|
this.meta.section_style='Simple';this.layout=new Layout(this.page_layout.body,'100%');if(this.meta.in_dialog&&!this.in_form){$(this.page_layout.wrapper).removeClass('layout-wrapper-background');$(this.page_layout.main).removeClass('layout-main-section');$(this.page_layout.sidebar_area).toggle(false);}else{this.setup_sidebar();}
|
||||||
this.setup_footer();if(!(this.meta.istable||user=='Guest'||this.meta.in_dialog))
|
this.setup_footer();if(!(this.meta.istable||user=='Guest'||(this.meta.in_dialog&&!this.in_form)))
|
||||||
this.frm_head=new _f.FrmHeader(this.page_layout.head,this);if(this.meta.colour)
|
this.frm_head=new _f.FrmHeader(this.page_layout.head,this);if(this.meta.colour)
|
||||||
this.layout.wrapper.style.backgroundColor='#'+this.meta.colour.split(':')[1];this.setup_fields_std();}
|
this.layout.wrapper.style.backgroundColor='#'+this.meta.colour.split(':')[1];this.setup_fields_std();}
|
||||||
_f.Frm.prototype.setup_print=function(){var l=[]
|
_f.Frm.prototype.setup_print=function(){var l=[]
|
||||||
@@ -1728,12 +1733,12 @@ _f.Frm.prototype.email_doc=function(){if(!_e.dialog)_e.make();_e.dialog.widgets[
|
|||||||
sel=this.print_sel;var c=$td(_e.dialog.rows['Format'].tab,0,1);if(c.cur_sel){c.removeChild(c.cur_sel);c.cur_sel=null;}
|
sel=this.print_sel;var c=$td(_e.dialog.rows['Format'].tab,0,1);if(c.cur_sel){c.removeChild(c.cur_sel);c.cur_sel=null;}
|
||||||
c.appendChild(this.print_sel);c.cur_sel=this.print_sel;_e.dialog.widgets['Send With Attachments'].checked=0;if(cur_frm.doc.file_list){$ds(_e.dialog.rows['Send With Attachments']);}else{$dh(_e.dialog.rows['Send With Attachments']);}
|
c.appendChild(this.print_sel);c.cur_sel=this.print_sel;_e.dialog.widgets['Send With Attachments'].checked=0;if(cur_frm.doc.file_list){$ds(_e.dialog.rows['Send With Attachments']);}else{$dh(_e.dialog.rows['Send With Attachments']);}
|
||||||
_e.dialog.widgets['Subject'].value=get_doctype_label(this.meta.name)+': '+this.docname;_e.dialog.show();}
|
_e.dialog.widgets['Subject'].value=get_doctype_label(this.meta.name)+': '+this.docname;_e.dialog.show();}
|
||||||
_f.Frm.prototype.rename_notify=function(dt,old,name){if(this.meta.in_dialog)
|
_f.Frm.prototype.rename_notify=function(dt,old,name){if(this.meta.in_dialog&&!this.in_form)
|
||||||
return;if(this.docname==old)
|
return;if(this.docname==old)
|
||||||
this.docname=name;else
|
this.docname=name;else
|
||||||
return;this.is_editable[name]=this.is_editable[old];delete this.is_editable[old];if(this&&this.opendocs[old]){local_dt[dt][name]=local_dt[dt][old];local_dt[dt][old]=null;}
|
return;this.is_editable[name]=this.is_editable[old];delete this.is_editable[old];if(this&&this.opendocs[old]){local_dt[dt][name]=local_dt[dt][old];local_dt[dt][old]=null;}
|
||||||
delete this.opendocs[old];this.opendocs[name]=true;wn.re_route[window.location.hash]='#Form/'+encodeURIComponent(this.doctype)+'/'+encodeURIComponent(name);wn.set_route('Form',this.doctype,name);}
|
delete this.opendocs[old];this.opendocs[name]=true;wn.re_route[window.location.hash]='#Form/'+encodeURIComponent(this.doctype)+'/'+encodeURIComponent(name);wn.set_route('Form',this.doctype,name);}
|
||||||
_f.Frm.prototype.setup_meta=function(){this.meta=get_local('DocType',this.doctype);this.perm=get_perm(this.doctype);if(this.meta.istable){this.meta.in_dialog=1}
|
_f.Frm.prototype.setup_meta=function(doctype){this.meta=get_local('DocType',this.doctype);this.perm=get_perm(this.doctype);if(this.meta.istable){this.meta.in_dialog=1}
|
||||||
this.setup_print();}
|
this.setup_print();}
|
||||||
_f.Frm.prototype.setup_sidebar=function(){this.sidebar=new wn.widgets.form.sidebar.Sidebar(this);}
|
_f.Frm.prototype.setup_sidebar=function(){this.sidebar=new wn.widgets.form.sidebar.Sidebar(this);}
|
||||||
_f.Frm.prototype.setup_footer=function(){var me=this;var f=this.page_layout.footer;f.save_area=$a(this.page_layout.footer,'div','',{display:'none',marginTop:'11px'});f.help_area=$a(this.page_layout.footer,'div');var b=$btn(f.save_area,'Save',function(){cur_frm.save('Save');},{marginLeft:'0px'},'green');f.show_save=function(){$ds(me.page_layout.footer.save_area);}
|
_f.Frm.prototype.setup_footer=function(){var me=this;var f=this.page_layout.footer;f.save_area=$a(this.page_layout.footer,'div','',{display:'none',marginTop:'11px'});f.help_area=$a(this.page_layout.footer,'div');var b=$btn(f.save_area,'Save',function(){cur_frm.save('Save');},{marginLeft:'0px'},'green');f.show_save=function(){$ds(me.page_layout.footer.save_area);}
|
||||||
@@ -1759,14 +1764,14 @@ _f.Frm.prototype.set_print_heading=function(txt){this.pformat[cur_frm.docname]=t
|
|||||||
_f.Frm.prototype.defocus_rest=function(){if(_f.cur_grid_cell)_f.cur_grid_cell.grid.cell_deselect();}
|
_f.Frm.prototype.defocus_rest=function(){if(_f.cur_grid_cell)_f.cur_grid_cell.grid.cell_deselect();}
|
||||||
_f.Frm.prototype.get_doc_perms=function(){var p=[0,0,0,0,0,0];for(var i=0;i<this.perm.length;i++){if(this.perm[i]){if(this.perm[i][READ])p[READ]=1;if(this.perm[i][WRITE])p[WRITE]=1;if(this.perm[i][SUBMIT])p[SUBMIT]=1;if(this.perm[i][CANCEL])p[CANCEL]=1;if(this.perm[i][AMEND])p[AMEND]=1;}}
|
_f.Frm.prototype.get_doc_perms=function(){var p=[0,0,0,0,0,0];for(var i=0;i<this.perm.length;i++){if(this.perm[i]){if(this.perm[i][READ])p[READ]=1;if(this.perm[i][WRITE])p[WRITE]=1;if(this.perm[i][SUBMIT])p[SUBMIT]=1;if(this.perm[i][CANCEL])p[CANCEL]=1;if(this.perm[i][AMEND])p[AMEND]=1;}}
|
||||||
return p;}
|
return p;}
|
||||||
_f.Frm.prototype.refresh_header=function(){if(!this.meta.in_dialog){set_title(this.meta.issingle?this.doctype:this.docname);}
|
_f.Frm.prototype.refresh_header=function(){if(!this.meta.in_dialog||this.in_form){set_title(this.meta.issingle?this.doctype:this.docname);}
|
||||||
if(this.frm_head)this.frm_head.refresh();if(wn.ui.toolbar.recent)
|
if(this.frm_head)this.frm_head.refresh();if(wn.ui.toolbar.recent)
|
||||||
wn.ui.toolbar.recent.add(this.doctype,this.docname,1);}
|
wn.ui.toolbar.recent.add(this.doctype,this.docname,1);}
|
||||||
_f.Frm.prototype.check_doc_perm=function(){var dt=this.parent_doctype?this.parent_doctype:this.doctype;var dn=this.parent_docname?this.parent_docname:this.docname;this.perm=get_perm(dt,dn);this.orig_perm=get_perm(dt,dn,1);if(!this.perm[0][READ]){if(user=='Guest'){if(_f.temp_access[dt]&&_f.temp_access[dt][dn]){this.perm=[[1,0,0]]
|
_f.Frm.prototype.check_doc_perm=function(){var dt=this.parent_doctype?this.parent_doctype:this.doctype;var dn=this.parent_docname?this.parent_docname:this.docname;this.perm=get_perm(dt,dn);this.orig_perm=get_perm(dt,dn,1);if(!this.perm[0][READ]){if(user=='Guest'){if(_f.temp_access[dt]&&_f.temp_access[dt][dn]){this.perm=[[1,0,0]]
|
||||||
return 1;}}
|
return 1;}}
|
||||||
window.back();return 0;}
|
window.back();return 0;}
|
||||||
return 1}
|
return 1}
|
||||||
_f.Frm.prototype.refresh=function(docname){if(docname){if(this.docname!=docname&&!this.meta.in_dialog&&!this.meta.istable)scroll(0,0);this.docname=docname;}
|
_f.Frm.prototype.refresh=function(docname){if(docname){if(this.docname!=docname&&(!this.meta.in_dialog||this.in_form)&&!this.meta.istable)scroll(0,0);this.docname=docname;}
|
||||||
if(!this.meta.istable){cur_frm=this;this.parent.cur_frm=this;}
|
if(!this.meta.istable){cur_frm=this;this.parent.cur_frm=this;}
|
||||||
if(this.docname){if(!this.check_doc_perm())return;if(!this.setup_done)this.setup();this.runclientscript('set_perm',this.doctype,this.docname);this.doc=get_local(this.doctype,this.docname);cur_frm.cscript.is_onload=false;if(!this.opendocs[this.docname]){cur_frm.cscript.is_onload=true;this.setnewdoc(this.docname);}
|
if(this.docname){if(!this.check_doc_perm())return;if(!this.setup_done)this.setup();this.runclientscript('set_perm',this.doctype,this.docname);this.doc=get_local(this.doctype,this.docname);cur_frm.cscript.is_onload=false;if(!this.opendocs[this.docname]){cur_frm.cscript.is_onload=true;this.setnewdoc(this.docname);}
|
||||||
if(this.doc.__islocal)
|
if(this.doc.__islocal)
|
||||||
@@ -1776,7 +1781,7 @@ this.runclientscript('refresh');$(document).trigger('form_refresh');this.refresh
|
|||||||
if(this.doc.docstatus==0){$(this.wrapper).find('.form-layout-row :input:first').focus();}}else{this.refresh_header();if(this.print_wrapper){this.refresh_print_layout();}
|
if(this.doc.docstatus==0){$(this.wrapper).find('.form-layout-row :input:first').focus();}}else{this.refresh_header();if(this.print_wrapper){this.refresh_print_layout();}
|
||||||
this.runclientscript('edit_status_changed');}
|
this.runclientscript('edit_status_changed');}
|
||||||
$(cur_frm.wrapper).trigger('render_complete');}}
|
$(cur_frm.wrapper).trigger('render_complete');}}
|
||||||
_f.Frm.prototype.refresh_footer=function(){var f=this.page_layout.footer;if(f.save_area){if(get_url_arg('embed')||(this.editable&&!this.meta.in_dialog&&this.doc.docstatus==0&&!this.meta.istable&&this.get_doc_perms()[WRITE])){f.show_save();}else{f.hide_save();}}}
|
_f.Frm.prototype.refresh_footer=function(){var f=this.page_layout.footer;if(f.save_area){if(get_url_arg('embed')||(this.editable&&(!this.meta.in_dialog||this.in_form)&&this.doc.docstatus==0&&!this.meta.istable&&this.get_doc_perms()[WRITE])){f.show_save();}else{f.hide_save();}}}
|
||||||
_f.Frm.prototype.refresh_fields=function(){for(var i=0;i<this.fields.length;i++){var f=this.fields[i];f.perm=this.perm;f.docname=this.docname;var fn=f.df.fieldname||f.df.label;if(fn)
|
_f.Frm.prototype.refresh_fields=function(){for(var i=0;i<this.fields.length;i++){var f=this.fields[i];f.perm=this.perm;f.docname=this.docname;var fn=f.df.fieldname||f.df.label;if(fn)
|
||||||
f.df=get_field(this.doctype,fn,this.docname);if(f.df.fieldtype!='Section Break'&&f.refresh){f.refresh();}}
|
f.df=get_field(this.doctype,fn,this.docname);if(f.df.fieldtype!='Section Break'&&f.refresh){f.refresh();}}
|
||||||
$.each(this.sections,function(i,f){f.refresh(true);})
|
$.each(this.sections,function(i,f){f.refresh(true);})
|
||||||
@@ -1829,7 +1834,7 @@ _f.Frm.prototype.savedoc=function(save_action,onsave,onerr){this.error_in_sectio
|
|||||||
_f.Frm.prototype.saveupdate=function(){this.save('Update');}
|
_f.Frm.prototype.saveupdate=function(){this.save('Update');}
|
||||||
_f.Frm.prototype.savesubmit=function(){var answer=confirm("Permanently Submit "+this.docname+"?");var me=this;if(answer){this.save('Submit',function(r){if(!r.exc&&me.cscript.on_submit){me.runclientscript('on_submit',me.doctype,me.docname);}});}}
|
_f.Frm.prototype.savesubmit=function(){var answer=confirm("Permanently Submit "+this.docname+"?");var me=this;if(answer){this.save('Submit',function(r){if(!r.exc&&me.cscript.on_submit){me.runclientscript('on_submit',me.doctype,me.docname);}});}}
|
||||||
_f.Frm.prototype.savecancel=function(){var answer=confirm("Permanently Cancel "+this.docname+"?");if(answer)this.save('Cancel');}
|
_f.Frm.prototype.savecancel=function(){var answer=confirm("Permanently Cancel "+this.docname+"?");if(answer)this.save('Cancel');}
|
||||||
_f.Frm.prototype.savetrash=function(){var me=this;var answer=confirm("Permanently Delete "+this.docname+"? This action cannot be reversed");if(answer){$c('webnotes.model.delete_doc',{dt:this.doctype,dn:this.docname},function(r,rt){if(r.message=='okay'){LocalDB.delete_doc(me.doctype,me.docname);if(wn.ui.toolbar.recent)wn.ui.toolbar.recent.remove(me.doctype,me.docname);window.back();}})}}
|
_f.Frm.prototype.savetrash=function(){var me=this;var answer=confirm("Permanently Delete "+this.docname+"? This action cannot be reversed");if(answer){$c('webnotes.model.delete_doc',{dt:this.doctype,dn:this.docname},function(r,rt){if(r.message=='okay'){LocalDB.delete_doc(me.doctype,me.docname);if(wn.ui.toolbar.recent)wn.ui.toolbar.recent.remove(me.doctype,me.docname);window.history.back();}})}}
|
||||||
_f.Frm.prototype.amend_doc=function(){if(!this.fields_dict['amended_from']){alert('"amended_from" field must be present to do an amendment.');return;}
|
_f.Frm.prototype.amend_doc=function(){if(!this.fields_dict['amended_from']){alert('"amended_from" field must be present to do an amendment.');return;}
|
||||||
var me=this;var fn=function(newdoc){newdoc.amended_from=me.docname;if(me.fields_dict&&me.fields_dict['amendment_date'])
|
var me=this;var fn=function(newdoc){newdoc.amended_from=me.docname;if(me.fields_dict&&me.fields_dict['amendment_date'])
|
||||||
newdoc.amendment_date=dateutil.obj_to_str(new Date());}
|
newdoc.amendment_date=dateutil.obj_to_str(new Date());}
|
||||||
@@ -2112,7 +2117,7 @@ $c_get_values=function(args,doc,dt,dn,user_callback){var call_back=function(r,rt
|
|||||||
refresh_field(fl[i],dn,args.table_field);else
|
refresh_field(fl[i],dn,args.table_field);else
|
||||||
refresh_field(fl[i]);}}
|
refresh_field(fl[i]);}}
|
||||||
$c('webnotes.widgets.form.utils.get_fields',args,call_back);}
|
$c('webnotes.widgets.form.utils.get_fields',args,call_back);}
|
||||||
get_server_fields=function(method,arg,table_field,doc,dt,dn,allow_edit,call_back){if(!allow_edit)freeze('Fetching Data...');$c('runserverobj',args={'method':method,'docs':compress_doclist([doc]),'arg':arg},function(r,rt){if(r.message){var d=locals[dt][dn];var field_dict=r.message;for(var key in field_dict){d[key]=field_dict[key];if(table_field)refresh_field(key,d.name,table_field);else refresh_field(key);}}
|
get_server_fields=function(method,arg,table_field,doc,dt,dn,allow_edit,call_back){if(!allow_edit)freeze('Fetching Data...');$c('runserverobj',args={'method':method,'docs':compress_doclist(make_doclist(doc.doctype,doc.name)),'arg':arg},function(r,rt){if(r.message){var d=locals[dt][dn];var field_dict=r.message;for(var key in field_dict){d[key]=field_dict[key];if(table_field)refresh_field(key,d.name,table_field);else refresh_field(key);}}
|
||||||
if(call_back){doc=locals[doc.doctype][doc.name];call_back(doc,dt,dn);}
|
if(call_back){doc=locals[doc.doctype][doc.name];call_back(doc,dt,dn);}
|
||||||
if(!allow_edit)unfreeze();});}
|
if(!allow_edit)unfreeze();});}
|
||||||
set_multiple=function(dt,dn,dict,table_field){var d=locals[dt][dn];for(var key in dict){d[key]=dict[key];if(table_field)refresh_field(key,d.name,table_field);else refresh_field(key);}}
|
set_multiple=function(dt,dn,dict,table_field){var d=locals[dt][dn];for(var key in dict){d[key]=dict[key];if(table_field)refresh_field(key,d.name,table_field);else refresh_field(key);}}
|
||||||
@@ -2163,7 +2168,7 @@ CommentItem.prototype.cmt_delete=function(cell,ri,ci,d){var me=this;if(d[ri][2]=
|
|||||||
/*
|
/*
|
||||||
* lib/js/legacy/wn/widgets/form/sidebar.js
|
* lib/js/legacy/wn/widgets/form/sidebar.js
|
||||||
*/
|
*/
|
||||||
wn.widgets.form.sidebar={Sidebar:function(form){var me=this;this.form=form;this.opts={sections:[{title:'Actions',items:[{type:'link',label:'New',icon:'icon-plus',display:function(){return in_list(profile.can_create,form.doctype)},onclick:function(){new_doc(me.form.doctype)}},{type:'link',label:'List',icon:'icon-list',display:function(){return!me.form.meta.issingle;},onclick:function(){window.location.href="#!List/"+me.form.doctype}},{type:'link',label:'Refresh',icon:'icon-refresh',onclick:function(){me.form.reload_doc()}},{type:'link',label:'Print',display:function(){return!(me.form.doc.__islocal||me.form.meta.allow_print);},icon:'icon-print',onclick:function(){me.form.print_doc()}},{type:'link',label:'Email',display:function(){return!(me.form.doc.__islocal||me.form.meta.allow_email);},icon:'icon-envelope',onclick:function(){me.form.email_doc()}},{type:'link',label:'Copy',display:function(){return in_list(profile.can_create,me.form.doctype)&&!me.form.meta.allow_copy},icon:'icon-file',onclick:function(){me.form.copy_doc()}},{type:'link',label:'Delete',display:function(){return me.form.meta.allow_trash&&cint(me.form.doc.docstatus)!=2&&(!me.form.doc.__islocal)&&me.form.perm[0][CANCEL]},icon:'icon-remove-sign',onclick:function(){me.form.savetrash()}}]},{title:'Assign To',render:function(wrapper){me.form.assign_to=new wn.widgets.form.sidebar.AssignTo(wrapper,me,me.form.doctype,me.form.docname);},display:function(){if(me.form.doc.__local)return false;else return true;}},{title:'Attachments',render:function(wrapper){me.form.attachments=new wn.widgets.form.sidebar.Attachments(wrapper,me,me.form.doctype,me.form.docname);},display:function(){return me.form.meta.allow_attach}},{title:'Comments',render:function(wrapper){new wn.widgets.form.sidebar.Comments(wrapper,me,me.form.doctype,me.form.docname);},display:function(){return!me.form.doc.__islocal}},{title:'Tags',render:function(wrapper){me.form.taglist=new TagList(wrapper,me.form.doc._user_tags?me.form.doc._user_tags.split(','):[],me.form.doctype,me.form.docname,0,function(){});},display:function(){return!me.form.doc.__islocal}},{title:'Users',render:function(wrapper){var doc=cur_frm.doc;var scrub_date=function(d){if(d)t=d.split(' ');else return'';return dateutil.str_to_user(t[0])+' '+t[1];}
|
wn.widgets.form.sidebar={Sidebar:function(form){var me=this;this.form=form;this.opts={sections:[{title:'Actions',items:[{type:'link',label:'New',icon:'icon-plus',display:function(){return in_list(profile.can_create,form.doctype)},onclick:function(){new_doc(me.form.doctype)}},{type:'link',label:'List',icon:'icon-list',display:function(){return!me.form.meta.issingle;},onclick:function(){window.location.href="#!List/"+me.form.doctype}},{type:'link',label:'Refresh',icon:'icon-refresh',onclick:function(){me.form.reload_doc()}},{type:'link',label:'Print',display:function(){return!(me.form.doc.__islocal||me.form.meta.allow_print);},icon:'icon-print',onclick:function(){me.form.print_doc()}},{type:'link',label:'Email',display:function(){return!(me.form.doc.__islocal||me.form.meta.allow_email);},icon:'icon-envelope',onclick:function(){me.form.email_doc()}},{type:'link',label:'Copy',display:function(){return in_list(profile.can_create,me.form.doctype)&&!me.form.meta.allow_copy},icon:'icon-file',onclick:function(){me.form.copy_doc()}},{type:'link',label:'Delete',display:function(){return(cint(me.form.doc.docstatus)!=1)&&!me.form.doc.__islocal&&wn.model.can_delete(me.form.doctype);},icon:'icon-remove-sign',onclick:function(){me.form.savetrash()}}]},{title:'Assign To',render:function(wrapper){me.form.assign_to=new wn.widgets.form.sidebar.AssignTo(wrapper,me,me.form.doctype,me.form.docname);},display:function(){if(me.form.doc.__local)return false;else return true;}},{title:'Attachments',render:function(wrapper){me.form.attachments=new wn.widgets.form.sidebar.Attachments(wrapper,me,me.form.doctype,me.form.docname);},display:function(){return me.form.meta.allow_attach}},{title:'Comments',render:function(wrapper){new wn.widgets.form.sidebar.Comments(wrapper,me,me.form.doctype,me.form.docname);},display:function(){return!me.form.doc.__islocal}},{title:'Tags',render:function(wrapper){me.form.taglist=new TagList(wrapper,me.form.doc._user_tags?me.form.doc._user_tags.split(','):[],me.form.doctype,me.form.docname,0,function(){});},display:function(){return!me.form.doc.__islocal}},{title:'Users',render:function(wrapper){var doc=cur_frm.doc;var scrub_date=function(d){if(d)t=d.split(' ');else return'';return dateutil.str_to_user(t[0])+' '+t[1];}
|
||||||
$(wrapper).html(repl('<p>Created:<br> <span class="avatar-small">\
|
$(wrapper).html(repl('<p>Created:<br> <span class="avatar-small">\
|
||||||
<img title="%(created_by)s" src="%(avatar_created)s" /></span> \
|
<img title="%(created_by)s" src="%(avatar_created)s" /></span> \
|
||||||
<span class="help small">%(creation)s</span></p>\
|
<span class="help small">%(creation)s</span></p>\
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(op
|
|||||||
return;}
|
return;}
|
||||||
if(r.server_messages)msgprint(r.server_messages)
|
if(r.server_messages)msgprint(r.server_messages)
|
||||||
if(r.exc){console.log(r.exc);};if(r['403']){wn.container.change_to('403');}
|
if(r.exc){console.log(r.exc);};if(r['403']){wn.container.change_to('403');}
|
||||||
if(r.docs)LocalDB.sync(r.docs);}
|
if(r.docs){LocalDB.sync(r.docs);}}
|
||||||
wn.request.call=function(opts){wn.request.prepare(opts);$.ajax({url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus)
|
wn.request.call=function(opts){wn.request.prepare(opts);$.ajax({url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus)
|
||||||
if(opts.error)opts.error(xhr)}})}
|
if(opts.error)opts.error(xhr)}})}
|
||||||
wn.call=function(opts){var args=$.extend({},opts.args)
|
wn.call=function(opts){var args=$.extend({},opts.args)
|
||||||
@@ -625,8 +625,10 @@ LocalDB.add=function(dt,dn){if(!locals[dt])locals[dt]={};if(locals[dt][dn])delet
|
|||||||
LocalDB.delete_doc=function(dt,dn){var doc=get_local(dt,dn);for(var ndt in locals){if(locals[ndt]){for(var ndn in locals[ndt]){var doc=locals[ndt][ndn];if(doc&&doc.parenttype==dt&&(doc.parent==dn||doc.__oldparent==dn)){delete locals[ndt][ndn];}}}}
|
LocalDB.delete_doc=function(dt,dn){var doc=get_local(dt,dn);for(var ndt in locals){if(locals[ndt]){for(var ndn in locals[ndt]){var doc=locals[ndt][ndn];if(doc&&doc.parenttype==dt&&(doc.parent==dn||doc.__oldparent==dn)){delete locals[ndt][ndn];}}}}
|
||||||
delete locals[dt][dn];}
|
delete locals[dt][dn];}
|
||||||
function get_local(dt,dn){return locals[dt]?locals[dt][dn]:null;}
|
function get_local(dt,dn){return locals[dt]?locals[dt][dn]:null;}
|
||||||
LocalDB.sync=function(list){if(list._kl)list=expand_doclist(list);for(var i=0;i<list.length;i++){var d=list[i];if(!d.name)
|
LocalDB.sync=function(list){if(list._kl)list=expand_doclist(list);if(list){LocalDB.clear_locals(list[0].doctype,list[0].name);}
|
||||||
|
for(var i=0;i<list.length;i++){var d=list[i];if(!d.name)
|
||||||
d.name=LocalDB.get_localname(d.doctype);LocalDB.add(d.doctype,d.name);locals[d.doctype][d.name]=d;if(d.doctype=='DocField')wn.meta.add_field(d);if(d.localname){wn.model.new_names[d.localname]=d.name;$(document).trigger('rename',[d.doctype,d.localname,d.name]);delete locals[d.doctype][d.localname];}}}
|
d.name=LocalDB.get_localname(d.doctype);LocalDB.add(d.doctype,d.name);locals[d.doctype][d.name]=d;if(d.doctype=='DocField')wn.meta.add_field(d);if(d.localname){wn.model.new_names[d.localname]=d.name;$(document).trigger('rename',[d.doctype,d.localname,d.name]);delete locals[d.doctype][d.localname];}}}
|
||||||
|
LocalDB.clear_locals=function(dt,dn){var doclist=make_doclist(dt,dn,1);$.each(doclist,function(i,v){v&&delete locals[v.doctype][v.name];});}
|
||||||
local_name_idx={};LocalDB.get_localname=function(doctype){if(!local_name_idx[doctype])local_name_idx[doctype]=1;var n='New '+get_doctype_label(doctype)+' '+local_name_idx[doctype];local_name_idx[doctype]++;return n;}
|
local_name_idx={};LocalDB.get_localname=function(doctype){if(!local_name_idx[doctype])local_name_idx[doctype]=1;var n='New '+get_doctype_label(doctype)+' '+local_name_idx[doctype];local_name_idx[doctype]++;return n;}
|
||||||
LocalDB.set_default_values=function(doc){var doctype=doc.doctype;var docfields=wn.meta.docfield_list[doctype];if(!docfields){return;}
|
LocalDB.set_default_values=function(doc){var doctype=doc.doctype;var docfields=wn.meta.docfield_list[doctype];if(!docfields){return;}
|
||||||
var fields_to_refresh=[];for(var fid=0;fid<docfields.length;fid++){var f=docfields[fid];if(!in_list(no_value_fields,f.fieldtype)&&doc[f.fieldname]==null){var v=LocalDB.get_default_value(f.fieldname,f.fieldtype,f['default']);if(v){doc[f.fieldname]=v;fields_to_refresh.push(f.fieldname);}}}
|
var fields_to_refresh=[];for(var fid=0;fid<docfields.length;fid++){var f=docfields[fid];if(!in_list(no_value_fields,f.fieldtype)&&doc[f.fieldname]==null){var v=LocalDB.get_default_value(f.fieldname,f.fieldtype,f['default']);if(v){doc[f.fieldname]=v;fields_to_refresh.push(f.fieldname);}}}
|
||||||
@@ -656,7 +658,8 @@ return sys_defaults[fn];}
|
|||||||
LocalDB.add_child=function(doc,childtype,parentfield){var n=LocalDB.create(childtype);var d=locals[childtype][n];d.parent=doc.name;d.parentfield=parentfield;d.parenttype=doc.doctype;return d;}
|
LocalDB.add_child=function(doc,childtype,parentfield){var n=LocalDB.create(childtype);var d=locals[childtype][n];d.parent=doc.name;d.parentfield=parentfield;d.parenttype=doc.doctype;return d;}
|
||||||
LocalDB.no_copy_list=['amended_from','amendment_date','cancel_reason'];LocalDB.copy=function(dt,dn,from_amend){var newdoc=LocalDB.create(dt);for(var key in locals[dt][dn]){var df=get_field(dt,key);if(key!=='name'&&key.substr(0,2)!='__'&&!(df&&((!from_amend&&cint(df.no_copy)==1)||in_list(LocalDB.no_copy_list,df.fieldname)))){locals[dt][newdoc][key]=locals[dt][dn][key];}}
|
LocalDB.no_copy_list=['amended_from','amendment_date','cancel_reason'];LocalDB.copy=function(dt,dn,from_amend){var newdoc=LocalDB.create(dt);for(var key in locals[dt][dn]){var df=get_field(dt,key);if(key!=='name'&&key.substr(0,2)!='__'&&!(df&&((!from_amend&&cint(df.no_copy)==1)||in_list(LocalDB.no_copy_list,df.fieldname)))){locals[dt][newdoc][key]=locals[dt][dn][key];}}
|
||||||
return locals[dt][newdoc];}
|
return locals[dt][newdoc];}
|
||||||
function make_doclist(dt,dn,deleted){var dl=[];dl[0]=locals[dt][dn];for(var ndt in locals){if(locals[ndt]){for(var ndn in locals[ndt]){var doc=locals[ndt][ndn];if(doc&&doc.parenttype==dt&&(doc.parent==dn||(deleted&&doc.__oldparent==dn))){dl[dl.length]=doc;}}}}
|
function make_doclist(dt,dn,deleted){if(!locals[dt]){return[];}
|
||||||
|
var dl=[];dl[0]=locals[dt][dn];for(var ndt in locals){if(locals[ndt]){for(var ndn in locals[ndt]){var doc=locals[ndt][ndn];if(doc&&doc.parenttype==dt&&(doc.parent==dn||(deleted&&doc.__oldparent==dn))){dl[dl.length]=doc;}}}}
|
||||||
return dl;}
|
return dl;}
|
||||||
var Meta={};var local_dt={};Meta.make_local_dt=function(dt,dn){var dl=make_doclist('DocType',dt);if(!local_dt[dt])local_dt[dt]={};if(!local_dt[dt][dn])local_dt[dt][dn]={};for(var i=0;i<dl.length;i++){var d=dl[i];if(d.doctype=='DocField'){var key=d.fieldname?d.fieldname:d.label;local_dt[dt][dn][key]=copy_dict(d);}}}
|
var Meta={};var local_dt={};Meta.make_local_dt=function(dt,dn){var dl=make_doclist('DocType',dt);if(!local_dt[dt])local_dt[dt]={};if(!local_dt[dt][dn])local_dt[dt][dn]={};for(var i=0;i<dl.length;i++){var d=dl[i];if(d.doctype=='DocField'){var key=d.fieldname?d.fieldname:d.label;local_dt[dt][dn][key]=copy_dict(d);}}}
|
||||||
Meta.get_field=function(dt,fn,dn){if(dn&&local_dt[dt]&&local_dt[dt][dn]){return local_dt[dt][dn][fn];}else{if(wn.meta.docfield_map[dt])var d=wn.meta.docfield_map[dt][fn];if(d)return d;}
|
Meta.get_field=function(dt,fn,dn){if(dn&&local_dt[dt]&&local_dt[dt][dn]){return local_dt[dt][dn][fn];}else{if(wn.meta.docfield_map[dt])var d=wn.meta.docfield_map[dt][fn];if(d)return d;}
|
||||||
|
|||||||
@@ -98,19 +98,20 @@ return v;};function LinkField(){}LinkField.prototype=new Field();LinkField.proto
|
|||||||
$(me.btn2).css('display','inline-block');else $dh(me.btn2);}}
|
$(me.btn2).css('display','inline-block');else $dh(me.btn2);}}
|
||||||
me.txt.field_object=this;me.input.set_input=function(val){if(val==undefined)val='';me.txt.value=val;}
|
me.txt.field_object=this;me.input.set_input=function(val){if(val==undefined)val='';me.txt.value=val;}
|
||||||
me.get_value=function(){return me.txt.value;}
|
me.get_value=function(){return me.txt.value;}
|
||||||
$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('<li></li>').data('item.autocomplete',item).append(repl('<a>%(label)s<br><span style="font-size:10px">%(info)s</span></a>',item)).appendTo(ul);};$(this.txt).change(function(){if(!$(this).val()){if(selector&&selector.display)
|
$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('<li></li>').data('item.autocomplete',item).append(repl('<a>%(label)s<br><span style="font-size:10px">%(info)s</span></a>',item)).appendTo(ul);};$(this.txt).change(function(){var val=$(this).val();me.set_input_value_executed=false;if(!val){if(selector&&selector.display)
|
||||||
return;me.set_input_value('');}})}
|
return;me.set_input_value('');}else{setTimeout(function(){if(!me.set_input_value_executed){me.set_input_value(val);}},100);}})}
|
||||||
LinkField.prototype.get_custom_query=function(){this.set_get_query();if(this.get_query){if(cur_frm)
|
LinkField.prototype.get_custom_query=function(){this.set_get_query();if(this.get_query){if(cur_frm)
|
||||||
var doc=locals[cur_frm.doctype][cur_frm.docname];return this.get_query(doc,this.doctype,this.docname);}}
|
var doc=locals[cur_frm.doctype][cur_frm.docname];return this.get_query(doc,this.doctype,this.docname);}}
|
||||||
LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);}
|
LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);}
|
||||||
if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}}
|
if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}}
|
||||||
me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}}
|
me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}}
|
||||||
_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
|
_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
|
||||||
LinkField.prototype.set_input_value=function(val){var me=this;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;}
|
LinkField.prototype.set_input_value=function(val){var me=this;me.set_input_value_executed=true;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;}
|
||||||
if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}}
|
if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}}
|
||||||
me.set(val);if(_f.cur_grid_cell)
|
me.set(val);if(_f.cur_grid_cell)
|
||||||
_f.cur_grid_cell.grid.cell_deselect();if(locals[me.doctype][me.docname][me.df.fieldname]&&!val){me.run_trigger();return;}
|
_f.cur_grid_cell.grid.cell_deselect();if(locals[me.doctype][me.docname][me.df.fieldname]&&!val){me.run_trigger();return;}
|
||||||
var fetch='';if(cur_frm.fetch_dict[me.df.fieldname])
|
me.validate_link(val,from_selector);}
|
||||||
|
LinkField.prototype.validate_link=function(val,from_selector){var me=this;var fetch='';if(cur_frm.fetch_dict[me.df.fieldname])
|
||||||
fetch=cur_frm.fetch_dict[me.df.fieldname].columns.join(', ');$c('webnotes.widgets.form.utils.validate_link',{'value':val,'options':me.df.options,'fetch':fetch},function(r,rt){if(r.message=='Ok'){if($(me.txt).val()!=val){if((me.grid&&!from_selector)||(!me.grid)){$(me.txt).val(val);}}
|
fetch=cur_frm.fetch_dict[me.df.fieldname].columns.join(', ');$c('webnotes.widgets.form.utils.validate_link',{'value':val,'options':me.df.options,'fetch':fetch},function(r,rt){if(r.message=='Ok'){if($(me.txt).val()!=val){if((me.grid&&!from_selector)||(!me.grid)){$(me.txt).val(val);}}
|
||||||
if(r.fetch_values)
|
if(r.fetch_values)
|
||||||
me.set_fetch_values(r.fetch_values);me.run_trigger();}else{var astr='';if(in_list(profile.can_create,me.df.options))astr=repl('<br><br><span class="link_type" onclick="newdoc(\'%(dt)s\')">Click here</span> to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)})
|
me.set_fetch_values(r.fetch_values);me.run_trigger();}else{var astr='';if(in_list(profile.can_create,me.df.options))astr=repl('<br><br><span class="link_type" onclick="newdoc(\'%(dt)s\')">Click here</span> to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)})
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ var me=this;var dt=me.parent_dt?me.parent_dt:me.doctype;var fl=[{'fieldtype':'Da
|
|||||||
me.make_datatable();me.orig_sort_list=[];if(me.parent_dt){me.setup_dt_filters_and_cols(fl,me.parent_dt);var fl=[];}
|
me.make_datatable();me.orig_sort_list=[];if(me.parent_dt){me.setup_dt_filters_and_cols(fl,me.parent_dt);var fl=[];}
|
||||||
me.setup_dt_filters_and_cols(fl,me.doctype);if(!this.has_primary_filters)
|
me.setup_dt_filters_and_cols(fl,me.doctype);if(!this.has_primary_filters)
|
||||||
$dh(this.report_filters.first_page_filter);this.column_picker.refresh();$ds(me.body);}
|
$dh(this.report_filters.first_page_filter);this.column_picker.refresh();$ds(me.body);}
|
||||||
_r.ReportBuilder.prototype.set_filters_from_route=function(){var route=wn.get_route();if(route.length>3){for(var i=3;i<route.length;i++){var p=route[i].split('=');if(p.length==2){var dt=this.parent_dt?this.parent_dt:this.doctype;this.set_filter(dt,p[0],p[1]);}}}}
|
_r.ReportBuilder.prototype.set_filters_from_route=function(){var route=wn.get_route();this.current_route=wn.get_route_str();if(route.length>3){for(var i=3;i<route.length;i++){var p=route[i].split('=');if(p.length==2){var dt=this.parent_dt?this.parent_dt:this.doctype;this.set_filter(dt,p[0],p[1]);}}}}
|
||||||
_r.ReportBuilder.prototype.add_filter=function(f){if(this.filter_fields_dict[f.parent+'\1'+f.label]){this.filter_fields_dict[f.parent+'\1'+f.label].df=f;}else{this.report_filters.add_field(f,f.parent,null,1);}}
|
_r.ReportBuilder.prototype.add_filter=function(f){if(this.filter_fields_dict[f.parent+'\1'+f.label]){this.filter_fields_dict[f.parent+'\1'+f.label].df=f;}else{this.report_filters.add_field(f,f.parent,null,1);}}
|
||||||
_r.ReportBuilder.prototype.setup_dt_filters_and_cols=function(fl,dt){var me=this;var lab=$a(me.filter_area,'div','filter_dt_head');lab.innerHTML='Filters for '+get_doctype_label(dt);var lab=$a(me.picker_area,'div','builder_dt_head');lab.innerHTML='Select columns for '+get_doctype_label(dt);var dt_fields=wn.meta.docfield_list[dt];for(var i=0;i<dt_fields.length;i++){fl[fl.length]=dt_fields[i];}
|
_r.ReportBuilder.prototype.setup_dt_filters_and_cols=function(fl,dt){var me=this;var lab=$a(me.filter_area,'div','filter_dt_head');lab.innerHTML='Filters for '+get_doctype_label(dt);var lab=$a(me.picker_area,'div','builder_dt_head');lab.innerHTML='Select columns for '+get_doctype_label(dt);var dt_fields=wn.meta.docfield_list[dt];for(var i=0;i<dt_fields.length;i++){fl[fl.length]=dt_fields[i];}
|
||||||
var sf_list=locals.DocType[dt].search_fields?locals.DocType[dt].search_fields.split(','):[];for(var i in sf_list)sf_list[i]=strip(sf_list[i]);for(var i=0;i<fl.length;i++){var f=fl[i];if(f&&cint(f.in_filter)){me.report_filters.add_field(f,dt,in_list(sf_list,f.fieldname));}
|
var sf_list=locals.DocType[dt].search_fields?locals.DocType[dt].search_fields.split(','):[];for(var i in sf_list)sf_list[i]=strip(sf_list[i]);for(var i=0;i<fl.length;i++){var f=fl[i];if(f&&cint(f.in_filter)){me.report_filters.add_field(f,dt,in_list(sf_list,f.fieldname));}
|
||||||
|
|||||||
Reference in New Issue
Block a user