Merge branch 'latest' of github.com:webnotes/erpnext into latest

This commit is contained in:
Rushabh Mehta 2012-02-07 11:43:51 +05:30
commit 9c7fe3bce4
35 changed files with 3296 additions and 3051 deletions

View File

@ -5,145 +5,145 @@
{
'creation': '2010-08-08 17:09:35',
'docstatus': 0,
'modified': '2011-10-12 12:10:15',
'modified_by': 'Administrator',
'owner': 'Administrator'
'modified': '2012-02-06 15:25:06',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'doctype': u'Table Mapper Detail',
'name': '__common__',
'parent': 'Purchase Order-Payable Voucher',
'parentfield': 'table_mapper_details',
'parenttype': 'DocType Mapper'
'parent': u'Purchase Order-Payable Voucher',
'parentfield': u'table_mapper_details',
'parenttype': u'DocType Mapper'
},
# These values are common for all Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'doctype': u'Field Mapper Detail',
'name': '__common__',
'parent': 'Purchase Order-Payable Voucher',
'parentfield': 'field_mapper_details',
'parenttype': 'DocType Mapper'
'parent': u'Purchase Order-Payable Voucher',
'parentfield': u'field_mapper_details',
'parenttype': u'DocType Mapper'
},
# These values are common for all DocType Mapper
{
'doctype': u'DocType Mapper',
'from_doctype': 'Purchase Order',
'module': 'Accounts',
'from_doctype': u'Purchase Order',
'module': u'Accounts',
'name': '__common__',
'ref_doc_submitted': 1,
'to_doctype': 'Payable Voucher'
'to_doctype': u'Payable Voucher'
},
# DocType Mapper, Purchase Order-Payable Voucher
{
'doctype': u'DocType Mapper',
'name': 'Purchase Order-Payable Voucher'
'name': u'Purchase Order-Payable Voucher'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: flt(obj.qty) - flt(obj.billed_qty)',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'eval: flt(obj.qty) - flt(obj.billed_qty)',
'map': u'Yes',
'match_id': 1,
'to_field': 'qty'
'to_field': u'qty'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'purchase_rate',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'purchase_rate',
'map': u'Yes',
'match_id': 1,
'to_field': 'rate'
'to_field': u'rate'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.purchase_rate)',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.purchase_rate)',
'map': u'Yes',
'match_id': 1,
'to_field': 'amount'
'to_field': u'amount'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.import_rate)',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.import_rate)',
'map': u'Yes',
'match_id': 1,
'to_field': 'import_amount'
'to_field': u'import_amount'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'parent',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'parent',
'map': u'Yes',
'match_id': 1,
'to_field': 'purchase_order'
'to_field': u'purchase_order'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'name',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'name',
'map': u'Yes',
'match_id': 1,
'to_field': 'po_detail'
'to_field': u'po_detail'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'naming_series',
'map': 'No',
'doctype': u'Field Mapper Detail',
'from_field': u'naming_series',
'map': u'No',
'match_id': 0,
'to_field': 'naming_series'
'to_field': u'naming_series'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'total_tax',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'total_tax',
'map': u'Yes',
'match_id': 0,
'to_field': 'total_tax'
'to_field': u'total_tax'
},
# Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'from_table': 'Purchase Order',
'doctype': u'Table Mapper Detail',
'from_table': u'Purchase Order',
'match_id': 0,
'to_table': 'Payable Voucher',
'validation_logic': 'docstatus =1'
'to_table': u'Payable Voucher',
'validation_logic': u'docstatus =1'
},
# Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'from_field': 'po_details',
'from_table': 'PO Detail',
'doctype': u'Table Mapper Detail',
'from_field': u'po_details',
'from_table': u'PO Detail',
'match_id': 1,
'to_field': 'entries',
'to_table': 'PV Detail',
'validation_logic': 'ifnull(billed_qty,0) < qty and docstatus = 1'
'to_field': u'entries',
'to_table': u'PV Detail',
'validation_logic': u'ifnull(billed_qty,0) < qty and docstatus = 1'
},
# Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'from_field': 'purchase_tax_details',
'from_table': 'Purchase Tax Detail',
'doctype': u'Table Mapper Detail',
'from_field': u'purchase_tax_details',
'from_table': u'Purchase Tax Detail',
'match_id': 2,
'to_field': 'purchase_tax_details',
'to_table': 'Purchase Tax Detail',
'validation_logic': 'docstatus =1'
'to_field': u'purchase_tax_details',
'to_table': u'Purchase Tax Detail',
'validation_logic': u'docstatus =1'
}
]

View File

@ -5,181 +5,181 @@
{
'creation': '2010-08-08 17:09:35',
'docstatus': 0,
'modified': '2011-10-12 10:49:26',
'modified_by': 'Administrator',
'owner': 'Administrator'
'modified': '2012-02-06 15:26:25',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'doctype': u'Table Mapper Detail',
'name': '__common__',
'parent': 'Purchase Receipt-Payable Voucher',
'parentfield': 'table_mapper_details',
'parenttype': 'DocType Mapper'
'parent': u'Purchase Receipt-Payable Voucher',
'parentfield': u'table_mapper_details',
'parenttype': u'DocType Mapper'
},
# These values are common for all Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'doctype': u'Field Mapper Detail',
'name': '__common__',
'parent': 'Purchase Receipt-Payable Voucher',
'parentfield': 'field_mapper_details',
'parenttype': 'DocType Mapper'
'parent': u'Purchase Receipt-Payable Voucher',
'parentfield': u'field_mapper_details',
'parenttype': u'DocType Mapper'
},
# These values are common for all DocType Mapper
{
'doctype': u'DocType Mapper',
'from_doctype': 'Purchase Receipt',
'module': 'Accounts',
'from_doctype': u'Purchase Receipt',
'module': u'Accounts',
'name': '__common__',
'ref_doc_submitted': 1,
'to_doctype': 'Payable Voucher'
'to_doctype': u'Payable Voucher'
},
# DocType Mapper, Purchase Receipt-Payable Voucher
{
'doctype': u'DocType Mapper',
'name': 'Purchase Receipt-Payable Voucher'
'name': u'Purchase Receipt-Payable Voucher'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: flt(obj.qty) - flt(obj.billed_qty)',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'eval: flt(obj.qty) - flt(obj.billed_qty)',
'map': u'Yes',
'match_id': 1,
'to_field': 'qty'
'to_field': u'qty'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'purchase_rate',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'purchase_rate',
'map': u'Yes',
'match_id': 1,
'to_field': 'rate'
'to_field': u'rate'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.purchase_rate)',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.purchase_rate)',
'map': u'Yes',
'match_id': 1,
'to_field': 'amount'
'to_field': u'amount'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.import_rate)',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.import_rate)',
'map': u'Yes',
'match_id': 1,
'to_field': 'import_amount'
'to_field': u'import_amount'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'parent',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'parent',
'map': u'Yes',
'match_id': 1,
'to_field': 'purchase_receipt'
'to_field': u'purchase_receipt'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'prevdoc_docname',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'prevdoc_docname',
'map': u'Yes',
'match_id': 1,
'to_field': 'purchase_order'
'to_field': u'purchase_order'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'name',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'name',
'map': u'Yes',
'match_id': 1,
'to_field': 'pr_detail'
'to_field': u'pr_detail'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'prevdoc_detail_docname',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'prevdoc_detail_docname',
'map': u'Yes',
'match_id': 1,
'to_field': 'po_detail'
'to_field': u'po_detail'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'naming_series',
'map': 'No',
'doctype': u'Field Mapper Detail',
'from_field': u'naming_series',
'map': u'No',
'match_id': 0,
'to_field': 'naming_series'
'to_field': u'naming_series'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'net_total',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'net_total',
'map': u'Yes',
'match_id': 0,
'to_field': 'net_total'
'to_field': u'net_total'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'grand_total',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'grand_total',
'map': u'Yes',
'match_id': 0,
'to_field': 'grand_total'
'to_field': u'grand_total'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'total_tax',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'total_tax',
'map': u'Yes',
'match_id': 0,
'to_field': 'total_tax'
'to_field': u'total_tax'
},
# Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'from_field': 'purchase_receipt_details',
'from_table': 'Purchase Receipt Detail',
'doctype': u'Table Mapper Detail',
'from_field': u'purchase_receipt_details',
'from_table': u'Purchase Receipt Detail',
'match_id': 1,
'to_field': 'entries',
'to_table': 'PV Detail',
'validation_logic': 'ifnull(billed_qty,0) < qty'
'to_field': u'entries',
'to_table': u'PV Detail',
'validation_logic': u'ifnull(billed_qty,0) < qty'
},
# Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'from_table': 'Purchase Receipt',
'doctype': u'Table Mapper Detail',
'from_table': u'Purchase Receipt',
'match_id': 0,
'to_table': 'Payable Voucher',
'validation_logic': 'docstatus=1'
'to_table': u'Payable Voucher',
'validation_logic': u'docstatus=1'
},
# Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'from_field': 'purchase_tax_details',
'from_table': 'Purchase Tax Detail',
'doctype': u'Table Mapper Detail',
'from_field': u'purchase_tax_details',
'from_table': u'Purchase Tax Detail',
'match_id': 2,
'to_field': 'purchase_tax_details',
'to_table': 'Purchase Tax Detail',
'validation_logic': 'docstatus=1'
'to_field': u'purchase_tax_details',
'to_table': u'Purchase Tax Detail',
'validation_logic': u'docstatus=1'
}
]

View File

@ -9,8 +9,28 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
else {
hide_field(['tds_applicable','tds_category','Get TDS','tax_code','rate','ded_amount','supplier_account']);
}
cur_frm.cscript.load_defaults(doc, cdt, cdn);
}
cur_frm.cscript.load_defaults = function(doc, cdt, cdn) {
if(!cur_frm.doc.__islocal || !cur_frm.doc.company) { return; }
doc = locals[doc.doctype][doc.name];
var fields_to_refresh = LocalDB.set_default_values(doc);
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
fields_to_refresh = null;
var children = getchildren('Journal Voucher Detail', doc.name, 'entries');
if(!children) { return; }
for(var i=0; i<children.length; i++) {
LocalDB.set_default_values(children[i]);
}
refresh_field('entries');
}
cur_frm.cscript.is_opening = function(doc, cdt, cdn) {
hide_field('aging_date');
if (doc.is_opening == 'Yes') unhide_field('aging_date');

View File

@ -22,6 +22,9 @@ cur_frm.cscript.onload = function(doc,dt,dn) {
if(doc.__islocal){
hide_field(['supplier_address', 'contact_person', 'supplier_name', 'address_display', 'contact_display', 'contact_mobile', 'contact_email']);
}
// defined in purchase_common.js
cur_frm.cscript.update_item_details(doc, cdt, cdn);
}

View File

@ -92,7 +92,19 @@ class DocType(TransactionBase):
# Get Item Details
# -----------------
def get_item_details(self,arg):
def get_item_details(self, arg=None):
if arg:
return self.get_pv_details(arg)
else:
for doc in self.doclist:
if doc.fields.get('item_code'):
ret = self.get_pv_details(doc.item_code)
for r in ret:
if not doc.fields.get(r):
doc.fields[r] = ret[r]
def get_pv_details(self, arg):
item_det = sql("select item_name, brand, description, item_group,purchase_account,cost_center from tabItem where name=%s",arg,as_dict=1)
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , arg)
t = {}
@ -111,6 +123,8 @@ class DocType(TransactionBase):
}
return ret
# Advance Allocation
# -------------------
def get_advances(self):

View File

@ -25,6 +25,9 @@ cur_frm.cscript.onload = function(doc,dt,dn) {
if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn);
hide_field(['customer_address', 'contact_person', 'customer_name', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
// defined in sales_common.js
cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
}

View File

@ -148,8 +148,22 @@ class DocType(TransactionBase):
# Item Details
# -------------
def get_item_details(self, item_code):
def get_item_details(self, item_code=None):
if item_code:
ret = get_obj('Sales Common').get_item_details(item_code, self)
return self.get_pos_details(item_code, ret)
else:
obj = get_obj('Sales Common')
for doc in self.doclist:
if doc.fields.get('item_code'):
ret = obj.get_item_details(doc.item_code, self)
ret = self.get_pos_details(item_code, ret)
for r in ret:
if not doc.fields.get(r):
doc.fields[r] = ret[r]
def get_pos_details(self, item_code, ret):
if item_code and cint(self.doc.is_pos) == 1:
dtl = webnotes.conn.sql("select income_account, warehouse, cost_center from `tabPOS Setting` where user = '%s' and company = '%s'" % (session['user'], self.doc.company), as_dict=1)
if not dtl:
@ -162,6 +176,7 @@ class DocType(TransactionBase):
ret['actual_qty']= actual_qty and flt(actual_qty[0][0]) or 0
return ret
# Fetch ref rate from item master as per selected price list
def get_adj_percent(self, arg=''):
get_obj('Sales Common').get_adj_percent(self)

View File

@ -10,6 +10,8 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
if (!doc.transaction_date) doc.transaction_date = dateutil.obj_to_str(new Date())
if (!doc.status) doc.status = 'Draft';
// defined in purchase_common.js
//cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {

View File

@ -90,7 +90,21 @@ class DocType:
# get item details
# ---------------------------------
def get_item_details(self, arg =''):
if arg:
return get_obj(dt='Purchase Common').get_item_details(self,arg)
else:
obj = get_obj('Purchase Common')
for doc in self.doclist:
if doc.fields.get('item_code'):
temp = {
'item_code': doc.fields.get('item_code'),
'warehouse': doc.fields.get('warehouse')
}
ret = obj.get_item_details(self, json.dumps(temp))
for r in ret:
if not doc.fields.get(r):
doc.fields[r] = ret[r]
# Get UOM Details
# ---------------------------------

View File

@ -14,6 +14,41 @@ cur_frm.cscript.get_default_schedule_date = function(doc) {
}
// Gets called after existing item details are update to fill in
// remaining default values
cur_frm.cscript.load_defaults = function(doc, dt, dn) {
if(!cur_frm.doc.__islocal) { return; }
doc = locals[doc.doctype][doc.name];
var fields_to_refresh = LocalDB.set_default_values(doc);
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
fields_to_refresh = null;
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
if(!children) { return; }
for(var i=0; i<children.length; i++) {
LocalDB.set_default_values(children[i]);
}
refresh_field(cur_frm.cscript.fname);
}
// Update existing item details
cur_frm.cscript.update_item_details = function(doc, dt, dn) {
if(!cur_frm.doc.__islocal) return;
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
if(children) {
$c_obj(make_doclist(doc.doctype, doc.name), 'get_item_details', '',
function(r, rt) {
if(!r.exc) {
refresh_field(cur_frm.cscript.fname);
doc = locals[doc.doctype][doc.name];
cur_frm.cscript.load_defaults(doc, dt, dn);
}
});
}
}
// ======================== Conversion Rate ==========================================
cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) {
cur_frm.cscript.calc_amount( doc, 1);
@ -29,8 +64,11 @@ cur_frm.fields_dict[fname].grid.get_field("item_code").get_query = function(doc,
cur_frm.cscript.item_code = function(doc,cdt,cdn) {
var d = locals[cdt][cdn];
if (d.item_code) {
temp = "{'item_code':'"+(d.item_code?d.item_code:'')+"', 'warehouse':'"+(d.warehouse?d.warehouse:'')+"'}"
get_server_fields('get_item_details', temp, fname, doc, cdt, cdn, 1);
temp = {
item_code: d.item_code || '',
warehouse: d.warehouse || ''
}
get_server_fields('get_item_details', JSON.stringify(temp), fname, doc, cdt, cdn, 1);
}
}
@ -304,8 +342,13 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname)
else if(doc.doctype == 'Payable Voucher') net_total += flt(flt(cl[i].qty) * flt(cl[i].rate));
var prev_total = flt(cl[i].amount);
if(cl[i].item_tax_rate)
if(cl[i].item_tax_rate) {
try {
var check_tax = JSON.parse(cl[i].item_tax_rate); //to get in dictionary
} catch(exception) {
var check_tax = eval('var a='+cl[i].item_tax_rate+';a'); //to get in dictionary
}
}
// Add Item Code in new Row
//--------------------------
@ -321,6 +364,7 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname)
if(cl[i].item_tax_rate && check_tax[account]!=null) {rate = flt(check_tax[account]);}
else // if particular item doesn't have particular rate it will take other charges rate
rate = flt(tax[t].rate);
//Check For Rate and get tax amount
var tax_amount = cur_frm.cscript.check_charge_type_and_get_tax_amount(doc,tax,t, cl[i], rate);

View File

@ -97,8 +97,8 @@ class DocType(TransactionBase):
# Get Item Details
def get_item_details(self, obj, arg =''):
arg = eval(arg)
import json
arg = json.loads(arg)
item = sql("select item_name,item_group, brand, description, min_order_qty, stock_uom, default_warehouse,lead_time_days, last_purchase_rate from `tabItem` where name = %s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())", (arg['item_code']), as_dict = 1)
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , arg['item_code'])
t = {}
@ -119,7 +119,7 @@ class DocType(TransactionBase):
'stock_uom' : item and item[0]['stock_uom'] or '',
'conversion_factor' : '1',
'warehouse' : wh,
'item_tax_rate' : str(t),
'item_tax_rate' : json.dumps(t),
'batch_no' : '',
'discount_rate' : 0
}

View File

@ -19,6 +19,9 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(doc.__islocal){
hide_field(['supplier_name','supplier_address','contact_person','address_display','contact_display','contact_mobile','contact_email']);
}
// defined in purchase_common.js
//cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {

View File

@ -40,7 +40,22 @@ class DocType(TransactionBase):
# Get Item Details
def get_item_details(self, arg =''):
if arg:
return get_obj(dt='Purchase Common').get_item_details(self,arg)
else:
obj = get_obj('Purchase Common')
for doc in self.doclist:
if doc.fields.get('item_code'):
temp = {
'item_code': doc.fields.get('item_code'),
'warehouse': doc.fields.get('warehouse')
}
ret = obj.get_item_details(self, json.dumps(temp))
for r in ret:
if not doc.fields.get(r):
doc.fields[r] = ret[r]
# Get UOM Details
def get_uom_details(self, arg = ''):

View File

@ -95,7 +95,8 @@ class DocType:
from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename[1])
if not type(content) == str:
# NOTE: Don't know why this condition exists
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
import webnotes.model.import_docs

View File

@ -31,6 +31,10 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
hide_field(['customer','customer_address','contact_person', 'customer_name','contact_display', 'customer_group']);
}
}
// defined in sales_common.js
cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
@ -268,6 +272,7 @@ cur_frm.cscript.quot_to_validate = function(doc,cdt,cdn){
//===================validation function =================================
cur_frm.cscript.validate = function(doc,cdt,cdn){
cur_frm.cscript['Re-Calculate Values'](doc, cdt, cdn);
cur_frm.cscript.quot_to_validate(doc,cdt,cdn);
}

View File

@ -60,8 +60,18 @@ class DocType(TransactionBase):
# Get Item Details
# -----------------
def get_item_details(self, item_code):
def get_item_details(self, item_code=None):
if item_code:
return get_obj('Sales Common').get_item_details(item_code, self)
else:
obj = get_obj('Sales Common')
for doc in self.doclist:
if doc.fields.get('item_code'):
ret = obj.get_item_details(doc.item_code, self)
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
# --------------------------------------------------------------

View File

@ -15,6 +15,42 @@ cur_frm.cscript.load_taxes = function(doc, cdt, cdn) {
}
// Gets called after existing item details are update to fill in
// remaining default values
cur_frm.cscript.load_defaults = function(doc, dt, dn) {
if(!cur_frm.doc.__islocal) { return; }
doc = locals[doc.doctype][doc.name];
var fields_to_refresh = LocalDB.set_default_values(doc);
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
fields_to_refresh = null;
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
if(!children) { return; }
for(var i=0; i<children.length; i++) {
LocalDB.set_default_values(children[i]);
}
refresh_field(cur_frm.cscript.fname);
}
// Update existing item details
cur_frm.cscript.update_item_details = function(doc, dt, dn) {
if(!cur_frm.doc.__islocal) return;
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
if(children) {
$c_obj(make_doclist(doc.doctype, doc.name), 'get_item_details', '',
function(r, rt) {
if(!r.exc) {
refresh_field(cur_frm.cscript.fname);
doc = locals[doc.doctype][doc.name];
cur_frm.cscript.load_defaults(doc, dt, dn);
}
});
}
}
// -----------------
// Shipping Address
// -----------------
@ -171,7 +207,7 @@ cur_frm.cscript.export_rate = function(doc,cdt,cdn) {
var cur_rec = locals[cdt][cdn];
var fname = cur_frm.cscript.fname;
var tname = cur_frm.cscript.tname;
if(flt(cur_rec.ref_rate)>0 && flt(cur_rec.export_rate)>0 && !flt(cur_rec.adj_rate)) {
if(flt(cur_rec.ref_rate)>0 && flt(cur_rec.export_rate)>0) {
var adj_rate = 100 * (1 - (flt(cur_rec.export_rate) / flt(cur_rec.ref_rate)));
set_multiple(tname, cur_rec.name, { 'adj_rate': adj_rate }, fname);
}
@ -293,8 +329,13 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname)
for(var i=0;i<cl.length;i++) {
net_total += flt(flt(cl[i].qty) * flt(cl[i].basic_rate));
var prev_total = flt(cl[i].amount);
if(cl[i].item_tax_rate)
if(cl[i].item_tax_rate) {
try {
var check_tax = JSON.parse(cl[i].item_tax_rate); //to get in dictionary
} catch(exception) {
var check_tax = eval('var a='+cl[i].item_tax_rate+';a'); //to get in dictionary
}
}
// Add Item Code in new Row
$td(otc,i+1,0).innerHTML = cl[i].item_code ? cl[i].item_code : cl[i].description;
@ -409,8 +450,11 @@ cur_frm.cscript.consider_incl_rate = function(doc, other_fname) {
cur_frm.cscript.back_calc_basic_rate = function(doc, tname, fname, child, other_fname) {
var get_item_tax_rate = function(item, tax) {
if(item.item_tax_rate) {
// Should to replace eval with JSON.parse when item_tax_rate is converted to json string notation
try {
var item_tax = JSON.parse(item.item_tax_rate);
} catch(exception) {
var item_tax = eval('var a='+item.item_tax_rate+';a');
}
if(item_tax[tax.account_head]!=null) {
return flt(item_tax[tax.account_head]);
}

View File

@ -109,6 +109,7 @@ class DocType(TransactionBase):
# Get Item Details
# ===============================================================
def get_item_details(self, item_code, obj):
import json
if not obj.doc.price_list_name:
msgprint("Please Select Price List before selecting Items")
raise Exception
@ -130,7 +131,7 @@ class DocType(TransactionBase):
'adj_rate' : 0,
'amount' : 0,
'export_amount' : 0,
'item_tax_rate' : str(t),
'item_tax_rate' : json.dumps(t),
'batch_no' : ''
}
if(obj.doc.price_list_name and item): #this is done to fetch the changed BASIC RATE and REF RATE based on PRICE LIST

View File

@ -22,6 +22,9 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(doc.__islocal){
hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','shipping_address']);
}
// defined in sales_common.js
cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {

View File

@ -85,8 +85,18 @@ class DocType(TransactionBase):
# ================================================================================
# Get Item Details
# ----------------
def get_item_details(self, item_code):
def get_item_details(self, item_code=None):
if item_code:
return get_obj('Sales Common').get_item_details(item_code, self)
else:
obj = get_obj('Sales Common')
for doc in self.doclist:
if doc.fields.get('item_code'):
ret = obj.get_item_details(doc.item_code, self)
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
# --------------------------------------------------------------

View File

@ -763,7 +763,7 @@ def send():
"""
edigest_list = webnotes.conn.sql("""
SELECT name FROM `tabEmail Digest`
WHERE enabled=1
WHERE enabled=1 and docstatus<2
""", as_list=1)
from webnotes.model.code import get_obj

View File

@ -86,7 +86,8 @@ class DocType:
from webnotes.utils import file_manager
fn, content = file_manager.get_file(fid)
if not type(content) == str:
# NOTE: Don't know why this condition exists
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
return content

View File

@ -97,7 +97,8 @@ class DocType:
from webnotes.utils import file_manager
fn, content = file_manager.get_file(fid)
if not type(content) == str:
# NOTE: Don't know why this condition exists
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
return content

View File

@ -23,6 +23,10 @@ cur_frm.cscript.onload = function(doc, dt, dn) {
if(doc.__islocal){
hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
// defined in sales_common.js
//cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {

View File

@ -100,8 +100,18 @@ class DocType(TransactionBase):
# ================================================================================
# ***************** Get Item Details ******************************
def get_item_details(self, item_code):
def get_item_details(self, item_code=None):
if item_code:
return get_obj('Sales Common').get_item_details(item_code, self)
else:
obj = get_obj('Sales Common')
for doc in self.doclist:
if doc.fields.get('item_code'):
ret = obj.get_item_details(doc.item_code, self)
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 ***
def get_adj_percent(self, arg=''):

View File

@ -20,6 +20,8 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(doc.supplier) unhide_field(['supplier_name','supplier_address','contact_person','address_display','contact_display','contact_mobile','contact_email']);
// defined in purchase_common.js
cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
@ -237,7 +239,7 @@ cur_frm.cscript['Make Purchase Invoice'] = function() {
'from_doctype': cur_frm.doc.doctype,
'to_doctype':'Payable Voucher',
'from_docname': cur_frm.doc.name,
'from_to_list':"[['Purchase Receipt','Payable Voucher'],['Purchase Receipt Detail','PV Detail']]"
'from_to_list':"[['Purchase Receipt','Payable Voucher'],['Purchase Receipt Detail','PV Detail'],['Purchase Tax Detail','Purchase Tax Detail']]"
}, function(r,rt) {
loaddoc('Payable Voucher', n);
}

View File

@ -46,7 +46,22 @@ class DocType(TransactionBase):
# Get Item Details
def get_item_details(self, arg = ''):
if arg:
return get_obj(dt='Purchase Common').get_item_details(self,arg)
else:
import json
obj = get_obj('Purchase Common')
for doc in self.doclist:
if doc.fields.get('item_code'):
temp = {
'item_code': doc.fields.get('item_code'),
'warehouse': doc.fields.get('warehouse')
}
ret = obj.get_item_details(self, json.dumps(temp))
for r in ret:
if not doc.fields.get(r):
doc.fields[r] = ret[r]
# Get UOM Details
def get_uom_details(self, arg = ''):

View File

@ -25,7 +25,8 @@ class DocType:
from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename[1])
if not type(content) == str:
# NOTE: Don't know why this condition exists
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
return content

View File

@ -107,7 +107,7 @@ class DocType:
prev_sle = bin_obj.get_prev_sle(posting_date, posting_time)
if not prev_sle:
return 0.0
fcfs_stack = eval(prev_sle.get('fcfs_stack', '[]'))
fcfs_stack = eval(str(prev_sle.get('fcfs_stack', '[]')))
in_rate = fcfs_stack and self.get_fifo_rate(fcfs_stack) or 0
elif val_method == 'Moving Average':
prev_sle = bin_obj.get_prev_sle(posting_date, posting_time)

View File

@ -1,4 +1,5 @@
import webnotes
from webnotes.utils import cstr
from webnotes.utils.email_lib.receive import POP3Mailbox
@ -111,7 +112,7 @@ class SupportMailbox(POP3Mailbox):
status = add_file_list('Support Ticket', doc.name, attachment['filename'], fid)
if not status:
doc.description = doc.description \
+ "\nCould not attach: " + str(attachment['filename'])
+ "\nCould not attach: " + cstr(attachment['filename'])
doc.save()
webnotes.conn.commit()
@ -137,7 +138,7 @@ We will get back to you as soon as possible
sendmail(\
recipients = [d.raised_by], \
sender = self.email_settings.support_email, \
subject = '['+d.name+'] ' + str(d.subject or ''), \
subject = '['+d.name+'] ' + cstr(d.subject), \
msg = response)
def auto_close_tickets(self):

View File

@ -76,7 +76,8 @@ class DocType:
from webnotes.utils import file_manager
fn, content = file_manager.get_file(fid)
if not type(content) == str:
# NOTE: Don't know why this condition exists
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
return content

View File

@ -5,12 +5,13 @@ erpnext.make_product_categories = function(wrapper) {
wrapper.category_list = new wn.widgets.Listing({
parent: $(wrapper).find('.web-side-section').get(0),
query: 'select label, count(t2.name) as items, t1.item_group \
from `tabProduct Group` t1, `tabItem` t2\
from `tabProduct Group` t1, `tabProduct` t2, tabItem t3\
where t1.parent="Products Settings" \
and t2.item_group = t1.item_group \
and ifnull(t2.show_in_website, 0)=1 \
group by t2.item_group \
order by t1.idx desc',
and t2.item = t3.name \
and t3.item_group = t1.item_group \
and ifnull(t2.published, 0)=1 \
group by t1.item_group \
order by t1.idx',
hide_refresh: true,
render_row: function(parent, data) {
parent.innerHTML = repl('<a href="#!products/%(label)s">%(label)s</a> (%(items)s)',

View File

@ -57,6 +57,7 @@ erpnext.products.make_product_list = function(wrapper) {
t1.page_name, t1.short_description \
from tabProduct t1, tabItem t2 \
where t1.item = t2.name \
and ifnull(t1.published,0)=1 \
and t2.item_group="%(cat)s" \
%(search_cond)s', args)
},
@ -66,7 +67,7 @@ erpnext.products.make_product_list = function(wrapper) {
<div style="float:left; width: 400px">\
<b><a href="#!%(page_name)s">%(title)s</a></b>\
<p>%(short_description)s</p></div>\
<div style="clear: both; margin-bottom: 7px;"></div>', data);
<div style="clear: both; margin-bottom: 15px; border-bottom: 1px solid #AAA"></div>', data);
}
});