Skip to content

Commit

Permalink
supplier quotation, project shift patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Anand Doshi committed Aug 2, 2012
1 parent dc40385 commit a67a74f
Show file tree
Hide file tree
Showing 17 changed files with 1,715 additions and 105 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ patch.log
lib
conf.py
version.num
public/*.html
!public/blank.html
!public/unsupported.html
!public/app.html
public/js/lib
public/images/lib
public/files
public/backups
public/css/wn-web.css
public/js/wn-web.js
backups
files
logs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# DocType Mapper, Purchase Request-Supplier Quotation
[

# These values are common in all dictionaries
{
'creation': '2012-08-02 18:36:26',
'docstatus': 0,
'modified': '2012-08-02 18:37:32',
'modified_by': u'Administrator',
'owner': u'Administrator'
},

# These values are common for all Table Mapper Detail
{
'doctype': u'Table Mapper Detail',
'name': '__common__',
'parent': u'Purchase Request-Supplier Quotation',
'parentfield': u'table_mapper_details',
'parenttype': u'DocType Mapper'
},

# These values are common for all Field Mapper Detail
{
'doctype': u'Field Mapper Detail',
'name': '__common__',
'parent': u'Purchase Request-Supplier Quotation',
'parentfield': u'field_mapper_details',
'parenttype': u'DocType Mapper'
},

# These values are common for all DocType Mapper
{
'doctype': u'DocType Mapper',
'from_doctype': u'Purchase Request',
'module': u'Buying',
'name': '__common__',
'ref_doc_submitted': 1,
'to_doctype': u'Supplier Quotation'
},

# DocType Mapper, Purchase Request-Supplier Quotation
{
'doctype': u'DocType Mapper',
'name': u'Purchase Request-Supplier Quotation'
},

# Field Mapper Detail
{
'checking_operator': u'=',
'doctype': u'Field Mapper Detail',
'from_field': u'company',
'map': u'Yes',
'match_id': 0,
'to_field': u'company'
},

# Field Mapper Detail
{
'doctype': u'Field Mapper Detail',
'from_field': u'parenttype',
'map': u'Yes',
'match_id': 1,
'to_field': u'prevdoc_doctype'
},

# Field Mapper Detail
{
'doctype': u'Field Mapper Detail',
'from_field': u'parent',
'map': u'Yes',
'match_id': 1,
'to_field': u'prevdoc_docname'
},

# Field Mapper Detail
{
'doctype': u'Field Mapper Detail',
'from_field': u'name',
'map': u'Yes',
'match_id': 1,
'to_field': u'prevdoc_detail_docname'
},

# Field Mapper Detail
{
'doctype': u'Field Mapper Detail',
'from_field': u'uom',
'map': u'Yes',
'match_id': 1,
'to_field': u'stock_uom'
},

# Field Mapper Detail
{
'checking_operator': u'>=',
'doctype': u'Field Mapper Detail',
'from_field': u'transaction_date',
'map': u'No',
'match_id': 0,
'to_field': u'transaction_date'
},

# Table Mapper Detail
{
'doctype': u'Table Mapper Detail',
'from_table': u'Purchase Request',
'match_id': 0,
'reference_key': u'prevdoc_docname',
'to_table': u'Supplier Quotation',
'validation_logic': u'docstatus = 1'
},

# Table Mapper Detail
{
'doctype': u'Table Mapper Detail',
'from_field': u'indent_details',
'from_table': u'Purchase Request Item',
'match_id': 1,
'reference_doctype_key': u'prevdoc_doctype',
'to_field': u'quotation_details',
'to_table': u'Supplier Quotation Item',
'validation_logic': u'docstatus =1'
}
]
34 changes: 14 additions & 20 deletions erpnext/buying/doctype/purchase_common/purchase_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,21 @@ var set_dynamic_label_child = function(doc, cdt, cdn, base_curr) {
//------------------------------------------------------------------

cur_frm.cscript.dynamic_label = function(doc, cdt, cdn, callback1) {
var callback = function(r, rt) {
if (r.message) base_curr = r.message;
else base_curr = sys_defaults['currency'];

if (base_curr == doc.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_curr);
set_dynamic_label_child(doc, cdt, cdn, base_curr);

if(callback1) callback1(doc, cdt, cdn);
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']);
}

if (doc.company == sys_defaults['company']) callback('', '');
else wn.call({
method: 'selling.doctype.sales_common.sales_common.get_comp_base_currency',
args: {company: doc.company},
callback: callback
});

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) {
Expand Down
2 changes: 1 addition & 1 deletion erpnext/buying/doctype/purchase_common/purchase_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def update_prevdoc_detail(self, obj, is_submit):
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):
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)
Expand Down
39 changes: 3 additions & 36 deletions erpnext/buying/doctype/purchase_order/purchase_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ 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');

//========================== On Load =================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {

if(!doc.fiscal_year && doc.__islocal){ //set_default_values(doc);
Expand All @@ -37,22 +36,14 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
}

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.dynamic_label(doc, dt, dn, callback);
if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
}

// ================================== Refresh ==========================================
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
// Show buttons
// ---------------------------------
cur_frm.clear_custom_buttons();
erpnext.hide_naming_series();

if (!cur_frm.cscript.is_onload) cur_frm.cscript.dynamic_label(doc, cdt, cdn);
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']);
Expand All @@ -68,7 +59,6 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
else $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(false);
}

//Supplier
cur_frm.cscript.supplier = function(doc,dt,dn) {
if (doc.supplier) {
get_server_fields('get_default_supplier_address',
Expand Down Expand Up @@ -102,33 +92,14 @@ cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].supplier_name = locals[cur_frm.doctype][cur_frm.docname].supplier_name;
}





//================ create new contact ============================================================================
cur_frm.cscript.new_contact = function(){
tn = createLocal('Contact');
locals['Contact'][tn].is_supplier = 1;
if(doc.supplier) locals['Contact'][tn].supplier = doc.supplier;
loaddoc('Contact', tn);
}

//======================= transaction date =============================
cur_frm.cscript.transaction_date = function(doc,cdt,cdn){
if(doc.__islocal){
cur_frm.cscript.get_default_schedule_date(doc);
}
if(doc.__islocal){ cur_frm.cscript.get_default_schedule_date(doc); }
}


// ---------------------- Get project name --------------------------
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';
}

//==================== Purchase Request No Get Query =======================================================
//===== Only those Purchase Requests status != 'Completed' and docstatus = 1 i.e. submitted=================
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';
}
Expand Down Expand Up @@ -203,10 +174,6 @@ cur_frm.cscript['Unstop Purchase Order'] = function() {
}
}

// ***************** Get Print Heading *****************
cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) {
return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
}
//****************** For print sales order no and date*************************
cur_frm.pformat.indent_no = function(doc, cdt, cdn){
//function to make row of table
Expand Down
22 changes: 3 additions & 19 deletions erpnext/buying/doctype/purchase_order/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def get_bin_details(self, arg = ''):

# Pull Purchase Request
def get_indent_details(self):
#self.validate_prev_docname()
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')
Expand All @@ -101,26 +100,13 @@ def get_indent_details(self):
else:
d.purchase_ref_rate = d.discount_rate = d.purchase_rate = d.import_ref_rate = d.import_rate = 0.0

# GET TERMS & CONDITIONS
# =====================================================================================
def get_tc_details(self):
"""get terms & conditions"""
return get_obj('Purchase Common').get_tc_details(self)



# validate if indent has been pulled twice
def validate_prev_docname(self):
for d in getlist(self.doclist, 'po_details'):
if d.prevdoc_docname and self.doc.indent_no == d.prevdoc_docname:
msgprint(cstr(self.doc.indent_no) + " indent details have already been pulled. ")
raise Exception

# get last purchase rate
def get_last_purchase_rate(self):
get_obj('Purchase Common').get_last_purchase_rate(self)

# validation
#-------------------------------------------------------------------------------------------------------------
def validate_doc(self,pc_obj):
# Validate values with reference document
pc_obj.validate_reference_value(obj = self)
Expand Down Expand Up @@ -233,16 +219,14 @@ def on_submit(self):
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 = sql("update `tabSupplier` set last_purchase_order = '%s' where name = '%s'" % (self.doc.name, self.doc.supplier))
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')

self.doc.indent_no = '';


# On Cancel
# -------------------------------------------------------------------------------------------------------
Expand Down
21 changes: 2 additions & 19 deletions erpnext/buying/doctype/purchase_order/purchase_order.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

# These values are common in all dictionaries
{
'creation': '2012-05-11 12:00:15',
'creation': '2012-07-02 14:44:19',
'docstatus': 0,
'modified': '2012-05-11 16:59:10',
'modified': '2012-08-02 13:43:50',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
Expand Down Expand Up @@ -962,23 +962,6 @@
'width': u'50%'
},

# DocField
{
'colour': u'White:FFF',
'description': u'Track this Purchase Order against any Project',
'doctype': u'DocField',
'fieldname': u'project_name',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Project Name',
'oldfieldname': u'project_name',
'oldfieldtype': u'Link',
'options': u'Project',
'permlevel': 0,
'search_index': 1,
'trigger': u'Client'
},

# DocField
{
'colour': u'White:FFF',
Expand Down
Empty file.
Loading

0 comments on commit a67a74f

Please sign in to comment.