From f8f0c0d08961f191e86873bbf5e0c09182d608a3 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 17 Jan 2013 20:20:56 +0530 Subject: [PATCH] updates in purchase cycle's price list --- .../purchase_invoice/purchase_invoice.js | 49 +- .../purchase_invoice/purchase_invoice.txt | 792 +++++++++--------- .../purchase_common/purchase_common.js | 252 ++++-- .../purchase_common/purchase_common.py | 22 - .../doctype/purchase_order/purchase_order.js | 57 +- .../doctype/purchase_order/purchase_order.txt | 58 +- .../purchase_request/purchase_request.js | 45 +- .../supplier_quotation/supplier_quotation.js | 31 +- .../supplier_quotation/supplier_quotation.txt | 340 ++++---- buying/utils.py | 2 +- controllers/buying_controller.py | 30 +- patches/january_2013/purchase_price_list.py | 7 + setup/utils.py | 23 +- stock/doctype/item/item.txt | 106 +-- stock/doctype/item_price/item_price.txt | 47 +- .../purchase_receipt/purchase_receipt.js | 44 +- .../purchase_receipt/purchase_receipt.txt | 340 ++++---- 17 files changed, 1190 insertions(+), 1055 deletions(-) create mode 100644 patches/january_2013/purchase_price_list.py diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js index 834cfbd569..5335249ea8 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -20,6 +20,28 @@ cur_frm.cscript.other_fname = "purchase_tax_details"; wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js'); wn.require('app/buying/doctype/purchase_common/purchase_common.js'); +erpnext.buying.PurchaseInvoiceController = erpnext.buying.BuyingController.extend({ + refresh: function(doc) { + this._super(); + + // Show / Hide button + if(doc.docstatus==1 && doc.outstanding_amount > 0) + cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher); + + if(doc.docstatus==1) { + cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry); + } + + cur_frm.cscript.is_opening(doc); + } +}); + +var new_cscript = new erpnext.buying.PurchaseInvoiceController({frm: cur_frm}); + +// for backward compatibility: combine new and previous states +$.extend(cur_frm.cscript, new_cscript); + + cur_frm.cscript.onload = function(doc,dt,dn) { if(!doc.voucher_date) set_multiple(dt,dn,{voucher_date:get_today()}); if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()}); @@ -27,35 +49,14 @@ cur_frm.cscript.onload = function(doc,dt,dn) { cur_frm.cscript.onload_post_render = function(doc, dt, dn) { var callback = function(doc, dt, dn) { - var callback1 = function(doc, dt, dn) { - if(doc.__islocal && doc.supplier) cur_frm.cscript.supplier(doc,dt,dn); - } - - // defined in purchase_common.js - cur_frm.cscript.update_item_details(doc, dt, dn, callback1); + if(doc.__islocal && doc.supplier) cur_frm.cscript.supplier(doc,dt,dn); } - cur_frm.cscript.dynamic_label(doc, dt, dn, callback); -} -cur_frm.cscript.refresh = function(doc, dt, dn) { + // defined in purchase_common.js + cur_frm.cscript.update_item_details(doc, dt, dn, callback); - cur_frm.clear_custom_buttons(); - erpnext.hide_naming_series(); - - if (!cur_frm.cscript.is_onload) cur_frm.cscript.dynamic_label(doc, dt, dn); - - - // Show / Hide button - if(doc.docstatus==1 && doc.outstanding_amount > 0) - cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher); - - if(doc.docstatus==1) { - cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry); - } - cur_frm.cscript.is_opening(doc, dt, dn); } - cur_frm.cscript.supplier = function(doc,dt,dn) { var callback = function(r,rt) { var doc = locals[cur_frm.doctype][cur_frm.docname]; diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.txt b/accounts/doctype/purchase_invoice/purchase_invoice.txt index 988dd5f20e..1b1dab21b1 100755 --- a/accounts/doctype/purchase_invoice/purchase_invoice.txt +++ b/accounts/doctype/purchase_invoice/purchase_invoice.txt @@ -2,14 +2,14 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-12-03 17:26:39", + "creation": "2013-01-15 18:42:58", "modified_by": "Administrator", - "modified": "2012-12-04 17:15:28" + "modified": "2013-01-17 20:11:05" }, { - "is_submittable": 1, "autoname": "naming_series:", "allow_attach": 1, + "is_submittable": 1, "search_fields": "posting_date, credit_to, fiscal_year, bill_no, grand_total, outstanding_amount", "module": "Accounts", "doctype": "DocType", @@ -29,6 +29,7 @@ "read": 1, "doctype": "DocPerm", "parenttype": "DocType", + "report": 1, "parentfield": "permissions" }, { @@ -48,7 +49,6 @@ "description": "To manage multiple series please go to Setup > Manage Series", "no_copy": 1, "oldfieldtype": "Select", - "colour": "White:FFF", "doctype": "DocField", "label": "Series", "oldfieldname": "naming_series", @@ -67,7 +67,6 @@ "label": "Credit To", "oldfieldname": "credit_to", "permlevel": 0, - "trigger": "Client", "fieldname": "credit_to", "fieldtype": "Link", "search_index": 1, @@ -196,35 +195,83 @@ "permlevel": 0 }, { - "print_hide": 1, - "description": "Will be calculated automatically when you enter the details", - "oldfieldtype": "Currency", + "oldfieldtype": "Button", "doctype": "DocField", - "label": "Net Total", - "oldfieldname": "net_total", - "fieldname": "net_total", - "fieldtype": "Currency", - "permlevel": 1 + "label": "Recalculate", + "fieldname": "recalculate", + "fieldtype": "Button", + "permlevel": 0 + }, + { + "doctype": "DocField", + "options": "Simple", + "fieldname": "section_break_17", + "fieldtype": "Section Break", + "permlevel": 0 }, { "print_hide": 1, - "oldfieldtype": "Currency", + "description": "Select Items from Purchase Order", + "oldfieldtype": "Link", "doctype": "DocField", - "label": "Net Total (Import)", - "oldfieldname": "net_total_import", - "fieldname": "net_total_import", - "fieldtype": "Currency", - "permlevel": 1 + "label": "Purchase Order", + "oldfieldname": "purchase_order_main", + "options": "Purchase Order", + "fieldname": "purchase_order_main", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "print_hide": 1, + "description": "Select Items from Purchase Receipt", + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Purchase Receipt", + "oldfieldname": "purchase_receipt_main", + "options": "Purchase Receipt", + "fieldname": "purchase_receipt_main", + "fieldtype": "Link", + "permlevel": 0 }, { "oldfieldtype": "Button", "doctype": "DocField", - "label": "Recalculate", - "trigger": "Client", - "fieldname": "recalculate", + "label": "Get Items", + "options": "pull_details", + "fieldname": "get_items", "fieldtype": "Button", "permlevel": 0 }, + { + "doctype": "DocField", + "label": "Currency & Price List", + "fieldname": "currency_price_list", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "print_hide": 1, + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Currency", + "oldfieldname": "currency", + "options": "link:Currency", + "fieldname": "currency", + "fieldtype": "Select", + "permlevel": 0 + }, + { + "print_hide": 1, + "description": "The rate at which Bill Currency is converted into company's base currency", + "default": "1", + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Exchange Rate", + "oldfieldname": "conversion_rate", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "permlevel": 0 + }, { "doctype": "DocField", "fieldname": "column_break2", @@ -232,71 +279,31 @@ "permlevel": 0 }, { - "print_hide": 1, - "description": "The rate at which Bill Currency is converted into company's base currency", - "default": "1", - "oldfieldtype": "Currency", - "colour": "White:FFF", "doctype": "DocField", - "label": "Bill Conversion Rate", - "oldfieldname": "conversion_rate", - "fieldname": "conversion_rate", + "label": "Price List", + "options": "Price List", + "fieldname": "price_list_name", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Price List Currency", + "options": "Currency", + "fieldname": "price_list_currency", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Price List Exchange Rate", + "fieldname": "plc_conversion_rate", "fieldtype": "Float", "permlevel": 0 }, - { - "print_hide": 1, - "oldfieldtype": "Select", - "doctype": "DocField", - "label": "Bill Currency", - "oldfieldname": "currency", - "options": "link:Currency", - "fieldname": "currency", - "fieldtype": "Select", - "permlevel": 0 - }, - { - "print_hide": 1, - "description": "Select Items from Purchase Order", - "oldfieldtype": "Link", - "colour": "White:FFF", - "doctype": "DocField", - "label": "Purchase Order", - "oldfieldname": "purchase_order_main", - "permlevel": 0, - "trigger": "Client", - "fieldname": "purchase_order_main", - "fieldtype": "Link", - "options": "Purchase Order" - }, - { - "print_hide": 1, - "description": "Select Items from Purchase Receipt", - "oldfieldtype": "Link", - "colour": "White:FFF", - "doctype": "DocField", - "label": "Purchase Receipt", - "oldfieldname": "purchase_receipt_main", - "permlevel": 0, - "trigger": "Client", - "fieldname": "purchase_receipt_main", - "fieldtype": "Link", - "options": "Purchase Receipt" - }, - { - "oldfieldtype": "Button", - "colour": "White:FFF", - "doctype": "DocField", - "label": "Get Items", - "options": "pull_details", - "fieldname": "get_items", - "fieldtype": "Button", - "permlevel": 0 - }, { "description": "Add / Edit Taxes and Charges", "oldfieldtype": "Section Break", - "colour": "White:FFF", "doctype": "DocField", "label": "Taxes", "fieldname": "taxes", @@ -339,7 +346,6 @@ "oldfieldtype": "Button", "doctype": "DocField", "label": "Calculate Tax", - "trigger": "Client", "fieldname": "calculate_tax", "fieldtype": "Button", "permlevel": 0 @@ -373,20 +379,17 @@ { "print_hide": 1, "oldfieldtype": "Link", - "colour": "White:FFF", "doctype": "DocField", "label": "Supplier", "oldfieldname": "supplier", - "permlevel": 0, - "trigger": "Client", + "options": "Supplier", "fieldname": "supplier", "fieldtype": "Link", "hidden": 0, - "options": "Supplier" + "permlevel": 0 }, { "depends_on": "eval:doc.supplier", - "colour": "White:FFF", "doctype": "DocField", "label": "Supplier Address", "options": "Address", @@ -404,7 +407,6 @@ { "print_hide": 1, "depends_on": "eval:doc.supplier", - "colour": "White:FFF", "doctype": "DocField", "label": "Contact Person", "options": "Contact", @@ -412,206 +414,6 @@ "fieldtype": "Link", "permlevel": 0 }, - { - "print_hide": 1, - "oldfieldtype": "Section Break", - "doctype": "DocField", - "label": "More Info", - "fieldname": "more_info", - "fieldtype": "Section Break", - "permlevel": 0 - }, - { - "print_hide": 1, - "oldfieldtype": "Column Break", - "doctype": "DocField", - "width": "50%", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "print_hide": 1, - "default": "No", - "oldfieldtype": "Select", - "colour": "White:FFF", - "doctype": "DocField", - "label": "Is Opening", - "oldfieldname": "is_opening", - "permlevel": 0, - "trigger": "Client", - "fieldname": "is_opening", - "fieldtype": "Select", - "search_index": 1, - "options": "No\nYes", - "in_filter": 1 - }, - { - "print_hide": 1, - "oldfieldtype": "Date", - "doctype": "DocField", - "label": "Aging Date", - "oldfieldname": "aging_date", - "fieldname": "aging_date", - "fieldtype": "Date", - "search_index": 0, - "permlevel": 0 - }, - { - "print_hide": 1, - "no_copy": 1, - "oldfieldtype": "Link", - "doctype": "DocField", - "label": "Amended From", - "oldfieldname": "amended_from", - "options": "Purchase Invoice", - "fieldname": "amended_from", - "fieldtype": "Link", - "permlevel": 1 - }, - { - "print_hide": 1, - "description": "The date at which current entry is corrected in the system.", - "no_copy": 1, - "oldfieldtype": "Date", - "doctype": "DocField", - "label": "Amendment Date", - "oldfieldname": "amendment_date", - "fieldname": "amendment_date", - "fieldtype": "Date", - "permlevel": 0 - }, - { - "print_hide": 1, - "no_copy": 1, - "oldfieldtype": "Link", - "colour": "White:FFF", - "allow_on_submit": 1, - "doctype": "DocField", - "label": "Select Print Heading", - "oldfieldname": "select_print_heading", - "permlevel": 0, - "trigger": "Client", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "options": "Print Heading", - "report_hide": 1 - }, - { - "print_hide": 0, - "no_copy": 0, - "oldfieldtype": "Date", - "doctype": "DocField", - "label": "Due Date", - "oldfieldname": "due_date", - "fieldname": "due_date", - "fieldtype": "Date", - "search_index": 1, - "permlevel": 0, - "in_filter": 1 - }, - { - "oldfieldtype": "Select", - "doctype": "DocField", - "label": "Mode of Payment", - "oldfieldname": "mode_of_payment", - "options": "link:Mode of Payment", - "fieldname": "mode_of_payment", - "fieldtype": "Select", - "permlevel": 0 - }, - { - "print_hide": 1, - "oldfieldtype": "Column Break", - "doctype": "DocField", - "width": "50%", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "print_hide": 1, - "oldfieldtype": "Link", - "doctype": "DocField", - "label": "Company", - "oldfieldname": "company", - "options": "Company", - "fieldname": "company", - "fieldtype": "Link", - "search_index": 1, - "permlevel": 0, - "in_filter": 1 - }, - { - "print_hide": 1, - "oldfieldtype": "Select", - "doctype": "DocField", - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "options": "link:Fiscal Year", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "search_index": 1, - "permlevel": 0, - "in_filter": 1 - }, - { - "print_hide": 1, - "no_copy": 1, - "oldfieldtype": "Data", - "colour": "White:FFF", - "doctype": "DocField", - "label": "Cancel Reason", - "oldfieldname": "cancel_reason", - "fieldname": "cancel_reason", - "fieldtype": "Data", - "depends_on": "eval:!doc.__islocal", - "permlevel": 1 - }, - { - "print_hide": 1, - "no_copy": 1, - "oldfieldtype": "Text", - "doctype": "DocField", - "label": "Remarks", - "oldfieldname": "remarks", - "fieldname": "remarks", - "fieldtype": "Small Text", - "reqd": 0, - "permlevel": 0 - }, - { - "print_hide": 1, - "oldfieldtype": "Section Break", - "doctype": "DocField", - "label": "Advances", - "fieldname": "advances", - "fieldtype": "Section Break", - "permlevel": 0 - }, - { - "print_hide": 1, - "oldfieldtype": "Button", - "doctype": "DocField", - "label": "Get Advances Paid", - "options": "get_advances", - "fieldname": "get_advances_paid", - "fieldtype": "Button", - "permlevel": 0 - }, - { - "print_hide": 1, - "no_copy": 1, - "oldfieldtype": "Table", - "colour": "White:FFF", - "doctype": "DocField", - "label": "Purchase Invoice Advances", - "oldfieldname": "advance_allocation_details", - "options": "Purchase Invoice Advance", - "fieldname": "advance_allocation_details", - "fieldtype": "Table", - "permlevel": 0 - }, { "oldfieldtype": "Section Break", "doctype": "DocField", @@ -620,22 +422,13 @@ "fieldtype": "Section Break", "permlevel": 0 }, - { - "print_hide": 1, - "oldfieldtype": "Column Break", - "doctype": "DocField", - "width": "50%", - "fieldname": "column_break7", - "fieldtype": "Column Break", - "permlevel": 0 - }, { "print_hide": 1, "oldfieldtype": "Currency", "doctype": "DocField", - "label": "Taxes and Charges Added", - "oldfieldname": "other_charges_added", - "fieldname": "other_charges_added", + "label": "Net Total (Import)", + "oldfieldname": "net_total_import", + "fieldname": "net_total_import", "fieldtype": "Currency", "permlevel": 1 }, @@ -643,9 +436,9 @@ "print_hide": 1, "oldfieldtype": "Currency", "doctype": "DocField", - "label": "Taxes and Charges Deducted", - "oldfieldname": "other_charges_deducted", - "fieldname": "other_charges_deducted", + "label": "Taxes and Charges Added (Import)", + "oldfieldname": "other_charges_added_import", + "fieldname": "other_charges_added_import", "fieldtype": "Currency", "permlevel": 1 }, @@ -653,33 +446,32 @@ "print_hide": 1, "oldfieldtype": "Currency", "doctype": "DocField", - "label": "Grand Total", - "oldfieldname": "grand_total", - "fieldname": "grand_total", + "label": "Taxes and Charges Deducted (Import)", + "oldfieldname": "other_charges_deducted_import", + "fieldname": "other_charges_deducted_import", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Grand Total (Import)", + "oldfieldname": "grand_total_import", + "fieldname": "grand_total_import", "fieldtype": "Currency", "permlevel": 1 }, { "print_hide": 1, - "description": "In Words will be visible once you save the Purchase Invoice.", "oldfieldtype": "Data", - "colour": "White:FFF", "doctype": "DocField", - "label": "In Words", - "oldfieldname": "in_words", - "fieldname": "in_words", + "label": "In Words (Import)", + "oldfieldname": "in_words_import", + "fieldname": "in_words_import", "fieldtype": "Data", "permlevel": 1 }, - { - "print_hide": 1, - "oldfieldtype": "Column Break", - "doctype": "DocField", - "width": "50%", - "fieldname": "column_break8", - "fieldtype": "Column Break", - "permlevel": 0 - }, { "print_hide": 1, "no_copy": 1, @@ -716,6 +508,67 @@ "permlevel": 1, "in_filter": 1 }, + { + "print_hide": 1, + "oldfieldtype": "Column Break", + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break8", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "print_hide": 1, + "description": "Will be calculated automatically when you enter the details", + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Net Total", + "oldfieldname": "net_total", + "fieldname": "net_total", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Taxes and Charges Added", + "oldfieldname": "other_charges_added", + "fieldname": "other_charges_added", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Taxes and Charges Deducted", + "oldfieldname": "other_charges_deducted", + "fieldname": "other_charges_deducted", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Grand Total", + "oldfieldname": "grand_total", + "fieldname": "grand_total", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "description": "In Words will be visible once you save the Purchase Invoice.", + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "In Words", + "oldfieldname": "in_words", + "fieldname": "in_words", + "fieldtype": "Data", + "permlevel": 1 + }, { "print_hide": 1, "no_copy": 1, @@ -729,7 +582,6 @@ "print_hide": 1, "no_copy": 1, "depends_on": "eval:flt(doc.write_off_amount)!=0", - "colour": "White:FFF", "doctype": "DocField", "label": "Write Off Account", "options": "Account", @@ -741,7 +593,6 @@ "print_hide": 1, "no_copy": 1, "depends_on": "eval:flt(doc.write_off_amount)!=0", - "colour": "White:FFF", "doctype": "DocField", "label": "Write Off Cost Center", "options": "Account", @@ -749,47 +600,6 @@ "fieldtype": "Link", "permlevel": 0 }, - { - "print_hide": 1, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Taxes and Charges Added (Import)", - "oldfieldname": "other_charges_added_import", - "fieldname": "other_charges_added_import", - "fieldtype": "Currency", - "permlevel": 1 - }, - { - "print_hide": 1, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Taxes and Charges Deducted (Import)", - "oldfieldname": "other_charges_deducted_import", - "fieldname": "other_charges_deducted_import", - "fieldtype": "Currency", - "permlevel": 1 - }, - { - "print_hide": 1, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Grand Total (Import)", - "oldfieldname": "grand_total_import", - "fieldname": "grand_total_import", - "fieldtype": "Currency", - "permlevel": 1 - }, - { - "print_hide": 1, - "oldfieldtype": "Data", - "colour": "White:FFF", - "doctype": "DocField", - "label": "In Words (Import)", - "oldfieldname": "in_words_import", - "fieldname": "in_words_import", - "fieldtype": "Data", - "permlevel": 1 - }, { "print_hide": 1, "no_copy": 1, @@ -803,6 +613,176 @@ "permlevel": 0, "report_hide": 0 }, + { + "print_hide": 1, + "oldfieldtype": "Section Break", + "doctype": "DocField", + "label": "Advances", + "fieldname": "advances", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "print_hide": 1, + "oldfieldtype": "Button", + "doctype": "DocField", + "label": "Get Advances Paid", + "options": "get_advances", + "fieldname": "get_advances_paid", + "fieldtype": "Button", + "permlevel": 0 + }, + { + "print_hide": 1, + "no_copy": 1, + "oldfieldtype": "Table", + "doctype": "DocField", + "label": "Purchase Invoice Advances", + "oldfieldname": "advance_allocation_details", + "options": "Purchase Invoice Advance", + "fieldname": "advance_allocation_details", + "fieldtype": "Table", + "permlevel": 0 + }, + { + "print_hide": 1, + "oldfieldtype": "Section Break", + "doctype": "DocField", + "label": "More Info", + "fieldname": "more_info", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "print_hide": 1, + "default": "No", + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Is Opening", + "oldfieldname": "is_opening", + "permlevel": 0, + "fieldname": "is_opening", + "fieldtype": "Select", + "search_index": 1, + "options": "No\nYes", + "in_filter": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Date", + "doctype": "DocField", + "label": "Aging Date", + "oldfieldname": "aging_date", + "fieldname": "aging_date", + "fieldtype": "Date", + "search_index": 0, + "permlevel": 0 + }, + { + "print_hide": 1, + "no_copy": 1, + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Amended From", + "oldfieldname": "amended_from", + "options": "Purchase Invoice", + "fieldname": "amended_from", + "fieldtype": "Link", + "permlevel": 1 + }, + { + "print_hide": 1, + "no_copy": 1, + "oldfieldtype": "Link", + "allow_on_submit": 1, + "doctype": "DocField", + "label": "Select Print Heading", + "oldfieldname": "select_print_heading", + "permlevel": 0, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "options": "Print Heading", + "report_hide": 1 + }, + { + "print_hide": 0, + "no_copy": 0, + "oldfieldtype": "Date", + "doctype": "DocField", + "label": "Due Date", + "oldfieldname": "due_date", + "fieldname": "due_date", + "fieldtype": "Date", + "search_index": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Mode of Payment", + "oldfieldname": "mode_of_payment", + "options": "link:Mode of Payment", + "fieldname": "mode_of_payment", + "fieldtype": "Select", + "permlevel": 0 + }, + { + "doctype": "DocField", + "fieldname": "column_break_63", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "print_hide": 1, + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Company", + "oldfieldname": "company", + "options": "Company", + "fieldname": "company", + "fieldtype": "Link", + "search_index": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "options": "link:Fiscal Year", + "fieldname": "fiscal_year", + "fieldtype": "Select", + "search_index": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "print_hide": 1, + "no_copy": 1, + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "Cancel Reason", + "oldfieldname": "cancel_reason", + "fieldname": "cancel_reason", + "fieldtype": "Data", + "depends_on": "eval:!doc.__islocal", + "permlevel": 1 + }, + { + "print_hide": 1, + "no_copy": 1, + "oldfieldtype": "Text", + "doctype": "DocField", + "label": "Remarks", + "oldfieldname": "remarks", + "fieldname": "remarks", + "fieldtype": "Small Text", + "reqd": 0, + "permlevel": 0 + }, { "print_hide": 1, "no_copy": 1, @@ -813,14 +793,24 @@ "hidden": 1, "permlevel": 0 }, + { + "amend": 0, + "create": 0, + "doctype": "DocPerm", + "submit": 0, + "write": 0, + "role": "Accounts Manager", + "cancel": 0, + "permlevel": 1 + }, { "amend": 1, "create": 1, "doctype": "DocPerm", "submit": 1, "write": 1, + "role": "Accounts Manager", "cancel": 1, - "role": "Accounts User", "permlevel": 0 }, { @@ -829,8 +819,17 @@ "doctype": "DocPerm", "submit": 0, "write": 0, + "role": "Accounts User", "cancel": 0, + "permlevel": 1 + }, + { + "amend": 0, + "create": 0, + "doctype": "DocPerm", + "submit": 0, "role": "Purchase User", + "cancel": 0, "permlevel": 1 }, { @@ -839,69 +838,24 @@ "doctype": "DocPerm", "submit": 0, "write": 1, - "cancel": 0, "role": "Purchase User", + "cancel": 0, + "permlevel": 0 + }, + { + "amend": 1, + "create": 1, + "doctype": "DocPerm", + "submit": 1, + "write": 1, + "role": "Accounts User", + "cancel": 1, "permlevel": 0 }, { - "amend": 0, - "create": 0, "doctype": "DocPerm", - "submit": 0, - "write": 0, - "cancel": 0, "role": "Supplier", "permlevel": 0, "match": "supplier" - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "submit": 0, - "write": 0, - "cancel": 0, - "role": "Accounts Manager", - "permlevel": 1 - }, - { - "amend": 1, - "create": 1, - "doctype": "DocPerm", - "submit": 1, - "write": 1, - "cancel": 1, - "role": "Accounts Manager", - "permlevel": 0 - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "submit": 0, - "write": 0, - "cancel": 0, - "role": "Accounts User", - "permlevel": 1 - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "submit": 0, - "write": 0, - "cancel": 0, - "role": "Auditor", - "permlevel": 1 - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "submit": 0, - "write": 0, - "cancel": 0, - "role": "Auditor", - "permlevel": 0 } ] \ No newline at end of file diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index 649f282c1c..4b88425bdf 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -25,16 +25,61 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({ setup: function() { var me = this; - this.frm.fields_dict.price_list_currency.get_query = function() { - return repl("select distinct ref_currency from `tabItem Price` \ - where price_list_name=\"%(price_list_name)s\" and %(key)s like \"%s%%\"", - {price_list_name: me.frm.doc.price_list_name}); - }; + if(this.frm.fields_dict.price_list_name) { + this.frm.fields_dict.price_list_name.get_query = function() { + return repl("select distinct price_list_name from `tabItem Price` \ + where for_buying = 1 and price_list_name like \"%s%%\""); + }; + } + + if(this.frm.fields_dict.price_list_currency) { + this.frm.fields_dict.price_list_currency.get_query = function() { + return repl("select distinct ref_currency from `tabItem Price` \ + where price_list_name=\"%(price_list_name)s\" and for_buying = 1 \ + and ref_currency like \"%s%%\"", + {price_list_name: me.frm.doc.price_list_name}); + }; + } + }, + + refresh: function() { + this.frm.clear_custom_buttons(); + erpnext.hide_naming_series(); + + if(this.frm.fields_dict.supplier) + this.frm.toggle_display("contact_section", this.frm.doc.supplier); + + if(this.frm.fields_dict.currency) + this.set_dynamic_labels(); + + // TODO: improve this + if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name + && this.frm.doc.price_list_name && this.frm.doc.price_list_currency) { + this.price_list_name(); + } }, price_list_name: function() { this.frm.toggle_reqd(["price_list_currency", "plc_conversion_rate"], - !!this.frm.doc.price_list_name); + !!(this.frm.doc.price_list_name)); + + var me = this; + + if(this.frm.doc.price_list_name) { + // set price list currency + this.frm.call({ + method: "setup.utils.get_price_list_currency", + args: {args: { + price_list_name: this.frm.doc.price_list_name, + use_for: "buying" + }}, + callback: function(r) { + if(!r.exc && r.message.price_list_currency) { + me.price_list_currency(); + } + } + }); + } }, item_code: function(doc, cdt, cdn) { @@ -80,6 +125,118 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({ } else { this.load_taxes(doc, dt, dn, callback); } + }, + + currency: function() { + this.set_dynamic_labels(); + }, + + company: function() { + this.set_dynamic_labels(); + }, + + price_list_currency: function() { + this.set_dynamic_labels(); + + if(this.frm.doc.price_list_currency === this.get_company_currency()) { + this.frm.set_value("plc_conversion_rate", 1.0); + } + }, + + set_dynamic_labels: function(doc, dt, dn) { + var company_currency = this.get_company_currency(); + + this.change_form_labels(company_currency); + this.change_grid_labels(company_currency); + }, + + change_form_labels: function(company_currency) { + var me = this; + var field_label_map = {}; + + var setup_field_label_map = function(fields_list, currency) { + $.each(fields_list, function(i, fname) { + var docfield = wn.meta.get_docfield(me.frm.doc.doctype, fname); + if(docfield) { + var label = wn._((docfield.label || "")).replace(/\([^\)]*\)/g, ""); + field_label_map[fname] = label.trim() + " (" + currency + ")"; + } + }); + } + + setup_field_label_map(["net_total", "total_tax", "grand_total", "in_words", + "other_charges_added", "other_charges_deducted", + "outstanding_amount", "total_advance", "total_amount_to_pay", "rounded_total"], + company_currency); + + setup_field_label_map(["net_total_import", "grand_total_import", "in_words_import", + "other_charges_added_import", "other_charges_deducted_import"], this.frm.doc.currency); + + setup_field_label_map(["conversion_rate"], "1 " + this.frm.doc.currency + + " = [?] " + company_currency); + + if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) { + setup_field_label_map(["plc_conversion_rate"], "1 " + this.frm.doc.price_list_currency + + " = [?] " + company_currency); + } + + // toggle fields + this.frm.toggle_display(["conversion_rate", "net_total", "grand_total", + "in_words", "other_charges_added", "other_charges_deducted"], + this.frm.doc.currency != company_currency); + + // set labels + $.each(field_label_map, function(fname, label) { + me.frm.fields_dict[fname].set_label(label); + }); + }, + + change_grid_labels: function(company_currency) { + var me = this; + var field_label_map = {}; + + var setup_field_label_map = function(fields_list, currency, parentfield) { + var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype; + $.each(fields_list, function(i, fname) { + var docfield = wn.meta.get_docfield(grid_doctype, fname); + if(docfield) { + field_label_map[grid_doctype + "-" + fname] = + docfield.label + " (" + currency + ")"; + } + }); + } + + setup_field_label_map(["purchase_rate", "purchase_ref_rate", "amount", "rate"], + company_currency, this.fname); + + setup_field_label_map(["import_rate", "import_ref_rate", "import_amount"], + this.frm.doc.currency, this.fname); + + setup_field_label_map(["tax_amount", "total"], company_currency, this.other_fname); + + if(this.frm.fields_dict["advance_allocation_details"]) { + setup_field_label_map(["advance_amount", "allocated_amount"], company_currency, + "advance_allocation_details"); + } + + // toggle columns + var item_grid = this.frm.fields_dict[this.fname].grid; + var hide = this.frm.doc.currency == company_currency; + $.each(["purchase_rate", "purchase_ref_rate", "amount", "rate"], function(i, fname) { + if(wn.meta.get_docfield(item_grid.doctype, fname)) + item_grid.set_column_disp(fname, hide); + }); + + // set labels + var $wrapper = $(this.frm.wrapper); + $.each(field_label_map, function(fname, label) { + $wrapper.find('[data-grid-fieldname="'+fname+'"]').text(label); + }); + }, + + get_company_currency: function() { + return (wn.boot.company[this.frm.doc.company].default_currency || + sys_defaults['currency']); } }); @@ -89,7 +246,7 @@ $.extend(prev_cscript, cur_frm.cscript); cur_frm.cscript = new erpnext.buying.BuyingController({frm: cur_frm}); -// combine new and previous states +// for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, prev_cscript); @@ -139,83 +296,6 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) { 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['outstanding_amount'].label_area.innerHTML = 'Outstanding Amount (' + 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 + ')'; - } 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'} - 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); @@ -697,10 +777,6 @@ var calculate_outstanding = function(doc) { } -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) { diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py index 188ebf9de0..78264c2511 100644 --- a/buying/doctype/purchase_common/purchase_common.py +++ b/buying/doctype/purchase_common/purchase_common.py @@ -254,28 +254,6 @@ class DocType(BuyingController): else: chk_dupl_itm.append(f) - # validate conversion rate - def validate_conversion_rate(self, obj): - default_currency = super(DocType, self).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) - # Validate values with reference document #--------------------------------------- def validate_reference_value(self, obj): diff --git a/buying/doctype/purchase_order/purchase_order.js b/buying/doctype/purchase_order/purchase_order.js index b5a7405271..fa37704916 100644 --- a/buying/doctype/purchase_order/purchase_order.js +++ b/buying/doctype/purchase_order/purchase_order.js @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +wn.provide("erpnext.buying"); + cur_frm.cscript.tname = "Purchase Order Item"; cur_frm.cscript.fname = "po_details"; cur_frm.cscript.other_fname = "purchase_tax_details"; @@ -22,6 +24,35 @@ wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxe wn.require('app/buying/doctype/purchase_common/purchase_common.js'); wn.require('app/utilities/doctype/sms_control/sms_control.js'); +erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({ + refresh: function(doc, cdt, cdn) { + this._super(); + + if(doc.docstatus == 1 && doc.status != 'Stopped'){ + cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']); + if(flt(doc.per_received, 2) < 100) cur_frm.add_custom_button('Make Purchase Receipt', cur_frm.cscript['Make Purchase Receipt']); + if(flt(doc.per_billed, 2) < 100) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Purchase Invoice']); + if(flt(doc.per_billed, 2) < 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']); + + }, + + onload_post_render: function(doc, dt, dn) { + var callback = function(doc, dt, dn) { + if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc); + } + this.update_item_details(doc, dt, dn, callback); + } +}); + +var new_cscript = new erpnext.buying.PurchaseOrderController({frm: cur_frm}); + +// for backward compatibility: combine new and previous states +$.extend(cur_frm.cscript, new_cscript); + cur_frm.cscript.onload = function(doc, cdt, cdn) { // set missing values in parent doc set_missing_values(doc, { @@ -34,32 +65,6 @@ 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.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(flt(doc.per_received, 2) < 100) cur_frm.add_custom_button('Make Purchase Receipt', cur_frm.cscript['Make Purchase Receipt']); - if(flt(doc.per_billed, 2) < 100) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Purchase Invoice']); - if(flt(doc.per_billed, 2) < 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', diff --git a/buying/doctype/purchase_order/purchase_order.txt b/buying/doctype/purchase_order/purchase_order.txt index 344416f491..f4570e89c1 100644 --- a/buying/doctype/purchase_order/purchase_order.txt +++ b/buying/doctype/purchase_order/purchase_order.txt @@ -2,9 +2,9 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-12-03 17:56:30", + "creation": "2013-01-17 11:11:23", "modified_by": "Administrator", - "modified": "2013-01-15 15:42:21" + "modified": "2013-01-17 12:49:14" }, { "autoname": "naming_series:", @@ -253,34 +253,11 @@ }, { "doctype": "DocField", - "label": "Price List and Currency", + "label": "Currency & Price List", "fieldname": "price_list_and_currency", "fieldtype": "Section Break", "permlevel": 0 }, - { - "doctype": "DocField", - "label": "Price List", - "options": "link:Price List", - "fieldname": "price_list_name", - "fieldtype": "Select", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Price List Currency", - "options": "Currency", - "fieldname": "price_list_currency", - "fieldtype": "Link", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Price List Exchange Rate", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "permlevel": 0 - }, { "doctype": "DocField", "fieldname": "cb_currency", @@ -316,6 +293,35 @@ "hidden": 0, "permlevel": 0 }, + { + "doctype": "DocField", + "fieldname": "cb_price_list", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Price List", + "options": "Price List", + "fieldname": "price_list_name", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Price List Currency", + "options": "Currency", + "fieldname": "price_list_currency", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Price List Exchange Rate", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "permlevel": 0 + }, { "print_hide": 0, "oldfieldtype": "Section Break", diff --git a/buying/doctype/purchase_request/purchase_request.js b/buying/doctype/purchase_request/purchase_request.js index f46518f0bf..fdbb9c0976 100644 --- a/buying/doctype/purchase_request/purchase_request.js +++ b/buying/doctype/purchase_request/purchase_request.js @@ -19,6 +19,31 @@ cur_frm.cscript.fname = "indent_details"; wn.require('app/buying/doctype/purchase_common/purchase_common.js'); wn.require('app/utilities/doctype/sms_control/sms_control.js'); + +erpnext.buying.PurchaseRequestController = erpnext.buying.BuyingController.extend({ + refresh: function(doc) { + this._super(); + + if(doc.docstatus == 1 && doc.status != 'Stopped'){ + cur_frm.add_custom_button("Make Supplier Quotation", cur_frm.cscript.make_supplier_quotation); + if(flt(doc.per_ordered, 2) < 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); + + } + + if(doc.docstatus == 1 && doc.status == 'Stopped') + cur_frm.add_custom_button('Unstop Purchase Request', cur_frm.cscript['Unstop Purchase Request']) + } +}); + +var new_cscript = new erpnext.buying.PurchaseRequestController({frm: cur_frm}); + +// for backward compatibility: combine new and previous states +$.extend(cur_frm.cscript, new_cscript); + //========================== On Load ================================================= cur_frm.cscript.onload = function(doc, cdt, cdn) { @@ -43,26 +68,6 @@ cur_frm.cscript.get_item_defaults = function(doc) { } } - -//======================= 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'){ - cur_frm.add_custom_button("Make Supplier Quotation", cur_frm.cscript.make_supplier_quotation); - if(flt(doc.per_ordered, 2) < 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); - - } - - if(doc.docstatus == 1 && doc.status == 'Stopped') - cur_frm.add_custom_button('Unstop Purchase Request', cur_frm.cscript['Unstop Purchase Request']) -} - //======================= transaction date ============================= cur_frm.cscript.transaction_date = function(doc,cdt,cdn){ if(doc.__islocal){ diff --git a/buying/doctype/supplier_quotation/supplier_quotation.js b/buying/doctype/supplier_quotation/supplier_quotation.js index 37bb625b9c..87bf63cd6f 100644 --- a/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/buying/doctype/supplier_quotation/supplier_quotation.js @@ -23,6 +23,24 @@ cur_frm.cscript.other_fname = "purchase_tax_details"; wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js'); wn.require('app/buying/doctype/purchase_common/purchase_common.js'); +erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({ + refresh: function() { + this._super(); + + cur_frm.cscript.load_taxes(this.frm.doc); + + if (this.frm.doc.docstatus === 1) { + cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order); + } + } +}); + +var new_cscript = new erpnext.buying.SupplierQuotationController({frm: cur_frm}); + +// for backward compatibility: combine new and previous states +$.extend(cur_frm.cscript, new_cscript); + + cur_frm.cscript.onload = function(doc, dt, dn) { // set missing values in parent doc set_missing_values(doc, { @@ -35,19 +53,6 @@ cur_frm.cscript.onload = function(doc, dt, dn) { }); } -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 = wn.model.make_new_doc_and_get_name("Purchase Order"); $c("dt_map", { diff --git a/buying/doctype/supplier_quotation/supplier_quotation.txt b/buying/doctype/supplier_quotation/supplier_quotation.txt index 5d05d98b73..d11f482c35 100644 --- a/buying/doctype/supplier_quotation/supplier_quotation.txt +++ b/buying/doctype/supplier_quotation/supplier_quotation.txt @@ -2,9 +2,9 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-12-20 12:50:48", + "creation": "2013-01-17 11:11:23", "modified_by": "Administrator", - "modified": "2013-01-15 15:38:38" + "modified": "2013-01-17 19:56:48" }, { "autoname": "naming_series:", @@ -37,15 +37,6 @@ "name": "Supplier Quotation", "doctype": "DocType" }, - { - "print_width": "50%", - "oldfieldtype": "Column Break", - "doctype": "DocField", - "width": "50%", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "permlevel": 0 - }, { "print_hide": 1, "description": "To manage multiple series please go to Setup > Manage Series", @@ -166,37 +157,6 @@ "fieldtype": "Section Break", "permlevel": 0 }, - { - "print_width": "50%", - "doctype": "DocField", - "width": "50%", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "print_hide": 1, - "no_copy": 1, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Net Total*", - "oldfieldname": "net_total", - "fieldname": "net_total", - "fieldtype": "Currency", - "reqd": 0, - "permlevel": 1 - }, - { - "print_hide": 1, - "no_copy": 0, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Net Total (Import)", - "oldfieldname": "net_total_import", - "fieldname": "net_total_import", - "fieldtype": "Currency", - "permlevel": 1 - }, { "oldfieldtype": "Button", "doctype": "DocField", @@ -206,40 +166,10 @@ "permlevel": 0 }, { - "print_width": "50%", "doctype": "DocField", - "width": "50%", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "print_hide": 1, - "description": "Supplier's currency", - "no_copy": 0, - "oldfieldtype": "Select", - "doctype": "DocField", - "label": "Currency", - "oldfieldname": "currency", - "permlevel": 0, - "fieldname": "currency", - "fieldtype": "Select", - "reqd": 1, - "options": "link:Currency" - }, - { - "print_hide": 1, - "description": "Rate at which supplier's currency is converted to company's base currency", - "no_copy": 1, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Conversion Rate", - "oldfieldname": "conversion_rate", - "default": "1", - "fieldname": "conversion_rate", - "fieldtype": "Currency", - "reqd": 1, - "hidden": 0, + "options": "Simple", + "fieldname": "section_break_14", + "fieldtype": "Section Break", "permlevel": 0 }, { @@ -266,6 +196,73 @@ "hidden": 0, "permlevel": 0 }, + { + "doctype": "DocField", + "label": "Currency & Price List", + "fieldname": "currency_price_list", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "print_hide": 1, + "description": "Supplier's currency", + "no_copy": 0, + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Currency", + "oldfieldname": "currency", + "permlevel": 0, + "fieldname": "currency", + "fieldtype": "Select", + "reqd": 1, + "options": "link:Currency" + }, + { + "print_hide": 1, + "description": "Rate at which supplier's currency is converted to company's base currency", + "no_copy": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Exchange Rate", + "oldfieldname": "conversion_rate", + "default": "1", + "fieldname": "conversion_rate", + "fieldtype": "Currency", + "reqd": 1, + "hidden": 0, + "permlevel": 0 + }, + { + "print_width": "50%", + "doctype": "DocField", + "width": "50%", + "fieldname": "cb_price_list", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Price List", + "options": "Price List", + "fieldname": "price_list_name", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Price List Currency", + "options": "Currency", + "fieldname": "price_list_currency", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Price List Exchange Rate", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "permlevel": 0 + }, { "oldfieldtype": "Section Break", "doctype": "DocField", @@ -327,6 +324,113 @@ "fieldtype": "HTML", "permlevel": 0 }, + { + "oldfieldtype": "Section Break", + "doctype": "DocField", + "label": "Totals", + "fieldname": "totals", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "print_hide": 1, + "no_copy": 0, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Net Total (Import)", + "oldfieldname": "net_total_import", + "fieldname": "net_total_import", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "no_copy": 0, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Taxes and Charges Added (Import)", + "oldfieldname": "other_charges_added_import", + "fieldname": "other_charges_added_import", + "fieldtype": "Currency", + "permlevel": 1, + "report_hide": 0 + }, + { + "print_hide": 1, + "no_copy": 0, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Taxes and Charges Deducted (Import)", + "oldfieldname": "other_charges_deducted_import", + "fieldname": "other_charges_deducted_import", + "fieldtype": "Currency", + "permlevel": 1, + "report_hide": 0 + }, + { + "print_hide": 1, + "no_copy": 0, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Grand Total (Import)", + "oldfieldname": "grand_total_import", + "fieldname": "grand_total_import", + "fieldtype": "Currency", + "permlevel": 1, + "report_hide": 0 + }, + { + "print_hide": 1, + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "In Words(Import)", + "oldfieldname": "in_words_import", + "fieldname": "in_words_import", + "fieldtype": "Data", + "permlevel": 1 + }, + { + "print_hide": 0, + "oldfieldtype": "Column Break", + "doctype": "DocField", + "fieldname": "column_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "print_hide": 1, + "no_copy": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Net Total*", + "oldfieldname": "net_total", + "fieldname": "net_total", + "fieldtype": "Currency", + "reqd": 0, + "permlevel": 1 + }, + { + "print_hide": 1, + "no_copy": 0, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Taxes and Charges Added", + "oldfieldname": "other_charges_added", + "fieldname": "other_charges_added", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "no_copy": 0, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Taxes and Charges Deducted", + "oldfieldname": "other_charges_deducted", + "fieldname": "other_charges_deducted", + "fieldtype": "Currency", + "permlevel": 1 + }, { "print_hide": 1, "no_copy": 1, @@ -338,14 +442,6 @@ "fieldtype": "Currency", "permlevel": 1 }, - { - "oldfieldtype": "Section Break", - "doctype": "DocField", - "label": "Totals", - "fieldname": "totals", - "fieldtype": "Section Break", - "permlevel": 0 - }, { "print_hide": 1, "no_copy": 1, @@ -378,82 +474,6 @@ "fieldtype": "Data", "permlevel": 1 }, - { - "print_hide": 1, - "no_copy": 0, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Taxes and Charges Added", - "oldfieldname": "other_charges_added", - "fieldname": "other_charges_added", - "fieldtype": "Currency", - "permlevel": 1 - }, - { - "print_hide": 1, - "no_copy": 0, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Taxes and Charges Deducted", - "oldfieldname": "other_charges_deducted", - "fieldname": "other_charges_deducted", - "fieldtype": "Currency", - "permlevel": 1 - }, - { - "print_hide": 0, - "oldfieldtype": "Column Break", - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "print_hide": 1, - "no_copy": 0, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Grand Total (Import)", - "oldfieldname": "grand_total_import", - "fieldname": "grand_total_import", - "fieldtype": "Currency", - "permlevel": 1, - "report_hide": 0 - }, - { - "print_hide": 1, - "oldfieldtype": "Data", - "doctype": "DocField", - "label": "In Words(Import)", - "oldfieldname": "in_words_import", - "fieldname": "in_words_import", - "fieldtype": "Data", - "permlevel": 1 - }, - { - "print_hide": 1, - "no_copy": 0, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Taxes and Charges Added (Import)", - "oldfieldname": "other_charges_added_import", - "fieldname": "other_charges_added_import", - "fieldtype": "Currency", - "permlevel": 1, - "report_hide": 0 - }, - { - "print_hide": 1, - "no_copy": 0, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Taxes and Charges Deducted (Import)", - "oldfieldname": "other_charges_deducted_import", - "fieldname": "other_charges_deducted_import", - "fieldtype": "Currency", - "permlevel": 1, - "report_hide": 0 - }, { "oldfieldtype": "Section Break", "doctype": "DocField", @@ -464,8 +484,8 @@ }, { "print_hide": 1, - "oldfieldtype": "Select", "allow_on_submit": 1, + "oldfieldtype": "Select", "doctype": "DocField", "label": "Letter Head", "oldfieldname": "letter_head", diff --git a/buying/utils.py b/buying/utils.py index 293108e928..b299c5ecac 100644 --- a/buying/utils.py +++ b/buying/utils.py @@ -82,7 +82,7 @@ def get_item_details(args): if args.doctype in ["Purchase Order", "Purchase Invoice", "Purchase Receipt"]: # try fetching from price list - if args.price_list_name: + if args.price_list_name and args.price_list_currency: rates_as_per_price_list = get_rates_as_per_price_list(args, item_wrapper.doclist) if rates_as_per_price_list: out.update(rates_as_per_price_list) diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index c5e00603cc..f9c33edbdd 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -16,13 +16,19 @@ from __future__ import unicode_literals import webnotes +from webnotes import _, msgprint +from webnotes.utils import flt from buying.utils import get_item_details +from setup.utils import get_company_currency from utilities.transaction_base import TransactionBase class BuyingController(TransactionBase): def validate(self): - pass + if self.meta.get_field("currency"): + self.company_currency = get_company_currency(self.doc.company) + self.validate_conversion_rate("currency", "conversion_rate") + self.validate_conversion_rate("price_list_currency", "plc_conversion_rate") def update_item_details(self): for item in self.doclist.get({"parentfield": self.fname}): @@ -38,3 +44,25 @@ class BuyingController(TransactionBase): for r in ret: if not item.fields.get(r): item.fields[r] = ret[r] + + def validate_conversion_rate(self, currency_field, conversion_rate_field): + """common validation for currency and price list currency""" + + currency = self.doc.fields.get(currency_field) + conversion_rate = flt(self.doc.fields.get(conversion_rate_field)) + conversion_rate_label = self.meta.get_label(conversion_rate_field) + + if conversion_rate == 0: + msgprint(conversion_rate_label + _(' cannot be 0'), raise_exception=True) + + # parenthesis for 'OR' are necessary as we want it to evaluate as + # mandatory valid condition and (1st optional valid condition + # or 2nd optional valid condition) + valid_conversion_rate = (conversion_rate and + ((currency == self.company_currency and conversion_rate == 1.00) + or (currency != self.company_currency and conversion_rate != 1.00))) + + if not valid_conversion_rate: + msgprint(_('Please enter valid ') + conversion_rate_label + (': ') + + ("1 %s = [?] %s" % _(currency, self.company_currency)), + raise_exception=True) diff --git a/patches/january_2013/purchase_price_list.py b/patches/january_2013/purchase_price_list.py new file mode 100644 index 0000000000..4a1369fbd2 --- /dev/null +++ b/patches/january_2013/purchase_price_list.py @@ -0,0 +1,7 @@ +import webnotes + +def execute(): + # check for selling + webnotes.conn.sql("""update `tabItem Price` set selling=1 + where ifnull(selling, 0)=0 and ifnull(buying, 0)=0""") + \ No newline at end of file diff --git a/setup/utils.py b/setup/utils.py index baa4d0ffd0..396dc16a7d 100644 --- a/setup/utils.py +++ b/setup/utils.py @@ -16,6 +16,8 @@ from __future__ import unicode_literals import webnotes +from webnotes import _, msgprint +import json def get_company_currency(company): currency = webnotes.conn.get_value("Company", company, "default_currency") @@ -25,4 +27,23 @@ def get_company_currency(company): msgprint(_('Please specify Default Currency in Company Master \ and Global Defaults'), raise_exception=True) - return currency \ No newline at end of file + return currency + +@webnotes.whitelist() +def get_price_list_currency(args): + """ + args = { + "price_list_name": "Something", + "use_for": "buying" or "selling" + } + """ + if isinstance(args, basestring): + args = json.loads(args) + + result = webnotes.conn.sql("""select ref_currency from `tabItem Price` + where price_list_name=%s and `%s`=1""" % ("%s", args.get("use_for")), + (args.get("price_list_name"),)) + if result and len(result)==1: + return {"price_list_currency": result[0][0]} + else: + return {} diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt index 1f623bbd39..9608367241 100644 --- a/stock/doctype/item/item.txt +++ b/stock/doctype/item/item.txt @@ -2,9 +2,9 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-12-28 11:01:35", + "creation": "2013-01-17 10:57:15", "modified_by": "Administrator", - "modified": "2013-01-16 11:14:57" + "modified": "2013-01-17 11:22:07" }, { "allow_attach": 1, @@ -32,8 +32,9 @@ "read": 1, "submit": 0, "doctype": "DocPerm", - "report": 1, + "amend": 0, "parenttype": "DocType", + "report": 1, "parentfield": "permissions" }, { @@ -49,15 +50,6 @@ "fieldtype": "Section Break", "permlevel": 0 }, - { - "oldfieldtype": "Small Text", - "doctype": "DocField", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "permlevel": 1 - }, { "description": "Item will be saved by this name in the data base.", "oldfieldtype": "Data", @@ -596,18 +588,6 @@ "depends_on": "eval:doc.is_sales_item==\"Yes\"", "permlevel": 0 }, - { - "description": "Create a price list from Price List master and enter standard ref rates against each of them. On selection of a price list in Quotation, Sales Order or Delivery Note, corresponding ref rate will be fetched for this item.", - "oldfieldtype": "Table", - "doctype": "DocField", - "label": "Item Prices", - "oldfieldname": "ref_rate_details", - "options": "Item Price", - "fieldname": "ref_rate_details", - "fieldtype": "Table", - "depends_on": "eval:doc.is_sales_item==\"Yes\"", - "permlevel": 0 - }, { "description": "For the convenience of customers, these codes can be used in print formats like Invoices and Delivery Notes", "depends_on": "eval:doc.is_sales_item==\"Yes\"", @@ -636,6 +616,25 @@ "fieldtype": "Table", "permlevel": 0 }, + { + "doctype": "DocField", + "label": "Price Lists and Rates", + "fieldname": "price_list_section", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "description": "Create a price list from Price List master and enter standard ref rates against each of them. On selection of a price list in Quotation, Sales Order or Delivery Note, corresponding ref rate will be fetched for this item.", + "oldfieldtype": "Table", + "doctype": "DocField", + "label": "Item Prices", + "oldfieldname": "ref_rate_details", + "options": "Item Price", + "fieldname": "ref_rate_details", + "fieldtype": "Table", + "depends_on": "eval:doc.is_sales_item==\"Yes\"", + "permlevel": 0 + }, { "oldfieldtype": "Section Break", "doctype": "DocField", @@ -691,6 +690,7 @@ "permlevel": 0 }, { + "read_only": 1, "no_copy": 1, "oldfieldtype": "Link", "doctype": "DocField", @@ -700,7 +700,7 @@ "fieldname": "default_bom", "fieldtype": "Link", "depends_on": "eval:doc.is_manufactured_item==\"Yes\"", - "permlevel": 1 + "permlevel": 0 }, { "description": "Selecting \"Yes\" will allow you to make a Production Order for this item.", @@ -765,13 +765,14 @@ "permlevel": 0 }, { + "read_only": 1, "description": "website page link", "depends_on": "show_in_website", "doctype": "DocField", "label": "Page Name", "fieldname": "page_name", "fieldtype": "Data", - "permlevel": 1 + "permlevel": 0 }, { "description": "Products will be sorted by weight-age in default searches. More the weight-age, higher the product will appear in the list.", @@ -866,53 +867,32 @@ "create": 1, "doctype": "DocPerm", "write": 1, - "role": "Material Master Manager", "cancel": 1, - "permlevel": 0 - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "write": 0, - "role": "Material Manager", - "cancel": 0, - "permlevel": 0 - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "write": 0, - "role": "Material User", - "cancel": 0, - "permlevel": 0 - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "write": 0, "role": "Material Master Manager", - "cancel": 0, - "permlevel": 1 + "permlevel": 0 }, { - "amend": 0, "create": 0, "doctype": "DocPerm", "write": 0, - "role": "Material Manager", "cancel": 0, - "permlevel": 1 - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "write": 0, "role": "Material User", + "permlevel": 0 + }, + { + "create": 0, + "doctype": "DocPerm", + "write": 0, "cancel": 0, + "role": "Material Master Manager", + "permlevel": 1 + }, + { + "create": 0, + "doctype": "DocPerm", + "write": 0, + "cancel": 0, + "role": "Material User", "permlevel": 1 } ] \ No newline at end of file diff --git a/stock/doctype/item_price/item_price.txt b/stock/doctype/item_price/item_price.txt index 2f6133f03b..eccae617a8 100644 --- a/stock/doctype/item_price/item_price.txt +++ b/stock/doctype/item_price/item_price.txt @@ -2,31 +2,24 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-03-27 14:36:36", + "creation": "2013-01-15 18:43:18", "modified_by": "Administrator", - "modified": "2012-03-27 14:36:36" + "modified": "2013-01-17 17:53:42" }, { - "section_style": "Tray", - "istable": 1, - "in_create": 1, - "module": "Stock", - "server_code_error": " ", "read_only": 0, + "istable": 1, "autoname": "RFD/.#####", - "name": "__common__", - "colour": "White:FFF", + "in_create": 1, "doctype": "DocType", - "show_in_menu": 0, - "version": 3 + "module": "Stock", + "name": "__common__" }, { "name": "__common__", "parent": "Item Price", - "search_index": 1, "doctype": "DocField", "parenttype": "DocType", - "in_filter": 1, "permlevel": 0, "parentfield": "fields" }, @@ -40,9 +33,11 @@ "label": "Price List Name", "oldfieldname": "price_list_name", "fieldname": "price_list_name", - "fieldtype": "Select", + "fieldtype": "Link", + "search_index": 1, "reqd": 1, - "options": "link:Price List" + "options": "Price List", + "in_filter": 1 }, { "oldfieldtype": "Currency", @@ -51,7 +46,9 @@ "oldfieldname": "ref_rate", "fieldname": "ref_rate", "fieldtype": "Currency", - "reqd": 0 + "search_index": 0, + "reqd": 0, + "in_filter": 1 }, { "oldfieldtype": "Select", @@ -60,7 +57,23 @@ "oldfieldname": "ref_currency", "fieldname": "ref_currency", "fieldtype": "Select", + "search_index": 1, "reqd": 1, - "options": "link:Currency" + "options": "link:Currency", + "in_filter": 1 + }, + { + "description": "Allow this price in sales related forms", + "doctype": "DocField", + "label": "For Selling", + "fieldname": "selling", + "fieldtype": "Check" + }, + { + "description": "Allow this price in purchase related forms", + "doctype": "DocField", + "label": "For Buying", + "fieldname": "buying", + "fieldtype": "Check" } ] \ No newline at end of file diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js index 23aa2cc951..df2825b65b 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/stock/doctype/purchase_receipt/purchase_receipt.js @@ -22,6 +22,29 @@ wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxe wn.require('app/buying/doctype/purchase_common/purchase_common.js'); wn.require('app/utilities/doctype/sms_control/sms_control.js'); +erpnext.buying.PurchaseReceiptController = erpnext.buying.BuyingController.extend({ + refresh: function() { + this._super(); + + if(this.frm.doc.docstatus == 1) { + if(flt(this.frm.doc.per_billed, 2) < 100) { + cur_frm.add_custom_button('Make Purchase Invoice', + cur_frm.cscript['Make Purchase Invoice']); + } + cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']); + } + + if(wn.boot.control_panel.country == 'India') { + unhide_field(['challan_no', 'challan_date']); + } + } +}); + +var new_cscript = new erpnext.buying.PurchaseReceiptController({frm: cur_frm}); + +// for backward compatibility: combine new and previous states +$.extend(cur_frm.cscript, new_cscript); + //========================== On Load ================================================================ cur_frm.cscript.onload = function(doc, cdt, cdn) { if(!doc.fiscal_year && doc.__islocal){ wn.model.set_default_values(doc);} @@ -38,26 +61,6 @@ cur_frm.cscript.onload_post_render = function(doc, dt, dn) { cur_frm.cscript.dynamic_label(doc, dt, dn, callback); } -//========================== Refresh =============================================================== -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - cur_frm.clear_custom_buttons(); - - erpnext.hide_naming_series(); - if(doc.supplier) $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true); - else $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(false); - - if (!cur_frm.cscript.is_onload) cur_frm.cscript.dynamic_label(doc, cdt, cdn); - - if(doc.docstatus == 1){ - if (flt(doc.per_billed, 2) < 100) cur_frm.add_custom_button('Make Purchase Invoice', cur_frm.cscript['Make Purchase Invoice']); - cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']); - } - - if(wn.boot.control_panel.country == 'India') { - unhide_field(['challan_no', 'challan_date']); - } -} - //Supplier cur_frm.cscript.supplier = function(doc,dt,dn) { if (doc.supplier) { @@ -65,7 +68,6 @@ cur_frm.cscript.supplier = function(doc,dt,dn) { JSON.stringify({ supplier: doc.supplier }),'', doc, dt, dn, 1, function() { cur_frm.refresh(); }); - $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true); } } diff --git a/stock/doctype/purchase_receipt/purchase_receipt.txt b/stock/doctype/purchase_receipt/purchase_receipt.txt index 97104c84e1..8273dfe4ec 100755 --- a/stock/doctype/purchase_receipt/purchase_receipt.txt +++ b/stock/doctype/purchase_receipt/purchase_receipt.txt @@ -2,9 +2,9 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-12-03 17:56:26", + "creation": "2013-01-17 11:11:24", "modified_by": "Administrator", - "modified": "2013-01-15 15:43:07" + "modified": "2013-01-17 20:17:44" }, { "autoname": "naming_series:", @@ -222,26 +222,19 @@ }, { "print_hide": 1, - "print_width": "150px", - "oldfieldtype": "Currency", + "oldfieldtype": "Button", "doctype": "DocField", - "label": "Net Total", - "oldfieldname": "net_total", - "width": "150px", - "fieldname": "net_total", - "fieldtype": "Currency", - "reqd": 1, - "permlevel": 1 + "label": "Get Current Stock", + "options": "get_current_stock", + "fieldname": "get_current_stock", + "fieldtype": "Button", + "permlevel": 0 }, { - "print_hide": 1, - "oldfieldtype": "Currency", "doctype": "DocField", - "label": "Net Total (Import)", - "oldfieldname": "net_total_import", - "fieldname": "net_total_import", - "fieldtype": "Currency", - "permlevel": 1 + "fieldname": "column_break_18", + "fieldtype": "Column Break", + "permlevel": 0 }, { "oldfieldtype": "Button", @@ -252,48 +245,9 @@ "permlevel": 0 }, { - "print_hide": 1, - "oldfieldtype": "Button", "doctype": "DocField", - "label": "Get Current Stock", - "options": "get_current_stock", - "fieldname": "get_current_stock", - "fieldtype": "Button", - "permlevel": 0 - }, - { - "print_width": "50%", - "oldfieldtype": "Column Break", - "doctype": "DocField", - "width": "50%", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "print_hide": 1, - "description": "Supplier's currency", - "oldfieldtype": "Select", - "doctype": "DocField", - "label": "Currency", - "oldfieldname": "currency", - "options": "link:Currency", - "fieldname": "currency", - "fieldtype": "Select", - "reqd": 1, - "permlevel": 0 - }, - { - "print_hide": 1, - "description": "Rate at which supplier's currency is converted to company's base currency", - "default": "1.00", - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Conversion Rate", - "oldfieldname": "conversion_rate", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "reqd": 1, + "fieldname": "section_break_20", + "fieldtype": "Section Break", "permlevel": 0 }, { @@ -319,6 +273,71 @@ "fieldtype": "Button", "permlevel": 0 }, + { + "doctype": "DocField", + "label": "Currency & Price List", + "fieldname": "currency_price_list", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "print_hide": 1, + "description": "Supplier's currency", + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Currency", + "oldfieldname": "currency", + "options": "link:Currency", + "fieldname": "currency", + "fieldtype": "Select", + "reqd": 1, + "permlevel": 0 + }, + { + "print_hide": 1, + "description": "Rate at which supplier's currency is converted to company's base currency", + "default": "1.00", + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Exchange Rate", + "oldfieldname": "conversion_rate", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "reqd": 1, + "permlevel": 0 + }, + { + "print_width": "50%", + "oldfieldtype": "Column Break", + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Price List", + "options": "Price List", + "fieldname": "price_list_name", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Price List Currency", + "options": "Currency", + "fieldname": "price_list_currency", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Price List Exchange Rate", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "permlevel": 0 + }, { "description": "Add / Edit Taxes and Charges", "oldfieldtype": "Section Break", @@ -369,16 +388,6 @@ "fieldtype": "Button", "permlevel": 0 }, - { - "print_hide": 1, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Total Tax", - "oldfieldname": "total_tax", - "fieldname": "total_tax", - "fieldtype": "Currency", - "permlevel": 1 - }, { "print_hide": 1, "oldfieldtype": "HTML", @@ -397,6 +406,107 @@ "fieldtype": "Section Break", "permlevel": 0 }, + { + "print_hide": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Net Total (Import)", + "oldfieldname": "net_total_import", + "fieldname": "net_total_import", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Taxes and Charges Added (Import)", + "oldfieldname": "other_charges_added_import", + "fieldname": "other_charges_added_import", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Taxes and Charges Deducted (Import)", + "oldfieldname": "other_charges_deducted_import", + "fieldname": "other_charges_deducted_import", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Grand Total (Import)", + "oldfieldname": "grand_total_import", + "fieldname": "grand_total_import", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "In Words (Import)", + "oldfieldname": "in_words_import", + "fieldname": "in_words_import", + "fieldtype": "Data", + "permlevel": 1 + }, + { + "print_width": "50%", + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "print_hide": 1, + "print_width": "150px", + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Net Total", + "oldfieldname": "net_total", + "width": "150px", + "fieldname": "net_total", + "fieldtype": "Currency", + "reqd": 1, + "permlevel": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Taxes and Charges Added", + "oldfieldname": "other_charges_added", + "fieldname": "other_charges_added", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Taxes and Charges Deducted", + "oldfieldname": "other_charges_deducted", + "fieldname": "other_charges_deducted", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Total Tax", + "oldfieldname": "total_tax", + "fieldname": "total_tax", + "fieldtype": "Currency", + "permlevel": 1 + }, { "print_hide": 1, "oldfieldtype": "Currency", @@ -428,74 +538,6 @@ "fieldtype": "Data", "permlevel": 1 }, - { - "print_hide": 1, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Taxes and Charges Added", - "oldfieldname": "other_charges_added", - "fieldname": "other_charges_added", - "fieldtype": "Currency", - "permlevel": 1 - }, - { - "print_hide": 1, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Taxes and Charges Deducted", - "oldfieldname": "other_charges_deducted", - "fieldname": "other_charges_deducted", - "fieldtype": "Currency", - "permlevel": 1 - }, - { - "print_width": "50%", - "doctype": "DocField", - "width": "50%", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "print_hide": 1, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Grand Total (Import)", - "oldfieldname": "grand_total_import", - "fieldname": "grand_total_import", - "fieldtype": "Currency", - "permlevel": 1 - }, - { - "print_hide": 1, - "oldfieldtype": "Data", - "doctype": "DocField", - "label": "In Words (Import)", - "oldfieldname": "in_words_import", - "fieldname": "in_words_import", - "fieldtype": "Data", - "permlevel": 1 - }, - { - "print_hide": 1, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Taxes and Charges Added (Import)", - "oldfieldname": "other_charges_added_import", - "fieldname": "other_charges_added_import", - "fieldtype": "Currency", - "permlevel": 1 - }, - { - "print_hide": 1, - "oldfieldtype": "Currency", - "doctype": "DocField", - "label": "Taxes and Charges Deducted (Import)", - "oldfieldname": "other_charges_deducted_import", - "fieldname": "other_charges_deducted_import", - "fieldtype": "Currency", - "permlevel": 1 - }, { "description": "Add Terms and Conditions for the Purchase Receipt. You can also prepare a Terms and Conditions Master and use the Template.", "oldfieldtype": "Section Break", @@ -560,6 +602,12 @@ "fieldtype": "Link", "permlevel": 0 }, + { + "doctype": "DocField", + "fieldname": "column_break_57", + "fieldtype": "Column Break", + "permlevel": 0 + }, { "print_hide": 1, "doctype": "DocField", @@ -623,6 +671,7 @@ }, { "print_hide": 1, + "permlevel": 1, "print_width": "150px", "no_copy": 1, "oldfieldtype": "Data", @@ -633,22 +682,7 @@ "fieldname": "amended_from", "fieldtype": "Data", "hidden": 1, - "permlevel": 1 - }, - { - "print_hide": 1, - "description": "The date at which current entry is corrected in the system.", - "print_width": "100px", - "no_copy": 1, - "oldfieldtype": "Date", - "doctype": "DocField", - "label": "Amendment Date", - "oldfieldname": "amendment_date", - "width": "100px", - "fieldname": "amendment_date", - "fieldtype": "Date", - "hidden": 1, - "permlevel": 0 + "options": "Purchase Receipt" }, { "print_hide": 1,