moved directory structure

This commit is contained in:
Rushabh Mehta
2012-09-24 19:13:42 +05:30
parent e47a6779e9
commit 2fa2f7178d
1637 changed files with 47 additions and 11450 deletions

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,668 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// 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
// 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/>.
// Preset
// ------
// cur_frm.cscript.tname - Details table name
// cur_frm.cscript.fname - Details fieldname
var tname = cur_frm.cscript.tname;
var fname = cur_frm.cscript.fname;
cur_frm.cscript.get_default_schedule_date = function(doc) {
var ch = getchildren( tname, doc.name, fname);
if (flt(ch.length) > 0){
$c_obj(make_doclist(doc.doctype, doc.name), 'get_default_schedule_date', '', function(r, rt) { refresh_field(fname); });
}
}
cur_frm.cscript.load_taxes = function(doc, cdt, cdn, callback) {
// run if this is not executed from dt_map...
doc = locals[doc.doctype][doc.name];
if(doc.supplier || getchildren('Purchase Taxes and Charges', doc.name, 'purchase_tax_details', doc.doctype).length) {
if(callback) {
callback(doc, cdt, cdn);
}
} else {
$c_obj(make_doclist(doc.doctype, doc.name),'load_default_taxes','',function(r,rt){
refresh_field('purchase_tax_details');
if(callback) callback(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, callback) {
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);
cur_frm.cscript.load_taxes(doc, dt, dn, callback);
}
// Update existing item details
cur_frm.cscript.update_item_details = function(doc, dt, dn, callback) {
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, callback);
}
});
} else {
cur_frm.cscript.load_taxes(doc, dt, dn, callback);
}
}
var set_dynamic_label_par = function(doc, cdt, cdn, base_curr) {
//parent flds
par_cols_base = {'net_total': 'Net Total', 'total_tax': 'Total Tax', 'grand_total': 'Grand Total', /*'rounded_total': 'Rounded Total',*/
'in_words': 'In Words', 'other_charges_added': 'Taxes and Charges Added', 'other_charges_deducted': 'Taxes and Charges Deducted'}
par_cols_import = {'net_total_import': 'Net Total', 'grand_total_import': 'Grand Total', 'in_words_import': 'In Words',
'other_charges_added_import': 'Taxes and Charges Added', 'other_charges_deducted_import': 'Taxes and Charges Deducted'};
for (d in par_cols_base) cur_frm.fields_dict[d].label_area.innerHTML = par_cols_base[d]+' (' + base_curr + ')';
for (d in par_cols_import) cur_frm.fields_dict[d].label_area.innerHTML = par_cols_import[d]+' (' + doc.currency + ')';
cur_frm.fields_dict['conversion_rate'].label_area.innerHTML = "Conversion Rate (" + doc.currency +' -> '+ base_curr + ')';
if (doc.doctype == 'Purchase Invoice') {
cur_frm.fields_dict['total_tds_on_voucher'].label_area.innerHTML = 'Total TDS On Voucher (' + base_curr + ')';
cur_frm.fields_dict['outstanding_amount'].label_area.innerHTML = 'Outstanding Amount (' + base_curr + ')';
cur_frm.fields_dict['tds_amount_on_advance'].label_area.innerHTML = 'TDS Amount On Advance (' + base_curr + ')';
cur_frm.fields_dict['total_advance'].label_area.innerHTML = 'Total Advance (Incl. TDS) (' + base_curr + ')';
cur_frm.fields_dict['total_amount_to_pay'].label_area.innerHTML = 'Total Amount To Pay (' + base_curr + ')';
cur_frm.fields_dict['ded_amount'].label_area.innerHTML = 'TDS Amount (' + base_curr + ')';
} else cur_frm.fields_dict['rounded_total'].label_area.innerHTML = 'Rounded Total (' + base_curr + ')';
}
var set_dynamic_label_child = function(doc, cdt, cdn, base_curr) {
// item table flds
item_cols_base = {'purchase_ref_rate': 'Ref Rate', 'amount': 'Amount'};
item_cols_import = {'import_rate': 'Rate', 'import_ref_rate': 'Ref Rate', 'import_amount': 'Amount'};
for (d in item_cols_base) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_base[d]+' ('+base_curr+')');
for (d in item_cols_import) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_import[d]+' ('+doc.currency+')');
var hide = (doc.currency == sys_defaults['currency']) ? false : true;
for (f in item_cols_base) {
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(f, hide);
}
if (doc.doctype == 'Purchase Invoice') {
$('[data-grid-fieldname="'+cur_frm.cscript.tname+'-rate"]').html('Rate ('+base_curr+')');
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp('rate', hide);
// advance table flds
adv_cols = {'advance_amount': 'Advance Amount', 'allocated_amount': 'Allocated Amount', 'tds_amount': 'TDS Amount', 'tds_allocated': 'TDS Allocated'}
for (d in adv_cols) $('[data-grid-fieldname="Purchase Invoice Advance-'+d+'"]').html(adv_cols[d]+' ('+base_curr+')');
}
else {
$('[data-grid-fieldname="'+cur_frm.cscript.tname+'-purchase_rate"]').html('Rate ('+base_curr+')');
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp('purchase_rate', hide);
}
//tax table flds
tax_cols = {'tax_amount': 'Amount', 'total': 'Aggregate Total'};
for (d in tax_cols) $('[data-grid-fieldname="Purchase Taxes and Charges-'+d+'"]').html(tax_cols[d]+' ('+base_curr+')');
}
// Change label dynamically based on currency
//------------------------------------------------------------------
cur_frm.cscript.dynamic_label = function(doc, cdt, cdn, callback1) {
var base_currency = wn.boot.company[doc.company].default_currency || sys_defaults['currency'];
if (doc.currency === base_currency) {
set_multiple(cdt, cdn, {conversion_rate:1});
hide_field(['conversion_rate', 'net_total_import','grand_total_import',
'in_words_import', 'other_charges_added_import', 'other_charges_deducted_import']);
} else {
unhide_field(['conversion_rate', 'net_total_import','grand_total_import',
'in_words_import', 'other_charges_added_import', 'other_charges_deducted_import']);
}
set_dynamic_label_par(doc, cdt, cdn, base_currency);
set_dynamic_label_child(doc, cdt, cdn, base_currency);
if (callback1) callback1(doc, cdt, cdn);
}
cur_frm.cscript.currency = function(doc, cdt, cdn) {
cur_frm.cscript.dynamic_label(doc, cdt, cdn);
}
cur_frm.cscript.company = cur_frm.cscript.currency;
// ======================== Conversion Rate ==========================================
cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) {
cur_frm.cscript.calc_amount( doc, 1);
}
//==================== Item Code Get Query =======================================================
// Only Is Purchase Item = 'Yes' and Items not moved to trash are allowed.
cur_frm.fields_dict[fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
if (doc.is_subcontracted =="Yes") {
return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE ifnull(tabItem.is_sub_contracted_item, "No")="Yes" AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50'
} else {
return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE ifnull(tabItem.is_purchase_item, "No")="Yes" AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50'
}
}
//==================== Get Item Code Details =====================================================
cur_frm.cscript.item_code = function(doc,cdt,cdn) {
var d = locals[cdt][cdn];
if (d.item_code) {
temp = {
item_code: d.item_code || '',
warehouse: d.warehouse || ''
}
get_server_fields('get_item_details', JSON.stringify(temp), fname, doc, cdt, cdn, 1);
}
}
//==================== Update Stock Qty ==========================================================
cur_frm.cscript.update_stock_qty = function(doc,cdt,cdn){
d = locals[cdt][cdn]
// Step 1:=> Check if qty , uom, conversion_factor
if (d.qty && d.uom && d.conversion_factor){
// Step 2:=> Set stock_qty = qty * conversion_factor
d.stock_qty = flt(flt(d.qty) * flt(d.conversion_factor));
// Step 3:=> Refer stock_qty field a that particular row.
refresh_field('stock_qty' , d.name,fname);
}
}
//==================== UOM ======================================================================
cur_frm.cscript.uom = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if (d.item_code && d.uom) {
call_back = function(doc, cdt, cdn){
cur_frm.cscript.calc_amount(doc, 2);
}
str_arg = {'item_code':d.item_code, 'uom':d.uom, 'stock_qty':flt(d.stock_qty), 'qty': flt(d.qty), 'conversion_rate':doc.conversion_rate, 'doc_name': doc.name}
// Updates Conversion Factor, Qty and Purchase Rate
get_server_fields('get_uom_details',JSON.stringify(str_arg), fname, doc,cdt,cdn,1, call_back);
// don't make mistake of calling update_stock_qty() the get_uom_details returns stock_qty as per conversion factor properly
}
}
//==================== Conversion factor =========================================================
cur_frm.cscript.conversion_factor = function(doc, cdt, cdn) {
cur_frm.cscript.uom(doc, cdt, cdn);
}
//==================== stock qty ======================================================================
cur_frm.cscript.stock_qty = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(d.uom && d.qty){
d.conversion_factor = flt(d.stock_qty)/flt(d.qty);
refresh_field('conversion_factor', d.name, fname);
}
}
//==================== Warehouse ================================================================
cur_frm.cscript.warehouse = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if (d.item_code && d.warehouse) {
str_arg = "{'item_code':'" + (d.item_code?d.item_code:'') + "', 'warehouse':'" + (d.warehouse?d.warehouse:'') + "'}"
get_server_fields('get_bin_details', str_arg, fname, doc, cdt, cdn, 1);
}
}
//=================== Quantity ===================================================================
cur_frm.cscript.qty = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
// Step 1: => Update Stock Qty
cur_frm.cscript.update_stock_qty(doc,cdt,cdn);
// Step 2: => Calculate Amount
cur_frm.cscript.calc_amount(doc, 2);
}
//=================== Purchase Rate ==============================================================
cur_frm.cscript.purchase_rate = function(doc, cdt, cdn) {
cur_frm.cscript.calc_amount(doc, 2);
}
//==================== Import Rate ================================================================
cur_frm.cscript.import_rate = function(doc, cdt, cdn) {
cur_frm.cscript.calc_amount(doc, 1);
}
//==================== Discount Rate ================================================================
cur_frm.cscript.discount_rate = function(doc, cdt, cdn) {
cur_frm.cscript.calc_amount(doc, 4);
}
//==================== Purchase Ref Rate ================================================================
cur_frm.cscript.purchase_ref_rate = function(doc, cdt, cdn) {
cur_frm.cscript.calc_amount(doc, 4);
}
//==================== Import Ref Rate ================================================================
cur_frm.cscript.import_ref_rate = function(doc, cdt, cdn) {
cur_frm.cscript.calc_amount(doc, 5);
}
//==================== check if item table is blank ==============================================
var is_item_table = function(doc,cdt,cdn) {
// Step 1 :=>Get all childrens/ rows from Detail Table
var cl = getchildren(tname, doc.name, fname);
// Step 2 :=> If there are no rows then set validated = false, this will stop further execution of code.
if (cl.length == 0) {
alert("There is no item in table"); validated = false;
}
}
//==================== Validate ====================================================================
cur_frm.cscript.validate = function(doc, cdt, cdn) {
// Step 1:=> check if item table is blank
is_item_table(doc,cdt,cdn);
// Step 2:=> Calculate Amount
cur_frm.cscript.calc_amount(doc, 1);
// calculate advances if pv
if(doc.doctype == 'Purchase Invoice') calc_total_advance(doc, cdt, cdn);
}
// **************** RE-CALCULATE VALUES ***************************
cur_frm.cscript.recalculate_values = function(doc, cdt, cdn) {
cur_frm.cscript.calculate_tax(doc,cdt,cdn);
}
cur_frm.cscript.calculate_tax = function(doc, cdt, cdn) {
var other_fname = cur_frm.cscript.other_fname;
var cl = getchildren('Purchase Taxes and Charges', doc.name, other_fname, doc.doctype);
for(var i = 0; i<cl.length; i++){
cl[i].total_tax_amount = 0;
cl[i].total_amount = 0;
cl[i].tax_amount = 0; // this is done to calculate other charges
cl[i].total = 0;
if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type) && !cl[i].row_id){
alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);
validated = false;
}
}
cur_frm.cscript.calc_amount(doc, 1);
}
cur_frm.cscript.get_item_wise_tax_detail = function( doc, rate, cl, i, tax, t) {
doc = locals[doc.doctype][doc.name];
var detail = '';
detail = cl[i].item_code + " : " + cstr(rate) + NEWLINE;
return detail;
}
cur_frm.cscript.amount = function(doc, cdt, cdn) {
cur_frm.cscript.calc_amount(doc, 3);
}
//====================== Calculate Amount for PO and PR not for PV ============================================================
cur_frm.cscript.calc_amount = function(doc, n) {
// Set defaults
doc = locals[doc.doctype][doc.name]
var other_fname = cur_frm.cscript.other_fname;
if(!flt(doc.conversion_rate)) { doc.conversion_rate = 1; refresh_field('conversion_rate'); }
if(!n) n=0;
var net_total = 0;
var net_total_import = 0;
var cl = getchildren(tname, doc.name, fname);
for(var i=0;i<cl.length;i++)
{
var rate_fld = (doc.doctype != 'Purchase Invoice') ? 'purchase_rate': 'rate';
var tmp = {};
if(!cl[i].discount_rate) cl[i].discount_rate = 0;
if(n == 1){
set_multiple(tname, cl[i].name, {'purchase_ref_rate':flt(cl[i].import_ref_rate)*flt(doc.conversion_rate)}, fname);
set_multiple(tname, cl[i].name, {'discount_rate': flt(flt( flt( flt(cl[i].import_ref_rate) - flt(cl[i].import_rate) ) * 100 )/flt(cl[i].import_ref_rate)) }, fname);
tmp[rate_fld] = flt(doc.conversion_rate) * flt(cl[i].import_rate);
set_multiple(tname, cl[i].name, tmp, fname);
set_multiple(tname, cl[i].name, {'amount': flt(flt(cl[i].qty) * flt(doc.conversion_rate) * flt(cl[i].import_rate))}, fname);
set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i].import_rate))}, fname);
}else if(n == 2){
set_multiple(tname, cl[i].name, {'purchase_ref_rate':flt(cl[i].import_ref_rate)*flt(doc.conversion_rate)}, fname);
set_multiple(tname, cl[i].name, {'discount_rate': flt(flt( flt( flt(cl[i].purchase_ref_rate) - flt(cl[i][rate_fld]) ) * 100 )/flt(cl[i].purchase_ref_rate)) }, fname);
set_multiple(tname, cl[i].name, {'amount': flt(flt(cl[i].qty) * flt(cl[i][rate_fld])),}, fname);
set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i][rate_fld]) / flt(doc.conversion_rate)) }, fname);
set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname);
}else if(n == 3){
tmp[rate_fld] = flt(flt(cl[i].amount) / flt(cl[i].qty));
set_multiple(tname, cl[i].name, tmp, fname);
set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname);
set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname);
}else if( n==4){
set_multiple(tname, cl[i].name, {'import_ref_rate': flt(flt(cl[i].purchase_ref_rate) / flt(doc.conversion_rate))}, fname);
tmp[rate_fld] = flt( flt(cl[i].purchase_ref_rate) - flt(flt(cl[i].purchase_ref_rate)*flt(cl[i].discount_rate)/100) )
set_multiple(tname, cl[i].name, tmp, fname);
set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname);
set_multiple(tname, cl[i].name, {'amount':flt(flt(cl[i].qty) * flt(cl[i][rate_fld]))}, fname);
set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname);
}else if( n==5){
tmp[rate_fld] = flt( flt(cl[i].import_ref_rate) - flt(flt(cl[i].import_ref_rate)*flt(cl[i].discount_rate)/100) ) * flt(doc.conversion_rate);
set_multiple(tname, cl[i].name, {'purchase_ref_rate': flt(flt(cl[i].import_ref_rate) * flt(doc.conversion_rate))}, fname);
set_multiple(tname, cl[i].name, tmp, fname);
set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname);
set_multiple(tname, cl[i].name, {'amount':flt(flt(cl[i].qty) * flt(cl[i][rate_fld]))}, fname);
set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname);
}
if (n != 3){
net_total += flt(flt(cl[i].qty) * flt(cl[i][rate_fld]));
net_total_import += flt(flt(cl[i].qty) * flt(cl[i].import_rate));
} else if(n == 3){
net_total += flt(cl[i].amount);
net_total_import += flt(cl[i].amount) / flt(doc.conversion_rate);
}
//update stock uom
cur_frm.cscript.update_stock_qty(doc, tname, cl[i].name);
}
doc.net_total = flt(net_total) ;
doc.net_total_import = flt(net_total_import) ;
refresh_field('net_total');
refresh_field('net_total_import');
cur_frm.cscript.val_cal_charges(doc, tname, fname, other_fname);
}
//======== Function was broken away from cur_frm.cscript.calc_amount as PV has fieldname 'rate' instead of 'purchase_rate'===========
cur_frm.cscript.val_cal_charges = function(doc, tname, fname, other_fname){
doc = locals[doc.doctype][doc.name]
if(flt(doc.net_total) > 0) {
var cl = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
for(var i = 0; i<cl.length; i++){
cl[i].total_tax_amount = 0;
cl[i].total_amount = 0;
cl[i].tax_amount = 0; // this is done to calculate other charges
cl[i].total = 0;
cl[i].item_wise_tax_detail = "";
if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type) && !cl[i].row_id){
alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);
validated = false;
}
}
cur_frm.cscript.calc_other_charges(doc , tname , fname , other_fname); // calculate other charges
}
cur_frm.cscript.calc_doc_values(doc, tname, fname, other_fname); // calculates total amounts
refresh_many(['net_total', 'grand_total', 'rounded_total', 'grand_total_import', 'rounded_total_import', 'in_words', 'in_words_import', 'purchase_tax_details', 'total_tax', 'other_charges_added', 'other_charges_deducted', 'net_total_import', 'other_charges_added_import', 'other_charges_deducted_import']);
}
// ******************************* OTHER CHARGES *************************************
cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname) {
doc = locals[doc.doctype][doc.name];
// make display area
// ------------------
cur_frm.fields_dict['tax_calculation'].disp_area.innerHTML = '<b style="padding: 8px 0px;">Calculation Details for Taxes, Charges and Landed Cost:</b>';
var cl = getchildren(tname, doc.name, fname);
var tax = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
// make display table
// ------------------
var otc = make_table(cur_frm.fields_dict['tax_calculation'].disp_area, cl.length + 1, tax.length + 1, '90%',[],{border:'1px solid #AAA',padding:'2px'});
$y(otc,{marginTop:'8px'});
var tax_desc = {}; var tax_desc_rates = []; var net_total = 0;
for(var i=0;i<cl.length;i++) {
var item_tax = 0;
if(doc.doctype != 'Purchase Invoice') net_total += flt(flt(cl[i].qty) * flt(cl[i].purchase_rate));
else if(doc.doctype == 'Purchase Invoice') net_total += flt(flt(cl[i].qty) * flt(cl[i].rate));
var prev_total = flt(cl[i].amount);
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;
var tax = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
var total = net_total;
for(var t=0;t<tax.length;t++){
var account = tax[t].account_head;
$td(otc,0,t+1).innerHTML = account?account:'';
//Check For Rate
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);
//enter item_wise_tax_detail i.e. tax rate on each item
item_wise_tax_detail = cur_frm.cscript.get_item_wise_tax_detail( doc, rate, cl, i, tax, t);
if(tax[t].add_deduct_tax == 'Add'){
// this is calculation part for all types
if(tax[t].charge_type != "Actual") tax[t].item_wise_tax_detail += item_wise_tax_detail;
tax[t].total_amount = flt(tax_amount.toFixed(2)); //stores actual tax amount in virtual field
tax[t].total_tax_amount = flt(prev_total.toFixed(2)); //stores total amount in virtual field
tax[t].tax_amount += flt(tax_amount.toFixed(2));
var total_amount = flt(tax[t].tax_amount);
total_tax_amount = flt(tax[t].total_tax_amount) + flt(total_amount);
if(tax[t].category != "For Valuation"){
set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':total_amount, 'total':flt(total)+flt(tax[t].tax_amount)/*_tax_amount)*/}, other_fname);
prev_total += flt(tax[t].total_amount);
total += flt(tax[t].tax_amount); // for adding total to previous amount
}
else{
set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':total_amount, 'total':flt(total)/*_tax_amount)*/}, other_fname);
prev_total = prev_total;
}
//prev_total += flt(tax[t].total_amount); // for previous row total
if(tax[t].charge_type == 'Actual')
$td(otc,i+1,t+1).innerHTML = fmt_money(tax[t].total_amount);
else
$td(otc,i+1,t+1).innerHTML = '('+fmt_money(rate) + '%) ' +fmt_money(tax[t].total_amount);
if (tax[t].category != "For Total"){
item_tax += tax[t].total_amount;
}
}
else if(tax[t].add_deduct_tax == 'Deduct'){
// this is calculation part for all types
if(tax[t].charge_type != "Actual") tax[t].item_wise_tax_detail += item_wise_tax_detail;
tax[t].total_amount = flt(tax_amount.toFixed(2)); //stores actual tax amount in virtual field
tax[t].total_tax_amount = flt(prev_total.toFixed(2)); //stores total amount in virtual field
tax[t].tax_amount += flt(tax_amount.toFixed(2));
var total_amount = flt(tax[t].tax_amount);
total_tax_amount = flt(tax[t].total_tax_amount) - flt(total_amount);
if(tax[t].category != "For Valuation"){
set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'tax_amount':total_amount, 'total':flt(total)-flt(tax[t].tax_amount)/*_tax_amount)*/}, other_fname);
prev_total -= flt(tax[t].total_amount);
total -= flt(tax[t].tax_amount); // for adding total to previous amount
}
else{
set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'tax_amount':total_amount, 'total':flt(total)/*_tax_amount)*/}, other_fname);
prev_total = prev_total;
}
//prev_total += flt(tax[t].total_amount); // for previous row total
if(tax[t].charge_type == 'Actual')
$td(otc,i+1,t+1).innerHTML = fmt_money(tax[t].total_amount);
else
$td(otc,i+1,t+1).innerHTML = '('+fmt_money(rate) + '%) ' +fmt_money(tax[t].total_amount);
if (tax[t].category != "For Total"){
item_tax -= tax[t].total_amount;
}
}
}
set_multiple(tname, cl[i].name, {'item_tax_amount': item_tax }, fname);
}
}
// ******* Calculation of total amounts of document (item amount + other charges)****************
cur_frm.cscript.calc_doc_values = function(doc, tname, fname, other_fname) {
doc = locals[doc.doctype][doc.name];
var net_total = 0; var total_tax = 0; var other_charges_added = 0;
var other_charges_deducted = 0;
var cl = getchildren(tname, doc.name, fname);
for(var i = 0; i<cl.length; i++){
net_total += flt(cl[i].amount);
}
var d = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
for(var j = 0; j<d.length; j++){
if(d[j].category != 'For Valuation'){
if(d[j].add_deduct_tax == 'Add'){
other_charges_added += flt(d[j].tax_amount);
total_tax += flt(d[j].tax_amount);
}
if(d[j].add_deduct_tax == 'Deduct'){
other_charges_deducted += flt(d[j].tax_amount);
total_tax -= flt(d[j].tax_amount);
}
}
}
doc.net_total = flt(net_total);
doc.total_tax = flt(total_tax);
doc.other_charges_added = flt(other_charges_added);
doc.other_charges_deducted = flt(other_charges_deducted);
doc.grand_total = flt(flt(net_total) + flt(other_charges_added) - flt(other_charges_deducted));
doc.rounded_total = Math.round(doc.grand_total);
doc.net_total_import = flt(flt(net_total) / flt(doc.conversion_rate));
doc.other_charges_added_import = flt(flt(other_charges_added) / flt(doc.conversion_rate));
doc.other_charges_deducted_import = flt(flt(other_charges_deducted) / flt(doc.conversion_rate));
doc.grand_total_import = flt(flt(doc.grand_total) / flt(doc.conversion_rate));
doc.rounded_total_import = Math.round(doc.grand_total_import);
refresh_many(['net_total','total_taxes','grand_total']);
if(doc.doctype == 'Purchase Invoice'){
calculate_outstanding(doc);
}
}
var calculate_outstanding = function(doc) {
var t_tds_tax = 0.0;
doc.total_tds_on_voucher = flt(doc.ded_amount);
// total amount to pay
doc.total_amount_to_pay = flt(flt(doc.net_total) + flt(doc.other_charges_added) - flt(doc.other_charges_deducted) - flt(doc.total_tds_on_voucher));
// outstanding amount
if(doc.docstatus==0) doc.outstanding_amount = flt(doc.net_total) + flt(doc.other_charges_added) - flt(doc.other_charges_deducted) - flt(doc.total_tds_on_voucher) - flt(doc.total_advance);
refresh_many(['total_tds_on_voucher','total_amount_to_pay', 'outstanding_amount']);
}
cur_frm.cscript.check_charge_type_and_get_tax_amount = function(doc, tax, t, cl, rate, print_amt) {
doc = locals[doc.doctype][doc.name];
var tax_amount = 0;
if(tax[t].charge_type == 'Actual') {
var value = flt(tax[t].rate) / flt(doc.net_total); // this give the ratio in which all items are divided
return tax_amount = flt(value) * flt(cl.amount);
}
else if(tax[t].charge_type == 'On Net Total') {
return tax_amount = (flt(rate) * flt(cl.amount) / 100);
}
else if(tax[t].charge_type == 'On Previous Row Amount'){
var row_no = (tax[t].row_id).toString();
var row = (row_no).split("+"); // splits the values and stores in an array
for(var r = 0;r<row.length;r++){
var id = cint(row[r].replace(/^\s+|\s+$/g,""));
tax_amount += (flt(rate) * flt(tax[id-1].total_amount) / 100);
}
var row_id = row_no.indexOf("/");
if(row_id != -1) {
rate = '';
var row = (row_no).split("/"); // splits the values and stores in an array
if(row.length>2) alert("You cannot enter more than 2 nos. for division");
var id1 = cint(row[0].replace(/^\s+|\s+$/g,""));
var id2 = cint(row[1].replace(/^\s+|\s+$/g,""));
tax_amount = flt(tax[id1-1].total_amount) / flt(tax[id2-1].total_amount);
}
return tax_amount
}
else if(tax[t].charge_type == 'On Previous Row Total') {
var row = cint(tax[t].row_id);
if(tax[row-1].add_deduct_tax == 'Add'){
return tax_amount = flt(rate) * (flt(tax[row-1].total_tax_amount)+flt(tax[row-1].total_amount)) / 100;
}
else if(tax[row-1].add_deduct_tax == 'Deduct'){
return tax_amount = flt(rate) * (flt(tax[row-1].total_tax_amount)-flt(tax[row-1].total_amount)) / 100;
}
}
}
cur_frm.cscript.toggle_contact_section = function(doc) {
cur_frm.toggle_display("contact_section", doc.supplier);
}
cur_frm.cscript.project_name = function(doc, cdt, cdn) {
var item_doc = locals[cdt][cdn];
if (item_doc.project_name) {
$.each(getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname, doc.doctype),
function(i, v) {
if (v && !v.project_name) v.project_name = item_doc.project_name;
});
refresh_field(cur_frm.cscript.fname);
}
}

View File

@@ -0,0 +1,692 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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
# 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/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
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, getchildren, make_autoname
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
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.chk_tol_for_list = ['Purchase Request - Purchase Order', 'Purchase Order - Purchase Receipt', 'Purchase Order - Purchase Invoice']
self.update_qty = {
'Purchase Request - Purchase Order': 'ordered_qty',
'Purchase Order - Purchase Receipt': 'received_qty',
'Purchase Order - Purchase Invoice': 'billed_qty',
'Purchase Receipt - Purchase Invoice': 'billed_qty'
}
self.update_percent_field = {
'Purchase Request - Purchase Order': 'per_ordered',
'Purchase Order - Purchase Receipt': 'per_received',
'Purchase Order - Purchase Invoice': 'per_billed',
'Purchase Receipt - Purchase Invoice': 'per_billed'
}
# used in validation for items and update_prevdoc_detail
self.doctype_dict = {
'Purchase Request': 'Purchase Request Item',
'Purchase Order': 'Purchase Order Item',
'Purchase Receipt': 'Purchase Receipt Item'
}
self.next_dt_detail = {
'ordered_qty' : 'Purchase Order Item',
'billed_qty' : 'Purchase Invoice Item',
'received_qty': 'Purchase Receipt Item'
}
self.msg = []
def get_default_schedule_date( self, obj):
for d in getlist( obj.doclist, obj.fname):
item = sql("select lead_time_days from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())" % cstr(d.item_code) , as_dict = 1)
ltd = item and cint(item[0]['lead_time_days']) or 0
if ltd and obj.doc.transaction_date:
if d.fields.has_key('lead_time_date') or obj.doc.doctype == 'Purchase Request':
d.lead_time_date = cstr(add_days( obj.doc.transaction_date, cint(ltd)))
if not d.fields.has_key('prevdoc_docname') or (d.fields.has_key('prevdoc_docname') and not d.prevdoc_docname):
d.schedule_date = cstr( add_days( obj.doc.transaction_date, cint(ltd)))
# Client Trigger functions
#------------------------------------------------------------------------------------------------
# Get Supplier Details
def get_supplier_details(self, name = ''):
details = sql("select supplier_name,address from `tabSupplier` where name = '%s' and docstatus != 2" %(name), as_dict = 1)
if details:
ret = {
'supplier_name' : details and details[0]['supplier_name'] or '',
'supplier_address' : details and details[0]['address'] or ''
}
# ********** get primary contact details (this is done separately coz. , in case there is no primary contact thn it would not be able to fetch customer details in case of join query)
contact_det = sql("select contact_name, contact_no, email_id from `tabContact` where supplier = '%s' and is_supplier = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), as_dict = 1)
ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
return ret
else:
msgprint("Supplier : %s does not exists" % (name))
raise Exception
# Get TERMS AND CONDITIONS
# =======================================================================================
def get_tc_details(self,obj):
r = sql("select terms from `tabTerms and Conditions` where name = %s", obj.doc.tc_name)
if r: obj.doc.terms = r[0][0]
# Get Item Details
def get_item_details(self, obj, 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 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 = {}
for x in tax: t[x[0]] = flt(x[1])
# get warehouse
if arg['warehouse']:
wh = arg['warehouse']
else:
wh = item and item[0]['default_warehouse'] or ''
ret = {
'item_name': item and item[0]['item_name'] or '',
'item_group': item and item[0]['item_group'] or '',
'brand': item and item[0]['brand'] or '',
'description': item and item[0]['description'] or '',
'qty': 0,
'uom': item and item[0]['stock_uom'] or '',
'stock_uom': item and item[0]['stock_uom'] or '',
'conversion_factor': '1',
'warehouse': wh,
'item_tax_rate': json.dumps(t),
'batch_no': '',
'discount_rate': 0
}
# get min_order_qty from item
if obj.doc.doctype == 'Purchase Request':
ret['min_order_qty'] = item and flt(item[0]['min_order_qty']) or 0
# get projected qty from bin
if ret['warehouse']:
bin = sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (arg['item_code'], ret['warehouse']), as_dict=1)
ret['projected_qty'] = bin and flt(bin[0]['projected_qty']) or 0
# get schedule date, lead time date
if obj.doc.transaction_date and item and item[0]['lead_time_days']:
ret['schedule_date'] = cstr(add_days(obj.doc.transaction_date, cint(item[0]['lead_time_days'])))
ret['lead_time_date'] = cstr(add_days(obj.doc.transaction_date, cint(item[0]['lead_time_days'])))
# get last purchase rate as per stock uom and default currency for following list of doctypes
if obj.doc.doctype in ['Purchase Order', 'Purchase Receipt']:
last_purchase_details, last_purchase_date = self.get_last_purchase_details(arg['item_code'], obj.doc.name)
if last_purchase_details:
# updates ret with purchase_ref_rate, discount_rate, purchase_rate
conversion_rate = flt(obj.doc.fields.get('conversion_rate'))
ret.update(last_purchase_details)
ret.update({
'import_ref_rate': flt(last_purchase_details['purchase_ref_rate']) / conversion_rate,
'import_rate': flt(last_purchase_details['purchase_rate']) / conversion_rate,
})
else:
# set these values as blank in the form
ret.update({
'purchase_ref_rate': 0,
'discount_rate': 0,
'purchase_rate': 0,
'import_ref_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
# Get Available Qty at Warehouse
def get_bin_details( self, arg = ''):
arg = eval(arg)
bin = sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (arg['item_code'], arg['warehouse']), as_dict=1)
ret = { 'projected_qty' : bin and flt(bin[0]['projected_qty']) or 0 }
return ret
def get_uom_details(self, arg = ''):
"""fetches details on change of UOM"""
import json
arg, ret = json.loads(arg), {}
uom = webnotes.conn.sql("""\
select conversion_factor
from `tabUOM Conversion Detail`
where parent = %s and uom = %s""", (arg['item_code'],arg['uom']), as_dict = 1)
if not uom: return ret
last_purchase_details, last_purchase_date = self.get_last_purchase_details(arg['item_code'], arg['doc_name'])
conversion_factor = flt(uom[0]['conversion_factor'])
conversion_rate = flt(arg['conversion_rate'])
purchase_ref_rate = last_purchase_details and \
(last_purchase_details['purchase_ref_rate'] * conversion_factor) or 0
purchase_rate = last_purchase_details and \
(last_purchase_details['purchase_rate'] * conversion_factor) or 0
ret = {
'conversion_factor': conversion_factor,
'qty': flt(arg['stock_qty']) / conversion_factor,
'purchase_ref_rate': purchase_ref_rate,
'purchase_rate': purchase_rate,
'import_ref_rate': purchase_ref_rate / conversion_rate,
'import_rate': purchase_rate / conversion_rate,
}
return ret
# --- Last Purchase Rate related methods ---
def update_last_purchase_rate(self, obj, is_submit):
"""updates last_purchase_rate in item table for each item"""
import webnotes.utils
this_purchase_date = webnotes.utils.getdate(obj.doc.fields.get('posting_date') or obj.doc.fields.get('transaction_date'))
for d in getlist(obj.doclist,obj.fname):
# get last purchase details
last_purchase_details, last_purchase_date = self.get_last_purchase_details(d.item_code, obj.doc.name)
# compare last purchase date and this transaction's date
last_purchase_rate = None
if last_purchase_date > this_purchase_date:
last_purchase_rate = last_purchase_details['purchase_rate']
elif is_submit == 1:
# even if this transaction is the latest one, it should be submitted
# for it to be considered for latest purchase rate
last_purchase_rate = flt(d.purchase_rate) / flt(d.conversion_factor)
# update last purchsae rate
if last_purchase_rate:
sql("update `tabItem` set last_purchase_rate = %s where name = %s",
(flt(last_purchase_rate),d.item_code))
def get_last_purchase_rate(self, obj):
"""get last purchase rates for all items"""
doc_name = obj.doc.name
conversion_rate = flt(obj.doc.fields.get('conversion_rate')) or 1.0
for d in getlist(obj.doclist, obj.fname):
if d.item_code:
last_purchase_details, last_purchase_date = self.get_last_purchase_details(d.item_code, doc_name)
if last_purchase_details:
d.purchase_ref_rate = last_purchase_details['purchase_ref_rate'] * (flt(d.conversion_factor) or 1.0)
d.discount_rate = last_purchase_details['discount_rate']
d.purchase_rate = last_purchase_details['purchase_rate'] * (flt(d.conversion_factor) or 1.0)
d.import_ref_rate = d.purchase_ref_rate / conversion_rate
d.import_rate = d.purchase_rate / conversion_rate
else:
# if no last purchase found, reset all values to 0
d.purchase_ref_rate = d.purchase_rate = d.import_ref_rate = d.import_rate = d.discount_rate = 0
item_last_purchase_rate = webnotes.conn.get_value("Item",
d.item_code, "last_purchase_rate")
if item_last_purchase_rate:
d.purchase_ref_rate = d.purchase_rate = d.import_ref_rate \
= d.import_rate = item_last_purchase_rate
def get_last_purchase_details(self, item_code, doc_name):
import webnotes
import webnotes.utils
# get last purchase order item details
last_po_item = webnotes.conn.sql("""\
select po.name, po.transaction_date, po_item.conversion_factor, po_item.purchase_ref_rate,
po_item.discount_rate, po_item.purchase_rate
from `tabPurchase Order` po, `tabPurchase Order Item` po_item
where po.docstatus = 1 and po_item.item_code = %s and po.name != %s and
po.name = po_item.parent
order by po.transaction_date desc, po.name desc
limit 1""", (item_code, doc_name), as_dict=1)
# get last purchase receipt item details
last_pr_item = webnotes.conn.sql("""\
select pr.name, pr.posting_date, pr.posting_time, pr_item.conversion_factor,
pr_item.purchase_ref_rate, pr_item.discount_rate, pr_item.purchase_rate
from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item
where pr.docstatus = 1 and pr_item.item_code = %s and pr.name != %s and
pr.name = pr_item.parent
order by pr.posting_date desc, pr.posting_time desc, pr.name desc
limit 1""", (item_code, doc_name), as_dict=1)
# get the latest of the two
po_date_obj = webnotes.utils.getdate(last_po_item and last_po_item[0]['transaction_date'] or '2000-01-01')
pr_date_obj = webnotes.utils.getdate(last_pr_item and last_pr_item[0]['posting_date'] or '2000-01-01')
# if both exists, return true
both_exists = last_po_item and last_pr_item
# get the last purchased item, by comparing dates
if (both_exists and po_date_obj > pr_date_obj) or (not both_exists and last_po_item):
last_purchase_item = last_po_item[0]
last_purchase_date = po_date_obj
elif both_exists or (not both_exists and last_pr_item):
last_purchase_item = last_pr_item[0]
last_purchase_date = pr_date_obj
else:
# if none exists
return None, webnotes.utils.getdate('2000-01-01')
# prepare last purchase details, dividing by conversion factor
conversion_factor = flt(last_purchase_item['conversion_factor'])
last_purchase_details = {
'purchase_ref_rate': flt(last_purchase_item['purchase_ref_rate']) / conversion_factor,
'purchase_rate': flt(last_purchase_item['purchase_rate']) / conversion_factor,
'discount_rate': flt(last_purchase_item['discount_rate']),
}
return last_purchase_details, last_purchase_date
# validation
# -------------------------------------------------------------------------------------------------------
# validate fields
def validate_mandatory(self, obj):
# check amendment date
if obj.doc.amended_from and not obj.doc.amendment_date:
msgprint("Please enter amendment date")
raise Exception
# validate for same items and validate is_stock_item , is_purchase_item also validate uom and conversion factor
def validate_for_items(self, obj):
check_list, chk_dupl_itm=[],[]
for d in getlist( obj.doclist, obj.fname):
# validation for valid qty
if flt(d.qty) < 0 or (d.parenttype != 'Purchase Receipt' and not flt(d.qty)):
msgprint("Please enter valid qty for item %s" % cstr(d.item_code))
raise Exception
# udpate with latest quantities
bin = sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
f_lst ={'projected_qty': bin and flt(bin[0]['projected_qty']) or 0, 'ordered_qty': 0, 'received_qty' : 0, 'billed_qty': 0}
if d.doctype == 'Purchase Receipt Item':
f_lst.pop('received_qty')
for x in f_lst :
if d.fields.has_key(x):
d.fields[x] = f_lst[x]
item = sql("select is_stock_item, is_purchase_item, is_sub_contracted_item from tabItem where name=%s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())", d.item_code)
if not item:
msgprint("Item %s does not exist in Item Master." % cstr(d.item_code))
raise Exception
# validate stock item
if item[0][0]=='Yes':
if not d.warehouse:
msgprint("Warehouse is mandatory for %s, since it is a stock item" % d.item_code)
raise Exception
# validate purchase item
if item[0][1] != 'Yes' and item[0][2] != 'Yes':
msgprint("Item %s is not a purchase item or sub-contracted item. Please check" % (d.item_code))
raise Exception
if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname:
# check warehouse, uom in previous doc and in current doc are same.
data = sql("select item_code, warehouse, uom from `tab%s` where name = '%s'" % ( self.doctype_dict[d.prevdoc_doctype], d.prevdoc_detail_docname), as_dict = 1)
if not data:
msgprint("Please fetch data in Row " + cstr(d.idx) + " once again or please contact Administrator.")
raise Exception
# Check if Item Code has been modified.
if not cstr(data[0]['item_code']) == cstr(d.item_code):
msgprint("Please check Item %s is not present in %s %s ." % (d.item_code, d.prevdoc_doctype, d.prevdoc_docname))
raise Exception
# Check if Warehouse has been modified.
if not cstr(data[0]['warehouse']) == cstr(d.warehouse):
msgprint("Please check warehouse %s of Item %s which is not present in %s %s ." % (d.warehouse, d.item_code, d.prevdoc_doctype, d.prevdoc_docname))
raise Exception
# Check if UOM has been modified.
if not cstr(data[0]['uom']) == cstr(d.uom) and not cstr(d.prevdoc_doctype) == 'Purchase Request':
msgprint("Please check UOM %s of Item %s which is not present in %s %s ." % (d.uom, d.item_code, d.prevdoc_doctype, d.prevdoc_docname))
raise Exception
# list criteria that should not repeat if item is stock item
e = [d.schedule_date, d.item_code, d.description, d.warehouse, d.uom, d.fields.has_key('prevdoc_docname') and d.prevdoc_docname or '', d.fields.has_key('prevdoc_detail_docname') and d.prevdoc_detail_docname or '', d.fields.has_key('batch_no') and d.batch_no or '']
# if is not stock item
f = [d.schedule_date, d.item_code, d.description]
ch = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
if ch and ch[0][0] == 'Yes':
# check for same items
if e in check_list:
msgprint("""Item %s has been entered more than once with same description, schedule date, warehouse and uom.\n
Please change any of the field value to enter the item twice""" % d.item_code, raise_exception = 1)
else:
check_list.append(e)
elif ch and ch[0][0] == 'No':
# check for same items
if f in chk_dupl_itm:
msgprint("""Item %s has been entered more than once with same description, schedule date.\n
Please change any of the field value to enter the item twice.""" % d.item_code, raise_exception = 1)
else:
chk_dupl_itm.append(f)
# validate conversion rate
def validate_conversion_rate(self, obj):
default_currency = TransactionBase().get_company_currency(obj.doc.company)
if not default_currency:
msgprint('Message: Please enter default currency in Company Master')
raise Exception
if obj.doc.conversion_rate == 0:
msgprint('Conversion Rate cannot be 0', raise_exception=1)
elif not obj.doc.conversion_rate:
msgprint('Please specify Conversion Rate', raise_exception=1)
elif obj.doc.currency == default_currency and \
flt(obj.doc.conversion_rate) != 1.00:
msgprint("""Conversion Rate should be equal to 1.00, \
since the specified Currency and the company's currency \
are same""", raise_exception=1)
elif obj.doc.currency != default_currency and \
flt(obj.doc.conversion_rate) == 1.00:
msgprint("""Conversion Rate should not be equal to 1.00, \
since the specified Currency and the company's currency \
are different""", raise_exception=1)
def validate_doc(self, obj, prevdoc_doctype, prevdoc_docname):
if prevdoc_docname :
get_name = sql("select name from `tab%s` where name = '%s'" % (prevdoc_doctype, prevdoc_docname))
name = get_name and get_name[0][0] or ''
if name: #check for incorrect docname
dt = sql("select company, docstatus from `tab%s` where name = '%s'" % (prevdoc_doctype, name))
company_name = dt and cstr(dt[0][0]) or ''
docstatus = dt and dt[0][1] or 0
# check for docstatus
if (docstatus != 1):
msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) + " is not Submitted Document.")
raise Exception
# check for company
if (company_name != obj.doc.company):
msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) + " does not belong to the Company: " + cstr(obj.doc.company))
raise Exception
if prevdoc_doctype in ['Purchase Order', 'Purchase Receipt']:
dt = sql("select supplier, currency from `tab%s` where name = '%s'" % (prevdoc_doctype, name))
supplier = dt and dt[0][0] or ''
currency = dt and dt[0][1] or ''
# check for supplier
if (supplier != obj.doc.supplier):
msgprint("Purchase Order: " + cstr(d.prevdoc_docname) + " supplier :" + cstr(supplier) + " does not match with supplier of current document.")
raise Exception
# check for curency
if (currency != obj.doc.currency):
msgprint("Purchase Order: " + cstr(d.prevdoc_docname) + " currency :" + cstr(currency) + " does not match with currency of current document.")
raise Exception
else: # if not name than
msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) + " is not a valid " + cstr(prevdoc_doctype))
raise Exception
# Validate values with reference document
#---------------------------------------
def validate_reference_value(self, obj):
ref_doc = []
for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname and d.prevdoc_doctype not in ref_doc:
mapper_name = d.prevdoc_doctype + '-' + obj.doc.doctype
get_obj('DocType Mapper', mapper_name, with_children = 1).validate_reference_value(obj, obj.doc.name)
ref_doc.append(d.prevdoc_doctype)
# Check for Stopped status
def check_for_stopped_status(self, doctype, docname):
stopped = sql("select name from `tab%s` where name = '%s' and status = 'Stopped'" % ( doctype, docname))
if stopped:
msgprint("One cannot do any transaction against %s : %s, it's status is 'Stopped'" % ( doctype, docname))
raise Exception
# Check Docstatus of Next DocType on Cancel AND of Previous DocType on Submit
def check_docstatus(self, check, doctype, docname , detail_doctype = ''):
if check == 'Next':
# Convention := doctype => Next Doctype, docname = current_docname , detail_doctype = Next Doctype Detail Table
submitted = sql("select t1.name from `tab%s` t1,`tab%s` t2 where t1.name = t2.parent and t2.prevdoc_docname = '%s' and t1.docstatus = 1" % ( doctype, detail_doctype, docname))
if submitted:
msgprint(cstr(doctype) + " : " + cstr(submitted[0][0]) + " has already been submitted !")
raise Exception
if check == 'Previous':
# Convention := doctype => Previous Doctype, docname = Previous Docname
submitted = sql("select name from `tab%s` where docstatus = 1 and name = '%s'" % (doctype, docname))
if not submitted:
msgprint(cstr(doctype) + " : " + cstr(submitted[0][0]) + " not submitted !")
raise Exception
# Update Ref Doc
# =======================================================
def get_qty(self,curr_doctype,ref_tab_fname,ref_tab_dn,ref_doc_tname, transaction, curr_parent_name):
# Get total Quantities of current doctype (eg. PR) except for qty of this transaction
#------------------------------
# please check as UOM changes from Purchase Request - Purchase Order ,so doing following else uom should be same .
# i.e. in PO uom is NOS then in PR uom should be NOS
# but if in Purchase Request uom KG it can change in PO
get_qty = (transaction == 'Purchase Request - Purchase Order') and 'qty * conversion_factor' or 'qty'
qty = sql("select sum(%s) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% ( get_qty, curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
qty = qty and flt(qty[0][0]) or 0
# get total qty of ref doctype
#--------------------
max_qty = sql("select qty from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn))
max_qty = max_qty and flt(max_qty[0][0]) or 0
return cstr(qty)+'~~~'+cstr(max_qty)
def update_refdoc_qty(self, curr_qty, curr_doctype, ref_dn, ref_dt, ref_tab_fname, ref_tab_dn, transaction, item_code, is_submit, curr_parent_doctype, curr_parent_name):
# Get Quantity
#------------------------------
curr_ref_qty = self.get_qty(curr_doctype,ref_tab_fname,ref_tab_dn,self.doctype_dict[ref_dt], transaction, curr_parent_name)
qty, max_qty, max_qty_plus_tol = flt(curr_ref_qty.split('~~~')[0]), flt(curr_ref_qty.split('~~~')[1]), flt(curr_ref_qty.split('~~~')[1])
# Qty above Tolerance should be allowed only once.
# But there is special case for Transaction 'Purchase Request-Purhcase Order' that there should be no restriction
# One can create any no. of PO against same Purchase Request!!!
if qty >= max_qty and is_submit and flt(curr_qty) > 0:
reason = (curr_parent_doctype == 'Purchase Order') and 'Ordered' or (curr_parent_doctype == 'Purchase Receipt') and 'Received' or (curr_parent_doctype == 'Purchase Invoice') and 'Billed'
msgprint("Error: Item Code : '%s' of '%s' is already %s." %(item_code,ref_dn,reason))
raise Exception
#check if tolerance added in item master
tolerance = flt(get_value('Item',item_code,'tolerance') or 0)
if not(tolerance):
tolerance = flt(get_value('Global Defaults',None,'tolerance') or 0)
if is_submit:
qty = qty + flt(curr_qty)
# Calculate max_qty_plus_tol i.e. max_qty with tolerance
#-----------------------------------------------------------------
if transaction in self.chk_tol_for_list:
max_qty_plus_tol = max_qty * (1 + (flt(tolerance)/ 100))
if max_qty_plus_tol < qty:
reason = (curr_parent_doctype == 'Purchase Order') and 'Ordered' or (curr_parent_doctype == 'Purchase Receipt') and 'Received' or (curr_parent_doctype == 'Purchase Invoice') and 'Billed'
msgprint("error:Already %s Qty for %s is %s and maximum allowed Qty is %s" % (cstr(reason), item_code, cstr(flt(qty) - flt(curr_qty)) , cstr(max_qty_plus_tol)))
raise Exception
# Update qty
#------------------
sql("update `tab%s` set %s = '%s',modified = now() where name = '%s'" % (self.doctype_dict[ref_dt],self.update_qty[transaction] , flt(qty), ref_tab_dn))
def update_ref_doctype_dict(self, curr_qty, curr_doctype, ref_dn, ref_dt, ref_tab_fname, ref_tab_dn, transaction, item_code, is_submit, curr_parent_doctype, curr_parent_name):
# update qty
self.update_refdoc_qty( curr_qty, curr_doctype, ref_dn, ref_dt, ref_tab_fname, ref_tab_dn, transaction, item_code, is_submit, curr_parent_doctype, curr_parent_name)
# append distinct ref_dn in doctype_dict
if not self.ref_doctype_dict.has_key(ref_dn) and self.update_percent_field.has_key(transaction):
self.ref_doctype_dict[ref_dn] = [ ref_dt, self.doctype_dict[ref_dt],transaction]
# update prevdoc detail
# --------------------
def update_prevdoc_detail(self, obj, is_submit):
import math
self.ref_doctype_dict= {}
for d in getlist(obj.doclist, obj.fname):
if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname:
transaction = cstr(d.prevdoc_doctype) + ' - ' + cstr(obj.doc.doctype)
curr_qty = (transaction == 'Purchase Request - Purchase Order') and flt(d.qty) * flt(d.conversion_factor) or flt(d.qty)
self.update_ref_doctype_dict( flt(curr_qty), d.doctype, d.prevdoc_docname, d.prevdoc_doctype, 'prevdoc_detail_docname', d.prevdoc_detail_docname, transaction, d.item_code, is_submit, obj.doc.doctype, obj.doc.name)
# for payable voucher
if d.fields.has_key('purchase_order') and d.purchase_order:
curr_qty = sql("select sum(qty) from `tabPurchase Invoice Item` where po_detail = '%s' and parent = '%s'" % (cstr(d.po_detail), cstr(obj.doc.name)))
curr_qty = curr_qty and flt(curr_qty[0][0]) or 0
self.update_ref_doctype_dict( curr_qty, d.doctype, d.purchase_order, 'Purchase Order', 'po_detail', d.po_detail, 'Purchase Order - ' + cstr(obj.doc.doctype), d.item_code, is_submit, obj.doc.doctype, obj.doc.name)
if d.fields.has_key('purchase_receipt') and d.purchase_receipt:
self.update_ref_doctype_dict( flt(d.qty), d.doctype, d.purchase_receipt, 'Purchase Receipt', 'pr_detail', d.pr_detail, 'Purchase Receipt - ' + cstr(obj.doc.doctype), d.item_code, is_submit, obj.doc.doctype, obj.doc.name)
for ref_dn in self.ref_doctype_dict:
# Calculate percentage
#----------------------
ref_doc_obj = get_obj(self.ref_doctype_dict[ref_dn][0],ref_dn,with_children = 1)
count = 0
percent = 0
for d in getlist(ref_doc_obj.doclist,ref_doc_obj.fname):
ref_qty = d.fields[self.update_qty[self.ref_doctype_dict[ref_dn][2]]]
if flt(d.qty) - flt(ref_qty) <= 0:
percent += 100
else:
percent += (flt(ref_qty)/flt(d.qty) * 100)
count += 1
percent_complete = math.floor(flt(percent)/ flt(count))
# update percent complete and modified
#-------------------------------------
sql("update `tab%s` set %s = '%s', modified = '%s' where name = '%s'" % (self.ref_doctype_dict[ref_dn][0], self.update_percent_field[self.ref_doctype_dict[ref_dn][2]], percent_complete, obj.doc.modified, ref_dn))
def validate_fiscal_year(self, fiscal_year, transaction_date, dn):
fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%fiscal_year)
ysd=fy and fy[0][0] or ""
yed=add_days(str(ysd),365)
if str(transaction_date) < str(ysd) or str(transaction_date) > str(yed):
msgprint("'%s' Not Within The Fiscal Year"%(dn))
raise Exception
def load_default_taxes(self, obj):
return self.get_purchase_tax_details(obj, 1)
def get_purchase_tax_details(self,obj, default = 0):
obj.doclist = self.doc.clear_table(obj.doclist,'purchase_tax_details')
if default: add_cond = " and ifnull(t2.is_default,0) = 1"
else: add_cond = " and t1.parent = '"+cstr(obj.doc.purchase_other_charges)+"'"
other_charge = sql("""
select t1.*
from `tabPurchase Taxes and Charges` t1, `tabPurchase Taxes and Charges Master` t2
where t1.parent = t2.name %s
order by t1.idx
"""% add_cond, as_dict = 1)
idx = 0
for other in other_charge:
d = addchild(obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1, obj.doclist)
d.category = other['category']
d.add_deduct_tax = other['add_deduct_tax']
d.charge_type = other['charge_type']
d.row_id = other['row_id']
d.description = other['description']
d.account_head = other['account_head']
d.rate = flt(other['rate'])
d.tax_amount = flt(other['tax_amount'])
d.idx = idx
idx += 1
return obj.doclist
# Get Tax rate if account type is TAX
# =========================================================================
def get_rate(self, arg, obj):
arg = eval(arg)
rate = sql("select account_type, tax_rate from `tabAccount` where name = '%s'" %(arg['account_head']), as_dict=1)
ret = {
'rate' : rate and (rate[0]['account_type'] == 'Tax' and not arg['charge_type'] == 'Actual') and flt(rate[0]['tax_rate']) or 0
}
#msgprint(ret)
return ret
# Get total in words
# ==================================================================
def get_total_in_words(self, currency, amount):
from webnotes.utils import money_in_words
return money_in_words(amount, currency)
# get against document date
#-----------------------------
def get_prevdoc_date(self, obj):
import datetime
for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname:
dt = sql("select transaction_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))
d.prevdoc_date = dt and dt[0][0].strftime('%Y-%m-%d') or ''

View File

@@ -0,0 +1,31 @@
# DocType, Purchase Common
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:35:51',
'docstatus': 0,
'modified': '2012-03-27 14:35:51',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'colour': u'White:FFF',
'doctype': 'DocType',
'issingle': 1,
'module': u'Buying',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 187
},
# DocType, Purchase Common
{
'doctype': 'DocType',
'name': u'Purchase Common'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,226 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// 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
// 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/>.
cur_frm.cscript.tname = "Purchase Order Item";
cur_frm.cscript.fname = "po_details";
cur_frm.cscript.other_fname = "purchase_tax_details";
wn.require('erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');
cur_frm.cscript.onload = function(doc, cdt, cdn) {
// set missing values in parent doc
set_missing_values(doc, {
fiscal_year: sys_defaults.fiscal_year,
conversion_rate: 1,
currency: sys_defaults.currency,
status: "Draft",
transaction_date: get_today(),
is_subcontracted: "No"
});
}
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
var callback = function(doc, dt, dn) {
if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
}
cur_frm.cscript.update_item_details(doc, dt, dn, callback);
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.clear_custom_buttons();
erpnext.hide_naming_series();
cur_frm.cscript.dynamic_label(doc, cdt, cdn);
if(doc.docstatus == 1 && doc.status != 'Stopped'){
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
if(doc.per_received < 100) cur_frm.add_custom_button('Make Purchase Receipt', cur_frm.cscript['Make Purchase Receipt']);
if(doc.per_billed < 100) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Purchase Invoice']);
if(doc.per_billed < 100 || doc.per_received < 100) cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
}
if(doc.docstatus == 1 && doc.status == 'Stopped')
cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']);
cur_frm.cscript.toggle_contact_section(doc);
}
cur_frm.cscript.supplier = function(doc,dt,dn) {
if (doc.supplier) {
get_server_fields('get_default_supplier_address',
JSON.stringify({ supplier: doc.supplier }),'', doc, dt, dn, 1, function() {
cur_frm.refresh();
});
$(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
}
}
cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
if(doc.supplier) get_server_fields('get_supplier_address', JSON.stringify({supplier: doc.supplier, address: doc.supplier_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
}
cur_frm.fields_dict['supplier_address'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,address_line1,city FROM tabAddress WHERE supplier = "'+ doc.supplier +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE supplier = "'+ doc.supplier +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict.supplier_address.on_new = function(dn) {
locals['Address'][dn].supplier = locals[cur_frm.doctype][cur_frm.docname].supplier;
locals['Address'][dn].supplier_name = locals[cur_frm.doctype][cur_frm.docname].supplier_name;
}
cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].supplier = locals[cur_frm.doctype][cur_frm.docname].supplier;
locals['Contact'][dn].supplier_name = locals[cur_frm.doctype][cur_frm.docname].supplier_name;
}
cur_frm.cscript.transaction_date = function(doc,cdt,cdn){
if(doc.__islocal){ cur_frm.cscript.get_default_schedule_date(doc); }
}
cur_frm.fields_dict['po_details'].grid.get_field('project_name').get_query = function(doc, cdt, cdn) {
return 'SELECT `tabProject`.name FROM `tabProject` WHERE `tabProject`.status = "Open" AND `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50';
}
cur_frm.fields_dict['indent_no'].get_query = function(doc) {
return 'SELECT DISTINCT `tabPurchase Request`.`name` FROM `tabPurchase Request` WHERE `tabPurchase Request`.company = "' + doc.company + '" and `tabPurchase Request`.`docstatus` = 1 and `tabPurchase Request`.`status` != "Stopped" and ifnull(`tabPurchase Request`.`per_ordered`,0) < 100 and `tabPurchase Request`.%(key)s LIKE "%s" ORDER BY `tabPurchase Request`.`name` DESC LIMIT 50';
}
//========================= Get Last Purhase Rate =====================================
cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){
$c_obj(make_doclist(doc.doctype, doc.name), 'get_last_purchase_rate', '',
function(r, rt) {
refresh_field(cur_frm.cscript.fname);
var doc = locals[cdt][cdn];
cur_frm.cscript.calc_amount( doc, 2);
}
);
}
//========================= Make Purchase Receipt =======================================================
cur_frm.cscript['Make Purchase Receipt'] = function() {
n = createLocal('Purchase Receipt');
$c('dt_map', args={
'docs':compress_doclist([locals['Purchase Receipt'][n]]),
'from_doctype': cur_frm.doc.doctype,
'to_doctype':'Purchase Receipt',
'from_docname':cur_frm.doc.name,
'from_to_list':"[['Purchase Order','Purchase Receipt'],['Purchase Order Item','Purchase Receipt Item'],['Purchase Taxes and Charges','Purchase Taxes and Charges']]"
}, function(r,rt) {
loaddoc('Purchase Receipt', n);
}
);
}
//========================== Make Purchase Invoice =====================================================
cur_frm.cscript['Make Purchase Invoice'] = function() {
n = createLocal('Purchase Invoice');
$c('dt_map', args={
'docs':compress_doclist([locals['Purchase Invoice'][n]]),
'from_doctype':cur_frm.doc.doctype,
'to_doctype':'Purchase Invoice',
'from_docname': cur_frm.doc.name,
'from_to_list':"[['Purchase Order','Purchase Invoice'],['Purchase Order Item','Purchase Invoice Item'],['Purchase Taxes and Charges','Purchase Taxes and Charges']]"
}, function(r,rt) {
loaddoc('Purchase Invoice', n);
}
);
}
// Stop PURCHASE ORDER
// ==================================================================================================
cur_frm.cscript['Stop Purchase Order'] = function() {
var doc = cur_frm.doc;
var check = confirm("Do you really want to STOP " + doc.name);
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
}
// Unstop PURCHASE ORDER
// ==================================================================================================
cur_frm.cscript['Unstop Purchase Order'] = function() {
var doc = cur_frm.doc;
var check = confirm("Do you really want to UNSTOP " + doc.name);
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Submitted', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
}
//****************** For print sales order no and date*************************
cur_frm.pformat.indent_no = function(doc, cdt, cdn){
//function to make row of table
var make_row = function(title,val1, val2, bold){
var bstart = '<b>'; var bend = '</b>';
return '<tr><td style="width:39%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
+'<td style="width:61%;text-align:left;">'+val1+(val2?' ('+dateutil.str_to_user(val2)+')':'')+'</td>'
+'</tr>'
}
out ='';
var cl = getchildren('Purchase Order Item',doc.name,'po_details');
// outer table
var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 50%"></td><td>';
// main table
out +='<table class="noborder" style="width:100%">';
// add rows
if(cl.length){
prevdoc_list = new Array();
for(var i=0;i<cl.length;i++){
if(cl[i].prevdoc_doctype == 'Purchase Request' && cl[i].prevdoc_docname && prevdoc_list.indexOf(cl[i].prevdoc_docname) == -1) {
prevdoc_list.push(cl[i].prevdoc_docname);
if(prevdoc_list.length ==1)
out += make_row(cl[i].prevdoc_doctype, cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
else
out += make_row('', cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
}
}
}
out +='</table></td></tr></table></div>';
return out;
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
var args = {
type: 'Purchase Order',
doctype: 'Purchase Order'
}
cur_frm.cscript.notify(doc, args);
}

View File

@@ -0,0 +1,371 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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
# 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/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
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, getchildren, make_autoname
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
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.defaults = get_defaults()
self.tname = 'Purchase Order Item'
self.fname = 'po_details'
# Autoname
# ---------
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
def get_default_schedule_date(self):
get_obj(dt = 'Purchase Common').get_default_schedule_date(self)
def validate_fiscal_year(self):
get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'PO Date')
# Get Item Details
def get_item_details(self, arg =''):
import json
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 = ''):
return get_obj('Purchase Common').get_uom_details(arg)
# get available qty at warehouse
def get_bin_details(self, arg = ''):
return get_obj(dt='Purchase Common').get_bin_details(arg)
# Pull Purchase Request
def get_indent_details(self):
if self.doc.indent_no:
get_obj('DocType Mapper','Purchase Request-Purchase Order').dt_map('Purchase Request','Purchase Order',self.doc.indent_no, self.doc, self.doclist, "[['Purchase Request','Purchase Order'],['Purchase Request Item', 'Purchase Order Item']]")
pcomm = get_obj('Purchase Common')
for d in getlist(self.doclist, 'po_details'):
if d.item_code and not d.purchase_rate:
last_purchase_details, last_purchase_date = pcomm.get_last_purchase_details(d.item_code, self.doc.name)
if last_purchase_details:
conversion_factor = d.conversion_factor or 1.0
conversion_rate = self.doc.fields.get('conversion_rate') or 1.0
d.purchase_ref_rate = last_purchase_details['purchase_ref_rate'] * conversion_factor
d.discount_rate = last_purchase_details['discount_rate']
d.purchase_rate = last_purchase_details['purchase_rate'] * conversion_factor
d.import_ref_rate = d.purchase_ref_rate / conversion_rate
d.import_rate = d.purchase_rate / conversion_rate
else:
d.purchase_ref_rate = d.discount_rate = d.purchase_rate = d.import_ref_rate = d.import_rate = 0.0
def get_supplier_quotation_items(self):
if self.doc.supplier_quotation:
get_obj("DocType Mapper", "Supplier Quotation-Purchase Order").dt_map("Supplier Quotation",
"Purchase Order", self.doc.supplier_quotation, self.doc, self.doclist,
"""[['Supplier Quotation', 'Purchase Order'],
['Supplier Quotation Item', 'Purchase Order Item'],
['Purchase Taxes and Charges', 'Purchase Taxes and Charges']]""")
self.get_default_schedule_date()
for d in getlist(self.doclist, 'po_details'):
if d.prevdoc_detail_docname and not d.schedule_date:
d.schedule_date = webnotes.conn.get_value("Purchase Request Item",
d.prevdoc_detail_docname, "schedule_date")
def get_tc_details(self):
"""get terms & conditions"""
return get_obj('Purchase Common').get_tc_details(self)
def get_last_purchase_rate(self):
get_obj('Purchase Common').get_last_purchase_rate(self)
def validate_doc(self,pc_obj):
# Validate values with reference document
pc_obj.validate_reference_value(obj = self)
# Check for Stopped status
def check_for_stopped_status(self, pc_obj):
check_list =[]
for d in getlist(self.doclist, 'po_details'):
if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
check_list.append(d.prevdoc_docname)
pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
# Validate
def validate(self):
self.validate_fiscal_year()
# Step 1:=> set status as "Draft"
set(self.doc, 'status', 'Draft')
# Step 2:=> get Purchase Common Obj
pc_obj = get_obj(dt='Purchase Common')
# Step 3:=> validate mandatory
pc_obj.validate_mandatory(self)
# Step 4:=> validate for items
pc_obj.validate_for_items(self)
# Step 5:=> validate conversion rate
pc_obj.validate_conversion_rate(self)
# Get po date
pc_obj.get_prevdoc_date(self)
# validate_doc
self.validate_doc(pc_obj)
# Check for stopped status
self.check_for_stopped_status(pc_obj)
# get total in words
dcc = TransactionBase().get_company_currency(self.doc.company)
self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
# update bin
# ----------
def update_bin(self, is_submit, is_stopped = 0):
pc_obj = get_obj('Purchase Common')
for d in getlist(self.doclist, 'po_details'):
#1. Check if is_stock_item == 'Yes'
if sql("select is_stock_item from tabItem where name=%s", d.item_code)[0][0]=='Yes':
ind_qty, po_qty = 0, flt(d.qty) * flt(d.conversion_factor)
if is_stopped:
po_qty = flt(d.qty) > flt(d.received_qty) and flt( flt(flt(d.qty) - flt(d.received_qty)) * flt(d.conversion_factor))or 0
# No updates in Purchase Request on Stop / Unstop
if cstr(d.prevdoc_doctype) == 'Purchase Request' and not is_stopped:
# get qty and pending_qty of prevdoc
curr_ref_qty = pc_obj.get_qty( d.doctype, 'prevdoc_detail_docname', d.prevdoc_detail_docname, 'Purchase Request Item', 'Purchase Request - Purchase Order', self.doc.name)
max_qty, qty, curr_qty = flt(curr_ref_qty.split('~~~')[1]), flt(curr_ref_qty.split('~~~')[0]), 0
if flt(qty) + flt(po_qty) > flt(max_qty):
curr_qty = flt(max_qty) - flt(qty)
# special case as there is no restriction for Purchase Request - Purchase Order
curr_qty = (curr_qty > 0) and curr_qty or 0
else:
curr_qty = flt(po_qty)
ind_qty = -flt(curr_qty)
#==> Update Bin's Purchase Request Qty by +- ind_qty and Ordered Qty by +- qty
get_obj('Warehouse', d.warehouse).update_bin(0, 0, (is_submit and 1 or -1) * flt(po_qty), (is_submit and 1 or -1) * flt(ind_qty), 0, d.item_code, self.doc.transaction_date)
def check_modified_date(self):
mod_db = sql("select modified from `tabPurchase Order` where name = '%s'" % self.doc.name)
date_diff = sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
if date_diff and date_diff[0][0]:
msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ")
raise Exception
# On Close
#-------------------------------------------------------------------------------------------------
def update_status(self, status):
self.check_modified_date()
# step 1:=> Set Status
set(self.doc,'status',cstr(status))
# step 2:=> Update Bin
self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1)
# step 3:=> Acknowledge user
msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)))
# On Submit
def on_submit(self):
pc_obj = get_obj(dt ='Purchase Common')
# Step 1 :=> Update Previous Doc i.e. update pending_qty and Status accordingly
pc_obj.update_prevdoc_detail(self, is_submit = 1)
# Step 2 :=> Update Bin
self.update_bin(is_submit = 1, is_stopped = 0)
# Step 3 :=> Check For Approval Authority
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total)
# Step 4 :=> Update Current PO No. in Supplier as last_purchase_order.
update_supplier = webnotes.conn.set_value("Supplier", self.doc.supplier,
"last_purchase_order", self.doc.name)
# Step 5 :=> Update last purchase rate
pc_obj.update_last_purchase_rate(self, is_submit = 1)
# Step 6 :=> Set Status
set(self.doc,'status','Submitted')
# On Cancel
# -------------------------------------------------------------------------------------------------------
def on_cancel(self):
pc_obj = get_obj(dt = 'Purchase Common')
# 1.Check if PO status is stopped
pc_obj.check_for_stopped_status(cstr(self.doc.doctype), cstr(self.doc.name))
self.check_for_stopped_status(pc_obj)
# 2.Check if Purchase Receipt has been submitted against current Purchase Order
pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Receipt', docname = self.doc.name, detail_doctype = 'Purchase Receipt Item')
# 3.Check if Purchase Invoice has been submitted against current Purchase Order
#pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Invoice', docname = self.doc.name, detail_doctype = 'Purchase Invoice Item')
submitted = sql("select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_order = '%s' and t1.docstatus = 1" % self.doc.name)
if submitted:
msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !")
raise Exception
# 4.Set Status as Cancelled
set(self.doc,'status','Cancelled')
# 5.Update Purchase Requests Pending Qty and accordingly it's Status
pc_obj.update_prevdoc_detail(self,is_submit = 0)
# 6.Update Bin
self.update_bin( is_submit = 0, is_stopped = 0)
# Step 7 :=> Update last purchase rate
pc_obj.update_last_purchase_rate(self, is_submit = 0)
#----------- code for Sub-contracted Items -------------------
#--------check for sub-contracted items and accordingly update PO raw material detail table--------
def update_rw_material_detail(self):
for d in getlist(self.doclist,'po_details'):
item_det = sql("select is_sub_contracted_item, is_purchase_item from `tabItem` where name = '%s'"%(d.item_code))
if item_det[0][0] == 'Yes':
if item_det[0][1] == 'Yes':
if not self.doc.is_subcontracted:
msgprint("Please enter whether purchase order to be made for subcontracting or for purchasing in 'Is Subcontracted' field .")
raise Exception
if self.doc.is_subcontracted == 'Yes':
self.add_bom(d)
else:
self.doclist = self.doc.clear_table(self.doclist,'po_raw_material_details',1)
self.doc.save()
elif item_det[0][1] == 'No':
self.add_bom(d)
self.delete_irrelevant_raw_material()
#---------------calculate amt in Purchase Order Item Supplied-------------
self.calculate_amount(d)
def add_bom(self, d):
#----- fetching default bom from Bill of Materials instead of Item Master --
bom_det = sql("select t1.item, t2.item_code, t2.qty_consumed_per_unit, t2.moving_avg_rate, t2.value_as_per_mar, t2.stock_uom, t2.name, t2.parent from `tabBOM` t1, `tabBOM Item` t2 where t2.parent = t1.name and t1.item = '%s' and ifnull(t1.is_default,0) = 1 and t1.docstatus = 1" % d.item_code)
if not bom_det:
msgprint("No default BOM exists for item: %s" % d.item_code)
raise Exception
else:
#-------------- add child function--------------------
chgd_rqd_qty = []
for i in bom_det:
if i and not sql("select name from `tabPurchase Order Item Supplied` where reference_name = '%s' and bom_detail_no = '%s' and parent = '%s' " %(d.name, i[6], self.doc.name)):
rm_child = addchild(self.doc, 'po_raw_material_details', 'Purchase Order Item Supplied', 1, self.doclist)
rm_child.reference_name = d.name
rm_child.bom_detail_no = i and i[6] or ''
rm_child.main_item_code = i and i[0] or ''
rm_child.rm_item_code = i and i[1] or ''
rm_child.stock_uom = i and i[5] or ''
rm_child.rate = i and flt(i[3]) or flt(i[4])
rm_child.conversion_factor = d.conversion_factor
rm_child.required_qty = flt(i and flt(i[2]) or 0) * flt(d.qty) * flt(d.conversion_factor)
rm_child.amount = flt(flt(rm_child.consumed_qty)*flt(rm_child.rate))
rm_child.save()
chgd_rqd_qty.append(cstr(i[1]))
else:
act_qty = flt(i and flt(i[2]) or 0) * flt(d.qty) * flt(d.conversion_factor)
for po_rmd in getlist(self.doclist, 'po_raw_material_details'):
if i and i[6] == po_rmd.bom_detail_no and (flt(act_qty) != flt(po_rmd.required_qty) or i[1] != po_rmd.rm_item_code):
chgd_rqd_qty.append(cstr(i[1]))
po_rmd.main_item_code = i[0]
po_rmd.rm_item_code = i[1]
po_rmd.stock_uom = i[5]
po_rmd.required_qty = flt(act_qty)
po_rmd.rate = i and flt(i[3]) or flt(i[4])
po_rmd.amount = flt(flt(po_rmd.consumed_qty)*flt(po_rmd.rate))
# Delete irrelevant raw material from PR Raw material details
#--------------------------------------------------------------
def delete_irrelevant_raw_material(self):
for d in getlist(self.doclist,'po_raw_material_details'):
if not sql("select name from `tabPurchase Order Item` where name = '%s' and parent = '%s'and item_code = '%s'" % (d.reference_name, self.doc.name, d.main_item_code)):
d.parent = 'old_par:'+self.doc.name
d.save()
def calculate_amount(self, d):
amt = 0
for i in getlist(self.doclist,'po_raw_material_details'):
if(i.reference_name == d.name):
i.amount = flt(i.required_qty)* flt(i.rate)
amt += i.amount
d.rm_supp_cost = amt
# On Update
# ----------------------------------------------------------------------------------------------------
def on_update(self):
self.update_rw_material_detail()
def get_rate(self,arg):
return get_obj('Purchase Common').get_rate(arg,self)
def load_default_taxes(self):
self.doclist = get_obj('Purchase Common').load_default_taxes(self)
def get_purchase_tax_details(self):
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
// render
wn.doclistviews['Purchase Order'] = wn.views.ListView.extend({
init: function(d) {
this._super(d)
this.fields = this.fields.concat([
"`tabPurchase Order`.supplier_name",
"ifnull(`tabPurchase Order`.per_received,0) as per_received",
"ifnull(`tabPurchase Order`.per_billed,0) as per_billed",
"`tabPurchase Order`.currency",
"ifnull(`tabPurchase Order`.grand_total_import,0) as grand_total_import",
"`tabPurchase Order`.transaction_date",
]);
this.stats = this.stats.concat(['status', 'company']);
},
columns: [
{width: '3%', content: 'check'},
{width: '5%', content: 'avatar'},
{width: '3%', content: 'docstatus'},
{width: '15%', content: 'name'},
{width: '28%', content: 'supplier_name+tags', css: {color:'#222'}},
{
width: '18%',
content: function(parent, data) {
$(parent).html(data.currency + ' ' + fmt_money(data.grand_total_import))
},
css: {'text-align':'right'}
},
{width: '8%', content: 'per_received', type:'bar-graph', label:'Delivered'},
{width: '8%', content: 'per_billed', type:'bar-graph', label:'Billed'},
{width: '12%', content:'transaction_date',
css: {'text-align': 'right', 'color':'#777'},
title: "Purchase Order Date", type: "date"}
]
});

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,493 @@
# DocType, Purchase Order Item
[
# These values are common in all dictionaries
{
'creation': '2012-05-15 12:14:38',
'docstatus': 0,
'modified': '2012-08-06 15:55:11',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'autoname': u'POD/.#####',
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'istable': 1,
'module': u'Buying',
'name': '__common__',
'section_style': u'Tray',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Purchase Order Item',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# DocType, Purchase Order Item
{
'doctype': 'DocType',
'name': u'Purchase Order Item'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'schedule_date',
'fieldtype': u'Date',
'hidden': 0,
'in_filter': 1,
'label': u'Reqd By Date',
'no_copy': 1,
'oldfieldname': u'schedule_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'item_code',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Item Code',
'oldfieldname': u'item_code',
'oldfieldtype': u'Link',
'options': u'Item',
'permlevel': 0,
'print_hide': 0,
'reqd': 1,
'search_index': 1,
'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
{
'doctype': u'DocField',
'fieldname': u'item_name',
'fieldtype': u'Data',
'hidden': 0,
'in_filter': 1,
'label': u'Item Name',
'oldfieldname': u'item_name',
'oldfieldtype': u'Data',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Small Text',
'label': u'Description',
'oldfieldname': u'description',
'oldfieldtype': u'Small Text',
'permlevel': 0,
'reqd': 1,
'width': u'300px'
},
# DocField
{
'default': u'0.00',
'doctype': u'DocField',
'fieldname': u'qty',
'fieldtype': u'Currency',
'label': u'Quantity',
'oldfieldname': u'qty',
'oldfieldtype': u'Currency',
'permlevel': 0,
'reqd': 1,
'trigger': u'Client',
'width': u'60px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'import_ref_rate',
'fieldtype': u'Currency',
'label': u'Ref Rate ',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'discount_rate',
'fieldtype': u'Currency',
'label': u'Discount %',
'permlevel': 0,
'print_hide': 1,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'import_rate',
'fieldtype': u'Currency',
'hidden': 0,
'label': u'Rate ',
'oldfieldname': u'import_rate',
'oldfieldtype': u'Currency',
'permlevel': 0,
'print_hide': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'import_amount',
'fieldtype': u'Currency',
'label': u'Amount',
'oldfieldname': u'import_amount',
'oldfieldtype': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'purchase_ref_rate',
'fieldtype': u'Currency',
'label': u'Ref Rate *',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'default': u'0.00',
'doctype': u'DocField',
'fieldname': u'purchase_rate',
'fieldtype': u'Currency',
'label': u'Rate (Default Curr.) *',
'oldfieldname': u'purchase_rate',
'oldfieldtype': u'Currency',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'trigger': u'Client',
'width': u'100px'
},
# DocField
{
'default': u'0.00',
'doctype': u'DocField',
'fieldname': u'amount',
'fieldtype': u'Currency',
'label': u'Amount (Default Curr.)',
'oldfieldname': u'amount',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'warehouse',
'fieldtype': u'Link',
'hidden': 0,
'label': u'Warehouse',
'oldfieldname': u'warehouse',
'oldfieldtype': u'Link',
'options': u'Warehouse',
'permlevel': 0,
'print_hide': 1,
'reqd': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'project_name',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Project Name',
'options': u'Project',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'uom',
'fieldtype': u'Link',
'label': u'UOM',
'oldfieldname': u'uom',
'oldfieldtype': u'Link',
'options': u'UOM',
'permlevel': 0,
'print_hide': 0,
'reqd': 1,
'trigger': u'Client',
'width': u'100px'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'conversion_factor',
'fieldtype': u'Currency',
'hidden': 0,
'label': u'UOM Conversion Factor',
'oldfieldname': u'conversion_factor',
'oldfieldtype': u'Currency',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'trigger': u'Client',
'width': u'100px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'stock_uom',
'fieldtype': u'Data',
'hidden': 0,
'label': u'Stock UOM',
'oldfieldname': u'stock_uom',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1,
'reqd': 1,
'width': u'100px'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'prevdoc_doctype',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Prevdoc DocType',
'no_copy': 0,
'oldfieldname': u'prevdoc_doctype',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'prevdoc_docname',
'fieldtype': u'Link',
'hidden': 0,
'in_filter': 1,
'label': u'Purchase Requisition No',
'no_copy': 0,
'oldfieldname': u'prevdoc_docname',
'oldfieldtype': u'Link',
'options': u'Purchase Request',
'permlevel': 1,
'print_hide': 1,
'search_index': 1,
'width': u'120px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'prevdoc_date',
'fieldtype': u'Date',
'hidden': 1,
'in_filter': 1,
'label': u'Purchase Request Date',
'oldfieldname': u'prevdoc_date',
'oldfieldtype': u'Date',
'permlevel': 1,
'print_hide': 1,
'search_index': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'prevdoc_detail_docname',
'fieldtype': u'Data',
'hidden': 1,
'in_filter': 1,
'label': u'Purchase Request Detail No',
'no_copy': 0,
'oldfieldname': u'prevdoc_detail_docname',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'supplier_quotation',
'fieldtype': u'Link',
'hidden': 1,
'in_filter': 0,
'label': u'Supplier Quotation',
'options': u'Supplier Quotation',
'permlevel': 1,
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'supplier_quotation_item',
'fieldtype': u'Link',
'hidden': 1,
'label': u'Supplier Quotation Item',
'options': u'Supplier Quotation Item',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'brand',
'fieldtype': u'Link',
'hidden': 1,
'label': u'Brand',
'oldfieldname': u'brand',
'oldfieldtype': u'Link',
'options': u'Brand',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'item_group',
'fieldtype': u'Link',
'hidden': 1,
'in_filter': 1,
'label': u'Item Group',
'oldfieldname': u'item_group',
'oldfieldtype': u'Link',
'options': u'Item Group',
'permlevel': 1,
'print_hide': 1,
'search_index': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'stock_qty',
'fieldtype': u'Currency',
'hidden': 0,
'label': u'Stock Qty',
'no_copy': 1,
'oldfieldname': u'stock_qty',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1,
'trigger': u'Client',
'width': u'100px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'received_qty',
'fieldtype': u'Currency',
'hidden': 0,
'label': u'Received Qty',
'no_copy': 1,
'oldfieldname': u'received_qty',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'default': u'0.00',
'doctype': u'DocField',
'fieldname': u'billed_qty',
'fieldtype': u'Currency',
'hidden': 0,
'label': u'Billed Quantity',
'no_copy': 1,
'oldfieldname': u'billed_qty',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges',
'doctype': u'DocField',
'fieldname': u'item_tax_rate',
'fieldtype': u'Small Text',
'hidden': 1,
'label': u'Item Tax Rate',
'oldfieldname': u'item_tax_rate',
'oldfieldtype': u'Small Text',
'permlevel': 1,
'print_hide': 1,
'report_hide': 1
},
# DocField
{
'allow_on_submit': 1,
'doctype': u'DocField',
'fieldname': u'page_break',
'fieldtype': u'Check',
'hidden': 0,
'label': u'Page Break',
'no_copy': 1,
'oldfieldname': u'page_break',
'oldfieldtype': u'Check',
'permlevel': 0,
'print_hide': 1
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,144 @@
# DocType, Purchase Order Item Supplied
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:35:50',
'docstatus': 0,
'modified': '2012-03-27 14:35:50',
'modified_by': u'Administrator',
'owner': u'dhanalekshmi@webnotestech.com'
},
# These values are common for all DocType
{
'colour': u'White:FFF',
'doctype': 'DocType',
'hide_toolbar': 1,
'istable': 1,
'module': u'Buying',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Purchase Order Item Supplied',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# DocType, Purchase Order Item Supplied
{
'doctype': 'DocType',
'name': u'Purchase Order Item Supplied'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reference_name',
'fieldtype': u'Data',
'hidden': 0,
'in_filter': 0,
'label': u'Reference Name',
'oldfieldname': u'reference_name',
'oldfieldtype': u'Data',
'permlevel': 1,
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'bom_detail_no',
'fieldtype': u'Data',
'label': u'BOM Detail No',
'oldfieldname': u'bom_detail_no',
'oldfieldtype': u'Data',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'main_item_code',
'fieldtype': u'Data',
'label': u'Item Code',
'oldfieldname': u'main_item_code',
'oldfieldtype': u'Data',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'rm_item_code',
'fieldtype': u'Data',
'label': u'Raw Material Item Code',
'oldfieldname': u'rm_item_code',
'oldfieldtype': u'Data',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'required_qty',
'fieldtype': u'Currency',
'label': u'Required Qty',
'oldfieldname': u'required_qty',
'oldfieldtype': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'rate',
'fieldtype': u'Currency',
'label': u'Rate',
'oldfieldname': u'rate',
'oldfieldtype': u'Currency',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amount',
'fieldtype': u'Currency',
'label': u'Amount',
'oldfieldname': u'amount',
'oldfieldtype': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'conversion_factor',
'fieldtype': u'Currency',
'hidden': 1,
'label': u'Conversion Factor',
'oldfieldname': u'conversion_factor',
'oldfieldtype': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'stock_uom',
'fieldtype': u'Data',
'label': u'Stock Uom',
'oldfieldname': u'stock_uom',
'oldfieldtype': u'Data',
'permlevel': 1
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,179 @@
# DocType, Purchase Receipt Item Supplied
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:35:50',
'docstatus': 0,
'modified': '2012-03-27 14:35:50',
'modified_by': u'Administrator',
'owner': u'wasim@webnotestech.com'
},
# These values are common for all DocType
{
'colour': u'White:FFF',
'doctype': 'DocType',
'hide_toolbar': 0,
'istable': 1,
'module': u'Buying',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 17
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Purchase Receipt Item Supplied',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# DocType, Purchase Receipt Item Supplied
{
'doctype': 'DocType',
'name': u'Purchase Receipt Item Supplied'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reference_name',
'fieldtype': u'Data',
'hidden': 0,
'in_filter': 0,
'label': u'Reference Name',
'oldfieldname': u'reference_name',
'oldfieldtype': u'Data',
'permlevel': 1,
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'bom_detail_no',
'fieldtype': u'Data',
'label': u'BOM Detail No',
'oldfieldname': u'bom_detail_no',
'oldfieldtype': u'Data',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'main_item_code',
'fieldtype': u'Data',
'label': u'Item Code',
'oldfieldname': u'main_item_code',
'oldfieldtype': u'Data',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'rm_item_code',
'fieldtype': u'Data',
'label': u'Raw Material Item Code',
'oldfieldname': u'rm_item_code',
'oldfieldtype': u'Data',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Data',
'label': u'Description',
'oldfieldname': u'description',
'oldfieldtype': u'Data',
'permlevel': 1,
'width': u'300px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'required_qty',
'fieldtype': u'Currency',
'label': u'Required Qty',
'oldfieldname': u'required_qty',
'oldfieldtype': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'consumed_qty',
'fieldtype': u'Currency',
'label': u'Consumed Qty',
'oldfieldname': u'consumed_qty',
'oldfieldtype': u'Currency',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'rate',
'fieldtype': u'Currency',
'label': u'Rate',
'oldfieldname': u'rate',
'oldfieldtype': u'Currency',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'conversion_factor',
'fieldtype': u'Currency',
'hidden': 1,
'label': u'Conversion Factor',
'oldfieldname': u'conversion_factor',
'oldfieldtype': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amount',
'fieldtype': u'Currency',
'label': u'Amount',
'oldfieldname': u'amount',
'oldfieldtype': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'stock_uom',
'fieldtype': u'Data',
'label': u'Stock Uom',
'oldfieldname': u'stock_uom',
'oldfieldtype': u'Data',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'current_stock',
'fieldtype': u'Currency',
'label': u'Current Stock',
'oldfieldname': u'current_stock',
'oldfieldtype': u'Currency',
'permlevel': 1
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,139 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// 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
// 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/>.
cur_frm.cscript.tname = "Purchase Request Item";
cur_frm.cscript.fname = "indent_details";
wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
//========================== On Load =================================================
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) {
// second call
if(doc.__islocal){
cur_frm.cscript.get_item_defaults(doc);
}
}
cur_frm.cscript.get_item_defaults = function(doc) {
var ch = getchildren( 'Purchase Request Item', doc.name, 'indent_details');
if (flt(ch.length) > 0){
$c_obj(make_doclist(doc.doctype, doc.name), 'get_item_defaults', '', function(r, rt) {refresh_field('indent_details'); });
}
}
//======================= Refresh =====================================
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.clear_custom_buttons();
erpnext.hide_naming_series();
if(doc.docstatus == 1 && doc.status != 'Stopped'){
if(doc.per_ordered < 100) {
cur_frm.add_custom_button('Make Purchase Order', cur_frm.cscript['Make Purchase Order']);
cur_frm.add_custom_button('Stop Purchase Request', cur_frm.cscript['Stop Purchase Request']);
}
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
cur_frm.add_custom_button("Make Supplier Quotation", cur_frm.cscript.make_supplier_quotation);
}
if(doc.docstatus == 1 && doc.status == 'Stopped')
cur_frm.add_custom_button('Unstop Purchase Request', cur_frm.cscript['Unstop Purchase Request'])
}
//======================= validation ===================================
cur_frm.cscript.validate = function(doc,cdt,cdn){
is_item_table(doc,cdt,cdn);
}
//======================= transaction date =============================
cur_frm.cscript.transaction_date = function(doc,cdt,cdn){
if(doc.__islocal){
cur_frm.cscript.get_default_schedule_date(doc);
}
}
//=================== Quantity ===================================================================
cur_frm.cscript.qty = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if (flt(d.qty) < flt(d.min_order_qty))
alert("Warning: Purchase Requested Qty is less than Minimum Order Qty");
}
// On Button Click Functions
// ------------------------------------------------------------------------------
// Make Purchase Order
cur_frm.cscript['Make Purchase Order'] = function() {
var doc = cur_frm.doc;
n = createLocal('Purchase Order');
$c('dt_map', args={
'docs':compress_doclist([locals['Purchase Order'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Purchase Order',
'from_docname':doc.name,
'from_to_list':"[['Purchase Request','Purchase Order'],['Purchase Request Item','Purchase Order Item']]"
}, function(r,rt) {
loaddoc('Purchase Order', n);
}
);
}
// Stop INDENT
// ==================================================================================================
cur_frm.cscript['Stop Purchase Request'] = function() {
var doc = cur_frm.doc;
var check = confirm("Do you really want to STOP this Purchase Request?");
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
}
// Un Stop INDENT
//====================================================================================================
cur_frm.cscript['Unstop Purchase Request'] = function(){
var doc = cur_frm.doc
var check = confirm("Do you really want to UNSTOP this Purchase Request?");
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
}
cur_frm.cscript.make_supplier_quotation = function() {
var new_sq_name = createLocal("Supplier Quotation");
$c("dt_map", {
"docs": compress_doclist([locals['Supplier Quotation'][new_sq_name]]),
"from_doctype": cur_frm.doc.doctype,
"to_doctype": "Supplier Quotation",
"from_docname": cur_frm.doc.name,
"from_to_list": JSON.stringify([['Purchase Request', 'Supplier Quotation'],
['Purchase Request Item', 'Supplier Quotation Item']]),
}, function(r, rt) { loaddoc("Supplier Quotation", new_sq_name) });
}

View File

@@ -0,0 +1,234 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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
# 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/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
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, getchildren, make_autoname
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
self.defaults = get_defaults()
self.tname = 'Purchase Request Item'
self.fname = 'indent_details'
# Autoname
# ---------
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
def get_default_schedule_date(self):
get_obj(dt = 'Purchase Common').get_default_schedule_date(self)
# get available qty at warehouse
def get_bin_details(self, arg = ''):
return get_obj(dt='Purchase Common').get_bin_details(arg)
# Pull Sales Order Items
# -------------------------
def pull_so_details(self):
self.check_if_already_pulled()
if self.doc.sales_order_no:
get_obj('DocType Mapper', 'Sales Order-Purchase Request', with_children=1).dt_map('Sales Order', 'Purchase Request', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Purchase Request'],['Sales Order Item', 'Purchase Request Item']]")
self.get_item_defaults()
else:
msgprint("Please select Sales Order whose details need to pull")
def check_if_already_pulled(self):
pass#if self.[d.sales_order_no for d in getlist(self.doclist, 'indent_details')]
# Get item's other details
#- ------------------------
def get_item_defaults(self):
self.get_default_schedule_date()
for d in getlist(self.doclist, 'indent_details'):
det = sql("select min_order_qty from tabItem where name = '%s'" % d.item_code)
d.min_order_qty = det and flt(det[0][0]) or 0
# Validate so items
# ----------------------------
def validate_qty_against_so(self):
so_items = {} # Format --> {'SO/00001': {'Item/001': 120, 'Item/002': 24}}
for d in getlist(self.doclist, 'indent_details'):
if d.sales_order_no:
if not so_items.has_key(d.sales_order_no):
so_items[d.sales_order_no] = {d.item_code: flt(d.qty)}
else:
if not so_items[d.sales_order_no].has_key(d.item_code):
so_items[d.sales_order_no][d.item_code] = flt(d.qty)
else:
so_items[d.sales_order_no][d.item_code] += flt(d.qty)
for so_no in so_items.keys():
for item in so_items[so_no].keys():
already_indented = sql("select sum(qty) from `tabPurchase Request Item` where item_code = '%s' and sales_order_no = '%s' and docstatus = 1 and parent != '%s'" % (item, so_no, self.doc.name))
already_indented = already_indented and flt(already_indented[0][0]) or 0
actual_so_qty = sql("select sum(qty) from `tabSales Order Item` where parent = '%s' and item_code = '%s' and docstatus = 1 group by parent" % (so_no, item))
actual_so_qty = actual_so_qty and flt(actual_so_qty[0][0]) or 0
if flt(so_items[so_no][item]) + already_indented > actual_so_qty:
msgprint("You can raise indent of maximum qty: %s for item: %s against sales order: %s\n Anyway, you can add more qty in new row for the same item." % (actual_so_qty - already_indented, item, so_no), raise_exception=1)
# Validate fiscal year
# ----------------------------
def validate_fiscal_year(self):
get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Purchase Request Date')
# 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 = ''):
return get_obj(dt='Purchase Common').get_uom_details(arg)
# GET TERMS & CONDITIONS
#-----------------------------
def get_tc_details(self):
return get_obj('Purchase Common').get_tc_details(self)
# Validate Schedule Date
#--------------------------------
def validate_schedule_date(self):
#:::::::: validate schedule date v/s indent date ::::::::::::
for d in getlist(self.doclist, 'indent_details'):
if d.schedule_date < self.doc.transaction_date:
msgprint("Expected Schedule Date cannot be before Purchase Request Date")
raise Exception
# Validate
# ---------------------
def validate(self):
self.validate_schedule_date()
self.validate_fiscal_year()
# set status as "Draft"
set(self.doc, 'status', 'Draft')
# Get Purchase Common Obj
pc_obj = get_obj(dt='Purchase Common')
# Validate Mandatory
pc_obj.validate_mandatory(self)
# Validate for items
pc_obj.validate_for_items(self)
# Validate qty against SO
self.validate_qty_against_so()
# On Submit Functions
#----------------------------------------------------------------------------
# Update Quantity Requested for Purchase in Bin
def update_bin(self, is_submit, is_stopped):
for d in getlist(self.doclist, 'indent_details'):
# Step 1:=> Check if is_stock_item == 'Yes'
if cstr(sql("select is_stock_item from `tabItem` where name = '%s'" % cstr(d.item_code))[0][0]) == 'Yes':
if not d.warehouse:
msgprint('Please Enter Warehouse for Item %s as it is stock item.' % cstr(d.item_code))
raise Exception
# Step 2:=> Set Qty
qty =flt(d.qty)
if is_stopped:
qty = (d.qty > d.ordered_qty) and flt(flt(d.qty) - flt(d.ordered_qty)) or 0
# Step 3 :=> Update Bin's Purchase Request Qty by +- qty
get_obj('Warehouse', d.warehouse).update_bin(0, 0, 0, (is_submit and 1 or -1) * flt(qty), 0, d.item_code, self.doc.transaction_date)
# On Submit
#---------------------------------------------------------------------------
def on_submit(self):
# Step 1:=> Set Status
set(self.doc,'status','Submitted')
# Step 2:=> Update Bin
self.update_bin(is_submit = 1, is_stopped = 0)
def check_modified_date(self):
mod_db = sql("select modified from `tabPurchase Request` where name = '%s'" % self.doc.name)
date_diff = sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
if date_diff and date_diff[0][0]:
msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ")
raise Exception
# On Stop / unstop
#------------------------------------------------------------------------------
def update_status(self, status):
self.check_modified_date()
# Step 1:=> Update Bin
self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1)
# Step 2:=> Set status
set(self.doc,'status',cstr(status))
# Step 3:=> Acknowledge User
msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)) )
# On Cancel
#-----------------------------------------------------------------------------
def on_cancel(self):
# Step 1:=> Get Purchase Common Obj
pc_obj = get_obj(dt='Purchase Common')
# Step 2:=> Check for stopped status
pc_obj.check_for_stopped_status( self.doc.doctype, self.doc.name)
# Step 3:=> Check if Purchase Order has been submitted against current Purchase Request
pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Order', docname = self.doc.name, detail_doctype = 'Purchase Order Item')
# Step 4:=> Update Bin
self.update_bin(is_submit = 0, is_stopped = (cstr(self.doc.status) == 'Stopped') and 1 or 0)
# Step 5:=> Set Status
set(self.doc,'status','Cancelled')

View File

@@ -0,0 +1,527 @@
# DocType, Purchase Request
[
# These values are common in all dictionaries
{
'creation': '2012-04-13 11:56:20',
'docstatus': 0,
'modified': '2012-05-01 13:02:17',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1326190064',
'allow_attach': 1,
'allow_print': 0,
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'is_submittable': 1,
'module': u'Buying',
'name': '__common__',
'read_only_onload': 1,
'search_fields': u'status,transaction_date,sales_order_no',
'section_style': u'Tabbed',
'server_code_error': u' ',
'show_in_menu': 0,
'subject': u'%(per_ordered)s% ordered',
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Purchase Request',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Purchase Request',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1
},
# DocType, Purchase Request
{
'doctype': 'DocType',
'name': u'Purchase Request'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Purchase Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Purchase Manager',
'submit': 1,
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Material Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Material Manager',
'submit': 1,
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Material User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Material User',
'submit': 1,
'write': 1
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Purchase User',
'submit': 1,
'write': 1
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Purchase User'
},
# DocField
{
'colour': u'White:FFF',
'default': u'Enter items and their details which are falling short in your warehouse and for which you want your purchase department to raise a purchase order.',
'description': u'Enter items and their details for which you want your purchase department to raise a purchase order.',
'doctype': u'DocField',
'fieldname': u'basic_info',
'fieldtype': u'Section Break',
'label': u'Basic Info',
'oldfieldtype': u'Section Break',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'To manage multiple series please go to Setup > Manage Series',
'doctype': u'DocField',
'fieldname': u'naming_series',
'fieldtype': u'Select',
'label': u'Series',
'no_copy': 1,
'oldfieldname': u'naming_series',
'oldfieldtype': u'Select',
'options': u'IDT',
'permlevel': 0,
'print_hide': 1,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'The date at which current entry is made in system.',
'doctype': u'DocField',
'fieldname': u'transaction_date',
'fieldtype': u'Date',
'in_filter': 1,
'label': u'Transaction Date',
'no_copy': 1,
'oldfieldname': u'transaction_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 1,
'search_index': 1,
'trigger': u'Client',
'width': u'100px'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'items',
'fieldtype': u'Section Break',
'label': u'Items',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'allow_on_submit': 1,
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'indent_details',
'fieldtype': u'Table',
'label': u'Purchase Requisition Details',
'no_copy': 0,
'oldfieldname': u'indent_details',
'oldfieldtype': u'Table',
'options': u'Purchase Request Item',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break1',
'fieldtype': u'Section Break',
'options': u'Simple',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break4',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'description': u'One or multiple Sales Order no which generated this Purchase Requisition',
'doctype': u'DocField',
'fieldname': u'sales_order_no',
'fieldtype': u'Link',
'label': u'Sales Order No',
'no_copy': 1,
'oldfieldname': u'sales_order_no',
'oldfieldtype': u'Data',
'options': u'Sales Order',
'permlevel': 0,
'width': u'100px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break5',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'pull_sales_order_details',
'fieldtype': u'Button',
'label': u'Pull Sales Order Items',
'options': u'pull_so_details',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'default': u'Give additional details about the indent.',
'description': u'Filing in Additional Information about the Purchase Requisition will help you analyze your data better.',
'doctype': u'DocField',
'fieldname': u'more_info',
'fieldtype': u'Section Break',
'label': u'More Info',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'description': u'Select the relevant company name if you have multiple companies',
'doctype': u'DocField',
'fieldname': u'company',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Company',
'oldfieldname': u'company',
'oldfieldtype': u'Link',
'options': u'Company',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'search_index': 1,
'width': u'150px'
},
# DocField
{
'colour': u'White:FFF',
'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': 1,
'width': u'150px'
},
# DocField
{
'colour': u'White:FFF',
'description': u'Name of the entity who has requested for the Purchase Requisition',
'doctype': u'DocField',
'fieldname': u'requested_by',
'fieldtype': u'Data',
'label': u'Requested By',
'no_copy': 1,
'oldfieldname': u'requested_by',
'oldfieldtype': u'Data',
'permlevel': 0,
'width': u'100px'
},
# DocField
{
'colour': u'White:FFF',
'description': u'After cancelling the Purchase Requisition, a dialog box will ask you reason for cancellation which will be reflected in this field',
'doctype': u'DocField',
'fieldname': u'cancel_reason',
'fieldtype': u'Data',
'label': u'Cancel Reason',
'no_copy': 1,
'oldfieldname': u'cancel_reason',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break2',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'allow_on_submit': 1,
'doctype': u'DocField',
'fieldname': u'letter_head',
'fieldtype': u'Select',
'label': u'Letter Head',
'oldfieldname': u'letter_head',
'oldfieldtype': u'Select',
'options': u'link:Letter Head',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'status',
'fieldtype': u'Select',
'in_filter': 1,
'label': u'Status',
'no_copy': 1,
'oldfieldname': u'status',
'oldfieldtype': u'Select',
'options': u'\nDraft\nSubmitted\nStopped\nCancelled',
'permlevel': 1,
'print_hide': 1,
'reqd': 0,
'search_index': 1,
'width': u'100px'
},
# DocField
{
'colour': u'White:FFF',
'description': u'% of materials ordered against this Purchase Requisition',
'doctype': u'DocField',
'fieldname': u'per_ordered',
'fieldtype': u'Currency',
'label': u'% Ordered',
'no_copy': 1,
'oldfieldname': u'per_ordered',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 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
{
'description': u'The date at which current entry is corrected in the system.',
'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'remark',
'fieldtype': u'Small Text',
'label': u'Remarks',
'no_copy': 1,
'oldfieldname': u'remark',
'oldfieldtype': u'Small Text',
'permlevel': 0,
'print_hide': 0,
'width': u'150px'
},
# DocField
{
'description': u'Add Terms and Conditions for the Purchase Requisition. You can also prepare a Terms and Conditions Master and use the Template',
'doctype': u'DocField',
'fieldname': u'terms_section_break',
'fieldtype': u'Section Break',
'label': u'Terms and Conditions',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'tc_name',
'fieldtype': u'Link',
'label': u'Select Terms and Conditions',
'oldfieldname': u'tc_name',
'oldfieldtype': u'Link',
'options': u'Terms and Conditions',
'permlevel': 0,
'print_hide': 1,
'report_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'get_terms',
'fieldtype': u'Button',
'label': u'Get Terms and Conditions',
'oldfieldtype': u'Button',
'options': u'get_tc_details',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'terms',
'fieldtype': u'Text Editor',
'label': u'Terms and Conditions Content',
'oldfieldname': u'terms',
'oldfieldtype': u'Text Editor',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'file_list',
'fieldtype': u'Text',
'hidden': 1,
'label': u'File List',
'no_copy': 1,
'permlevel': 0,
'print_hide': 1
}
]

View File

@@ -0,0 +1,37 @@
// render
wn.doclistviews['Purchase Request'] = wn.views.ListView.extend({
init: function(d) {
this._super(d)
this.fields = this.fields.concat([
"`tabPurchase Request`.status",
"IFNULL(`tabPurchase Request`.per_ordered, 0) as per_ordered",
"`tabPurchase Request`.remark",
"`tabPurchase Request`.transaction_date",
]);
this.stats = this.stats.concat(['status', 'company']);
},
prepare_data: function(data) {
this._super(data);
if(['Stopped', 'Cancelled'].indexOf(data.status)!=-1) {
data.label_type = 'important';
} else if(data.status == 'Submitted') {
data.label_type = 'success';
}
data.status_html = repl('<span class="label label-%(label_type)s">%(status)s</span>', data);
},
columns: [
{width: '3%', content: 'check'},
{width: '5%', content:'avatar'},
{width: '3%', content:'docstatus'},
{width: '17%', content:'name'},
{width: '50%', content:'status_html+remark+tags', css: {'color': '#222'}},
{width: '10%', content: 'per_ordered', type:'bar-graph', label:'Ordered'},
{width: '12%', content:'transaction_date',
css: {'text-align': 'right', 'color':'#777'},
title: "Quotation Date", type: "date"}
]
});

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,262 @@
# DocType, Purchase Request Item
[
# These values are common in all dictionaries
{
'creation': '2012-04-11 13:17:40',
'docstatus': 0,
'modified': '2012-04-12 14:52:49',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'autoname': u'IDTD/.#####',
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'istable': 1,
'module': u'Buying',
'name': '__common__',
'section_style': u'Tray',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 37
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Purchase Request Item',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# DocType, Purchase Request Item
{
'doctype': 'DocType',
'name': u'Purchase Request Item'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'schedule_date',
'fieldtype': u'Date',
'label': u'Required Date',
'no_copy': 1,
'oldfieldname': u'schedule_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'print_hide': 0,
'reqd': 1,
'width': u'100px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'item_code',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Item Code',
'oldfieldname': u'item_code',
'oldfieldtype': u'Link',
'options': u'Item',
'permlevel': 0,
'reqd': 1,
'search_index': 1,
'trigger': u'Client',
'width': u'100px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Text',
'label': u'Description',
'oldfieldname': u'description',
'oldfieldtype': u'Text',
'permlevel': 0,
'reqd': 1,
'width': u'250px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'warehouse',
'fieldtype': u'Link',
'label': u'Warehouse',
'oldfieldname': u'warehouse',
'oldfieldtype': u'Link',
'options': u'Warehouse',
'permlevel': 0,
'print_hide': 0,
'reqd': 0,
'trigger': u'Client',
'width': u'100px'
},
# DocField
{
'colour': u'White:FFF',
'default': u'0.00',
'doctype': u'DocField',
'fieldname': u'qty',
'fieldtype': u'Currency',
'label': u'Quantity',
'no_copy': 0,
'oldfieldname': u'qty',
'oldfieldtype': u'Currency',
'permlevel': 0,
'reqd': 1,
'trigger': u'Client',
'width': u'80px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'uom',
'fieldtype': u'Link',
'label': u'Stock UOM',
'no_copy': 0,
'oldfieldname': u'uom',
'oldfieldtype': u'Link',
'options': u'UOM',
'permlevel': 1,
'reqd': 1,
'width': u'70px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'lead_time_date',
'fieldtype': u'Date',
'label': u'Lead Time Date',
'no_copy': 1,
'oldfieldname': u'lead_time_date',
'oldfieldtype': u'Date',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'item_name',
'fieldtype': u'Data',
'in_filter': 1,
'label': u'Item Name',
'oldfieldname': u'item_name',
'oldfieldtype': u'Data',
'permlevel': 0,
'reqd': 1,
'search_index': 1,
'width': u'100px'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'item_group',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Item Group',
'no_copy': 0,
'oldfieldname': u'item_group',
'oldfieldtype': u'Link',
'options': u'Item Group',
'permlevel': 1,
'print_hide': 1,
'reqd': 0,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'brand',
'fieldtype': u'Link',
'label': u'Brand',
'oldfieldname': u'brand',
'oldfieldtype': u'Link',
'options': u'Brand',
'permlevel': 1,
'print_hide': 1,
'width': u'100px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'min_order_qty',
'fieldtype': u'Currency',
'label': u'Min Order Qty',
'no_copy': 1,
'oldfieldname': u'min_order_qty',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1,
'reqd': 0,
'width': u'70px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'projected_qty',
'fieldtype': u'Currency',
'label': u'Projected Qty',
'no_copy': 1,
'oldfieldname': u'projected_qty',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1,
'width': u'70px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'ordered_qty',
'fieldtype': u'Currency',
'label': u'Ordered Qty',
'no_copy': 1,
'oldfieldname': u'ordered_qty',
'oldfieldtype': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'sales_order_no',
'fieldtype': u'Link',
'label': u'Sales Order No',
'no_copy': 1,
'options': u'Sales Order',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'allow_on_submit': 1,
'doctype': u'DocField',
'fieldname': u'page_break',
'fieldtype': u'Check',
'label': u'Page Break',
'no_copy': 1,
'oldfieldname': u'page_break',
'oldfieldtype': u'Check',
'permlevel': 0,
'print_hide': 1
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,60 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// 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
// 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/>.
cur_frm.cscript.item_code = function(doc, cdt, cdn) {
if (doc.item_code)
get_server_fields('get_purchase_receipt_item_details','','',doc,cdt,cdn,1);
}
cur_frm.cscript.inspection_type = function(doc, cdt, cdn) {
if(doc.inspection_type == 'Incoming'){
doc.delivery_note_no = '';
hide_field('delivery_note_no');
unhide_field('purchase_receipt_no');
}
else if(doc.inspection_type == 'Outgoing'){
doc.purchase_receipt_no = '';
unhide_field('delivery_note_no');
hide_field('purchase_receipt_no');
}
else {
doc.purchase_receipt_no = '';
doc.delivery_note_no = '';
hide_field('purchase_receipt_no');
hide_field('delivery_note_no');
}
}
cur_frm.cscript.refresh = cur_frm.cscript.inspection_type;
// item code based on GRN/DN
cur_frm.fields_dict['item_code'].get_query = function(doc, cdt, cdn) {
if (doc.purchase_receipt_no)
return 'SELECT item_code, item_name, description FROM `tabPurchase Receipt Item` WHERE parent = "'+ doc.purchase_receipt_no +'" and docstatus != 2 AND item_code LIKE "%s" ORDER BY item_code ASC LIMIT 50';
else if (doc.delivery_note_no)
return 'SELECT item_code, item_name, description FROM `tabDelivery Note Item` WHERE parent = "'+ doc.delivery_note_no +'" and docstatus != 2 AND item_code LIKE "%s" ORDER BY item_code ASC LIMIT 50';
else
return 'SELECT name, item_name, description FROM tabItem WHERE docstatus != 2 AND %(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
}
// Serial No based on item_code
cur_frm.fields_dict['item_serial_no'].get_query = function(doc, cdt, cdn) {
if (doc.item_code)
return 'SELECT name, item_code, warehouse FROM `tabSerial No` WHERE docstatus != 2 AND item_code = "' + doc.item_code +'" AND status = "In Store" AND %(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
else
return 'SELECT name, item_code, warehouse FROM `tabSerial No` WHERE docstatus != 2 AND status = "In Store" AND %(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
}

View File

@@ -0,0 +1,69 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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
# 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/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
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, getchildren, make_autoname
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
# Autoname
# ---------
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
def get_item_specification_details(self):
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))
for d in specification:
child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', 1, self.doclist)
child.specification = d[0]
child.value = d[1]
child.status = 'Accepted'
def on_submit(self):
if self.doc.purchase_receipt_no:
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):
if self.doc.purchase_receipt_no:
sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '', t2.modified = '%s' \
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))

View File

@@ -0,0 +1,346 @@
# DocType, Quality Inspection
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:35:51',
'docstatus': 0,
'modified': '2012-03-27 14:45:50',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1317365120',
'autoname': u'QAI/.######',
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'is_submittable': 1,
'module': u'Buying',
'name': '__common__',
'print_outline': u'Yes',
'search_fields': u'item_code, report_date, purchase_receipt_no, delivery_note_no',
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 38
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Quality Inspection',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Quality Inspection',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1,
'role': u'Quality Manager'
},
# DocType, Quality Inspection
{
'doctype': 'DocType',
'name': u'Quality Inspection'
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 1
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'submit': 1,
'write': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'qa_inspection',
'fieldtype': u'Section Break',
'label': u'QA Inspection',
'no_copy': 0,
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'naming_series',
'fieldtype': u'Select',
'label': u'Naming Series',
'no_copy': 1,
'options': u'\nQAI/11-12/',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'inspection_type',
'fieldtype': u'Select',
'in_filter': 1,
'label': u'Inspection Type',
'oldfieldname': u'inspection_type',
'oldfieldtype': u'Select',
'options': u'\nIncoming\nOutgoing\nIn Process',
'permlevel': 0,
'reqd': 1,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'report_date',
'fieldtype': u'Date',
'in_filter': 1,
'label': u'Report Date',
'oldfieldname': u'report_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 1,
'search_index': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'item_code',
'fieldtype': u'Link',
'hidden': 0,
'in_filter': 1,
'label': u'Item Code',
'oldfieldname': u'item_code',
'oldfieldtype': u'Link',
'options': u'Item',
'permlevel': 0,
'reqd': 1,
'search_index': 1,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'sample_size',
'fieldtype': u'Currency',
'in_filter': 0,
'label': u'Sample Size',
'oldfieldname': u'sample_size',
'oldfieldtype': u'Currency',
'permlevel': 0,
'reqd': 1,
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Small Text',
'in_filter': 1,
'label': u'Description',
'oldfieldname': u'description',
'oldfieldtype': u'Small Text',
'permlevel': 0,
'search_index': 0,
'width': u'300px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'item_serial_no',
'fieldtype': u'Link',
'hidden': 0,
'label': u'Item Serial No',
'oldfieldname': u'item_serial_no',
'oldfieldtype': u'Link',
'options': u'Serial No',
'permlevel': 0,
'print_hide': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'batch_no',
'fieldtype': u'Link',
'label': u'Batch No',
'oldfieldname': u'batch_no',
'oldfieldtype': u'Link',
'options': u'Batch',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'purchase_receipt_no',
'fieldtype': u'Link',
'hidden': 0,
'in_filter': 1,
'label': u'Purchase Receipt No',
'oldfieldname': u'purchase_receipt_no',
'oldfieldtype': u'Link',
'options': u'Purchase Receipt',
'permlevel': 0,
'search_index': 1,
'trigger': u'Client'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'delivery_note_no',
'fieldtype': u'Link',
'hidden': 0,
'in_filter': 1,
'label': u'Delivery Note No',
'oldfieldname': u'delivery_note_no',
'oldfieldtype': u'Link',
'options': u'Delivery Note',
'permlevel': 0,
'print_hide': 0,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'inspected_by',
'fieldtype': u'Data',
'label': u'Inspected By',
'oldfieldname': u'inspected_by',
'oldfieldtype': u'Data',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'remarks',
'fieldtype': u'Text',
'label': u'Remarks',
'no_copy': 1,
'oldfieldname': u'remarks',
'oldfieldtype': u'Text',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'verified_by',
'fieldtype': u'Data',
'label': u'Verified By',
'oldfieldname': u'verified_by',
'oldfieldtype': u'Data',
'permlevel': 0
},
# 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
},
# 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': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'specification_details',
'fieldtype': u'Section Break',
'label': u'Specification Details',
'oldfieldtype': u'Section Break',
'options': u'Simple',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'get_specification_details',
'fieldtype': u'Button',
'label': u'Get Specification Details',
'options': u'get_item_specification_details',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'qa_specification_details',
'fieldtype': u'Table',
'label': u'Quality Inspection Readings',
'oldfieldname': u'qa_specification_details',
'oldfieldtype': u'Table',
'options': u'Quality Inspection Reading',
'permlevel': 0
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,175 @@
# DocType, Quality Inspection Reading
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:35:52',
'docstatus': 0,
'modified': '2012-03-27 14:35:52',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'autoname': u'QASD/.#####',
'colour': u'White:FFF',
'doctype': 'DocType',
'istable': 1,
'module': u'Buying',
'name': '__common__',
'section_style': u'Tray',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 2
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Quality Inspection Reading',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# DocType, Quality Inspection Reading
{
'doctype': 'DocType',
'name': u'Quality Inspection Reading'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'specification',
'fieldtype': u'Data',
'label': u'Parameter',
'oldfieldname': u'specification',
'oldfieldtype': u'Data',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'value',
'fieldtype': u'Data',
'label': u'Acceptance Criteria',
'oldfieldname': u'value',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reading_1',
'fieldtype': u'Data',
'label': u'Reading 1',
'oldfieldname': u'reading_1',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reading_2',
'fieldtype': u'Data',
'label': u'Reading 2',
'oldfieldname': u'reading_2',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reading_3',
'fieldtype': u'Data',
'label': u'Reading 3',
'oldfieldname': u'reading_3',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reading_4',
'fieldtype': u'Data',
'label': u'Reading 4',
'oldfieldname': u'reading_4',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reading_5',
'fieldtype': u'Data',
'label': u'Reading 5',
'oldfieldname': u'reading_5',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reading_6',
'fieldtype': u'Data',
'label': u'Reading 6',
'oldfieldname': u'reading_6',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reading_7',
'fieldtype': u'Data',
'label': u'Reading 7',
'oldfieldname': u'reading_7',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reading_8',
'fieldtype': u'Data',
'label': u'Reading 8',
'oldfieldname': u'reading_8',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reading_9',
'fieldtype': u'Data',
'label': u'Reading 9',
'oldfieldname': u'reading_9',
'oldfieldtype': u'Data'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reading_10',
'fieldtype': u'Data',
'label': u'Reading 10',
'oldfieldname': u'reading_10',
'oldfieldtype': u'Data'
},
# DocField
{
'default': u'Accepted',
'doctype': u'DocField',
'fieldname': u'status',
'fieldtype': u'Select',
'label': u'Status',
'oldfieldname': u'status',
'oldfieldtype': u'Select',
'options': u'Accepted\nRejected'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,178 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// 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
// 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/>.
wn.require('erpnext/setup/doctype/contact_control/contact_control.js');
wn.require('erpnext/support/doctype/communication/communication.js');
cur_frm.cscript.onload = function(doc,dt,dn){
// history doctypes and scripts
cur_frm.history_dict = {
'Purchase Order' : 'cur_frm.cscript.make_po_list(this.body, this.doc)',
'Purchase Receipt' : 'cur_frm.cscript.make_pr_list(this.body, this.doc)',
'Purchase Invoice' : 'cur_frm.cscript.make_pi_list(this.body, this.doc)'
}
// make contact, history list body
//cur_frm.cscript.make_cl_body();
cur_frm.cscript.make_hl_body();
cur_frm.cscript.make_communication_body();
}
cur_frm.cscript.refresh = function(doc,dt,dn) {
if(sys_defaults.supp_master_name == 'Supplier Name')
hide_field('naming_series');
else
unhide_field('naming_series');
if(doc.__islocal){
hide_field(['address_html','contact_html']);
}
else{
unhide_field(['address_html','contact_html']);
// make lists
cur_frm.cscript.make_address(doc,dt,dn);
cur_frm.cscript.make_contact(doc,dt,dn);
cur_frm.cscript.render_communication_list(doc, cdt, cdn);
cur_frm.cscript.make_history(doc,dt,dn);
}
}
cur_frm.cscript.make_address = function() {
if(!cur_frm.address_list) {
cur_frm.address_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['address_html'].wrapper,
page_length: 2,
new_doctype: "Address",
get_query: function() {
return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where supplier='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_address desc"
},
as_dict: 1,
no_results_message: 'No addresses created',
render_row: cur_frm.cscript.render_address_row,
});
// note: render_address_row is defined in contact_control.js
}
cur_frm.address_list.run();
}
cur_frm.cscript.make_contact = function() {
if(!cur_frm.contact_list) {
cur_frm.contact_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['contact_html'].wrapper,
page_length: 2,
new_doctype: "Contact",
get_query: function() {
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where supplier='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc"
},
as_dict: 1,
no_results_message: 'No contacts created',
render_row: cur_frm.cscript.render_contact_row,
});
// note: render_contact_row is defined in contact_control.js
}
cur_frm.contact_list.run();
}
// Transaction History
cur_frm.cscript.make_po_list = function(parent, doc) {
var ListView = wn.views.ListView.extend({
init: function(doclistview) {
this._super(doclistview);
this.fields = this.fields.concat([
"`tabPurchase Order`.status",
"`tabPurchase Order`.currency",
"ifnull(`tabPurchase Order`.grand_total_import, 0) as grand_total_import",
]);
},
prepare_data: function(data) {
this._super(data);
data.grand_total_import = data.currency + " " + fmt_money(data.grand_total_import);
},
columns: [
{width: '3%', content: 'docstatus'},
{width: '20%', content: 'name'},
{width: '30%', content: 'status',
css: {'text-align': 'right', 'color': '#777'}},
{width: '35%', content: 'grand_total_import', css: {'text-align': 'right'}},
{width: '12%', content:'modified', css: {'text-align': 'right'}}
],
});
cur_frm.cscript.render_list(doc, 'Purchase Order', parent, ListView);
}
cur_frm.cscript.make_pr_list = function(parent, doc) {
var ListView = wn.views.ListView.extend({
init: function(doclistview) {
this._super(doclistview);
this.fields = this.fields.concat([
"`tabPurchase Receipt`.status",
"`tabPurchase Receipt`.currency",
"ifnull(`tabPurchase Receipt`.grand_total_import, 0) as grand_total_import",
"ifnull(`tabPurchase Receipt`.per_billed, 0) as per_billed",
]);
},
prepare_data: function(data) {
this._super(data);
data.grand_total_import = data.currency + " " + fmt_money(data.grand_total_import);
},
columns: [
{width: '3%', content: 'docstatus'},
{width: '20%', content: 'name'},
{width: '20%', content: 'status',
css: {'text-align': 'right', 'color': '#777'}},
{width: '35%', content: 'grand_total_import', css: {'text-align': 'right'}},
{width: '10%', content: 'per_billed', type: 'bar-graph', label: 'Billed'},
{width: '12%', content:'modified', css: {'text-align': 'right'}}
],
});
cur_frm.cscript.render_list(doc, 'Purchase Receipt', parent, ListView);
}
cur_frm.cscript.make_pi_list = function(parent, doc) {
var ListView = wn.views.ListView.extend({
init: function(doclistview) {
this._super(doclistview);
this.fields = this.fields.concat([
"`tabPurchase Invoice`.currency",
"ifnull(`tabPurchase Invoice`.grand_total_import, 0) as grand_total_import",
]);
},
prepare_data: function(data) {
this._super(data);
data.grand_total_import = data.currency + " " + fmt_money(data.grand_total_import);
},
columns: [
{width: '3%', content: 'docstatus'},
{width: '30%', content: 'name'},
{width: '55%', content: 'grand_total_import', css: {'text-align': 'right'}},
{width: '12%', content:'modified', css: {'text-align': 'right'}}
],
});
cur_frm.cscript.render_list(doc, 'Purchase Invoice', parent, ListView);
}

View File

@@ -0,0 +1,200 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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
# 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/>.
# Please edit this list and import only required elements
from __future__ import unicode_literals
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, getchildren, make_autoname
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 autoname(self):
#get default naming conventional from control panel
supp_master_name = get_defaults()['supp_master_name']
if supp_master_name == 'Supplier Name':
# filter out bad characters in name
#supp = self.doc.supplier_name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','')
supp = self.doc.supplier_name
cust = sql("select name from `tabCustomer` where name = '%s'" % (supp))
cust = cust and cust[0][0] or ''
if cust:
msgprint("You already have a Customer with same name")
raise Exception
self.doc.name = supp
else:
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
# ----------------------------------------
# update credit days and limit in account
# ----------------------------------------
def update_credit_days_limit(self):
sql("update tabAccount set credit_days = '%s' where name = '%s'" % (self.doc.credit_days, self.doc.name + " - " + self.get_company_abbr()))
def on_update(self):
if not self.doc.naming_series:
self.doc.naming_series = ''
# create address
addr_flds = [self.doc.address_line1, self.doc.address_line2, self.doc.city, self.doc.state, self.doc.country, self.doc.pincode]
address_line = "\n".join(filter(lambda x : (x!='' and x!=None),addr_flds))
set(self.doc,'address', address_line)
# create account head
self.create_account_head()
# update credit days and limit in account
self.update_credit_days_limit()
def check_state(self):
return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
# ACCOUNTS
# -------------------------------------------
def get_payables_group(self):
g = sql("select payables_group from tabCompany where name=%s", self.doc.company)
g = g and g[0][0] or ''
if not g:
msgprint("Update Company master, assign a default group for Payables")
raise Exception
return g
def add_account(self, ac, par, abbr):
arg = {'account_name':ac,'parent_account':par, 'group_or_ledger':'Group', 'company':self.doc.company,'account_type':'','tax_rate':'0'}
t = get_obj('GL Control').add_ac(cstr(arg))
msgprint("Created Group " + t)
def get_company_abbr(self):
return sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
def get_parent_account(self, abbr):
if (not self.doc.supplier_type):
msgprint("Supplier Type is mandatory")
raise Exception
if not sql("select name from tabAccount where name=%s and debit_or_credit = 'Credit' and ifnull(is_pl_account, 'No') = 'No'", (self.doc.supplier_type + " - " + abbr)):
# if not group created , create it
self.add_account(self.doc.supplier_type, self.get_payables_group(), abbr)
return self.doc.supplier_type + " - " + abbr
def validate(self):
#validation for Naming Series mandatory field...
if get_defaults()['supp_master_name'] == 'Naming Series':
if not self.doc.naming_series:
msgprint("Series is Mandatory.")
raise Exception
# create accont head - in tree under zone + territory
# -------------------------------------------------------
def create_account_head(self):
if self.doc.company :
abbr = self.get_company_abbr()
if not sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)):
parent_account = self.get_parent_account(abbr)
arg = {'account_name':self.doc.name,'parent_account': parent_account, 'group_or_ledger':'Ledger', 'company':self.doc.company,'account_type':'','tax_rate':'0','master_type':'Supplier','master_name':self.doc.name,'address':self.doc.address}
# create
ac = get_obj('GL Control').add_ac(cstr(arg))
msgprint("Created Account Head: "+ac)
else :
msgprint("Please select Company under which you want to create account head")
def get_contacts(self,nm):
if nm:
contact_details =convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm))
return contact_details
else:
return ''
def delete_supplier_address(self):
for rec in sql("select * from `tabAddress` where supplier='%s'" %(self.doc.name), as_dict=1):
sql("delete from `tabAddress` where name=%s",(rec['name']))
def delete_supplier_contact(self):
for rec in sql("select * from `tabContact` where supplier='%s'" %(self.doc.name), as_dict=1):
sql("delete from `tabContact` where name=%s",(rec['name']))
def delete_supplier_communication(self):
webnotes.conn.sql("""\
delete from `tabCommunication`
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):
self.delete_supplier_address()
self.delete_supplier_contact()
self.delete_supplier_communication()
self.delete_supplier_account()
# on rename
# ---------
def on_rename(self,newdn,olddn):
#update supplier_name if not naming series
if get_defaults().get('supp_master_name') == 'Supplier Name':
update_fields = [
('Supplier', 'name'),
('Address', 'supplier'),
('Contact', 'supplier'),
('Purchase Invoice', 'supplier'),
('Purchase Order', 'supplier'),
('Purchase Receipt', 'supplier'),
('Serial No', 'supplier')]
for rec in update_fields:
sql("update `tab%s` set supplier_name = '%s' where %s = '%s'" %(rec[0],newdn,rec[1],olddn))
#update master_name in doctype account
sql("update `tabAccount` set master_name = '%s', master_type = 'Supplier' where master_name = '%s'" %(newdn,olddn))

View File

@@ -0,0 +1,355 @@
# DocType, Supplier
[
# These values are common in all dictionaries
{
'creation': '2012-05-15 12:14:41',
'docstatus': 0,
'modified': '2012-07-18 17:41:49',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1306471021',
'allow_trash': 1,
'colour': u'White:FFF',
'doctype': 'DocType',
'document_type': u'Master',
'module': u'Buying',
'name': '__common__',
'search_fields': u'supplier_name,supplier_type',
'section_style': u'Tabbed',
'server_code_error': u' ',
'show_in_menu': 0,
'subject': u' ',
'tag_fields': u'supplier_type',
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Supplier',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Supplier',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1
},
# DocType, Supplier
{
'doctype': 'DocType',
'name': u'Supplier'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Purchase Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Purchase Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Purchase Master Manager'
},
# DocPerm
{
'amend': 0,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Purchase Master Manager',
'submit': 0,
'write': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts',
'doctype': u'DocField',
'fieldname': u'basic_info',
'fieldtype': u'Section Break',
'label': u'Basic Info',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'supplier_name',
'fieldtype': u'Data',
'label': u'Supplier Name',
'no_copy': 1,
'oldfieldname': u'supplier_name',
'oldfieldtype': u'Data',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'supplier_type',
'fieldtype': u'Link',
'label': u'Supplier Type',
'oldfieldname': u'supplier_type',
'oldfieldtype': u'Link',
'options': u'Supplier Type',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'naming_series',
'fieldtype': u'Select',
'label': u'Series',
'no_copy': 1,
'oldfieldname': u'naming_series',
'oldfieldtype': u'Select',
'options': u'\nSUPP\nSUPP/10-11/',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'address_contacts',
'fieldtype': u'Section Break',
'label': u'Address & Contacts',
'oldfieldtype': u'Column Break',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:doc.__islocal',
'doctype': u'DocField',
'fieldname': u'address_desc',
'fieldtype': u'HTML',
'label': u'Address Desc',
'options': u'<em>Addresses will appear only when you save the supplier</em>',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'address_html',
'fieldtype': u'HTML',
'label': u'Address HTML',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:doc.__islocal',
'doctype': u'DocField',
'fieldname': u'contact_desc',
'fieldtype': u'HTML',
'label': u'Contact Desc',
'options': u'<em>Contact Details will appear only when you save the supplier</em>',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'contact_html',
'fieldtype': u'HTML',
'label': u'Contact HTML',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'communication_history',
'fieldtype': u'Section Break',
'label': u'Communication History',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'communication_html',
'fieldtype': u'HTML',
'label': u'Communication HTML',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'more_info',
'fieldtype': u'Section Break',
'label': u'More Info',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'Enter the company name under which Account Head will be created for this Supplier',
'doctype': u'DocField',
'fieldname': u'company',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Company',
'oldfieldname': u'company',
'oldfieldtype': u'Link',
'options': u'Company',
'permlevel': 0,
'reqd': 1,
'search_index': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'This currency will get fetched in Purchase transactions of this supplier',
'doctype': u'DocField',
'fieldname': u'default_currency',
'fieldtype': u'Select',
'label': u'Default Currency',
'no_copy': 1,
'options': u'link:Currency',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'Statutory info and other general information about your Supplier',
'doctype': u'DocField',
'fieldname': u'supplier_details',
'fieldtype': u'Text',
'label': u'Supplier Details',
'oldfieldname': u'supplier_details',
'oldfieldtype': u'Code',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break2',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'credit_days',
'fieldtype': u'Int',
'label': u'Credit Days',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'website',
'fieldtype': u'Data',
'label': u'Website',
'oldfieldname': u'website',
'oldfieldtype': u'Data',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:!doc.__islocal',
'doctype': u'DocField',
'fieldname': u'transaction_history',
'fieldtype': u'Section Break',
'label': u'Transaction History',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:!doc.__islocal',
'doctype': u'DocField',
'fieldname': u'history_html',
'fieldtype': u'HTML',
'label': u'History HTML',
'oldfieldtype': u'HTML',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'trash_reason',
'fieldtype': u'Small Text',
'label': u'Trash Reason',
'oldfieldname': u'trash_reason',
'oldfieldtype': u'Small Text',
'permlevel': 1
}
]

View File

@@ -0,0 +1,27 @@
// render
wn.doclistviews['Supplier'] = wn.views.ListView.extend({
init: function(d) {
this._super(d)
this.fields = this.fields.concat([
"`tabSupplier`.supplier_type",
"`tabSupplier`.supplier_name",
]);
//this.stats = this.stats.concat(['company']);
},
prepare_data: function(data) {
this._super(data);
data.supplier_name = repl("<a href=\"#!Form/Supplier/%(name)s\">%(supplier_name)s</a>",
data);
},
columns: [
{width: '3%', content: 'check'},
{width: '5%', content:'avatar'},
{width: '50%', content:'supplier_name'},
{width: '10%', content:'tags'},
{width: '20%', content:'supplier_type', css: {'color': '#aaa'}},
{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
]
});

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,121 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// 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
// 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/>.
// define defaults for purchase common
cur_frm.cscript.tname = "Supplier Quotation Item";
cur_frm.cscript.fname = "quotation_items";
cur_frm.cscript.other_fname = "purchase_tax_details";
// attach required files
wn.require('erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js');
cur_frm.cscript.onload = function(doc, dt, dn) {
// set missing values in parent doc
set_missing_values(doc, {
fiscal_year: sys_defaults.fiscal_year,
conversion_rate: 1,
currency: sys_defaults.currency,
status: "Draft",
transaction_date: get_today(),
is_subcontracted: "No"
});
}
cur_frm.cscript.refresh = function(doc, dt, dn) {
erpnext.hide_naming_series();
cur_frm.cscript.dynamic_label(doc, dt, dn);
cur_frm.cscript.load_taxes(doc, dt, dn);
cur_frm.cscript.toggle_contact_section(doc);
cur_frm.clear_custom_buttons();
if (doc.docstatus === 1) {
cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order);
}
}
cur_frm.cscript.make_purchase_order = function() {
var new_po_name = createLocal("Purchase Order");
$c("dt_map", {
"docs": compress_doclist([locals['Purchase Order'][new_po_name]]),
"from_doctype": cur_frm.doc.doctype,
"to_doctype": "Purchase Order",
"from_docname": cur_frm.doc.name,
"from_to_list": JSON.stringify([['Supplier Quotation', 'Purchase Order'],
['Supplier Quotation Item', 'Purchase Order Item'],
['Purchase Taxes and Charges', 'Purchase Taxes and Charges']]),
}, function(r, rt) { loaddoc("Purchase Order", new_po_name) });
}
cur_frm.cscript.supplier = function(doc, dt, dn) {
if (doc.supplier) {
get_server_fields('get_default_supplier_address',
JSON.stringify({ supplier: doc.supplier }), '', doc, dt, dn, 1,
function() { cur_frm.refresh(); });
cur_frm.cscript.toggle_contact_section(doc);
}
}
cur_frm.cscript.uom = function(doc, cdt, cdn) {
// no need to trigger updation of stock uom, as this field doesn't exist in supplier quotation
}
cur_frm.fields_dict['quotation_items'].grid.get_field('project_name').get_query =
function(doc, cdt, cdn) {
return "select `tabProject`.name from `tabProject` \
where `tabProject`.status = \"Open\" and `tabProject`.name like \"%s\" \
order by `tabProject`.name ASC LIMIT 50";
}
cur_frm.fields_dict['indent_no'].get_query = function(doc) {
return "select distinct `tabPurchase Request`.`name` from `tabPurchase Request` \
where `tabPurchase Request`.company = \"" + doc.company +
"\" and `tabPurchase Request`.`docstatus` = 1 and \
`tabPurchase Request`.`status` != \"Stopped\" and \
ifnull(`tabPurchase Request`.`per_ordered`,0) < 100 and \
`tabPurchase Request`.%(key)s LIKE \"%s\" \
order by `tabPurchase Request`.`name` desc limit 50";
}
cur_frm.cscript.supplier_address = function(doc, dt, dn) {
if (doc.supplier) {
get_server_fields("get_supplier_address", JSON.stringify({supplier: doc.supplier,
address: doc.supplier_address, contact: doc.contact_person}), '', doc, dt, dn, 1);
}
}
cur_frm.cscript.contact_person = cur_frm.cscript.supplier_address;
cur_frm.fields_dict['supplier_address'].get_query = function(doc, cdt, cdn) {
return "SELECT name, address_line1, city FROM tabAddress WHERE supplier = \"" + doc.supplier
+ "\" AND docstatus != 2 AND name LIKE \"%s\" ORDER BY name ASC LIMIT 50";
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return "SELECT name, CONCAT(first_name, \" \", ifnull(last_name,\"\")) As FullName, \
department, designation FROM tabContact WHERE supplier = \"" + doc.supplier
+"\" AND docstatus != 2 AND name LIKE \"%s\" ORDER BY name ASC LIMIT 50";
}
cur_frm.fields_dict.supplier_address.on_new = function(dn) {
locals['Address'][dn].supplier = locals[cur_frm.doctype][cur_frm.docname].supplier;
locals['Address'][dn].supplier_name = locals[cur_frm.doctype][cur_frm.docname].supplier_name;
}
cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].supplier = locals[cur_frm.doctype][cur_frm.docname].supplier;
locals['Contact'][dn].supplier_name = locals[cur_frm.doctype][cur_frm.docname].supplier_name;
}

View File

@@ -0,0 +1,98 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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
# 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/>.
from __future__ import unicode_literals
import webnotes
from webnotes.model.code import get_obj
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
def __init__(self, doc, doclist=None):
self.doc, self.doclist = doc, doclist or []
self.tname, self.fname = "Supplier Quotation Item", "quotation_items"
def autoname(self):
"""autoname based on naming series value"""
from webnotes.model.doc import make_autoname
self.doc.name = make_autoname(self.doc.naming_series + ".#####")
def validate(self):
self.validate_fiscal_year()
self.validate_common()
self.set_in_words()
self.doc.status = "Draft"
def on_submit(self):
webnotes.conn.set(self.doc, "status", "Submitted")
def on_cancel(self):
webnotes.conn.set(self.doc, "status", "Cancelled")
def on_trash(self):
pass
def get_item_details(self, args=None):
if args:
return get_obj(dt='Purchase Common').get_item_details(self, args)
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]
def get_indent_details(self):
if self.doc.indent_no:
mapper = get_obj("DocType Mapper", "Purchase Request-Supplier Quotation")
mapper.dt_map("Purchase Request", "Supplier Quotation", self.doc.indent_no,
self.doc, self.doclist, """[['Purchase Request', 'Supplier Quotation'],
['Purchase Request Item', 'Supplier Quotation Item']]""")
from webnotes.model.doclist import getlist
for d in getlist(self.doclist, self.fname):
if d.item_code and not d.purchase_rate:
d.purchase_ref_rate = d.discount_rate = d.purchase_rate = 0.0
d.import_ref_rate = d.import_rate = 0.0
def load_default_taxes(self):
self.doclist = get_obj('Purchase Common').load_default_taxes(self)
def get_purchase_tax_details(self):
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
def validate_fiscal_year(self):
get_obj(dt = 'Purchase Common').validate_fiscal_year( \
self.doc.fiscal_year, self.doc.transaction_date, 'Quotation Date')
def validate_common(self):
pc = get_obj('Purchase Common')
pc.validate_mandatory(self)
pc.validate_for_items(self)
pc.validate_conversion_rate(self)
pc.get_prevdoc_date(self)
pc.validate_reference_value(self)
def set_in_words(self):
pc = get_obj('Purchase Common')
company_currency = TransactionBase().get_company_currency(self.doc.company)
self.doc.in_words = pc.get_total_in_words(company_currency, self.doc.grand_total)
self.doc.in_words_import = pc.get_total_in_words(self.doc.currency, self.doc.grand_total_import)

View File

@@ -0,0 +1,924 @@
# DocType, Supplier Quotation
[
# These values are common in all dictionaries
{
'creation': '2012-08-01 20:03:35',
'docstatus': 0,
'modified': '2012-08-02 18:04:35',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'allow_attach': 1,
'default_print_format': u'Standard',
'doctype': 'DocType',
'document_type': u'Transaction',
'is_submittable': 1,
'is_transaction_doc': 1,
'module': u'Buying',
'name': '__common__',
'read_only_onload': 1,
'search_fields': u'status, transaction_date, supplier,grand_total',
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Supplier Quotation',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Supplier Quotation',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1
},
# DocType, Supplier Quotation
{
'doctype': 'DocType',
'name': u'Supplier Quotation'
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Production Manager',
'submit': 1,
'write': 1
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Purchase Manager',
'submit': 1,
'write': 1
},
# DocPerm
{
'amend': 1,
'cancel': 0,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Purchase User',
'submit': 0,
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Material User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Supplier',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'All',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 2,
'role': u'All',
'submit': 0,
'write': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'basic_info',
'fieldtype': u'Section Break',
'label': u'Basic Info',
'oldfieldtype': u'Section Break',
'permlevel': 0,
'print_hide': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'description': u'To manage multiple series please go to Setup > Manage Series',
'doctype': u'DocField',
'fieldname': u'naming_series',
'fieldtype': u'Select',
'label': u'Series',
'no_copy': 1,
'oldfieldname': u'naming_series',
'oldfieldtype': u'Select',
'options': u'SQTN',
'permlevel': 0,
'print_hide': 1,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'Supplier (vendor) name as entered in supplier master',
'doctype': u'DocField',
'fieldname': u'supplier',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Supplier',
'oldfieldname': u'supplier',
'oldfieldtype': u'Link',
'options': u'Supplier',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'search_index': 1,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'supplier_name',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Name',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'address_display',
'fieldtype': u'Small Text',
'hidden': 1,
'label': u'Address',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'contact_display',
'fieldtype': u'Small Text',
'hidden': 1,
'label': u'Contact',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'contact_mobile',
'fieldtype': u'Text',
'hidden': 1,
'label': u'Mobile No',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'contact_email',
'fieldtype': u'Text',
'hidden': 1,
'label': u'Contact Email',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'print_hide': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'description': u'The date at which current entry is made in system.',
'doctype': u'DocField',
'fieldname': u'transaction_date',
'fieldtype': u'Date',
'in_filter': 1,
'label': u'Quotation Date',
'oldfieldname': u'transaction_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 1,
'search_index': 1,
'trigger': u'Client'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'items',
'fieldtype': u'Section Break',
'label': u'Items',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'allow_on_submit': 1,
'doctype': u'DocField',
'fieldname': u'quotation_items',
'fieldtype': u'Table',
'label': u'Quotation Items',
'no_copy': 0,
'oldfieldname': u'po_details',
'oldfieldtype': u'Table',
'options': u'Supplier Quotation Item',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break0',
'fieldtype': u'Section Break',
'options': u'Simple',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break2',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'net_total',
'fieldtype': u'Currency',
'label': u'Net Total*',
'no_copy': 1,
'oldfieldname': u'net_total',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1,
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'net_total_import',
'fieldtype': u'Currency',
'label': u'Net Total (Import)',
'no_copy': 0,
'oldfieldname': u'net_total_import',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'recalculate_values',
'fieldtype': u'Button',
'label': u'Re-Calculate Values',
'oldfieldtype': u'Button',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break3',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'description': u"Supplier's currency",
'doctype': u'DocField',
'fieldname': u'currency',
'fieldtype': u'Select',
'label': u'Currency',
'no_copy': 0,
'oldfieldname': u'currency',
'oldfieldtype': u'Select',
'options': u'link:Currency',
'permlevel': 0,
'print_hide': 1,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'default': u'1',
'description': u"Rate at which supplier's currency is converted to company's base currency",
'doctype': u'DocField',
'fieldname': u'conversion_rate',
'fieldtype': u'Currency',
'hidden': 0,
'label': u'Conversion Rate',
'no_copy': 1,
'oldfieldname': u'conversion_rate',
'oldfieldtype': u'Currency',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'trigger': u'Client'
},
# DocField
{
'colour': u'White:FFF',
'description': u'You can make a purchase order from multiple Purchase Requests. Select Purchase Requests one by one and click on the button below.',
'doctype': u'DocField',
'fieldname': u'indent_no',
'fieldtype': u'Link',
'hidden': 0,
'label': u'Select Purchase Request',
'no_copy': 1,
'oldfieldname': u'indent_no',
'oldfieldtype': u'Link',
'options': u'Purchase Request',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'get_items',
'fieldtype': u'Button',
'hidden': 0,
'label': u'Get Items',
'oldfieldtype': u'Button',
'options': u'get_indent_details',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'taxes',
'fieldtype': u'Section Break',
'label': u'Taxes',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.',
'doctype': u'DocField',
'fieldname': u'purchase_other_charges',
'fieldtype': u'Link',
'label': u'Purchase Taxes and Charges',
'no_copy': 1,
'oldfieldname': u'purchase_other_charges',
'oldfieldtype': u'Link',
'options': u'Purchase Taxes and Charges Master',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'get_tax_detail',
'fieldtype': u'Button',
'label': u'Get Tax Detail',
'oldfieldtype': u'Button',
'options': u'get_purchase_tax_details',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'purchase_tax_details',
'fieldtype': u'Table',
'label': u'Purchase Taxes and Charges',
'no_copy': 0,
'oldfieldname': u'purchase_tax_details',
'oldfieldtype': u'Table',
'options': u'Purchase Taxes and Charges',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'calculate_tax',
'fieldtype': u'Button',
'label': u'Calculate Tax',
'oldfieldtype': u'Button',
'permlevel': 0,
'print_hide': 1,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'tax_calculation',
'fieldtype': u'HTML',
'label': u'Tax Calculation',
'no_copy': 1,
'oldfieldtype': u'HTML',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'total_tax',
'fieldtype': u'Currency',
'label': u'Total Tax*',
'no_copy': 1,
'oldfieldname': u'total_tax',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'totals',
'fieldtype': u'Section Break',
'label': u'Totals',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'grand_total',
'fieldtype': u'Currency',
'label': u'Grand Total',
'no_copy': 1,
'oldfieldname': u'grand_total',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'rounded_total',
'fieldtype': u'Currency',
'label': u'Rounded Total',
'oldfieldname': u'rounded_total',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'In Words will be visible once you save the Purchase Order.',
'doctype': u'DocField',
'fieldname': u'in_words',
'fieldtype': u'Data',
'label': u'In Words',
'oldfieldname': u'in_words',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'other_charges_added',
'fieldtype': u'Currency',
'label': u'Taxes and Charges Added',
'no_copy': 0,
'oldfieldname': u'other_charges_added',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'other_charges_deducted',
'fieldtype': u'Currency',
'label': u'Taxes and Charges Deducted',
'no_copy': 0,
'oldfieldname': u'other_charges_deducted',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break4',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'print_hide': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'grand_total_import',
'fieldtype': u'Currency',
'label': u'Grand Total (Import)',
'no_copy': 0,
'oldfieldname': u'grand_total_import',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1,
'report_hide': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'in_words_import',
'fieldtype': u'Data',
'label': u'In Words(Import)',
'oldfieldname': u'in_words_import',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'other_charges_added_import',
'fieldtype': u'Currency',
'label': u'Taxes and Charges Added (Import)',
'no_copy': 0,
'oldfieldname': u'other_charges_added_import',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1,
'report_hide': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'other_charges_deducted_import',
'fieldtype': u'Currency',
'label': u'Taxes and Charges Deducted (Import)',
'no_copy': 0,
'oldfieldname': u'other_charges_deducted_import',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1,
'report_hide': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'terms_section_break',
'fieldtype': u'Section Break',
'label': u'Terms and Conditions',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'allow_on_submit': 1,
'doctype': u'DocField',
'fieldname': u'letter_head',
'fieldtype': u'Select',
'label': u'Letter Head',
'oldfieldname': u'letter_head',
'oldfieldtype': u'Select',
'options': u'link:Letter Head',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'tc_name',
'fieldtype': u'Link',
'label': u'Select Terms and Conditions',
'oldfieldname': u'tc_name',
'oldfieldtype': u'Link',
'options': u'Terms and Conditions',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'get_terms',
'fieldtype': u'Button',
'label': u'Get Terms and Conditions',
'oldfieldtype': u'Button',
'options': u'get_tc_details',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'terms_html',
'fieldtype': u'HTML',
'label': u'Terms and Conditions HTML',
'oldfieldtype': u'HTML',
'options': u'You can add Terms and Notes that will be printed in the Transaction',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'terms',
'fieldtype': u'Text Editor',
'label': u'Terms and Conditions1',
'oldfieldname': u'terms',
'oldfieldtype': u'Text Editor',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'contact_section',
'fieldtype': u'Section Break',
'label': u'Contact Info',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'supplier_address',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Supplier Address',
'options': u'Address',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'contact_person',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Contact Person',
'options': u'Contact',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'more_info',
'fieldtype': u'Section Break',
'label': u'More Info',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'status',
'fieldtype': u'Select',
'in_filter': 1,
'label': u'Status',
'no_copy': 1,
'oldfieldname': u'status',
'oldfieldtype': u'Select',
'options': u'\nDraft\nSubmitted\nStopped\nCancelled',
'permlevel': 1,
'print_hide': 1,
'reqd': 1,
'search_index': 1
},
# DocField
{
'default': u'No',
'doctype': u'DocField',
'fieldname': u'is_subcontracted',
'fieldtype': u'Select',
'label': u'Is Subcontracted',
'options': u'\nYes\nNo',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amended_from',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Amended From',
'no_copy': 1,
'oldfieldname': u'amended_from',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1,
'report_hide': 0
},
# DocField
{
'description': u'The date at which current entry is corrected in the system.',
'doctype': u'DocField',
'fieldname': u'amendment_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Amendment Date',
'no_copy': 1,
'oldfieldname': u'amendment_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u'Select the relevant company name if you have multiple companies',
'doctype': u'DocField',
'fieldname': u'company',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Company',
'no_copy': 0,
'oldfieldname': u'company',
'oldfieldtype': u'Link',
'options': u'Company',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'fiscal_year',
'fieldtype': u'Select',
'in_filter': 1,
'label': u'Fiscal Year',
'no_copy': 0,
'oldfieldname': u'fiscal_year',
'oldfieldtype': u'Select',
'options': u'link:Fiscal Year',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'search_index': 1
},
# DocField
{
'allow_on_submit': 1,
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'select_print_heading',
'fieldtype': u'Link',
'label': u'Select Print Heading',
'no_copy': 1,
'oldfieldname': u'select_print_heading',
'oldfieldtype': u'Link',
'options': u'Print Heading',
'permlevel': 0,
'print_hide': 1,
'report_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break5',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'print_hide': 1,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:!doc.__islocal',
'doctype': u'DocField',
'fieldname': u'cancel_reason',
'fieldtype': u'Data',
'hidden': 0,
'label': u'Cancel Reason',
'no_copy': 1,
'oldfieldname': u'cancel_reason',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'file_list',
'fieldtype': u'Text',
'hidden': 1,
'label': u'File List',
'no_copy': 1,
'permlevel': 0,
'print_hide': 1
}
]

View File

@@ -0,0 +1,33 @@
// render
wn.doclistviews['Supplier Quotation'] = wn.views.ListView.extend({
init: function(d) {
this._super(d)
this.fields = this.fields.concat([
"`tabSupplier Quotation`.supplier_name",
"`tabSupplier Quotation`.currency",
"ifnull(`tabSupplier Quotation`.grand_total_import,0) as grand_total_import",
"`tabSupplier Quotation`.transaction_date",
]);
this.stats = this.stats.concat(['status', 'company']);
},
columns: [
{width: '3%', content: 'check'},
{width: '5%', content:'avatar'},
{width: '3%', content:'docstatus'},
{width: '15%', content:'name'},
{width: '44%', content:'supplier_name+tags', css: {color:'#222'}},
{
width: '18%',
content: function(parent, data) {
$(parent).html(data.currency + ' ' + fmt_money(data.grand_total_import))
},
css: {'text-align':'right'}
},
{width: '12%', content:'transaction_date',
css: {'text-align': 'right', 'color':'#777'},
title: "Supplier Quotation Date", type: "date"}
]
});

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,370 @@
# DocType, Supplier Quotation Item
[
# These values are common in all dictionaries
{
'creation': '2012-08-01 20:07:22',
'docstatus': 0,
'modified': '2012-08-03 12:34:33',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'autoname': u'SQI-.#####',
'default_print_format': u'Standard',
'doctype': 'DocType',
'istable': 1,
'module': u'Buying',
'name': '__common__',
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Supplier Quotation Item',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# DocType, Supplier Quotation Item
{
'doctype': 'DocType',
'name': u'Supplier Quotation Item'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'item_code',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Item Code',
'oldfieldname': u'item_code',
'oldfieldtype': u'Link',
'options': u'Item',
'permlevel': 0,
'print_hide': 0,
'reqd': 1,
'search_index': 1,
'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
{
'doctype': u'DocField',
'fieldname': u'item_name',
'fieldtype': u'Data',
'hidden': 0,
'in_filter': 1,
'label': u'Item Name',
'oldfieldname': u'item_name',
'oldfieldtype': u'Data',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Small Text',
'label': u'Description',
'oldfieldname': u'description',
'oldfieldtype': u'Small Text',
'permlevel': 0,
'reqd': 1,
'width': u'300px'
},
# DocField
{
'default': u'0.00',
'doctype': u'DocField',
'fieldname': u'qty',
'fieldtype': u'Currency',
'label': u'Quantity',
'oldfieldname': u'qty',
'oldfieldtype': u'Currency',
'permlevel': 0,
'reqd': 1,
'trigger': u'Client',
'width': u'60px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'import_ref_rate',
'fieldtype': u'Currency',
'label': u'Ref Rate ',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'discount_rate',
'fieldtype': u'Currency',
'label': u'Discount %',
'permlevel': 0,
'print_hide': 1,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'import_rate',
'fieldtype': u'Currency',
'hidden': 0,
'label': u'Rate ',
'oldfieldname': u'import_rate',
'oldfieldtype': u'Currency',
'permlevel': 0,
'print_hide': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'import_amount',
'fieldtype': u'Currency',
'label': u'Amount',
'oldfieldname': u'import_amount',
'oldfieldtype': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'purchase_ref_rate',
'fieldtype': u'Currency',
'label': u'Ref Rate *',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'default': u'0.00',
'doctype': u'DocField',
'fieldname': u'purchase_rate',
'fieldtype': u'Currency',
'label': u'Rate (Default Curr.) *',
'oldfieldname': u'purchase_rate',
'oldfieldtype': u'Currency',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'trigger': u'Client',
'width': u'100px'
},
# DocField
{
'default': u'0.00',
'doctype': u'DocField',
'fieldname': u'amount',
'fieldtype': u'Currency',
'label': u'Amount (Default Curr.)',
'oldfieldname': u'amount',
'oldfieldtype': u'Currency',
'permlevel': 1,
'print_hide': 1,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'warehouse',
'fieldtype': u'Link',
'hidden': 0,
'label': u'Warehouse',
'oldfieldname': u'warehouse',
'oldfieldtype': u'Link',
'options': u'Warehouse',
'permlevel': 0,
'print_hide': 1,
'reqd': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'project_name',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Project Name',
'options': u'Project',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'uom',
'fieldtype': u'Link',
'label': u'UOM',
'oldfieldname': u'uom',
'oldfieldtype': u'Link',
'options': u'UOM',
'permlevel': 0,
'print_hide': 0,
'reqd': 1,
'trigger': u'Client',
'width': u'100px'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'prevdoc_doctype',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Prevdoc DocType',
'no_copy': 0,
'oldfieldname': u'prevdoc_doctype',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'prevdoc_docname',
'fieldtype': u'Link',
'hidden': 0,
'in_filter': 1,
'label': u'Purchase Request No',
'no_copy': 0,
'oldfieldname': u'prevdoc_docname',
'oldfieldtype': u'Link',
'options': u'Purchase Request',
'permlevel': 1,
'print_hide': 1,
'search_index': 1,
'width': u'120px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'prevdoc_date',
'fieldtype': u'Date',
'hidden': 1,
'in_filter': 1,
'label': u'Purchase Request Date',
'oldfieldname': u'prevdoc_date',
'oldfieldtype': u'Date',
'permlevel': 1,
'print_hide': 1,
'search_index': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'prevdoc_detail_docname',
'fieldtype': u'Data',
'hidden': 1,
'in_filter': 1,
'label': u'Purchase Request Detail No',
'no_copy': 0,
'oldfieldname': u'prevdoc_detail_docname',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'brand',
'fieldtype': u'Link',
'hidden': 1,
'label': u'Brand',
'oldfieldname': u'brand',
'oldfieldtype': u'Link',
'options': u'Brand',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'item_group',
'fieldtype': u'Link',
'hidden': 1,
'in_filter': 1,
'label': u'Item Group',
'oldfieldname': u'item_group',
'oldfieldtype': u'Link',
'options': u'Item Group',
'permlevel': 1,
'print_hide': 1,
'search_index': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges',
'doctype': u'DocField',
'fieldname': u'item_tax_rate',
'fieldtype': u'Small Text',
'hidden': 1,
'label': u'Item Tax Rate',
'oldfieldname': u'item_tax_rate',
'oldfieldtype': u'Small Text',
'permlevel': 1,
'print_hide': 1,
'report_hide': 1
},
# DocField
{
'allow_on_submit': 1,
'doctype': u'DocField',
'fieldname': u'page_break',
'fieldtype': u'Check',
'hidden': 0,
'label': u'Page Break',
'no_copy': 1,
'oldfieldname': u'page_break',
'oldfieldtype': u'Check',
'permlevel': 0,
'print_hide': 1
}
]