Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Rushabh Mehta 2012-03-01 18:42:44 +05:30
commit f6cca4f218
18 changed files with 943 additions and 219 deletions

View File

@ -177,7 +177,7 @@ class DocType:
#----------------------------------------------------------------------------
def make_single_entry(self,parent,d,le_map,cancel, merge_entries):
if self.get_val(le_map['account'], d, parent) and (self.get_val(le_map['debit'], d, parent) or self.get_val(le_map['credit'], d, parent)):
flist = ['account','cost_center','against','debit','credit','remarks','voucher_type','voucher_no','transaction_date','posting_date','fiscal_year','against_voucher','against_voucher_type','company','is_opening', 'aging_date']
flist = ['account','cost_center','against','debit','credit','remarks','voucher_type','voucher_no','posting_date','fiscal_year','against_voucher','against_voucher_type','company','is_opening', 'aging_date']
# Check budget before gl entry
#check budget only if account is expense account
@ -536,7 +536,6 @@ def create_new_invoice(prev_rv):
# update new rv
new_rv.doc.voucher_date = new_rv.doc.next_date
new_rv.doc.posting_date = new_rv.doc.next_date
new_rv.doc.aging_date = new_rv.doc.next_date
new_rv.doc.due_date = add_days(new_rv.doc.next_date, cint(date_diff(prev_rv.doc.due_date, prev_rv.doc.posting_date)))

View File

@ -533,7 +533,7 @@ class DocType(TransactionBase):
self.values.append({
'item_code' : d.item_code,
'warehouse' : wh,
'transaction_date' : self.doc.voucher_date,
'transaction_date' : getdate(self.doc.modified).strftime('%Y-%m-%d'),
'posting_date' : self.doc.posting_date,
'posting_time' : self.doc.posting_time,
'voucher_type' : 'Receivable Voucher',

View File

@ -66,7 +66,7 @@ for r in row_list:
for r in res:
if r[col_idx['Against Receivable']]:
dt=sql("select voucher_date, Aging_date from `tabReceivable Voucher` where name='%s'"%r[col_idx['Against Receivable']])
dt=sql("select date(modified), Aging_date from `tabReceivable Voucher` where name='%s'"%r[col_idx['Against Receivable']])
r.append('')
r.append(dt and cstr(dt[0][0]) or '')
r.append(dt and cstr(dt[0][1]) or '')
@ -103,4 +103,4 @@ for r in res:
r.append(val_l2)
r.append(val_l3)
r.append(val_l4)
r.append(val_l5_above)
r.append(val_l5_above)

View File

@ -66,7 +66,7 @@ for r in row_list:
for r in res:
if r[col_idx['Against Payable']]:
dt=sql("select voucher_date, aging_date from `tabPayable Voucher` where name='%s'"%r[col_idx['Against Payable']])
dt=sql("select date(modified), aging_date from `tabPayable Voucher` where name='%s'"%r[col_idx['Against Payable']])
r.append('')
r.append(dt and cstr(dt[0][0]) or '')
r.append(dt and cstr(dt[0][1]) or '')
@ -102,4 +102,4 @@ for r in res:
r.append(val_l2)
r.append(val_l3)
r.append(val_l4)
r.append(val_l5_above)
r.append(val_l5_above)

View File

@ -16,6 +16,4 @@
def execute():
import webnotes
webnotes.conn.sql("""
delete from __SessionCache
""")
webnotes.clear_cache()

View File

@ -0,0 +1,7 @@
def execute():
import webnotes
from webnotes.modules.module_manager import reload_doc
webnotes.conn.sql("delete from `tabField Mapper Detail` where from_field = 'transaction_date' and parent in ('Sales Order-Delivery Note', 'Purchase Order-Purchase Receipt')")
reload_doc('stock', 'DocType Mapper', 'Sales Order-Delivery Note')
reload_doc('stock', 'DocType Mapper', 'Purchase Order-Purchase Receipt')

View File

@ -33,10 +33,10 @@ def execute():
}
for d in del_flds:
webnotes.conn.sql("delete from `tabDocField` where fieldname in (%s) and parent = %s", (del_flds[d], d))
webnotes.conn.sql("delete from `tabDocField` where fieldname in (%s) and parent = '%s'"% (del_flds[d], d))
for d in del_labels:
webnotes.conn.sql("delete from `tabDocField` where label in (%s) and parent = %s", (del_labels[d], d))
webnotes.conn.sql("delete from `tabDocField` where label in (%s) and parent = '%s'"% (del_labels[d], d))
delete_doc('DocType', 'Update Delivery Date Detail')

View File

@ -32,6 +32,21 @@ convert_to_lists = webnotes.conn.convert_to_lists
from utilities.transaction_base import TransactionBase
@webnotes.whitelist()
def get_comp_base_currency(arg=None):
""" get default currency of company"""
return webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", webnotes.form_dict['company'])[0][0]
@webnotes.whitelist()
def get_price_list_currency(arg=None):
""" Get all currency in which price list is maintained"""
plc = webnotes.conn.sql("select distinct ref_currency from `tabRef Rate Detail` where price_list_name = %s", webnotes.form_dict['price_list'])
plc = [d[0] for d in plc]
base_currency = get_comp_base_currency(webnotes.form_dict['company'])
return plc, base_currency
class DocType(TransactionBase):
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
@ -770,16 +785,3 @@ class StatusUpdater:
name="%(name)s"
""" % args)
@webnotes.whitelist()
def get_comp_base_currency(arg=None):
""" get default currency of company"""
return webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", webnotes.form_dict['company'])[0][0]
@webnotes.whitelist()
def get_price_list_currency(arg=None):
""" Get all currency in which price list is maintained"""
plc = webnotes.conn.sql("select distinct ref_currency from `tabRef Rate Detail` where price_list_name = %s", webnotes.form_dict['price_list'])
plc = [d[0] for d in plc]
base_currency = get_comp_base_currency(webnotes.form_dict['company'])
return plc, base_currency

View File

@ -60,7 +60,7 @@ elif based_on == 'Sales Partner':
if under == 'Receivable Voucher':
under_detail = 'RV'
dt = 'voucher_date'
dt = 'posting_date'
else:
under_detail = under
dt = "transaction_date"
@ -516,4 +516,4 @@ for r in res:
tot_target = 0
elif tl == 1:
out.append(r)
out.append(r)

View File

@ -0,0 +1,562 @@
// common partner functions
// =========================
/*
// make shipping list body
// ------------------------
cur_frm.cscript.make_sl_body = function(){
cur_frm.fields_dict['Shipping HTML'].wrapper.innerHTML = '';
cur_frm.shipping_html = $a(cur_frm.fields_dict['Shipping HTML'].wrapper,'div');
}
*/
// make history list body
// -----------------------
cur_frm.cscript.make_hl_body = function(){
cur_frm.fields_dict['History HTML'].wrapper.innerHTML = '';
cur_frm.history_html = $a(cur_frm.fields_dict['History HTML'].wrapper,'div');
}
/*
// set shipping list message
// --------------------------
cur_frm.cscript.set_sl_msg = function(doc){
cur_frm.shipping_html.innerHTML = 'Shipping Address Details will appear only when you save the ' + doc.doctype.toLowerCase();
}
*/
/*
// set history list message
// -------------------------
cur_frm.cscript.set_hl_msg = function(doc){
cur_frm.history_html.innerHTML= 'History Details will appear only when you save the ' + doc.doctype.toLowerCase();
}
*/
/*
// make shipping address
// -------------
cur_frm.cscript.make_shipping_address = function(doc, dt, dn){
cur_frm.shipping_html.innerHTML = '';
var dsn = cur_frm.doc.customer_name;
var dsa = cur_frm.doc.address;
cl = new AddressList(cur_frm.shipping_html,dt,dn,dsn,dsa);
}
*/
// make history
// -------------
cur_frm.cscript.make_history = function(doc,dt,dn){
cur_frm.history_html.innerHTML = '';
cur_frm.cscript.make_history_list(cur_frm.history_html,doc);
}
// make history list
// ------------------
cur_frm.cscript.make_history_list = function(parent,doc){
var sel = $a(parent,'select');
var ls = ['Select Transaction..'];
for(d in cur_frm.history_dict){
ls.push(d);
}
add_sel_options(sel,ls,'Select..');
var body = $a(parent,'div');
body.innerHTML = '<div class="help_box">Please select a transaction type to see History</div>';
sel.body = body;
sel.doc = doc;
sel.onchange = function(){
for(d in cur_frm.history_dict){
if(sel_val(this) == d){
this.body.innerHTML = '';
eval(cur_frm.history_dict[d]);
return;
}
else{
// pass
}
}
}
}
// run list
// ---------
cur_frm.cscript.run_list = function(lst,parent,q,q_max,doc,dn,nm){
parent.innerHTML = '';
$dh(parent);
lst.doc = doc;
lst.dn = dn;
lst.nm = nm;
lst.page_len = 10;
lst.get_query = function(){
this.query = q;
this.query_max = q_max;
}
lst.make(parent);
lst.run();
lst.onrun = function(){
$ds(parent);
if(!this.has_data()){
parent.innerHTML = '';
var dv = $a(parent,'div','help_box');
$a(dv,'span').innerHTML = "No " + this.dn + " found. ";
var lbl = 'Create the <b>first</b> ' + this.dn + ' for ' + this.doc.name;
var sp = $a(dv,'span');
sp.nm = this.nm;
$(sp).html(lbl).addClass('link_type').click(function(){ newdoc(this.nm); });
}
}
}
// get sates on country trigger
// -----------------------------
cur_frm.cscript.get_states=function(doc,dt,dn){
$c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])},
function(r,rt){
if(r.message) {
set_field_options('state', r.message);
}
}
);
}
cur_frm.cscript.country = function(doc, dt, dn) {
cur_frm.cscript.get_states(doc, dt, dn);
}
// territory help - cutsomer + sales partner
// -----------------------------------------
cur_frm.cscript.TerritoryHelp = function(doc,dt,dn){
var call_back = function(){
var sb_obj = new SalesBrowser();
sb_obj.set_val('Territory');
}
loadpage('Sales Browser',call_back);
}
// get query select Territory
// ---------------------------
if(cur_frm.fields_dict['territory']){
cur_frm.fields_dict['territory'].get_query = function(doc,dt,dn) {
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';
}
}
// =======================================================================================================
// contact list
// --------------
ContactList = function(parent,dt,dn,dsn){
var me = this;
this.dt = dt;
this.dn = dn;
this.dsn = dsn ? dsn : dn;
this.wrapper = $a(parent,'div');
me.get_list();
}
// add contact
// ------------
ContactList.prototype.add_contact = function(){
var me = this;
// onload - set default values
var cont = LocalDB.create('Contact');
var c = locals['Contact'][cont];
if(me.dt == 'Customer') {
c.is_customer = 1;
c.customer = me.dn;
c.customer_name = me.dsn;
}
else if(me.dt == 'Supplier'){
c.is_supplier = 1;
c.supplier = me.dn;
c.supplier_name = me.dsn;
}
else if(me.dt == 'Sales Partner'){
c.is_sales_partner = 1;
c.sales_partner = me.dn;
//c.sales_partner_name = me.dsn;
}
loaddoc('Contact',c.name);
}
// get contact list
// -----------------
ContactList.prototype.get_list = function(){
var me = this;
me.make_list();
var dt = me.dt.toLowerCase().split(' ').join('_');
// build query
me.lst.get_query = function(){
this.query = repl("select name, first_name, last_name, concat_ws(' ', first_name, last_name), email_id, contact_no, department, designation, is_primary_contact, has_login, disable_login from tabContact where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
this.query_max = repl("select count(name) from tabContact where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
}
// render list ui
me.lst.show_cell = function(cell,ri,ci,d){
me.render_list(cell,ri,ci,d);
}
// run query
me.lst.run();
// onrun
me.lst.onrun = function(){
if(!this.has_data()){
this.rec_label.innerHTML = '';
$a(this.rec_label,'span').innerHTML = "You do not have any contact. ";
$($a(this.rec_label,'span')).html('Add a new contact').addClass('link_type').click(function(){ me.add_contact(); });
$dh(this.results);
}
else{
$ds(this.results);
}
}
}
// make list
// -----------
ContactList.prototype.make_list = function(){
var me = this;
var l = new Listing();
l.colwidths = ['5%','30%','30%','20%','20%'];
l.colnames = ['Sr.','Contact Name','Email Id','Contact No', 'Action'];
l.page_len = 10;
me.lst = l;
l.make(me.wrapper);
// Add contact button
me.add_btn = $btn(l.btn_area,'+ Add Contact', function(){ me.add_contact();}, {fontWeight:'bold'});
}
// make contact cell
// ------------------
ContactList.prototype.render_list = function(cell,ri,ci,d){
var me = this;
// name
if(ci == 0){
var nm = $a($a(cell,'div'),'span','',{cursor:'pointer'});
nm.innerHTML = d[ri][3];
nm.id = d[ri][0];
nm.onclick = function(){
loaddoc('Contact', this.id);
// on save callback - refresh list
}
// department and designation
var des = d[ri][7] ? d[ri][7] : '';
var dep = d[ri][6] ? d[ri][6] : '';
var sp = $a(cell,'div','comment');
sp.innerHTML = des + (dep ? (', ' + dep) : '');
}
// email id, contact no, department, designation
// -----------------------------------------------------
if(ci == 1) cell.innerHTML = d[ri][4] ? d[ri][4] : '-';
if(ci == 2) cell.innerHTML = d[ri][5] ? d[ri][5] : '-';
// actions
// --------------------------------------
if(ci== 3) me.make_actions(cell,ri,ci,d);
}
// make actions
// ---------------
ContactList.prototype.make_actions = function(cell,ri,ci,d){
var me = this;
var tab = make_table(cell,1,2,'100%',['40%','60%']);
// Edit and Delete
var t = make_table($td(tab,0,0),1,2);
var edit = $a($td(t,0,0),'div','wn-icon ic-doc_edit');
$(edit).click(function(){ loaddoc('Contact',d[ri][0]); });
edit.setAttribute('title','Edit');
// Below code should be uncommented once customer/venodr invitation process is stable
// ===========================================================================
/*
var del = $a($td(t,0,1),'div','wn-icon ic-trash');
$(del).click(function(){ me.delete_contact(d[ri][0],d[ri][4]) });
set_custom_tooltip(del, 'Delete');
// Invite, Enable and Disable - Integrate after gateway logic incorporated
if(d[ri][9] == 'Yes') {
if(d[ri][10] == 'Yes'){
var enb = $a($td(tab,0,1),'div','wn-icon ic-checkmark');
$(enb).click(function(){ me.enable_login(d[ri][0], d[ri][4]); });
}
else{
var dsb = $a($td(tab,0,1),'div','wn-icon ic-delete');
$(dsb).click(function(){ me.disable_login(d[ri][0], d[ri][4]) });
}
}
else{
var inv = $a($td(tab,0,1),'div','wn-icon ic-mail');
$(inv).click(function(){ me.invite_contact(d[ri][0], d[ri][4], d[ri][1], d[ri][2]) });
}*/
}
// enable login
// ----------------------------------------------------------
ContactList.prototype.enable_login = function(id, email_id){
var me = this;
var callback = function(r,rt){
me.get_list();
if(!r.exc) msgprint('Login for contact enabled',1);
else errprint(r.exc);
}
var args = {};
args.contact = id;
args.email = email_id;
$c_obj('Contact Control','enable_login',JSON.stringify(args),callback);
}
// disable login
// -------------------------------------------------------------
ContactList.prototype.disable_login = function(id, email_id){
var me = this;
var callback = function(r,rt){
me.get_list();
if(!r.exc) msgprint('Login for contact disabled',1);
else errprint(r.exc);
}
var args = {};
args.contact = id;
args.email = email_id;
$c_obj('Contact Control','disable_login',JSON.stringify(args),callback);
}
// delete contact
// -----------------
ContactList.prototype.delete_contact = function(id,email_id,has_login){
var me = this;
var callback = function(r,rt){
me.get_list();
if(!r.exc) msgprint('Contact deleted successfully');
else errprint(r.exc);
}
var args = {};
args.contact = id;
args.email = email_id;
args.has_login = has_login;
$c_obj('Contact Control','delete_contact',JSON.stringify(args),callback);
}
// invite user
// --------------------------------------------------------
ContactList.prototype.invite_contact = function(id,email_id,first_name,last_name){
var me = this;
if(!email_id){
msgprint("Please add email id and save the contact first. You can then invite contact to view transactions.")
}
else{
var callback = function(r,rt){
if(!r.exc) msgprint('Invitation sent');
else errprint(r.exc);
}
var args = {
'contact' : id,
'email' : email_id,
'first_name' : first_name ? first_name : '',
'last_name' : last_name ? last_name : '',
'usert_type' : 'Partner'
};
$c_obj('Contact Control','invite_contact',JSON.stringify(args),callback);
}
}
// address list
// --------------
AddressList = function(parent,dt,dn,dsn,dsa){
var me = this;
this.dt = dt;
this.dn = dn;
this.dsn = dsn ? dsn : dn;
this.dsa = dsa ? dsa : '';
this.wrapper = $a(parent,'div');
me.get_addr_list();
}
// add contact
// ------------
AddressList.prototype.add_address = function(){
var me = this;
// onload - set default values
var addr = LocalDB.create('Shipping Address');
var a = locals['Shipping Address'][addr];
a.customer = me.dn;
a.customer_name = me.dsn;
a.customer_address = me.dsa;
loaddoc('Shipping Address',a.name);
}
// get address list
// -----------------
AddressList.prototype.get_addr_list = function(){
var me = this;
me.make_addr_list();
var dt = me.dt.toLowerCase().split(' ').join('_');
// build query
me.lst.get_query = function(){
this.query = repl("select name, ship_to, shipping_address, is_primary_address, shipping_details from `tabShipping Address` where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
this.query_max = repl("select count(name) from `tabShipping Address` where %(dt)s = '%(dn)s'",{'dt':dt, 'dn':me.dn});
}
// render list ui
me.lst.show_cell = function(cell,ri,ci,d){
me.render_list(cell,ri,ci,d);
}
// run query
me.lst.run();
// onrun
me.lst.onrun = function(){
if(!this.has_data()){
this.rec_label.innerHTML = '';
$a(this.rec_label,'span').innerHTML = "You do not have any shipping address.";
$($a(this.rec_label,'span')).html('Add a new address').addClass('link_type').click(function(){ me.add_address(); });
$dh(this.results);
}
else{
$ds(this.results);
}
}
}
// make list
// -----------
AddressList.prototype.make_addr_list = function(){
var me = this;
var l = new Listing();
l.colwidths = ['5%', '15%', '25%','10%','35%','10%'];
l.colnames = ['Sr.', 'Ship To', 'Shipping Address','Primary Address', 'Shipping Details', 'Action'];
l.page_len = 10;
me.lst = l;
l.make(me.wrapper);
// Add address button
me.add_btn = $btn(l.btn_area,'+ Add Address', function(){ me.add_address();}, {fontWeight:'bold'});
}
// make address cell
// ------------------
AddressList.prototype.render_list = function(cell,ri,ci,d){
var me = this;
// name
if(ci == 0){
var nm = $a($a(cell,'div'),'span','',{cursor:'pointer'});
nm.innerHTML = d[ri][1];
nm.id = d[ri][0];
nm.onclick = function(){
loaddoc('Shipping Address', this.id);
}
}
// shipping address, primary address, shipping details
// ----------------------------------------------------
if(ci == 1) cell.innerHTML = d[ri][2] ? d[ri][2] : '-';
if(ci == 2) cell.innerHTML = d[ri][3] ? d[ri][3] : '-';
if(ci == 3) cell.innerHTML = d[ri][4] ? d[ri][4] : '-';
// actions
// --------------------------------------
if(ci== 4) me.make_actions(cell,ri,ci,d);
}
// make actions
// ---------------
AddressList.prototype.make_actions = function(cell,ri,ci,d){
var me = this;
var tab = make_table(cell,1,2,'100%',['40%','60%']);
// Edit and Delete
var t = make_table($td(tab,0,0),1,2);
var edit = $a($td(t,0,0),'div','wn-icon ic-doc_edit');
$(edit).click(function(){ loaddoc('Shipping Address',d[ri][0]); });
edit.setAttribute('title','Edit');
}

View File

@ -0,0 +1,103 @@
# Please edit this list and import only required elements
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
from webnotes.model.doclist import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, is_testing, msgprint, errprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self,doc,doclist=[]):
self.doc = doc
self.doclist = doclist
def enable_login(self,arg):
arg = eval(arg)
sql("update tabContact set disable_login = 'No' where name=%s",arg['contact'])
sql("update tabProfile set enabled=1 where name=%s",arg['email'])
def disable_login(self,arg):
arg = eval(arg)
sql("update tabContact set disable_login = 'Yes' where name=%s",arg['contact'])
sql("update tabProfile set enabled=0 where name=%s",arg['email'])
def create_login(self,arg):
arg = eval(arg)
cont_det = sql("select * from tabContact where name=%s",(arg['contact']),as_dict=1)
if cont_det[0]['docstatus'] !=0:
msgprint('Please save the corresponding contact first')
raise Exception
if sql("select name from tabProfile where name=%s",cont_det[0]['email_id']):
msgprint('Profile with same name already exist.')
raise Exception
else:
p = Document('Profile')
p.name = cont_det[0]['email_id']
p.first_name = cont_det[0]['first_name']
p.last_name = cont_det[0]['last_name']
p.email = cont_det[0]['email_id']
p.cell_no = cont_det[0]['contact_no']
p.password = 'password'
p.enabled = 1
p.user_type = 'Partner';
p.save(1)
get_obj(doc=p).on_update()
role = []
if cont_det[0]['contact_type'] == 'Individual':
role = ['Customer']
else:
if cont_det[0]['is_customer']:
role.append('Customer')
if cont_det[0]['is_supplier']:
role.append('Supplier')
if cont_det[0]['is_sales_partner']:
role.append('Partner')
if role:
prof_nm = p.name
for i in role:
r = Document('UserRole')
r.parent = p.name
r.role = i
r.parenttype = 'Profile'
r.parentfield = 'userroles'
r.save(1)
if i == 'Customer':
def_keys = ['from_company','customer_name','customer']
def_val = cont_det[0]['customer_name']
self.set_default_val(def_keys,def_val,prof_nm)
if i == 'Supplier':
def_keys = ['supplier_name','supplier']
def_val = cont_det[0]['supplier_name']
self.set_default_val(def_keys,def_val,prof_nm)
sql("update tabContact set has_login = 'Yes' where name=%s",cont_det[0]['name'])
sql("update tabContact set disable_login = 'No' where name=%s",cont_det[0]['name'])
msgprint('User login is created.')
#------set default values---------
def set_default_val(self,def_keys,def_val,prof_nm):
for d in def_keys:
kv = Document('DefaultValue')
kv.defkey = d
kv.defvalue = def_val
kv.parent = prof_nm
kv.parenttype = 'Profile'
kv.parentfield = 'defaults'
kv.save(1)

View File

@ -0,0 +1,88 @@
# DocType, Contact Control
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:08:56',
'docstatus': 0,
'modified': '2010-09-20 14:06:57',
'modified_by': 'yogesh@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'colour': 'White:FFF',
'doctype': 'DocType',
'in_create': 1,
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'read_only': 1,
'section_style': 'Simple',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 25
},
# These values are common for all DocField
{
'doctype': 'DocField',
'fieldtype': 'Text',
'name': '__common__',
'parent': 'Contact Control',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 0,
'doctype': 'DocPerm',
'idx': 1,
'name': '__common__',
'parent': 'Contact Control',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'System Manager',
'write': 1
},
# DocType, Contact Control
{
'doctype': 'DocType',
'name': 'Contact Control'
},
# DocPerm
{
'doctype': 'DocPerm'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'header',
'idx': 1,
'label': 'Header'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'customer_intro',
'idx': 2,
'label': 'Customer Intro'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'supplier_intro',
'idx': 3,
'label': 'Supplier Intro'
}
]

View File

@ -8,11 +8,11 @@
#
# This program is distributed in the hope that it will be useful,
# 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.
#
# 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
import webnotes
@ -34,33 +34,33 @@ convert_to_lists = webnotes.conn.convert_to_lists
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
self.nsm_parent_field = 'parent_item_group';
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
self.nsm_parent_field = 'parent_item_group';
# update Node Set Model
def update_nsm_model(self):
import webnotes
import webnotes.utils.nestedset
webnotes.utils.nestedset.update_nsm(self)
# update Node Set Model
def update_nsm_model(self):
import webnotes
import webnotes.utils.nestedset
webnotes.utils.nestedset.update_nsm(self)
# ON UPDATE
#--------------------------------------
def on_update(self):
# update nsm
self.update_nsm_model()
# ON UPDATE
#--------------------------------------
def on_update(self):
# update nsm
self.update_nsm_model()
def validate(self):
if self.doc.lft and self.doc.rgt:
res = sql("select name from `tabItem Group` where is_group = 'Yes' and docstatus!= 2 and (rgt > %s or lft < %s) and name ='%s' and name !='%s'"%(self.doc.rgt,self.doc.lft,self.doc.parent_item_group,self.doc.item_group_name))
if not res:
msgprint("Please enter proper parent item group.")
raise Exception
r = sql("select name from `tabItem Group` where name = '%s' and docstatus = 2"%(self.doc.item_group_name))
if r:
msgprint("'%s' record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.item_group_name))
raise Exception
def validate(self):
if self.doc.lft and self.doc.rgt:
res = sql("select name from `tabItem Group` where is_group = 'Yes' and docstatus!= 2 and (rgt > %s or lft < %s) and name ='%s' and name !='%s'"%(self.doc.rgt,self.doc.lft,self.doc.parent_item_group,self.doc.item_group_name))
if not res:
msgprint("Please enter proper parent item group.")
raise Exception
r = sql("select name from `tabItem Group` where name = '%s' and docstatus = 2"%(self.doc.item_group_name))
if r:
msgprint("'%s' record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.item_group_name))
raise Exception
def on_trash(self):
ig = sql("select name from `tabItem` where ifnull(item_group, '') = %s", self.doc.name)

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2010-09-20 12:33:34',
'creation': '2010-08-08 17:09:35',
'docstatus': 0,
'modified': '2012-03-01 14:01:03',
'modified': '2012-03-01 17:58:16',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -22,6 +22,7 @@
# These values are common for all Field Mapper Detail
{
'doctype': u'Field Mapper Detail',
'map': u'Yes',
'name': '__common__',
'parent': u'Purchase Order-Purchase Receipt',
'parentfield': u'field_mapper_details',
@ -49,7 +50,6 @@
'checking_operator': u'=',
'doctype': u'Field Mapper Detail',
'from_field': u'supplier',
'map': u'Yes',
'match_id': 0,
'to_field': u'supplier'
},
@ -59,7 +59,6 @@
'checking_operator': u'=',
'doctype': u'Field Mapper Detail',
'from_field': u'company',
'map': u'Yes',
'match_id': 0,
'to_field': u'company'
},
@ -69,7 +68,6 @@
'checking_operator': u'=',
'doctype': u'Field Mapper Detail',
'from_field': u'currency',
'map': u'Yes',
'match_id': 0,
'to_field': u'currency'
},
@ -78,7 +76,6 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'name',
'map': u'Yes',
'match_id': 1,
'to_field': u'prevdoc_detail_docname'
},
@ -87,7 +84,6 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'parent',
'map': u'Yes',
'match_id': 1,
'to_field': u'prevdoc_docname'
},
@ -96,7 +92,6 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'parenttype',
'map': u'Yes',
'match_id': 1,
'to_field': u'prevdoc_doctype'
},
@ -106,7 +101,6 @@
'checking_operator': u'=',
'doctype': u'Field Mapper Detail',
'from_field': u'item_code',
'map': u'Yes',
'match_id': 1,
'to_field': u'item_code'
},
@ -115,7 +109,6 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'eval:(flt(obj.qty) - flt(obj.received_qty)) ',
'map': u'Yes',
'match_id': 1,
'to_field': u'received_qty'
},
@ -124,7 +117,6 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'eval:(flt(obj.qty) - flt(obj.received_qty)) ',
'map': u'Yes',
'match_id': 1,
'to_field': u'qty'
},
@ -133,7 +125,6 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'eval:(flt(obj.qty) - flt(obj.received_qty)) * flt(obj.conversion_factor)',
'map': u'Yes',
'match_id': 1,
'to_field': u'stock_qty'
},
@ -142,7 +133,6 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'eval:(flt(obj.qty) - flt(obj.received_qty)) * flt(obj.import_rate)',
'map': u'Yes',
'match_id': 1,
'to_field': u'import_amount'
},
@ -151,7 +141,6 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'eval:(flt(obj.qty) - flt(obj.received_qty)) * flt(obj.purchase_rate)',
'map': u'Yes',
'match_id': 1,
'to_field': u'amount'
},
@ -160,7 +149,6 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'schedule_date',
'map': u'Yes',
'match_id': 1,
'to_field': u'schedule_date'
},
@ -169,7 +157,6 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'net_total',
'map': u'Yes',
'match_id': 0,
'to_field': u'net_total'
},
@ -178,7 +165,6 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'grand_total',
'map': u'Yes',
'match_id': 0,
'to_field': u'grand_total'
},
@ -187,25 +173,14 @@
{
'doctype': u'Field Mapper Detail',
'from_field': u'total_tax',
'map': u'Yes',
'match_id': 0,
'to_field': u'total_tax'
},
# Field Mapper Detail
{
'doctype': u'Field Mapper Detail',
'from_field': u'transaction_date',
'map': u'No',
'match_id': 0,
'to_field': u'transaction_date'
},
# Field Mapper Detail
{
'doctype': u'Field Mapper Detail',
'from_field': u'conversion_rate',
'map': u'Yes',
'match_id': 0,
'to_field': u'conversion_rate'
},

View File

@ -5,273 +5,263 @@
{
'creation': '2010-08-08 17:09:35',
'docstatus': 0,
'modified': '2011-09-14 12:36:25',
'modified_by': 'Administrator',
'owner': 'Administrator'
'modified': '2012-03-01 17:58:16',
'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': 'Sales Order-Delivery Note',
'parentfield': 'table_mapper_details',
'parenttype': 'DocType Mapper'
'parent': u'Sales Order-Delivery Note',
'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': 'Sales Order-Delivery Note',
'parentfield': 'field_mapper_details',
'parenttype': 'DocType Mapper'
'parent': u'Sales Order-Delivery Note',
'parentfield': u'field_mapper_details',
'parenttype': u'DocType Mapper'
},
# These values are common for all DocType Mapper
{
'doctype': u'DocType Mapper',
'from_doctype': 'Sales Order',
'module': 'Stock',
'from_doctype': u'Sales Order',
'module': u'Stock',
'name': '__common__',
'ref_doc_submitted': 1,
'to_doctype': 'Delivery Note'
'to_doctype': u'Delivery Note'
},
# DocType Mapper, Sales Order-Delivery Note
{
'doctype': u'DocType Mapper',
'name': 'Sales Order-Delivery Note'
'name': u'Sales Order-Delivery Note'
},
# Field Mapper Detail
{
'checking_operator': '>=',
'doctype': 'Field Mapper Detail',
'from_field': 'transaction_date',
'map': 'No',
'doctype': u'Field Mapper Detail',
'from_field': u'name',
'map': u'Yes',
'match_id': 0,
'to_field': 'transaction_date'
'to_field': u'sales_order_no'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'name',
'map': 'Yes',
'checking_operator': u'=',
'doctype': u'Field Mapper Detail',
'from_field': u'company',
'map': u'Yes',
'match_id': 0,
'to_field': 'sales_order_no'
'to_field': u'company'
},
# Field Mapper Detail
{
'checking_operator': '=',
'doctype': 'Field Mapper Detail',
'from_field': 'company',
'map': 'Yes',
'checking_operator': u'=',
'doctype': u'Field Mapper Detail',
'from_field': u'currency',
'map': u'Yes',
'match_id': 0,
'to_field': 'company'
'to_field': u'currency'
},
# Field Mapper Detail
{
'checking_operator': '=',
'doctype': 'Field Mapper Detail',
'from_field': 'currency',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'shipping_address_name',
'map': u'Yes',
'match_id': 0,
'to_field': 'currency'
'to_field': u'customer_address'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'shipping_address_name',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'shipping_address',
'map': u'Yes',
'match_id': 0,
'to_field': 'customer_address'
'to_field': u'address_display'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'shipping_address',
'map': 'Yes',
'match_id': 0,
'to_field': 'address_display'
},
# 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': 'prevdoc_docname'
'to_field': u'prevdoc_docname'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'parenttype',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'parenttype',
'map': u'Yes',
'match_id': 1,
'to_field': 'prevdoc_doctype'
'to_field': u'prevdoc_doctype'
},
# 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': 'prevdoc_detail_docname'
'to_field': u'prevdoc_detail_docname'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate)',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate)',
'map': u'Yes',
'match_id': 1,
'to_field': 'export_amount'
'to_field': u'export_amount'
},
# Field Mapper Detail
{
'checking_operator': '=',
'doctype': 'Field Mapper Detail',
'from_field': 'basic_rate',
'map': 'Yes',
'checking_operator': u'=',
'doctype': u'Field Mapper Detail',
'from_field': u'basic_rate',
'map': u'Yes',
'match_id': 1,
'to_field': 'basic_rate'
'to_field': u'basic_rate'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: flt(obj.qty) - flt(obj.delivered_qty)',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'eval: flt(obj.qty) - flt(obj.delivered_qty)',
'map': u'Yes',
'match_id': 1,
'to_field': 'qty'
'to_field': u'qty'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.basic_rate)',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.basic_rate)',
'map': u'Yes',
'match_id': 1,
'to_field': 'amount'
'to_field': u'amount'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'reserved_warehouse',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'reserved_warehouse',
'map': u'Yes',
'match_id': 1,
'to_field': 'warehouse'
'to_field': u'warehouse'
},
# Field Mapper Detail
{
'checking_operator': '=',
'doctype': 'Field Mapper Detail',
'from_field': 'project_name',
'map': 'Yes',
'checking_operator': u'=',
'doctype': u'Field Mapper Detail',
'from_field': u'project_name',
'map': u'Yes',
'match_id': 0,
'to_field': 'project_name'
'to_field': u'project_name'
},
# Field Mapper Detail
{
'checking_operator': '=',
'doctype': 'Field Mapper Detail',
'from_field': 'customer',
'map': 'Yes',
'checking_operator': u'=',
'doctype': u'Field Mapper Detail',
'from_field': u'customer',
'map': u'Yes',
'match_id': 0,
'to_field': 'customer'
'to_field': u'customer'
},
# 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': 'status',
'map': 'No',
'doctype': u'Field Mapper Detail',
'from_field': u'status',
'map': u'No',
'match_id': 0,
'to_field': 'status'
'to_field': u'status'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'incentives',
'map': 'No',
'doctype': u'Field Mapper Detail',
'from_field': u'incentives',
'map': u'No',
'match_id': 3,
'to_field': 'incentives'
'to_field': u'incentives'
},
# Field Mapper Detail
{
'doctype': 'Field Mapper Detail',
'from_field': 'allocated_amount',
'map': 'Yes',
'doctype': u'Field Mapper Detail',
'from_field': u'allocated_amount',
'map': u'Yes',
'match_id': 0,
'to_field': 'customer_mobile_no'
'to_field': u'customer_mobile_no'
},
# Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'from_field': 'sales_team',
'from_table': 'Sales Team',
'doctype': u'Table Mapper Detail',
'from_field': u'sales_team',
'from_table': u'Sales Team',
'match_id': 3,
'to_field': 'sales_team',
'to_table': 'Sales Team',
'validation_logic': 'name is not null'
'to_field': u'sales_team',
'to_table': u'Sales Team',
'validation_logic': u'name is not null'
},
# Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'from_field': 'other_charges',
'from_table': 'RV Tax Detail',
'doctype': u'Table Mapper Detail',
'from_field': u'other_charges',
'from_table': u'RV Tax Detail',
'match_id': 2,
'to_field': 'other_charges',
'to_table': 'RV Tax Detail',
'validation_logic': 'name is not null'
'to_field': u'other_charges',
'to_table': u'RV Tax Detail',
'validation_logic': u'name is not null'
},
# Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'from_field': 'sales_order_details',
'from_table': 'Sales Order Detail',
'doctype': u'Table Mapper Detail',
'from_field': u'sales_order_details',
'from_table': u'Sales Order Detail',
'match_id': 1,
'reference_doctype_key': 'prevdoc_doctype',
'reference_key': 'prevdoc_detail_docname',
'to_field': 'delivery_note_details',
'to_table': 'Delivery Note Detail',
'validation_logic': 'qty > ifnull(delivered_qty,0) and docstatus = 1'
'reference_doctype_key': u'prevdoc_doctype',
'reference_key': u'prevdoc_detail_docname',
'to_field': u'delivery_note_details',
'to_table': u'Delivery Note Detail',
'validation_logic': u'qty > ifnull(delivered_qty,0) and docstatus = 1'
},
# Table Mapper Detail
{
'doctype': 'Table Mapper Detail',
'from_table': 'Sales Order',
'doctype': u'Table Mapper Detail',
'from_table': u'Sales Order',
'match_id': 0,
'reference_key': 'prevdoc_docname',
'to_table': 'Delivery Note',
'validation_logic': 'docstatus = 1'
'reference_key': u'prevdoc_docname',
'to_table': u'Delivery Note',
'validation_logic': u'docstatus = 1'
}
]

View File

@ -240,9 +240,9 @@ class DocType(TransactionBase):
if prevdoc_docname and prevdoc:
# ::::::::::: Validates Transaction Date of DN and previous doc (i.e. SO , PO, PR) *********
trans_date = sql("select transaction_date from `tab%s` where name = '%s'" %(prevdoc,prevdoc_docname))[0][0]
if trans_date and getdate(self.doc.transaction_date) < (trans_date):
msgprint("Your Voucher Date cannot be before "+cstr(prevdoc)+" Date.")
trans_date = sql("select posting_date from `tab%s` where name = '%s'" %(prevdoc,prevdoc_docname))[0][0]
if trans_date and getdate(self.doc.posting_date) < (trans_date):
msgprint("Your Posting Date cannot be before "+cstr(prevdoc)+" Date.")
raise Exception
# ::::::::: Validates DN and previous doc details ::::::::::::::::::
get_name = sql("select name from `tab%s` where name = '%s'" % (prevdoc, prevdoc_docname))
@ -452,7 +452,7 @@ class DocType(TransactionBase):
self.values.append({
'item_code' : d[1],
'warehouse' : wh,
'transaction_date' : self.doc.transaction_date,
'transaction_date' : getdate(self.doc.modified).strftime('%Y-%m-%d'),
'posting_date' : self.doc.posting_date,
'posting_time' : self.doc.posting_time,
'voucher_type' : 'Delivery Note',

View File

@ -57,7 +57,7 @@ class DocType(TransactionBase):
#-----------------Validation For Fiscal Year------------------------
def validate_fiscal_year(self):
get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Transaction Date')
get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Transaction Date')
# Get Item Details
@ -226,7 +226,7 @@ class DocType(TransactionBase):
ord_qty = -flt(curr_qty)
# update order qty in bin
bin = get_obj('Warehouse', d.warehouse).update_bin(0, 0, (is_submit and 1 or -1) * flt(ord_qty), 0, 0, d.item_code, self.doc.transaction_date)
bin = get_obj('Warehouse', d.warehouse).update_bin(0, 0, (is_submit and 1 or -1) * flt(ord_qty), 0, 0, d.item_code, self.doc.posting_date)
# UPDATE actual qty to warehouse by pr_qty
self.make_sl_entry(d, d.warehouse, flt(pr_qty), d.valuation_rate, is_submit)
@ -245,7 +245,7 @@ class DocType(TransactionBase):
self.values.append({
'item_code' : d.fields.has_key('item_code') and d.item_code or d.rm_item_code,
'warehouse' : wh,
'transaction_date' : self.doc.transaction_date,
'transaction_date' : getdate(self.doc.modified).strftime('%Y-%m-%d'),
'posting_date' : self.doc.posting_date,
'posting_time' : self.doc.posting_time,
'voucher_type' : 'Purchase Receipt',