diff --git a/.travis.yml b/.travis.yml index 73b758f72b2..4c5b1714a34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ install: - CFLAGS=-O0 pip install git+https://github.com/frappe/frappe.git@develop && - pip install --editable . -script: +script: cd ./test_sites/ && frappe --reinstall test_site && frappe --install_app erpnext test_site && diff --git a/MANIFEST.in b/MANIFEST.in index 7bf6b4dc441..1414d502cc0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,7 +3,6 @@ include requirements.txt include *.json include *.md include *.py -include *.txt recursive-include erpnext *.css recursive-include erpnext *.csv recursive-include erpnext *.html @@ -14,5 +13,4 @@ recursive-include erpnext *.md recursive-include erpnext *.png recursive-include erpnext *.py recursive-include erpnext *.svg -recursive-include erpnext *.txt recursive-exclude * *.pyc \ No newline at end of file diff --git a/erpnext/accounts/Print Format/Cheque Printing Format/Cheque Printing Format.json b/erpnext/accounts/Print Format/Cheque Printing Format/Cheque Printing Format.json new file mode 100755 index 00000000000..60088c91814 --- /dev/null +++ b/erpnext/accounts/Print Format/Cheque Printing Format/Cheque Printing Format.json @@ -0,0 +1,14 @@ +{ + "creation": "2012-04-11 13:16:56.000000", + "doc_type": "Journal Voucher", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n
\n



\n
\nPAYMENT ADVICE

\n\n\n\n\n\n\n\n
To :
\n\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Voucher No :\n\n
Voucher Date :\n\n
Cheque No :\n\n
Cheque Date :\n\n
\n
\n
We are pleased to enclose our cheque in full/part Settlement of your under noted bills
\n
\n\n\n\n\n\n\n\n\n\n\n\n
 Total :\n\n
Narration :\n\n


\n
Prepared By
\n
Authorised Signatory
\n
Received Payment as Above
\n
_____________
\n
A/c Payee
\n
_____________
\n
\n\n
\n
\n\n
\n
\n\n
\n
\n\n
\n
", + "idx": 1, + "modified": "2012-04-13 12:24:20.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Cheque Printing Format", + "owner": "Administrator", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/accounts/Print Format/Cheque Printing Format/Cheque Printing Format.txt b/erpnext/accounts/Print Format/Cheque Printing Format/Cheque Printing Format.txt deleted file mode 100755 index 19456a920ab..00000000000 --- a/erpnext/accounts/Print Format/Cheque Printing Format/Cheque Printing Format.txt +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2012-04-11 13:16:56", - "modified_by": "Administrator", - "modified": "2012-04-13 12:24:20" - }, - { - "doc_type": "Journal Voucher", - "name": "__common__", - "module": "Accounts", - "doctype": "Print Format", - "html": "\n
\n



\n
\nPAYMENT ADVICE

\n\n\n\n\n\n\n\n
To :
\n\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Voucher No :\n\n
Voucher Date :\n\n
Cheque No :\n\n
Cheque Date :\n\n
\n
\n
We are pleased to enclose our cheque in full/part Settlement of your under noted bills
\n
\n\n\n\n\n\n\n\n\n\n\n\n
 Total :\n\n
Narration :\n\n


\n
Prepared By
\n
Authorised Signatory
\n
Received Payment as Above
\n
_____________
\n
A/c Payee
\n
_____________
\n
\n\n
\n
\n\n
\n
\n\n
\n
\n\n
\n
", - "standard": "Yes" - }, - { - "name": "Cheque Printing Format", - "doctype": "Print Format" - } -] \ No newline at end of file diff --git a/erpnext/accounts/Print Format/POS Invoice/POS Invoice.json b/erpnext/accounts/Print Format/POS Invoice/POS Invoice.json new file mode 100644 index 00000000000..c251c90dd6a --- /dev/null +++ b/erpnext/accounts/Print Format/POS Invoice/POS Invoice.json @@ -0,0 +1,15 @@ +{ + "creation": "2011-12-21 11:08:55.000000", + "doc_type": "Sales Invoice", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\t\n\n\t\t\n\t\t\n\n\t\t\n\t\t\n\t\n\n\t\n\t\t\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\n", + "idx": 1, + "modified": "2014-01-27 17:26:10.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "POS Invoice", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/accounts/Print Format/POS Invoice/POS Invoice.txt b/erpnext/accounts/Print Format/POS Invoice/POS Invoice.txt deleted file mode 100644 index 4f20ac245b2..00000000000 --- a/erpnext/accounts/Print Format/POS Invoice/POS Invoice.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2011-12-21 11:08:55", - "docstatus": 0, - "modified": "2014-01-27 17:26:10", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Sales Invoice", - "doctype": "Print Format", - "html": "\n\t\n\n\t\t\n\t\t\n\n\t\t\n\t\t\n\t\n\n\t\n\t\t\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\n", - "module": "Accounts", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "POS Invoice" - } -] \ No newline at end of file diff --git a/erpnext/accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.json b/erpnext/accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.json new file mode 100755 index 00000000000..aacb31102ef --- /dev/null +++ b/erpnext/accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.json @@ -0,0 +1,14 @@ +{ + "creation": "2012-05-01 12:46:31.000000", + "doc_type": "Journal Voucher", + "docstatus": 0, + "doctype": "Print Format", + "html": "

\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n
Receipt No.:
Date :
Remark:
Received From:
\n
\n\n

\n

\n
\n\n\n\n\n

For ,


(Authorised Signatory)
", + "idx": 1, + "modified": "2013-01-21 18:40:20.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Payment Receipt Voucher", + "owner": "Administrator", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.txt b/erpnext/accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.txt deleted file mode 100755 index 73bc63b7902..00000000000 --- a/erpnext/accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.txt +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "creation": "2012-05-01 12:46:31", - "docstatus": 0, - "modified": "2013-01-21 18:40:20", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Journal Voucher", - "doctype": "Print Format", - "html": "

\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n
Receipt No.:
Date :
Remark:
Received From:
\n
\n\n

\n

\n
\n\n\n\n\n

For ,


(Authorised Signatory)
", - "module": "Accounts", - "name": "__common__", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Payment Receipt Voucher" - } -] \ No newline at end of file diff --git a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.json b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.json new file mode 100644 index 00000000000..795df9af8cf --- /dev/null +++ b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:30:27.000000", + "doc_type": "Sales Invoice", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:33:08.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Invoice Classic", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt deleted file mode 100644 index 5bf9bf32031..00000000000 --- a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:30:27", - "docstatus": 0, - "modified": "2014-02-11 17:33:08", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Sales Invoice", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Accounts", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Sales Invoice Classic" - } -] \ No newline at end of file diff --git a/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.json b/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.json new file mode 100644 index 00000000000..567da70e9fc --- /dev/null +++ b/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:30:27.000000", + "doc_type": "Sales Invoice", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:33:05.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Invoice Modern", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt b/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt deleted file mode 100644 index f36f4a588fc..00000000000 --- a/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:30:27", - "docstatus": 0, - "modified": "2014-02-11 17:33:05", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Sales Invoice", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Accounts", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Sales Invoice Modern" - } -] \ No newline at end of file diff --git a/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.json b/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.json new file mode 100644 index 00000000000..7c3de89f31c --- /dev/null +++ b/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:30:27.000000", + "doc_type": "Sales Invoice", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:34:00.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Invoice Spartan", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt b/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt deleted file mode 100644 index e60f8a099b7..00000000000 --- a/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:30:27", - "docstatus": 0, - "modified": "2014-02-11 17:34:00", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Sales Invoice", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Accounts", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Sales Invoice Spartan" - } -] \ No newline at end of file diff --git a/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.html b/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.html index d4a49ef503a..8dc39f94828 100644 --- a/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.html +++ b/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.html @@ -65,7 +65,7 @@ Basic Rate Amount - {%- for row in doclist.get({"doctype":"Sales Invoice Item"}) %} + {%- for row in doc.get({"doctype":"Sales Invoice Item"}) %} {{ row.idx }} {{ row.item_name }} @@ -106,7 +106,7 @@ utils.fmt_money(doc.net_total_export, currency=doc.currency) }} - {%- for charge in doclist.get({"doctype":"Sales Taxes and Charges"}) -%} + {%- for charge in doc.get({"doctype":"Sales Taxes and Charges"}) -%} {%- if not charge.included_in_print_rate -%} {{ charge.description }} diff --git a/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.json b/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.json new file mode 100644 index 00000000000..6c66cb869d9 --- /dev/null +++ b/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.json @@ -0,0 +1,13 @@ +{ + "creation": "2013-03-21 15:24:28.000000", + "doc_type": "Sales Invoice", + "docstatus": 0, + "doctype": "Print Format", + "idx": 1, + "modified": "2013-03-21 15:26:21.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "SalesInvoice", + "owner": "Administrator", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.txt b/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.txt deleted file mode 100644 index d2b1cdbaf47..00000000000 --- a/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.txt +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "creation": "2013-03-21 15:24:28", - "docstatus": 0, - "modified": "2013-03-21 15:26:21", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Sales Invoice", - "doctype": "Print Format", - "module": "Accounts", - "name": "__common__", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "SalesInvoice" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/account/account.js b/erpnext/accounts/doctype/account/account.js index 2577ccf88ba..76a1e56fe92 100644 --- a/erpnext/accounts/doctype/account/account.js +++ b/erpnext/accounts/doctype/account/account.js @@ -18,7 +18,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { if(doc.group_or_ledger=='Ledger') { frappe.model.with_doc("Accounts Settings", "Accounts Settings", function (name) { - var accounts_settings = frappe.model.get_doc("Accounts Settings", name); + var accounts_settings = frappe.get_doc("Accounts Settings", name); var display = accounts_settings["frozen_accounts_modifier"] && in_list(user_roles, accounts_settings["frozen_accounts_modifier"]); @@ -87,7 +87,7 @@ cur_frm.cscript.add_toolbar_buttons = function(doc) { } cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { - return $c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) { + return $c_obj(cur_frm.doc,'convert_group_to_ledger','',function(r,rt) { if(r.message == 1) { cur_frm.refresh(); } @@ -95,7 +95,7 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { } cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) { - return $c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) { + return $c_obj(cur_frm.doc,'convert_ledger_to_group','',function(r,rt) { if(r.message == 1) { cur_frm.refresh(); } diff --git a/erpnext/accounts/doctype/account/account.json b/erpnext/accounts/doctype/account/account.json new file mode 100644 index 00000000000..85ab439074d --- /dev/null +++ b/erpnext/accounts/doctype/account/account.json @@ -0,0 +1,326 @@ +{ + "allow_copy": 1, + "allow_rename": 1, + "creation": "2013-01-30 12:49:46.000000", + "description": "Heads (or groups) against which Accounting Entries are made and balances are maintained.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "properties", + "fieldtype": "Section Break", + "label": "Account Details", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "account_name", + "fieldtype": "Data", + "in_filter": 1, + "label": "Account Name", + "no_copy": 1, + "oldfieldname": "account_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "level", + "fieldtype": "Int", + "hidden": 1, + "label": "Level", + "oldfieldname": "level", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "default": "Ledger", + "fieldname": "group_or_ledger", + "fieldtype": "Select", + "in_filter": 1, + "label": "Group or Ledger", + "oldfieldname": "group_or_ledger", + "oldfieldtype": "Select", + "options": "\nLedger\nGroup", + "permlevel": 0, + "read_only": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "read_only": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "parent_account", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Parent Account", + "oldfieldname": "parent_account", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "report_type", + "fieldtype": "Select", + "label": "Report Type", + "options": "\nBalance Sheet\nProfit and Loss", + "permlevel": 0 + }, + { + "description": "Setting Account Type helps in selecting this Account in transactions.", + "fieldname": "account_type", + "fieldtype": "Select", + "in_filter": 1, + "label": "Account Type", + "oldfieldname": "account_type", + "oldfieldtype": "Select", + "options": "Bank\nCash\nTax\nChargeable\nWarehouse\nReceivable\nPayable\nEquity\nFixed Asset\nCost of Goods Sold\nExpense Account\nIncome Account\nStock Received But Not Billed\nExpenses Included In Valuation\nStock Adjustment", + "permlevel": 0, + "search_index": 0 + }, + { + "description": "Rate at which this tax is applied", + "fieldname": "tax_rate", + "fieldtype": "Float", + "hidden": 0, + "label": "Rate", + "oldfieldname": "tax_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 0 + }, + { + "description": "If the account is frozen, entries are allowed to restricted users.", + "fieldname": "freeze_account", + "fieldtype": "Select", + "label": "Frozen", + "oldfieldname": "freeze_account", + "oldfieldtype": "Select", + "options": "No\nYes", + "permlevel": 0 + }, + { + "fieldname": "credit_days", + "fieldtype": "Int", + "hidden": 1, + "label": "Credit Days", + "oldfieldname": "credit_days", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "credit_limit", + "fieldtype": "Currency", + "hidden": 1, + "label": "Credit Limit", + "oldfieldname": "credit_limit", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1 + }, + { + "description": "If this Account represents a Customer, Supplier or Employee, set it here.", + "fieldname": "master_type", + "fieldtype": "Select", + "label": "Master Type", + "oldfieldname": "master_type", + "oldfieldtype": "Select", + "options": "\nSupplier\nCustomer\nEmployee", + "permlevel": 0 + }, + { + "fieldname": "master_name", + "fieldtype": "Link", + "label": "Master Name", + "oldfieldname": "master_name", + "oldfieldtype": "Link", + "options": "[Select]", + "permlevel": 0 + }, + { + "fieldname": "balance_must_be", + "fieldtype": "Select", + "label": "Balance must be", + "options": "\nDebit\nCredit", + "permlevel": 0 + }, + { + "fieldname": "lft", + "fieldtype": "Int", + "hidden": 1, + "label": "Lft", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "rgt", + "fieldtype": "Int", + "hidden": 1, + "label": "Rgt", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "old_parent", + "fieldtype": "Data", + "hidden": 1, + "label": "Old Parent", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "icon": "icon-money", + "idx": 1, + "in_create": 1, + "modified": "2014-03-19 12:07:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Account", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Auditor", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "permlevel": 2, + "read": 1, + "report": 1, + "role": "Auditor", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "restrict": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "permlevel": 2, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "permlevel": 2, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 0, + "write": 0 + } + ], + "search_fields": "group_or_ledger" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 4c3e4d16820..59637a59793 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -3,26 +3,19 @@ from __future__ import unicode_literals import frappe - from frappe.utils import flt, fmt_money, cstr, cint from frappe import msgprint, throw, _ +from frappe.model.document import Document -get_value = frappe.db.get_value - -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl - self.nsm_parent_field = 'parent_account' +class Account(Document): + nsm_parent_field = 'parent_account' def autoname(self): - self.doc.name = self.doc.account_name.strip() + ' - ' + \ - frappe.db.get_value("Company", self.doc.company, "abbr") + self.name = self.account_name.strip() + ' - ' + \ + frappe.db.get_value("Company", self.company, "abbr") def get_address(self): - return { - 'address': frappe.db.get_value(self.doc.master_type, - self.doc.master_name, "address") - } + return {'address': frappe.db.get_value(self.master_type, self.master_name, "address")} def validate(self): self.validate_master_name() @@ -32,55 +25,49 @@ class DocType: self.validate_mandatory() self.validate_warehouse_account() self.validate_frozen_accounts_modifier() - - if not self.doc.parent_account: - self.doc.parent_account = '' def validate_master_name(self): - """Remind to add master name""" - if self.doc.master_type in ('Customer', 'Supplier') or self.doc.account_type == "Warehouse": - if not self.doc.master_name: + if self.master_type in ('Customer', 'Supplier') or self.account_type == "Warehouse": + if not self.master_name: msgprint(_("Please enter Master Name once the account is created.")) - elif not frappe.db.exists(self.doc.master_type or self.doc.account_type, - self.doc.master_name): + elif not frappe.db.exists(self.master_type or self.account_type, self.master_name): throw(_("Invalid Master Name")) def validate_parent(self): """Fetch Parent Details and validation for account not to be created under ledger""" - if self.doc.parent_account: - par = frappe.db.sql("""select name, group_or_ledger, report_type - from tabAccount where name =%s""", self.doc.parent_account, as_dict=1) + if self.parent_account: + par = frappe.db.get_value("Account", self.parent_account, + ["name", "group_or_ledger", "report_type"], as_dict=1) if not par: throw(_("Parent account does not exists")) - elif par[0]["name"] == self.doc.name: + elif par["name"] == self.name: throw(_("You can not assign itself as parent account")) - elif par[0]["group_or_ledger"] != 'Group': + elif par["group_or_ledger"] != 'Group': throw(_("Parent account can not be a ledger")) - if par[0]["report_type"]: - self.doc.report_type = par[0]["report_type"] + if par["report_type"]: + self.report_type = par["report_type"] def validate_duplicate_account(self): - if self.doc.fields.get('__islocal') or not self.doc.name: - company_abbr = frappe.db.get_value("Company", self.doc.company, "abbr") - if frappe.db.sql("""select name from tabAccount where name=%s""", - (self.doc.account_name + " - " + company_abbr)): - throw("{name}: {acc_name} {exist}, {rename}".format(**{ - "name": _("Account Name"), - "acc_name": self.doc.account_name, - "exist": _("already exists"), - "rename": _("please rename") - })) + if self.get('__islocal') or not self.name: + company_abbr = frappe.db.get_value("Company", self.company, "abbr") + if frappe.db.exists("Account", (self.account_name + " - " + company_abbr)): + throw("{name}: {acc_name} {exist}, {rename}".format(**{ + "name": _("Account Name"), + "acc_name": self.account_name, + "exist": _("already exists"), + "rename": _("please rename") + })) def validate_root_details(self): #does not exists parent - if frappe.db.exists("Account", self.doc.name): - if not frappe.db.get_value("Account", self.doc.name, "parent_account"): + if frappe.db.exists("Account", self.name): + if not frappe.db.get_value("Account", self.name, "parent_account"): throw(_("Root cannot be edited.")) def validate_frozen_accounts_modifier(self): - old_value = frappe.db.get_value("Account", self.doc.name, "freeze_account") - if old_value and old_value != self.doc.freeze_account: + old_value = frappe.db.get_value("Account", self.name, "freeze_account") + if old_value and old_value != self.freeze_account: frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None, 'frozen_accounts_modifier') if not frozen_accounts_modifier or \ @@ -91,50 +78,50 @@ class DocType: if self.check_if_child_exists(): throw("{acc}: {account_name} {child}. {msg}".format(**{ "acc": _("Account"), - "account_name": self.doc.name, + "account_name": self.name, "child": _("has existing child"), "msg": _("You can not convert this account to ledger") })) elif self.check_gle_exists(): throw(_("Account with existing transaction can not be converted to ledger.")) else: - self.doc.group_or_ledger = 'Ledger' - self.doc.save() + self.group_or_ledger = 'Ledger' + self.save() return 1 def convert_ledger_to_group(self): if self.check_gle_exists(): throw(_("Account with existing transaction can not be converted to group.")) - elif self.doc.master_type or self.doc.account_type: + elif self.master_type or self.account_type: throw(_("Cannot covert to Group because Master Type or Account Type is selected.")) else: - self.doc.group_or_ledger = 'Group' - self.doc.save() + self.group_or_ledger = 'Group' + self.save() return 1 # Check if any previous balance exists def check_gle_exists(self): - return frappe.db.get_value("GL Entry", {"account": self.doc.name}) + return frappe.db.get_value("GL Entry", {"account": self.name}) def check_if_child_exists(self): return frappe.db.sql("""select name from `tabAccount` where parent_account = %s - and docstatus != 2""", self.doc.name) + and docstatus != 2""", self.name) def validate_mandatory(self): - if not self.doc.report_type: + if not self.report_type: throw(_("Report Type is mandatory")) def validate_warehouse_account(self): if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): return - if self.doc.account_type == "Warehouse": - old_warehouse = cstr(frappe.db.get_value("Account", self.doc.name, "master_name")) - if old_warehouse != cstr(self.doc.master_name): + if self.account_type == "Warehouse": + old_warehouse = cstr(frappe.db.get_value("Account", self.name, "master_name")) + if old_warehouse != cstr(self.master_name): if old_warehouse: self.validate_warehouse(old_warehouse) - if self.doc.master_name: - self.validate_warehouse(self.doc.master_name) + if self.master_name: + self.validate_warehouse(self.master_name) else: throw(_("Master Name is mandatory if account type is Warehouse")) @@ -163,10 +150,10 @@ class DocType: credit_limit_from = 'Customer' cr_limit = frappe.db.sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2 - where t2.name=%s and t1.name = t2.master_name""", self.doc.name) + where t2.name=%s and t1.name = t2.master_name""", self.name) credit_limit = cr_limit and flt(cr_limit[0][0]) or 0 if not credit_limit: - credit_limit = frappe.db.get_value('Company', self.doc.company, 'credit_limit') + credit_limit = frappe.db.get_value('Company', self.company, 'credit_limit') credit_limit_from = 'Company' # If outstanding greater than credit limit and not authorized person raise exception @@ -175,11 +162,11 @@ class DocType: throw("""Total Outstanding amount (%s) for %s can not be \ greater than credit limit (%s). To change your credit limit settings, \ please update in the %s master""" % (fmt_money(total_outstanding), - self.doc.name, fmt_money(credit_limit), credit_limit_from)) + self.name, fmt_money(credit_limit), credit_limit_from)) def validate_trash(self): """checks gl entries and if child exists""" - if not self.doc.parent_account: + if not self.parent_account: throw(_("Root account can not be deleted")) if self.check_gle_exists(): @@ -195,7 +182,7 @@ class DocType: def before_rename(self, old, new, merge=False): # Add company abbr if not provided from erpnext.setup.doctype.company.company import get_name_with_abbr - new_account = get_name_with_abbr(new, self.doc.company) + new_account = get_name_with_abbr(new, self.company) # Validate properties before merging if merge: @@ -205,7 +192,7 @@ class DocType: val = list(frappe.db.get_value("Account", new_account, ["group_or_ledger", "report_type", "company"])) - if val != [self.doc.group_or_ledger, self.doc.report_type, self.doc.company]: + if val != [self.group_or_ledger, self.report_type, self.company]: throw(_("""Merging is only possible if following \ properties are same in both records. Group or Ledger, Report Type, Company""")) diff --git a/erpnext/accounts/doctype/account/account.txt b/erpnext/accounts/doctype/account/account.txt deleted file mode 100644 index 17d77f936a6..00000000000 --- a/erpnext/accounts/doctype/account/account.txt +++ /dev/null @@ -1,317 +0,0 @@ -[ - { - "creation": "2013-01-30 12:49:46", - "docstatus": 0, - "modified": "2014-03-19 12:07:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_copy": 1, - "allow_rename": 1, - "description": "Heads (or groups) against which Accounting Entries are made and balances are maintained.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-money", - "in_create": 1, - "module": "Accounts", - "name": "__common__", - "search_fields": "group_or_ledger" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Account", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Account", - "parentfield": "permissions", - "parenttype": "DocType", - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Account" - }, - { - "doctype": "DocField", - "fieldname": "properties", - "fieldtype": "Section Break", - "label": "Account Details", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "account_name", - "fieldtype": "Data", - "in_filter": 1, - "label": "Account Name", - "no_copy": 1, - "oldfieldname": "account_name", - "oldfieldtype": "Data", - "read_only": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "level", - "fieldtype": "Int", - "hidden": 1, - "label": "Level", - "oldfieldname": "level", - "oldfieldtype": "Int", - "print_hide": 1, - "read_only": 1 - }, - { - "default": "Ledger", - "doctype": "DocField", - "fieldname": "group_or_ledger", - "fieldtype": "Select", - "in_filter": 1, - "label": "Group or Ledger", - "oldfieldname": "group_or_ledger", - "oldfieldtype": "Select", - "options": "\nLedger\nGroup", - "read_only": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "read_only": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "parent_account", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Parent Account", - "oldfieldname": "parent_account", - "oldfieldtype": "Link", - "options": "Account", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "report_type", - "fieldtype": "Select", - "label": "Report Type", - "options": "\nBalance Sheet\nProfit and Loss" - }, - { - "description": "Setting Account Type helps in selecting this Account in transactions.", - "doctype": "DocField", - "fieldname": "account_type", - "fieldtype": "Select", - "in_filter": 1, - "label": "Account Type", - "oldfieldname": "account_type", - "oldfieldtype": "Select", - "options": "Bank\nCash\nTax\nChargeable\nWarehouse\nReceivable\nPayable\nEquity\nFixed Asset\nCost of Goods Sold\nExpense Account\nIncome Account\nStock Received But Not Billed\nExpenses Included In Valuation\nStock Adjustment", - "search_index": 0 - }, - { - "description": "Rate at which this tax is applied", - "doctype": "DocField", - "fieldname": "tax_rate", - "fieldtype": "Float", - "hidden": 0, - "label": "Rate", - "oldfieldname": "tax_rate", - "oldfieldtype": "Currency", - "reqd": 0 - }, - { - "description": "If the account is frozen, entries are allowed to restricted users.", - "doctype": "DocField", - "fieldname": "freeze_account", - "fieldtype": "Select", - "label": "Frozen", - "oldfieldname": "freeze_account", - "oldfieldtype": "Select", - "options": "No\nYes" - }, - { - "doctype": "DocField", - "fieldname": "credit_days", - "fieldtype": "Int", - "hidden": 1, - "label": "Credit Days", - "oldfieldname": "credit_days", - "oldfieldtype": "Int", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "credit_limit", - "fieldtype": "Currency", - "hidden": 1, - "label": "Credit Limit", - "oldfieldname": "credit_limit", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1 - }, - { - "description": "If this Account represents a Customer, Supplier or Employee, set it here.", - "doctype": "DocField", - "fieldname": "master_type", - "fieldtype": "Select", - "label": "Master Type", - "oldfieldname": "master_type", - "oldfieldtype": "Select", - "options": "\nSupplier\nCustomer\nEmployee" - }, - { - "doctype": "DocField", - "fieldname": "master_name", - "fieldtype": "Link", - "label": "Master Name", - "oldfieldname": "master_name", - "oldfieldtype": "Link", - "options": "[Select]" - }, - { - "doctype": "DocField", - "fieldname": "balance_must_be", - "fieldtype": "Select", - "label": "Balance must be", - "options": "\nDebit\nCredit" - }, - { - "doctype": "DocField", - "fieldname": "lft", - "fieldtype": "Int", - "hidden": 1, - "label": "Lft", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "rgt", - "fieldtype": "Int", - "hidden": 1, - "label": "Rgt", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "old_parent", - "fieldtype": "Data", - "hidden": 1, - "label": "Old Parent", - "print_hide": 1, - "read_only": 1 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "role": "Accounts User", - "write": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "role": "Auditor", - "write": 0 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "role": "Sales User", - "write": 0 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "role": "Purchase User", - "write": 0 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "permlevel": 2, - "role": "Auditor", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "export": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "restrict": 1, - "role": "Accounts Manager", - "write": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "permlevel": 2, - "role": "Accounts Manager", - "write": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "permlevel": 2, - "role": "Accounts User", - "write": 0 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/account/test_account.py b/erpnext/accounts/doctype/account/test_account.py index 10883d9ddee..37746299e6b 100644 --- a/erpnext/accounts/doctype/account/test_account.py +++ b/erpnext/accounts/doctype/account/test_account.py @@ -9,38 +9,39 @@ def _make_test_records(verbose): accounts = [ # [account_name, parent_account, group_or_ledger] - ["_Test Account Bank Account", "Bank Accounts", "Ledger"], + ["_Test Account Bank Account", "Bank Accounts", "Ledger", "Bank"], - ["_Test Account Stock Expenses", "Direct Expenses", "Group"], - ["_Test Account Shipping Charges", "_Test Account Stock Expenses", "Ledger"], - ["_Test Account Customs Duty", "_Test Account Stock Expenses", "Ledger"], + ["_Test Account Stock Expenses", "Direct Expenses", "Group", None], + ["_Test Account Shipping Charges", "_Test Account Stock Expenses", "Ledger", "Chargeable"], + ["_Test Account Customs Duty", "_Test Account Stock Expenses", "Ledger", "Tax"], - ["_Test Account Tax Assets", "Current Assets", "Group"], - ["_Test Account VAT", "_Test Account Tax Assets", "Ledger"], - ["_Test Account Service Tax", "_Test Account Tax Assets", "Ledger"], + ["_Test Account Tax Assets", "Current Assets", "Group", None], + ["_Test Account VAT", "_Test Account Tax Assets", "Ledger", "Tax"], + ["_Test Account Service Tax", "_Test Account Tax Assets", "Ledger", "Tax"], - ["_Test Account Reserves and Surplus", "Current Liabilities", "Ledger"], + ["_Test Account Reserves and Surplus", "Current Liabilities", "Ledger", None], - ["_Test Account Cost for Goods Sold", "Expenses", "Ledger"], - ["_Test Account Excise Duty", "_Test Account Tax Assets", "Ledger"], - ["_Test Account Education Cess", "_Test Account Tax Assets", "Ledger"], - ["_Test Account S&H Education Cess", "_Test Account Tax Assets", "Ledger"], - ["_Test Account CST", "Direct Expenses", "Ledger"], - ["_Test Account Discount", "Direct Expenses", "Ledger"], + ["_Test Account Cost for Goods Sold", "Expenses", "Ledger", None], + ["_Test Account Excise Duty", "_Test Account Tax Assets", "Ledger", "Tax"], + ["_Test Account Education Cess", "_Test Account Tax Assets", "Ledger", "Tax"], + ["_Test Account S&H Education Cess", "_Test Account Tax Assets", "Ledger", "Tax"], + ["_Test Account CST", "Direct Expenses", "Ledger", "Tax"], + ["_Test Account Discount", "Direct Expenses", "Ledger", None], # related to Account Inventory Integration - ["_Test Account Stock In Hand", "Current Assets", "Ledger"], - ["_Test Account Fixed Assets", "Current Assets", "Ledger"], + ["_Test Account Stock In Hand", "Current Assets", "Ledger", None], + ["_Test Account Fixed Assets", "Current Assets", "Ledger", None], ] for company, abbr in [["_Test Company", "_TC"], ["_Test Company 1", "_TC1"]]: - test_objects = make_test_objects("Account", [[{ + test_objects = make_test_objects("Account", [{ "doctype": "Account", "account_name": account_name, "parent_account": parent_account + " - " + abbr, "company": company, - "group_or_ledger": group_or_ledger - }] for account_name, parent_account, group_or_ledger in accounts]) + "group_or_ledger": group_or_ledger, + "account_type": account_type + } for account_name, parent_account, group_or_ledger, account_type in accounts]) return test_objects \ No newline at end of file diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json new file mode 100644 index 00000000000..942de750799 --- /dev/null +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -0,0 +1,66 @@ +{ + "creation": "2013-06-24 15:49:57.000000", + "description": "Settings for Accounts", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "default": "1", + "description": "If enabled, the system will post accounting entries for inventory automatically.", + "fieldname": "auto_accounting_for_stock", + "fieldtype": "Check", + "label": "Make Accounting Entry For Every Stock Movement", + "permlevel": 0 + }, + { + "description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.", + "fieldname": "acc_frozen_upto", + "fieldtype": "Date", + "label": "Accounts Frozen Upto", + "permlevel": 0 + }, + { + "description": "Users with this role are allowed to create / modify accounting entry before frozen date", + "fieldname": "bde_auth_role", + "fieldtype": "Link", + "label": "Allowed Role to Edit Entries Before Frozen Date", + "options": "Role", + "permlevel": 0 + }, + { + "description": "Users with this role are allowed to set frozen accounts and create / modify accounting entries against frozen accounts", + "fieldname": "frozen_accounts_modifier", + "fieldtype": "Link", + "label": "Frozen Accounts Modifier", + "options": "Role", + "permlevel": 0 + }, + { + "description": "Role that is allowed to submit transactions that exceed credit limits set.", + "fieldname": "credit_controller", + "fieldtype": "Link", + "label": "Credit Controller", + "options": "Role", + "permlevel": 0 + } + ], + "icon": "icon-cog", + "idx": 1, + "issingle": 1, + "modified": "2013-12-20 19:22:52.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Accounts Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "Accounts Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py index 3e01eea710e..b7288e0469e 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -7,18 +7,16 @@ from __future__ import unicode_literals import frappe from frappe import _ from frappe.utils import cint +from frappe.model.document import Document -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - +class AccountsSettings(Document): def on_update(self): - frappe.db.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock) + frappe.db.set_default("auto_accounting_for_stock", self.auto_accounting_for_stock) - if cint(self.doc.auto_accounting_for_stock): + if cint(self.auto_accounting_for_stock): # set default perpetual account in company for company in frappe.db.sql("select name from tabCompany"): - frappe.bean("Company", company[0]).save() + frappe.get_doc("Company", company[0]).save() # Create account head for warehouses warehouse_list = frappe.db.sql("select name, company from tabWarehouse", as_dict=1) @@ -27,5 +25,5 @@ class DocType: frappe.throw(_("Company is missing in following warehouses") + ": \n" + "\n".join(warehouse_with_no_company)) for wh in warehouse_list: - wh_bean = frappe.bean("Warehouse", wh.name) - wh_bean.save() \ No newline at end of file + wh_doc = frappe.get_doc("Warehouse", wh.name) + wh_doc.save() \ No newline at end of file diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.txt b/erpnext/accounts/doctype/accounts_settings/accounts_settings.txt deleted file mode 100644 index f36e21840dd..00000000000 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.txt +++ /dev/null @@ -1,85 +0,0 @@ -[ - { - "creation": "2013-06-24 15:49:57", - "docstatus": 0, - "modified": "2013-12-20 19:22:52", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Settings for Accounts", - "doctype": "DocType", - "icon": "icon-cog", - "issingle": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Accounts Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Accounts Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "role": "Accounts Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Accounts Settings" - }, - { - "default": "1", - "description": "If enabled, the system will post accounting entries for inventory automatically.", - "doctype": "DocField", - "fieldname": "auto_accounting_for_stock", - "fieldtype": "Check", - "label": "Make Accounting Entry For Every Stock Movement" - }, - { - "description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.", - "doctype": "DocField", - "fieldname": "acc_frozen_upto", - "fieldtype": "Date", - "label": "Accounts Frozen Upto" - }, - { - "description": "Users with this role are allowed to create / modify accounting entry before frozen date", - "doctype": "DocField", - "fieldname": "bde_auth_role", - "fieldtype": "Link", - "label": "Allowed Role to Edit Entries Before Frozen Date", - "options": "Role" - }, - { - "description": "Users with this role are allowed to set frozen accounts and create / modify accounting entries against frozen accounts", - "doctype": "DocField", - "fieldname": "frozen_accounts_modifier", - "fieldtype": "Link", - "label": "Frozen Accounts Modifier", - "options": "Role" - }, - { - "description": "Role that is allowed to submit transactions that exceed credit limits set.", - "doctype": "DocField", - "fieldname": "credit_controller", - "fieldtype": "Link", - "label": "Credit Controller", - "options": "Role" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json new file mode 100644 index 00000000000..eff6e6d5cfb --- /dev/null +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json @@ -0,0 +1,96 @@ +{ + "allow_copy": 1, + "allow_email": 1, + "allow_print": 1, + "creation": "2013-01-10 16:34:05.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Select account head of the bank where cheque was deposited.", + "fieldname": "bank_account", + "fieldtype": "Link", + "label": "Bank Account", + "options": "Account", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "hidden": 1, + "label": "Company", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "reqd": 0 + }, + { + "fieldname": "from_date", + "fieldtype": "Date", + "label": "From Date", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "to_date", + "fieldtype": "Date", + "label": "To Date", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "get_non_reconciled_entries", + "fieldtype": "Button", + "label": "Get Non Reconciled Entries", + "options": "get_details", + "permlevel": 0 + }, + { + "fieldname": "entries", + "fieldtype": "Table", + "label": "Entries", + "options": "Bank Reconciliation Detail", + "permlevel": 0 + }, + { + "fieldname": "update_clearance_date", + "fieldtype": "Button", + "label": "Update Clearance Date", + "options": "update_details", + "permlevel": 0 + }, + { + "fieldname": "total_amount", + "fieldtype": "Currency", + "label": "Total Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + } + ], + "hide_heading": 1, + "hide_toolbar": 1, + "icon": "icon-check", + "idx": 1, + "issingle": 1, + "modified": "2013-07-05 14:26:22.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Bank Reconciliation", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "permlevel": 0, + "read": 1, + "report": 0, + "role": "Accounts User", + "submit": 0, + "write": 1 + } + ], + "read_only": 1 +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index 859c9d00c43..dc7d57becbe 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -3,32 +3,31 @@ from __future__ import unicode_literals import frappe +from frappe.utils import cstr, flt, getdate, nowdate +from frappe import msgprint, _ +from frappe.model.document import Document -from frappe.utils import cstr, flt, getdate, now, nowdate -from frappe.model import db_exists -from frappe.model.doc import addchild -from frappe.model.bean import getlist, copy_doclist -from frappe import msgprint - - - - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - +class BankReconciliation(Document): def get_details(self): - if not (self.doc.bank_account and self.doc.from_date and self.doc.to_date): + if not (self.bank_account and self.from_date and self.to_date): msgprint("Bank Account, From Date and To Date are Mandatory") return - dl = frappe.db.sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date)) + dl = frappe.db.sql("""select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, + t2.credit, t1.posting_date, t2.against_account + from + `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 + where + t2.parent = t1.name and t2.account = %s + and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') + and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1""", + (self.bank_account, self.from_date, self.to_date)) - self.doclist = self.doc.clear_table(self.doclist, 'entries') - self.doc.total_amount = 0.0 + self.set('entries', []) + self.total_amount = 0.0 for d in dl: - nl = addchild(self.doc, 'entries', 'Bank Reconciliation Detail', self.doclist) + nl = self.append('entries', {}) nl.posting_date = cstr(d[5]) nl.voucher_id = cstr(d[0]) nl.cheque_number = cstr(d[1]) @@ -36,22 +35,21 @@ class DocType: nl.debit = flt(d[3]) nl.credit = flt(d[4]) nl.against_account = cstr(d[6]) - self.doc.total_amount += flt(flt(d[4]) - flt(d[3])) + self.total_amount += flt(flt(d[4]) - flt(d[3])) def update_details(self): vouchers = [] - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.clearance_date: if d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_date): - msgprint("Clearance Date can not be before Cheque Date (Row #%s)" % - d.idx, raise_exception=1) + frappe.throw("Clearance Date can not be before Cheque Date (Row #%s)" % d.idx) - frappe.db.sql("""update `tabJournal Voucher` - set clearance_date = %s, modified = %s where name=%s""", - (d.clearance_date, nowdate(), d.voucher_id)) + frappe.db.set_value("Journal Voucher", d.voucher_id, "clearance_date", d.clearance_date) + frappe.db.sql("""update `tabJournal Voucher` set clearance_date = %s, modified = %s + where name=%s""", (d.clearance_date, nowdate(), d.voucher_id)) vouchers.append(d.voucher_id) if vouchers: msgprint("Clearance Date updated in %s" % ", ".join(vouchers)) else: - msgprint("Clearance Date not mentioned") \ No newline at end of file + msgprint(_("Clearance Date not mentioned")) \ No newline at end of file diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.txt b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.txt deleted file mode 100644 index 3cd385b4939..00000000000 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.txt +++ /dev/null @@ -1,115 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:05", - "docstatus": 0, - "modified": "2013-07-05 14:26:22", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_copy": 1, - "allow_email": 1, - "allow_print": 1, - "doctype": "DocType", - "hide_heading": 1, - "hide_toolbar": 1, - "icon": "icon-check", - "issingle": 1, - "module": "Accounts", - "name": "__common__", - "read_only": 1 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Bank Reconciliation", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Bank Reconciliation", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 0, - "role": "Accounts User", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Bank Reconciliation" - }, - { - "description": "Select account head of the bank where cheque was deposited.", - "doctype": "DocField", - "fieldname": "bank_account", - "fieldtype": "Link", - "label": "Bank Account", - "options": "Account", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "hidden": 1, - "label": "Company", - "options": "Company", - "print_hide": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "from_date", - "fieldtype": "Date", - "label": "From Date", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "to_date", - "fieldtype": "Date", - "label": "To Date", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "get_non_reconciled_entries", - "fieldtype": "Button", - "label": "Get Non Reconciled Entries", - "options": "get_details" - }, - { - "doctype": "DocField", - "fieldname": "entries", - "fieldtype": "Table", - "label": "Entries", - "options": "Bank Reconciliation Detail" - }, - { - "doctype": "DocField", - "fieldname": "update_clearance_date", - "fieldtype": "Button", - "label": "Update Clearance Date", - "options": "update_details" - }, - { - "doctype": "DocField", - "fieldname": "total_amount", - "fieldtype": "Currency", - "label": "Total Amount", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.json b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.json new file mode 100644 index 00000000000..250dc451269 --- /dev/null +++ b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.json @@ -0,0 +1,109 @@ +{ + "creation": "2013-02-22 01:27:37.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "voucher_id", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Voucher ID", + "no_copy": 0, + "oldfieldname": "voucher_id", + "oldfieldtype": "Link", + "options": "Journal Voucher", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "against_account", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Against Account", + "no_copy": 0, + "oldfieldname": "against_account", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "posting_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Posting Date", + "no_copy": 0, + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "clearance_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Clearance Date", + "no_copy": 0, + "oldfieldname": "clearance_date", + "oldfieldtype": "Date", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "cheque_number", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Cheque Number", + "no_copy": 0, + "oldfieldname": "cheque_number", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "cheque_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Cheque Date", + "no_copy": 0, + "oldfieldname": "cheque_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "debit", + "fieldtype": "Currency", + "label": "Debit", + "no_copy": 0, + "oldfieldname": "debit", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "credit", + "fieldtype": "Currency", + "label": "Credit", + "no_copy": 0, + "oldfieldname": "credit", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:22:55.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Bank Reconciliation Detail", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py index 26c87f1c04a..9be696cb0d3 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py +++ b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import frappe +from frappe.model.document import Document -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +class BankReconciliationDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.txt b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.txt deleted file mode 100644 index 47ff4f1344a..00000000000 --- a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.txt +++ /dev/null @@ -1,108 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:37", - "docstatus": 0, - "modified": "2013-12-20 19:22:55", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "no_copy": 0, - "parent": "Bank Reconciliation Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "search_index": 0 - }, - { - "doctype": "DocType", - "name": "Bank Reconciliation Detail" - }, - { - "doctype": "DocField", - "fieldname": "voucher_id", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Voucher ID", - "oldfieldname": "voucher_id", - "oldfieldtype": "Link", - "options": "Journal Voucher" - }, - { - "doctype": "DocField", - "fieldname": "against_account", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Against Account", - "oldfieldname": "against_account", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "in_list_view": 1, - "label": "Posting Date", - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "clearance_date", - "fieldtype": "Date", - "in_list_view": 1, - "label": "Clearance Date", - "oldfieldname": "clearance_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "cheque_number", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Cheque Number", - "oldfieldname": "cheque_number", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "cheque_date", - "fieldtype": "Date", - "in_list_view": 1, - "label": "Cheque Date", - "oldfieldname": "cheque_date", - "oldfieldtype": "Date", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "debit", - "fieldtype": "Currency", - "label": "Debit", - "oldfieldname": "debit", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "credit", - "fieldtype": "Currency", - "label": "Credit", - "oldfieldname": "credit", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_detail/budget_detail.json b/erpnext/accounts/doctype/budget_detail/budget_detail.json new file mode 100644 index 00000000000..f8a969c0977 --- /dev/null +++ b/erpnext/accounts/doctype/budget_detail/budget_detail.json @@ -0,0 +1,52 @@ +{ + "autoname": "CBD/.######", + "creation": "2013-03-07 11:55:04.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "account", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Account", + "oldfieldname": "account", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "budget_allocated", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Budget Allocated", + "oldfieldname": "budget_allocated", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:22:59.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Budget Detail", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_detail/budget_detail.py b/erpnext/accounts/doctype/budget_detail/budget_detail.py index 26c87f1c04a..ff4f8867f7d 100644 --- a/erpnext/accounts/doctype/budget_detail/budget_detail.py +++ b/erpnext/accounts/doctype/budget_detail/budget_detail.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import frappe +from frappe.model.document import Document -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +class BudgetDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_detail/budget_detail.txt b/erpnext/accounts/doctype/budget_detail/budget_detail.txt deleted file mode 100644 index 31312c92083..00000000000 --- a/erpnext/accounts/doctype/budget_detail/budget_detail.txt +++ /dev/null @@ -1,61 +0,0 @@ -[ - { - "creation": "2013-03-07 11:55:04", - "docstatus": 0, - "modified": "2013-12-20 19:22:59", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "CBD/.######", - "doctype": "DocType", - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Budget Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocType", - "name": "Budget Detail" - }, - { - "doctype": "DocField", - "fieldname": "account", - "fieldtype": "Link", - "in_filter": 1, - "label": "Account", - "oldfieldname": "account", - "oldfieldtype": "Link", - "options": "Account", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "budget_allocated", - "fieldtype": "Currency", - "label": "Budget Allocated", - "oldfieldname": "budget_allocated", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "search_index": 1 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.js b/erpnext/accounts/doctype/budget_distribution/budget_distribution.js index c2563741a43..3c11d874a48 100644 --- a/erpnext/accounts/doctype/budget_distribution/budget_distribution.js +++ b/erpnext/accounts/doctype/budget_distribution/budget_distribution.js @@ -7,8 +7,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){ refresh_field('budget_distribution_details'); } - return $c('runserverobj',args={'method' : 'get_months', 'docs' : - frappe.model.compress(make_doclist(doc.doctype, doc.name))},callback1); + return $c('runserverobj',args={'method':'get_months', 'docs':doc}, callback1); } } diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.json b/erpnext/accounts/doctype/budget_distribution/budget_distribution.json new file mode 100644 index 00000000000..2bad58978e4 --- /dev/null +++ b/erpnext/accounts/doctype/budget_distribution/budget_distribution.json @@ -0,0 +1,81 @@ +{ + "autoname": "field:distribution_id", + "creation": "2013-01-10 16:34:05.000000", + "description": "**Budget Distribution** helps you distribute your budget across months if you have seasonality in your business.\n\nTo distribute a budget using this distribution, set this **Budget Distribution** in the **Cost Center**", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Name of the Budget Distribution", + "fieldname": "distribution_id", + "fieldtype": "Data", + "label": "Distribution Name", + "oldfieldname": "distribution_id", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "budget_distribution_details", + "fieldtype": "Table", + "label": "Budget Distribution Details", + "oldfieldname": "budget_distribution_details", + "oldfieldtype": "Table", + "options": "Budget Distribution Detail", + "permlevel": 0 + }, + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-bar-chart", + "idx": 1, + "modified": "2014-01-20 17:48:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Budget Distribution", + "name_case": "Title Case", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "delete": 0, + "permlevel": 2, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0 + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.py b/erpnext/accounts/doctype/budget_distribution/budget_distribution.py index 51730976668..2cc5015c4dc 100644 --- a/erpnext/accounts/doctype/budget_distribution/budget_distribution.py +++ b/erpnext/accounts/doctype/budget_distribution/budget_distribution.py @@ -3,30 +3,23 @@ from __future__ import unicode_literals import frappe - from frappe.utils import flt -from frappe.model.doc import addchild -from frappe.model.bean import getlist -from frappe import msgprint, _ +from frappe import _ +from frappe.model.document import Document -class DocType: - def __init__(self,doc,doclist=[]): - self.doc,self.doclist = doc,doclist - +class BudgetDistribution(Document): def get_months(self): month_list = ['January','February','March','April','May','June','July','August','September', 'October','November','December'] idx =1 for m in month_list: - mnth = addchild(self.doc, 'budget_distribution_details', - 'Budget Distribution Detail', self.doclist) - mnth.month = m or '' + mnth = self.append('budget_distribution_details') + mnth.month = m mnth.idx = idx idx += 1 def validate(self): - total = sum([flt(d.percentage_allocation, 2) for d in self.doclist.get( - {"parentfield": "budget_distribution_details"})]) + total = sum([flt(d.percentage_allocation) for d in self.get("budget_distribution_details")]) if total != 100.0: - msgprint(_("Percentage Allocation should be equal to ") + "100%", raise_exception=1) \ No newline at end of file + frappe.throw(_("Percentage Allocation should be equal to ") + "100%") \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.txt b/erpnext/accounts/doctype/budget_distribution/budget_distribution.txt deleted file mode 100644 index 48d6e7b54a7..00000000000 --- a/erpnext/accounts/doctype/budget_distribution/budget_distribution.txt +++ /dev/null @@ -1,96 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:05", - "docstatus": 0, - "modified": "2014-01-20 17:48:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "field:distribution_id", - "description": "**Budget Distribution** helps you distribute your budget across months if you have seasonality in your business.\n\nTo distribute a budget using this distribution, set this **Budget Distribution** in the **Cost Center**", - "doctype": "DocType", - "icon": "icon-bar-chart", - "module": "Accounts", - "name": "__common__", - "name_case": "Title Case" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Budget Distribution", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Budget Distribution", - "parentfield": "permissions", - "parenttype": "DocType", - "read": 1, - "report": 1, - "role": "Accounts Manager", - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Budget Distribution" - }, - { - "description": "Name of the Budget Distribution", - "doctype": "DocField", - "fieldname": "distribution_id", - "fieldtype": "Data", - "label": "Distribution Name", - "oldfieldname": "distribution_id", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "budget_distribution_details", - "fieldtype": "Table", - "label": "Budget Distribution Details", - "oldfieldname": "budget_distribution_details", - "oldfieldtype": "Table", - "options": "Budget Distribution Detail" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "amend": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "write": 1 - }, - { - "delete": 0, - "doctype": "DocPerm", - "permlevel": 2 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_distribution/test_budget_distribution.py b/erpnext/accounts/doctype/budget_distribution/test_budget_distribution.py index 15b60db9965..4626bae4db8 100644 --- a/erpnext/accounts/doctype/budget_distribution/test_budget_distribution.py +++ b/erpnext/accounts/doctype/budget_distribution/test_budget_distribution.py @@ -1,70 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Budget Distribution", - "distribution_id": "_Test Distribution", - "fiscal_year": "_Test Fiscal Year 2013", - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "January", - "percentage_allocation": "8" - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "February", - "percentage_allocation": "8" - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "March", - "percentage_allocation": "8" - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "April", - "percentage_allocation": "8" - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "May", - "percentage_allocation": "8" - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "June", - "percentage_allocation": "8" - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "July", - "percentage_allocation": "8" - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "August", - "percentage_allocation": "8" - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "September", - "percentage_allocation": "8" - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "October", - "percentage_allocation": "8" - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "November", - "percentage_allocation": "10" - }, { - "doctype": "Budget Distribution Detail", - "parentfield": "budget_distribution_details", - "month": "December", - "percentage_allocation": "10" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Budget Distribution') \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_distribution/test_records.json b/erpnext/accounts/doctype/budget_distribution/test_records.json new file mode 100644 index 00000000000..7e8c640dd74 --- /dev/null +++ b/erpnext/accounts/doctype/budget_distribution/test_records.json @@ -0,0 +1,44 @@ +[{ + "doctype": "Budget Distribution", + "distribution_id": "_Test Distribution", + "fiscal_year": "_Test Fiscal Year 2013", + "budget_distribution_details": [ + { + "month": "January", + "percentage_allocation": "8" + }, { + "month": "February", + "percentage_allocation": "8" + }, { + "month": "March", + "percentage_allocation": "8" + }, { + "month": "April", + "percentage_allocation": "8" + }, { + "month": "May", + "percentage_allocation": "8" + }, { + "month": "June", + "percentage_allocation": "8" + }, { + "month": "July", + "percentage_allocation": "8" + }, { + "month": "August", + "percentage_allocation": "8" + }, { + "month": "September", + "percentage_allocation": "8" + }, { + "month": "October", + "percentage_allocation": "8" + }, { + "month": "November", + "percentage_allocation": "10" + }, { + "month": "December", + "percentage_allocation": "10" + } + ] +}] diff --git a/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.json b/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.json new file mode 100644 index 00000000000..aa4f2aedc27 --- /dev/null +++ b/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.json @@ -0,0 +1,35 @@ +{ + "autoname": "BDD/.#####", + "creation": "2013-02-22 01:27:38.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "month", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Month", + "oldfieldname": "month", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "percentage_allocation", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Percentage Allocation", + "oldfieldname": "percentage_allocation", + "oldfieldtype": "Currency", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:22:59.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Budget Distribution Detail", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py b/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py index 26c87f1c04a..87d38fd36ad 100644 --- a/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py +++ b/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import frappe +from frappe.model.document import Document -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +class BudgetDistributionDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.txt b/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.txt deleted file mode 100644 index a171bf69cc1..00000000000 --- a/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.txt +++ /dev/null @@ -1,47 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:38", - "docstatus": 0, - "modified": "2013-12-20 19:22:59", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "BDD/.#####", - "doctype": "DocType", - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Budget Distribution Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Budget Distribution Detail" - }, - { - "doctype": "DocField", - "fieldname": "month", - "fieldtype": "Data", - "label": "Month", - "oldfieldname": "month", - "oldfieldtype": "Data", - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "percentage_allocation", - "fieldtype": "Float", - "label": "Percentage Allocation", - "oldfieldname": "percentage_allocation", - "oldfieldtype": "Currency" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/c_form/c_form.json b/erpnext/accounts/doctype/c_form/c_form.json new file mode 100644 index 00000000000..06c56d2767e --- /dev/null +++ b/erpnext/accounts/doctype/c_form/c_form.json @@ -0,0 +1,178 @@ +{ + "allow_attach": 1, + "autoname": "naming_series:", + "creation": "2013-03-07 11:55:06.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "options": "\nC-FORM/", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "c_form_no", + "fieldtype": "Data", + "label": "C-Form No", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "received_date", + "fieldtype": "Date", + "label": "Received Date", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "label": "Customer", + "options": "Customer", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "company", + "fieldtype": "Select", + "label": "Company", + "options": "link:Company", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "label": "Fiscal Year", + "options": "link:Fiscal Year", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "quarter", + "fieldtype": "Select", + "label": "Quarter", + "options": "\nI\nII\nIII\nIV", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "total_amount", + "fieldtype": "Currency", + "label": "Total Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "state", + "fieldtype": "Data", + "label": "State", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "section_break0", + "fieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "invoice_details", + "fieldtype": "Table", + "label": "Invoice Details", + "options": "C-Form Invoice Detail", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "total_invoiced_amount", + "fieldtype": "Currency", + "label": "Total Invoiced Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "options": "C-Form", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "icon": "icon-file-text", + "idx": 1, + "is_submittable": 1, + "max_attachments": 3, + "modified": "2013-12-20 19:23:58.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "C-Form", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 0, + "write": 1 + }, + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "permlevel": 1, + "read": 1, + "report": 1, + "role": "All", + "submit": 0 + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/c_form/c_form.py b/erpnext/accounts/doctype/c_form/c_form.py index fdf8b30ebb0..95e2e4060f0 100644 --- a/erpnext/accounts/doctype/c_form/c_form.py +++ b/erpnext/accounts/doctype/c_form/c_form.py @@ -3,35 +3,32 @@ from __future__ import unicode_literals import frappe -from frappe.utils import flt, getdate -from frappe.model.bean import getlist - -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl +from frappe.utils import flt +from frappe import _ +from frappe.model.document import Document +class CForm(Document): def validate(self): """Validate invoice that c-form is applicable and no other c-form is received for that""" - for d in getlist(self.doclist, 'invoice_details'): + for d in self.get('invoice_details'): if d.invoice_no: inv = frappe.db.sql("""select c_form_applicable, c_form_no from `tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no) if not inv: - frappe.msgprint("""Invoice: %s is not exists in the system or - is not submitted, please check.""" % d.invoice_no, raise_exception=1) + frappe.throw("""Invoice: %s is not exists in the system or + is not submitted, please check.""" % d.invoice_no) elif inv[0][0] != 'Yes': - frappe.msgprint("C-form is not applicable for Invoice: %s" % - d.invoice_no, raise_exception=1) + frappe.throw("C-form is not applicable for Invoice: %s" % d.invoice_no) - elif inv[0][1] and inv[0][1] != self.doc.name: - frappe.msgprint("""Invoice %s is tagged in another C-form: %s. + elif inv[0][1] and inv[0][1] != self.name: + frappe.throw("""Invoice %s is tagged in another C-form: %s. If you want to change C-form no for this invoice, please remove invoice no from the previous c-form and then try again""" % - (d.invoice_no, inv[0][1]), raise_exception=1) + (d.invoice_no, inv[0][1])) def on_update(self): """ Update C-Form No on invoices""" @@ -42,37 +39,34 @@ class DocType: def before_cancel(self): # remove cform reference - frappe.db.sql("""update `tabSales Invoice` set c_form_no=null - where c_form_no=%s""", self.doc.name) + frappe.db.sql("""update `tabSales Invoice` set c_form_no=null where c_form_no=%s""", self.name) def set_cform_in_sales_invoices(self): - inv = [d.invoice_no for d in getlist(self.doclist, 'invoice_details')] + inv = [d.invoice_no for d in self.get('invoice_details')] if inv: - frappe.db.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s - where name in (%s)""" % ('%s', '%s', ', '.join(['%s'] * len(inv))), - tuple([self.doc.name, self.doc.modified] + inv)) + frappe.db.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s where name in (%s)""" % + ('%s', '%s', ', '.join(['%s'] * len(inv))), tuple([self.name, self.modified] + inv)) frappe.db.sql("""update `tabSales Invoice` set c_form_no = null, modified = %s where name not in (%s) and ifnull(c_form_no, '') = %s""" % - ('%s', ', '.join(['%s']*len(inv)), '%s'), - tuple([self.doc.modified] + inv + [self.doc.name])) + ('%s', ', '.join(['%s']*len(inv)), '%s'), tuple([self.modified] + inv + [self.name])) else: - frappe.msgprint("Please enter atleast 1 invoice in the table", raise_exception=1) + frappe.throw(_("Please enter atleast 1 invoice in the table")) def set_total_invoiced_amount(self): - total = sum([flt(d.grand_total) for d in getlist(self.doclist, 'invoice_details')]) - frappe.db.set(self.doc, 'total_invoiced_amount', total) + total = sum([flt(d.grand_total) for d in self.get('invoice_details')]) + frappe.db.set(self, 'total_invoiced_amount', total) def get_invoice_details(self, invoice_no): """ Pull details from invoices for referrence """ - inv = frappe.db.sql("""select posting_date, territory, net_total, grand_total - from `tabSales Invoice` where name = %s""", invoice_no) + inv = frappe.db.get_value("Sales Invoice", invoice_no, + ["posting_date", "territory", "net_total", "grand_total"], as_dict=True) return { - 'invoice_date' : inv and getdate(inv[0][0]).strftime('%Y-%m-%d') or '', - 'territory' : inv and inv[0][1] or '', - 'net_total' : inv and flt(inv[0][2]) or '', - 'grand_total' : inv and flt(inv[0][3]) or '' + 'invoice_date' : inv.posting_date, + 'territory' : inv.territory, + 'net_total' : inv.net_total, + 'grand_total' : inv.grand_total } def get_invoice_nos(doctype, txt, searchfield, start, page_len, filters): diff --git a/erpnext/accounts/doctype/c_form/c_form.txt b/erpnext/accounts/doctype/c_form/c_form.txt deleted file mode 100644 index d5ff32b33b5..00000000000 --- a/erpnext/accounts/doctype/c_form/c_form.txt +++ /dev/null @@ -1,193 +0,0 @@ -[ - { - "creation": "2013-03-07 11:55:06", - "docstatus": 0, - "modified": "2013-12-20 19:23:58", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "icon": "icon-file-text", - "is_submittable": 1, - "max_attachments": 3, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "C-Form", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "C-Form", - "parentfield": "permissions", - "parenttype": "DocType", - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "C-Form" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "options": "\nC-FORM/", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "c_form_no", - "fieldtype": "Data", - "label": "C-Form No", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "received_date", - "fieldtype": "Date", - "label": "Received Date", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "label": "Customer", - "options": "Customer", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "label": "Company", - "options": "link:Company", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "label": "Fiscal Year", - "options": "link:Fiscal Year", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "quarter", - "fieldtype": "Select", - "label": "Quarter", - "options": "\nI\nII\nIII\nIV", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "total_amount", - "fieldtype": "Currency", - "label": "Total Amount", - "options": "Company:company:default_currency", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "state", - "fieldtype": "Data", - "label": "State", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "invoice_details", - "fieldtype": "Table", - "label": "Invoice Details", - "options": "C-Form Invoice Detail", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "total_invoiced_amount", - "fieldtype": "Currency", - "label": "Total Invoiced Amount", - "options": "Company:company:default_currency", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "options": "C-Form", - "print_hide": 1, - "read_only": 1 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "role": "Accounts User", - "write": 1 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "role": "Accounts Manager", - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "All" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.json b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.json new file mode 100644 index 00000000000..37b63b7b68d --- /dev/null +++ b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.json @@ -0,0 +1,68 @@ +{ + "creation": "2013-02-22 01:27:38.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "invoice_no", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Invoice No", + "options": "Sales Invoice", + "permlevel": 0, + "print_width": "160px", + "width": "160px" + }, + { + "fieldname": "invoice_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Invoice Date", + "permlevel": 0, + "print_width": "120px", + "read_only": 1, + "width": "120px" + }, + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Territory", + "options": "Territory", + "permlevel": 0, + "print_width": "120px", + "read_only": 1, + "width": "120px" + }, + { + "fieldname": "net_total", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Net Total", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_width": "120px", + "read_only": 1, + "width": "120px" + }, + { + "fieldname": "grand_total", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Grand Total", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_width": "120px", + "read_only": 1, + "width": "120px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:00.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "C-Form Invoice Detail", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py index 26c87f1c04a..f6b54746866 100644 --- a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py +++ b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import frappe +from frappe.model.document import Document -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +class CFormInvoiceDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.txt b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.txt deleted file mode 100644 index 77dfa724306..00000000000 --- a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.txt +++ /dev/null @@ -1,77 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:38", - "docstatus": 0, - "modified": "2013-12-20 19:23:00", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "C-Form Invoice Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "C-Form Invoice Detail" - }, - { - "doctype": "DocField", - "fieldname": "invoice_no", - "fieldtype": "Link", - "label": "Invoice No", - "options": "Sales Invoice", - "print_width": "160px", - "width": "160px" - }, - { - "doctype": "DocField", - "fieldname": "invoice_date", - "fieldtype": "Date", - "label": "Invoice Date", - "print_width": "120px", - "read_only": 1, - "width": "120px" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "label": "Territory", - "options": "Territory", - "print_width": "120px", - "read_only": 1, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total", - "options": "Company:company:default_currency", - "print_width": "120px", - "read_only": 1, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "grand_total", - "fieldtype": "Currency", - "label": "Grand Total", - "options": "Company:company:default_currency", - "print_width": "120px", - "read_only": 1, - "width": "120px" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.json b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.json new file mode 100644 index 00000000000..4f5ce66f0ac --- /dev/null +++ b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.json @@ -0,0 +1,59 @@ +{ + "autoname": "field:chart_name", + "creation": "2014-03-05 14:11:31.000000", + "description": "Financial Chart of Accounts. Imported from file.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "chart_name", + "fieldtype": "Data", + "in_list_view": 0, + "label": "Chart Name", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "country", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Country", + "options": "Country", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "preview", + "fieldtype": "HTML", + "label": "Preview", + "permlevel": 0 + }, + { + "fieldname": "source_file", + "fieldtype": "Data", + "hidden": 1, + "label": "Source File", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + } + ], + "idx": 1, + "in_create": 1, + "modified": "2014-03-05 14:51:05.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Chart of Accounts", + "owner": "Administrator", + "permissions": [ + { + "export": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager" + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py index 16c6acff584..d69ae731804 100644 --- a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py @@ -5,25 +5,21 @@ from __future__ import unicode_literals import frappe, os, json from frappe.utils import cstr from unidecode import unidecode +from frappe.model.document import Document - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - self.no_report_type = False +class ChartofAccounts(Document): + no_report_type = False def create_accounts(self, company): chart = {} - with open(os.path.join(os.path.dirname(__file__), "charts", - self.doc.source_file), "r") as f: + with open(os.path.join(os.path.dirname(__file__), "charts", self.source_file), "r") as f: chart = json.loads(f.read()) - from erpnext.accounts.doctype.chart_of_accounts.charts.account_properties \ - import account_properties + from erpnext.accounts.doctype.chart_of_accounts.charts.account_properties import account_properties if chart: accounts = [] - + def _import_accounts(children, parent): for child in children: account_name = child.get("name") @@ -33,10 +29,9 @@ class DocType: count = accounts.count(account_name_in_db) account_name = account_name + " " + cstr(count) - child.update(account_properties.get(chart.get("name"), {})\ - .get(account_name, {})) + child.update(account_properties.get(chart.get("name"), {}).get(account_name, {})) - account = frappe.bean({ + account = frappe.get_doc({ "doctype": "Account", "account_name": account_name, "company": company, @@ -49,19 +44,19 @@ class DocType: accounts.append(account_name_in_db) # set report_type for all parents where blank - if not account.doc.report_type or account.doc.report_type == 'None': + if not account.report_type or account.report_type == 'None': self.no_report_type = True elif self.no_report_type: frappe.db.sql("""update tabAccount set report_type=%s where lft<=%s and rgt>=%s and ifnull(report_type, '')=''""", - (account.doc.report_type, account.doc.lft, account.doc.rgt)) + (account.report_type, account.lft, account.rgt)) if child.get("children"): - _import_accounts(child.get("children"), account.doc.name) + _import_accounts(child.get("children"), account.name) _import_accounts(chart.get("root").get("children"), None) @frappe.whitelist() def get_charts_for_country(country): - return frappe.db.sql_list("select chart_name from `tabChart of Accounts` where country=%s", - country) \ No newline at end of file + return frappe.db.sql_list("""select chart_name from `tabChart of Accounts` + where country=%s""", country) diff --git a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.txt b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.txt deleted file mode 100644 index fc2a742791d..00000000000 --- a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.txt +++ /dev/null @@ -1,78 +0,0 @@ -[ - { - "creation": "2014-03-05 14:11:31", - "docstatus": 0, - "modified": "2014-03-05 14:51:05", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "field:chart_name", - "description": "Financial Chart of Accounts. Imported from file.", - "doctype": "DocType", - "document_type": "Master", - "in_create": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Chart of Accounts", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "export": 0, - "name": "__common__", - "parent": "Chart of Accounts", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Accounts Manager" - }, - { - "doctype": "DocType", - "name": "Chart of Accounts" - }, - { - "doctype": "DocField", - "fieldname": "chart_name", - "fieldtype": "Data", - "in_list_view": 0, - "label": "Chart Name", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "country", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Country", - "options": "Country", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "preview", - "fieldtype": "HTML", - "label": "Preview" - }, - { - "doctype": "DocField", - "fieldname": "source_file", - "fieldtype": "Data", - "hidden": 1, - "label": "Source File", - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/chart_of_accounts/import_charts.py b/erpnext/accounts/doctype/chart_of_accounts/import_charts.py index f95a4ed5fcd..9e605516656 100644 --- a/erpnext/accounts/doctype/chart_of_accounts/import_charts.py +++ b/erpnext/accounts/doctype/chart_of_accounts/import_charts.py @@ -13,13 +13,13 @@ def import_charts(): chart = json.loads(f.read()) country = frappe.db.get_value("Country", {"code": fname.split("_", 1)[0]}) if country: - bean = frappe.bean({ + doc = frappe.get_doc({ "doctype":"Chart of Accounts", "chart_name": chart.get("name"), "source_file": fname, "country": country }).insert() - print bean.doc.name.encode("utf-8") + print doc.name.encode("utf-8") else: print "No chart for: " + chart.get("name").encode("utf-8") diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js index 5c8be10a3f5..0cd3a700a40 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.js +++ b/erpnext/accounts/doctype/cost_center/cost_center.js @@ -70,7 +70,7 @@ cur_frm.cscript.hide_unhide_group_ledger = function(doc) { } cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { - return $c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) { + return $c_obj(cur_frm.doc,'convert_group_to_ledger','',function(r,rt) { if(r.message == 1) { cur_frm.refresh(); } @@ -78,7 +78,7 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { } cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) { - return $c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) { + return $c_obj(cur_frm.doc,'convert_ledger_to_group','',function(r,rt) { if(r.message == 1) { cur_frm.refresh(); } diff --git a/erpnext/accounts/doctype/cost_center/cost_center.json b/erpnext/accounts/doctype/cost_center/cost_center.json new file mode 100644 index 00000000000..9dd868a563b --- /dev/null +++ b/erpnext/accounts/doctype/cost_center/cost_center.json @@ -0,0 +1,190 @@ +{ + "allow_copy": 1, + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:cost_center_name", + "creation": "2013-01-23 19:57:17.000000", + "description": "Track separate Income and Expense for product verticals or divisions.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "sb0", + "fieldtype": "Section Break", + "label": "Cost Center Details", + "permlevel": 0 + }, + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "cost_center_name", + "fieldtype": "Data", + "in_filter": 0, + "label": "Cost Center Name", + "no_copy": 1, + "oldfieldname": "cost_center_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "parent_cost_center", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Parent Cost Center", + "oldfieldname": "parent_cost_center", + "oldfieldtype": "Link", + "options": "Cost Center", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "oldfieldname": "company_name", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "cb0", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "group_or_ledger", + "fieldtype": "Select", + "hidden": 0, + "label": "Group or Ledger", + "no_copy": 1, + "oldfieldname": "group_or_ledger", + "oldfieldtype": "Select", + "options": "\nGroup\nLedger", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1, + "reqd": 1 + }, + { + "description": "Define Budget for this Cost Center. To set budget action, see Company Master", + "fieldname": "sb1", + "fieldtype": "Section Break", + "label": "Budget", + "permlevel": 0 + }, + { + "description": "Select Budget Distribution, if you want to track based on seasonality.", + "fieldname": "distribution_id", + "fieldtype": "Link", + "label": "Distribution Id", + "oldfieldname": "distribution_id", + "oldfieldtype": "Link", + "options": "Budget Distribution", + "permlevel": 0 + }, + { + "description": "Add rows to set annual budgets on Accounts.", + "fieldname": "budget_details", + "fieldtype": "Table", + "label": "Budget Details", + "oldfieldname": "budget_details", + "oldfieldtype": "Table", + "options": "Budget Detail", + "permlevel": 0 + }, + { + "fieldname": "lft", + "fieldtype": "Int", + "hidden": 1, + "in_filter": 1, + "label": "lft", + "no_copy": 1, + "oldfieldname": "lft", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1, + "search_index": 1 + }, + { + "fieldname": "rgt", + "fieldtype": "Int", + "hidden": 1, + "in_filter": 1, + "label": "rgt", + "no_copy": 1, + "oldfieldname": "rgt", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "old_parent", + "fieldtype": "Link", + "hidden": 1, + "ignore_restrictions": 1, + "label": "old_parent", + "no_copy": 1, + "oldfieldname": "old_parent", + "oldfieldtype": "Data", + "options": "Cost Center", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + } + ], + "icon": "icon-money", + "idx": 1, + "in_create": 1, + "modified": "2014-01-20 17:48:30.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Cost Center", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 0, + "write": 0 + } + ], + "search_fields": "name,parent_cost_center" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py index e02496ff5d3..d79bbcc5cd8 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.py +++ b/erpnext/accounts/doctype/cost_center/cost_center.py @@ -3,59 +3,56 @@ from __future__ import unicode_literals import frappe -from frappe.model.bean import getlist + from frappe import msgprint, _ -from frappe.utils.nestedset import DocTypeNestedSet +from frappe.utils.nestedset import NestedSet -class DocType(DocTypeNestedSet): - def __init__(self,d,dl): - self.doc, self.doclist = d,dl - self.nsm_parent_field = 'parent_cost_center' - +class CostCenter(NestedSet): + nsm_parent_field = 'parent_cost_center' + def autoname(self): - company_abbr = frappe.db.sql("select abbr from tabCompany where name=%s", - self.doc.company)[0][0] - self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr + self.name = self.cost_center_name.strip() + ' - ' + \ + frappe.db.get_value("Company", self.company, "abbr") def validate_mandatory(self): - if not self.doc.group_or_ledger: + if not self.group_or_ledger: msgprint("Please select Group or Ledger value", raise_exception=1) - if self.doc.cost_center_name != self.doc.company and not self.doc.parent_cost_center: + if self.cost_center_name != self.company and not self.parent_cost_center: msgprint("Please enter parent cost center", raise_exception=1) - elif self.doc.cost_center_name == self.doc.company and self.doc.parent_cost_center: + elif self.cost_center_name == self.company and self.parent_cost_center: msgprint(_("Root cannot have a parent cost center"), raise_exception=1) def convert_group_to_ledger(self): if self.check_if_child_exists(): - msgprint("Cost Center: %s has existing child. You can not convert this cost center to ledger" % (self.doc.name), raise_exception=1) + msgprint("Cost Center: %s has existing child. You can not convert this cost center to ledger" % (self.name), raise_exception=1) elif self.check_gle_exists(): msgprint("Cost Center with existing transaction can not be converted to ledger.", raise_exception=1) else: - self.doc.group_or_ledger = 'Ledger' - self.doc.save() + self.group_or_ledger = 'Ledger' + self.save() return 1 def convert_ledger_to_group(self): if self.check_gle_exists(): msgprint("Cost Center with existing transaction can not be converted to group.", raise_exception=1) else: - self.doc.group_or_ledger = 'Group' - self.doc.save() + self.group_or_ledger = 'Group' + self.save() return 1 def check_gle_exists(self): - return frappe.db.get_value("GL Entry", {"cost_center": self.doc.name}) + return frappe.db.get_value("GL Entry", {"cost_center": self.name}) def check_if_child_exists(self): return frappe.db.sql("select name from `tabCost Center` where \ - parent_cost_center = %s and docstatus != 2", self.doc.name) + parent_cost_center = %s and docstatus != 2", self.name) def validate_budget_details(self): check_acc_list = [] - for d in getlist(self.doclist, 'budget_details'): - if self.doc.group_or_ledger=="Group": + for d in self.get('budget_details'): + if self.group_or_ledger=="Group": msgprint("Budget cannot be set for Group Cost Centers", raise_exception=1) if [d.account, d.fiscal_year] in check_acc_list: @@ -67,7 +64,7 @@ class DocType(DocTypeNestedSet): """ Cost Center name must be unique """ - if (self.doc.fields.get("__islocal") or not self.doc.name) and frappe.db.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.doc.cost_center_name, self.doc.company)): + if (self.get("__islocal") or not self.name) and frappe.db.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.cost_center_name, self.company)): msgprint("Cost Center Name already exists, please rename", raise_exception=1) self.validate_mandatory() @@ -76,10 +73,10 @@ class DocType(DocTypeNestedSet): def before_rename(self, olddn, newdn, merge=False): # Add company abbr if not provided from erpnext.setup.doctype.company.company import get_name_with_abbr - new_cost_center = get_name_with_abbr(newdn, self.doc.company) + new_cost_center = get_name_with_abbr(newdn, self.company) # Validate properties before merging - super(DocType, self).before_rename(olddn, new_cost_center, merge, "group_or_ledger") + super(CostCenter, self).before_rename(olddn, new_cost_center, merge, "group_or_ledger") return new_cost_center @@ -88,5 +85,5 @@ class DocType(DocTypeNestedSet): frappe.db.set_value("Cost Center", newdn, "cost_center_name", " - ".join(newdn.split(" - ")[:-1])) else: - super(DocType, self).after_rename(olddn, newdn, merge) + super(CostCenter, self).after_rename(olddn, newdn, merge) diff --git a/erpnext/accounts/doctype/cost_center/cost_center.txt b/erpnext/accounts/doctype/cost_center/cost_center.txt deleted file mode 100644 index 66864bce4c0..00000000000 --- a/erpnext/accounts/doctype/cost_center/cost_center.txt +++ /dev/null @@ -1,202 +0,0 @@ -[ - { - "creation": "2013-01-23 19:57:17", - "docstatus": 0, - "modified": "2014-01-20 17:48:30", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_copy": 1, - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:cost_center_name", - "description": "Track separate Income and Expense for product verticals or divisions.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-money", - "in_create": 1, - "module": "Accounts", - "name": "__common__", - "search_fields": "name,parent_cost_center" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Cost Center", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Cost Center", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Cost Center" - }, - { - "doctype": "DocField", - "fieldname": "sb0", - "fieldtype": "Section Break", - "label": "Cost Center Details" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "cost_center_name", - "fieldtype": "Data", - "in_filter": 0, - "label": "Cost Center Name", - "no_copy": 1, - "oldfieldname": "cost_center_name", - "oldfieldtype": "Data", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "parent_cost_center", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Parent Cost Center", - "oldfieldname": "parent_cost_center", - "oldfieldtype": "Link", - "options": "Cost Center", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "oldfieldname": "company_name", - "oldfieldtype": "Link", - "options": "Company", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb0", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "group_or_ledger", - "fieldtype": "Select", - "hidden": 0, - "label": "Group or Ledger", - "no_copy": 1, - "oldfieldname": "group_or_ledger", - "oldfieldtype": "Select", - "options": "\nGroup\nLedger", - "print_hide": 1, - "report_hide": 1, - "reqd": 1 - }, - { - "description": "Define Budget for this Cost Center. To set budget action, see Company Master", - "doctype": "DocField", - "fieldname": "sb1", - "fieldtype": "Section Break", - "label": "Budget" - }, - { - "description": "Select Budget Distribution, if you want to track based on seasonality.", - "doctype": "DocField", - "fieldname": "distribution_id", - "fieldtype": "Link", - "label": "Distribution Id", - "oldfieldname": "distribution_id", - "oldfieldtype": "Link", - "options": "Budget Distribution" - }, - { - "description": "Add rows to set annual budgets on Accounts.", - "doctype": "DocField", - "fieldname": "budget_details", - "fieldtype": "Table", - "label": "Budget Details", - "oldfieldname": "budget_details", - "oldfieldtype": "Table", - "options": "Budget Detail" - }, - { - "doctype": "DocField", - "fieldname": "lft", - "fieldtype": "Int", - "hidden": 1, - "in_filter": 1, - "label": "lft", - "no_copy": 1, - "oldfieldname": "lft", - "oldfieldtype": "Int", - "print_hide": 1, - "report_hide": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "rgt", - "fieldtype": "Int", - "hidden": 1, - "in_filter": 1, - "label": "rgt", - "no_copy": 1, - "oldfieldname": "rgt", - "oldfieldtype": "Int", - "print_hide": 1, - "report_hide": 1, - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "old_parent", - "fieldtype": "Link", - "hidden": 1, - "ignore_restrictions": 1, - "label": "old_parent", - "no_copy": 1, - "oldfieldname": "old_parent", - "oldfieldtype": "Data", - "options": "Cost Center", - "print_hide": 1, - "report_hide": 1 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Accounts Manager", - "write": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Accounts User", - "write": 0 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/cost_center/test_cost_center.py b/erpnext/accounts/doctype/cost_center/test_cost_center.py index 2fd7ecf9666..d23d38af614 100644 --- a/erpnext/accounts/doctype/cost_center/test_cost_center.py +++ b/erpnext/accounts/doctype/cost_center/test_cost_center.py @@ -1,19 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Cost Center", - "cost_center_name": "_Test Cost Center", - "parent_cost_center": "_Test Company - _TC", - "company": "_Test Company", - "group_or_ledger": "Ledger", - "distribution_id": "_Test Distribution", - }, { - "doctype": "Budget Detail", - "parentfield": "budget_details", - "account": "_Test Account Cost for Goods Sold - _TC", - "budget_allocated": 100000, - "fiscal_year": "_Test Fiscal Year 2013" - }], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Cost Center') \ No newline at end of file diff --git a/erpnext/accounts/doctype/cost_center/test_records.json b/erpnext/accounts/doctype/cost_center/test_records.json new file mode 100644 index 00000000000..9e3e011fe2f --- /dev/null +++ b/erpnext/accounts/doctype/cost_center/test_records.json @@ -0,0 +1,19 @@ +[ + { + "budget_details": [ + { + "account": "_Test Account Cost for Goods Sold - _TC", + "budget_allocated": 100000, + "doctype": "Budget Detail", + "fiscal_year": "_Test Fiscal Year 2013", + "parentfield": "budget_details" + } + ], + "company": "_Test Company", + "cost_center_name": "_Test Cost Center", + "distribution_id": "_Test Distribution", + "doctype": "Cost Center", + "group_or_ledger": "Ledger", + "parent_cost_center": "_Test Company - _TC" + } +] \ No newline at end of file diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.json b/erpnext/accounts/doctype/fiscal_year/fiscal_year.json new file mode 100644 index 00000000000..314dfab1a79 --- /dev/null +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.json @@ -0,0 +1,82 @@ +{ + "allow_import": 1, + "autoname": "field:year", + "creation": "2013-01-22 16:50:25.000000", + "description": "**Fiscal Year** represents a Financial Year. All accounting entries and other major transactions are tracked against **Fiscal Year**.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "description": "For e.g. 2012, 2012-13", + "fieldname": "year", + "fieldtype": "Data", + "label": "Year Name", + "oldfieldname": "year", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "year_start_date", + "fieldtype": "Date", + "label": "Year Start Date", + "no_copy": 1, + "oldfieldname": "year_start_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "year_end_date", + "fieldtype": "Date", + "label": "Year End Date", + "no_copy": 1, + "permlevel": 0, + "reqd": 1 + }, + { + "default": "No", + "description": "Entries are not allowed against this Fiscal Year if the year is closed.", + "fieldname": "is_fiscal_year_closed", + "fieldtype": "Select", + "label": "Year Closed", + "no_copy": 1, + "oldfieldname": "is_fiscal_year_closed", + "oldfieldtype": "Select", + "options": "\nNo\nYes", + "permlevel": 0, + "reqd": 0 + } + ], + "icon": "icon-calendar", + "idx": 1, + "modified": "2014-01-20 17:48:46.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Fiscal Year", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "submit": 0, + "write": 1 + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "All" + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py index 3918751d84d..6e72c9ad79a 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py @@ -6,40 +6,40 @@ import frappe from frappe import msgprint, _ from frappe.utils import getdate -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class FiscalYear(Document): def set_as_default(self): - frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name) - frappe.get_obj("Global Defaults").on_update() + frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.name) + frappe.get_doc("Global Defaults").on_update() # clear cache frappe.clear_cache() - msgprint(self.doc.name + _(""" is now the default Fiscal Year. \ + msgprint(self.name + _(""" is now the default Fiscal Year. \ Please refresh your browser for the change to take effect.""")) def validate(self): year_start_end_dates = frappe.db.sql("""select year_start_date, year_end_date - from `tabFiscal Year` where name=%s""", (self.doc.name)) + from `tabFiscal Year` where name=%s""", (self.name)) if year_start_end_dates: - if getdate(self.doc.year_start_date) != year_start_end_dates[0][0] or getdate(self.doc.year_end_date) != year_start_end_dates[0][1]: + if getdate(self.year_start_date) != year_start_end_dates[0][0] or getdate(self.year_end_date) != year_start_end_dates[0][1]: frappe.throw(_("Cannot change Year Start Date and Year End Date once the Fiscal Year is saved.")) def on_update(self): # validate year start date and year end date - if getdate(self.doc.year_start_date) > getdate(self.doc.year_end_date): + if getdate(self.year_start_date) > getdate(self.year_end_date): frappe.throw(_("Year Start Date should not be greater than Year End Date")) - if (getdate(self.doc.year_end_date) - getdate(self.doc.year_start_date)).days > 366: + if (getdate(self.year_end_date) - getdate(self.year_start_date)).days > 366: frappe.throw(_("Year Start Date and Year End Date are not within Fiscal Year.")) year_start_end_dates = frappe.db.sql("""select name, year_start_date, year_end_date - from `tabFiscal Year` where name!=%s""", (self.doc.name)) + from `tabFiscal Year` where name!=%s""", (self.name)) for fiscal_year, ysd, yed in year_start_end_dates: - if (getdate(self.doc.year_start_date) == ysd and getdate(self.doc.year_end_date) == yed) \ + if (getdate(self.year_start_date) == ysd and getdate(self.year_end_date) == yed) \ and (not frappe.flags.in_test): frappe.throw(_("Year Start Date and Year End Date are already set in Fiscal Year: ") + fiscal_year) \ No newline at end of file diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.txt b/erpnext/accounts/doctype/fiscal_year/fiscal_year.txt deleted file mode 100644 index 27fac8df252..00000000000 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.txt +++ /dev/null @@ -1,98 +0,0 @@ -[ - { - "creation": "2013-01-22 16:50:25", - "docstatus": 0, - "modified": "2014-01-20 17:48:46", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:year", - "description": "**Fiscal Year** represents a Financial Year. All accounting entries and other major transactions are tracked against **Fiscal Year**.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-calendar", - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Fiscal Year", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Fiscal Year", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1 - }, - { - "doctype": "DocType", - "name": "Fiscal Year" - }, - { - "description": "For e.g. 2012, 2012-13", - "doctype": "DocField", - "fieldname": "year", - "fieldtype": "Data", - "label": "Year Name", - "oldfieldname": "year", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "year_start_date", - "fieldtype": "Date", - "label": "Year Start Date", - "no_copy": 1, - "oldfieldname": "year_start_date", - "oldfieldtype": "Date", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "year_end_date", - "fieldtype": "Date", - "label": "Year End Date", - "no_copy": 1, - "reqd": 1 - }, - { - "default": "No", - "description": "Entries are not allowed against this Fiscal Year if the year is closed.", - "doctype": "DocField", - "fieldname": "is_fiscal_year_closed", - "fieldtype": "Select", - "label": "Year Closed", - "no_copy": 1, - "oldfieldname": "is_fiscal_year_closed", - "oldfieldtype": "Select", - "options": "\nNo\nYes", - "reqd": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "report": 1, - "role": "System Manager", - "submit": 0, - "write": 1 - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "All" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py index cd9b1f4eadb..edceddb5f12 100644 --- a/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py @@ -3,35 +3,6 @@ from __future__ import unicode_literals -test_records = [ - [{ - "doctype": "Fiscal Year", - "year": "_Test Fiscal Year 2012", - "year_start_date": "2012-01-01", - "year_end_date": "2012-12-31" - }], - [{ - "doctype": "Fiscal Year", - "year": "_Test Fiscal Year 2013", - "year_start_date": "2013-01-01", - "year_end_date": "2013-12-31" - }], - [{ - "doctype": "Fiscal Year", - "year": "_Test Fiscal Year 2014", - "year_start_date": "2014-01-01", - "year_end_date": "2014-12-31" - }], - [{ - "doctype": "Fiscal Year", - "year": "_Test Fiscal Year 2015", - "year_start_date": "2015-01-01", - "year_end_date": "2015-12-31" - }], - [{ - "doctype": "Fiscal Year", - "year": "_Test Fiscal Year 2016", - "year_start_date": "2016-01-01", - "year_end_date": "2016-12-31" - }], -] \ No newline at end of file +import frappe + +test_records = frappe.get_test_records('Fiscal Year') \ No newline at end of file diff --git a/erpnext/accounts/doctype/fiscal_year/test_records.json b/erpnext/accounts/doctype/fiscal_year/test_records.json new file mode 100644 index 00000000000..09fb90e9e3b --- /dev/null +++ b/erpnext/accounts/doctype/fiscal_year/test_records.json @@ -0,0 +1,32 @@ +[ + { + "doctype": "Fiscal Year", + "year": "_Test Fiscal Year 2012", + "year_end_date": "2012-12-31", + "year_start_date": "2012-01-01" + }, + { + "doctype": "Fiscal Year", + "year": "_Test Fiscal Year 2013", + "year_end_date": "2013-12-31", + "year_start_date": "2013-01-01" + }, + { + "doctype": "Fiscal Year", + "year": "_Test Fiscal Year 2014", + "year_end_date": "2014-12-31", + "year_start_date": "2014-01-01" + }, + { + "doctype": "Fiscal Year", + "year": "_Test Fiscal Year 2015", + "year_end_date": "2015-12-31", + "year_start_date": "2015-01-01" + }, + { + "doctype": "Fiscal Year", + "year": "_Test Fiscal Year 2016", + "year_end_date": "2016-12-31", + "year_start_date": "2016-01-01" + } +] \ No newline at end of file diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.json b/erpnext/accounts/doctype/gl_entry/gl_entry.json new file mode 100644 index 00000000000..79bf90b5de8 --- /dev/null +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.json @@ -0,0 +1,229 @@ +{ + "autoname": "GL.#######", + "creation": "2013-01-10 16:34:06.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "posting_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Posting Date", + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "transaction_date", + "fieldtype": "Date", + "label": "Transaction Date", + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "aging_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Aging Date", + "oldfieldname": "aging_date", + "oldfieldtype": "Date", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "account", + "fieldtype": "Link", + "in_filter": 1, + "label": "Account", + "oldfieldname": "account", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "cost_center", + "fieldtype": "Link", + "in_filter": 1, + "label": "Cost Center", + "oldfieldname": "cost_center", + "oldfieldtype": "Link", + "options": "Cost Center", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "debit", + "fieldtype": "Currency", + "label": "Debit Amt", + "oldfieldname": "debit", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "credit", + "fieldtype": "Currency", + "label": "Credit Amt", + "oldfieldname": "credit", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "against", + "fieldtype": "Text", + "in_filter": 1, + "label": "Against", + "oldfieldname": "against", + "oldfieldtype": "Text", + "permlevel": 0 + }, + { + "fieldname": "against_voucher", + "fieldtype": "Data", + "in_filter": 1, + "label": "Against Voucher", + "oldfieldname": "against_voucher", + "oldfieldtype": "Data", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "against_voucher_type", + "fieldtype": "Data", + "in_filter": 0, + "label": "Against Voucher Type", + "oldfieldname": "against_voucher_type", + "oldfieldtype": "Data", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "voucher_type", + "fieldtype": "Select", + "in_filter": 1, + "label": "Voucher Type", + "oldfieldname": "voucher_type", + "oldfieldtype": "Select", + "options": "Journal Voucher\nSales Invoice\nPurchase Invoice", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "voucher_no", + "fieldtype": "Data", + "in_filter": 1, + "label": "Voucher No", + "oldfieldname": "voucher_no", + "oldfieldtype": "Data", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "remarks", + "fieldtype": "Text", + "in_filter": 1, + "label": "Remarks", + "no_copy": 1, + "oldfieldname": "remarks", + "oldfieldtype": "Text", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "is_opening", + "fieldtype": "Select", + "in_filter": 1, + "label": "Is Opening", + "oldfieldname": "is_opening", + "oldfieldtype": "Select", + "options": "No\nYes", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "is_advance", + "fieldtype": "Select", + "in_filter": 0, + "label": "Is Advance", + "oldfieldname": "is_advance", + "oldfieldtype": "Select", + "options": "No\nYes", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "search_index": 0 + } + ], + "icon": "icon-list", + "idx": 1, + "in_create": 1, + "modified": "2013-12-20 19:24:08.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "GL Entry", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 0 + }, + { + "create": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "submit": 0, + "write": 0 + } + ], + "search_fields": "voucher_no,account,posting_date,against_voucher" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index 9e1dbb7f58d..bbdf17ebdfe 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -7,9 +7,9 @@ import frappe from frappe.utils import flt, fmt_money, getdate from frappe import _ -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class GLEntry(Document): def validate(self): self.check_mandatory() @@ -20,42 +20,42 @@ class DocType: def on_update_with_args(self, adv_adj, update_outstanding = 'Yes'): self.validate_account_details(adv_adj) - validate_frozen_account(self.doc.account, adv_adj) - check_freezing_date(self.doc.posting_date, adv_adj) - validate_balance_type(self.doc.account, adv_adj) + validate_frozen_account(self.account, adv_adj) + check_freezing_date(self.posting_date, adv_adj) + validate_balance_type(self.account, adv_adj) # Update outstanding amt on against voucher - if self.doc.against_voucher and self.doc.against_voucher_type != "POS" \ + if self.against_voucher and self.against_voucher_type != "POS" \ and update_outstanding == 'Yes': - update_outstanding_amt(self.doc.account, self.doc.against_voucher_type, - self.doc.against_voucher) + update_outstanding_amt(self.account, self.against_voucher_type, + self.against_voucher) def check_mandatory(self): mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company'] for k in mandatory: - if not self.doc.fields.get(k): + if not self.get(k): frappe.throw(k + _(" is mandatory for GL Entry")) # Zero value transaction is not allowed - if not (flt(self.doc.debit) or flt(self.doc.credit)): + if not (flt(self.debit) or flt(self.credit)): frappe.throw(_("GL Entry: Debit or Credit amount is mandatory for ") + - self.doc.account) + self.account) def pl_must_have_cost_center(self): - if frappe.db.get_value("Account", self.doc.account, "report_type") == "Profit and Loss": - if not self.doc.cost_center and self.doc.voucher_type != 'Period Closing Voucher': + if frappe.db.get_value("Account", self.account, "report_type") == "Profit and Loss": + if not self.cost_center and self.voucher_type != 'Period Closing Voucher': frappe.throw(_("Cost Center must be specified for Profit and Loss type account: ") - + self.doc.account) - elif self.doc.cost_center: - self.doc.cost_center = None + + self.account) + elif self.cost_center: + self.cost_center = None def validate_posting_date(self): from erpnext.accounts.utils import validate_fiscal_year - validate_fiscal_year(self.doc.posting_date, self.doc.fiscal_year, "Posting Date") + validate_fiscal_year(self.posting_date, self.fiscal_year, "Posting Date") def check_pl_account(self): - if self.doc.is_opening=='Yes' and \ - frappe.db.get_value("Account", self.doc.account, "report_type")=="Profit and Loss": + if self.is_opening=='Yes' and \ + frappe.db.get_value("Account", self.account, "report_type")=="Profit and Loss": frappe.throw(_("For opening balance entry, account can not be \ a Profit and Loss type account")) @@ -63,32 +63,32 @@ class DocType: """Account must be ledger, active and not freezed""" ret = frappe.db.sql("""select group_or_ledger, docstatus, company - from tabAccount where name=%s""", self.doc.account, as_dict=1)[0] + from tabAccount where name=%s""", self.account, as_dict=1)[0] if ret.group_or_ledger=='Group': - frappe.throw(_("Account") + ": " + self.doc.account + _(" is not a ledger")) + frappe.throw(_("Account") + ": " + self.account + _(" is not a ledger")) if ret.docstatus==2: - frappe.throw(_("Account") + ": " + self.doc.account + _(" is not active")) + frappe.throw(_("Account") + ": " + self.account + _(" is not active")) - if ret.company != self.doc.company: - frappe.throw(_("Account") + ": " + self.doc.account + - _(" does not belong to the company") + ": " + self.doc.company) + if ret.company != self.company: + frappe.throw(_("Account") + ": " + self.account + + _(" does not belong to the company") + ": " + self.company) def validate_cost_center(self): if not hasattr(self, "cost_center_company"): self.cost_center_company = {} def _get_cost_center_company(): - if not self.cost_center_company.get(self.doc.cost_center): - self.cost_center_company[self.doc.cost_center] = frappe.db.get_value( - "Cost Center", self.doc.cost_center, "company") + if not self.cost_center_company.get(self.cost_center): + self.cost_center_company[self.cost_center] = frappe.db.get_value( + "Cost Center", self.cost_center, "company") - return self.cost_center_company[self.doc.cost_center] + return self.cost_center_company[self.cost_center] - if self.doc.cost_center and _get_cost_center_company() != self.doc.company: - frappe.throw(_("Cost Center") + ": " + self.doc.cost_center + - _(" does not belong to the company") + ": " + self.doc.company) + if self.cost_center and _get_cost_center_company() != self.company: + frappe.throw(_("Cost Center") + ": " + self.cost_center + + _(" does not belong to the company") + ": " + self.company) def validate_balance_type(account, adv_adj=False): if not adv_adj and account: diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.txt b/erpnext/accounts/doctype/gl_entry/gl_entry.txt deleted file mode 100644 index 3ec5ec6c74d..00000000000 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.txt +++ /dev/null @@ -1,234 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:06", - "docstatus": 0, - "modified": "2013-12-20 19:24:08", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "GL.#######", - "doctype": "DocType", - "icon": "icon-list", - "in_create": 1, - "module": "Accounts", - "name": "__common__", - "search_fields": "voucher_no,account,posting_date,against_voucher" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "GL Entry", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "GL Entry", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0, - "write": 0 - }, - { - "doctype": "DocType", - "name": "GL Entry" - }, - { - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Posting Date", - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "transaction_date", - "fieldtype": "Date", - "label": "Transaction Date", - "oldfieldname": "transaction_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "aging_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Aging Date", - "oldfieldname": "aging_date", - "oldfieldtype": "Date", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "account", - "fieldtype": "Link", - "in_filter": 1, - "label": "Account", - "oldfieldname": "account", - "oldfieldtype": "Link", - "options": "Account", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "in_filter": 1, - "label": "Cost Center", - "oldfieldname": "cost_center", - "oldfieldtype": "Link", - "options": "Cost Center", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "debit", - "fieldtype": "Currency", - "label": "Debit Amt", - "oldfieldname": "debit", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "credit", - "fieldtype": "Currency", - "label": "Credit Amt", - "oldfieldname": "credit", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "against", - "fieldtype": "Text", - "in_filter": 1, - "label": "Against", - "oldfieldname": "against", - "oldfieldtype": "Text" - }, - { - "doctype": "DocField", - "fieldname": "against_voucher", - "fieldtype": "Data", - "in_filter": 1, - "label": "Against Voucher", - "oldfieldname": "against_voucher", - "oldfieldtype": "Data", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "against_voucher_type", - "fieldtype": "Data", - "in_filter": 0, - "label": "Against Voucher Type", - "oldfieldname": "against_voucher_type", - "oldfieldtype": "Data", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "voucher_type", - "fieldtype": "Select", - "in_filter": 1, - "label": "Voucher Type", - "oldfieldname": "voucher_type", - "oldfieldtype": "Select", - "options": "Journal Voucher\nSales Invoice\nPurchase Invoice", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "voucher_no", - "fieldtype": "Data", - "in_filter": 1, - "label": "Voucher No", - "oldfieldname": "voucher_no", - "oldfieldtype": "Data", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "remarks", - "fieldtype": "Text", - "in_filter": 1, - "label": "Remarks", - "no_copy": 1, - "oldfieldname": "remarks", - "oldfieldtype": "Text", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "is_opening", - "fieldtype": "Select", - "in_filter": 1, - "label": "Is Opening", - "oldfieldname": "is_opening", - "oldfieldtype": "Select", - "options": "No\nYes", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "is_advance", - "fieldtype": "Select", - "in_filter": 0, - "label": "Is Advance", - "oldfieldname": "is_advance", - "oldfieldtype": "Select", - "options": "No\nYes", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "search_index": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "role": "Accounts User" - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "role": "Accounts Manager" - }, - { - "doctype": "DocPerm", - "role": "System Manager" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js index 1107ba4a6cb..b1aa70bceef 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js @@ -8,23 +8,22 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({ this.load_defaults(); this.setup_queries(); }, - + load_defaults: function() { if(this.frm.doc.__islocal && this.frm.doc.company) { frappe.model.set_default_values(this.frm.doc); - $.each(frappe.model.get_doclist(this.frm.doc.doctype, - this.frm.doc.name, {parentfield: "entries"}), function(i, jvd) { + $.each(this.frm.doc.entries || [], function(i, jvd) { frappe.model.set_default_values(jvd); } ); - + if(!this.frm.doc.amended_from) this.frm.doc.posting_date = get_today(); } }, - + setup_queries: function() { var me = this; - + $.each(["account", "cost_center"], function(i, fieldname) { me.frm.set_query(fieldname, "entries", function() { frappe.model.validate_missing(me.frm.doc, "company"); @@ -36,11 +35,11 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({ }; }); }); - - $.each([["against_voucher", "Purchase Invoice", "credit_to"], + + $.each([["against_voucher", "Purchase Invoice", "credit_to"], ["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) { me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) { - var jvd = frappe.model.get_doc(cdt, cdn); + var jvd = frappe.get_doc(cdt, cdn); frappe.model.validate_missing(jvd, "account"); return { filters: [ @@ -51,49 +50,49 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({ }; }); }); - + this.frm.set_query("against_jv", "entries", function(doc, cdt, cdn) { - var jvd = frappe.model.get_doc(cdt, cdn); + var jvd = frappe.get_doc(cdt, cdn); frappe.model.validate_missing(jvd, "account"); - + return { query: "accounts.doctype.journal_voucher.journal_voucher.get_against_jv", filters: { account: jvd.account } }; }); }, - + against_voucher: function(doc, cdt, cdn) { - var d = frappe.model.get_doc(cdt, cdn); + var d = frappe.get_doc(cdt, cdn); if (d.against_voucher && !flt(d.debit)) { this.get_outstanding({ - 'doctype': 'Purchase Invoice', + 'doctype': 'Purchase Invoice', 'docname': d.against_voucher }, d) } }, - + against_invoice: function(doc, cdt, cdn) { - var d = frappe.model.get_doc(cdt, cdn); + var d = frappe.get_doc(cdt, cdn); if (d.against_invoice && !flt(d.credit)) { this.get_outstanding({ - 'doctype': 'Sales Invoice', + 'doctype': 'Sales Invoice', 'docname': d.against_invoice }, d) } }, - + against_jv: function(doc, cdt, cdn) { - var d = frappe.model.get_doc(cdt, cdn); + var d = frappe.get_doc(cdt, cdn); if (d.against_jv && !flt(d.credit) && !flt(d.debit)) { this.get_outstanding({ - 'doctype': 'Journal Voucher', + 'doctype': 'Journal Voucher', 'docname': d.against_jv, 'account': d.account }, d) } }, - + get_outstanding: function(args, child) { var me = this; return this.frm.call({ @@ -105,7 +104,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({ } }); } - + }); cur_frm.script_manager.make(erpnext.accounts.JournalVoucher); @@ -114,7 +113,7 @@ cur_frm.cscript.refresh = function(doc) { cur_frm.cscript.is_opening(doc) erpnext.hide_naming_series(); cur_frm.cscript.voucher_type(doc); - if(doc.docstatus==1) { + if(doc.docstatus==1) { cur_frm.appframe.add_button(frappe._('View Ledger'), function() { frappe.route_options = { "voucher_no": doc.name, @@ -139,7 +138,7 @@ cur_frm.cscript.is_opening = function(doc, cdt, cdn) { cur_frm.cscript.update_totals = function(doc) { var td=0.0; var tc =0.0; - var el = getchildren('Journal Voucher Detail', doc.name, 'entries'); + var el = doc.entries || []; for(var i in el) { td += flt(el[i].debit, 2); tc += flt(el[i].credit, 2); @@ -155,8 +154,8 @@ cur_frm.cscript.debit = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc) cur_frm.cscript.credit = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc); } cur_frm.cscript.get_balance = function(doc,dt,dn) { - cur_frm.cscript.update_totals(doc); - return $c_obj(make_doclist(dt,dn), 'get_balance', '', function(r, rt){ + cur_frm.cscript.update_totals(doc); + return $c_obj(cur_frm.doc, 'get_balance', '', function(r, rt){ cur_frm.refresh(); }); } @@ -175,7 +174,7 @@ cur_frm.cscript.account = function(doc,dt,dn) { } }); } -} +} cur_frm.cscript.validate = function(doc,cdt,cdn) { cur_frm.cscript.update_totals(doc); @@ -194,10 +193,9 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher"); cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher"); - if(frappe.model.get("Journal Voucher Detail", {"parent":doc.name}).length!==0 // too late - || !doc.company) // too early + if((doc.entries || []).length!==0 || !doc.company) // too early return; - + var update_jv_details = function(doc, r) { $.each(r.message, function(i, d) { var jvdetail = frappe.model.add_child(doc, "Journal Voucher Detail", "entries"); @@ -206,7 +204,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { }); refresh_field("entries"); } - + if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)) { return frappe.call({ type: "GET", @@ -229,7 +227,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { "company": doc.company }, callback: function(r) { - frappe.model.clear_table("Journal Voucher Detail", "Journal Voucher", + frappe.model.clear_table("Journal Voucher Detail", "Journal Voucher", doc.name, "entries"); if(r.message) { update_jv_details(doc, r); @@ -238,4 +236,4 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { } }) } -} \ No newline at end of file +} diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.json b/erpnext/accounts/doctype/journal_voucher/journal_voucher.json new file mode 100644 index 00000000000..872fffa3889 --- /dev/null +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.json @@ -0,0 +1,492 @@ +{ + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-03-25 10:53:52.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "voucher_type_and_date", + "fieldtype": "Section Break", + "label": "Voucher Type and Date", + "options": "icon-flag", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "JV", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "voucher_type", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Voucher Type", + "oldfieldname": "voucher_type", + "oldfieldtype": "Select", + "options": "\nJournal Entry\nBank Voucher\nCash Voucher\nCredit Card Voucher\nDebit Note\nCredit Note\nContra Voucher\nExcise Voucher\nWrite Off Voucher\nOpening Entry", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "search_index": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "posting_date", + "fieldtype": "Date", + "in_filter": 1, + "in_list_view": 1, + "label": "Posting Date", + "no_copy": 1, + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "2_add_edit_gl_entries", + "fieldtype": "Section Break", + "label": "Journal Entries", + "oldfieldtype": "Section Break", + "options": "icon-table", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "entries", + "fieldtype": "Table", + "label": "Entries", + "oldfieldname": "entries", + "oldfieldtype": "Table", + "options": "Journal Voucher Detail", + "permlevel": 0, + "print_hide": 0, + "read_only": 0 + }, + { + "fieldname": "section_break99", + "fieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "total_debit", + "fieldtype": "Currency", + "in_filter": 1, + "in_list_view": 1, + "label": "Total Debit", + "no_copy": 1, + "oldfieldname": "total_debit", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "total_credit", + "fieldtype": "Currency", + "in_filter": 1, + "label": "Total Credit", + "no_copy": 1, + "oldfieldname": "total_credit", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break99", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "difference", + "fieldtype": "Currency", + "label": "Difference", + "no_copy": 1, + "oldfieldname": "difference", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "get_balance", + "fieldtype": "Button", + "label": "Make Difference Entry", + "oldfieldtype": "Button", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "reference", + "fieldtype": "Section Break", + "label": "Reference", + "options": "icon-pushpin", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "eg. Cheque Number", + "fieldname": "cheque_no", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Reference Number", + "no_copy": 1, + "oldfieldname": "cheque_no", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0, + "search_index": 1 + }, + { + "fieldname": "cheque_date", + "fieldtype": "Date", + "label": "Reference Date", + "no_copy": 1, + "oldfieldname": "cheque_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "clearance_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Clearance Date", + "no_copy": 1, + "oldfieldname": "clearance_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "column_break98", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "user_remark", + "fieldtype": "Small Text", + "in_filter": 1, + "label": "User Remark", + "no_copy": 1, + "oldfieldname": "user_remark", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "User Remark will be added to Auto Remark", + "fieldname": "remark", + "fieldtype": "Small Text", + "in_list_view": 0, + "label": "Remark", + "no_copy": 1, + "oldfieldname": "remark", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "bill_no", + "fieldtype": "Data", + "in_list_view": 0, + "label": "Bill No", + "oldfieldname": "bill_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "bill_date", + "fieldtype": "Date", + "label": "Bill Date", + "oldfieldname": "bill_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "due_date", + "fieldtype": "Date", + "label": "Due Date", + "oldfieldname": "due_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 0, + "read_only": 0 + }, + { + "fieldname": "addtional_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "default": "No", + "description": "Considered as Opening Balance", + "fieldname": "is_opening", + "fieldtype": "Select", + "in_filter": 1, + "label": "Is Opening", + "oldfieldname": "is_opening", + "oldfieldtype": "Select", + "options": "No\nYes", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "search_index": 1 + }, + { + "description": "Actual Posting Date", + "fieldname": "aging_date", + "fieldtype": "Date", + "label": "Aging Date", + "no_copy": 0, + "oldfieldname": "aging_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "default": "Accounts Receivable", + "depends_on": "eval:doc.voucher_type == 'Write Off Voucher'", + "fieldname": "write_off_based_on", + "fieldtype": "Select", + "label": "Write Off Based On", + "options": "Accounts Receivable\nAccounts Payable", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "depends_on": "eval:doc.voucher_type == 'Write Off Voucher'", + "fieldname": "write_off_amount", + "fieldtype": "Currency", + "label": "Write Off Amount <=", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "depends_on": "eval:doc.voucher_type == 'Write Off Voucher'", + "fieldname": "get_outstanding_invoices", + "fieldtype": "Button", + "label": "Get Outstanding Invoices", + "options": "get_outstanding_invoices", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "letter_head", + "fieldtype": "Link", + "label": "Letter Head", + "options": "Letter Head", + "permlevel": 0 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "pay_to_recd_from", + "fieldtype": "Data", + "hidden": 0, + "label": "Pay To / Recd From", + "no_copy": 1, + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "report_hide": 1 + }, + { + "fieldname": "total_amount", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Total Amount", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1 + }, + { + "fieldname": "total_amount_in_words", + "fieldtype": "Data", + "hidden": 1, + "label": "Total Amount in Words", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Link", + "options": "Journal Voucher", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "icon": "icon-file-text", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:48:51.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Journal Voucher", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Auditor", + "submit": 0, + "write": 0 + } + ], + "read_only_onload": 1, + "search_fields": "voucher_type,posting_date, due_date, cheque_no" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py index 57c14b00d60..f11589bdf11 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py @@ -5,74 +5,72 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, cstr, flt, fmt_money, formatdate, getdate -from frappe.model.doc import addchild -from frappe.model.bean import getlist from frappe import msgprint, _ from erpnext.setup.utils import get_company_currency from erpnext.controllers.accounts_controller import AccountsController -class DocType(AccountsController): - def __init__(self,d,dl): - self.doc, self.doclist = d,dl +class JournalVoucher(AccountsController): + def __init__(self, arg1, arg2=None): + super(JournalVoucher, self).__init__(arg1, arg2) self.master_type = {} self.credit_days_for = {} self.credit_days_global = -1 self.is_approving_authority = -1 def validate(self): - if not self.doc.is_opening: - self.doc.is_opening='No' - - self.doc.clearance_date = None - - super(DocType, self).validate_date_with_fiscal_year() - + if not self.is_opening: + self.is_opening='No' + + self.clearance_date = None + + super(JournalVoucher, self).validate_date_with_fiscal_year() + self.validate_debit_credit() self.validate_cheque_info() self.validate_entries_for_advance() self.validate_against_jv() - + self.set_against_account() self.create_remarks() self.set_aging_date() self.set_print_format_fields() - + def on_submit(self): - if self.doc.voucher_type in ['Bank Voucher', 'Contra Voucher', 'Journal Entry']: + if self.voucher_type in ['Bank Voucher', 'Contra Voucher', 'Journal Entry']: self.check_credit_days() self.make_gl_entries() self.check_credit_limit() def on_cancel(self): from erpnext.accounts.utils import remove_against_link_from_jv - remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_jv") - + remove_against_link_from_jv(self.doctype, self.name, "against_jv") + self.make_gl_entries(1) - + def on_trash(self): pass - #if self.doc.amended_from: - # frappe.delete_doc("Journal Voucher", self.doc.amended_from) + #if self.amended_from: + # frappe.delete_doc("Journal Voucher", self.amended_from) def validate_debit_credit(self): - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.debit and d.credit: - msgprint("You cannot credit and debit same account at the same time.", + msgprint("You cannot credit and debit same account at the same time.", raise_exception=1) def validate_cheque_info(self): - if self.doc.voucher_type in ['Bank Voucher']: - if not self.doc.cheque_no or not self.doc.cheque_date: + if self.voucher_type in ['Bank Voucher']: + if not self.cheque_no or not self.cheque_date: msgprint("Reference No & Reference Date is required for %s" % - self.doc.voucher_type, raise_exception=1) - - if self.doc.cheque_date and not self.doc.cheque_no: + self.voucher_type, raise_exception=1) + + if self.cheque_date and not self.cheque_no: msgprint("Reference No is mandatory if you entered Reference Date", raise_exception=1) def validate_entries_for_advance(self): - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if not d.is_advance and not d.against_voucher and \ not d.against_invoice and not d.against_jv: master_type = frappe.db.get_value("Account", d.account, "master_type") @@ -82,133 +80,133 @@ class DocType(AccountsController): Account %s if this is an advance entry." % d.account) def validate_against_jv(self): - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.against_jv: - if d.against_jv == self.doc.name: + if d.against_jv == self.name: msgprint("You can not enter current voucher in 'Against JV' column", raise_exception=1) - elif not frappe.db.sql("""select name from `tabJournal Voucher Detail` - where account = %s and docstatus = 1 and parent = %s""", + elif not frappe.db.sql("""select name from `tabJournal Voucher Detail` + where account = %s and docstatus = 1 and parent = %s""", (d.account, d.against_jv)): msgprint("Against JV: %s is not valid." % d.against_jv, raise_exception=1) - + def set_against_account(self): # Debit = Credit debit, credit = 0.0, 0.0 debit_list, credit_list = [], [] - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): debit += flt(d.debit, 2) credit += flt(d.credit, 2) if flt(d.debit)>0 and (d.account not in debit_list): debit_list.append(d.account) if flt(d.credit)>0 and (d.account not in credit_list): credit_list.append(d.account) - self.doc.total_debit = debit - self.doc.total_credit = credit + self.total_debit = debit + self.total_credit = credit + + if abs(self.total_debit-self.total_credit) > 0.001: + msgprint("Debit must be equal to Credit. The difference is %s" % + (self.total_debit-self.total_credit), raise_exception=1) - if abs(self.doc.total_debit-self.doc.total_credit) > 0.001: - msgprint("Debit must be equal to Credit. The difference is %s" % - (self.doc.total_debit-self.doc.total_credit), raise_exception=1) - # update against account - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if flt(d.debit) > 0: d.against_account = ', '.join(credit_list) if flt(d.credit) > 0: d.against_account = ', '.join(debit_list) def create_remarks(self): r = [] - if self.doc.cheque_no : - if self.doc.cheque_date: - r.append('Via Reference #%s dated %s' % - (self.doc.cheque_no, formatdate(self.doc.cheque_date))) + if self.cheque_no: + if self.cheque_date: + r.append('Via Reference #%s dated %s' % + (self.cheque_no, formatdate(self.cheque_date))) else : msgprint("Please enter Reference date", raise_exception=1) - - for d in getlist(self.doclist, 'entries'): + + for d in self.get('entries'): if d.against_invoice and d.credit: currency = frappe.db.get_value("Sales Invoice", d.against_invoice, "currency") - r.append('%s %s against Invoice: %s' % + r.append('%s %s against Invoice: %s' % (cstr(currency), fmt_money(flt(d.credit)), d.against_invoice)) - + if d.against_voucher and d.debit: - bill_no = frappe.db.sql("""select bill_no, bill_date, currency + bill_no = frappe.db.sql("""select bill_no, bill_date, currency from `tabPurchase Invoice` where name=%s""", d.against_voucher) if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() \ not in ['na', 'not applicable', 'none']: - r.append('%s %s against Bill %s dated %s' % - (cstr(bill_no[0][2]), fmt_money(flt(d.debit)), bill_no[0][0], + r.append('%s %s against Bill %s dated %s' % + (cstr(bill_no[0][2]), fmt_money(flt(d.debit)), bill_no[0][0], bill_no[0][1] and formatdate(bill_no[0][1].strftime('%Y-%m-%d')) or '')) - - if self.doc.user_remark: - r.append("User Remark : %s"%self.doc.user_remark) + + if self.user_remark: + r.append("User Remark : %s"%self.user_remark) if r: - self.doc.remark = ("\n").join(r) + self.remark = ("\n").join(r) else: frappe.msgprint("User Remarks is mandatory", raise_exception=1) def set_aging_date(self): - if self.doc.is_opening != 'Yes': - self.doc.aging_date = self.doc.posting_date + if self.is_opening != 'Yes': + self.aging_date = self.posting_date else: # check account type whether supplier or customer exists = False - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): account_type = frappe.db.get_value("Account", d.account, "account_type") if account_type in ["Supplier", "Customer"]: exists = True break # If customer/supplier account, aging date is mandatory - if exists and not self.doc.aging_date: + if exists and not self.aging_date: msgprint("Aging Date is mandatory for opening entry", raise_exception=1) else: - self.doc.aging_date = self.doc.posting_date + self.aging_date = self.posting_date def set_print_format_fields(self): - for d in getlist(self.doclist, 'entries'): - account_type, master_type = frappe.db.get_value("Account", d.account, + for d in self.get('entries'): + account_type, master_type = frappe.db.get_value("Account", d.account, ["account_type", "master_type"]) - + if master_type in ['Supplier', 'Customer']: - if not self.doc.pay_to_recd_from: - self.doc.pay_to_recd_from = frappe.db.get_value(master_type, - ' - '.join(d.account.split(' - ')[:-1]), + if not self.pay_to_recd_from: + self.pay_to_recd_from = frappe.db.get_value(master_type, + ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name') - + if account_type in ['Bank', 'Cash']: - company_currency = get_company_currency(self.doc.company) - amt = flt(d.debit) and d.debit or d.credit - self.doc.total_amount = company_currency + ' ' + cstr(amt) + company_currency = get_company_currency(self.company) + amt = flt(d.debit) and d.debit or d.credit + self.total_amount = company_currency + ' ' + cstr(amt) from frappe.utils import money_in_words - self.doc.total_amount_in_words = money_in_words(amt, company_currency) + self.total_amount_in_words = money_in_words(amt, company_currency) def check_credit_days(self): date_diff = 0 - if self.doc.cheque_date: - date_diff = (getdate(self.doc.cheque_date)-getdate(self.doc.posting_date)).days - + if self.cheque_date: + date_diff = (getdate(self.cheque_date)-getdate(self.posting_date)).days + if date_diff <= 0: return - + # Get List of Customer Account - acc_list = filter(lambda d: frappe.db.get_value("Account", d.account, - "master_type")=='Customer', getlist(self.doclist,'entries')) - + acc_list = filter(lambda d: frappe.db.get_value("Account", d.account, + "master_type")=='Customer', self.get('entries')) + for d in acc_list: credit_days = self.get_credit_days_for(d.account) # Check credit days if credit_days > 0 and not self.get_authorized_user() and cint(date_diff) > credit_days: msgprint("Credit Not Allowed: Cannot allow a check that is dated \ more than %s days after the posting date" % credit_days, raise_exception=1) - + def get_credit_days_for(self, ac): if not self.credit_days_for.has_key(ac): self.credit_days_for[ac] = cint(frappe.db.get_value("Account", ac, "credit_days")) if not self.credit_days_for[ac]: if self.credit_days_global==-1: - self.credit_days_global = cint(frappe.db.get_value("Company", - self.doc.company, "credit_days")) - + self.credit_days_global = cint(frappe.db.get_value("Company", + self.company, "credit_days")) + return self.credit_days_global else: return self.credit_days_for[ac] @@ -218,35 +216,35 @@ class DocType(AccountsController): self.is_approving_authority = 0 # Fetch credit controller role - approving_authority = frappe.db.get_value("Global Defaults", None, + approving_authority = frappe.db.get_value("Global Defaults", None, "credit_controller") - + # Check logged-in user is authorized if approving_authority in frappe.user.get_roles(): self.is_approving_authority = 1 - + return self.is_approving_authority def check_account_against_entries(self): - for d in self.doclist.get({"parentfield": "entries"}): - if d.against_invoice and frappe.db.get_value("Sales Invoice", + for d in self.get("entries"): + if d.against_invoice and frappe.db.get_value("Sales Invoice", d.against_invoice, "debit_to") != d.account: frappe.throw(_("Row #") + cstr(d.idx) + ": " + _("Account is not matching with Debit To account of Sales Invoice")) - - if d.against_voucher and frappe.db.get_value("Purchase Invoice", + + if d.against_voucher and frappe.db.get_value("Purchase Invoice", d.against_voucher, "credit_to") != d.account: frappe.throw(_("Row #") + cstr(d.idx) + ": " + _("Account is not matching with Credit To account of Purchase Invoice")) def make_gl_entries(self, cancel=0, adv_adj=0): from erpnext.accounts.general_ledger import make_gl_entries - + if not cancel: self.check_account_against_entries() - + gl_map = [] - for d in self.doclist.get({"parentfield": "entries"}): + for d in self.get("entries"): if d.debit or d.credit: gl_map.append( self.get_gl_dict({ @@ -254,87 +252,87 @@ class DocType(AccountsController): "against": d.against_account, "debit": d.debit, "credit": d.credit, - "against_voucher_type": ((d.against_voucher and "Purchase Invoice") - or (d.against_invoice and "Sales Invoice") + "against_voucher_type": ((d.against_voucher and "Purchase Invoice") + or (d.against_invoice and "Sales Invoice") or (d.against_jv and "Journal Voucher")), "against_voucher": d.against_voucher or d.against_invoice or d.against_jv, - "remarks": self.doc.remark, + "remarks": self.remark, "cost_center": d.cost_center }) ) if gl_map: make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj) - + def check_credit_limit(self): - for d in self.doclist.get({"parentfield": "entries"}): - master_type, master_name = frappe.db.get_value("Account", d.account, + for d in self.get("entries"): + master_type, master_name = frappe.db.get_value("Account", d.account, ["master_type", "master_name"]) if master_type == "Customer" and master_name: - super(DocType, self).check_credit_limit(d.account) + super(JournalVoucher, self).check_credit_limit(d.account) def get_balance(self): - if not getlist(self.doclist,'entries'): + if not self.get('entries'): msgprint("Please enter atleast 1 entry in 'GL Entries' table") else: - flag, self.doc.total_debit, self.doc.total_credit = 0, 0, 0 - diff = flt(self.doc.difference, 2) - + flag, self.total_debit, self.total_credit = 0, 0, 0 + diff = flt(self.difference, 2) + # If any row without amount, set the diff on that row - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if not d.credit and not d.debit and diff != 0: if diff>0: d.credit = diff elif diff<0: d.debit = diff flag = 1 - + # Set the diff in a new row if flag == 0 and diff != 0: - jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist) + jd = self.append('entries', {}) if diff>0: jd.credit = abs(diff) elif diff<0: jd.debit = abs(diff) - - # Set the total debit, total credit and difference - for d in getlist(self.doclist,'entries'): - self.doc.total_debit += flt(d.debit, 2) - self.doc.total_credit += flt(d.credit, 2) - self.doc.difference = flt(self.doc.total_debit, 2) - flt(self.doc.total_credit, 2) + # Set the total debit, total credit and difference + for d in self.get('entries'): + self.total_debit += flt(d.debit, 2) + self.total_credit += flt(d.credit, 2) + + self.difference = flt(self.total_debit, 2) - flt(self.total_credit, 2) def get_outstanding_invoices(self): - self.doclist = self.doc.clear_table(self.doclist, 'entries') + self.set('entries', []) total = 0 for d in self.get_values(): total += flt(d[2]) - jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist) + jd = self.append('entries', {}) jd.account = cstr(d[1]) - if self.doc.write_off_based_on == 'Accounts Receivable': + if self.write_off_based_on == 'Accounts Receivable': jd.credit = flt(d[2]) jd.against_invoice = cstr(d[0]) - elif self.doc.write_off_based_on == 'Accounts Payable': + elif self.write_off_based_on == 'Accounts Payable': jd.debit = flt(d[2]) jd.against_voucher = cstr(d[0]) jd.save(1) - jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist) - if self.doc.write_off_based_on == 'Accounts Receivable': + jd = self.append('entries', {}) + if self.write_off_based_on == 'Accounts Receivable': jd.debit = total - elif self.doc.write_off_based_on == 'Accounts Payable': + elif self.write_off_based_on == 'Accounts Payable': jd.credit = total jd.save(1) def get_values(self): - cond = (flt(self.doc.write_off_amount) > 0) and \ - ' and outstanding_amount <= '+ self.doc.write_off_amount or '' - if self.doc.write_off_based_on == 'Accounts Receivable': - return frappe.db.sql("""select name, debit_to, outstanding_amount - from `tabSales Invoice` where docstatus = 1 and company = %s - and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company) - elif self.doc.write_off_based_on == 'Accounts Payable': - return frappe.db.sql("""select name, credit_to, outstanding_amount - from `tabPurchase Invoice` where docstatus = 1 and company = %s - and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company) + cond = (flt(self.write_off_amount) > 0) and \ + ' and outstanding_amount <= '+ self.write_off_amount or '' + if self.write_off_based_on == 'Accounts Receivable': + return frappe.db.sql("""select name, debit_to, outstanding_amount + from `tabSales Invoice` where docstatus = 1 and company = %s + and outstanding_amount > 0 %s""" % ('%s', cond), self.company) + elif self.write_off_based_on == 'Accounts Payable': + return frappe.db.sql("""select name, credit_to, outstanding_amount + from `tabPurchase Invoice` where docstatus = 1 and company = %s + and outstanding_amount > 0 %s""" % ('%s', cond), self.company) @frappe.whitelist() def get_default_bank_cash_account(company, voucher_type): @@ -346,122 +344,115 @@ def get_default_bank_cash_account(company, voucher_type): "account": account, "balance": get_balance_on(account) } - + @frappe.whitelist() def get_payment_entry_from_sales_invoice(sales_invoice): from erpnext.accounts.utils import get_balance_on - si = frappe.bean("Sales Invoice", sales_invoice) - jv = get_payment_entry(si.doc) - jv.doc.remark = 'Payment received against Sales Invoice %(name)s. %(remarks)s' % si.doc.fields + si = frappe.get_doc("Sales Invoice", sales_invoice) + jv = get_payment_entry(si) + jv.remark = 'Payment received against Sales Invoice {0}. {1}'.format(si.name, si.remarks) # credit customer - jv.doclist[1].account = si.doc.debit_to - jv.doclist[1].balance = get_balance_on(si.doc.debit_to) - jv.doclist[1].credit = si.doc.outstanding_amount - jv.doclist[1].against_invoice = si.doc.name + jv.get("entries")[0].account = si.debit_to + jv.get("entries")[0].balance = get_balance_on(si.debit_to) + jv.get("entries")[0].credit = si.outstanding_amount + jv.get("entries")[0].against_invoice = si.name # debit bank - jv.doclist[2].debit = si.doc.outstanding_amount - - return [d.fields for d in jv.doclist] + jv.get("entries")[1].debit = si.outstanding_amount + + return jv.as_dict() @frappe.whitelist() def get_payment_entry_from_purchase_invoice(purchase_invoice): from erpnext.accounts.utils import get_balance_on - pi = frappe.bean("Purchase Invoice", purchase_invoice) - jv = get_payment_entry(pi.doc) - jv.doc.remark = 'Payment against Purchase Invoice %(name)s. %(remarks)s' % pi.doc.fields - + pi = frappe.get_doc("Purchase Invoice", purchase_invoice) + jv = get_payment_entry(pi) + jv.remark = 'Payment against Purchase Invoice {0}. {1}'.format(pi.name, pi.remarks) + # credit supplier - jv.doclist[1].account = pi.doc.credit_to - jv.doclist[1].balance = get_balance_on(pi.doc.credit_to) - jv.doclist[1].debit = pi.doc.outstanding_amount - jv.doclist[1].against_voucher = pi.doc.name + jv.get("entries")[0].account = pi.credit_to + jv.get("entries")[0].balance = get_balance_on(pi.credit_to) + jv.get("entries")[0].debit = pi.outstanding_amount + jv.get("entries")[0].against_voucher = pi.name # credit bank - jv.doclist[2].credit = pi.doc.outstanding_amount - - return [d.fields for d in jv.doclist] + jv.get("entries")[1].credit = pi.outstanding_amount + + return jv.as_dict() def get_payment_entry(doc): bank_account = get_default_bank_cash_account(doc.company, "Bank Voucher") - - jv = frappe.new_bean('Journal Voucher') - jv.doc.voucher_type = 'Bank Voucher' - jv.doc.company = doc.company - jv.doc.fiscal_year = doc.fiscal_year + jv = frappe.new_doc('Journal Voucher') + jv.voucher_type = 'Bank Voucher' - jv.doclist.append({ - "doctype": "Journal Voucher Detail", - "parentfield": "entries" - }) + jv.company = doc.company + jv.fiscal_year = doc.fiscal_year + + d1 = jv.append("entries") + d2 = jv.append("entries") - jv.doclist.append({ - "doctype": "Journal Voucher Detail", - "parentfield": "entries" - }) - if bank_account: - jv.doclist[2].account = bank_account["account"] - jv.doclist[2].balance = bank_account["balance"] - + d2.account = bank_account["account"] + d2.balance = bank_account["balance"] + return jv - + @frappe.whitelist() def get_opening_accounts(company): """get all balance sheet accounts for opening entry""" from erpnext.accounts.utils import get_balance_on - accounts = frappe.db.sql_list("""select name from tabAccount + accounts = frappe.db.sql_list("""select name from tabAccount where group_or_ledger='Ledger' and report_type='Profit and Loss' and company=%s""", company) - + return [{"account": a, "balance": get_balance_on(a)} for a in accounts] - + def get_against_purchase_invoice(doctype, txt, searchfield, start, page_len, filters): - return frappe.db.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date - from `tabPurchase Invoice` where credit_to = %s and docstatus = 1 + return frappe.db.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date + from `tabPurchase Invoice` where credit_to = %s and docstatus = 1 and outstanding_amount > 0 and %s like %s order by name desc limit %s, %s""" % - ("%s", searchfield, "%s", "%s", "%s"), - (filters["account"], "%%%s%%" % txt, start, page_len)) - -def get_against_sales_invoice(doctype, txt, searchfield, start, page_len, filters): - return frappe.db.sql("""select name, debit_to, outstanding_amount - from `tabSales Invoice` where debit_to = %s and docstatus = 1 - and outstanding_amount > 0 and `%s` like %s order by name desc limit %s, %s""" % - ("%s", searchfield, "%s", "%s", "%s"), - (filters["account"], "%%%s%%" % txt, start, page_len)) - -def get_against_jv(doctype, txt, searchfield, start, page_len, filters): - return frappe.db.sql("""select jv.name, jv.posting_date, jv.user_remark - from `tabJournal Voucher` jv, `tabJournal Voucher Detail` jv_detail - where jv_detail.parent = jv.name and jv_detail.account = %s and jv.docstatus = 1 - and jv.%s like %s order by jv.name desc limit %s, %s""" % - ("%s", searchfield, "%s", "%s", "%s"), + ("%s", searchfield, "%s", "%s", "%s"), (filters["account"], "%%%s%%" % txt, start, page_len)) -@frappe.whitelist() +def get_against_sales_invoice(doctype, txt, searchfield, start, page_len, filters): + return frappe.db.sql("""select name, debit_to, outstanding_amount + from `tabSales Invoice` where debit_to = %s and docstatus = 1 + and outstanding_amount > 0 and `%s` like %s order by name desc limit %s, %s""" % + ("%s", searchfield, "%s", "%s", "%s"), + (filters["account"], "%%%s%%" % txt, start, page_len)) + +def get_against_jv(doctype, txt, searchfield, start, page_len, filters): + return frappe.db.sql("""select jv.name, jv.posting_date, jv.user_remark + from `tabJournal Voucher` jv, `tabJournal Voucher Detail` jv_detail + where jv_detail.parent = jv.name and jv_detail.account = %s and jv.docstatus = 1 + and jv.%s like %s order by jv.name desc limit %s, %s""" % + ("%s", searchfield, "%s", "%s", "%s"), + (filters["account"], "%%%s%%" % txt, start, page_len)) + +@frappe.whitelist() def get_outstanding(args): args = eval(args) if args.get("doctype") == "Journal Voucher" and args.get("account"): against_jv_amount = frappe.db.sql(""" - select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) - from `tabJournal Voucher Detail` where parent=%s and account=%s + select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) + from `tabJournal Voucher Detail` where parent=%s and account=%s and ifnull(against_invoice, '')='' and ifnull(against_voucher, '')='' and ifnull(against_jv, '')=''""", (args['docname'], args['account'])) - + against_jv_amount = flt(against_jv_amount[0][0]) if against_jv_amount else 0 if against_jv_amount > 0: return {"credit": against_jv_amount} else: return {"debit": -1* against_jv_amount} - + elif args.get("doctype") == "Sales Invoice": return { - "credit": flt(frappe.db.get_value("Sales Invoice", args["docname"], + "credit": flt(frappe.db.get_value("Sales Invoice", args["docname"], "outstanding_amount")) } elif args.get("doctype") == "Purchase Invoice": return { - "debit": flt(frappe.db.get_value("Purchase Invoice", args["docname"], + "debit": flt(frappe.db.get_value("Purchase Invoice", args["docname"], "outstanding_amount")) } diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.txt b/erpnext/accounts/doctype/journal_voucher/journal_voucher.txt deleted file mode 100644 index 73710f935d9..00000000000 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.txt +++ /dev/null @@ -1,503 +0,0 @@ -[ - { - "creation": "2013-03-25 10:53:52", - "docstatus": 0, - "modified": "2014-01-20 17:48:51", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "icon": "icon-file-text", - "is_submittable": 1, - "module": "Accounts", - "name": "__common__", - "read_only_onload": 1, - "search_fields": "voucher_type,posting_date, due_date, cheque_no" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Journal Voucher", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Journal Voucher", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Journal Voucher" - }, - { - "doctype": "DocField", - "fieldname": "voucher_type_and_date", - "fieldtype": "Section Break", - "label": "Voucher Type and Date", - "options": "icon-flag" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "JV", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "voucher_type", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Voucher Type", - "oldfieldname": "voucher_type", - "oldfieldtype": "Select", - "options": "\nJournal Entry\nBank Voucher\nCash Voucher\nCredit Card Voucher\nDebit Note\nCredit Note\nContra Voucher\nExcise Voucher\nWrite Off Voucher\nOpening Entry", - "print_hide": 0, - "read_only": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "in_filter": 1, - "in_list_view": 1, - "label": "Posting Date", - "no_copy": 1, - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "2_add_edit_gl_entries", - "fieldtype": "Section Break", - "label": "Journal Entries", - "oldfieldtype": "Section Break", - "options": "icon-table", - "read_only": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "entries", - "fieldtype": "Table", - "label": "Entries", - "oldfieldname": "entries", - "oldfieldtype": "Table", - "options": "Journal Voucher Detail", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break99", - "fieldtype": "Section Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "total_debit", - "fieldtype": "Currency", - "in_filter": 1, - "in_list_view": 1, - "label": "Total Debit", - "no_copy": 1, - "oldfieldname": "total_debit", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_credit", - "fieldtype": "Currency", - "in_filter": 1, - "label": "Total Credit", - "no_copy": 1, - "oldfieldname": "total_credit", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break99", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "difference", - "fieldtype": "Currency", - "label": "Difference", - "no_copy": 1, - "oldfieldname": "difference", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "get_balance", - "fieldtype": "Button", - "label": "Make Difference Entry", - "oldfieldtype": "Button", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "reference", - "fieldtype": "Section Break", - "label": "Reference", - "options": "icon-pushpin", - "read_only": 0 - }, - { - "description": "eg. Cheque Number", - "doctype": "DocField", - "fieldname": "cheque_no", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Reference Number", - "no_copy": 1, - "oldfieldname": "cheque_no", - "oldfieldtype": "Data", - "read_only": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "cheque_date", - "fieldtype": "Date", - "label": "Reference Date", - "no_copy": 1, - "oldfieldname": "cheque_date", - "oldfieldtype": "Date", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "clearance_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Clearance Date", - "no_copy": 1, - "oldfieldname": "clearance_date", - "oldfieldtype": "Date", - "print_hide": 0, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break98", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "user_remark", - "fieldtype": "Small Text", - "in_filter": 1, - "label": "User Remark", - "no_copy": 1, - "oldfieldname": "user_remark", - "oldfieldtype": "Small Text", - "read_only": 0 - }, - { - "description": "User Remark will be added to Auto Remark", - "doctype": "DocField", - "fieldname": "remark", - "fieldtype": "Small Text", - "in_list_view": 0, - "label": "Remark", - "no_copy": 1, - "oldfieldname": "remark", - "oldfieldtype": "Small Text", - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "bill_no", - "fieldtype": "Data", - "in_list_view": 0, - "label": "Bill No", - "oldfieldname": "bill_no", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "bill_date", - "fieldtype": "Date", - "label": "Bill Date", - "oldfieldname": "bill_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "due_date", - "fieldtype": "Date", - "label": "Due Date", - "oldfieldname": "due_date", - "oldfieldtype": "Date", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "addtional_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "default": "No", - "description": "Considered as Opening Balance", - "doctype": "DocField", - "fieldname": "is_opening", - "fieldtype": "Select", - "in_filter": 1, - "label": "Is Opening", - "oldfieldname": "is_opening", - "oldfieldtype": "Select", - "options": "No\nYes", - "print_hide": 1, - "read_only": 0, - "search_index": 1 - }, - { - "description": "Actual Posting Date", - "doctype": "DocField", - "fieldname": "aging_date", - "fieldtype": "Date", - "label": "Aging Date", - "no_copy": 0, - "oldfieldname": "aging_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 0 - }, - { - "default": "Accounts Receivable", - "depends_on": "eval:doc.voucher_type == 'Write Off Voucher'", - "doctype": "DocField", - "fieldname": "write_off_based_on", - "fieldtype": "Select", - "label": "Write Off Based On", - "options": "Accounts Receivable\nAccounts Payable", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "depends_on": "eval:doc.voucher_type == 'Write Off Voucher'", - "doctype": "DocField", - "fieldname": "write_off_amount", - "fieldtype": "Currency", - "label": "Write Off Amount <=", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "depends_on": "eval:doc.voucher_type == 'Write Off Voucher'", - "doctype": "DocField", - "fieldname": "get_outstanding_invoices", - "fieldtype": "Button", - "label": "Get Outstanding Invoices", - "options": "get_outstanding_invoices", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Link", - "label": "Letter Head", - "options": "Letter Head" - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "pay_to_recd_from", - "fieldtype": "Data", - "hidden": 0, - "label": "Pay To / Recd From", - "no_copy": 1, - "print_hide": 0, - "read_only": 0, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_amount", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Total Amount", - "no_copy": 1, - "print_hide": 1, - "read_only": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_amount_in_words", - "fieldtype": "Data", - "hidden": 1, - "label": "Total Amount in Words", - "no_copy": 1, - "print_hide": 1, - "read_only": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Link", - "options": "Journal Voucher", - "print_hide": 1, - "read_only": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Accounts User", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Accounts Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Auditor", - "submit": 0, - "write": 0 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py index 35e2155d69b..425baf16f4b 100644 --- a/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py @@ -9,200 +9,127 @@ import frappe class TestJournalVoucher(unittest.TestCase): def test_journal_voucher_with_against_jv(self): self.clear_account_balance() - jv_invoice = frappe.bean(copy=test_records[2]) + jv_invoice = frappe.copy_doc(test_records[2]) jv_invoice.insert() jv_invoice.submit() - + + self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail` + where account = %s and docstatus = 1 and parent = %s""", + ("_Test Customer - _TC", jv_invoice.name))) + self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail` - where against_jv=%s""", jv_invoice.doc.name)) - - jv_payment = frappe.bean(copy=test_records[0]) - jv_payment.doclist[1].against_jv = jv_invoice.doc.name + where against_jv=%s""", jv_invoice.name)) + + jv_payment = frappe.copy_doc(test_records[0]) + jv_payment.get("entries")[0].against_jv = jv_invoice.name jv_payment.insert() jv_payment.submit() - + self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail` - where against_jv=%s""", jv_invoice.doc.name)) - + where against_jv=%s""", jv_invoice.name)) + self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail` - where against_jv=%s and credit=400""", jv_invoice.doc.name)) - + where against_jv=%s and credit=400""", jv_invoice.name)) + # cancel jv_invoice jv_invoice.cancel() - + self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail` - where against_jv=%s""", jv_invoice.doc.name)) - + where against_jv=%s""", jv_invoice.name)) + def test_jv_against_stock_account(self): from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory set_perpetual_inventory() - - jv = frappe.bean(copy=test_records[0]) - jv.doclist[1].account = "_Test Warehouse - _TC" + + jv = frappe.copy_doc(test_records[0]) + jv.get("entries")[0].account = "_Test Warehouse - _TC" jv.insert() - + from erpnext.accounts.general_ledger import StockAccountInvalidTransaction self.assertRaises(StockAccountInvalidTransaction, jv.submit) set_perpetual_inventory(0) - + def test_monthly_budget_crossed_ignore(self): frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore") self.clear_account_balance() - - jv = frappe.bean(copy=test_records[0]) - jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" - jv.doclist[2].cost_center = "_Test Cost Center - _TC" - jv.doclist[2].debit = 20000.0 - jv.doclist[1].credit = 20000.0 + + jv = frappe.copy_doc(test_records[0]) + jv.get("entries")[1].account = "_Test Account Cost for Goods Sold - _TC" + jv.get("entries")[1].cost_center = "_Test Cost Center - _TC" + jv.get("entries")[1].debit = 20000.0 + jv.get("entries")[0].credit = 20000.0 jv.insert() jv.submit() - self.assertTrue(frappe.db.get_value("GL Entry", - {"voucher_type": "Journal Voucher", "voucher_no": jv.doc.name})) - + self.assertTrue(frappe.db.get_value("GL Entry", + {"voucher_type": "Journal Voucher", "voucher_no": jv.name})) + def test_monthly_budget_crossed_stop(self): from erpnext.accounts.utils import BudgetError frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop") self.clear_account_balance() - - jv = frappe.bean(copy=test_records[0]) - jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" - jv.doclist[2].cost_center = "_Test Cost Center - _TC" - jv.doclist[2].debit = 20000.0 - jv.doclist[1].credit = 20000.0 + + jv = frappe.copy_doc(test_records[0]) + jv.get("entries")[1].account = "_Test Account Cost for Goods Sold - _TC" + jv.get("entries")[1].cost_center = "_Test Cost Center - _TC" + jv.get("entries")[1].debit = 20000.0 + jv.get("entries")[0].credit = 20000.0 jv.insert() - + self.assertRaises(BudgetError, jv.submit) - + frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore") - + def test_yearly_budget_crossed_stop(self): from erpnext.accounts.utils import BudgetError self.clear_account_balance() self.test_monthly_budget_crossed_ignore() - + frappe.db.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop") - - jv = frappe.bean(copy=test_records[0]) - jv.doc.posting_date = "2013-08-12" - jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" - jv.doclist[2].cost_center = "_Test Cost Center - _TC" - jv.doclist[2].debit = 150000.0 - jv.doclist[1].credit = 150000.0 + + jv = frappe.copy_doc(test_records[0]) + jv.posting_date = "2013-08-12" + jv.get("entries")[1].account = "_Test Account Cost for Goods Sold - _TC" + jv.get("entries")[1].cost_center = "_Test Cost Center - _TC" + jv.get("entries")[1].debit = 150000.0 + jv.get("entries")[0].credit = 150000.0 jv.insert() - + self.assertRaises(BudgetError, jv.submit) - + frappe.db.set_value("Company", "_Test Company", "yearly_bgt_flag", "Ignore") - + def test_monthly_budget_on_cancellation(self): from erpnext.accounts.utils import BudgetError frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop") self.clear_account_balance() - - jv = frappe.bean(copy=test_records[0]) - jv.doclist[1].account = "_Test Account Cost for Goods Sold - _TC" - jv.doclist[1].cost_center = "_Test Cost Center - _TC" - jv.doclist[1].credit = 30000.0 - jv.doclist[2].debit = 30000.0 + + jv = frappe.copy_doc(test_records[0]) + jv.get("entries")[0].account = "_Test Account Cost for Goods Sold - _TC" + jv.get("entries")[0].cost_center = "_Test Cost Center - _TC" + jv.get("entries")[0].credit = 30000.0 + jv.get("entries")[1].debit = 30000.0 jv.submit() - - self.assertTrue(frappe.db.get_value("GL Entry", - {"voucher_type": "Journal Voucher", "voucher_no": jv.doc.name})) - - jv1 = frappe.bean(copy=test_records[0]) - jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" - jv1.doclist[2].cost_center = "_Test Cost Center - _TC" - jv1.doclist[2].debit = 40000.0 - jv1.doclist[1].credit = 40000.0 + + self.assertTrue(frappe.db.get_value("GL Entry", + {"voucher_type": "Journal Voucher", "voucher_no": jv.name})) + + jv1 = frappe.copy_doc(test_records[0]) + jv1.get("entries")[1].account = "_Test Account Cost for Goods Sold - _TC" + jv1.get("entries")[1].cost_center = "_Test Cost Center - _TC" + jv1.get("entries")[1].debit = 40000.0 + jv1.get("entries")[0].credit = 40000.0 jv1.submit() - - self.assertTrue(frappe.db.get_value("GL Entry", - {"voucher_type": "Journal Voucher", "voucher_no": jv1.doc.name})) - + + self.assertTrue(frappe.db.get_value("GL Entry", + {"voucher_type": "Journal Voucher", "voucher_no": jv1.name})) + self.assertRaises(BudgetError, jv.cancel) - + frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore") - + def clear_account_balance(self): frappe.db.sql("""delete from `tabGL Entry`""") - -test_records = [ - [{ - "company": "_Test Company", - "doctype": "Journal Voucher", - "fiscal_year": "_Test Fiscal Year 2013", - "naming_series": "_T-Journal Voucher-", - "posting_date": "2013-02-14", - "user_remark": "test", - "voucher_type": "Bank Voucher", - "cheque_no": "33", - "cheque_date": "2013-02-14" - }, - { - "account": "_Test Customer - _TC", - "doctype": "Journal Voucher Detail", - "credit": 400.0, - "debit": 0.0, - "parentfield": "entries" - }, - { - "account": "_Test Account Bank Account - _TC", - "doctype": "Journal Voucher Detail", - "debit": 400.0, - "credit": 0.0, - "parentfield": "entries" - }], - [{ - "company": "_Test Company", - "doctype": "Journal Voucher", - "fiscal_year": "_Test Fiscal Year 2013", - "naming_series": "_T-Journal Voucher-", - "posting_date": "2013-02-14", - "user_remark": "test", - "voucher_type": "Bank Voucher", - "cheque_no": "33", - "cheque_date": "2013-02-14" - }, - { - "account": "_Test Supplier - _TC", - "doctype": "Journal Voucher Detail", - "credit": 0.0, - "debit": 400.0, - "parentfield": "entries" - }, - { - "account": "_Test Account Bank Account - _TC", - "doctype": "Journal Voucher Detail", - "debit": 0.0, - "credit": 400.0, - "parentfield": "entries" - }], - [{ - "company": "_Test Company", - "doctype": "Journal Voucher", - "fiscal_year": "_Test Fiscal Year 2013", - "naming_series": "_T-Journal Voucher-", - "posting_date": "2013-02-14", - "user_remark": "test", - "voucher_type": "Bank Voucher", - "cheque_no": "33", - "cheque_date": "2013-02-14" - }, - { - "account": "_Test Customer - _TC", - "doctype": "Journal Voucher Detail", - "credit": 0.0, - "debit": 400.0, - "parentfield": "entries" - }, - { - "account": "Sales - _TC", - "doctype": "Journal Voucher Detail", - "credit": 400.0, - "debit": 0.0, - "parentfield": "entries", - "cost_center": "_Test Cost Center - _TC" - }], -] \ No newline at end of file + +test_records = frappe.get_test_records('Journal Voucher') diff --git a/erpnext/accounts/doctype/journal_voucher/test_records.json b/erpnext/accounts/doctype/journal_voucher/test_records.json new file mode 100644 index 00000000000..9355c50a180 --- /dev/null +++ b/erpnext/accounts/doctype/journal_voucher/test_records.json @@ -0,0 +1,84 @@ +[ + { + "cheque_date": "2013-02-14", + "cheque_no": "33", + "company": "_Test Company", + "doctype": "Journal Voucher", + "entries": [ + { + "account": "_Test Customer - _TC", + "credit": 400.0, + "debit": 0.0, + "doctype": "Journal Voucher Detail", + "parentfield": "entries" + }, + { + "account": "_Test Account Bank Account - _TC", + "credit": 0.0, + "debit": 400.0, + "doctype": "Journal Voucher Detail", + "parentfield": "entries" + } + ], + "fiscal_year": "_Test Fiscal Year 2013", + "naming_series": "_T-Journal Voucher-", + "posting_date": "2013-02-14", + "user_remark": "test", + "voucher_type": "Bank Voucher" + }, + { + "cheque_date": "2013-02-14", + "cheque_no": "33", + "company": "_Test Company", + "doctype": "Journal Voucher", + "entries": [ + { + "account": "_Test Supplier - _TC", + "credit": 0.0, + "debit": 400.0, + "doctype": "Journal Voucher Detail", + "parentfield": "entries" + }, + { + "account": "_Test Account Bank Account - _TC", + "credit": 400.0, + "debit": 0.0, + "doctype": "Journal Voucher Detail", + "parentfield": "entries" + } + ], + "fiscal_year": "_Test Fiscal Year 2013", + "naming_series": "_T-Journal Voucher-", + "posting_date": "2013-02-14", + "user_remark": "test", + "voucher_type": "Bank Voucher" + }, + { + "cheque_date": "2013-02-14", + "cheque_no": "33", + "company": "_Test Company", + "doctype": "Journal Voucher", + "entries": [ + { + "account": "_Test Customer - _TC", + "credit": 0.0, + "debit": 400.0, + "doctype": "Journal Voucher Detail", + "parentfield": "entries" + }, + { + "account": "Sales - _TC", + "cost_center": "_Test Cost Center - _TC", + "credit": 400.0, + "debit": 0.0, + "doctype": "Journal Voucher Detail", + "parentfield": "entries" + } + ], + "fiscal_year": "_Test Fiscal Year 2013", + "naming_series": "_T-Journal Voucher-", + "posting_date": "2013-02-14", + "user_remark": "test", + "voucher_type": "Bank Voucher" + } +] diff --git a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.json b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.json new file mode 100644 index 00000000000..defd88e6dbc --- /dev/null +++ b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.json @@ -0,0 +1,166 @@ +{ + "autoname": "JVD.######", + "creation": "2013-02-22 01:27:39.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "account", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Account", + "oldfieldname": "account", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "print_width": "250px", + "reqd": 1, + "search_index": 1, + "width": "250px" + }, + { + "default": ":Company", + "description": "If Income or Expense", + "fieldname": "cost_center", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Cost Center", + "oldfieldname": "cost_center", + "oldfieldtype": "Link", + "options": "Cost Center", + "permlevel": 0, + "print_width": "180px", + "search_index": 0, + "width": "180px" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "balance", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Account Balance", + "no_copy": 1, + "oldfieldname": "balance", + "oldfieldtype": "Data", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "sec_break1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "debit", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Debit", + "oldfieldname": "debit", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "credit", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Credit", + "oldfieldname": "credit", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "reference", + "fieldtype": "Section Break", + "label": "Reference", + "permlevel": 0 + }, + { + "fieldname": "against_invoice", + "fieldtype": "Link", + "in_filter": 1, + "label": "Against Sales Invoice", + "no_copy": 1, + "oldfieldname": "against_invoice", + "oldfieldtype": "Link", + "options": "Sales Invoice", + "permlevel": 0, + "print_hide": 0, + "search_index": 1 + }, + { + "fieldname": "against_voucher", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Against Purchase Invoice", + "no_copy": 1, + "oldfieldname": "against_voucher", + "oldfieldtype": "Link", + "options": "Purchase Invoice", + "permlevel": 0, + "print_hide": 0, + "search_index": 1 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "against_jv", + "fieldtype": "Link", + "in_filter": 1, + "label": "Against Journal Voucher", + "no_copy": 1, + "oldfieldname": "against_jv", + "oldfieldtype": "Link", + "options": "Journal Voucher", + "permlevel": 0, + "print_hide": 0, + "search_index": 1 + }, + { + "fieldname": "is_advance", + "fieldtype": "Select", + "label": "Is Advance", + "no_copy": 1, + "oldfieldname": "is_advance", + "oldfieldtype": "Select", + "options": "No\nYes", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "against_account", + "fieldtype": "Text", + "hidden": 1, + "label": "Against Account", + "no_copy": 1, + "oldfieldname": "against_account", + "oldfieldtype": "Text", + "permlevel": 0, + "print_hide": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-03 12:44:31.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Journal Voucher Detail", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py index 26c87f1c04a..36700d2dc37 100644 --- a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py +++ b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class JournalVoucherDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt deleted file mode 100644 index c03e025c07d..00000000000 --- a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt +++ /dev/null @@ -1,179 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:39", - "docstatus": 0, - "modified": "2014-02-03 12:44:31", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "JVD.######", - "doctype": "DocType", - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Journal Voucher Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Journal Voucher Detail" - }, - { - "doctype": "DocField", - "fieldname": "account", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Account", - "oldfieldname": "account", - "oldfieldtype": "Link", - "options": "Account", - "print_width": "250px", - "reqd": 1, - "search_index": 1, - "width": "250px" - }, - { - "default": ":Company", - "description": "If Income or Expense", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Cost Center", - "oldfieldname": "cost_center", - "oldfieldtype": "Link", - "options": "Cost Center", - "print_width": "180px", - "search_index": 0, - "width": "180px" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "balance", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Account Balance", - "no_copy": 1, - "oldfieldname": "balance", - "oldfieldtype": "Data", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "sec_break1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "debit", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Debit", - "oldfieldname": "debit", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "credit", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Credit", - "oldfieldname": "credit", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "reference", - "fieldtype": "Section Break", - "label": "Reference" - }, - { - "doctype": "DocField", - "fieldname": "against_invoice", - "fieldtype": "Link", - "in_filter": 1, - "label": "Against Sales Invoice", - "no_copy": 1, - "oldfieldname": "against_invoice", - "oldfieldtype": "Link", - "options": "Sales Invoice", - "print_hide": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "against_voucher", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Against Purchase Invoice", - "no_copy": 1, - "oldfieldname": "against_voucher", - "oldfieldtype": "Link", - "options": "Purchase Invoice", - "print_hide": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "against_jv", - "fieldtype": "Link", - "in_filter": 1, - "label": "Against Journal Voucher", - "no_copy": 1, - "oldfieldname": "against_jv", - "oldfieldtype": "Link", - "options": "Journal Voucher", - "print_hide": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "is_advance", - "fieldtype": "Select", - "label": "Is Advance", - "no_copy": 1, - "oldfieldname": "is_advance", - "oldfieldtype": "Select", - "options": "No\nYes", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "against_account", - "fieldtype": "Text", - "hidden": 1, - "label": "Against Account", - "no_copy": 1, - "oldfieldname": "against_account", - "oldfieldtype": "Text", - "print_hide": 1 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json new file mode 100644 index 00000000000..870c18565af --- /dev/null +++ b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json @@ -0,0 +1,58 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:mode_of_payment", + "creation": "2012-12-04 17:49:20.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "mode_of_payment", + "fieldtype": "Data", + "label": "Mode of Payment", + "oldfieldname": "mode_of_payment", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Default Bank / Cash account will be automatically updated in POS Invoice when this mode is selected.", + "fieldname": "default_account", + "fieldtype": "Link", + "label": "Default Account", + "options": "Account", + "permlevel": 0, + "read_only": 0 + } + ], + "icon": "icon-credit-card", + "idx": 1, + "modified": "2013-12-20 19:24:14.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Mode of Payment", + "owner": "harshada@webnotestech.com", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py index 26c87f1c04a..ddabf8973f9 100644 --- a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py +++ b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ModeOfPayment(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.txt b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.txt deleted file mode 100644 index 58300306f18..00000000000 --- a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.txt +++ /dev/null @@ -1,75 +0,0 @@ -[ - { - "creation": "2012-12-04 17:49:20", - "docstatus": 0, - "modified": "2013-12-20 19:24:14", - "modified_by": "Administrator", - "owner": "harshada@webnotestech.com" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:mode_of_payment", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-credit-card", - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Mode of Payment", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "read_only": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Mode of Payment", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Accounts Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Mode of Payment" - }, - { - "doctype": "DocField", - "fieldname": "mode_of_payment", - "fieldtype": "Data", - "label": "Mode of Payment", - "oldfieldname": "mode_of_payment", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company" - }, - { - "description": "Default Bank / Cash account will be automatically updated in POS Invoice when this mode is selected.", - "doctype": "DocField", - "fieldname": "default_account", - "fieldtype": "Link", - "label": "Default Account", - "options": "Account" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.json b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.json new file mode 100644 index 00000000000..ce1a06b8e2e --- /dev/null +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.json @@ -0,0 +1,186 @@ +{ + "creation": "2013-01-30 12:49:46.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Other", + "fields": [ + { + "fieldname": "account", + "fieldtype": "Link", + "label": "Account", + "options": "Account", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "account_type", + "fieldtype": "Data", + "hidden": 1, + "label": "Account Type", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "hidden": 1, + "label": "Company", + "options": "Company", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "voucher_type", + "fieldtype": "Select", + "label": "Voucher Type", + "options": "Sales Invoice\nPurchase Invoice\nJournal Voucher", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "voucher_no", + "fieldtype": "Link", + "label": "Voucher No", + "options": "[Select]", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "pull_payment_entries", + "fieldtype": "Button", + "label": "Pull Payment Entries", + "options": "get_payment_entries", + "permlevel": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "total_amount", + "fieldtype": "Currency", + "label": "Total Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "pending_amt_to_reconcile", + "fieldtype": "Currency", + "label": "Outstanding Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "payment_entries", + "fieldtype": "Section Break", + "label": "Payment Entries", + "permlevel": 0 + }, + { + "description": "Update allocated amount in the above table and then click \"Allocate\" button", + "fieldname": "ir_payment_details", + "fieldtype": "Table", + "label": "Payment Entries", + "options": "Payment to Invoice Matching Tool Detail", + "permlevel": 0 + }, + { + "fieldname": "reconcile", + "fieldtype": "Button", + "label": "Allocate", + "options": "reconcile", + "permlevel": 0 + }, + { + "fieldname": "section_break0", + "fieldtype": "Section Break", + "options": "Simple", + "permlevel": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "label": "Filter By Date", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "from_date", + "fieldtype": "Date", + "label": "From Date", + "permlevel": 0 + }, + { + "fieldname": "to_date", + "fieldtype": "Date", + "label": "To Date", + "permlevel": 0 + }, + { + "fieldname": "help_html", + "fieldtype": "HTML", + "label": "Help HTML", + "options": "Click \"Pull Payment Entries\" to refresh the table with filters.", + "permlevel": 0 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "label": "Filter By Amount", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "amt_greater_than", + "fieldtype": "Data", + "label": "Amount >=", + "permlevel": 0 + }, + { + "fieldname": "amt_less_than", + "fieldtype": "Data", + "label": "Amount <=", + "permlevel": 0 + } + ], + "hide_toolbar": 1, + "icon": "icon-magic", + "idx": 1, + "issingle": 1, + "modified": "2013-12-20 19:23:24.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Payment to Invoice Matching Tool", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + }, + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "Accounts User", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py index 5b2360888b4..cff24e14e86 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py @@ -5,26 +5,23 @@ from __future__ import unicode_literals import frappe from frappe.utils import flt -from frappe.model.doc import addchild -from frappe.model.bean import getlist + from frappe import msgprint, _ -class DocType: - def __init__(self, doc, doclist): - self.doc = doc - self.doclist = doclist - +from frappe.model.document import Document + +class PaymenttoInvoiceMatchingTool(Document): def get_voucher_details(self): total_amount = frappe.db.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabGL Entry` where voucher_type = %s and voucher_no = %s - and account = %s""", (self.doc.voucher_type, self.doc.voucher_no, self.doc.account)) + and account = %s""", (self.voucher_type, self.voucher_no, self.account)) total_amount = total_amount and flt(total_amount[0][0]) or 0 reconciled_payment = frappe.db.sql(""" select abs(sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))) from `tabGL Entry` where against_voucher = %s and voucher_no != %s - and account = %s""", (self.doc.voucher_no, self.doc.voucher_no, self.doc.account)) + and account = %s""", (self.voucher_no, self.voucher_no, self.account)) reconciled_payment = reconciled_payment and flt(reconciled_payment[0][0]) or 0 ret = { @@ -40,22 +37,22 @@ class DocType: Payment entry will be decided based on account type (Dr/Cr) """ - self.doclist = self.doc.clear_table(self.doclist, 'ir_payment_details') + self.set('ir_payment_details', []) gle = self.get_gl_entries() self.create_payment_table(gle) def get_gl_entries(self): self.validate_mandatory() - cond = self.doc.from_date and " and t1.posting_date >= '" + self.doc.from_date + "'" or "" - cond += self.doc.to_date and " and t1.posting_date <= '" + self.doc.to_date + "'"or "" + cond = self.from_date and " and t1.posting_date >= '" + self.from_date + "'" or "" + cond += self.to_date and " and t1.posting_date <= '" + self.to_date + "'"or "" - if self.doc.amt_greater_than: + if self.amt_greater_than: cond += ' and abs(ifnull(t2.debit, 0) - ifnull(t2.credit, 0)) >= ' + \ - self.doc.amt_greater_than - if self.doc.amt_less_than: + self.amt_greater_than + if self.amt_less_than: cond += ' and abs(ifnull(t2.debit, 0) - ifnull(t2.credit, 0)) >= ' + \ - self.doc.amt_less_than + self.amt_less_than gle = frappe.db.sql(""" select t1.name as voucher_no, t1.posting_date, t1.total_debit as total_amt, @@ -65,14 +62,13 @@ class DocType: where t1.name = t2.parent and t1.docstatus = 1 and t2.account = %s and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')='' and ifnull(t2.against_jv, '')='' and t1.name != %s %s group by t1.name, t2.name """ % - ('%s', '%s', cond), (self.doc.account, self.doc.voucher_no), as_dict=1) + ('%s', '%s', cond), (self.account, self.voucher_no), as_dict=1) return gle def create_payment_table(self, gle): for d in gle: - ch = addchild(self.doc, 'ir_payment_details', - 'Payment to Invoice Matching Tool Detail', self.doclist) + ch = self.append('ir_payment_details', {}) ch.voucher_no = d.get('voucher_no') ch.posting_date = d.get('posting_date') ch.amt_due = flt(d.get('amt_due')) @@ -82,7 +78,7 @@ class DocType: ch.voucher_detail_no = d.get('voucher_detail_no') def validate_mandatory(self): - if not self.doc.account: + if not self.account: msgprint("Please select Account first", raise_exception=1) def reconcile(self): @@ -92,21 +88,21 @@ class DocType: 2. split into multiple rows if partially adjusted, assign against voucher 3. submit payment voucher """ - if not self.doc.voucher_no or not frappe.db.sql("""select name from `tab%s` - where name = %s""" % (self.doc.voucher_type, '%s'), self.doc.voucher_no): + if not self.voucher_no or not frappe.db.sql("""select name from `tab%s` + where name = %s""" % (self.voucher_type, '%s'), self.voucher_no): frappe.throw(_("Please select valid Voucher No to proceed")) lst = [] - for d in getlist(self.doclist, 'ir_payment_details'): + for d in self.get('ir_payment_details'): if flt(d.amt_to_be_reconciled) > 0: args = { 'voucher_no' : d.voucher_no, 'voucher_detail_no' : d.voucher_detail_no, - 'against_voucher_type' : self.doc.voucher_type, - 'against_voucher' : self.doc.voucher_no, - 'account' : self.doc.account, + 'against_voucher_type' : self.voucher_type, + 'against_voucher' : self.voucher_no, + 'account' : self.account, 'is_advance' : 'No', - # 'dr_or_cr' : self.doc.account_type=='debit' and 'credit' or 'debit', + # 'dr_or_cr' : self.account_type=='debit' and 'credit' or 'debit', 'unadjusted_amt' : flt(d.amt_due), 'allocated_amt' : flt(d.amt_to_be_reconciled) } diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt deleted file mode 100644 index bc4e0f7d927..00000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.txt +++ /dev/null @@ -1,198 +0,0 @@ -[ - { - "creation": "2013-01-30 12:49:46", - "docstatus": 0, - "modified": "2013-12-20 19:23:24", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "document_type": "Other", - "hide_toolbar": 1, - "icon": "icon-magic", - "issingle": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Payment to Invoice Matching Tool", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Payment to Invoice Matching Tool", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Payment to Invoice Matching Tool" - }, - { - "doctype": "DocField", - "fieldname": "account", - "fieldtype": "Link", - "label": "Account", - "options": "Account", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "account_type", - "fieldtype": "Data", - "hidden": 1, - "label": "Account Type", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "hidden": 1, - "label": "Company", - "options": "Company", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "voucher_type", - "fieldtype": "Select", - "label": "Voucher Type", - "options": "Sales Invoice\nPurchase Invoice\nJournal Voucher", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "voucher_no", - "fieldtype": "Link", - "label": "Voucher No", - "options": "[Select]", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "pull_payment_entries", - "fieldtype": "Button", - "label": "Pull Payment Entries", - "options": "get_payment_entries" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "total_amount", - "fieldtype": "Currency", - "label": "Total Amount", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "pending_amt_to_reconcile", - "fieldtype": "Currency", - "label": "Outstanding Amount", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "payment_entries", - "fieldtype": "Section Break", - "label": "Payment Entries" - }, - { - "description": "Update allocated amount in the above table and then click \"Allocate\" button", - "doctype": "DocField", - "fieldname": "ir_payment_details", - "fieldtype": "Table", - "label": "Payment Entries", - "options": "Payment to Invoice Matching Tool Detail" - }, - { - "doctype": "DocField", - "fieldname": "reconcile", - "fieldtype": "Button", - "label": "Allocate", - "options": "reconcile" - }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "options": "Simple" - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "label": "Filter By Date", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "from_date", - "fieldtype": "Date", - "label": "From Date" - }, - { - "doctype": "DocField", - "fieldname": "to_date", - "fieldtype": "Date", - "label": "To Date" - }, - { - "doctype": "DocField", - "fieldname": "help_html", - "fieldtype": "HTML", - "label": "Help HTML", - "options": "Click \"Pull Payment Entries\" to refresh the table with filters." - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "label": "Filter By Amount", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "amt_greater_than", - "fieldtype": "Data", - "label": "Amount >=" - }, - { - "doctype": "DocField", - "fieldname": "amt_less_than", - "fieldtype": "Data", - "label": "Amount <=" - }, - { - "doctype": "DocPerm", - "role": "Accounts Manager" - }, - { - "doctype": "DocPerm", - "role": "Accounts User" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py index fed02523765..2198909d452 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py @@ -5,4 +5,4 @@ from __future__ import unicode_literals import unittest import frappe -test_records = [] \ No newline at end of file +test_records = frappe.get_test_records('Payment To Invoice Matching Tool') \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_records.json b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_records.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_records.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.json b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.json new file mode 100644 index 00000000000..eecbb110c61 --- /dev/null +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.json @@ -0,0 +1,88 @@ +{ + "creation": "2013-02-22 01:27:39.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "voucher_no", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Voucher No", + "options": "Journal Voucher", + "permlevel": 0, + "print_width": "140px", + "read_only": 1, + "reqd": 0, + "width": "140px" + }, + { + "fieldname": "amt_due", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Unmatched Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "amt_to_be_reconciled", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Allocated Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "posting_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Posting Date", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "total_amt", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Total Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "against_account", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Against Account", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "remarks", + "fieldtype": "Small Text", + "label": "Remarks", + "permlevel": 0, + "print_width": "200px", + "read_only": 1, + "width": "200px" + }, + { + "fieldname": "voucher_detail_no", + "fieldtype": "Data", + "hidden": 1, + "label": "Voucher Detail No", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:24.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Payment to Invoice Matching Tool Detail", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py index 26c87f1c04a..a7bf686170e 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PaymentToInvoiceMatchingToolDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.txt b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.txt deleted file mode 100644 index 1017a98ef52..00000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.txt +++ /dev/null @@ -1,101 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:39", - "docstatus": 0, - "modified": "2013-12-20 19:23:24", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Payment to Invoice Matching Tool Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Payment to Invoice Matching Tool Detail" - }, - { - "doctype": "DocField", - "fieldname": "voucher_no", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Voucher No", - "options": "Journal Voucher", - "print_width": "140px", - "read_only": 1, - "reqd": 0, - "width": "140px" - }, - { - "doctype": "DocField", - "fieldname": "amt_due", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Unmatched Amount", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "amt_to_be_reconciled", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Allocated Amount", - "options": "Company:company:default_currency", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "in_list_view": 1, - "label": "Posting Date", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_amt", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Total Amount", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "against_account", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Against Account", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "remarks", - "fieldtype": "Small Text", - "label": "Remarks", - "print_width": "200px", - "read_only": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "voucher_detail_no", - "fieldtype": "Data", - "hidden": 1, - "label": "Voucher Detail No", - "print_hide": 1, - "read_only": 1, - "reqd": 0 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.json b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.json new file mode 100644 index 00000000000..d964ac7bc7d --- /dev/null +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.json @@ -0,0 +1,136 @@ +{ + "autoname": "PCE/.###", + "creation": "2013-01-10 16:34:07.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "transaction_date", + "fieldtype": "Date", + "label": "Transaction Date", + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "posting_date", + "fieldtype": "Date", + "label": "Posting Date", + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "label": "Closing Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "company", + "fieldtype": "Select", + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Select", + "options": "link:Company", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "The account head under Liability, in which Profit/Loss will be booked", + "fieldname": "closing_account_head", + "fieldtype": "Link", + "label": "Closing Account Head", + "oldfieldname": "closing_account_head", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "coa_help", + "fieldtype": "HTML", + "label": "CoA Help", + "oldfieldtype": "HTML", + "options": "To manage Account Head, click here", + "permlevel": 0 + }, + { + "fieldname": "remarks", + "fieldtype": "Small Text", + "label": "Remarks", + "oldfieldname": "remarks", + "oldfieldtype": "Small Text", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-file-text", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:48:59.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Period Closing Voucher", + "owner": "jai@webnotestech.com", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 1, + "write": 1 + } + ], + "search_fields": "posting_date, fiscal_year" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py index 100bd9562d9..d8661e19d85 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py @@ -7,11 +7,7 @@ from frappe.utils import cstr, flt from frappe import _ from erpnext.controllers.accounts_controller import AccountsController -class DocType(AccountsController): - def __init__(self,d,dl): - self.doc, self.doclist = d, dl - self.year_start_date = '' - +class PeriodClosingVoucher(AccountsController): def validate(self): self.validate_account_head() self.validate_posting_date() @@ -21,24 +17,24 @@ class DocType(AccountsController): def on_cancel(self): frappe.db.sql("""delete from `tabGL Entry` - where voucher_type = 'Period Closing Voucher' and voucher_no=%s""", self.doc.name) + where voucher_type = 'Period Closing Voucher' and voucher_no=%s""", self.name) def validate_account_head(self): - if frappe.db.get_value("Account", self.doc.closing_account_head, "report_type") \ + if frappe.db.get_value("Account", self.closing_account_head, "report_type") \ != "Balance Sheet": - frappe.throw(_("Account") + ": " + self.doc.closing_account_head + + frappe.throw(_("Account") + ": " + self.closing_account_head + _("must be a Liability account")) def validate_posting_date(self): from erpnext.accounts.utils import get_fiscal_year - self.year_start_date = get_fiscal_year(self.doc.posting_date, self.doc.fiscal_year)[1] + self.year_start_date = get_fiscal_year(self.posting_date, self.fiscal_year)[1] pce = frappe.db.sql("""select name from `tabPeriod Closing Voucher` where posting_date > %s and fiscal_year = %s and docstatus = 1""", - (self.doc.posting_date, self.doc.fiscal_year)) + (self.posting_date, self.fiscal_year)) if pce and pce[0][0]: frappe.throw(_("Another Period Closing Entry") + ": " + cstr(pce[0][0]) + - _("has been made after posting date") + ": " + self.doc.posting_date) + _("has been made after posting date") + ": " + self.posting_date) def get_pl_balances(self): """Get balance for pl accounts""" @@ -49,7 +45,7 @@ class DocType(AccountsController): and t2.docstatus < 2 and t2.company = %s and t1.posting_date between %s and %s group by t1.account - """, (self.doc.company, self.year_start_date, self.doc.posting_date), as_dict=1) + """, (self.company, self.get("year_start_date"), self.posting_date), as_dict=1) def make_gl_entries(self): gl_entries = [] @@ -67,7 +63,7 @@ class DocType(AccountsController): if net_pl_balance: gl_entries.append(self.get_gl_dict({ - "account": self.doc.closing_account_head, + "account": self.closing_account_head, "debit": abs(net_pl_balance) if net_pl_balance > 0 else 0, "credit": abs(net_pl_balance) if net_pl_balance < 0 else 0 })) diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.txt b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.txt deleted file mode 100644 index 170f49f1fa7..00000000000 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.txt +++ /dev/null @@ -1,145 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:07", - "docstatus": 0, - "modified": "2014-01-20 17:48:59", - "modified_by": "Administrator", - "owner": "jai@webnotestech.com" - }, - { - "autoname": "PCE/.###", - "doctype": "DocType", - "icon": "icon-file-text", - "is_submittable": 1, - "module": "Accounts", - "name": "__common__", - "search_fields": "posting_date, fiscal_year" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Period Closing Voucher", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Period Closing Voucher", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Period Closing Voucher" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "transaction_date", - "fieldtype": "Date", - "label": "Transaction Date", - "oldfieldname": "transaction_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "label": "Posting Date", - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "label": "Closing Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Select", - "options": "link:Company", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break" - }, - { - "description": "The account head under Liability, in which Profit/Loss will be booked", - "doctype": "DocField", - "fieldname": "closing_account_head", - "fieldtype": "Link", - "label": "Closing Account Head", - "oldfieldname": "closing_account_head", - "oldfieldtype": "Link", - "options": "Account", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "coa_help", - "fieldtype": "HTML", - "label": "CoA Help", - "oldfieldtype": "HTML", - "options": "To manage Account Head, click here" - }, - { - "doctype": "DocField", - "fieldname": "remarks", - "fieldtype": "Small Text", - "label": "Remarks", - "oldfieldname": "remarks", - "oldfieldtype": "Small Text", - "reqd": 1 - }, - { - "doctype": "DocPerm", - "role": "System Manager" - }, - { - "doctype": "DocPerm", - "role": "Accounts Manager" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py index 9b62af19bc1..146764dcbf6 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py @@ -5,34 +5,34 @@ from __future__ import unicode_literals import unittest import frappe +from erpnext.accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records class TestPeriodClosingVoucher(unittest.TestCase): def test_closing_entry(self): # clear GL Entries frappe.db.sql("""delete from `tabGL Entry`""") - - from erpnext.accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records - jv = frappe.bean(copy=jv_records[2]) + jv = frappe.copy_doc(jv_records[2]) jv.insert() jv.submit() - - jv1 = frappe.bean(copy=jv_records[0]) - jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC" - jv1.doclist[2].debit = 600.0 - jv1.doclist[1].credit = 600.0 + + jv1 = frappe.copy_doc(jv_records[0]) + jv1.get("entries")[1].account = "_Test Account Cost for Goods Sold - _TC" + jv1.get("entries")[1].cost_center = "_Test Cost Center - _TC" + jv1.get("entries")[1].debit = 600.0 + jv1.get("entries")[0].credit = 600.0 jv1.insert() jv1.submit() - - pcv = frappe.bean(copy=test_record) + + pcv = frappe.copy_doc(test_records[0]) pcv.insert() pcv.submit() - + gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Period Closing Voucher' and voucher_no=%s - order by account asc, debit asc""", pcv.doc.name, as_dict=1) + order by account asc, debit asc""", pcv.name, as_dict=1) self.assertTrue(gl_entries) - + expected_gl_entries = sorted([ ["_Test Account Reserves and Surplus - _TC", 200.0, 0.0], ["_Test Account Cost for Goods Sold - _TC", 0.0, 600.0], @@ -42,15 +42,7 @@ class TestPeriodClosingVoucher(unittest.TestCase): self.assertEquals(expected_gl_entries[i][0], gle.account) self.assertEquals(expected_gl_entries[i][1], gle.debit) self.assertEquals(expected_gl_entries[i][2], gle.credit) - - + + test_dependencies = ["Customer", "Cost Center"] - -test_record = [{ - "doctype": "Period Closing Voucher", - "closing_account_head": "_Test Account Reserves and Surplus - _TC", - "company": "_Test Company", - "fiscal_year": "_Test Fiscal Year 2013", - "posting_date": "2013-03-31", - "remarks": "test" -}] +test_records = frappe.get_test_records("Period Closing Voucher") diff --git a/erpnext/accounts/doctype/period_closing_voucher/test_records.json b/erpnext/accounts/doctype/period_closing_voucher/test_records.json new file mode 100644 index 00000000000..d21948f674a --- /dev/null +++ b/erpnext/accounts/doctype/period_closing_voucher/test_records.json @@ -0,0 +1,8 @@ +[{ + "doctype": "Period Closing Voucher", + "closing_account_head": "_Test Account Reserves and Surplus - _TC", + "company": "_Test Company", + "fiscal_year": "_Test Fiscal Year 2013", + "posting_date": "2013-03-31", + "remarks": "test" +}] diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.js b/erpnext/accounts/doctype/pos_setting/pos_setting.js index debfcd9d1ac..61c64c2839f 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.js +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt cur_frm.cscript.onload = function(doc,cdt,cdn){ - return $c_obj(make_doclist(cdt,cdn),'get_series','',function(r,rt){ + return $c_obj(cur_frm.doc, 'get_series','',function(r,rt){ if(r.message) set_field_options('naming_series', r.message); }); diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.json b/erpnext/accounts/doctype/pos_setting/pos_setting.json new file mode 100755 index 00000000000..0e68bc3fed2 --- /dev/null +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.json @@ -0,0 +1,234 @@ +{ + "autoname": "POS/.####", + "creation": "2013-05-24 12:15:51.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "user", + "fieldtype": "Link", + "in_list_view": 1, + "label": "User", + "oldfieldname": "user", + "oldfieldtype": "Link", + "options": "User", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "label": "Territory", + "oldfieldname": "territory", + "oldfieldtype": "Link", + "options": "Territory", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "selling_price_list", + "fieldtype": "Link", + "label": "Price List", + "oldfieldname": "price_list_name", + "oldfieldtype": "Select", + "options": "Price List", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "default": "1", + "description": "Create Stock Ledger Entries when you submit a Sales Invoice", + "fieldname": "update_stock", + "fieldtype": "Check", + "label": "Update Stock", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "label": "Customer", + "oldfieldname": "customer_account", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "cash_bank_account", + "fieldtype": "Link", + "label": "Cash/Bank Account", + "oldfieldname": "cash_bank_account", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "income_account", + "fieldtype": "Link", + "label": "Income Account", + "oldfieldname": "income_account", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", + "fieldname": "expense_account", + "fieldtype": "Link", + "hidden": 0, + "label": "Expense Account", + "options": "Account", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "warehouse", + "fieldtype": "Link", + "label": "Warehouse", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "cost_center", + "fieldtype": "Link", + "label": "Cost Center", + "oldfieldname": "cost_center", + "oldfieldtype": "Link", + "options": "Cost Center", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "oldfieldname": "charge", + "oldfieldtype": "Link", + "options": "Sales Taxes and Charges Master", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "letter_head", + "fieldtype": "Select", + "label": "Letter Head", + "oldfieldname": "letter_head", + "oldfieldtype": "Select", + "options": "link:Letter Head", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms and Conditions", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "select_print_heading", + "fieldtype": "Select", + "in_filter": 0, + "label": "Print Heading", + "oldfieldname": "select_print_heading", + "oldfieldtype": "Select", + "options": "link:Print Heading", + "permlevel": 0, + "read_only": 0 + } + ], + "icon": "icon-cog", + "idx": 1, + "modified": "2014-01-29 13:08:25.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "POS Setting", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 0 + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.py b/erpnext/accounts/doctype/pos_setting/pos_setting.py index 29ae298b8e8..f7fdd319fe5 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.py +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.py @@ -6,16 +6,11 @@ import frappe from frappe import msgprint, _ from frappe.utils import cint -class DocType: - def __init__(self,doc,doclist): - self.doc, self.doclist = doc,doclist +from frappe.model.document import Document +class POSSetting(Document): def get_series(self): - import frappe.model.doctype - docfield = frappe.model.doctype.get('Sales Invoice') - series = [d.options for d in docfield - if d.doctype == 'DocField' and d.fieldname == 'naming_series'] - return series and series[0] or '' + frappe.get_meta("Sales Invoice").get_field("naming_series").options or "" def validate(self): self.check_for_duplicate() @@ -25,30 +20,30 @@ class DocType: def check_for_duplicate(self): res = frappe.db.sql("""select name, user from `tabPOS Setting` where ifnull(user, '') = %s and name != %s and company = %s""", - (self.doc.user, self.doc.name, self.doc.company)) + (self.user, self.name, self.company)) if res: if res[0][1]: msgprint("POS Setting '%s' already created for user: '%s' and company: '%s'" % - (res[0][0], res[0][1], self.doc.company), raise_exception=1) + (res[0][0], res[0][1], self.company), raise_exception=1) else: msgprint("Global POS Setting already created - %s for this company: '%s'" % - (res[0][0], self.doc.company), raise_exception=1) + (res[0][0], self.company), raise_exception=1) def validate_expense_account(self): if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \ - and not self.doc.expense_account: + and not self.expense_account: msgprint(_("Expense Account is mandatory"), raise_exception=1) def validate_all_link_fields(self): - accounts = {"Account": [self.doc.cash_bank_account, self.doc.income_account, - self.doc.expense_account], "Cost Center": [self.doc.cost_center], - "Warehouse": [self.doc.warehouse]} + accounts = {"Account": [self.cash_bank_account, self.income_account, + self.expense_account], "Cost Center": [self.cost_center], + "Warehouse": [self.warehouse]} for link_dt, dn_list in accounts.items(): for link_dn in dn_list: if link_dn and not frappe.db.exists({"doctype": link_dt, - "company": self.doc.company, "name": link_dn}): - frappe.throw(link_dn +_(" does not belong to ") + self.doc.company) + "company": self.company, "name": link_dn}): + frappe.throw(link_dn +_(" does not belong to ") + self.company) def on_update(self): self.set_defaults() @@ -60,7 +55,7 @@ class DocType: frappe.defaults.clear_default("is_pos") if not include_current_pos: - condition = " where name != '%s'" % self.doc.name.replace("'", "\'") + condition = " where name != '%s'" % self.name.replace("'", "\'") else: condition = "" diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.txt b/erpnext/accounts/doctype/pos_setting/pos_setting.txt deleted file mode 100755 index bad0d7eb59a..00000000000 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.txt +++ /dev/null @@ -1,246 +0,0 @@ -[ - { - "creation": "2013-05-24 12:15:51", - "docstatus": 0, - "modified": "2014-01-29 13:08:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "POS/.####", - "doctype": "DocType", - "icon": "icon-cog", - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "POS Setting", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "delete": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "POS Setting", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "POS Setting" - }, - { - "doctype": "DocField", - "fieldname": "user", - "fieldtype": "Link", - "in_list_view": 1, - "label": "User", - "oldfieldname": "user", - "oldfieldtype": "Link", - "options": "User", - "read_only": 0 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "label": "Territory", - "oldfieldname": "territory", - "oldfieldtype": "Link", - "options": "Territory", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "currency", - "fieldtype": "Link", - "label": "Currency", - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "selling_price_list", - "fieldtype": "Link", - "label": "Price List", - "oldfieldname": "price_list_name", - "oldfieldtype": "Select", - "options": "Price List", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0 - }, - { - "default": "1", - "description": "Create Stock Ledger Entries when you submit a Sales Invoice", - "doctype": "DocField", - "fieldname": "update_stock", - "fieldtype": "Check", - "label": "Update Stock", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "label": "Customer", - "oldfieldname": "customer_account", - "oldfieldtype": "Link", - "options": "Customer", - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "cash_bank_account", - "fieldtype": "Link", - "label": "Cash/Bank Account", - "oldfieldname": "cash_bank_account", - "oldfieldtype": "Link", - "options": "Account", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "income_account", - "fieldtype": "Link", - "label": "Income Account", - "oldfieldname": "income_account", - "oldfieldtype": "Link", - "options": "Account", - "read_only": 0, - "reqd": 1 - }, - { - "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", - "doctype": "DocField", - "fieldname": "expense_account", - "fieldtype": "Link", - "hidden": 0, - "label": "Expense Account", - "options": "Account", - "print_hide": 1, - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "label": "Warehouse", - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "label": "Cost Center", - "oldfieldname": "cost_center", - "oldfieldtype": "Link", - "options": "Cost Center", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "oldfieldname": "charge", - "oldfieldtype": "Link", - "options": "Sales Taxes and Charges Master", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Select", - "label": "Letter Head", - "oldfieldname": "letter_head", - "oldfieldtype": "Select", - "options": "link:Letter Head", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms and Conditions", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Select", - "in_filter": 0, - "label": "Print Heading", - "oldfieldname": "select_print_heading", - "oldfieldtype": "Select", - "options": "link:Print Heading", - "read_only": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "Accounts Manager", - "write": 1 - }, - { - "doctype": "DocPerm", - "role": "Accounts User" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/pos_setting/test_pos_setting.py b/erpnext/accounts/doctype/pos_setting/test_pos_setting.py index 42125cd0f90..d563be96d7f 100644 --- a/erpnext/accounts/doctype/pos_setting/test_pos_setting.py +++ b/erpnext/accounts/doctype/pos_setting/test_pos_setting.py @@ -1,19 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "POS Setting", - "name": "_Test POS Setting", - "currency": "INR", - "selling_price_list": "_Test Price List", - "company": "_Test Company", - "warehouse": "_Test Warehouse - _TC", - "territory": "_Test Territory", - "cash_bank_account": "_Test Account Bank Account - _TC", - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "naming_series": "_T-Sales Invoice-" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Pos Setting') \ No newline at end of file diff --git a/erpnext/accounts/doctype/pos_setting/test_records.json b/erpnext/accounts/doctype/pos_setting/test_records.json new file mode 100644 index 00000000000..f5071629e1d --- /dev/null +++ b/erpnext/accounts/doctype/pos_setting/test_records.json @@ -0,0 +1,16 @@ +[ + { + "cash_bank_account": "_Test Account Bank Account - _TC", + "company": "_Test Company", + "cost_center": "_Test Cost Center - _TC", + "currency": "INR", + "doctype": "POS Setting", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "income_account": "Sales - _TC", + "name": "_Test POS Setting", + "naming_series": "_T-Sales Invoice-", + "selling_price_list": "_Test Price List", + "territory": "_Test Territory", + "warehouse": "_Test Warehouse - _TC" + } +] \ No newline at end of file diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.json b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json new file mode 100644 index 00000000000..32df323915c --- /dev/null +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json @@ -0,0 +1,258 @@ +{ + "autoname": "PRULE.#####", + "creation": "2014-02-21 15:02:51.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "basic_section", + "fieldtype": "Section Break", + "label": "Basic Section", + "permlevel": 0 + }, + { + "default": "Today", + "fieldname": "valid_from", + "fieldtype": "Date", + "label": "Valid From", + "permlevel": 0 + }, + { + "fieldname": "valid_upto", + "fieldtype": "Date", + "label": "Valid Upto", + "permlevel": 0 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "priority", + "fieldtype": "Select", + "label": "Priority", + "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20", + "permlevel": 0 + }, + { + "fieldname": "disable", + "fieldtype": "Check", + "label": "Disable", + "permlevel": 0 + }, + { + "fieldname": "price_discount_section", + "fieldtype": "Section Break", + "label": "Price / Discount", + "permlevel": 0 + }, + { + "default": "Discount Percentage", + "fieldname": "price_or_discount", + "fieldtype": "Select", + "label": "Price or Discount", + "options": "\nPrice\nDiscount Percentage", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.price_or_discount==\"Price\"", + "fieldname": "price", + "fieldtype": "Float", + "label": "Price", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.price_or_discount==\"Discount Percentage\"", + "fieldname": "discount_percentage", + "fieldtype": "Float", + "label": "Discount Percentage", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.price_or_discount==\"Discount Percentage\"", + "fieldname": "for_price_list", + "fieldtype": "Link", + "label": "For Price List", + "options": "Price List", + "permlevel": 0 + }, + { + "fieldname": "applicability_section", + "fieldtype": "Section Break", + "label": "Applicability", + "permlevel": 0 + }, + { + "default": "Item Code", + "fieldname": "apply_on", + "fieldtype": "Select", + "label": "Apply On", + "options": "\nItem Code\nItem Group\nBrand", + "permlevel": 0, + "reqd": 1 + }, + { + "depends_on": "eval:doc.apply_on==\"Item Code\"", + "fieldname": "item_code", + "fieldtype": "Link", + "label": "Item Code", + "options": "Item", + "permlevel": 0, + "reqd": 0 + }, + { + "depends_on": "eval:doc.apply_on==\"Item Group\"", + "fieldname": "item_group", + "fieldtype": "Link", + "label": "Item Group", + "options": "Item Group", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.apply_on==\"Brand\"", + "fieldname": "brand", + "fieldtype": "Link", + "label": "Brand", + "options": "Brand", + "permlevel": 0 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "applicable_for", + "fieldtype": "Select", + "label": "Applicable For", + "options": "\nCustomer\nCustomer Group\nTerritory\nSales Partner\nCampaign\nSupplier\nSupplier Type", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.applicable_for==\"Customer\"", + "fieldname": "customer", + "fieldtype": "Link", + "label": "Customer", + "options": "Customer", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.applicable_for==\"Customer Group\"", + "fieldname": "customer_group", + "fieldtype": "Link", + "label": "Customer Group", + "options": "Customer Group", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.applicable_for==\"Territory\"", + "fieldname": "territory", + "fieldtype": "Link", + "label": "Territory", + "options": "Territory", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.applicable_for==\"Sales Partner\"", + "fieldname": "sales_partner", + "fieldtype": "Link", + "label": "Sales Partner", + "options": "Sales Partner", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.applicable_for==\"Campaign\"", + "fieldname": "campaign", + "fieldtype": "Link", + "label": "Campaign", + "options": "Campaign", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.applicable_for==\"Supplier\"", + "fieldname": "supplier", + "fieldtype": "Link", + "label": "Supplier", + "options": "Supplier", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.applicable_for==\"Supplier Type\"", + "fieldname": "supplier_type", + "fieldtype": "Link", + "label": "Supplier Type", + "options": "Supplier Type", + "permlevel": 0 + }, + { + "fieldname": "min_qty", + "fieldtype": "Float", + "label": "Min Qty", + "permlevel": 0 + }, + { + "fieldname": "max_qty", + "fieldtype": "Float", + "label": "Max Qty", + "permlevel": 0 + } + ], + "icon": "icon-gift", + "idx": 1, + "istable": 0, + "modified": "2014-03-05 18:23:34.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Pricing Rule", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "permlevel": 0, + "read": 1, + "role": "Accounts Manager", + "write": 1 + }, + { + "create": 1, + "delete": 1, + "permlevel": 0, + "read": 1, + "role": "Sales Manager", + "write": 1 + }, + { + "create": 1, + "delete": 1, + "permlevel": 0, + "read": 1, + "role": "Purchase Manager", + "write": 1 + }, + { + "create": 1, + "delete": 1, + "permlevel": 0, + "read": 1, + "role": "Website Manager", + "write": 1 + }, + { + "create": 1, + "delete": 1, + "permlevel": 0, + "read": 1, + "role": "System Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 5073718d435..eb70ee1b44a 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -8,9 +8,7 @@ import frappe from frappe import throw, _ from frappe.model.controller import DocListController -class DocType(DocListController): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +class PricingRule(DocListController): def validate(self): self.validate_mandatory() @@ -18,14 +16,14 @@ class DocType(DocListController): def validate_mandatory(self): for field in ["apply_on", "applicable_for", "price_or_discount"]: - val = self.doc.fields.get("applicable_for") - if val and not self.doc.fields.get(frappe.scrub(val)): + val = self.get("applicable_for") + if val and not self.get(frappe.scrub(val)): throw("{fname} {msg}".format(fname = _(val), msg = _(" is mandatory")), frappe.MandatoryError) def cleanup_fields_value(self): for logic_field in ["apply_on", "applicable_for", "price_or_discount"]: - fieldname = frappe.scrub(self.doc.fields.get(logic_field) or "") + fieldname = frappe.scrub(self.get(logic_field) or "") # reset all values except for the logic field options = (self.meta.get_options(logic_field) or "").split("\n") @@ -34,5 +32,5 @@ class DocType(DocListController): f = frappe.scrub(f) if f!=fieldname: - self.doc.fields[f] = None + self.set(f, None) \ No newline at end of file diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.txt b/erpnext/accounts/doctype/pricing_rule/pricing_rule.txt deleted file mode 100644 index 413405c962d..00000000000 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.txt +++ /dev/null @@ -1,261 +0,0 @@ -[ - { - "creation": "2014-02-21 15:02:51", - "docstatus": 0, - "modified": "2014-03-05 18:23:34", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "PRULE.#####", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-gift", - "istable": 0, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Pricing Rule", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Pricing Rule", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Pricing Rule" - }, - { - "doctype": "DocField", - "fieldname": "basic_section", - "fieldtype": "Section Break", - "label": "Basic Section" - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "valid_from", - "fieldtype": "Date", - "label": "Valid From" - }, - { - "doctype": "DocField", - "fieldname": "valid_upto", - "fieldtype": "Date", - "label": "Valid Upto" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "priority", - "fieldtype": "Select", - "label": "Priority", - "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20" - }, - { - "doctype": "DocField", - "fieldname": "disable", - "fieldtype": "Check", - "label": "Disable" - }, - { - "doctype": "DocField", - "fieldname": "price_discount_section", - "fieldtype": "Section Break", - "label": "Price / Discount" - }, - { - "default": "Discount Percentage", - "doctype": "DocField", - "fieldname": "price_or_discount", - "fieldtype": "Select", - "label": "Price or Discount", - "options": "\nPrice\nDiscount Percentage", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "depends_on": "eval:doc.price_or_discount==\"Price\"", - "doctype": "DocField", - "fieldname": "price", - "fieldtype": "Float", - "label": "Price" - }, - { - "depends_on": "eval:doc.price_or_discount==\"Discount Percentage\"", - "doctype": "DocField", - "fieldname": "discount_percentage", - "fieldtype": "Float", - "label": "Discount Percentage" - }, - { - "depends_on": "eval:doc.price_or_discount==\"Discount Percentage\"", - "doctype": "DocField", - "fieldname": "for_price_list", - "fieldtype": "Link", - "label": "For Price List", - "options": "Price List" - }, - { - "doctype": "DocField", - "fieldname": "applicability_section", - "fieldtype": "Section Break", - "label": "Applicability" - }, - { - "default": "Item Code", - "doctype": "DocField", - "fieldname": "apply_on", - "fieldtype": "Select", - "label": "Apply On", - "options": "\nItem Code\nItem Group\nBrand", - "reqd": 1 - }, - { - "depends_on": "eval:doc.apply_on==\"Item Code\"", - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "label": "Item Code", - "options": "Item", - "reqd": 0 - }, - { - "depends_on": "eval:doc.apply_on==\"Item Group\"", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "label": "Item Group", - "options": "Item Group" - }, - { - "depends_on": "eval:doc.apply_on==\"Brand\"", - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Link", - "label": "Brand", - "options": "Brand" - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "applicable_for", - "fieldtype": "Select", - "label": "Applicable For", - "options": "\nCustomer\nCustomer Group\nTerritory\nSales Partner\nCampaign\nSupplier\nSupplier Type" - }, - { - "depends_on": "eval:doc.applicable_for==\"Customer\"", - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "label": "Customer", - "options": "Customer" - }, - { - "depends_on": "eval:doc.applicable_for==\"Customer Group\"", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "label": "Customer Group", - "options": "Customer Group" - }, - { - "depends_on": "eval:doc.applicable_for==\"Territory\"", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "label": "Territory", - "options": "Territory" - }, - { - "depends_on": "eval:doc.applicable_for==\"Sales Partner\"", - "doctype": "DocField", - "fieldname": "sales_partner", - "fieldtype": "Link", - "label": "Sales Partner", - "options": "Sales Partner" - }, - { - "depends_on": "eval:doc.applicable_for==\"Campaign\"", - "doctype": "DocField", - "fieldname": "campaign", - "fieldtype": "Link", - "label": "Campaign", - "options": "Campaign" - }, - { - "depends_on": "eval:doc.applicable_for==\"Supplier\"", - "doctype": "DocField", - "fieldname": "supplier", - "fieldtype": "Link", - "label": "Supplier", - "options": "Supplier" - }, - { - "depends_on": "eval:doc.applicable_for==\"Supplier Type\"", - "doctype": "DocField", - "fieldname": "supplier_type", - "fieldtype": "Link", - "label": "Supplier Type", - "options": "Supplier Type" - }, - { - "doctype": "DocField", - "fieldname": "min_qty", - "fieldtype": "Float", - "label": "Min Qty" - }, - { - "doctype": "DocField", - "fieldname": "max_qty", - "fieldtype": "Float", - "label": "Max Qty" - }, - { - "doctype": "DocPerm", - "role": "Accounts Manager" - }, - { - "doctype": "DocPerm", - "role": "Sales Manager" - }, - { - "doctype": "DocPerm", - "role": "Purchase Manager" - }, - { - "doctype": "DocPerm", - "role": "Website Manager" - }, - { - "doctype": "DocPerm", - "role": "System Manager" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py index a28db322b25..e3d79f161e8 100644 --- a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py @@ -11,16 +11,16 @@ class TestPricingRule(unittest.TestCase): from erpnext.stock.get_item_details import get_item_details from frappe import MandatoryError - test_record = [{ - "doctype": "Pricing Rule", - "apply_on": "Item Code", - "item_code": "_Test Item", - "price_or_discount": "Discount Percentage", - "price": 0, - "discount_percentage": 10, - }] - frappe.bean(copy=test_record).insert() - + test_record = { + "doctype": "Pricing Rule", + "apply_on": "Item Code", + "item_code": "_Test Item", + "price_or_discount": "Discount Percentage", + "price": 0, + "discount_percentage": 10, + } + frappe.get_doc(test_record.copy()).insert() + args = frappe._dict({ "item_code": "_Test Item", "company": "_Test Company", @@ -34,46 +34,46 @@ class TestPricingRule(unittest.TestCase): "transaction_type": "selling", "customer": "_Test Customer", }) - + details = get_item_details(args) self.assertEquals(details.get("discount_percentage"), 10) - - prule = frappe.bean(copy=test_record) - prule.doc.applicable_for = "Customer" + + prule = frappe.get_doc(test_record.copy()) + prule.applicable_for = "Customer" self.assertRaises(MandatoryError, prule.insert) - prule.doc.customer = "_Test Customer" - prule.doc.discount_percentage = 20 + prule.customer = "_Test Customer" + prule.discount_percentage = 20 prule.insert() details = get_item_details(args) self.assertEquals(details.get("discount_percentage"), 20) - - prule = frappe.bean(copy=test_record) - prule.doc.apply_on = "Item Group" - prule.doc.item_group = "All Item Groups" - prule.doc.discount_percentage = 15 + + prule = frappe.get_doc(test_record.copy()) + prule.apply_on = "Item Group" + prule.item_group = "All Item Groups" + prule.discount_percentage = 15 prule.insert() - + args.customer = None details = get_item_details(args) self.assertEquals(details.get("discount_percentage"), 10) - - prule = frappe.bean(copy=test_record) - prule.doc.applicable_for = "Campaign" - prule.doc.campaign = "_Test Campaign" - prule.doc.discount_percentage = 5 - prule.doc.priority = 8 + + prule = frappe.get_doc(test_record.copy()) + prule.applicable_for = "Campaign" + prule.campaign = "_Test Campaign" + prule.discount_percentage = 5 + prule.priority = 8 prule.insert() - + args.campaign = "_Test Campaign" details = get_item_details(args) self.assertEquals(details.get("discount_percentage"), 5) - + frappe.db.sql("update `tabPricing Rule` set priority=NULL where campaign='_Test Campaign'") details = get_item_details(args) self.assertEquals(details.get("discount_percentage"), 15) - + args.item_code = "_Test Item 2" details = get_item_details(args) self.assertEquals(details.get("discount_percentage"), 15) - - frappe.db.sql("delete from `tabPricing Rule`") \ No newline at end of file + + frappe.db.sql("delete from `tabPricing Rule`") diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index be1f3b23621..a45af20ae66 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -108,7 +108,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ }, entries_add: function(doc, cdt, cdn) { - var row = frappe.model.get_doc(cdt, cdn); + var row = frappe.get_doc(cdt, cdn); this.frm.script_manager.copy_from_first_row("entries", row, ["expense_account", "cost_center"]); } }); @@ -184,7 +184,7 @@ cur_frm.set_query("expense_account", "entries", function(doc) { cur_frm.cscript.expense_account = function(doc, cdt, cdn){ var d = locals[cdt][cdn]; if(d.idx == 1 && d.expense_account){ - var cl = getchildren('Purchase Invoice Item', doc.name, 'entries', doc.doctype); + var cl = doc.entries || []; for(var i = 0; i < cl.length; i++){ if(!cl[i].expense_account) cl[i].expense_account = d.expense_account; } @@ -205,7 +205,7 @@ cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = functio cur_frm.cscript.cost_center = function(doc, cdt, cdn){ var d = locals[cdt][cdn]; if(d.idx == 1 && d.cost_center){ - var cl = getchildren('Purchase Invoice Item', doc.name, 'entries', doc.doctype); + var cl = doc.entries || []; for(var i = 0; i < cl.length; i++){ if(!cl[i].cost_center) cl[i].cost_center = d.cost_center; } diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json new file mode 100755 index 00000000000..7917caf19cf --- /dev/null +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -0,0 +1,826 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-05-21 16:16:39.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "supplier_section", + "fieldtype": "Section Break", + "label": "Supplier", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "BILL\nBILLJ", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 1 + }, + { + "fieldname": "supplier", + "fieldtype": "Link", + "hidden": 0, + "label": "Supplier", + "oldfieldname": "supplier", + "oldfieldtype": "Link", + "options": "Supplier", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "supplier", + "fieldname": "supplier_name", + "fieldtype": "Data", + "hidden": 0, + "in_list_view": 1, + "label": "Name", + "oldfieldname": "supplier_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_mobile", + "fieldtype": "Text", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_email", + "fieldtype": "Text", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "reqd": 0, + "width": "50%" + }, + { + "default": "Today", + "fieldname": "posting_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Posting Date", + "no_copy": 0, + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "description": "If not applicable please enter: NA", + "fieldname": "bill_no", + "fieldtype": "Data", + "in_filter": 1, + "label": "Supplier Invoice No", + "oldfieldname": "bill_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "bill_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Supplier Invoice Date", + "oldfieldname": "bill_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Link", + "options": "Purchase Invoice", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "search_index": 1 + }, + { + "fieldname": "currency_price_list", + "fieldtype": "Section Break", + "label": "Currency and Price List", + "options": "icon-tag", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "description": "The rate at which Bill Currency is converted into company's base currency", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "label": "Exchange Rate", + "oldfieldname": "conversion_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "buying_price_list", + "fieldtype": "Link", + "label": "Price List", + "options": "Price List", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "price_list_currency", + "fieldtype": "Link", + "label": "Price List Currency", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "label": "Price List Exchange Rate", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "items", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "entries", + "fieldtype": "Table", + "label": "Entries", + "oldfieldname": "entries", + "oldfieldtype": "Table", + "options": "Purchase Invoice Item", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "section_break_26", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "net_total_import", + "fieldtype": "Currency", + "label": "Net Total", + "oldfieldname": "net_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "column_break_28", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "Will be calculated automatically when you enter the details", + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total (Company Currency)", + "oldfieldname": "net_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "taxes", + "fieldtype": "Section Break", + "label": "Taxes and Charges", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "oldfieldname": "purchase_other_charges", + "oldfieldtype": "Link", + "options": "Purchase Taxes and Charges Master", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "other_charges", + "fieldtype": "Table", + "label": "Purchase Taxes and Charges", + "oldfieldname": "purchase_tax_details", + "oldfieldtype": "Table", + "options": "Purchase Taxes and Charges", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "other_charges_calculation", + "fieldtype": "HTML", + "label": "Taxes and Charges Calculation", + "oldfieldtype": "HTML", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "Totals", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "other_charges_added_import", + "fieldtype": "Currency", + "label": "Taxes and Charges Added", + "oldfieldname": "other_charges_added_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "other_charges_deducted_import", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted", + "oldfieldname": "other_charges_deducted_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "grand_total_import", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Grand Total", + "oldfieldname": "grand_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "in_words_import", + "fieldtype": "Data", + "label": "In Words", + "oldfieldname": "in_words_import", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "total_amount_to_pay", + "fieldtype": "Currency", + "hidden": 0, + "label": "Total Amount To Pay", + "no_copy": 1, + "oldfieldname": "total_amount_to_pay", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "total_advance", + "fieldtype": "Currency", + "label": "Total Advance", + "no_copy": 1, + "oldfieldname": "total_advance", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "outstanding_amount", + "fieldtype": "Currency", + "in_filter": 1, + "in_list_view": 1, + "label": "Outstanding Amount", + "no_copy": 1, + "oldfieldname": "outstanding_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "column_break8", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "total_tax", + "fieldtype": "Currency", + "label": "Total Tax (Company Currency)", + "oldfieldname": "total_tax", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "other_charges_added", + "fieldtype": "Currency", + "label": "Taxes and Charges Added (Company Currency)", + "oldfieldname": "other_charges_added", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "other_charges_deducted", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted (Company Currency)", + "oldfieldname": "other_charges_deducted", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "In Words will be visible once you save the Purchase Invoice.", + "fieldname": "in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "write_off_amount", + "fieldtype": "Currency", + "label": "Write Off Amount", + "no_copy": 1, + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "eval:flt(doc.write_off_amount)!=0", + "fieldname": "write_off_account", + "fieldtype": "Link", + "label": "Write Off Account", + "no_copy": 1, + "options": "Account", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "eval:flt(doc.write_off_amount)!=0", + "fieldname": "write_off_cost_center", + "fieldtype": "Link", + "label": "Write Off Cost Center", + "no_copy": 1, + "options": "Cost Center", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "against_expense_account", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Against Expense Account", + "no_copy": 1, + "oldfieldname": "against_expense_account", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0 + }, + { + "fieldname": "advances", + "fieldtype": "Section Break", + "label": "Advances", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "get_advances_paid", + "fieldtype": "Button", + "label": "Get Advances Paid", + "oldfieldtype": "Button", + "options": "get_advances", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "advance_allocation_details", + "fieldtype": "Table", + "label": "Purchase Invoice Advances", + "no_copy": 1, + "oldfieldname": "advance_allocation_details", + "oldfieldtype": "Table", + "options": "Purchase Invoice Advance", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "options": "icon-legal", + "permlevel": 0 + }, + { + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "options": "Terms and Conditions", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Terms and Conditions1", + "permlevel": 0 + }, + { + "depends_on": "supplier", + "fieldname": "contact_section", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "supplier_address", + "fieldtype": "Link", + "label": "Supplier Address", + "options": "Address", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "col_break23", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "contact_person", + "fieldtype": "Link", + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "description": "Supplier (Payable) Account", + "fieldname": "credit_to", + "fieldtype": "Link", + "in_filter": 1, + "label": "Credit To", + "oldfieldname": "credit_to", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "default": "No", + "description": "Considered as Opening Balance", + "fieldname": "is_opening", + "fieldtype": "Select", + "in_filter": 1, + "label": "Is Opening", + "oldfieldname": "is_opening", + "oldfieldtype": "Select", + "options": "No\nYes", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "search_index": 1 + }, + { + "description": "Actual Invoice Date", + "fieldname": "aging_date", + "fieldtype": "Date", + "label": "Aging Date", + "oldfieldname": "aging_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "search_index": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "fieldname": "due_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Due Date", + "no_copy": 0, + "oldfieldname": "due_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "search_index": 1 + }, + { + "fieldname": "mode_of_payment", + "fieldtype": "Select", + "label": "Mode of Payment", + "oldfieldname": "mode_of_payment", + "oldfieldtype": "Select", + "options": "link:Mode of Payment", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break_63", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Select", + "label": "Letter Head", + "options": "link:Letter Head", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "search_index": 1 + }, + { + "fieldname": "remarks", + "fieldtype": "Small Text", + "label": "Remarks", + "no_copy": 1, + "oldfieldname": "remarks", + "oldfieldtype": "Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0 + } + ], + "icon": "icon-file-text", + "idx": 1, + "is_submittable": 1, + "modified": "2014-02-17 12:01:59.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Purchase Invoice", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Supplier", + "submit": 0, + "write": 0 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Auditor", + "submit": 0, + "write": 0 + } + ], + "read_only_onload": 1, + "search_fields": "posting_date, credit_to, fiscal_year, bill_no, grand_total, outstanding_amount" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index c059d2d7c3f..8860a78e274 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -5,8 +5,7 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, cstr, flt, formatdate -from frappe.model.bean import getlist -from frappe.model.code import get_obj + from frappe import msgprint, _ from erpnext.setup.utils import get_company_currency @@ -15,11 +14,12 @@ import frappe.defaults from erpnext.controllers.buying_controller import BuyingController from erpnext.accounts.party import get_party_account, get_due_date -class DocType(BuyingController): - def __init__(self,d,dl): - self.doc, self.doclist = d, dl - self.tname = 'Purchase Invoice Item' - self.fname = 'entries' +class PurchaseInvoice(BuyingController): + tname = 'Purchase Invoice Item' + fname = 'entries' + + def __init__(self, arg1, arg2=None): + super(PurchaseInvoice, self).__init__(arg1, arg2) self.status_updater = [{ 'source_dt': 'Purchase Invoice Item', 'target_dt': 'Purchase Order Item', @@ -31,13 +31,13 @@ class DocType(BuyingController): 'source_field': 'amount', 'percent_join_field': 'purchase_order', }] - + def validate(self): - if not self.doc.is_opening: - self.doc.is_opening = 'No' - - super(DocType, self).validate() - + if not self.is_opening: + self.is_opening = 'No' + + super(PurchaseInvoice, self).validate() + self.po_required() self.pr_required() self.check_active_purchase_items() @@ -54,24 +54,24 @@ class DocType(BuyingController): self.validate_write_off_account() self.update_raw_material_cost() self.update_valuation_rate("entries") - self.validate_multiple_billing("Purchase Receipt", "pr_detail", "amount", + self.validate_multiple_billing("Purchase Receipt", "pr_detail", "amount", "purchase_receipt_details") - + def set_missing_values(self, for_validate=False): - if not self.doc.credit_to: - self.doc.credit_to = get_party_account(self.doc.company, self.doc.supplier, "Supplier") - if not self.doc.due_date: - self.doc.due_date = get_due_date(self.doc.posting_date, self.doc.supplier, "Supplier", - self.doc.credit_to, self.doc.company) - - super(DocType, self).set_missing_values(for_validate) - + if not self.credit_to: + self.credit_to = get_party_account(self.company, self.supplier, "Supplier") + if not self.due_date: + self.due_date = get_due_date(self.posting_date, self.supplier, "Supplier", + self.credit_to, self.company) + + super(PurchaseInvoice, self).set_missing_values(for_validate) + def get_advances(self): - super(DocType, self).get_advances(self.doc.credit_to, + super(PurchaseInvoice, self).get_advances(self.credit_to, "Purchase Invoice Advance", "advance_allocation_details", "debit") - + def check_active_purchase_items(self): - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.item_code: # extra condn coz item_code is not mandatory in PV valid_item = frappe.db.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code) if valid_item[0][0] == 2: @@ -80,61 +80,61 @@ class DocType(BuyingController): if not valid_item[0][1] == 'Yes': msgprint("Item : '%s' is not Purchase Item"%(d.item_code)) raise Exception - + def check_conversion_rate(self): - default_currency = get_company_currency(self.doc.company) + default_currency = get_company_currency(self.company) if not default_currency: msgprint('Message: Please enter default currency in Company Master') raise Exception - if (self.doc.currency == default_currency and flt(self.doc.conversion_rate) != 1.00) or not self.doc.conversion_rate or (self.doc.currency != default_currency and flt(self.doc.conversion_rate) == 1.00): + if (self.currency == default_currency and flt(self.conversion_rate) != 1.00) or not self.conversion_rate or (self.currency != default_currency and flt(self.conversion_rate) == 1.00): msgprint("Message: Please Enter Appropriate Conversion Rate.") - raise Exception - - def validate_bill_no(self): - if self.doc.bill_no and self.doc.bill_no.lower().strip() \ - not in ['na', 'not applicable', 'none']: - b_no = frappe.db.sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice` - where bill_no = %s and credit_to = %s and docstatus = 1 and name != %s""", - (self.doc.bill_no, self.doc.credit_to, self.doc.name)) - if b_no and cstr(b_no[0][2]) == cstr(self.doc.is_opening): - msgprint("Please check you have already booked expense against Bill No. %s \ - in Purchase Invoice %s" % (cstr(b_no[0][0]), cstr(b_no[0][1])), - raise_exception=1) - - if not self.doc.remarks and self.doc.bill_date: - self.doc.remarks = (self.doc.remarks or '') + "\n" + ("Against Bill %s dated %s" - % (self.doc.bill_no, formatdate(self.doc.bill_date))) + raise Exception - if not self.doc.remarks: - self.doc.remarks = "No Remarks" + def validate_bill_no(self): + if self.bill_no and self.bill_no.lower().strip() \ + not in ['na', 'not applicable', 'none']: + b_no = frappe.db.sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice` + where bill_no = %s and credit_to = %s and docstatus = 1 and name != %s""", + (self.bill_no, self.credit_to, self.name)) + if b_no and cstr(b_no[0][2]) == cstr(self.is_opening): + msgprint("Please check you have already booked expense against Bill No. %s \ + in Purchase Invoice %s" % (cstr(b_no[0][0]), cstr(b_no[0][1])), + raise_exception=1) + + if not self.remarks and self.bill_date: + self.remarks = (self.remarks or '') + "\n" + ("Against Bill %s dated %s" + % (self.bill_no, formatdate(self.bill_date))) + + if not self.remarks: + self.remarks = "No Remarks" def validate_credit_acc(self): - if frappe.db.get_value("Account", self.doc.credit_to, "report_type") != "Balance Sheet": + if frappe.db.get_value("Account", self.credit_to, "report_type") != "Balance Sheet": frappe.throw(_("Account must be a balance sheet account")) - + # Validate Acc Head of Supplier and Credit To Account entered # ------------------------------------------------------------ - def check_for_acc_head_of_supplier(self): - if self.doc.supplier and self.doc.credit_to: - acc_head = frappe.db.sql("select master_name from `tabAccount` where name = %s", self.doc.credit_to) - - if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.supplier)) or (not acc_head and (self.doc.credit_to != cstr(self.doc.supplier) + " - " + self.company_abbr)): - msgprint("Credit To: %s do not match with Supplier: %s for Company: %s.\n If both correctly entered, please select Master Type and Master Name in account master." %(self.doc.credit_to,self.doc.supplier,self.doc.company), raise_exception=1) - + def check_for_acc_head_of_supplier(self): + if self.supplier and self.credit_to: + acc_head = frappe.db.sql("select master_name from `tabAccount` where name = %s", self.credit_to) + + if (acc_head and cstr(acc_head[0][0]) != cstr(self.supplier)) or (not acc_head and (self.credit_to != cstr(self.supplier) + " - " + self.company_abbr)): + msgprint("Credit To: %s do not match with Supplier: %s for Company: %s.\n If both correctly entered, please select Master Type and Master Name in account master." %(self.credit_to,self.supplier,self.company), raise_exception=1) + # Check for Stopped PO # --------------------- def check_for_stopped_status(self): check_list = [] - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt: - check_list.append(d.purhcase_order) + check_list.append(d.purchase_order) stopped = frappe.db.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = %s", d.purchase_order) if stopped: msgprint("One cannot do any transaction against 'Purchase Order' : %s, it's status is 'Stopped'" % (d.purhcase_order)) raise Exception - + def validate_with_previous_doc(self): - super(DocType, self).validate_with_previous_doc(self.tname, { + super(PurchaseInvoice, self).validate_with_previous_doc(self.tname, { "Purchase Order": { "ref_dn_field": "purchase_order", "compare_fields": [["supplier", "="], ["company", "="], ["currency", "="]], @@ -155,9 +155,9 @@ class DocType(BuyingController): "is_child_table": True } }) - + if cint(frappe.defaults.get_global_default('maintain_same_rate')): - super(DocType, self).validate_with_previous_doc(self.tname, { + super(PurchaseInvoice, self).validate_with_previous_doc(self.tname, { "Purchase Order Item": { "ref_dn_field": "po_detail", "compare_fields": [["rate", "="]], @@ -170,64 +170,64 @@ class DocType(BuyingController): "is_child_table": True } }) - - + + def set_aging_date(self): - if self.doc.is_opening != 'Yes': - self.doc.aging_date = self.doc.posting_date - elif not self.doc.aging_date: + if self.is_opening != 'Yes': + self.aging_date = self.posting_date + elif not self.aging_date: msgprint("Aging Date is mandatory for opening entry") raise Exception - + def set_against_expense_account(self): auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) if auto_accounting_for_stock: stock_not_billed_account = self.get_company_default("stock_received_but_not_billed") - + against_accounts = [] stock_items = self.get_stock_items() - for item in self.doclist.get({"parentfield": "entries"}): + for item in self.get("entries"): if auto_accounting_for_stock and item.item_code in stock_items \ - and self.doc.is_opening == 'No': + and self.is_opening == 'No': # in case of auto inventory accounting, against expense account is always # Stock Received But Not Billed for a stock item item.expense_account = stock_not_billed_account item.cost_center = None - + if stock_not_billed_account not in against_accounts: against_accounts.append(stock_not_billed_account) - + elif not item.expense_account: - msgprint(_("Expense account is mandatory for item") + ": " + + msgprint(_("Expense account is mandatory for item") + ": " + (item.item_code or item.item_name), raise_exception=1) - + elif item.expense_account not in against_accounts: # if no auto_accounting_for_stock or not a stock item against_accounts.append(item.expense_account) - - self.doc.against_expense_account = ",".join(against_accounts) + + self.against_expense_account = ",".join(against_accounts) def po_required(self): if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes': - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if not d.purchase_order: msgprint("Purchse Order No. required against item %s"%d.item_code) raise Exception def pr_required(self): if frappe.db.get_value("Buying Settings", None, "pr_required") == 'Yes': - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if not d.purchase_receipt: msgprint("Purchase Receipt No. required against item %s"%d.item_code) raise Exception def validate_write_off_account(self): - if self.doc.write_off_amount and not self.doc.write_off_account: + if self.write_off_amount and not self.write_off_account: msgprint("Please enter Write Off Account", raise_exception=1) def check_prev_docstatus(self): - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if d.purchase_order: submitted = frappe.db.sql("select name from `tabPurchase Order` where docstatus = 1 and name = %s", d.purchase_order) if not submitted: @@ -236,8 +236,8 @@ class DocType(BuyingController): submitted = frappe.db.sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = %s", d.purchase_receipt) if not submitted: frappe.throw("Purchase Receipt : "+ cstr(d.purchase_receipt) +" is not submitted") - - + + def update_against_document_in_jv(self): """ Links invoice and advance voucher: @@ -245,33 +245,33 @@ class DocType(BuyingController): 2. split into multiple rows if partially adjusted, assign against voucher 3. submit advance voucher """ - + lst = [] - for d in getlist(self.doclist, 'advance_allocation_details'): + for d in self.get('advance_allocation_details'): if flt(d.allocated_amount) > 0: args = { - 'voucher_no' : d.journal_voucher, - 'voucher_detail_no' : d.jv_detail_no, - 'against_voucher_type' : 'Purchase Invoice', - 'against_voucher' : self.doc.name, - 'account' : self.doc.credit_to, - 'is_advance' : 'Yes', - 'dr_or_cr' : 'debit', + 'voucher_no' : d.journal_voucher, + 'voucher_detail_no' : d.jv_detail_no, + 'against_voucher_type' : 'Purchase Invoice', + 'against_voucher' : self.name, + 'account' : self.credit_to, + 'is_advance' : 'Yes', + 'dr_or_cr' : 'debit', 'unadjusted_amt' : flt(d.advance_amount), 'allocated_amt' : flt(d.allocated_amount) } lst.append(args) - + if lst: from erpnext.accounts.utils import reconcile_against_document reconcile_against_document(lst) def on_submit(self): self.check_prev_docstatus() - - get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, - self.doc.company, self.doc.grand_total) - + + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, + self.company, self.grand_total) + # this sequence because outstanding may get -negative self.make_gl_entries() self.update_against_document_in_jv() @@ -281,156 +281,156 @@ class DocType(BuyingController): def make_gl_entries(self): auto_accounting_for_stock = \ cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) - + gl_entries = [] - + # parent's gl entry - if self.doc.grand_total: + if self.grand_total: gl_entries.append( self.get_gl_dict({ - "account": self.doc.credit_to, - "against": self.doc.against_expense_account, - "credit": self.doc.total_amount_to_pay, - "remarks": self.doc.remarks, - "against_voucher": self.doc.name, - "against_voucher_type": self.doc.doctype, + "account": self.credit_to, + "against": self.against_expense_account, + "credit": self.total_amount_to_pay, + "remarks": self.remarks, + "against_voucher": self.name, + "against_voucher_type": self.doctype, }) ) - + # tax table gl entries valuation_tax = {} - for tax in self.doclist.get({"parentfield": "other_charges"}): + for tax in self.get("other_charges"): if tax.category in ("Total", "Valuation and Total") and flt(tax.tax_amount): gl_entries.append( self.get_gl_dict({ "account": tax.account_head, - "against": self.doc.credit_to, + "against": self.credit_to, "debit": tax.add_deduct_tax == "Add" and tax.tax_amount or 0, "credit": tax.add_deduct_tax == "Deduct" and tax.tax_amount or 0, - "remarks": self.doc.remarks, + "remarks": self.remarks, "cost_center": tax.cost_center }) ) - + # accumulate valuation tax if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount): if auto_accounting_for_stock and not tax.cost_center: frappe.throw(_("Row %(row)s: Cost Center is mandatory \ - if tax/charges category is Valuation or Valuation and Total" % + if tax/charges category is Valuation or Valuation and Total" % {"row": tax.idx})) valuation_tax.setdefault(tax.cost_center, 0) valuation_tax[tax.cost_center] += \ (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount) - + # item gl entries stock_item_and_auto_accounting_for_stock = False stock_items = self.get_stock_items() - for item in self.doclist.get({"parentfield": "entries"}): + for item in self.get("entries"): if auto_accounting_for_stock and item.item_code in stock_items: if flt(item.valuation_rate): - # if auto inventory accounting enabled and stock item, + # if auto inventory accounting enabled and stock item, # then do stock related gl entries # expense will be booked in sales invoice stock_item_and_auto_accounting_for_stock = True - - valuation_amt = flt(item.base_amount + item.item_tax_amount + item.rm_supp_cost, + + valuation_amt = flt(item.base_amount + item.item_tax_amount + item.rm_supp_cost, self.precision("base_amount", item)) - + gl_entries.append( self.get_gl_dict({ "account": item.expense_account, - "against": self.doc.credit_to, + "against": self.credit_to, "debit": valuation_amt, - "remarks": self.doc.remarks or "Accounting Entry for Stock" + "remarks": self.remarks or "Accounting Entry for Stock" }) ) - + elif flt(item.base_amount): # if not a stock item or auto inventory accounting disabled, book the expense gl_entries.append( self.get_gl_dict({ "account": item.expense_account, - "against": self.doc.credit_to, + "against": self.credit_to, "debit": item.base_amount, - "remarks": self.doc.remarks, + "remarks": self.remarks, "cost_center": item.cost_center }) ) - + if stock_item_and_auto_accounting_for_stock and valuation_tax: # credit valuation tax amount in "Expenses Included In Valuation" # this will balance out valuation amount included in cost of goods sold expenses_included_in_valuation = \ self.get_company_default("expenses_included_in_valuation") - + for cost_center, amount in valuation_tax.items(): gl_entries.append( self.get_gl_dict({ "account": expenses_included_in_valuation, "cost_center": cost_center, - "against": self.doc.credit_to, + "against": self.credit_to, "credit": amount, - "remarks": self.doc.remarks or "Accounting Entry for Stock" + "remarks": self.remarks or "Accounting Entry for Stock" }) ) - - # writeoff account includes petty difference in the invoice amount + + # writeoff account includes petty difference in the invoice amount # and the amount that is paid - if self.doc.write_off_account and flt(self.doc.write_off_amount): + if self.write_off_account and flt(self.write_off_amount): gl_entries.append( self.get_gl_dict({ - "account": self.doc.write_off_account, - "against": self.doc.credit_to, - "credit": flt(self.doc.write_off_amount), - "remarks": self.doc.remarks, - "cost_center": self.doc.write_off_cost_center + "account": self.write_off_account, + "against": self.credit_to, + "credit": flt(self.write_off_amount), + "remarks": self.remarks, + "cost_center": self.write_off_cost_center }) ) - + if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries - make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2)) + make_gl_entries(gl_entries, cancel=(self.docstatus == 2)) def on_cancel(self): from erpnext.accounts.utils import remove_against_link_from_jv - remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_voucher") - + remove_against_link_from_jv(self.doctype, self.name, "against_voucher") + self.update_prevdoc_status() self.update_billing_status_for_zero_amount_refdoc("Purchase Order") self.make_cancel_gl_entries() - + def on_update(self): pass - + def update_raw_material_cost(self): if self.sub_contracted_items: - for d in self.doclist.get({"parentfield": "entries"}): - rm_cost = frappe.db.sql("""select raw_material_cost / quantity - from `tabBOM` where item = %s and is_default = 1 and docstatus = 1 + for d in self.get("entries"): + rm_cost = frappe.db.sql("""select raw_material_cost / quantity + from `tabBOM` where item = %s and is_default = 1 and docstatus = 1 and is_active = 1 """, (d.item_code,)) rm_cost = rm_cost and flt(rm_cost[0][0]) or 0 - + d.conversion_factor = d.conversion_factor or flt(frappe.db.get_value( - "UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom}, + "UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom}, "conversion_factor")) or 1 - + d.rm_supp_cost = rm_cost * flt(d.qty) * flt(d.conversion_factor) - + @frappe.whitelist() def get_expense_account(doctype, txt, searchfield, start, page_len, filters): from erpnext.controllers.queries import get_match_cond - - # expense account can be any Debit account, - # but can also be a Liability account with account_type='Expense Account' in special circumstances. + + # expense account can be any Debit account, + # but can also be a Liability account with account_type='Expense Account' in special circumstances. # Hence the first condition is an "OR" - return frappe.db.sql("""select tabAccount.name from `tabAccount` + return frappe.db.sql("""select tabAccount.name from `tabAccount` where (tabAccount.report_type = "Profit and Loss" or tabAccount.account_type = "Expense Account") - and tabAccount.group_or_ledger="Ledger" - and tabAccount.docstatus!=2 + and tabAccount.group_or_ledger="Ledger" + and tabAccount.docstatus!=2 and ifnull(tabAccount.master_type, "")="" and ifnull(tabAccount.master_name, "")="" - and tabAccount.company = '%(company)s' + and tabAccount.company = '%(company)s' and tabAccount.%(key)s LIKE '%(txt)s' - %(mcond)s""" % {'company': filters['company'], 'key': searchfield, + %(mcond)s""" % {'company': filters['company'], 'key': searchfield, 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)}) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.txt b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.txt deleted file mode 100755 index 1ad767e31c8..00000000000 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.txt +++ /dev/null @@ -1,829 +0,0 @@ -[ - { - "creation": "2013-05-21 16:16:39", - "docstatus": 0, - "modified": "2014-02-17 12:01:59", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "icon": "icon-file-text", - "is_submittable": 1, - "module": "Accounts", - "name": "__common__", - "read_only_onload": 1, - "search_fields": "posting_date, credit_to, fiscal_year, bill_no, grand_total, outstanding_amount" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Purchase Invoice", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Purchase Invoice", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Purchase Invoice" - }, - { - "doctype": "DocField", - "fieldname": "supplier_section", - "fieldtype": "Section Break", - "label": "Supplier", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "BILL\nBILLJ", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "supplier", - "fieldtype": "Link", - "hidden": 0, - "label": "Supplier", - "oldfieldname": "supplier", - "oldfieldtype": "Link", - "options": "Supplier", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "supplier", - "doctype": "DocField", - "fieldname": "supplier_name", - "fieldtype": "Data", - "hidden": 0, - "in_list_view": 1, - "label": "Name", - "oldfieldname": "supplier_name", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Text", - "hidden": 1, - "label": "Mobile No", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Text", - "hidden": 1, - "label": "Contact Email", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "reqd": 0, - "width": "50%" - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Posting Date", - "no_copy": 0, - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "description": "If not applicable please enter: NA", - "doctype": "DocField", - "fieldname": "bill_no", - "fieldtype": "Data", - "in_filter": 1, - "label": "Supplier Invoice No", - "oldfieldname": "bill_no", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "bill_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Supplier Invoice Date", - "oldfieldname": "bill_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 0, - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Link", - "options": "Purchase Invoice", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "read_only": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "currency_price_list", - "fieldtype": "Section Break", - "label": "Currency and Price List", - "options": "icon-tag", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "currency", - "fieldtype": "Link", - "label": "Currency", - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "print_hide": 1, - "read_only": 0 - }, - { - "description": "The rate at which Bill Currency is converted into company's base currency", - "doctype": "DocField", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "label": "Exchange Rate", - "oldfieldname": "conversion_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "buying_price_list", - "fieldtype": "Link", - "label": "Price List", - "options": "Price List", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "price_list_currency", - "fieldtype": "Link", - "label": "Price List Currency", - "options": "Currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "label": "Price List Exchange Rate", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "items", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart", - "read_only": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "entries", - "fieldtype": "Table", - "label": "Entries", - "oldfieldname": "entries", - "oldfieldtype": "Table", - "options": "Purchase Invoice Item", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_26", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total_import", - "fieldtype": "Currency", - "label": "Net Total", - "oldfieldname": "net_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_28", - "fieldtype": "Column Break" - }, - { - "description": "Will be calculated automatically when you enter the details", - "doctype": "DocField", - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total (Company Currency)", - "oldfieldname": "net_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "taxes", - "fieldtype": "Section Break", - "label": "Taxes and Charges", - "oldfieldtype": "Section Break", - "options": "icon-money", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "oldfieldname": "purchase_other_charges", - "oldfieldtype": "Link", - "options": "Purchase Taxes and Charges Master", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "other_charges", - "fieldtype": "Table", - "label": "Purchase Taxes and Charges", - "oldfieldname": "purchase_tax_details", - "oldfieldtype": "Table", - "options": "Purchase Taxes and Charges", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_calculation", - "fieldtype": "HTML", - "label": "Taxes and Charges Calculation", - "oldfieldtype": "HTML", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "Totals", - "oldfieldtype": "Section Break", - "options": "icon-money", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_added_import", - "fieldtype": "Currency", - "label": "Taxes and Charges Added", - "oldfieldname": "other_charges_added_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_deducted_import", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted", - "oldfieldname": "other_charges_deducted_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "grand_total_import", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Grand Total", - "oldfieldname": "grand_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "in_words_import", - "fieldtype": "Data", - "label": "In Words", - "oldfieldname": "in_words_import", - "oldfieldtype": "Data", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_amount_to_pay", - "fieldtype": "Currency", - "hidden": 0, - "label": "Total Amount To Pay", - "no_copy": 1, - "oldfieldname": "total_amount_to_pay", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_advance", - "fieldtype": "Currency", - "label": "Total Advance", - "no_copy": 1, - "oldfieldname": "total_advance", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "outstanding_amount", - "fieldtype": "Currency", - "in_filter": 1, - "in_list_view": 1, - "label": "Outstanding Amount", - "no_copy": 1, - "oldfieldname": "outstanding_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break8", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "total_tax", - "fieldtype": "Currency", - "label": "Total Tax (Company Currency)", - "oldfieldname": "total_tax", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_added", - "fieldtype": "Currency", - "label": "Taxes and Charges Added (Company Currency)", - "oldfieldname": "other_charges_added", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_deducted", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted (Company Currency)", - "oldfieldname": "other_charges_deducted", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "description": "In Words will be visible once you save the Purchase Invoice.", - "doctype": "DocField", - "fieldname": "in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "write_off_amount", - "fieldtype": "Currency", - "label": "Write Off Amount", - "no_copy": 1, - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "eval:flt(doc.write_off_amount)!=0", - "doctype": "DocField", - "fieldname": "write_off_account", - "fieldtype": "Link", - "label": "Write Off Account", - "no_copy": 1, - "options": "Account", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "eval:flt(doc.write_off_amount)!=0", - "doctype": "DocField", - "fieldname": "write_off_cost_center", - "fieldtype": "Link", - "label": "Write Off Cost Center", - "no_copy": 1, - "options": "Cost Center", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "against_expense_account", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Against Expense Account", - "no_copy": 1, - "oldfieldname": "against_expense_account", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 0, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "advances", - "fieldtype": "Section Break", - "label": "Advances", - "oldfieldtype": "Section Break", - "options": "icon-money", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "get_advances_paid", - "fieldtype": "Button", - "label": "Get Advances Paid", - "oldfieldtype": "Button", - "options": "get_advances", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "advance_allocation_details", - "fieldtype": "Table", - "label": "Purchase Invoice Advances", - "no_copy": 1, - "oldfieldname": "advance_allocation_details", - "oldfieldtype": "Table", - "options": "Purchase Invoice Advance", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "options": "icon-legal" - }, - { - "doctype": "DocField", - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "options": "Terms and Conditions", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Terms and Conditions1" - }, - { - "depends_on": "supplier", - "doctype": "DocField", - "fieldname": "contact_section", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "supplier_address", - "fieldtype": "Link", - "label": "Supplier Address", - "options": "Address", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break23", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "label": "Contact Person", - "options": "Contact", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text", - "print_hide": 1, - "read_only": 0 - }, - { - "description": "Supplier (Payable) Account", - "doctype": "DocField", - "fieldname": "credit_to", - "fieldtype": "Link", - "in_filter": 1, - "label": "Credit To", - "oldfieldname": "credit_to", - "oldfieldtype": "Link", - "options": "Account", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "default": "No", - "description": "Considered as Opening Balance", - "doctype": "DocField", - "fieldname": "is_opening", - "fieldtype": "Select", - "in_filter": 1, - "label": "Is Opening", - "oldfieldname": "is_opening", - "oldfieldtype": "Select", - "options": "No\nYes", - "print_hide": 1, - "read_only": 0, - "search_index": 1 - }, - { - "description": "Actual Invoice Date", - "doctype": "DocField", - "fieldname": "aging_date", - "fieldtype": "Date", - "label": "Aging Date", - "oldfieldname": "aging_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 0, - "search_index": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "due_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Due Date", - "no_copy": 0, - "oldfieldname": "due_date", - "oldfieldtype": "Date", - "print_hide": 0, - "read_only": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "mode_of_payment", - "fieldtype": "Select", - "label": "Mode of Payment", - "oldfieldname": "mode_of_payment", - "oldfieldtype": "Select", - "options": "link:Mode of Payment", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_63", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Select", - "label": "Letter Head", - "options": "link:Letter Head", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "read_only": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "remarks", - "fieldtype": "Small Text", - "label": "Remarks", - "no_copy": 1, - "oldfieldname": "remarks", - "oldfieldtype": "Text", - "print_hide": 1, - "read_only": 0, - "reqd": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Accounts User", - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase User", - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Supplier", - "submit": 0, - "write": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Accounts Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Auditor", - "submit": 0, - "write": 0 - } -] diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index b5942e3ddcc..c4ef3e7ec0f 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import unittest import frappe import frappe.model -import json +import json from frappe.utils import cint import frappe.defaults from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory @@ -18,13 +18,13 @@ class TestPurchaseInvoice(unittest.TestCase): def test_gl_entries_without_auto_accounting_for_stock(self): set_perpetual_inventory(0) self.assertTrue(not cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))) - - wrapper = frappe.bean(copy=test_records[0]) + + wrapper = frappe.copy_doc(test_records[0]) wrapper.insert() wrapper.submit() wrapper.load_from_db() - dl = wrapper.doclist - + dl = wrapper + expected_gl_entries = { "_Test Supplier - _TC": [0, 1512.30], "_Test Account Cost for Goods Sold - _TC": [1250, 0], @@ -37,23 +37,23 @@ class TestPurchaseInvoice(unittest.TestCase): "_Test Account Discount - _TC": [0, 168.03], } gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry` - where voucher_type = 'Purchase Invoice' and voucher_no = %s""", dl[0].name, as_dict=1) + where voucher_type = 'Purchase Invoice' and voucher_no = %s""", dl.name, as_dict=1) for d in gl_entries: self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account)) - + def test_gl_entries_with_auto_accounting_for_stock(self): set_perpetual_inventory(1) self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1) - - pi = frappe.bean(copy=test_records[1]) + + pi = frappe.copy_doc(test_records[1]) pi.insert() pi.submit() - + gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s - order by account asc""", pi.doc.name, as_dict=1) + order by account asc""", pi.name, as_dict=1) self.assertTrue(gl_entries) - + expected_values = sorted([ ["_Test Supplier - _TC", 0, 720], ["Stock Received But Not Billed - _TC", 750.0, 0], @@ -61,59 +61,59 @@ class TestPurchaseInvoice(unittest.TestCase): ["_Test Account VAT - _TC", 120.0, 0], ["Expenses Included In Valuation - _TC", 0, 250.0], ]) - + for i, gle in enumerate(gl_entries): self.assertEquals(expected_values[i][0], gle.account) self.assertEquals(expected_values[i][1], gle.debit) self.assertEquals(expected_values[i][2], gle.credit) - + set_perpetual_inventory(0) def test_gl_entries_with_aia_for_non_stock_items(self): set_perpetual_inventory() self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1) - - pi = frappe.bean(copy=test_records[1]) - pi.doclist[1].item_code = "_Test Non Stock Item" - pi.doclist[1].expense_account = "_Test Account Cost for Goods Sold - _TC" - pi.doclist.pop(2) - pi.doclist.pop(3) + + pi = frappe.copy_doc(test_records[1]) + pi.get("entries")[0].item_code = "_Test Non Stock Item" + pi.get("entries")[0].expense_account = "_Test Account Cost for Goods Sold - _TC" + pi.get("other_charges").pop(0) + pi.get("other_charges").pop(1) pi.insert() pi.submit() - + gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s - order by account asc""", pi.doc.name, as_dict=1) + order by account asc""", pi.name, as_dict=1) self.assertTrue(gl_entries) - + expected_values = sorted([ ["_Test Supplier - _TC", 0, 620], ["_Test Account Cost for Goods Sold - _TC", 500.0, 0], ["_Test Account VAT - _TC", 120.0, 0], ]) - + for i, gle in enumerate(gl_entries): self.assertEquals(expected_values[i][0], gle.account) self.assertEquals(expected_values[i][1], gle.debit) self.assertEquals(expected_values[i][2], gle.credit) set_perpetual_inventory(0) - + def test_purchase_invoice_calculation(self): - wrapper = frappe.bean(copy=test_records[0]) + wrapper = frappe.copy_doc(test_records[0]) wrapper.insert() wrapper.load_from_db() - + expected_values = [ ["_Test Item Home Desktop 100", 90, 59], ["_Test Item Home Desktop 200", 135, 177] ] - for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})): + for i, item in enumerate(wrapper.get("entries")): self.assertEqual(item.item_code, expected_values[i][0]) self.assertEqual(item.item_tax_amount, expected_values[i][1]) self.assertEqual(item.valuation_rate, expected_values[i][2]) - - self.assertEqual(wrapper.doclist[0].net_total, 1250) - + + self.assertEqual(wrapper.net_total, 1250) + # tax amounts expected_values = [ ["_Test Account Shipping Charges - _TC", 100, 1350], @@ -125,28 +125,28 @@ class TestPurchaseInvoice(unittest.TestCase): ["_Test Account VAT - _TC", 156.25, 1680.33], ["_Test Account Discount - _TC", 168.03, 1512.30], ] - - for i, tax in enumerate(wrapper.doclist.get({"parentfield": "other_charges"})): + + for i, tax in enumerate(wrapper.get("other_charges")): self.assertEqual(tax.account_head, expected_values[i][0]) self.assertEqual(tax.tax_amount, expected_values[i][1]) self.assertEqual(tax.total, expected_values[i][2]) - + def test_purchase_invoice_with_subcontracted_item(self): - wrapper = frappe.bean(copy=test_records[0]) - wrapper.doclist[1].item_code = "_Test FG Item" + wrapper = frappe.copy_doc(test_records[0]) + wrapper.get("entries")[0].item_code = "_Test FG Item" wrapper.insert() wrapper.load_from_db() - + expected_values = [ ["_Test FG Item", 90, 7059], ["_Test Item Home Desktop 200", 135, 177] ] - for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})): + for i, item in enumerate(wrapper.get("entries")): self.assertEqual(item.item_code, expected_values[i][0]) self.assertEqual(item.item_tax_amount, expected_values[i][1]) self.assertEqual(item.valuation_rate, expected_values[i][2]) - - self.assertEqual(wrapper.doclist[0].net_total, 1250) + + self.assertEqual(wrapper.net_total, 1250) # tax amounts expected_values = [ @@ -160,252 +160,42 @@ class TestPurchaseInvoice(unittest.TestCase): ["_Test Account Discount - _TC", 168.03, 1512.30], ] - for i, tax in enumerate(wrapper.doclist.get({"parentfield": "other_charges"})): + for i, tax in enumerate(wrapper.get("other_charges")): self.assertEqual(tax.account_head, expected_values[i][0]) self.assertEqual(tax.tax_amount, expected_values[i][1]) self.assertEqual(tax.total, expected_values[i][2]) - + def test_purchase_invoice_with_advance(self): from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \ import test_records as jv_test_records - - jv = frappe.bean(copy=jv_test_records[1]) + + jv = frappe.copy_doc(jv_test_records[1]) jv.insert() jv.submit() - - pi = frappe.bean(copy=test_records[0]) - pi.doclist.append({ - "doctype": "Purchase Invoice Advance", - "parentfield": "advance_allocation_details", - "journal_voucher": jv.doc.name, - "jv_detail_no": jv.doclist[1].name, + + pi = frappe.copy_doc(test_records[0]) + pi.append("advance_allocation_details", { + "journal_voucher": jv.name, + "jv_detail_no": jv.get("entries")[0].name, "advance_amount": 400, "allocated_amount": 300, - "remarks": jv.doc.remark + "remarks": jv.remark }) pi.insert() pi.submit() pi.load_from_db() - + self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail` - where against_voucher=%s""", pi.doc.name)) - + where against_voucher=%s""", pi.name)) + self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail` - where against_voucher=%s and debit=300""", pi.doc.name)) - - self.assertEqual(pi.doc.outstanding_amount, 1212.30) - + where against_voucher=%s and debit=300""", pi.name)) + + self.assertEqual(pi.outstanding_amount, 1212.30) + pi.cancel() - + self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail` - where against_voucher=%s""", pi.doc.name)) - -test_records = [ - [ - # parent - { - "doctype": "Purchase Invoice", - "naming_series": "BILL", - "supplier_name": "_Test Supplier", - "credit_to": "_Test Supplier - _TC", - "bill_no": "NA", - "posting_date": "2013-02-03", - "fiscal_year": "_Test Fiscal Year 2013", - "company": "_Test Company", - "currency": "INR", - "conversion_rate": 1, - "grand_total_import": 0, # for feed - "buying_price_list": "_Test Price List" - }, - # items - { - "doctype": "Purchase Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "qty": 10, - "rate": 50, - "amount": 500, - "base_rate": 50, - "base_amount": 500, - "uom": "_Test UOM", - "item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}), - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "cost_center": "_Test Cost Center - _TC", - "conversion_factor": 1.0, - - }, - { - "doctype": "Purchase Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "qty": 5, - "rate": 150, - "amount": 750, - "base_rate": 150, - "base_amount": 750, - "uom": "_Test UOM", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "cost_center": "_Test Cost Center - _TC", - "conversion_factor": 1.0, - }, - # taxes - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "category": "Valuation and Total", - "add_deduct_tax": "Add", - "rate": 100 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Customs Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "category": "Valuation", - "add_deduct_tax": "Add", - "rate": 10 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Excise Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 12 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 2, - "row_id": 3 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account S&H Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 1, - "row_id": 3 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account CST - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 2, - "row_id": 5 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account VAT - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 12.5 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account Discount - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "category": "Total", - "add_deduct_tax": "Deduct", - "rate": 10, - "row_id": 7 - }, - ], - [ - # parent - { - "doctype": "Purchase Invoice", - "naming_series": "_T-Purchase Invoice-", - "supplier_name": "_Test Supplier", - "credit_to": "_Test Supplier - _TC", - "bill_no": "NA", - "posting_date": "2013-02-03", - "fiscal_year": "_Test Fiscal Year 2013", - "company": "_Test Company", - "currency": "INR", - "conversion_rate": 1.0, - "grand_total_import": 0, # for feed - "buying_price_list": "_Test Price List" - }, - # items - { - "doctype": "Purchase Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item", - "item_name": "_Test Item", - "qty": 10.0, - "rate": 50.0, - "uom": "_Test UOM", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "cost_center": "_Test Cost Center - _TC", - "conversion_factor": 1.0, - }, - # taxes - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "category": "Valuation and Total", - "add_deduct_tax": "Add", - "rate": 100.0 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account VAT - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "category": "Total", - "add_deduct_tax": "Add", - "rate": 120.0 - }, - { - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Customs Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "category": "Valuation", - "add_deduct_tax": "Add", - "rate": 150.0 - }, - ] -] \ No newline at end of file + where against_voucher=%s""", pi.name)) + +test_records = frappe.get_test_records('Purchase Invoice') diff --git a/erpnext/accounts/doctype/purchase_invoice/test_records.json b/erpnext/accounts/doctype/purchase_invoice/test_records.json new file mode 100644 index 00000000000..67a705cc4aa --- /dev/null +++ b/erpnext/accounts/doctype/purchase_invoice/test_records.json @@ -0,0 +1,206 @@ +[ + { + "bill_no": "NA", + "buying_price_list": "_Test Price List", + "company": "_Test Company", + "conversion_rate": 1, + "credit_to": "_Test Supplier - _TC", + "currency": "INR", + "doctype": "Purchase Invoice", + "entries": [ + { + "amount": 500, + "base_amount": 500, + "base_rate": 50, + "conversion_factor": 1.0, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Purchase Invoice Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "item_code": "_Test Item Home Desktop 100", + "item_name": "_Test Item Home Desktop 100", + "item_tax_rate": "{\"_Test Account Excise Duty - _TC\": 10}", + "parentfield": "entries", + "qty": 10, + "rate": 50, + "uom": "_Test UOM" + }, + { + "amount": 750, + "base_amount": 750, + "base_rate": 150, + "conversion_factor": 1.0, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Purchase Invoice Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "item_code": "_Test Item Home Desktop 200", + "item_name": "_Test Item Home Desktop 200", + "parentfield": "entries", + "qty": 5, + "rate": 150, + "uom": "_Test UOM" + } + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total_import": 0, + "naming_series": "BILL", + "other_charges": [ + { + "account_head": "_Test Account Shipping Charges - _TC", + "add_deduct_tax": "Add", + "category": "Valuation and Total", + "charge_type": "Actual", + "cost_center": "_Test Cost Center - _TC", + "description": "Shipping Charges", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 100 + }, + { + "account_head": "_Test Account Customs Duty - _TC", + "add_deduct_tax": "Add", + "category": "Valuation", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Customs Duty", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 10 + }, + { + "account_head": "_Test Account Excise Duty - _TC", + "add_deduct_tax": "Add", + "category": "Total", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Excise Duty", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 12 + }, + { + "account_head": "_Test Account Education Cess - _TC", + "add_deduct_tax": "Add", + "category": "Total", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "Education Cess", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 2, + "row_id": 3 + }, + { + "account_head": "_Test Account S&H Education Cess - _TC", + "add_deduct_tax": "Add", + "category": "Total", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "S&H Education Cess", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 1, + "row_id": 3 + }, + { + "account_head": "_Test Account CST - _TC", + "add_deduct_tax": "Add", + "category": "Total", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "CST", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 2, + "row_id": 5 + }, + { + "account_head": "_Test Account VAT - _TC", + "add_deduct_tax": "Add", + "category": "Total", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "VAT", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 12.5 + }, + { + "account_head": "_Test Account Discount - _TC", + "add_deduct_tax": "Deduct", + "category": "Total", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Discount", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 10, + "row_id": 7 + } + ], + "posting_date": "2013-02-03", + "supplier_name": "_Test Supplier" + }, + { + "bill_no": "NA", + "buying_price_list": "_Test Price List", + "company": "_Test Company", + "conversion_rate": 1.0, + "credit_to": "_Test Supplier - _TC", + "currency": "INR", + "doctype": "Purchase Invoice", + "entries": [ + { + "conversion_factor": 1.0, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Purchase Invoice Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "item_code": "_Test Item", + "item_name": "_Test Item", + "parentfield": "entries", + "qty": 10.0, + "rate": 50.0, + "uom": "_Test UOM" + } + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total_import": 0, + "naming_series": "_T-Purchase Invoice-", + "other_charges": [ + { + "account_head": "_Test Account Shipping Charges - _TC", + "add_deduct_tax": "Add", + "category": "Valuation and Total", + "charge_type": "Actual", + "cost_center": "_Test Cost Center - _TC", + "description": "Shipping Charges", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 100.0 + }, + { + "account_head": "_Test Account VAT - _TC", + "add_deduct_tax": "Add", + "category": "Total", + "charge_type": "Actual", + "cost_center": "_Test Cost Center - _TC", + "description": "VAT", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 120.0 + }, + { + "account_head": "_Test Account Customs Duty - _TC", + "add_deduct_tax": "Add", + "category": "Valuation", + "charge_type": "Actual", + "cost_center": "_Test Cost Center - _TC", + "description": "Customs Duty", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 150.0 + } + ], + "posting_date": "2013-02-03", + "supplier_name": "_Test Supplier" + } +] \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.json b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.json new file mode 100644 index 00000000000..47e2d89ae84 --- /dev/null +++ b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.json @@ -0,0 +1,88 @@ +{ + "creation": "2013-03-08 15:36:46.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "journal_voucher", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Journal Voucher", + "no_copy": 1, + "oldfieldname": "journal_voucher", + "oldfieldtype": "Link", + "options": "Journal Voucher", + "permlevel": 0, + "print_width": "180px", + "read_only": 1, + "width": "180px" + }, + { + "fieldname": "jv_detail_no", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Journal Voucher Detail No", + "no_copy": 1, + "oldfieldname": "jv_detail_no", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "print_width": "80px", + "read_only": 1, + "width": "80px" + }, + { + "fieldname": "remarks", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Remarks", + "no_copy": 1, + "oldfieldname": "remarks", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "advance_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Advance Amount", + "no_copy": 1, + "oldfieldname": "advance_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_width": "100px", + "read_only": 1, + "width": "100px" + }, + { + "fieldname": "allocated_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Allocated Amount", + "no_copy": 1, + "oldfieldname": "allocated_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_width": "100px", + "width": "100px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-03 12:38:24.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Purchase Invoice Advance", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py index 26c87f1c04a..9dc3b16878d 100644 --- a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py +++ b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseInvoiceAdvance(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.txt b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.txt deleted file mode 100644 index 98c85877550..00000000000 --- a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.txt +++ /dev/null @@ -1,101 +0,0 @@ -[ - { - "creation": "2013-03-08 15:36:46", - "docstatus": 0, - "modified": "2014-02-03 12:38:24", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Purchase Invoice Advance", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Purchase Invoice Advance" - }, - { - "doctype": "DocField", - "fieldname": "journal_voucher", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Journal Voucher", - "no_copy": 1, - "oldfieldname": "journal_voucher", - "oldfieldtype": "Link", - "options": "Journal Voucher", - "print_width": "180px", - "read_only": 1, - "width": "180px" - }, - { - "doctype": "DocField", - "fieldname": "jv_detail_no", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Journal Voucher Detail No", - "no_copy": 1, - "oldfieldname": "jv_detail_no", - "oldfieldtype": "Date", - "print_hide": 1, - "print_width": "80px", - "read_only": 1, - "width": "80px" - }, - { - "doctype": "DocField", - "fieldname": "remarks", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Remarks", - "no_copy": 1, - "oldfieldname": "remarks", - "oldfieldtype": "Small Text", - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "advance_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Advance Amount", - "no_copy": 1, - "oldfieldname": "advance_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_width": "100px", - "read_only": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "allocated_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Allocated Amount", - "no_copy": 1, - "oldfieldname": "allocated_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_width": "100px", - "width": "100px" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json new file mode 100755 index 00000000000..26f3be78894 --- /dev/null +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -0,0 +1,437 @@ +{ + "autoname": "EVD.######", + "creation": "2013-05-22 12:43:10.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 0, + "label": "Item", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_filter": 0, + "in_list_view": 1, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 0, + "width": "300px" + }, + { + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Quantity and Rate", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Qty", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "options": "UOM", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "conversion_factor", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Conversion Factor", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "sec_break1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "discount_percentage", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Discount %", + "permlevel": 0, + "print_hide": 0, + "read_only": 0 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "base_price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "sec_break2", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "rate", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Rate ", + "oldfieldname": "import_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "import_amount", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "base_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Rate (Company Currency)", + "oldfieldname": "rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "base_amount", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Amount (Company Currency)", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "pricing_rule_for_price", + "fieldtype": "Link", + "label": "Pricing Rule For Price", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "pricing_rule_for_discount", + "fieldtype": "Link", + "label": "Pricing Rule For Discount", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "accounting", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Accounting", + "permlevel": 0 + }, + { + "fieldname": "expense_account", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Expense Head", + "oldfieldname": "expense_head", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "print_hide": 1, + "print_width": "120px", + "read_only": 0, + "reqd": 0, + "width": "120px" + }, + { + "fieldname": "col_break5", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": ":Company", + "fieldname": "cost_center", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Cost Center", + "oldfieldname": "cost_center", + "oldfieldtype": "Link", + "options": "Cost Center", + "permlevel": 0, + "print_hide": 1, + "print_width": "120px", + "read_only": 0, + "width": "120px" + }, + { + "fieldname": "reference", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Reference", + "permlevel": 0 + }, + { + "fieldname": "project_name", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 0, + "label": "Project Name", + "options": "Project", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "brand", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Brand", + "oldfieldname": "brand", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "description": "Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges", + "fieldname": "item_tax_rate", + "fieldtype": "Small Text", + "hidden": 1, + "in_list_view": 0, + "label": "Item Tax Rate", + "oldfieldname": "item_tax_rate", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1 + }, + { + "fieldname": "item_tax_amount", + "fieldtype": "Currency", + "hidden": 1, + "in_list_view": 0, + "label": "Item Tax Amount", + "no_copy": 1, + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "search_index": 0, + "width": "150px" + }, + { + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "in_list_view": 0, + "label": "Page Break", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "fieldname": "col_break6", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "purchase_order", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 0, + "label": "Purchase Order", + "no_copy": 1, + "oldfieldname": "purchase_order", + "oldfieldtype": "Link", + "options": "Purchase Order", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "po_detail", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "Purchase Order Item", + "no_copy": 1, + "oldfieldname": "po_detail", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "purchase_receipt", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 0, + "label": "Purchase Receipt", + "no_copy": 1, + "oldfieldname": "purchase_receipt", + "oldfieldtype": "Link", + "options": "Purchase Receipt", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "pr_detail", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "PR Detail", + "no_copy": 1, + "oldfieldname": "pr_detail", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "valuation_rate", + "fieldtype": "Currency", + "hidden": 1, + "in_list_view": 0, + "label": "Valuation Rate", + "no_copy": 1, + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "rm_supp_cost", + "fieldtype": "Currency", + "hidden": 1, + "in_list_view": 0, + "label": "Raw Materials Supplied Cost", + "no_copy": 1, + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-28 11:27:53.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Purchase Invoice Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py index 26c87f1c04a..580d989158d 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseInvoiceItem(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt deleted file mode 100755 index b3562b37478..00000000000 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt +++ /dev/null @@ -1,450 +0,0 @@ -[ - { - "creation": "2013-05-22 12:43:10", - "docstatus": 0, - "modified": "2014-02-28 11:27:53", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "EVD.######", - "doctype": "DocType", - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Purchase Invoice Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Purchase Invoice Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 0, - "label": "Item", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "print_hide": 1, - "read_only": 0, - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_filter": 0, - "in_list_view": 1, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "print_width": "300px", - "read_only": 0, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Quantity and Rate" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Qty", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "print_hide": 0, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "options": "UOM", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "conversion_factor", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Conversion Factor", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "sec_break1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate", - "options": "currency", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "discount_percentage", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Discount %", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "base_price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate (Company Currency)", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "sec_break2", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Rate ", - "oldfieldname": "import_rate", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "import_amount", - "oldfieldtype": "Currency", - "options": "currency", - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break4", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "base_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Rate (Company Currency)", - "oldfieldname": "rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "base_amount", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Amount (Company Currency)", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_price", - "fieldtype": "Link", - "label": "Pricing Rule For Price", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_discount", - "fieldtype": "Link", - "label": "Pricing Rule For Discount", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "accounting", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Accounting" - }, - { - "doctype": "DocField", - "fieldname": "expense_account", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Expense Head", - "oldfieldname": "expense_head", - "oldfieldtype": "Link", - "options": "Account", - "print_hide": 1, - "print_width": "120px", - "read_only": 0, - "reqd": 0, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "col_break5", - "fieldtype": "Column Break" - }, - { - "default": ":Company", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Cost Center", - "oldfieldname": "cost_center", - "oldfieldtype": "Link", - "options": "Cost Center", - "print_hide": 1, - "print_width": "120px", - "read_only": 0, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "reference", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Reference" - }, - { - "doctype": "DocField", - "fieldname": "project_name", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 0, - "label": "Project Name", - "options": "Project", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Brand", - "oldfieldname": "brand", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 0 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "description": "Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges", - "doctype": "DocField", - "fieldname": "item_tax_rate", - "fieldtype": "Small Text", - "hidden": 1, - "in_list_view": 0, - "label": "Item Tax Rate", - "oldfieldname": "item_tax_rate", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_tax_amount", - "fieldtype": "Currency", - "hidden": 1, - "in_list_view": 0, - "label": "Item Tax Amount", - "no_copy": 1, - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "search_index": 0, - "width": "150px" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "page_break", - "fieldtype": "Check", - "in_list_view": 0, - "label": "Page Break", - "no_copy": 1, - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break6", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "purchase_order", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 0, - "label": "Purchase Order", - "no_copy": 1, - "oldfieldname": "purchase_order", - "oldfieldtype": "Link", - "options": "Purchase Order", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "po_detail", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "Purchase Order Item", - "no_copy": 1, - "oldfieldname": "po_detail", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "purchase_receipt", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 0, - "label": "Purchase Receipt", - "no_copy": 1, - "oldfieldname": "purchase_receipt", - "oldfieldtype": "Link", - "options": "Purchase Receipt", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "pr_detail", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "PR Detail", - "no_copy": 1, - "oldfieldname": "pr_detail", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "valuation_rate", - "fieldtype": "Currency", - "hidden": 1, - "in_list_view": 0, - "label": "Valuation Rate", - "no_copy": 1, - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "rm_supp_cost", - "fieldtype": "Currency", - "hidden": 1, - "in_list_view": 0, - "label": "Raw Materials Supplied Cost", - "no_copy": 1, - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json new file mode 100644 index 00000000000..4ec65dbc502 --- /dev/null +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json @@ -0,0 +1,162 @@ +{ + "autoname": "PVTD.######", + "creation": "2013-05-21 16:16:04.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "default": "Valuation and Total", + "fieldname": "category", + "fieldtype": "Select", + "in_list_view": 0, + "label": "Consider Tax or Charge for", + "oldfieldname": "category", + "oldfieldtype": "Select", + "options": "Valuation and Total\nValuation\nTotal", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "default": "Add", + "fieldname": "add_deduct_tax", + "fieldtype": "Select", + "label": "Add or Deduct", + "oldfieldname": "add_deduct_tax", + "oldfieldtype": "Select", + "options": "Add\nDeduct", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "charge_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Type", + "oldfieldname": "charge_type", + "oldfieldtype": "Select", + "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "row_id", + "fieldtype": "Data", + "hidden": 0, + "label": "Enter Row", + "oldfieldname": "row_id", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 0, + "reqd": 1, + "width": "300px" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "account_head", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Account Head", + "oldfieldname": "account_head", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "default": ":Company", + "fieldname": "cost_center", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Cost Center", + "oldfieldname": "cost_center", + "oldfieldtype": "Link", + "options": "Cost Center", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "rate", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "tax_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "tax_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "total", + "fieldtype": "Currency", + "label": "Total", + "oldfieldname": "total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "item_wise_tax_detail", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Item Wise Tax Detail ", + "oldfieldname": "item_wise_tax_detail", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "parenttype", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "label": "Parenttype", + "oldfieldname": "parenttype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "search_index": 0 + } + ], + "hide_heading": 1, + "idx": 1, + "istable": 1, + "modified": "2014-02-03 12:36:04.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Purchase Taxes and Charges", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py index 26c87f1c04a..25dbf9569c9 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseTaxesandCharges(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt deleted file mode 100644 index c5768c66514..00000000000 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt +++ /dev/null @@ -1,175 +0,0 @@ -[ - { - "creation": "2013-05-21 16:16:04", - "docstatus": 0, - "modified": "2014-02-03 12:36:04", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "PVTD.######", - "doctype": "DocType", - "hide_heading": 1, - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Purchase Taxes and Charges", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Purchase Taxes and Charges" - }, - { - "default": "Valuation and Total", - "doctype": "DocField", - "fieldname": "category", - "fieldtype": "Select", - "in_list_view": 0, - "label": "Consider Tax or Charge for", - "oldfieldname": "category", - "oldfieldtype": "Select", - "options": "Valuation and Total\nValuation\nTotal", - "read_only": 0, - "reqd": 1 - }, - { - "default": "Add", - "doctype": "DocField", - "fieldname": "add_deduct_tax", - "fieldtype": "Select", - "label": "Add or Deduct", - "oldfieldname": "add_deduct_tax", - "oldfieldtype": "Select", - "options": "Add\nDeduct", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "charge_type", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Type", - "oldfieldname": "charge_type", - "oldfieldtype": "Select", - "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "row_id", - "fieldtype": "Data", - "hidden": 0, - "label": "Enter Row", - "oldfieldname": "row_id", - "oldfieldtype": "Data", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "print_width": "300px", - "read_only": 0, - "reqd": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "account_head", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Account Head", - "oldfieldname": "account_head", - "oldfieldtype": "Link", - "options": "Account", - "read_only": 0, - "reqd": 1 - }, - { - "default": ":Company", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Cost Center", - "oldfieldname": "cost_center", - "oldfieldtype": "Link", - "options": "Cost Center", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "rate", - "oldfieldtype": "Currency", - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "tax_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "tax_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "total", - "fieldtype": "Currency", - "label": "Total", - "oldfieldname": "total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_wise_tax_detail", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Item Wise Tax Detail ", - "oldfieldname": "item_wise_tax_detail", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "parenttype", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "label": "Parenttype", - "oldfieldname": "parenttype", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 0, - "search_index": 0 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js index 2027a7b33aa..bc0a912bd69 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js @@ -41,7 +41,7 @@ cur_frm.pformat.other_charges= function(doc) { return doc_field.print_hide; } - var cl = getchildren('Purchase Taxes and Charges', doc.name, 'other_charges'); + var cl = doc.other_charges || []; // outer table var out='
\ diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.json b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.json new file mode 100644 index 00000000000..dd7c8e41e1d --- /dev/null +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.json @@ -0,0 +1,83 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:title", + "creation": "2013-01-10 16:34:08.000000", + "description": "Standard tax template that can be applied to all Purchase Transactions. This template can contain list of tax heads and also other expense heads like \"Shipping\", \"Insurance\", \"Handling\" etc.\n\n#### Note\n\nThe tax rate you define here will be the standard tax rate for all **Items**. If there are **Items** that have different rates, they must be added in the **Item Tax** table in the **Item** master.\n\n#### Description of Columns\n\n1. Calculation Type: \n - This can be on **Net Total** (that is the sum of basic amount).\n - **On Previous Row Total / Amount** (for cumulative taxes or charges). If you select this option, the tax will be applied as a percentage of the previous row (in the tax table) amount or total.\n - **Actual** (as mentioned).\n2. Account Head: The Account ledger under which this tax will be booked\n3. Cost Center: If the tax / charge is an income (like shipping) or expense it needs to be booked against a Cost Center.\n4. Description: Description of the tax (that will be printed in invoices / quotes).\n5. Rate: Tax rate.\n6. Amount: Tax amount.\n7. Total: Cumulative total to this point.\n8. Enter Row: If based on \"Previous Row Total\" you can select the row number which will be taken as a base for this calculation (default is the previous row).\n9. Consider Tax or Charge for: In this section you can specify if the tax / charge is only for valuation (not a part of total) or only for total (does not add value to the item) or for both.\n10. Add or Deduct: Whether you want to add or deduct the tax.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "title", + "fieldtype": "Data", + "in_filter": 1, + "label": "Title", + "oldfieldname": "title", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "is_default", + "fieldtype": "Check", + "label": "Default", + "permlevel": 0 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "options": "Company", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "other_charges", + "fieldtype": "Table", + "label": "Purchase Taxes and Charges", + "oldfieldname": "purchase_tax_details", + "oldfieldtype": "Table", + "options": "Purchase Taxes and Charges", + "permlevel": 0 + } + ], + "icon": "icon-money", + "idx": 1, + "modified": "2014-01-29 12:26:38.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Purchase Taxes and Charges Master", + "owner": "wasim@webnotestech.com", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Manager", + "submit": 0, + "write": 0 + }, + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Master Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py index eee6e9ac8c3..e93c57263f3 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py @@ -3,15 +3,7 @@ from __future__ import unicode_literals import frappe +from frappe.model.document import Document -from frappe.model import db_exists -from frappe.model.bean import copy_doclist -from frappe.model.code import get_obj - - - - -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist \ No newline at end of file +class PurchaseTaxesandChargesMaster(Document): + pass diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt deleted file mode 100644 index 346dd0e284b..00000000000 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt +++ /dev/null @@ -1,96 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:08", - "docstatus": 0, - "modified": "2014-01-29 12:26:38", - "modified_by": "Administrator", - "owner": "wasim@webnotestech.com" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:title", - "description": "Standard tax template that can be applied to all Purchase Transactions. This template can contain list of tax heads and also other expense heads like \"Shipping\", \"Insurance\", \"Handling\" etc.\n\n#### Note\n\nThe tax rate you define here will be the standard tax rate for all **Items**. If there are **Items** that have different rates, they must be added in the **Item Tax** table in the **Item** master.\n\n#### Description of Columns\n\n1. Calculation Type: \n - This can be on **Net Total** (that is the sum of basic amount).\n - **On Previous Row Total / Amount** (for cumulative taxes or charges). If you select this option, the tax will be applied as a percentage of the previous row (in the tax table) amount or total.\n - **Actual** (as mentioned).\n2. Account Head: The Account ledger under which this tax will be booked\n3. Cost Center: If the tax / charge is an income (like shipping) or expense it needs to be booked against a Cost Center.\n4. Description: Description of the tax (that will be printed in invoices / quotes).\n5. Rate: Tax rate.\n6. Amount: Tax amount.\n7. Total: Cumulative total to this point.\n8. Enter Row: If based on \"Previous Row Total\" you can select the row number which will be taken as a base for this calculation (default is the previous row).\n9. Consider Tax or Charge for: In this section you can specify if the tax / charge is only for valuation (not a part of total) or only for total (does not add value to the item) or for both.\n10. Add or Deduct: Whether you want to add or deduct the tax.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-money", - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Purchase Taxes and Charges Master", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Purchase Taxes and Charges Master", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Purchase Taxes and Charges Master" - }, - { - "doctype": "DocField", - "fieldname": "title", - "fieldtype": "Data", - "in_filter": 1, - "label": "Title", - "oldfieldname": "title", - "oldfieldtype": "Data", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "is_default", - "fieldtype": "Check", - "label": "Default" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "options": "Company", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "other_charges", - "fieldtype": "Table", - "label": "Purchase Taxes and Charges", - "oldfieldname": "purchase_tax_details", - "oldfieldtype": "Table", - "options": "Purchase Taxes and Charges" - }, - { - "amend": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase Manager", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Purchase Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice/pos.js b/erpnext/accounts/doctype/sales_invoice/pos.js index fc6190ae7ac..ff996cc1079 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.js +++ b/erpnext/accounts/doctype/sales_invoice/pos.js @@ -293,8 +293,7 @@ erpnext.POS = Class.extend({ // check whether the item is already added if (no_of_items != 0) { - $.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, - this.frm.cscript.fname, this.frm.doctype), function(i, d) { + $.each(this.frm.doc[this.frm.cscript.fname] || [], function(i, d) { if (d.item_code == item_code) { caught = true; if (serial_no) @@ -335,8 +334,7 @@ erpnext.POS = Class.extend({ }, update_qty: function(item_code, qty) { var me = this; - $.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, - this.frm.cscript.fname, this.frm.doctype), function(i, d) { + $.each(this.frm.doc[this.frm.cscript.fname] || [], function(i, d) { if (d.item_code == item_code) { if (qty == 0) { frappe.model.clear_doc(d.doctype, d.name); @@ -387,8 +385,7 @@ erpnext.POS = Class.extend({ var me = this; var $items = this.wrapper.find("#cart tbody").empty(); - $.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, - this.frm.cscript.fname, this.frm.doctype), function(i, d) { + $.each(this.frm.doc[this.frm.cscript.fname] || [], function(i, d) { $(repl('\ \ @@ -422,8 +419,7 @@ erpnext.POS = Class.extend({ }, show_taxes: function() { var me = this; - var taxes = frappe.model.get_children(this.sales_or_purchase + " Taxes and Charges", - this.frm.doc.name, this.frm.cscript.other_fname, this.frm.doctype); + var taxes = this.frm.doc[this.frm.cscript.other_fname] || []; $(this.wrapper).find(".tax-table") .toggle((taxes && taxes.length) ? true : false) .find("tbody").empty(); @@ -544,8 +540,7 @@ erpnext.POS = Class.extend({ } } - var child = frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, - this.frm.cscript.fname, this.frm.doctype); + var child = this.frm.doc[this.frm.cscript.fname] || []; $.each(child, function(i, d) { for (var i in selected_items) { diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 42cf8239b24..a87677604ea 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -68,7 +68,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte if(cint(doc.update_stock)!=1) { // show Make Delivery Note button only if Sales Invoice is not created from Delivery Note var from_delivery_note = false; - from_delivery_note = cur_frm.get_doclist({parentfield: "entries"}) + from_delivery_note = cur_frm.doc.entries .some(function(item) { return item.delivery_note ? true : false; }); @@ -199,7 +199,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }, entries_add: function(doc, cdt, cdn) { - var row = frappe.model.get_doc(cdt, cdn); + var row = frappe.get_doc(cdt, cdn); this.frm.script_manager.copy_from_first_row("entries", row, ["income_account", "cost_center"]); }, @@ -245,8 +245,7 @@ cur_frm.cscript.hide_fields = function(doc) { (cint(doc.update_stock)==1 ? true : false)); // India related fields - var cp = frappe.control_panel; - if (cp.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']); + if (frappe.boot.sysdefaults.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']); else hide_field(['c_form_applicable', 'c_form_no']); cur_frm.refresh_fields(); diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json new file mode 100644 index 00000000000..09c4fb1c728 --- /dev/null +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -0,0 +1,1228 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-05-24 19:29:05.000000", + "default_print_format": "Standard", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "fieldname": "customer_section", + "fieldtype": "Section Break", + "label": "Customer", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "INV\nINV/10-11/", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "hidden": 0, + "label": "Customer", + "no_copy": 0, + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "customer", + "fieldname": "customer_name", + "fieldtype": "Data", + "hidden": 0, + "in_list_view": 1, + "label": "Name", + "oldfieldname": "customer_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_mobile", + "fieldtype": "Text", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_email", + "fieldtype": "Text", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "is_pos", + "fieldtype": "Check", + "label": "Is POS", + "oldfieldname": "is_pos", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Link", + "options": "Sales Invoice", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "default": "Today", + "fieldname": "posting_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Posting Date", + "no_copy": 1, + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "due_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Payment Due Date", + "no_copy": 1, + "oldfieldname": "due_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "mode_of_payment", + "fieldtype": "Select", + "label": "Mode of Payment", + "no_copy": 0, + "oldfieldname": "mode_of_payment", + "oldfieldtype": "Select", + "options": "link:Mode of Payment", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "currency_section", + "fieldtype": "Section Break", + "label": "Currency and Price List", + "options": "icon-tag", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "description": "Rate at which Customer Currency is converted to customer's base currency", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "label": "Exchange Rate", + "oldfieldname": "conversion_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "selling_price_list", + "fieldtype": "Link", + "label": "Price List", + "oldfieldname": "price_list_name", + "oldfieldtype": "Select", + "options": "Price List", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "price_list_currency", + "fieldtype": "Link", + "label": "Price List Currency", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "description": "Rate at which Price list currency is converted to customer's base currency", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "label": "Price List Exchange Rate", + "no_copy": 0, + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "items", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "update_stock", + "fieldtype": "Check", + "label": "Update Stock", + "oldfieldname": "update_stock", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "entries", + "fieldtype": "Table", + "label": "Sales Invoice Items", + "oldfieldname": "entries", + "oldfieldtype": "Table", + "options": "Sales Invoice Item", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "packing_list", + "fieldtype": "Section Break", + "label": "Packing List", + "options": "icon-suitcase", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "packing_details", + "fieldtype": "Table", + "label": "Packing Details", + "options": "Packed Item", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "sales_bom_help", + "fieldtype": "HTML", + "label": "Sales BOM Help", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break_30", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "net_total_export", + "fieldtype": "Currency", + "label": "Net Total", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "column_break_32", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total (Company Currency)", + "oldfieldname": "net_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "taxes", + "fieldtype": "Section Break", + "label": "Taxes and Charges", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "oldfieldname": "charge", + "oldfieldtype": "Link", + "options": "Sales Taxes and Charges Master", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break_38", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "shipping_rule", + "fieldtype": "Link", + "label": "Shipping Rule", + "oldfieldtype": "Button", + "options": "Shipping Rule", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break_40", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "other_charges", + "fieldtype": "Table", + "label": "Sales Taxes and Charges", + "oldfieldname": "other_charges", + "oldfieldtype": "Table", + "options": "Sales Taxes and Charges", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "other_charges_calculation", + "fieldtype": "HTML", + "label": "Taxes and Charges Calculation", + "oldfieldtype": "HTML", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break_43", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "other_charges_total_export", + "fieldtype": "Currency", + "label": "Total Taxes and Charges", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_45", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "other_charges_total", + "fieldtype": "Currency", + "label": "Total Taxes and Charges (Company Currency)", + "oldfieldname": "other_charges_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 0 + }, + { + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "Totals", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "grand_total_export", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Grand Total", + "oldfieldname": "grand_total_export", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "rounded_total_export", + "fieldtype": "Currency", + "label": "Rounded Total", + "oldfieldname": "rounded_total_export", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "in_words_export", + "fieldtype": "Data", + "label": "In Words", + "oldfieldname": "in_words_export", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "gross_profit", + "fieldtype": "Currency", + "label": "Gross Profit", + "oldfieldname": "gross_profit", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "gross_profit_percent", + "fieldtype": "Float", + "label": "Gross Profit (%)", + "oldfieldname": "gross_profit_percent", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break5", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "grand_total", + "fieldtype": "Currency", + "in_filter": 1, + "label": "Grand Total (Company Currency)", + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total (Company Currency)", + "oldfieldname": "rounded_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "In Words will be visible once you save the Sales Invoice.", + "fieldname": "in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "total_advance", + "fieldtype": "Currency", + "label": "Total Advance", + "oldfieldname": "total_advance", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "outstanding_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Outstanding Amount", + "no_copy": 1, + "oldfieldname": "outstanding_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "advances", + "fieldtype": "Section Break", + "label": "Advances", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "get_advances_received", + "fieldtype": "Button", + "label": "Get Advances Received", + "oldfieldtype": "Button", + "options": "get_advances", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "advance_adjustment_details", + "fieldtype": "Table", + "label": "Sales Invoice Advance", + "oldfieldname": "advance_adjustment_details", + "oldfieldtype": "Table", + "options": "Sales Invoice Advance", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "is_pos", + "fieldname": "payments_section", + "fieldtype": "Section Break", + "label": "Payments", + "options": "icon-money", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "is_pos", + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "depends_on": "is_pos", + "fieldname": "paid_amount", + "fieldtype": "Currency", + "label": "Paid Amount", + "oldfieldname": "paid_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "is_pos", + "fieldname": "cash_bank_account", + "fieldtype": "Link", + "label": "Cash/Bank Account", + "oldfieldname": "cash_bank_account", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "is_pos", + "fieldname": "column_break4", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "depends_on": "is_pos", + "fieldname": "write_off_outstanding_amount_automatically", + "fieldtype": "Check", + "label": "Write Off Outstanding Amount", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "is_pos", + "fieldname": "write_off_amount", + "fieldtype": "Currency", + "label": "Write Off Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "is_pos", + "fieldname": "write_off_account", + "fieldtype": "Link", + "label": "Write Off Account", + "options": "Account", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "is_pos", + "fieldname": "write_off_cost_center", + "fieldtype": "Link", + "label": "Write Off Cost Center", + "options": "Cost Center", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "oldfieldtype": "Section Break", + "options": "icon-legal", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Terms and Conditions Details", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "customer", + "fieldname": "contact_section", + "fieldtype": "Section Break", + "hidden": 0, + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "in_filter": 1, + "label": "Territory", + "options": "Territory", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "description": "Add / Edit", + "fieldname": "customer_group", + "fieldtype": "Link", + "in_filter": 1, + "label": "Customer Group", + "options": "Customer Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "search_index": 0 + }, + { + "fieldname": "col_break23", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "customer_address", + "fieldtype": "Link", + "label": "Customer Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "contact_person", + "fieldtype": "Link", + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "description": "Customer (Receivable) Account", + "fieldname": "debit_to", + "fieldtype": "Link", + "in_filter": 1, + "label": "Debit To", + "oldfieldname": "debit_to", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "project_name", + "fieldtype": "Link", + "in_filter": 1, + "label": "Project Name", + "oldfieldname": "project_name", + "oldfieldtype": "Link", + "options": "Project", + "permlevel": 0, + "read_only": 0, + "search_index": 1 + }, + { + "depends_on": "eval:doc.source == 'Campaign'", + "fieldname": "campaign", + "fieldtype": "Link", + "label": "Campaign", + "oldfieldname": "campaign", + "oldfieldtype": "Link", + "options": "Campaign", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "source", + "fieldtype": "Select", + "label": "Source", + "oldfieldname": "source", + "oldfieldtype": "Select", + "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "default": "No", + "description": "Considered as an Opening Balance", + "fieldname": "is_opening", + "fieldtype": "Select", + "in_filter": 1, + "label": "Is Opening Entry", + "oldfieldname": "is_opening", + "oldfieldtype": "Select", + "options": "No\nYes", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "search_index": 0 + }, + { + "fieldname": "c_form_applicable", + "fieldtype": "Select", + "label": "C-Form Applicable", + "no_copy": 1, + "options": "No\nYes", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0 + }, + { + "fieldname": "c_form_no", + "fieldtype": "Link", + "label": "C-Form No", + "no_copy": 1, + "options": "C-Form", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break8", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Select", + "label": "Letter Head", + "oldfieldname": "letter_head", + "oldfieldtype": "Select", + "options": "link:Letter Head", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "fieldname": "posting_time", + "fieldtype": "Time", + "label": "Posting Time", + "no_copy": 1, + "oldfieldname": "posting_time", + "oldfieldtype": "Time", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "description": "Actual Invoice Date", + "fieldname": "aging_date", + "fieldtype": "Date", + "label": "Aging Date", + "oldfieldname": "aging_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "no_copy": 0, + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "remarks", + "fieldtype": "Small Text", + "label": "Remarks", + "no_copy": 1, + "oldfieldname": "remarks", + "oldfieldtype": "Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "sales_team_section_break", + "fieldtype": "Section Break", + "label": "Sales Team", + "oldfieldtype": "Section Break", + "options": "icon-group", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break9", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "sales_partner", + "fieldtype": "Link", + "in_filter": 1, + "label": "Sales Partner", + "oldfieldname": "sales_partner", + "oldfieldtype": "Link", + "options": "Sales Partner", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break10", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "commission_rate", + "fieldtype": "Float", + "label": "Commission Rate (%)", + "oldfieldname": "commission_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "total_commission", + "fieldtype": "Currency", + "label": "Total Commission", + "oldfieldname": "total_commission", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break2", + "fieldtype": "Section Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "sales_team", + "fieldtype": "Table", + "label": "Sales Team1", + "oldfieldname": "sales_team", + "oldfieldtype": "Table", + "options": "Sales Team", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "eval:doc.docstatus<2", + "fieldname": "recurring_invoice", + "fieldtype": "Section Break", + "label": "Recurring Invoice", + "options": "icon-time", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break11", + "fieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "50%" + }, + { + "allow_on_submit": 1, + "depends_on": "eval:doc.docstatus<2", + "description": "Check if recurring invoice, uncheck to stop recurring or put proper End Date", + "fieldname": "convert_into_recurring_invoice", + "fieldtype": "Check", + "label": "Convert into Recurring Invoice", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "depends_on": "eval:doc.convert_into_recurring_invoice==1", + "description": "Select the period when the invoice will be generated automatically", + "fieldname": "recurring_type", + "fieldtype": "Select", + "label": "Recurring Type", + "no_copy": 1, + "options": "\nMonthly\nQuarterly\nHalf-yearly\nYearly", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "depends_on": "eval:doc.convert_into_recurring_invoice==1", + "description": "The day of the month on which auto invoice will be generated e.g. 05, 28 etc ", + "fieldname": "repeat_on_day_of_month", + "fieldtype": "Int", + "label": "Repeat on Day of Month", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "depends_on": "eval:doc.convert_into_recurring_invoice==1", + "description": "Start date of current invoice's period", + "fieldname": "invoice_period_from_date", + "fieldtype": "Date", + "label": "Invoice Period From Date", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "depends_on": "eval:doc.convert_into_recurring_invoice==1", + "description": "End date of current invoice's period", + "fieldname": "invoice_period_to_date", + "fieldtype": "Date", + "label": "Invoice Period To Date", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break12", + "fieldtype": "Column Break", + "no_copy": 0, + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "50%" + }, + { + "allow_on_submit": 1, + "depends_on": "eval:doc.convert_into_recurring_invoice==1", + "description": "Enter email id separated by commas, invoice will be mailed automatically on particular date", + "fieldname": "notification_email_address", + "fieldtype": "Small Text", + "label": "Notification Email Address", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "eval:doc.convert_into_recurring_invoice==1", + "description": "The unique id for tracking all recurring invoices.\u00a0It is generated on submit.", + "fieldname": "recurring_id", + "fieldtype": "Data", + "label": "Recurring Id", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "depends_on": "eval:doc.convert_into_recurring_invoice==1", + "description": "The date on which next invoice will be generated. It is generated on submit.\n", + "fieldname": "next_date", + "fieldtype": "Date", + "label": "Next Date", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "allow_on_submit": 1, + "depends_on": "eval:doc.convert_into_recurring_invoice==1", + "description": "The date on which recurring invoice will be stop", + "fieldname": "end_date", + "fieldtype": "Date", + "label": "End Date", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "against_income_account", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Against Income Account", + "no_copy": 1, + "oldfieldname": "against_income_account", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + } + ], + "icon": "icon-file-text", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-28 18:43:10.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Invoice", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 1, + "write": 1 + }, + { + "cancel": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Customer" + } + ], + "read_only_onload": 1, + "search_fields": "posting_date, due_date, debit_to, fiscal_year, grand_total, outstanding_amount" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index e021485c61c..fb36484c71c 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -6,26 +6,23 @@ import frappe import frappe.defaults from frappe.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, \ - get_first_day, get_last_day - -from frappe.utils import comma_and -from frappe.model.doc import make_autoname -from frappe.model.bean import getlist -from frappe.model.code import get_obj + get_first_day, get_last_day, comma_and +from frappe.model.naming import make_autoname from frappe import _, msgprint from erpnext.accounts.party import get_party_account, get_due_date +from erpnext.controllers.stock_controller import update_gl_entries_after month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12} from erpnext.controllers.selling_controller import SellingController -class DocType(SellingController): - def __init__(self,d,dl): - self.doc, self.doclist = d, dl - self.log = [] - self.tname = 'Sales Invoice Item' - self.fname = 'entries' +class SalesInvoice(SellingController): + tname = 'Sales Invoice Item' + fname = 'entries' + + def __init__(self, arg1, arg2=None): + super(SalesInvoice, self).__init__(arg1, arg2) self.status_updater = [{ 'source_dt': 'Sales Invoice Item', 'target_field': 'billed_amt', @@ -40,10 +37,9 @@ class DocType(SellingController): 'status_field': 'billing_status', 'keyword': 'Billed' }] - def validate(self): - super(DocType, self).validate() + super(SalesInvoice, self).validate() self.validate_posting_time() self.so_dn_required() self.validate_proj_cust() @@ -56,72 +52,72 @@ class DocType(SellingController): self.clear_unallocated_advances("Sales Invoice Advance", "advance_adjustment_details") self.add_remarks() - if cint(self.doc.is_pos): + if cint(self.is_pos): self.validate_pos() self.validate_write_off_account() - if cint(self.doc.update_stock): + if cint(self.update_stock): self.validate_item_code() self.update_current_stock() self.validate_delivery_note() - if not self.doc.is_opening: - self.doc.is_opening = 'No' + if not self.is_opening: + self.is_opening = 'No' self.set_aging_date() self.set_against_income_account() self.validate_c_form() self.validate_time_logs_are_submitted() self.validate_recurring_invoice() - self.validate_multiple_billing("Delivery Note", "dn_detail", "amount", + self.validate_multiple_billing("Delivery Note", "dn_detail", "amount", "delivery_note_details") def on_submit(self): - if cint(self.doc.update_stock) == 1: + if cint(self.update_stock) == 1: self.update_stock_ledger() else: # Check for Approving Authority - if not self.doc.recurring_id: - get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, - self.doc.company, self.doc.grand_total, self) - + if not self.recurring_id: + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, + self.company, self.grand_total, self) + self.check_prev_docstatus() - + self.update_status_updater_args() self.update_prevdoc_status() self.update_billing_status_for_zero_amount_refdoc("Sales Order") - + # this sequence because outstanding may get -ve self.make_gl_entries() - self.check_credit_limit(self.doc.debit_to) + self.check_credit_limit(self.debit_to) - if not cint(self.doc.is_pos) == 1: + if not cint(self.is_pos) == 1: self.update_against_document_in_jv() self.update_c_form() - self.update_time_log_batch(self.doc.name) + self.update_time_log_batch(self.name) self.convert_to_recurring() def before_cancel(self): self.update_time_log_batch(None) def on_cancel(self): - if cint(self.doc.update_stock) == 1: + if cint(self.update_stock) == 1: self.update_stock_ledger() - + self.check_stop_sales_order("sales_order") - + from erpnext.accounts.utils import remove_against_link_from_jv - remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_invoice") + remove_against_link_from_jv(self.doctype, self.name, "against_invoice") self.update_status_updater_args() self.update_prevdoc_status() self.update_billing_status_for_zero_amount_refdoc("Sales Order") - + self.make_cancel_gl_entries() - + def update_status_updater_args(self): - if cint(self.doc.update_stock): + if cint(self.update_stock): self.status_updater.append({ 'source_dt':'Sales Invoice Item', 'target_dt':'Sales Order Item', @@ -138,34 +134,34 @@ class DocType(SellingController): 'second_source_field': 'qty', 'second_join_field': 'prevdoc_detail_docname' }) - + def on_update_after_submit(self): self.validate_recurring_invoice() self.convert_to_recurring() - + def get_portal_page(self): - return "invoice" if self.doc.docstatus==1 else None - + return "invoice" if self.docstatus==1 else None + def set_missing_values(self, for_validate=False): self.set_pos_fields(for_validate) - - if not self.doc.debit_to: - self.doc.debit_to = get_party_account(self.doc.company, self.doc.customer, "Customer") - if not self.doc.due_date: - self.doc.due_date = get_due_date(self.doc.posting_date, self.doc.customer, "Customer", - self.doc.debit_to, self.doc.company) - - super(DocType, self).set_missing_values(for_validate) - + + if not self.debit_to: + self.debit_to = get_party_account(self.company, self.customer, "Customer") + if not self.due_date: + self.due_date = get_due_date(self.posting_date, self.customer, "Customer", + self.debit_to, self.company) + + super(SalesInvoice, self).set_missing_values(for_validate) + def update_time_log_batch(self, sales_invoice): - for d in self.doclist.get({"doctype":"Sales Invoice Item"}): + for d in self.get(self.fname): if d.time_log_batch: - tlb = frappe.bean("Time Log Batch", d.time_log_batch) - tlb.doc.sales_invoice = sales_invoice - tlb.update_after_submit() + tlb = frappe.get_doc("Time Log Batch", d.time_log_batch) + tlb.sales_invoice = sales_invoice + tlb.save() def validate_time_logs_are_submitted(self): - for d in self.doclist.get({"doctype":"Sales Invoice Item"}): + for d in self.get(self.fname): if d.time_log_batch: status = frappe.db.get_value("Time Log Batch", d.time_log_batch, "status") if status!="Submitted": @@ -174,48 +170,48 @@ class DocType(SellingController): def set_pos_fields(self, for_validate=False): """Set retail related fields from pos settings""" - if cint(self.doc.is_pos) != 1: + if cint(self.is_pos) != 1: return - - from erpnext.stock.get_item_details import get_pos_settings_item_details, get_pos_settings - pos = get_pos_settings(self.doc.company) - + + from erpnext.stock.get_item_details import get_pos_settings_item_details, get_pos_settings + pos = get_pos_settings(self.company) + if pos: - if not for_validate and not self.doc.customer: - self.doc.customer = pos.customer + if not for_validate and not self.customer: + self.customer = pos.customer # self.set_customer_defaults() for fieldname in ('territory', 'naming_series', 'currency', 'taxes_and_charges', 'letter_head', 'tc_name', 'selling_price_list', 'company', 'select_print_heading', 'cash_bank_account'): - if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)): - self.doc.fields[fieldname] = pos.get(fieldname) - + if (not for_validate) or (for_validate and not self.get(fieldname)): + self.set(fieldname, pos.get(fieldname)) + if not for_validate: - self.doc.update_stock = cint(pos.get("update_stock")) + self.update_stock = cint(pos.get("update_stock")) # set pos values in items - for item in self.doclist.get({"parentfield": "entries"}): - if item.fields.get('item_code'): - for fname, val in get_pos_settings_item_details(pos, - frappe._dict(item.fields), pos).items(): - - if (not for_validate) or (for_validate and not item.fields.get(fname)): - item.fields[fname] = val + for item in self.get("entries"): + if item.get('item_code'): + for fname, val in get_pos_settings_item_details(pos, + frappe._dict(item.as_dict()), pos).items(): + + if (not for_validate) or (for_validate and not item.get(fname)): + item.set(fname, val) + + # fetch terms + if self.tc_name and not self.terms: + self.terms = frappe.db.get_value("Terms and Conditions", self.tc_name, "terms") - # fetch terms - if self.doc.tc_name and not self.doc.terms: - self.doc.terms = frappe.db.get_value("Terms and Conditions", self.doc.tc_name, "terms") - # fetch charges - if self.doc.charge and not len(self.doclist.get({"parentfield": "other_charges"})): + if self.taxes_and_charges and not len(self.get("other_charges")): self.set_taxes("other_charges", "taxes_and_charges") - + def get_advances(self): - super(DocType, self).get_advances(self.doc.debit_to, + super(SalesInvoice, self).get_advances(self.debit_to, "Sales Invoice Advance", "advance_adjustment_details", "credit") - + def get_company_abbr(self): - return frappe.db.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0] + return frappe.db.sql("select abbr from tabCompany where name=%s", self.company)[0][0] def update_against_document_in_jv(self): """ @@ -224,57 +220,57 @@ class DocType(SellingController): 2. split into multiple rows if partially adjusted, assign against voucher 3. submit advance voucher """ - + lst = [] - for d in getlist(self.doclist, 'advance_adjustment_details'): + for d in self.get('advance_adjustment_details'): if flt(d.allocated_amount) > 0: args = { - 'voucher_no' : d.journal_voucher, - 'voucher_detail_no' : d.jv_detail_no, - 'against_voucher_type' : 'Sales Invoice', - 'against_voucher' : self.doc.name, - 'account' : self.doc.debit_to, - 'is_advance' : 'Yes', - 'dr_or_cr' : 'credit', + 'voucher_no' : d.journal_voucher, + 'voucher_detail_no' : d.jv_detail_no, + 'against_voucher_type' : 'Sales Invoice', + 'against_voucher' : self.name, + 'account' : self.debit_to, + 'is_advance' : 'Yes', + 'dr_or_cr' : 'credit', 'unadjusted_amt' : flt(d.advance_amount), 'allocated_amt' : flt(d.allocated_amount) } lst.append(args) - + if lst: from erpnext.accounts.utils import reconcile_against_document reconcile_against_document(lst) - + def validate_customer_account(self): """Validates Debit To Account and Customer Matches""" - if self.doc.customer and self.doc.debit_to and not cint(self.doc.is_pos): - acc_head = frappe.db.sql("select master_name from `tabAccount` where name = %s and docstatus != 2", self.doc.debit_to) - - if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.customer)) or \ - (not acc_head and (self.doc.debit_to != cstr(self.doc.customer) + " - " + self.get_company_abbr())): + if self.customer and self.debit_to and not cint(self.is_pos): + acc_head = frappe.db.sql("select master_name from `tabAccount` where name = %s and docstatus != 2", self.debit_to) + + if (acc_head and cstr(acc_head[0][0]) != cstr(self.customer)) or \ + (not acc_head and (self.debit_to != cstr(self.customer) + " - " + self.get_company_abbr())): msgprint("Debit To: %s do not match with Customer: %s for Company: %s.\n If both correctly entered, please select Master Type \ - and Master Name in account master." %(self.doc.debit_to, self.doc.customer,self.doc.company), raise_exception=1) + and Master Name in account master." %(self.debit_to, self.customer,self.company), raise_exception=1) def validate_debit_acc(self): - if frappe.db.get_value("Account", self.doc.debit_to, "report_type") != "Balance Sheet": + if frappe.db.get_value("Account", self.debit_to, "report_type") != "Balance Sheet": frappe.throw(_("Account must be a balance sheet account")) - + def validate_fixed_asset_account(self): """Validate Fixed Asset and whether Income Account Entered Exists""" - for d in getlist(self.doclist,'entries'): - item = frappe.db.sql("""select name,is_asset_item,is_sales_item from `tabItem` - where name = %s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' + for d in self.get('entries'): + item = frappe.db.sql("""select name,is_asset_item,is_sales_item from `tabItem` + where name = %s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())""", d.item_code) - acc = frappe.db.sql("""select account_type from `tabAccount` + acc = frappe.db.sql("""select account_type from `tabAccount` where name = %s and docstatus != 2""", d.income_account) if not acc: msgprint("Account: "+d.income_account+" does not exist in the system", raise_exception=True) elif item and item[0][1] == 'Yes' and not acc[0][0] == 'Fixed Asset': - msgprint("Please select income head with account type 'Fixed Asset' as Item %s is an asset item" % d.item_code, raise_exception=True) - + msgprint("Please select income head with account type 'Fixed Asset' as Item %s is an asset item" % d.item_code, raise_exception=True) + def validate_with_previous_doc(self): - super(DocType, self).validate_with_previous_doc(self.tname, { + super(SalesInvoice, self).validate_with_previous_doc(self.tname, { "Sales Order": { "ref_dn_field": "sales_order", "compare_fields": [["customer", "="], ["company", "="], ["project_name", "="], @@ -286,9 +282,9 @@ class DocType(SellingController): ["currency", "="]], }, }) - + if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')): - super(DocType, self).validate_with_previous_doc(self.tname, { + super(SalesInvoice, self).validate_with_previous_doc(self.tname, { "Sales Order Item": { "ref_dn_field": "so_detail", "compare_fields": [["rate", "="]], @@ -301,27 +297,27 @@ class DocType(SellingController): "is_child_table": True } }) - + def set_aging_date(self): - if self.doc.is_opening != 'Yes': - self.doc.aging_date = self.doc.posting_date - elif not self.doc.aging_date: + if self.is_opening != 'Yes': + self.aging_date = self.posting_date + elif not self.aging_date: msgprint("Aging Date is mandatory for opening entry") raise Exception - + def set_against_income_account(self): """Set against account for debit to account""" against_acc = [] - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.income_account not in against_acc: against_acc.append(d.income_account) - self.doc.against_income_account = ','.join(against_acc) + self.against_income_account = ','.join(against_acc) def add_remarks(self): - if not self.doc.remarks: self.doc.remarks = 'No Remarks' + if not self.remarks: self.remarks = 'No Remarks' def so_dn_required(self): @@ -329,77 +325,77 @@ class DocType(SellingController): dic = {'Sales Order':'so_required','Delivery Note':'dn_required'} for i in dic: if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes': - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if frappe.db.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \ - and not d.fields[i.lower().replace(' ','_')]: + and not d.get(i.lower().replace(' ','_')): msgprint("%s is mandatory for stock item which is not mentioed against item: %s"%(i,d.item_code), raise_exception=1) def validate_proj_cust(self): """check for does customer belong to same project as entered..""" - if self.doc.project_name and self.doc.customer: - res = frappe.db.sql("""select name from `tabProject` - where name = %s and (customer = %s or - ifnull(customer,'')='')""", (self.doc.project_name, self.doc.customer)) + if self.project_name and self.customer: + res = frappe.db.sql("""select name from `tabProject` + where name = %s and (customer = %s or + ifnull(customer,'')='')""", (self.project_name, self.customer)) if not res: - msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in that project."%(self.doc.customer,self.doc.project_name)) + msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in that project."%(self.customer,self.project_name)) raise Exception def validate_pos(self): - if not self.doc.cash_bank_account and flt(self.doc.paid_amount): + if not self.cash_bank_account and flt(self.paid_amount): msgprint("Cash/Bank Account is mandatory for POS, for making payment entry") raise Exception - if flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) \ - - flt(self.doc.grand_total) > 1/(10**(self.precision("grand_total") + 1)): + if flt(self.paid_amount) + flt(self.write_off_amount) \ + - flt(self.grand_total) > 1/(10**(self.precision("grand_total") + 1)): frappe.throw(_("""(Paid amount + Write Off Amount) can not be \ greater than Grand Total""")) def validate_item_code(self): - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if not d.item_code: msgprint("Please enter Item Code at line no : %s to update stock or remove check from Update Stock in Basic Info Tab." % (d.idx), raise_exception=True) - + def validate_delivery_note(self): - for d in self.doclist.get({"parentfield": "entries"}): + for d in self.get("entries"): if d.delivery_note: msgprint("""Stock update can not be made against Delivery Note""", raise_exception=1) def validate_write_off_account(self): - if flt(self.doc.write_off_amount) and not self.doc.write_off_account: + if flt(self.write_off_amount) and not self.write_off_account: msgprint("Please enter Write Off Account", raise_exception=1) def validate_c_form(self): """ Blank C-form no if C-form applicable marked as 'No'""" - if self.doc.amended_from and self.doc.c_form_applicable == 'No' and self.doc.c_form_no: + if self.amended_from and self.c_form_applicable == 'No' and self.c_form_no: frappe.db.sql("""delete from `tabC-Form Invoice Detail` where invoice_no = %s - and parent = %s""", (self.doc.amended_from, self.doc.c_form_no)) + and parent = %s""", (self.amended_from, self.c_form_no)) + + frappe.db.set(self, 'c_form_no', '') - frappe.db.set(self.doc, 'c_form_no', '') - def update_current_stock(self): - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if d.item_code and d.warehouse: bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1) d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0 - for d in getlist(self.doclist, 'packing_details'): + for d in self.get('packing_details'): bin = frappe.db.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1) d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0 d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0 - - + + def get_warehouse(self): - w = frappe.db.sql("""select warehouse from `tabPOS Setting` - where ifnull(user,'') = %s and company = %s""", - (frappe.session['user'], self.doc.company)) + w = frappe.db.sql("""select warehouse from `tabPOS Setting` + where ifnull(user,'') = %s and company = %s""", + (frappe.session['user'], self.company)) w = w and w[0][0] or '' if not w: - ps = frappe.db.sql("""select name, warehouse from `tabPOS Setting` - where ifnull(user,'') = '' and company = %s""", self.doc.company) + ps = frappe.db.sql("""select name, warehouse from `tabPOS Setting` + where ifnull(user,'') = '' and company = %s""", self.company) if not ps: msgprint("To make POS entry, please create POS Setting from Accounts --> POS Setting page and refresh the system.", raise_exception=True) elif not ps[0][1]: @@ -409,43 +405,43 @@ class DocType(SellingController): return w def on_update(self): - if cint(self.doc.update_stock) == 1: + if cint(self.update_stock) == 1: # Set default warehouse from pos setting - if cint(self.doc.is_pos) == 1: + if cint(self.is_pos) == 1: w = self.get_warehouse() if w: - for d in getlist(self.doclist, 'entries'): + for d in self.get('entries'): if not d.warehouse: d.warehouse = cstr(w) from erpnext.stock.doctype.packed_item.packed_item import make_packing_list make_packing_list(self, 'entries') else: - self.doclist = self.doc.clear_table(self.doclist, 'packing_details') - - if cint(self.doc.is_pos) == 1: - if flt(self.doc.paid_amount) == 0: - if self.doc.cash_bank_account: - frappe.db.set(self.doc, 'paid_amount', - (flt(self.doc.grand_total) - flt(self.doc.write_off_amount))) + self.set('packing_details', []) + + if cint(self.is_pos) == 1: + if flt(self.paid_amount) == 0: + if self.cash_bank_account: + frappe.db.set(self, 'paid_amount', + (flt(self.grand_total) - flt(self.write_off_amount))) else: # show message that the amount is not paid - frappe.db.set(self.doc,'paid_amount',0) + frappe.db.set(self,'paid_amount',0) frappe.msgprint("Note: Payment Entry will not be created since 'Cash/Bank Account' was not specified.") else: - frappe.db.set(self.doc,'paid_amount',0) - + frappe.db.set(self,'paid_amount',0) + def check_prev_docstatus(self): - for d in getlist(self.doclist,'entries'): + for d in self.get('entries'): if d.sales_order: - submitted = frappe.db.sql("""select name from `tabSales Order` + submitted = frappe.db.sql("""select name from `tabSales Order` where docstatus = 1 and name = %s""", d.sales_order) if not submitted: msgprint("Sales Order : "+ cstr(d.sales_order) +" is not submitted") raise Exception , "Validation Error." if d.delivery_note: - submitted = frappe.db.sql("""select name from `tabDelivery Note` + submitted = frappe.db.sql("""select name from `tabDelivery Note` where docstatus = 1 and name = %s""", d.delivery_note) if not submitted: msgprint("Delivery Note : "+ cstr(d.delivery_note) +" is not submitted") @@ -460,213 +456,206 @@ class DocType(SellingController): "actual_qty": -1*flt(d.qty), "stock_uom": frappe.db.get_value("Item", d.item_code, "stock_uom") })) - + self.make_sl_entries(sl_entries) - + def make_gl_entries(self, repost_future_gle=True): gl_entries = self.get_gl_entries() - + if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries - - update_outstanding = cint(self.doc.is_pos) and self.doc.write_off_account \ + + update_outstanding = cint(self.is_pos) and self.write_off_account \ and 'No' or 'Yes' - make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2), + make_gl_entries(gl_entries, cancel=(self.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) - if repost_future_gle and cint(self.doc.update_stock) \ + if repost_future_gle and cint(self.update_stock) \ and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): items, warehouse_account = self.get_items_and_warehouse_accounts() - from controllers.stock_controller import update_gl_entries_after - update_gl_entries_after(self.doc.posting_date, self.doc.posting_time, + update_gl_entries_after(self.posting_date, self.posting_time, warehouse_account, items) - + def get_gl_entries(self, warehouse_account=None): from erpnext.accounts.general_ledger import merge_similar_entries - + gl_entries = [] - + self.make_customer_gl_entry(gl_entries) - + self.make_tax_gl_entries(gl_entries) - + self.make_item_gl_entries(gl_entries) - + # merge gl entries before adding pos entries gl_entries = merge_similar_entries(gl_entries) - + self.make_pos_gl_entries(gl_entries) - + return gl_entries - + def make_customer_gl_entry(self, gl_entries): - if self.doc.grand_total: + if self.grand_total: gl_entries.append( self.get_gl_dict({ - "account": self.doc.debit_to, - "against": self.doc.against_income_account, - "debit": self.doc.grand_total, - "remarks": self.doc.remarks, - "against_voucher": self.doc.name, - "against_voucher_type": self.doc.doctype, + "account": self.debit_to, + "against": self.against_income_account, + "debit": self.grand_total, + "remarks": self.remarks, + "against_voucher": self.name, + "against_voucher_type": self.doctype, }) ) - + def make_tax_gl_entries(self, gl_entries): - for tax in self.doclist.get({"parentfield": "other_charges"}): + for tax in self.get("other_charges"): if flt(tax.tax_amount_after_discount_amount): gl_entries.append( self.get_gl_dict({ "account": tax.account_head, - "against": self.doc.debit_to, + "against": self.debit_to, "credit": flt(tax.tax_amount_after_discount_amount), - "remarks": self.doc.remarks, + "remarks": self.remarks, "cost_center": tax.cost_center }) ) - - def make_item_gl_entries(self, gl_entries): - # income account gl entries - for item in self.doclist.get({"parentfield": "entries"}): + + def make_item_gl_entries(self, gl_entries): + # income account gl entries + for item in self.get("entries"): if flt(item.base_amount): gl_entries.append( self.get_gl_dict({ "account": item.income_account, - "against": self.doc.debit_to, + "against": self.debit_to, "credit": item.base_amount, - "remarks": self.doc.remarks, + "remarks": self.remarks, "cost_center": item.cost_center }) ) - + # expense account gl entries if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \ - and cint(self.doc.update_stock): - gl_entries += super(DocType, self).get_gl_entries() - + and cint(self.update_stock): + gl_entries += super(SalesInvoice, self).get_gl_entries() + def make_pos_gl_entries(self, gl_entries): - if cint(self.doc.is_pos) and self.doc.cash_bank_account and self.doc.paid_amount: + if cint(self.is_pos) and self.cash_bank_account and self.paid_amount: # POS, make payment entries gl_entries.append( self.get_gl_dict({ - "account": self.doc.debit_to, - "against": self.doc.cash_bank_account, - "credit": self.doc.paid_amount, - "remarks": self.doc.remarks, - "against_voucher": self.doc.name, - "against_voucher_type": self.doc.doctype, + "account": self.debit_to, + "against": self.cash_bank_account, + "credit": self.paid_amount, + "remarks": self.remarks, + "against_voucher": self.name, + "against_voucher_type": self.doctype, }) ) gl_entries.append( self.get_gl_dict({ - "account": self.doc.cash_bank_account, - "against": self.doc.debit_to, - "debit": self.doc.paid_amount, - "remarks": self.doc.remarks, + "account": self.cash_bank_account, + "against": self.debit_to, + "debit": self.paid_amount, + "remarks": self.remarks, }) ) # write off entries, applicable if only pos - if self.doc.write_off_account and self.doc.write_off_amount: + if self.write_off_account and self.write_off_amount: gl_entries.append( self.get_gl_dict({ - "account": self.doc.debit_to, - "against": self.doc.write_off_account, - "credit": self.doc.write_off_amount, - "remarks": self.doc.remarks, - "against_voucher": self.doc.name, - "against_voucher_type": self.doc.doctype, + "account": self.debit_to, + "against": self.write_off_account, + "credit": self.write_off_amount, + "remarks": self.remarks, + "against_voucher": self.name, + "against_voucher_type": self.doctype, }) ) gl_entries.append( self.get_gl_dict({ - "account": self.doc.write_off_account, - "against": self.doc.debit_to, - "debit": self.doc.write_off_amount, - "remarks": self.doc.remarks, - "cost_center": self.doc.write_off_cost_center + "account": self.write_off_account, + "against": self.debit_to, + "debit": self.write_off_amount, + "remarks": self.remarks, + "cost_center": self.write_off_cost_center }) ) - + def update_c_form(self): """Update amended id in C-form""" - if self.doc.c_form_no and self.doc.amended_from: + if self.c_form_no and self.amended_from: frappe.db.sql("""update `tabC-Form Invoice Detail` set invoice_no = %s, invoice_date = %s, territory = %s, net_total = %s, - grand_total = %s where invoice_no = %s and parent = %s""", - (self.doc.name, self.doc.amended_from, self.doc.c_form_no)) + grand_total = %s where invoice_no = %s and parent = %s""", + (self.name, self.amended_from, self.c_form_no)) - @property - def meta(self): - if not hasattr(self, "_meta"): - self._meta = frappe.get_doctype(self.doc.doctype) - return self._meta - def validate_recurring_invoice(self): - if self.doc.convert_into_recurring_invoice: + if self.convert_into_recurring_invoice: self.validate_notification_email_id() - - if not self.doc.recurring_type: + + if not self.recurring_type: msgprint(_("Please select: ") + self.meta.get_label("recurring_type"), raise_exception=1) - - elif not (self.doc.invoice_period_from_date and \ - self.doc.invoice_period_to_date): + + elif not (self.invoice_period_from_date and \ + self.invoice_period_to_date): msgprint(comma_and([self.meta.get_label("invoice_period_from_date"), self.meta.get_label("invoice_period_to_date")]) + _(": Mandatory for a Recurring Invoice."), raise_exception=True) - + def convert_to_recurring(self): - if self.doc.convert_into_recurring_invoice: - if not self.doc.recurring_id: - frappe.db.set(self.doc, "recurring_id", + if self.convert_into_recurring_invoice: + if not self.recurring_id: + frappe.db.set(self, "recurring_id", make_autoname("RECINV/.#####")) - + self.set_next_date() - elif self.doc.recurring_id: + elif self.recurring_id: frappe.db.sql("""update `tabSales Invoice` set convert_into_recurring_invoice = 0 - where recurring_id = %s""", (self.doc.recurring_id,)) - + where recurring_id = %s""", (self.recurring_id,)) + def validate_notification_email_id(self): - if self.doc.notification_email_address: + if self.notification_email_address: email_list = filter(None, [cstr(email).strip() for email in - self.doc.notification_email_address.replace("\n", "").split(",")]) - + self.notification_email_address.replace("\n", "").split(",")]) + from frappe.utils import validate_email_add for email in email_list: if not validate_email_add(email): msgprint(self.meta.get_label("notification_email_address") \ + " - " + _("Invalid Email Address") + ": \"%s\"" % email, raise_exception=1) - + else: msgprint("Notification Email Addresses not specified for recurring invoice", raise_exception=1) - + def set_next_date(self): """ Set next date on which auto invoice will be created""" - if not self.doc.repeat_on_day_of_month: - msgprint("""Please enter 'Repeat on Day of Month' field value. - The day of the month on which auto invoice + if not self.repeat_on_day_of_month: + msgprint("""Please enter 'Repeat on Day of Month' field value. + The day of the month on which auto invoice will be generated e.g. 05, 28 etc.""", raise_exception=1) - - next_date = get_next_date(self.doc.posting_date, - month_map[self.doc.recurring_type], cint(self.doc.repeat_on_day_of_month)) - - frappe.db.set(self.doc, 'next_date', next_date) - + + next_date = get_next_date(self.posting_date, + month_map[self.recurring_type], cint(self.repeat_on_day_of_month)) + + frappe.db.set(self, 'next_date', next_date) + def get_next_date(dt, mcount, day=None): dt = getdate(dt) - + from dateutil.relativedelta import relativedelta dt += relativedelta(months=mcount, day=day) - + return dt - + def manage_recurring_invoices(next_date=None, commit=True): - """ + """ Create recurring invoices on specific date by copying the original one and notify the concerned people """ @@ -675,14 +664,14 @@ def manage_recurring_invoices(next_date=None, commit=True): from `tabSales Invoice` where ifnull(convert_into_recurring_invoice, 0)=1 and docstatus=1 and next_date=%s and next_date <= ifnull(end_date, '2199-12-31')""", next_date) - + exception_list = [] for ref_invoice, recurring_id in recurring_invoices: if not frappe.db.sql("""select name from `tabSales Invoice` where posting_date=%s and recurring_id=%s and docstatus=1""", (next_date, recurring_id)): try: - ref_wrapper = frappe.bean('Sales Invoice', ref_invoice) + ref_wrapper = frappe.get_doc('Sales Invoice', ref_invoice) new_invoice_wrapper = make_new_invoice(ref_wrapper, next_date) send_notification(new_invoice_wrapper) if commit: @@ -694,72 +683,71 @@ def manage_recurring_invoices(next_date=None, commit=True): frappe.db.begin() frappe.db.sql("update `tabSales Invoice` set \ convert_into_recurring_invoice = 0 where name = %s", ref_invoice) - notify_errors(ref_invoice, ref_wrapper.doc.customer, ref_wrapper.doc.owner) + notify_errors(ref_invoice, ref_wrapper.customer, ref_wrapper.owner) frappe.db.commit() exception_list.append(frappe.get_traceback()) finally: if commit: frappe.db.begin() - + if exception_list: exception_message = "\n\n".join([cstr(d) for d in exception_list]) raise Exception, exception_message def make_new_invoice(ref_wrapper, posting_date): - from frappe.model.bean import clone from erpnext.accounts.utils import get_fiscal_year - new_invoice = clone(ref_wrapper) - - mcount = month_map[ref_wrapper.doc.recurring_type] - - invoice_period_from_date = get_next_date(ref_wrapper.doc.invoice_period_from_date, mcount) - - # get last day of the month to maintain period if the from date is first day of its own month + new_invoice = frappe.copy_doc(ref_wrapper) + + mcount = month_map[ref_wrapper.recurring_type] + + invoice_period_from_date = get_next_date(ref_wrapper.invoice_period_from_date, mcount) + + # get last day of the month to maintain period if the from date is first day of its own month # and to date is the last day of its own month - if (cstr(get_first_day(ref_wrapper.doc.invoice_period_from_date)) == \ - cstr(ref_wrapper.doc.invoice_period_from_date)) and \ - (cstr(get_last_day(ref_wrapper.doc.invoice_period_to_date)) == \ - cstr(ref_wrapper.doc.invoice_period_to_date)): - invoice_period_to_date = get_last_day(get_next_date(ref_wrapper.doc.invoice_period_to_date, + if (cstr(get_first_day(ref_wrapper.invoice_period_from_date)) == \ + cstr(ref_wrapper.invoice_period_from_date)) and \ + (cstr(get_last_day(ref_wrapper.invoice_period_to_date)) == \ + cstr(ref_wrapper.invoice_period_to_date)): + invoice_period_to_date = get_last_day(get_next_date(ref_wrapper.invoice_period_to_date, mcount)) else: - invoice_period_to_date = get_next_date(ref_wrapper.doc.invoice_period_to_date, mcount) - - new_invoice.doc.fields.update({ + invoice_period_to_date = get_next_date(ref_wrapper.invoice_period_to_date, mcount) + + new_invoice.update({ "posting_date": posting_date, "aging_date": posting_date, - "due_date": add_days(posting_date, cint(date_diff(ref_wrapper.doc.due_date, - ref_wrapper.doc.posting_date))), + "due_date": add_days(posting_date, cint(date_diff(ref_wrapper.due_date, + ref_wrapper.posting_date))), "invoice_period_from_date": invoice_period_from_date, "invoice_period_to_date": invoice_period_to_date, "fiscal_year": get_fiscal_year(posting_date)[0], - "owner": ref_wrapper.doc.owner, + "owner": ref_wrapper.owner, }) - + new_invoice.submit() - + return new_invoice - + def send_notification(new_rv): """Notify concerned persons about recurring invoice generation""" - + from frappe.core.doctype.print_format.print_format import get_html - frappe.sendmail(new_rv.doc.notification_email_address, - subject="New Invoice : " + new_rv.doc.name, - message = get_html(new_rv.doc, new_rv.doclist, "SalesInvoice")) - + frappe.sendmail(new_rv.notification_email_address, + subject="New Invoice : " + new_rv.name, + message = get_html(new_rv, new_rv, "SalesInvoice")) + def notify_errors(inv, customer, owner): from frappe.utils.user import get_system_managers recipients=get_system_managers() - + frappe.sendmail(recipients + [frappe.db.get_value("User", owner, "email")], subject="[Urgent] Error while creating recurring invoice for %s" % inv, message = frappe.get_template("template/emails/recurring_invoice_failed.html").render({ "name": inv, "customer": customer })) - + assign_task_to_owner(inv, "Recurring Invoice Failed", recipients) def assign_task_to_owner(inv, msg, users): @@ -787,64 +775,64 @@ def get_bank_cash_account(mode_of_payment): def get_income_account(doctype, txt, searchfield, start, page_len, filters): from erpnext.controllers.queries import get_match_cond - # income account can be any Credit account, - # but can also be a Asset account with account_type='Income Account' in special circumstances. + # income account can be any Credit account, + # but can also be a Asset account with account_type='Income Account' in special circumstances. # Hence the first condition is an "OR" - return frappe.db.sql("""select tabAccount.name from `tabAccount` + return frappe.db.sql("""select tabAccount.name from `tabAccount` where (tabAccount.report_type = "Profit and Loss" - or tabAccount.account_type = "Income Account") - and tabAccount.group_or_ledger="Ledger" + or tabAccount.account_type = "Income Account") + and tabAccount.group_or_ledger="Ledger" and tabAccount.docstatus!=2 and ifnull(tabAccount.master_type, "")="" and ifnull(tabAccount.master_name, "")="" - and tabAccount.company = '%(company)s' + and tabAccount.company = '%(company)s' and tabAccount.%(key)s LIKE '%(txt)s' - %(mcond)s""" % {'company': filters['company'], 'key': searchfield, + %(mcond)s""" % {'company': filters['company'], 'key': searchfield, 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)}) @frappe.whitelist() -def make_delivery_note(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist - +def make_delivery_note(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc + def set_missing_values(source, target): - bean = frappe.bean(target) - bean.run_method("onload_post_render") - + doc = frappe.get_doc(target) + doc.run_method("onload_post_render") + def update_item(source_doc, target_doc, source_parent): target_doc.base_amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \ flt(source_doc.base_rate) target_doc.amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \ flt(source_doc.rate) target_doc.qty = flt(source_doc.qty) - flt(source_doc.delivered_qty) - - doclist = get_mapped_doclist("Sales Invoice", source_name, { + + doclist = get_mapped_doc("Sales Invoice", source_name, { "Sales Invoice": { - "doctype": "Delivery Note", + "doctype": "Delivery Note", "validation": { "docstatus": ["=", 1] } - }, + }, "Sales Invoice Item": { - "doctype": "Delivery Note Item", + "doctype": "Delivery Note Item", "field_map": { - "name": "prevdoc_detail_docname", - "parent": "against_sales_invoice", + "name": "prevdoc_detail_docname", + "parent": "against_sales_invoice", "serial_no": "serial_no" }, "postprocess": update_item - }, + }, "Sales Taxes and Charges": { - "doctype": "Sales Taxes and Charges", + "doctype": "Sales Taxes and Charges", "add_if_empty": True - }, + }, "Sales Team": { - "doctype": "Sales Team", + "doctype": "Sales Team", "field_map": { "incentives": "incentives" }, "add_if_empty": True } - }, target_doclist, set_missing_values) - - return [d.fields for d in doclist] \ No newline at end of file + }, target_doc, set_missing_values) + + return doclist diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt b/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt deleted file mode 100644 index 49cc2133493..00000000000 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt +++ /dev/null @@ -1,1239 +0,0 @@ -[ - { - "creation": "2013-05-24 19:29:05", - "docstatus": 0, - "modified": "2014-01-28 18:43:10", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "autoname": "naming_series:", - "default_print_format": "Standard", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-file-text", - "is_submittable": 1, - "module": "Accounts", - "name": "__common__", - "read_only_onload": 1, - "search_fields": "posting_date, due_date, debit_to, fiscal_year, grand_total, outstanding_amount" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales Invoice", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Sales Invoice", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Sales Invoice" - }, - { - "doctype": "DocField", - "fieldname": "customer_section", - "fieldtype": "Section Break", - "label": "Customer", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "INV\nINV/10-11/", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "hidden": 0, - "label": "Customer", - "no_copy": 0, - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "hidden": 0, - "in_list_view": 1, - "label": "Name", - "oldfieldname": "customer_name", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Text", - "hidden": 1, - "label": "Mobile No", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Text", - "hidden": 1, - "label": "Contact Email", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "is_pos", - "fieldtype": "Check", - "label": "Is POS", - "oldfieldname": "is_pos", - "oldfieldtype": "Check", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Link", - "options": "Sales Invoice", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Posting Date", - "no_copy": 1, - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "print_hide": 0, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "due_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Payment Due Date", - "no_copy": 1, - "oldfieldname": "due_date", - "oldfieldtype": "Date", - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "mode_of_payment", - "fieldtype": "Select", - "label": "Mode of Payment", - "no_copy": 0, - "oldfieldname": "mode_of_payment", - "oldfieldtype": "Select", - "options": "link:Mode of Payment", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "currency_section", - "fieldtype": "Section Break", - "label": "Currency and Price List", - "options": "icon-tag", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "currency", - "fieldtype": "Link", - "label": "Currency", - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "description": "Rate at which Customer Currency is converted to customer's base currency", - "doctype": "DocField", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "label": "Exchange Rate", - "oldfieldname": "conversion_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "selling_price_list", - "fieldtype": "Link", - "label": "Price List", - "oldfieldname": "price_list_name", - "oldfieldtype": "Select", - "options": "Price List", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "price_list_currency", - "fieldtype": "Link", - "label": "Price List Currency", - "options": "Currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "description": "Rate at which Price list currency is converted to customer's base currency", - "doctype": "DocField", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "label": "Price List Exchange Rate", - "no_copy": 0, - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "items", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "update_stock", - "fieldtype": "Check", - "label": "Update Stock", - "oldfieldname": "update_stock", - "oldfieldtype": "Check", - "print_hide": 1, - "read_only": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "entries", - "fieldtype": "Table", - "label": "Sales Invoice Items", - "oldfieldname": "entries", - "oldfieldtype": "Table", - "options": "Sales Invoice Item", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "packing_list", - "fieldtype": "Section Break", - "label": "Packing List", - "options": "icon-suitcase", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "packing_details", - "fieldtype": "Table", - "label": "Packing Details", - "options": "Packed Item", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "sales_bom_help", - "fieldtype": "HTML", - "label": "Sales BOM Help", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_30", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total_export", - "fieldtype": "Currency", - "label": "Net Total", - "options": "currency", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_32", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total (Company Currency)", - "oldfieldname": "net_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "taxes", - "fieldtype": "Section Break", - "label": "Taxes and Charges", - "oldfieldtype": "Section Break", - "options": "icon-money", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "oldfieldname": "charge", - "oldfieldtype": "Link", - "options": "Sales Taxes and Charges Master", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_38", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "shipping_rule", - "fieldtype": "Link", - "label": "Shipping Rule", - "oldfieldtype": "Button", - "options": "Shipping Rule", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_40", - "fieldtype": "Section Break" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "other_charges", - "fieldtype": "Table", - "label": "Sales Taxes and Charges", - "oldfieldname": "other_charges", - "oldfieldtype": "Table", - "options": "Sales Taxes and Charges", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_calculation", - "fieldtype": "HTML", - "label": "Taxes and Charges Calculation", - "oldfieldtype": "HTML", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_43", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_total_export", - "fieldtype": "Currency", - "label": "Total Taxes and Charges", - "options": "currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_45", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_total", - "fieldtype": "Currency", - "label": "Total Taxes and Charges (Company Currency)", - "oldfieldname": "other_charges_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "discount_amount", - "fieldtype": "Currency", - "label": "Discount Amount", - "options": "Company:company:default_currency", - "print_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "Totals", - "oldfieldtype": "Section Break", - "options": "icon-money", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "grand_total_export", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Grand Total", - "oldfieldname": "grand_total_export", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "rounded_total_export", - "fieldtype": "Currency", - "label": "Rounded Total", - "oldfieldname": "rounded_total_export", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "in_words_export", - "fieldtype": "Data", - "label": "In Words", - "oldfieldname": "in_words_export", - "oldfieldtype": "Data", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "gross_profit", - "fieldtype": "Currency", - "label": "Gross Profit", - "oldfieldname": "gross_profit", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "gross_profit_percent", - "fieldtype": "Float", - "label": "Gross Profit (%)", - "oldfieldname": "gross_profit_percent", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break5", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "grand_total", - "fieldtype": "Currency", - "in_filter": 1, - "label": "Grand Total (Company Currency)", - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total (Company Currency)", - "oldfieldname": "rounded_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "description": "In Words will be visible once you save the Sales Invoice.", - "doctype": "DocField", - "fieldname": "in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_advance", - "fieldtype": "Currency", - "label": "Total Advance", - "oldfieldname": "total_advance", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "outstanding_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Outstanding Amount", - "no_copy": 1, - "oldfieldname": "outstanding_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "advances", - "fieldtype": "Section Break", - "label": "Advances", - "oldfieldtype": "Section Break", - "options": "icon-money", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "get_advances_received", - "fieldtype": "Button", - "label": "Get Advances Received", - "oldfieldtype": "Button", - "options": "get_advances", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "advance_adjustment_details", - "fieldtype": "Table", - "label": "Sales Invoice Advance", - "oldfieldname": "advance_adjustment_details", - "oldfieldtype": "Table", - "options": "Sales Invoice Advance", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "is_pos", - "doctype": "DocField", - "fieldname": "payments_section", - "fieldtype": "Section Break", - "label": "Payments", - "options": "icon-money", - "read_only": 0 - }, - { - "depends_on": "is_pos", - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "depends_on": "is_pos", - "doctype": "DocField", - "fieldname": "paid_amount", - "fieldtype": "Currency", - "label": "Paid Amount", - "oldfieldname": "paid_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "is_pos", - "doctype": "DocField", - "fieldname": "cash_bank_account", - "fieldtype": "Link", - "label": "Cash/Bank Account", - "oldfieldname": "cash_bank_account", - "oldfieldtype": "Link", - "options": "Account", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "is_pos", - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "depends_on": "is_pos", - "doctype": "DocField", - "fieldname": "write_off_outstanding_amount_automatically", - "fieldtype": "Check", - "label": "Write Off Outstanding Amount", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "is_pos", - "doctype": "DocField", - "fieldname": "write_off_amount", - "fieldtype": "Currency", - "label": "Write Off Amount", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "is_pos", - "doctype": "DocField", - "fieldname": "write_off_account", - "fieldtype": "Link", - "label": "Write Off Account", - "options": "Account", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "is_pos", - "doctype": "DocField", - "fieldname": "write_off_cost_center", - "fieldtype": "Link", - "label": "Write Off Cost Center", - "options": "Cost Center", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "oldfieldtype": "Section Break", - "options": "icon-legal", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Terms and Conditions Details", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor", - "read_only": 0 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_section", - "fieldtype": "Section Break", - "hidden": 0, - "label": "Contact Info", - "options": "icon-bullhorn", - "read_only": 0 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "in_filter": 1, - "label": "Territory", - "options": "Territory", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "in_filter": 1, - "label": "Customer Group", - "options": "Customer Group", - "print_hide": 1, - "read_only": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break23", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "customer_address", - "fieldtype": "Link", - "label": "Customer Address", - "options": "Address", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "label": "Contact Person", - "options": "Contact", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text", - "print_hide": 1, - "read_only": 0 - }, - { - "description": "Customer (Receivable) Account", - "doctype": "DocField", - "fieldname": "debit_to", - "fieldtype": "Link", - "in_filter": 1, - "label": "Debit To", - "oldfieldname": "debit_to", - "oldfieldtype": "Link", - "options": "Account", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "project_name", - "fieldtype": "Link", - "in_filter": 1, - "label": "Project Name", - "oldfieldname": "project_name", - "oldfieldtype": "Link", - "options": "Project", - "read_only": 0, - "search_index": 1 - }, - { - "depends_on": "eval:doc.source == 'Campaign'", - "doctype": "DocField", - "fieldname": "campaign", - "fieldtype": "Link", - "label": "Campaign", - "oldfieldname": "campaign", - "oldfieldtype": "Link", - "options": "Campaign", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "source", - "fieldtype": "Select", - "label": "Source", - "oldfieldname": "source", - "oldfieldtype": "Select", - "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", - "print_hide": 1, - "read_only": 0 - }, - { - "default": "No", - "description": "Considered as an Opening Balance", - "doctype": "DocField", - "fieldname": "is_opening", - "fieldtype": "Select", - "in_filter": 1, - "label": "Is Opening Entry", - "oldfieldname": "is_opening", - "oldfieldtype": "Select", - "options": "No\nYes", - "print_hide": 1, - "read_only": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "c_form_applicable", - "fieldtype": "Select", - "label": "C-Form Applicable", - "no_copy": 1, - "options": "No\nYes", - "print_hide": 1, - "read_only": 0, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "c_form_no", - "fieldtype": "Link", - "label": "C-Form No", - "no_copy": 1, - "options": "C-Form", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break8", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "read_only": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Select", - "label": "Letter Head", - "oldfieldname": "letter_head", - "oldfieldtype": "Select", - "options": "link:Letter Head", - "print_hide": 1, - "read_only": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "posting_time", - "fieldtype": "Time", - "label": "Posting Time", - "no_copy": 1, - "oldfieldname": "posting_time", - "oldfieldtype": "Time", - "print_hide": 1, - "read_only": 0 - }, - { - "description": "Actual Invoice Date", - "doctype": "DocField", - "fieldname": "aging_date", - "fieldtype": "Date", - "label": "Aging Date", - "oldfieldname": "aging_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "no_copy": 0, - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "remarks", - "fieldtype": "Small Text", - "label": "Remarks", - "no_copy": 1, - "oldfieldname": "remarks", - "oldfieldtype": "Text", - "print_hide": 1, - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "sales_team_section_break", - "fieldtype": "Section Break", - "label": "Sales Team", - "oldfieldtype": "Section Break", - "options": "icon-group", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break9", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "sales_partner", - "fieldtype": "Link", - "in_filter": 1, - "label": "Sales Partner", - "oldfieldname": "sales_partner", - "oldfieldtype": "Link", - "options": "Sales Partner", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break10", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "commission_rate", - "fieldtype": "Float", - "label": "Commission Rate (%)", - "oldfieldname": "commission_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "total_commission", - "fieldtype": "Currency", - "label": "Total Commission", - "oldfieldname": "total_commission", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break2", - "fieldtype": "Section Break", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "sales_team", - "fieldtype": "Table", - "label": "Sales Team1", - "oldfieldname": "sales_team", - "oldfieldtype": "Table", - "options": "Sales Team", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "eval:doc.docstatus<2", - "doctype": "DocField", - "fieldname": "recurring_invoice", - "fieldtype": "Section Break", - "label": "Recurring Invoice", - "options": "icon-time", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break11", - "fieldtype": "Column Break", - "print_hide": 1, - "read_only": 0, - "width": "50%" - }, - { - "allow_on_submit": 1, - "depends_on": "eval:doc.docstatus<2", - "description": "Check if recurring invoice, uncheck to stop recurring or put proper End Date", - "doctype": "DocField", - "fieldname": "convert_into_recurring_invoice", - "fieldtype": "Check", - "label": "Convert into Recurring Invoice", - "no_copy": 1, - "print_hide": 1, - "read_only": 0 - }, - { - "allow_on_submit": 1, - "depends_on": "eval:doc.convert_into_recurring_invoice==1", - "description": "Select the period when the invoice will be generated automatically", - "doctype": "DocField", - "fieldname": "recurring_type", - "fieldtype": "Select", - "label": "Recurring Type", - "no_copy": 1, - "options": "\nMonthly\nQuarterly\nHalf-yearly\nYearly", - "print_hide": 1, - "read_only": 0 - }, - { - "allow_on_submit": 1, - "depends_on": "eval:doc.convert_into_recurring_invoice==1", - "description": "The day of the month on which auto invoice will be generated e.g. 05, 28 etc ", - "doctype": "DocField", - "fieldname": "repeat_on_day_of_month", - "fieldtype": "Int", - "label": "Repeat on Day of Month", - "no_copy": 1, - "print_hide": 1, - "read_only": 0 - }, - { - "allow_on_submit": 1, - "depends_on": "eval:doc.convert_into_recurring_invoice==1", - "description": "Start date of current invoice's period", - "doctype": "DocField", - "fieldname": "invoice_period_from_date", - "fieldtype": "Date", - "label": "Invoice Period From Date", - "no_copy": 1, - "print_hide": 1, - "read_only": 0 - }, - { - "allow_on_submit": 1, - "depends_on": "eval:doc.convert_into_recurring_invoice==1", - "description": "End date of current invoice's period", - "doctype": "DocField", - "fieldname": "invoice_period_to_date", - "fieldtype": "Date", - "label": "Invoice Period To Date", - "no_copy": 1, - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break12", - "fieldtype": "Column Break", - "no_copy": 0, - "print_hide": 1, - "read_only": 0, - "width": "50%" - }, - { - "allow_on_submit": 1, - "depends_on": "eval:doc.convert_into_recurring_invoice==1", - "description": "Enter email id separated by commas, invoice will be mailed automatically on particular date", - "doctype": "DocField", - "fieldname": "notification_email_address", - "fieldtype": "Small Text", - "label": "Notification Email Address", - "no_copy": 1, - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "eval:doc.convert_into_recurring_invoice==1", - "description": "The unique id for tracking all recurring invoices.\u00a0It is generated on submit.", - "doctype": "DocField", - "fieldname": "recurring_id", - "fieldtype": "Data", - "label": "Recurring Id", - "no_copy": 1, - "print_hide": 1, - "read_only": 1 - }, - { - "depends_on": "eval:doc.convert_into_recurring_invoice==1", - "description": "The date on which next invoice will be generated. It is generated on submit.\n", - "doctype": "DocField", - "fieldname": "next_date", - "fieldtype": "Date", - "label": "Next Date", - "no_copy": 1, - "print_hide": 1, - "read_only": 1 - }, - { - "allow_on_submit": 1, - "depends_on": "eval:doc.convert_into_recurring_invoice==1", - "description": "The date on which recurring invoice will be stop", - "doctype": "DocField", - "fieldname": "end_date", - "fieldtype": "Date", - "label": "End Date", - "no_copy": 1, - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "against_income_account", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Against Income Account", - "no_copy": 1, - "oldfieldname": "against_income_account", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Accounts Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 0, - "create": 1, - "delete": 0, - "doctype": "DocPerm", - "role": "Accounts User", - "submit": 1, - "write": 1 - }, - { - "cancel": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Customer" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice/test_records.json b/erpnext/accounts/doctype/sales_invoice/test_records.json new file mode 100644 index 00000000000..b0828f5c7ea --- /dev/null +++ b/erpnext/accounts/doctype/sales_invoice/test_records.json @@ -0,0 +1,385 @@ +[ + { + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-01-23", + "entries": [ + { + "amount": 500.0, + "base_amount": 500.0, + "base_rate": 500.0, + "cost_center": "_Test Cost Center - _TC", + "description": "138-CMS Shoe", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_name": "138-CMS Shoe", + "parentfield": "entries", + "qty": 1.0, + "rate": 500.0 + } + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 561.8, + "grand_total_export": 561.8, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", + "net_total": 500.0, + "other_charges": [ + { + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 6 + }, + { + "account_head": "_Test Account Service Tax - _TC", + "charge_type": "On Net Total", + "description": "Service Tax", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 6.36 + } + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-01-23", + "price_list_currency": "INR", + "sales_team": [ + { + "allocated_percentage": 65.5, + "doctype": "Sales Team", + "parentfield": "sales_team", + "sales_person": "_Test Sales Person 1" + }, + { + "allocated_percentage": 34.5, + "doctype": "Sales Team", + "parentfield": "sales_team", + "sales_person": "_Test Sales Person 2" + } + ], + "selling_price_list": "_Test Price List", + "territory": "_Test Territory" + }, + { + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-01-23", + "entries": [ + { + "amount": 500.0, + "base_amount": 500.0, + "base_rate": 500.0, + "cost_center": "_Test Cost Center - _TC", + "description": "_Test Item", + "doctype": "Sales Invoice Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "income_account": "Sales - _TC", + "item_code": "_Test Item", + "item_name": "_Test Item", + "parentfield": "entries", + "price_list_rate": 500.0, + "qty": 1.0 + } + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 630.0, + "grand_total_export": 630.0, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", + "net_total": 500.0, + "other_charges": [ + { + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 16 + }, + { + "account_head": "_Test Account Service Tax - _TC", + "charge_type": "On Net Total", + "description": "Service Tax", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 10 + } + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-03-07", + "price_list_currency": "INR", + "selling_price_list": "_Test Price List", + "territory": "_Test Territory" + }, + { + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-01-23", + "entries": [ + { + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 100", + "item_name": "_Test Item Home Desktop 100", + "item_tax_rate": "{\"_Test Account Excise Duty - _TC\": 10}", + "parentfield": "entries", + "price_list_rate": 50, + "qty": 10, + "rate": 50, + "stock_uom": "_Test UOM" + }, + { + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 200", + "item_name": "_Test Item Home Desktop 200", + "parentfield": "entries", + "price_list_rate": 150, + "qty": 5, + "rate": 150, + "stock_uom": "_Test UOM" + } + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total_export": 0, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", + "other_charges": [ + { + "account_head": "_Test Account Shipping Charges - _TC", + "charge_type": "Actual", + "cost_center": "_Test Cost Center - _TC", + "description": "Shipping Charges", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 100 + }, + { + "account_head": "_Test Account Customs Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Customs Duty", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 10 + }, + { + "account_head": "_Test Account Excise Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Excise Duty", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 12 + }, + { + "account_head": "_Test Account Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "Education Cess", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 2, + "row_id": 3 + }, + { + "account_head": "_Test Account S&H Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "S&H Education Cess", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 1, + "row_id": 3 + }, + { + "account_head": "_Test Account CST - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "CST", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 2, + "row_id": 5 + }, + { + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 12.5 + }, + { + "account_head": "_Test Account Discount - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Discount", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": -10, + "row_id": 7 + } + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-01-23", + "price_list_currency": "INR", + "selling_price_list": "_Test Price List", + "territory": "_Test Territory" + }, + { + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-01-23", + "entries": [ + { + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 100", + "item_name": "_Test Item Home Desktop 100", + "item_tax_rate": "{\"_Test Account Excise Duty - _TC\": 10}", + "parentfield": "entries", + "price_list_rate": 62.5, + "qty": 10, + "stock_uom": "_Test UOM" + }, + { + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 200", + "item_name": "_Test Item Home Desktop 200", + "parentfield": "entries", + "price_list_rate": 190.66, + "qty": 5, + "stock_uom": "_Test UOM" + } + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total_export": 0, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", + "other_charges": [ + { + "account_head": "_Test Account Excise Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Excise Duty", + "doctype": "Sales Taxes and Charges", + "idx": 1, + "included_in_print_rate": 1, + "parentfield": "other_charges", + "rate": 12 + }, + { + "account_head": "_Test Account Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "Education Cess", + "doctype": "Sales Taxes and Charges", + "idx": 2, + "included_in_print_rate": 1, + "parentfield": "other_charges", + "rate": 2, + "row_id": 1 + }, + { + "account_head": "_Test Account S&H Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "S&H Education Cess", + "doctype": "Sales Taxes and Charges", + "idx": 3, + "included_in_print_rate": 1, + "parentfield": "other_charges", + "rate": 1, + "row_id": 1 + }, + { + "account_head": "_Test Account CST - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "CST", + "doctype": "Sales Taxes and Charges", + "idx": 4, + "included_in_print_rate": 1, + "parentfield": "other_charges", + "rate": 2, + "row_id": 3 + }, + { + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "idx": 5, + "included_in_print_rate": 1, + "parentfield": "other_charges", + "rate": 12.5 + }, + { + "account_head": "_Test Account Customs Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Customs Duty", + "doctype": "Sales Taxes and Charges", + "idx": 6, + "parentfield": "other_charges", + "rate": 10 + }, + { + "account_head": "_Test Account Shipping Charges - _TC", + "charge_type": "Actual", + "cost_center": "_Test Cost Center - _TC", + "description": "Shipping Charges", + "doctype": "Sales Taxes and Charges", + "idx": 7, + "parentfield": "other_charges", + "rate": 100 + }, + { + "account_head": "_Test Account Discount - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Discount", + "doctype": "Sales Taxes and Charges", + "idx": 8, + "parentfield": "other_charges", + "rate": -10, + "row_id": 7 + } + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-01-23", + "price_list_currency": "INR", + "selling_price_list": "_Test Price List", + "territory": "_Test Territory" + } +] \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 81d55722f9f..2a0bc248a0f 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2,70 +2,58 @@ # License: GNU General Public License v3. See license.txt import frappe -import unittest, json +import unittest, json, copy from frappe.utils import flt -from frappe.model.bean import DocstatusTransitionError, TimestampMismatchError from erpnext.accounts.utils import get_stock_and_account_difference from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory class TestSalesInvoice(unittest.TestCase): def make(self): - w = frappe.bean(copy=test_records[0]) - w.doc.is_pos = 0 + w = frappe.copy_doc(test_records[0]) + w.is_pos = 0 w.insert() w.submit() return w - - def test_double_submission(self): - w = frappe.bean(copy=test_records[0]) - w.doc.docstatus = '0' - w.insert() - - w2 = [d for d in w.doclist] - w.submit() - - w = frappe.bean(w2) - self.assertRaises(DocstatusTransitionError, w.submit) - + def test_timestamp_change(self): - w = frappe.bean(copy=test_records[0]) - w.doc.docstatus = '0' + w = frappe.copy_doc(test_records[0]) + w.docstatus = 0 w.insert() - w2 = frappe.bean([d.fields.copy() for d in w.doclist]) - + w2 = frappe.get_doc(w.doctype, w.name) + import time time.sleep(1) w.save() - + import time time.sleep(1) - self.assertRaises(TimestampMismatchError, w2.save) - + self.assertRaises(frappe.TimestampMismatchError, w2.save) + def test_sales_invoice_calculation_base_currency(self): - si = frappe.bean(copy=test_records[2]) + si = frappe.copy_doc(test_records[2]) si.insert() - + expected_values = { - "keys": ["price_list_rate", "discount_percentage", "rate", "amount", + "keys": ["price_list_rate", "discount_percentage", "rate", "amount", "base_price_list_rate", "base_rate", "base_amount"], "_Test Item Home Desktop 100": [50, 0, 50, 500, 50, 50, 500], "_Test Item Home Desktop 200": [150, 0, 150, 750, 150, 150, 750], } - + # check if children are saved - self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), + self.assertEquals(len(si.get("entries")), len(expected_values)-1) - + # check if item values are calculated - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): for i, k in enumerate(expected_values["keys"]): - self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) - + self.assertEquals(d.get(k), expected_values[d.item_code][i]) + # check net total - self.assertEquals(si.doc.net_total, 1250) - self.assertEquals(si.doc.net_total_export, 1250) - + self.assertEquals(si.net_total, 1250) + self.assertEquals(si.net_total_export, 1250) + # check tax calculation expected_values = { "keys": ["tax_amount", "total"], @@ -78,44 +66,44 @@ class TestSalesInvoice(unittest.TestCase): "_Test Account VAT - _TC": [156.25, 1807.83], "_Test Account Discount - _TC": [-180.78, 1627.05] } - - for d in si.doclist.get({"parentfield": "other_charges"}): + + for d in si.get("other_charges"): for i, k in enumerate(expected_values["keys"]): - self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) - - self.assertEquals(si.doc.grand_total, 1627.05) - self.assertEquals(si.doc.grand_total_export, 1627.05) - + self.assertEquals(d.get(k), expected_values[d.account_head][i]) + + self.assertEquals(si.grand_total, 1627.05) + self.assertEquals(si.grand_total_export, 1627.05) + def test_sales_invoice_calculation_export_currency(self): - si = frappe.bean(copy=test_records[2]) - si.doc.currency = "USD" - si.doc.conversion_rate = 50 - si.doclist[1].rate = 1 - si.doclist[1].price_list_rate = 1 - si.doclist[2].rate = 3 - si.doclist[2].price_list_rate = 3 + si = frappe.copy_doc(test_records[2]) + si.currency = "USD" + si.conversion_rate = 50 + si.get("entries")[0].rate = 1 + si.get("entries")[0].price_list_rate = 1 + si.get("entries")[1].rate = 3 + si.get("entries")[1].price_list_rate = 3 si.insert() - + expected_values = { - "keys": ["price_list_rate", "discount_percentage", "rate", "amount", + "keys": ["price_list_rate", "discount_percentage", "rate", "amount", "base_price_list_rate", "base_rate", "base_amount"], "_Test Item Home Desktop 100": [1, 0, 1, 10, 50, 50, 500], "_Test Item Home Desktop 200": [3, 0, 3, 15, 150, 150, 750], } - + # check if children are saved - self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), + self.assertEquals(len(si.get("entries")), len(expected_values)-1) - + # check if item values are calculated - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): for i, k in enumerate(expected_values["keys"]): - self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) - + self.assertEquals(d.get(k), expected_values[d.item_code][i]) + # check net total - self.assertEquals(si.doc.net_total, 1250) - self.assertEquals(si.doc.net_total_export, 25) - + self.assertEquals(si.net_total, 1250) + self.assertEquals(si.net_total_export, 25) + # check tax calculation expected_values = { "keys": ["tax_amount", "total"], @@ -128,50 +116,48 @@ class TestSalesInvoice(unittest.TestCase): "_Test Account VAT - _TC": [156.25, 1807.83], "_Test Account Discount - _TC": [-180.78, 1627.05] } - - for d in si.doclist.get({"parentfield": "other_charges"}): + + for d in si.get("other_charges"): for i, k in enumerate(expected_values["keys"]): - self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) - - self.assertEquals(si.doc.grand_total, 1627.05) - self.assertEquals(si.doc.grand_total_export, 32.54) + self.assertEquals(d.get(k), expected_values[d.account_head][i]) + + self.assertEquals(si.grand_total, 1627.05) + self.assertEquals(si.grand_total_export, 32.54) def test_sales_invoice_discount_amount(self): - si = frappe.bean(copy=test_records[3]) - si.doc.discount_amount = 104.95 - si.doclist.append({ + si = frappe.copy_doc(test_records[3]) + si.discount_amount = 104.95 + si.append("other_charges", { "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", "charge_type": "On Previous Row Amount", "account_head": "_Test Account Service Tax - _TC", "cost_center": "_Test Cost Center - _TC", "description": "Service Tax", "rate": 10, "row_id": 8, - "idx": 9 }) si.insert() - + expected_values = { - "keys": ["price_list_rate", "discount_percentage", "rate", "amount", + "keys": ["price_list_rate", "discount_percentage", "rate", "amount", "base_price_list_rate", "base_rate", "base_amount"], "_Test Item Home Desktop 100": [62.5, 0, 62.5, 625.0, 50, 50, 465.37], "_Test Item Home Desktop 200": [190.66, 0, 190.66, 953.3, 150, 150, 698.08], } - + # check if children are saved - self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), + self.assertEquals(len(si.get("entries")), len(expected_values)-1) - + # check if item values are calculated - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): for i, k in enumerate(expected_values["keys"]): - self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) - + self.assertEquals(d.get(k), expected_values[d.item_code][i]) + # check net total - self.assertEquals(si.doc.net_total, 1163.45) - self.assertEquals(si.doc.net_total_export, 1578.3) - + self.assertEquals(si.net_total, 1163.45) + self.assertEquals(si.net_total_export, 1578.3) + # check tax calculation expected_values = { "keys": ["tax_amount", "tax_amount_after_discount_amount", "total"], @@ -185,48 +171,46 @@ class TestSalesInvoice(unittest.TestCase): "_Test Account Discount - _TC": [-180.33, -168.54, 1516.88], "_Test Account Service Tax - _TC": [-18.03, -16.88, 1500] } - - for d in si.doclist.get({"parentfield": "other_charges"}): + + for d in si.get("other_charges"): for i, k in enumerate(expected_values["keys"]): - self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) - - self.assertEquals(si.doc.grand_total, 1500) - self.assertEquals(si.doc.grand_total_export, 1500) + self.assertEquals(d.get(k), expected_values[d.account_head][i]) + + self.assertEquals(si.grand_total, 1500) + self.assertEquals(si.grand_total_export, 1500) def test_discount_amount_gl_entry(self): - si = frappe.bean(copy=test_records[3]) - si.doc.discount_amount = 104.95 - si.doclist.append({ + si = frappe.copy_doc(test_records[3]) + si.discount_amount = 104.95 + si.append("other_charges", { "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", "charge_type": "On Previous Row Amount", "account_head": "_Test Account Service Tax - _TC", "cost_center": "_Test Cost Center - _TC", "description": "Service Tax", "rate": 10, - "row_id": 8, - "idx": 9 + "row_id": 8 }) si.insert() si.submit() gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s - order by account asc""", si.doc.name, as_dict=1) + order by account asc""", si.name, as_dict=1) self.assertTrue(gl_entries) expected_values = sorted([ - [si.doc.debit_to, 1500, 0.0], - [test_records[3][1]["income_account"], 0.0, 1163.45], - [test_records[3][3]["account_head"], 0.0, 130.31], - [test_records[3][4]["account_head"], 0.0, 2.61], - [test_records[3][5]["account_head"], 0.0, 1.31], - [test_records[3][6]["account_head"], 0.0, 25.96], - [test_records[3][7]["account_head"], 0.0, 145.43], - [test_records[3][8]["account_head"], 0.0, 116.35], - [test_records[3][9]["account_head"], 0.0, 100], - [test_records[3][10]["account_head"], 168.54, 0.0], + [si.debit_to, 1500, 0.0], + [test_records[3]["entries"][0]["income_account"], 0.0, 1163.45], + [test_records[3]["other_charges"][0]["account_head"], 0.0, 130.31], + [test_records[3]["other_charges"][1]["account_head"], 0.0, 2.61], + [test_records[3]["other_charges"][2]["account_head"], 0.0, 1.31], + [test_records[3]["other_charges"][3]["account_head"], 0.0, 25.96], + [test_records[3]["other_charges"][4]["account_head"], 0.0, 145.43], + [test_records[3]["other_charges"][5]["account_head"], 0.0, 116.35], + [test_records[3]["other_charges"][6]["account_head"], 0.0, 100], + [test_records[3]["other_charges"][7]["account_head"], 168.54, 0.0], ["_Test Account Service Tax - _TC", 16.88, 0.0], ]) @@ -238,53 +222,53 @@ class TestSalesInvoice(unittest.TestCase): # cancel si.cancel() - gle = frappe.db.sql("""select * from `tabGL Entry` - where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name) + gle = frappe.db.sql("""select * from `tabGL Entry` + where voucher_type='Sales Invoice' and voucher_no=%s""", si.name) self.assertFalse(gle) def test_inclusive_rate_validations(self): - si = frappe.bean(copy=test_records[2]) - for i, tax in enumerate(si.doclist.get({"parentfield": "other_charges"})): + si = frappe.copy_doc(test_records[2]) + for i, tax in enumerate(si.get("other_charges")): tax.idx = i+1 - - si.doclist[1].price_list_rate = 62.5 - si.doclist[1].price_list_rate = 191 - for i in [3, 5, 6, 7, 8, 9]: - si.doclist[i].included_in_print_rate = 1 - + + si.get("entries")[0].price_list_rate = 62.5 + si.get("entries")[0].price_list_rate = 191 + for i in xrange(6): + si.get("other_charges")[i].included_in_print_rate = 1 + # tax type "Actual" cannot be inclusive self.assertRaises(frappe.ValidationError, si.insert) - + # taxes above included type 'On Previous Row Total' should also be included - si.doclist[3].included_in_print_rate = 0 + si.get("other_charges")[0].included_in_print_rate = 0 self.assertRaises(frappe.ValidationError, si.insert) - + def test_sales_invoice_calculation_base_currency_with_tax_inclusive_price(self): # prepare - si = frappe.bean(copy=test_records[3]) + si = frappe.copy_doc(test_records[3]) si.insert() - + expected_values = { - "keys": ["price_list_rate", "discount_percentage", "rate", "amount", + "keys": ["price_list_rate", "discount_percentage", "rate", "amount", "base_price_list_rate", "base_rate", "base_amount"], "_Test Item Home Desktop 100": [62.5, 0, 62.5, 625.0, 50, 50, 499.98], "_Test Item Home Desktop 200": [190.66, 0, 190.66, 953.3, 150, 150, 750], } - + # check if children are saved - self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), + self.assertEquals(len(si.get("entries")), len(expected_values)-1) - + # check if item values are calculated - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): for i, k in enumerate(expected_values["keys"]): - self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) - + self.assertEquals(d.get(k), expected_values[d.item_code][i]) + # check net total - self.assertEquals(si.doc.net_total, 1249.98) - self.assertEquals(si.doc.net_total_export, 1578.3) - + self.assertEquals(si.net_total, 1249.98) + self.assertEquals(si.net_total_export, 1578.3) + # check tax calculation expected_values = { "keys": ["tax_amount", "total"], @@ -297,47 +281,46 @@ class TestSalesInvoice(unittest.TestCase): "_Test Account Shipping Charges - _TC": [100, 1803.31], "_Test Account Discount - _TC": [-180.33, 1622.98] } - - for d in si.doclist.get({"parentfield": "other_charges"}): + + for d in si.get("other_charges"): for i, k in enumerate(expected_values["keys"]): - self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) - - self.assertEquals(si.doc.grand_total, 1622.98) - self.assertEquals(si.doc.grand_total_export, 1622.98) - + self.assertEquals(d.get(k), expected_values[d.account_head][i]) + + self.assertEquals(si.grand_total, 1622.98) + self.assertEquals(si.grand_total_export, 1622.98) + def test_sales_invoice_calculation_export_currency_with_tax_inclusive_price(self): # prepare - si = frappe.bean(copy=test_records[3]) - si.doc.currency = "USD" - si.doc.conversion_rate = 50 - si.doclist[1].price_list_rate = 55.56 - si.doclist[1].discount_percentage = 10 - si.doclist[2].price_list_rate = 187.5 - si.doclist[2].discount_percentage = 20 - si.doclist[9].rate = 5000 - + si = frappe.copy_doc(test_records[3]) + si.currency = "USD" + si.conversion_rate = 50 + si.get("entries")[0].price_list_rate = 55.56 + si.get("entries")[0].discount_percentage = 10 + si.get("entries")[1].price_list_rate = 187.5 + si.get("entries")[1].discount_percentage = 20 + si.get("other_charges")[6].rate = 5000 + si.insert() - + expected_values = { - "keys": ["price_list_rate", "discount_percentage", "rate", "amount", + "keys": ["price_list_rate", "discount_percentage", "rate", "amount", "base_price_list_rate", "base_rate", "base_amount"], "_Test Item Home Desktop 100": [55.56, 10, 50, 500, 2222.11, 1999.9, 19999.04], "_Test Item Home Desktop 200": [187.5, 20, 150, 750, 7375.66, 5900.53, 29502.66], } - + # check if children are saved - self.assertEquals(len(si.doclist.get({"parentfield": "entries"})), - len(expected_values)-1) - + self.assertEquals(len(si.get("entries")), len(expected_values)-1) + # check if item values are calculated - for d in si.doclist.get({"parentfield": "entries"}): + for d in si.get("entries"): for i, k in enumerate(expected_values["keys"]): - self.assertEquals(d.fields.get(k), expected_values[d.item_code][i]) - + self.assertEquals(d.get(k), expected_values[d.item_code][i]) + # check net total - self.assertEquals(si.doc.net_total, 49501.7) - self.assertEquals(si.doc.net_total_export, 1250) - + self.assertEquals(si.net_total, 49501.7) + self.assertEquals(si.net_total_export, 1250) + # check tax calculation expected_values = { "keys": ["tax_amount", "total"], @@ -350,328 +333,325 @@ class TestSalesInvoice(unittest.TestCase): "_Test Account Shipping Charges - _TC": [5000, 72450.17], "_Test Account Discount - _TC": [-7245.01, 65205.16] } - - for d in si.doclist.get({"parentfield": "other_charges"}): + + for d in si.get("other_charges"): for i, k in enumerate(expected_values["keys"]): - self.assertEquals(d.fields.get(k), expected_values[d.account_head][i]) - - self.assertEquals(si.doc.grand_total, 65205.16) - self.assertEquals(si.doc.grand_total_export, 1304.1) + self.assertEquals(d.get(k), expected_values[d.account_head][i]) + + self.assertEquals(si.grand_total, 65205.16) + self.assertEquals(si.grand_total_export, 1304.1) def test_outstanding(self): w = self.make() - self.assertEquals(w.doc.outstanding_amount, w.doc.grand_total) - + self.assertEquals(w.outstanding_amount, w.grand_total) + def test_payment(self): frappe.db.sql("""delete from `tabGL Entry`""") w = self.make() - + from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \ import test_records as jv_test_records - - jv = frappe.bean(frappe.copy_doclist(jv_test_records[0])) - jv.doclist[1].against_invoice = w.doc.name + + jv = frappe.get_doc(frappe.copy_doc(jv_test_records[0])) + jv.get("entries")[0].against_invoice = w.name jv.insert() jv.submit() - - self.assertEquals(frappe.db.get_value("Sales Invoice", w.doc.name, "outstanding_amount"), + + self.assertEquals(frappe.db.get_value("Sales Invoice", w.name, "outstanding_amount"), 161.8) - + jv.cancel() - self.assertEquals(frappe.db.get_value("Sales Invoice", w.doc.name, "outstanding_amount"), + self.assertEquals(frappe.db.get_value("Sales Invoice", w.name, "outstanding_amount"), 561.8) - + def test_time_log_batch(self): - tlb = frappe.bean("Time Log Batch", "_T-Time Log Batch-00001") + tlb = frappe.get_doc("Time Log Batch", "_T-Time Log Batch-00001") tlb.submit() - - si = frappe.bean(frappe.copy_doclist(test_records[0])) - si.doclist[1].time_log_batch = "_T-Time Log Batch-00001" + + si = frappe.get_doc(frappe.copy_doc(test_records[0])) + si.get("entries")[0].time_log_batch = "_T-Time Log Batch-00001" si.insert() si.submit() - + self.assertEquals(frappe.db.get_value("Time Log Batch", "_T-Time Log Batch-00001", "status"), "Billed") - self.assertEquals(frappe.db.get_value("Time Log", "_T-Time Log-00001", "status"), + self.assertEquals(frappe.db.get_value("Time Log", "_T-Time Log-00001", "status"), "Billed") si.cancel() - self.assertEquals(frappe.db.get_value("Time Log Batch", "_T-Time Log Batch-00001", + self.assertEquals(frappe.db.get_value("Time Log Batch", "_T-Time Log Batch-00001", "status"), "Submitted") - self.assertEquals(frappe.db.get_value("Time Log", "_T-Time Log-00001", "status"), + self.assertEquals(frappe.db.get_value("Time Log", "_T-Time Log-00001", "status"), "Batched for Billing") - + def test_sales_invoice_gl_entry_without_aii(self): self.clear_stock_account_balance() set_perpetual_inventory(0) - si = frappe.bean(copy=test_records[1]) + si = frappe.copy_doc(test_records[1]) si.insert() si.submit() - + gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s - order by account asc""", si.doc.name, as_dict=1) - + order by account asc""", si.name, as_dict=1) + self.assertTrue(gl_entries) - + expected_values = sorted([ - [si.doc.debit_to, 630.0, 0.0], - [test_records[1][1]["income_account"], 0.0, 500.0], - [test_records[1][2]["account_head"], 0.0, 80.0], - [test_records[1][3]["account_head"], 0.0, 50.0], + [si.debit_to, 630.0, 0.0], + [test_records[1]["entries"][0]["income_account"], 0.0, 500.0], + [test_records[1]["other_charges"][0]["account_head"], 0.0, 80.0], + [test_records[1]["other_charges"][1]["account_head"], 0.0, 50.0], ]) - + for i, gle in enumerate(gl_entries): self.assertEquals(expected_values[i][0], gle.account) self.assertEquals(expected_values[i][1], gle.debit) self.assertEquals(expected_values[i][2], gle.credit) - + # cancel si.cancel() - - gle = frappe.db.sql("""select * from `tabGL Entry` - where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name) - + + gle = frappe.db.sql("""select * from `tabGL Entry` + where voucher_type='Sales Invoice' and voucher_no=%s""", si.name) + self.assertFalse(gle) - + def test_pos_gl_entry_with_aii(self): self.clear_stock_account_balance() set_perpetual_inventory() - + self._insert_purchase_receipt() self._insert_pos_settings() - - pos = frappe.copy_doclist(test_records[1]) - pos[0]["is_pos"] = 1 - pos[0]["update_stock"] = 1 - pos[0]["posting_time"] = "12:05" - pos[0]["cash_bank_account"] = "_Test Account Bank Account - _TC" - pos[0]["paid_amount"] = 600.0 - si = frappe.bean(copy=pos) + pos = copy.deepcopy(test_records[1]) + pos["is_pos"] = 1 + pos["update_stock"] = 1 + pos["posting_time"] = "12:05" + pos["cash_bank_account"] = "_Test Account Bank Account - _TC" + pos["paid_amount"] = 600.0 + + si = frappe.copy_doc(pos) si.insert() si.submit() - + # check stock ledger entries - sle = frappe.db.sql("""select * from `tabStock Ledger Entry` - where voucher_type = 'Sales Invoice' and voucher_no = %s""", - si.doc.name, as_dict=1)[0] + sle = frappe.db.sql("""select * from `tabStock Ledger Entry` + where voucher_type = 'Sales Invoice' and voucher_no = %s""", + si.name, as_dict=1)[0] self.assertTrue(sle) - self.assertEquals([sle.item_code, sle.warehouse, sle.actual_qty], + self.assertEquals([sle.item_code, sle.warehouse, sle.actual_qty], ["_Test Item", "_Test Warehouse - _TC", -1.0]) - + # check gl entries gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s - order by account asc, debit asc""", si.doc.name, as_dict=1) + order by account asc, debit asc""", si.name, as_dict=1) self.assertTrue(gl_entries) - + stock_in_hand = frappe.db.get_value("Account", {"master_name": "_Test Warehouse - _TC"}) - + expected_gl_entries = sorted([ - [si.doc.debit_to, 630.0, 0.0], - [pos[1]["income_account"], 0.0, 500.0], - [pos[2]["account_head"], 0.0, 80.0], - [pos[3]["account_head"], 0.0, 50.0], + [si.debit_to, 630.0, 0.0], + [pos["entries"][0]["income_account"], 0.0, 500.0], + [pos["other_charges"][0]["account_head"], 0.0, 80.0], + [pos["other_charges"][1]["account_head"], 0.0, 50.0], [stock_in_hand, 0.0, 75.0], - [pos[1]["expense_account"], 75.0, 0.0], - [si.doc.debit_to, 0.0, 600.0], + [pos["entries"][0]["expense_account"], 75.0, 0.0], + [si.debit_to, 0.0, 600.0], ["_Test Account Bank Account - _TC", 600.0, 0.0] ]) for i, gle in enumerate(gl_entries): self.assertEquals(expected_gl_entries[i][0], gle.account) self.assertEquals(expected_gl_entries[i][1], gle.debit) self.assertEquals(expected_gl_entries[i][2], gle.credit) - + si.cancel() - gle = frappe.db.sql("""select * from `tabGL Entry` - where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name) - + gle = frappe.db.sql("""select * from `tabGL Entry` + where voucher_type='Sales Invoice' and voucher_no=%s""", si.name) + self.assertFalse(gle) - + self.assertFalse(get_stock_and_account_difference([stock_in_hand])) - + set_perpetual_inventory(0) - + def test_si_gl_entry_with_aii_and_update_stock_with_warehouse_but_no_account(self): self.clear_stock_account_balance() set_perpetual_inventory() frappe.delete_doc("Account", "_Test Warehouse No Account - _TC") - + # insert purchase receipt from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \ as pr_test_records - pr = frappe.bean(copy=pr_test_records[0]) - pr.doc.naming_series = "_T-Purchase Receipt-" - pr.doclist[1].warehouse = "_Test Warehouse No Account - _TC" + pr = frappe.copy_doc(pr_test_records[0]) + pr.naming_series = "_T-Purchase Receipt-" + pr.get("purchase_receipt_details")[0].warehouse = "_Test Warehouse No Account - _TC" pr.insert() pr.submit() - - si_doclist = frappe.copy_doclist(test_records[1]) - si_doclist[0]["update_stock"] = 1 - si_doclist[0]["posting_time"] = "12:05" - si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC" - si = frappe.bean(copy=si_doclist) + si_doc = copy.deepcopy(test_records[1]) + si_doc["update_stock"] = 1 + si_doc["posting_time"] = "12:05" + si_doc.get("entries")[0]["warehouse"] = "_Test Warehouse No Account - _TC" + + si = frappe.copy_doc(si_doc) si.insert() si.submit() - + # check stock ledger entries - sle = frappe.db.sql("""select * from `tabStock Ledger Entry` - where voucher_type = 'Sales Invoice' and voucher_no = %s""", - si.doc.name, as_dict=1)[0] + sle = frappe.db.sql("""select * from `tabStock Ledger Entry` + where voucher_type = 'Sales Invoice' and voucher_no = %s""", + si.name, as_dict=1)[0] self.assertTrue(sle) - self.assertEquals([sle.item_code, sle.warehouse, sle.actual_qty], + self.assertEquals([sle.item_code, sle.warehouse, sle.actual_qty], ["_Test Item", "_Test Warehouse No Account - _TC", -1.0]) - + # check gl entries gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s - order by account asc, debit asc""", si.doc.name, as_dict=1) + order by account asc, debit asc""", si.name, as_dict=1) self.assertTrue(gl_entries) - + expected_gl_entries = sorted([ - [si.doc.debit_to, 630.0, 0.0], - [si_doclist[1]["income_account"], 0.0, 500.0], - [si_doclist[2]["account_head"], 0.0, 80.0], - [si_doclist[3]["account_head"], 0.0, 50.0], + [si.debit_to, 630.0, 0.0], + [si_doc.get("entries")[0]["income_account"], 0.0, 500.0], + [si_doc.get("other_charges")[0]["account_head"], 0.0, 80.0], + [si_doc.get("other_charges")[1]["account_head"], 0.0, 50.0], ]) for i, gle in enumerate(gl_entries): self.assertEquals(expected_gl_entries[i][0], gle.account) self.assertEquals(expected_gl_entries[i][1], gle.debit) self.assertEquals(expected_gl_entries[i][2], gle.credit) - + si.cancel() - gle = frappe.db.sql("""select * from `tabGL Entry` - where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name) - + gle = frappe.db.sql("""select * from `tabGL Entry` + where voucher_type='Sales Invoice' and voucher_no=%s""", si.name) + self.assertFalse(gle) set_perpetual_inventory(0) - + def test_sales_invoice_gl_entry_with_aii_no_item_code(self): self.clear_stock_account_balance() set_perpetual_inventory() - - si_copy = frappe.copy_doclist(test_records[1]) - si_copy[1]["item_code"] = None - si = frappe.bean(si_copy) + + si = frappe.get_doc(test_records[1]) + si.get("entries")[0].item_code = None si.insert() si.submit() - + gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s - order by account asc""", si.doc.name, as_dict=1) + order by account asc""", si.name, as_dict=1) self.assertTrue(gl_entries) - + expected_values = sorted([ - [si.doc.debit_to, 630.0, 0.0], - [test_records[1][1]["income_account"], 0.0, 500.0], - [test_records[1][2]["account_head"], 0.0, 80.0], - [test_records[1][3]["account_head"], 0.0, 50.0], + [si.debit_to, 630.0, 0.0], + [test_records[1]["entries"][0]["income_account"], 0.0, 500.0], + [test_records[1]["other_charges"][0]["account_head"], 0.0, 80.0], + [test_records[1]["other_charges"][1]["account_head"], 0.0, 50.0], ]) for i, gle in enumerate(gl_entries): self.assertEquals(expected_values[i][0], gle.account) self.assertEquals(expected_values[i][1], gle.debit) self.assertEquals(expected_values[i][2], gle.credit) - + set_perpetual_inventory(0) - + def test_sales_invoice_gl_entry_with_aii_non_stock_item(self): self.clear_stock_account_balance() set_perpetual_inventory() - si_copy = frappe.copy_doclist(test_records[1]) - si_copy[1]["item_code"] = "_Test Non Stock Item" - si = frappe.bean(si_copy) + si = frappe.get_doc(test_records[1]) + si.get("entries")[0].item_code = "_Test Non Stock Item" si.insert() si.submit() - + gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s - order by account asc""", si.doc.name, as_dict=1) + order by account asc""", si.name, as_dict=1) self.assertTrue(gl_entries) - + expected_values = sorted([ - [si.doc.debit_to, 630.0, 0.0], - [test_records[1][1]["income_account"], 0.0, 500.0], - [test_records[1][2]["account_head"], 0.0, 80.0], - [test_records[1][3]["account_head"], 0.0, 50.0], + [si.debit_to, 630.0, 0.0], + [test_records[1]["entries"][0]["income_account"], 0.0, 500.0], + [test_records[1]["other_charges"][0]["account_head"], 0.0, 80.0], + [test_records[1]["other_charges"][1]["account_head"], 0.0, 50.0], ]) for i, gle in enumerate(gl_entries): self.assertEquals(expected_values[i][0], gle.account) self.assertEquals(expected_values[i][1], gle.debit) self.assertEquals(expected_values[i][2], gle.credit) - + set_perpetual_inventory(0) - + def _insert_purchase_receipt(self): from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \ as pr_test_records - pr = frappe.bean(copy=pr_test_records[0]) - pr.doc.naming_series = "_T-Purchase Receipt-" + pr = frappe.copy_doc(pr_test_records[0]) + pr.naming_series = "_T-Purchase Receipt-" pr.insert() pr.submit() - + def _insert_delivery_note(self): from erpnext.stock.doctype.delivery_note.test_delivery_note import test_records \ as dn_test_records - dn = frappe.bean(copy=dn_test_records[0]) - dn.doc.naming_series = "_T-Delivery Note-" + dn = frappe.copy_doc(dn_test_records[0]) + dn.naming_series = "_T-Delivery Note-" dn.insert() dn.submit() return dn - + def _insert_pos_settings(self): from erpnext.accounts.doctype.pos_setting.test_pos_setting \ import test_records as pos_setting_test_records frappe.db.sql("""delete from `tabPOS Setting`""") - - ps = frappe.bean(copy=pos_setting_test_records[0]) + + ps = frappe.copy_doc(pos_setting_test_records[0]) ps.insert() - + def test_sales_invoice_with_advance(self): from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \ import test_records as jv_test_records - - jv = frappe.bean(copy=jv_test_records[0]) + + jv = frappe.copy_doc(jv_test_records[0]) jv.insert() jv.submit() - - si = frappe.bean(copy=test_records[0]) - si.doclist.append({ + + si = frappe.copy_doc(test_records[0]) + si.append("advance_adjustment_details", { "doctype": "Sales Invoice Advance", - "parentfield": "advance_adjustment_details", - "journal_voucher": jv.doc.name, - "jv_detail_no": jv.doclist[1].name, + "journal_voucher": jv.name, + "jv_detail_no": jv.get("entries")[0].name, "advance_amount": 400, "allocated_amount": 300, - "remarks": jv.doc.remark + "remarks": jv.remark }) si.insert() si.submit() si.load_from_db() - + self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail` - where against_invoice=%s""", si.doc.name)) - + where against_invoice=%s""", si.name)) + self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail` - where against_invoice=%s and credit=300""", si.doc.name)) - - self.assertEqual(si.doc.outstanding_amount, 261.8) - + where against_invoice=%s and credit=300""", si.name)) + + self.assertEqual(si.outstanding_amount, 261.8) + si.cancel() - + self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail` - where against_invoice=%s""", si.doc.name)) - + where against_invoice=%s""", si.name)) + def test_recurring_invoice(self): from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate from erpnext.accounts.utils import get_fiscal_year today = nowdate() - base_si = frappe.bean(copy=test_records[0]) - base_si.doc.fields.update({ + base_si = frappe.copy_doc(test_records[0]) + base_si.update({ "convert_into_recurring_invoice": 1, "recurring_type": "Monthly", "notification_email_address": "test@example.com, test1@example.com, test2@example.com", @@ -681,26 +661,26 @@ class TestSalesInvoice(unittest.TestCase): "invoice_period_from_date": get_first_day(today), "invoice_period_to_date": get_last_day(today) }) - + # monthly - si1 = frappe.bean(copy=base_si.doclist) + si1 = frappe.copy_doc(base_si) si1.insert() si1.submit() self._test_recurring_invoice(si1, True) - + # monthly without a first and last day period - si2 = frappe.bean(copy=base_si.doclist) - si2.doc.fields.update({ + si2 = frappe.copy_doc(base_si) + si2.update({ "invoice_period_from_date": today, "invoice_period_to_date": add_to_date(today, days=30) }) si2.insert() si2.submit() self._test_recurring_invoice(si2, False) - + # quarterly - si3 = frappe.bean(copy=base_si.doclist) - si3.doc.fields.update({ + si3 = frappe.copy_doc(base_si) + si3.update({ "recurring_type": "Quarterly", "invoice_period_from_date": get_first_day(today), "invoice_period_to_date": get_last_day(add_to_date(today, months=3)) @@ -708,10 +688,10 @@ class TestSalesInvoice(unittest.TestCase): si3.insert() si3.submit() self._test_recurring_invoice(si3, True) - + # quarterly without a first and last day period - si4 = frappe.bean(copy=base_si.doclist) - si4.doc.fields.update({ + si4 = frappe.copy_doc(base_si) + si4.update({ "recurring_type": "Quarterly", "invoice_period_from_date": today, "invoice_period_to_date": add_to_date(today, months=3) @@ -719,10 +699,10 @@ class TestSalesInvoice(unittest.TestCase): si4.insert() si4.submit() self._test_recurring_invoice(si4, False) - + # yearly - si5 = frappe.bean(copy=base_si.doclist) - si5.doc.fields.update({ + si5 = frappe.copy_doc(base_si) + si5.update({ "recurring_type": "Yearly", "invoice_period_from_date": get_first_day(today), "invoice_period_to_date": get_last_day(add_to_date(today, years=1)) @@ -730,10 +710,10 @@ class TestSalesInvoice(unittest.TestCase): si5.insert() si5.submit() self._test_recurring_invoice(si5, True) - + # yearly without a first and last day period - si6 = frappe.bean(copy=base_si.doclist) - si6.doc.fields.update({ + si6 = frappe.copy_doc(base_si) + si6.update({ "recurring_type": "Yearly", "invoice_period_from_date": today, "invoice_period_to_date": add_to_date(today, years=1) @@ -741,69 +721,69 @@ class TestSalesInvoice(unittest.TestCase): si6.insert() si6.submit() self._test_recurring_invoice(si6, False) - + # change posting date but keep recuring day to be today - si7 = frappe.bean(copy=base_si.doclist) - si7.doc.fields.update({ + si7 = frappe.copy_doc(base_si) + si7.update({ "posting_date": add_to_date(today, days=-1) }) si7.insert() si7.submit() - + # setting so that _test function works - si7.doc.posting_date = today + si7.posting_date = today self._test_recurring_invoice(si7, True) def _test_recurring_invoice(self, base_si, first_and_last_day): from frappe.utils import add_months, get_last_day from erpnext.accounts.doctype.sales_invoice.sales_invoice \ import manage_recurring_invoices, get_next_date - - no_of_months = ({"Monthly": 1, "Quarterly": 3, "Yearly": 12})[base_si.doc.recurring_type] - + + no_of_months = ({"Monthly": 1, "Quarterly": 3, "Yearly": 12})[base_si.recurring_type] + def _test(i): self.assertEquals(i+1, frappe.db.sql("""select count(*) from `tabSales Invoice` - where recurring_id=%s and docstatus=1""", base_si.doc.recurring_id)[0][0]) - - next_date = get_next_date(base_si.doc.posting_date, no_of_months, - base_si.doc.repeat_on_day_of_month) + where recurring_id=%s and docstatus=1""", base_si.recurring_id)[0][0]) + + next_date = get_next_date(base_si.posting_date, no_of_months, + base_si.repeat_on_day_of_month) manage_recurring_invoices(next_date=next_date, commit=False) - + recurred_invoices = frappe.db.sql("""select name from `tabSales Invoice` where recurring_id=%s and docstatus=1 order by name desc""", - base_si.doc.recurring_id) - + base_si.recurring_id) + self.assertEquals(i+2, len(recurred_invoices)) - - new_si = frappe.bean("Sales Invoice", recurred_invoices[0][0]) - + + new_si = frappe.get_doc("Sales Invoice", recurred_invoices[0][0]) + for fieldname in ["convert_into_recurring_invoice", "recurring_type", "repeat_on_day_of_month", "notification_email_address"]: - self.assertEquals(base_si.doc.fields.get(fieldname), - new_si.doc.fields.get(fieldname)) + self.assertEquals(base_si.get(fieldname), + new_si.get(fieldname)) + + self.assertEquals(new_si.posting_date, unicode(next_date)) + + self.assertEquals(new_si.invoice_period_from_date, + unicode(add_months(base_si.invoice_period_from_date, no_of_months))) - self.assertEquals(new_si.doc.posting_date, unicode(next_date)) - - self.assertEquals(new_si.doc.invoice_period_from_date, - unicode(add_months(base_si.doc.invoice_period_from_date, no_of_months))) - if first_and_last_day: - self.assertEquals(new_si.doc.invoice_period_to_date, - unicode(get_last_day(add_months(base_si.doc.invoice_period_to_date, + self.assertEquals(new_si.invoice_period_to_date, + unicode(get_last_day(add_months(base_si.invoice_period_to_date, no_of_months)))) else: - self.assertEquals(new_si.doc.invoice_period_to_date, - unicode(add_months(base_si.doc.invoice_period_to_date, no_of_months))) - - + self.assertEquals(new_si.invoice_period_to_date, + unicode(add_months(base_si.invoice_period_to_date, no_of_months))) + + return new_si - + # if yearly, test 1 repetition, else test 5 repetitions count = 1 if (no_of_months == 12) else 5 for i in xrange(count): base_si = _test(i) - + def clear_stock_account_balance(self): frappe.db.sql("delete from `tabStock Ledger Entry`") frappe.db.sql("delete from tabBin") @@ -812,439 +792,56 @@ class TestSalesInvoice(unittest.TestCase): def test_serialized(self): from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos - + se = make_serialized_item() - serial_nos = get_serial_nos(se.doclist[1].serial_no) - - si = frappe.bean(copy=test_records[0]) - si.doc.update_stock = 1 - si.doclist[1].item_code = "_Test Serialized Item With Series" - si.doclist[1].qty = 1 - si.doclist[1].serial_no = serial_nos[0] + serial_nos = get_serial_nos(se.get("mtn_details")[0].serial_no) + + si = frappe.copy_doc(test_records[0]) + si.update_stock = 1 + si.get("entries")[0].item_code = "_Test Serialized Item With Series" + si.get("entries")[0].qty = 1 + si.get("entries")[0].serial_no = serial_nos[0] si.insert() si.submit() - + self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], "status"), "Delivered") self.assertFalse(frappe.db.get_value("Serial No", serial_nos[0], "warehouse")) - self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], - "delivery_document_no"), si.doc.name) - + self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], + "delivery_document_no"), si.name) + return si - + def test_serialized_cancel(self): from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos si = self.test_serialized() si.cancel() - serial_nos = get_serial_nos(si.doclist[1].serial_no) + serial_nos = get_serial_nos(si.get("entries")[0].serial_no) self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], "status"), "Available") self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], "warehouse"), "_Test Warehouse - _TC") - self.assertFalse(frappe.db.get_value("Serial No", serial_nos[0], + self.assertFalse(frappe.db.get_value("Serial No", serial_nos[0], "delivery_document_no")) def test_serialize_status(self): from erpnext.stock.doctype.serial_no.serial_no import SerialNoStatusError, get_serial_nos from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item - + se = make_serialized_item() - serial_nos = get_serial_nos(se.doclist[1].serial_no) - - sr = frappe.bean("Serial No", serial_nos[0]) - sr.doc.status = "Not Available" + serial_nos = get_serial_nos(se.get("mtn_details")[0].serial_no) + + sr = frappe.get_doc("Serial No", serial_nos[0]) + sr.status = "Not Available" sr.save() - - si = frappe.bean(copy=test_records[0]) - si.doc.update_stock = 1 - si.doclist[1].item_code = "_Test Serialized Item With Series" - si.doclist[1].qty = 1 - si.doclist[1].serial_no = serial_nos[0] + + si = frappe.copy_doc(test_records[0]) + si.update_stock = 1 + si.get("entries")[0].item_code = "_Test Serialized Item With Series" + si.get("entries")[0].qty = 1 + si.get("entries")[0].serial_no = serial_nos[0] si.insert() self.assertRaises(SerialNoStatusError, si.submit) test_dependencies = ["Journal Voucher", "POS Setting", "Contact", "Address"] - -test_records = [ - [ - { - "naming_series": "_T-Sales Invoice-", - "company": "_Test Company", - "is_pos": 0, - "conversion_rate": 1.0, - "currency": "INR", - "debit_to": "_Test Customer - _TC", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total": 561.8, - "grand_total_export": 561.8, - "net_total": 500.0, - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory" - }, - { - "base_amount": 500.0, - "base_rate": 500.0, - "description": "138-CMS Shoe", - "doctype": "Sales Invoice Item", - "amount": 500.0, - "rate": 500.0, - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - "item_name": "138-CMS Shoe", - "parentfield": "entries", - "qty": 1.0 - }, - { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 6, - }, - { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 6.36, - }, - { - "parentfield": "sales_team", - "doctype": "Sales Team", - "sales_person": "_Test Sales Person 1", - "allocated_percentage": 65.5, - }, - { - "parentfield": "sales_team", - "doctype": "Sales Team", - "sales_person": "_Test Sales Person 2", - "allocated_percentage": 34.5, - }, - ], - [ - { - "naming_series": "_T-Sales Invoice-", - "company": "_Test Company", - "is_pos": 0, - "conversion_rate": 1.0, - "currency": "INR", - "debit_to": "_Test Customer - _TC", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total": 630.0, - "grand_total_export": 630.0, - "net_total": 500.0, - "plc_conversion_rate": 1.0, - "posting_date": "2013-03-07", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory" - }, - { - "item_code": "_Test Item", - "item_name": "_Test Item", - "description": "_Test Item", - "doctype": "Sales Invoice Item", - "parentfield": "entries", - "qty": 1.0, - "base_rate": 500.0, - "base_amount": 500.0, - "price_list_rate": 500.0, - "amount": 500.0, - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "cost_center": "_Test Cost Center - _TC", - }, - { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 16, - }, - { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 10 - } - ], - [ - { - "naming_series": "_T-Sales Invoice-", - "company": "_Test Company", - "is_pos": 0, - "conversion_rate": 1.0, - "currency": "INR", - "debit_to": "_Test Customer - _TC", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total_export": 0, - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory", - }, - # items - { - "doctype": "Sales Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "qty": 10, - "price_list_rate": 50, - "rate": 50, - "stock_uom": "_Test UOM", - "item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}), - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - - }, - { - "doctype": "Sales Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "qty": 5, - "price_list_rate": 150, - "rate": 150, - "stock_uom": "_Test UOM", - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - - }, - # taxes - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "rate": 100 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Customs Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "rate": 10 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Excise Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "rate": 12 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "rate": 2, - "row_id": 3 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account S&H Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "rate": 1, - "row_id": 3 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account CST - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "rate": 2, - "row_id": 5 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account VAT - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "rate": 12.5 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account Discount - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "rate": -10, - "row_id": 7 - }, - ], - [ - { - "naming_series": "_T-Sales Invoice-", - "company": "_Test Company", - "is_pos": 0, - "conversion_rate": 1.0, - "currency": "INR", - "debit_to": "_Test Customer - _TC", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total_export": 0, - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory", - }, - # items - { - "doctype": "Sales Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "qty": 10, - "price_list_rate": 62.5, - "stock_uom": "_Test UOM", - "item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}), - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - - }, - { - "doctype": "Sales Invoice Item", - "parentfield": "entries", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "qty": 5, - "price_list_rate": 190.66, - "stock_uom": "_Test UOM", - "income_account": "Sales - _TC", - "cost_center": "_Test Cost Center - _TC", - - }, - # taxes - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Excise Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "rate": 12, - "included_in_print_rate": 1, - "idx": 1 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "rate": 2, - "row_id": 1, - "included_in_print_rate": 1, - "idx": 2 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account S&H Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "rate": 1, - "row_id": 1, - "included_in_print_rate": 1, - "idx": 3 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account CST - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "rate": 2, - "row_id": 3, - "included_in_print_rate": 1, - "idx": 4 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account VAT - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "rate": 12.5, - "included_in_print_rate": 1, - "idx": 5 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Customs Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "rate": 10, - "idx": 6 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "rate": 100, - "idx": 7 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account Discount - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "rate": -10, - "row_id": 7, - "idx": 8 - }, - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Sales Invoice') diff --git a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.json b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.json new file mode 100644 index 00000000000..15bac1d50e5 --- /dev/null +++ b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.json @@ -0,0 +1,88 @@ +{ + "creation": "2013-02-22 01:27:41.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "journal_voucher", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Journal Voucher", + "no_copy": 1, + "oldfieldname": "journal_voucher", + "oldfieldtype": "Link", + "options": "Journal Voucher", + "permlevel": 0, + "print_width": "250px", + "read_only": 1, + "width": "250px" + }, + { + "fieldname": "remarks", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Remarks", + "no_copy": 1, + "oldfieldname": "remarks", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "jv_detail_no", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Journal Voucher Detail No", + "no_copy": 1, + "oldfieldname": "jv_detail_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "120px", + "read_only": 1, + "width": "120px" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "advance_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Advance amount", + "no_copy": 1, + "oldfieldname": "advance_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_width": "120px", + "read_only": 1, + "width": "120px" + }, + { + "fieldname": "allocated_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Allocated amount", + "no_copy": 1, + "oldfieldname": "allocated_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_width": "120px", + "width": "120px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-03 12:38:53.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Invoice Advance", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py index 26c87f1c04a..683ca8a00a7 100644 --- a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py +++ b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesInvoiceAdvance(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.txt b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.txt deleted file mode 100644 index f0f361d098f..00000000000 --- a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.txt +++ /dev/null @@ -1,101 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:41", - "docstatus": 0, - "modified": "2014-02-03 12:38:53", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales Invoice Advance", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Sales Invoice Advance" - }, - { - "doctype": "DocField", - "fieldname": "journal_voucher", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Journal Voucher", - "no_copy": 1, - "oldfieldname": "journal_voucher", - "oldfieldtype": "Link", - "options": "Journal Voucher", - "print_width": "250px", - "read_only": 1, - "width": "250px" - }, - { - "doctype": "DocField", - "fieldname": "remarks", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Remarks", - "no_copy": 1, - "oldfieldname": "remarks", - "oldfieldtype": "Small Text", - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "jv_detail_no", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Journal Voucher Detail No", - "no_copy": 1, - "oldfieldname": "jv_detail_no", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "120px", - "read_only": 1, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "advance_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Advance amount", - "no_copy": 1, - "oldfieldname": "advance_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_width": "120px", - "read_only": 1, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "allocated_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Allocated amount", - "no_copy": 1, - "oldfieldname": "allocated_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_width": "120px", - "width": "120px" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json new file mode 100644 index 00000000000..527213be01d --- /dev/null +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -0,0 +1,464 @@ +{ + "autoname": "INVD.######", + "creation": "2013-06-04 11:02:19.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "barcode", + "fieldtype": "Data", + "in_list_view": 0, + "label": "Barcode", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_filter": 0, + "in_list_view": 0, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "customer_item_code", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Customer's Item Code", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "200px", + "read_only": 0, + "reqd": 1, + "width": "200px" + }, + { + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Quantity and Rate", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Quantity", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate", + "oldfieldname": "ref_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "discount_percentage", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Discount (%)", + "oldfieldname": "adj_rate", + "oldfieldtype": "Float", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "options": "UOM", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "base_price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate (Company Currency)", + "oldfieldname": "base_ref_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "section_break1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "rate", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "export_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "export_amount", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "base_rate", + "fieldtype": "Currency", + "in_filter": 0, + "in_list_view": 0, + "label": "Rate (Company Currency)", + "oldfieldname": "basic_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "base_amount", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Amount (Company Currency)", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "pricing_rule_for_price", + "fieldtype": "Link", + "label": "Pricing Rule For Price", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "pricing_rule_for_discount", + "fieldtype": "Link", + "label": "Pricing Rule For Discount", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "accounting", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Accounting", + "permlevel": 0 + }, + { + "fieldname": "income_account", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 0, + "label": "Income Account", + "oldfieldname": "income_account", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "print_hide": 1, + "print_width": "120px", + "read_only": 0, + "reqd": 1, + "width": "120px" + }, + { + "fieldname": "expense_account", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "in_list_view": 0, + "label": "Expense Account", + "options": "Account", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "120px" + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": ":Company", + "fieldname": "cost_center", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 0, + "label": "Cost Center", + "oldfieldname": "cost_center", + "oldfieldtype": "Link", + "options": "Cost Center", + "permlevel": 0, + "print_hide": 1, + "print_width": "120px", + "read_only": 0, + "reqd": 0, + "width": "120px" + }, + { + "fieldname": "warehouse_and_reference", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Warehouse and Reference", + "permlevel": 0 + }, + { + "fieldname": "warehouse", + "fieldtype": "Link", + "hidden": 0, + "in_list_view": 0, + "label": "Warehouse", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "serial_no", + "fieldtype": "Small Text", + "in_filter": 1, + "in_list_view": 1, + "label": "Serial No", + "oldfieldname": "serial_no", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "batch_no", + "fieldtype": "Link", + "label": "Batch No", + "options": "Batch", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "brand", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "label": "Brand Name", + "oldfieldname": "brand", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "item_tax_rate", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Item Tax Rate", + "oldfieldname": "item_tax_rate", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "col_break5", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "actual_qty", + "fieldtype": "Float", + "label": "Available Qty at Warehouse", + "oldfieldname": "actual_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "time_log_batch", + "fieldtype": "Link", + "label": "Time Log Batch", + "options": "Time Log Batch", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "sales_order", + "fieldtype": "Link", + "in_filter": 1, + "label": "Sales Order", + "no_copy": 1, + "oldfieldname": "sales_order", + "oldfieldtype": "Link", + "options": "Sales Order", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "so_detail", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "label": "Sales Order Item", + "no_copy": 1, + "oldfieldname": "so_detail", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "delivery_note", + "fieldtype": "Link", + "in_filter": 1, + "label": "Delivery Note", + "no_copy": 1, + "oldfieldname": "delivery_note", + "oldfieldtype": "Link", + "options": "Delivery Note", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "dn_detail", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "label": "Delivery Note Item", + "no_copy": 1, + "oldfieldname": "dn_detail", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "delivered_qty", + "fieldtype": "Float", + "label": "Delivered Qty", + "oldfieldname": "delivered_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "label": "Page Break", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-28 11:04:19.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Invoice Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py index 26c87f1c04a..3fa0f2e0e5a 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesInvoiceItem(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.txt b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.txt deleted file mode 100644 index 224f7b7c690..00000000000 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.txt +++ /dev/null @@ -1,477 +0,0 @@ -[ - { - "creation": "2013-06-04 11:02:19", - "docstatus": 0, - "modified": "2014-02-28 11:04:19", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "INVD.######", - "doctype": "DocType", - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales Invoice Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Sales Invoice Item" - }, - { - "doctype": "DocField", - "fieldname": "barcode", - "fieldtype": "Data", - "in_list_view": 0, - "label": "Barcode", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "print_hide": 0, - "read_only": 0, - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_filter": 0, - "in_list_view": 0, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "customer_item_code", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Customer's Item Code", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "print_width": "200px", - "read_only": 0, - "reqd": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Quantity and Rate" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Quantity", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate", - "oldfieldname": "ref_rate", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "discount_percentage", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Discount (%)", - "oldfieldname": "adj_rate", - "oldfieldtype": "Float", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "options": "UOM", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "base_price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate (Company Currency)", - "oldfieldname": "base_ref_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "export_rate", - "oldfieldtype": "Currency", - "options": "currency", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "export_amount", - "oldfieldtype": "Currency", - "options": "currency", - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "base_rate", - "fieldtype": "Currency", - "in_filter": 0, - "in_list_view": 0, - "label": "Rate (Company Currency)", - "oldfieldname": "basic_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "base_amount", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Amount (Company Currency)", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_price", - "fieldtype": "Link", - "label": "Pricing Rule For Price", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_discount", - "fieldtype": "Link", - "label": "Pricing Rule For Discount", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "accounting", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Accounting" - }, - { - "doctype": "DocField", - "fieldname": "income_account", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 0, - "label": "Income Account", - "oldfieldname": "income_account", - "oldfieldtype": "Link", - "options": "Account", - "print_hide": 1, - "print_width": "120px", - "read_only": 0, - "reqd": 1, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "expense_account", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "in_list_view": 0, - "label": "Expense Account", - "options": "Account", - "print_hide": 1, - "read_only": 0, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "col_break4", - "fieldtype": "Column Break" - }, - { - "default": ":Company", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 0, - "label": "Cost Center", - "oldfieldname": "cost_center", - "oldfieldtype": "Link", - "options": "Cost Center", - "print_hide": 1, - "print_width": "120px", - "read_only": 0, - "reqd": 0, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "warehouse_and_reference", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Warehouse and Reference" - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "hidden": 0, - "in_list_view": 0, - "label": "Warehouse", - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Small Text", - "in_filter": 1, - "in_list_view": 1, - "label": "Serial No", - "oldfieldname": "serial_no", - "oldfieldtype": "Small Text", - "print_hide": 0, - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "batch_no", - "fieldtype": "Link", - "label": "Batch No", - "options": "Batch", - "print_hide": 1, - "read_only": 0 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "label": "Brand Name", - "oldfieldname": "brand", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "item_tax_rate", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Item Tax Rate", - "oldfieldname": "item_tax_rate", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break5", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "actual_qty", - "fieldtype": "Float", - "label": "Available Qty at Warehouse", - "oldfieldname": "actual_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "time_log_batch", - "fieldtype": "Link", - "label": "Time Log Batch", - "options": "Time Log Batch", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "sales_order", - "fieldtype": "Link", - "in_filter": 1, - "label": "Sales Order", - "no_copy": 1, - "oldfieldname": "sales_order", - "oldfieldtype": "Link", - "options": "Sales Order", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "so_detail", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "label": "Sales Order Item", - "no_copy": 1, - "oldfieldname": "so_detail", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "delivery_note", - "fieldtype": "Link", - "in_filter": 1, - "label": "Delivery Note", - "no_copy": 1, - "oldfieldname": "delivery_note", - "oldfieldtype": "Link", - "options": "Delivery Note", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "dn_detail", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "label": "Delivery Note Item", - "no_copy": 1, - "oldfieldname": "dn_detail", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "delivered_qty", - "fieldtype": "Float", - "label": "Delivered Qty", - "oldfieldname": "delivered_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "page_break", - "fieldtype": "Check", - "label": "Page Break", - "no_copy": 1, - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json new file mode 100644 index 00000000000..cd02e81a56a --- /dev/null +++ b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json @@ -0,0 +1,153 @@ +{ + "autoname": "INVTD.######", + "creation": "2013-04-24 11:39:32.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "charge_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Type", + "oldfieldname": "charge_type", + "oldfieldtype": "Select", + "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "row_id", + "fieldtype": "Data", + "hidden": 0, + "label": "Enter Row", + "oldfieldname": "row_id", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "reqd": 1, + "width": "300px" + }, + { + "fieldname": "col_break_1", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "account_head", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Account Head", + "oldfieldname": "account_head", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "default": ":Company", + "fieldname": "cost_center", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Cost Center", + "oldfieldname": "cost_center_other_charges", + "oldfieldtype": "Link", + "options": "Cost Center", + "permlevel": 0 + }, + { + "fieldname": "rate", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "tax_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "tax_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "total", + "fieldtype": "Currency", + "label": "Total", + "oldfieldname": "total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "allow_on_submit": 0, + "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", + "fieldname": "included_in_print_rate", + "fieldtype": "Check", + "label": "Is this Tax included in Basic Rate?", + "no_copy": 0, + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "report_hide": 1, + "width": "150px" + }, + { + "fieldname": "tax_amount_after_discount_amount", + "fieldtype": "Currency", + "hidden": 1, + "label": "Tax Amount After Discount Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "item_wise_tax_detail", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Item Wise Tax Detail", + "oldfieldname": "item_wise_tax_detail", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "parenttype", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "label": "Parenttype", + "oldfieldname": "parenttype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "search_index": 1 + } + ], + "hide_heading": 1, + "idx": 1, + "istable": 1, + "modified": "2014-01-03 15:04:25.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Taxes and Charges", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py index 26c87f1c04a..f4a94485349 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py +++ b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesTaxesandCharges(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt deleted file mode 100644 index 8bb154cb7f5..00000000000 --- a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt +++ /dev/null @@ -1,166 +0,0 @@ -[ - { - "creation": "2013-04-24 11:39:32", - "docstatus": 0, - "modified": "2014-01-03 15:04:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "INVTD.######", - "doctype": "DocType", - "hide_heading": 1, - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales Taxes and Charges", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Sales Taxes and Charges" - }, - { - "doctype": "DocField", - "fieldname": "charge_type", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Type", - "oldfieldname": "charge_type", - "oldfieldtype": "Select", - "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "row_id", - "fieldtype": "Data", - "hidden": 0, - "label": "Enter Row", - "oldfieldname": "row_id", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "print_width": "300px", - "reqd": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "col_break_1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "account_head", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Account Head", - "oldfieldname": "account_head", - "oldfieldtype": "Link", - "options": "Account", - "reqd": 1, - "search_index": 1 - }, - { - "default": ":Company", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Cost Center", - "oldfieldname": "cost_center_other_charges", - "oldfieldtype": "Link", - "options": "Cost Center" - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "rate", - "oldfieldtype": "Currency", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "tax_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "tax_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "total", - "fieldtype": "Currency", - "label": "Total", - "oldfieldname": "total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "allow_on_submit": 0, - "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", - "doctype": "DocField", - "fieldname": "included_in_print_rate", - "fieldtype": "Check", - "label": "Is this Tax included in Basic Rate?", - "no_copy": 0, - "print_hide": 1, - "print_width": "150px", - "report_hide": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "tax_amount_after_discount_amount", - "fieldtype": "Currency", - "hidden": 1, - "label": "Tax Amount After Discount Amount", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_wise_tax_detail", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Item Wise Tax Detail", - "oldfieldname": "item_wise_tax_detail", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "parenttype", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "label": "Parenttype", - "oldfieldname": "parenttype", - "oldfieldtype": "Data", - "print_hide": 1, - "search_index": 1 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js index 6f35f4af886..f4b425b84bf 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js @@ -54,7 +54,7 @@ cur_frm.pformat.other_charges= function(doc){ out =''; if (!doc.print_without_amount) { - var cl = getchildren('Sales Taxes and Charges', doc.name, 'other_charges'); + var cl = doc.other_charges || []; // outer table var out='
%(item_code)s%(item_name)s
'; diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.json b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.json new file mode 100644 index 00000000000..81cd189d35d --- /dev/null +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.json @@ -0,0 +1,121 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:title", + "creation": "2013-01-10 16:34:09.000000", + "description": "Standard tax template that can be applied to all Sales Transactions. This template can contain list of tax heads and also other expense / income heads like \"Shipping\", \"Insurance\", \"Handling\" etc.\n\n#### Note\n\nThe tax rate you define here will be the standard tax rate for all **Items**. If there are **Items** that have different rates, they must be added in the **Item Tax** table in the **Item** master.\n\n#### Description of Columns\n\n1. Calculation Type: \n - This can be on **Net Total** (that is the sum of basic amount).\n - **On Previous Row Total / Amount** (for cumulative taxes or charges). If you select this option, the tax will be applied as a percentage of the previous row (in the tax table) amount or total.\n - **Actual** (as mentioned).\n2. Account Head: The Account ledger under which this tax will be booked\n3. Cost Center: If the tax / charge is an income (like shipping) or expense it needs to be booked against a Cost Center.\n4. Description: Description of the tax (that will be printed in invoices / quotes).\n5. Rate: Tax rate.\n6. Amount: Tax amount.\n7. Total: Cumulative total to this point.\n8. Enter Row: If based on \"Previous Row Total\" you can select the row number which will be taken as a base for this calculation (default is the previous row).\n9. Is this Tax included in Basic Rate?: If you check this, it means that this tax will not be shown below the item table, but will be included in the Basic Rate in your main item table. This is useful where you want give a flat price (inclusive of all taxes) price to customers.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "title", + "fieldtype": "Data", + "in_filter": 1, + "label": "Title", + "oldfieldname": "title", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "is_default", + "fieldtype": "Check", + "label": "Default", + "permlevel": 0 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "section_break_5", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "description": "* Will be calculated in the transaction.", + "fieldname": "other_charges", + "fieldtype": "Table", + "label": "Sales Taxes and Charges Master", + "oldfieldname": "other_charges", + "oldfieldtype": "Table", + "options": "Sales Taxes and Charges", + "permlevel": 0 + }, + { + "description": "Specify a list of Territories, for which, this Taxes Master is valid", + "fieldname": "valid_for_territories", + "fieldtype": "Table", + "label": "Valid for Territories", + "options": "Applicable Territory", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-money", + "idx": 1, + "modified": "2014-01-28 12:28:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Taxes and Charges Master", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py index 047bbd4f11b..f63a767ba55 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py @@ -6,12 +6,12 @@ import frappe from frappe.utils import cint from frappe.model.controller import DocListController -class DocType(DocListController): +class SalesTaxesandChargesMaster(DocListController): def validate(self): - if self.doc.is_default == 1: + if self.is_default == 1: frappe.db.sql("""update `tabSales Taxes and Charges Master` set is_default = 0 where ifnull(is_default,0) = 1 and name != %s and company = %s""", - (self.doc.name, self.doc.company)) + (self.name, self.company)) # at least one territory self.validate_table_has_rows("valid_for_territories") \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt deleted file mode 100644 index db83cce2681..00000000000 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt +++ /dev/null @@ -1,126 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:09", - "docstatus": 0, - "modified": "2014-01-28 12:28:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:title", - "description": "Standard tax template that can be applied to all Sales Transactions. This template can contain list of tax heads and also other expense / income heads like \"Shipping\", \"Insurance\", \"Handling\" etc.\n\n#### Note\n\nThe tax rate you define here will be the standard tax rate for all **Items**. If there are **Items** that have different rates, they must be added in the **Item Tax** table in the **Item** master.\n\n#### Description of Columns\n\n1. Calculation Type: \n - This can be on **Net Total** (that is the sum of basic amount).\n - **On Previous Row Total / Amount** (for cumulative taxes or charges). If you select this option, the tax will be applied as a percentage of the previous row (in the tax table) amount or total.\n - **Actual** (as mentioned).\n2. Account Head: The Account ledger under which this tax will be booked\n3. Cost Center: If the tax / charge is an income (like shipping) or expense it needs to be booked against a Cost Center.\n4. Description: Description of the tax (that will be printed in invoices / quotes).\n5. Rate: Tax rate.\n6. Amount: Tax amount.\n7. Total: Cumulative total to this point.\n8. Enter Row: If based on \"Previous Row Total\" you can select the row number which will be taken as a base for this calculation (default is the previous row).\n9. Is this Tax included in Basic Rate?: If you check this, it means that this tax will not be shown below the item table, but will be included in the Basic Rate in your main item table. This is useful where you want give a flat price (inclusive of all taxes) price to customers.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-money", - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales Taxes and Charges Master", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Sales Taxes and Charges Master", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Sales Taxes and Charges Master" - }, - { - "doctype": "DocField", - "fieldname": "title", - "fieldtype": "Data", - "in_filter": 1, - "label": "Title", - "oldfieldname": "title", - "oldfieldtype": "Data", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "is_default", - "fieldtype": "Check", - "label": "Default" - }, - { - "doctype": "DocField", - "fieldname": "column_break_3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_5", - "fieldtype": "Section Break" - }, - { - "description": "* Will be calculated in the transaction.", - "doctype": "DocField", - "fieldname": "other_charges", - "fieldtype": "Table", - "label": "Sales Taxes and Charges Master", - "oldfieldname": "other_charges", - "oldfieldtype": "Table", - "options": "Sales Taxes and Charges" - }, - { - "description": "Specify a list of Territories, for which, this Taxes Master is valid", - "doctype": "DocField", - "fieldname": "valid_for_territories", - "fieldtype": "Table", - "label": "Valid for Territories", - "options": "Applicable Territory", - "reqd": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Accounts Manager", - "write": 1 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/test_records.json b/erpnext/accounts/doctype/sales_taxes_and_charges_master/test_records.json new file mode 100644 index 00000000000..dda8a4aa8f5 --- /dev/null +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/test_records.json @@ -0,0 +1,157 @@ +[ + { + "company": "_Test Company", + "doctype": "Sales Taxes and Charges Master", + "other_charges": [ + { + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 6 + }, + { + "account_head": "_Test Account Service Tax - _TC", + "charge_type": "On Net Total", + "description": "Service Tax", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 6.36 + } + ], + "title": "_Test Sales Taxes and Charges Master", + "valid_for_territories": [ + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "All Territories" + }, + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "_Test Territory Rest Of The World" + } + ] + }, + { + "company": "_Test Company", + "doctype": "Sales Taxes and Charges Master", + "other_charges": [ + { + "account_head": "_Test Account Shipping Charges - _TC", + "charge_type": "Actual", + "cost_center": "_Test Cost Center - _TC", + "description": "Shipping Charges", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 100 + }, + { + "account_head": "_Test Account Customs Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Customs Duty", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 10 + }, + { + "account_head": "_Test Account Excise Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Excise Duty", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 12 + }, + { + "account_head": "_Test Account Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "Education Cess", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 2, + "row_id": 3 + }, + { + "account_head": "_Test Account S&H Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "S&H Education Cess", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 1, + "row_id": 3 + }, + { + "account_head": "_Test Account CST - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "CST", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 2, + "row_id": 5 + }, + { + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 12.5 + }, + { + "account_head": "_Test Account Discount - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Discount", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": -10, + "row_id": 7 + } + ], + "title": "_Test India Tax Master", + "valid_for_territories": [ + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "_Test Territory India" + } + ] + }, + { + "company": "_Test Company", + "doctype": "Sales Taxes and Charges Master", + "other_charges": [ + { + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 12 + }, + { + "account_head": "_Test Account Service Tax - _TC", + "charge_type": "On Net Total", + "description": "Service Tax", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 4 + } + ], + "title": "_Test Sales Taxes and Charges Master - Rest of the World", + "valid_for_territories": [ + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "_Test Territory Rest Of The World" + } + ] + } +] \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/test_sales_taxes_and_charges_master.py b/erpnext/accounts/doctype/sales_taxes_and_charges_master/test_sales_taxes_and_charges_master.py index 670edc44e00..e31474d37f1 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/test_sales_taxes_and_charges_master.py +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/test_sales_taxes_and_charges_master.py @@ -1,154 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [ - { - "doctype": "Sales Taxes and Charges Master", - "title": "_Test Sales Taxes and Charges Master", - "company": "_Test Company" - }, - { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 6, - }, - { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 6.36, - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "All Territories" - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory Rest Of The World" - } - ], - [ - { - "doctype": "Sales Taxes and Charges Master", - "title": "_Test India Tax Master", - "company": "_Test Company" - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "Actual", - "account_head": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "rate": 100 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Customs Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "rate": 10 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account Excise Duty - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "rate": 12 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "rate": 2, - "row_id": 3 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Amount", - "account_head": "_Test Account S&H Education Cess - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "rate": 1, - "row_id": 3 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account CST - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "rate": 2, - "row_id": 5 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Net Total", - "account_head": "_Test Account VAT - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "rate": 12.5 - }, - { - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "charge_type": "On Previous Row Total", - "account_head": "_Test Account Discount - _TC", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "rate": -10, - "row_id": 7 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory India" - } - ], - [ - { - "doctype": "Sales Taxes and Charges Master", - "title": "_Test Sales Taxes and Charges Master - Rest of the World", - "company": "_Test Company" - }, - { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 12, - }, - { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 4, - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory Rest Of The World" - } - ], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Sales Taxes And Charges Master') \ No newline at end of file diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.json b/erpnext/accounts/doctype/shipping_rule/shipping_rule.json new file mode 100644 index 00000000000..d46bfdf37da --- /dev/null +++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.json @@ -0,0 +1,154 @@ +{ + "autoname": "Prompt", + "creation": "2013-06-25 11:48:03.000000", + "description": "Specify conditions to calculate shipping amount", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "example: Next Day Shipping", + "fieldname": "label", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Shipping Rule Label", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "column_break_2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": "Net Total", + "fieldname": "calculate_based_on", + "fieldtype": "Select", + "hidden": 1, + "in_list_view": 1, + "label": "Calculate Based On", + "options": "Net Total\nNet Weight", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "rule_conditions_section", + "fieldtype": "Section Break", + "label": "Shipping Rule Conditions", + "permlevel": 0 + }, + { + "fieldname": "shipping_rule_conditions", + "fieldtype": "Table", + "label": "Shipping Rule Conditions", + "options": "Shipping Rule Condition", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "section_break_6", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "description": "Specify a list of Territories, for which, this Shipping Rule is valid", + "fieldname": "valid_for_territories", + "fieldtype": "Table", + "label": "Valid For Territories", + "options": "Applicable Territory", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "column_break_8", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Company", + "options": "Company", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "section_break_10", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "account", + "fieldtype": "Link", + "label": "Shipping Account", + "options": "Account", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "column_break_12", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "cost_center", + "fieldtype": "Link", + "label": "Cost Center", + "options": "Cost Center", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-truck", + "idx": 1, + "modified": "2014-01-20 17:49:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Shipping Rule", + "owner": "Administrator", + "permissions": [ + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User" + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User" + }, + { + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "write": 1 + }, + { + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py index fe5d7f9010e..3cef9920b17 100644 --- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py +++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py @@ -14,13 +14,11 @@ class OverlappingConditionError(frappe.ValidationError): pass class FromGreaterThanToError(frappe.ValidationError): pass class ManyBlankToValuesError(frappe.ValidationError): pass -class DocType(DocListController): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +class ShippingRule(DocListController): def validate(self): self.validate_value("calculate_based_on", "in", ["Net Total", "Net Weight"]) - self.shipping_rule_conditions = self.doclist.get({"parentfield": "shipping_rule_conditions"}) + self.shipping_rule_conditions = self.get("shipping_rule_conditions") self.validate_from_to_values() self.sort_shipping_rule_conditions() self.validate_overlapping_shipping_rule_conditions() @@ -28,14 +26,14 @@ class DocType(DocListController): def validate_from_to_values(self): zero_to_values = [] - for d in self.shipping_rule_conditions: + for d in self.get("shipping_rule_conditions"): self.round_floats_in(d) # values cannot be negative self.validate_value("from_value", ">=", 0.0, d) self.validate_value("to_value", ">=", 0.0, d) - if d.to_value == 0: + if not d.to_value: zero_to_values.append(d) elif d.from_value >= d.to_value: msgprint(_("Error") + ": " + _("Row") + " # %d: " % d.idx + @@ -68,7 +66,7 @@ class DocType(DocListController): for i in xrange(0, len(self.shipping_rule_conditions)): for j in xrange(i+1, len(self.shipping_rule_conditions)): d1, d2 = self.shipping_rule_conditions[i], self.shipping_rule_conditions[j] - if d1.fields != d2.fields: + if d1.as_dict() != d2.as_dict(): # in our case, to_value can be zero, hence pass the from_value if so range_a = (d1.from_value, d1.to_value or d1.from_value) range_b = (d2.from_value, d2.to_value or d2.from_value) @@ -76,7 +74,7 @@ class DocType(DocListController): overlaps.append([d1, d2]) if overlaps: - company_currency = get_company_currency(self.doc.company) + company_currency = get_company_currency(self.company) msgprint(_("Error") + ": " + _("Overlapping Conditions found between") + ":") messages = [] for d1, d2 in overlaps: diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.txt b/erpnext/accounts/doctype/shipping_rule/shipping_rule.txt deleted file mode 100644 index c1e2e90bb7d..00000000000 --- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.txt +++ /dev/null @@ -1,161 +0,0 @@ -[ - { - "creation": "2013-06-25 11:48:03", - "docstatus": 0, - "modified": "2014-01-20 17:49:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "Prompt", - "description": "Specify conditions to calculate shipping amount", - "doctype": "DocType", - "icon": "icon-truck", - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Shipping Rule", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Shipping Rule", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Shipping Rule" - }, - { - "description": "example: Next Day Shipping", - "doctype": "DocField", - "fieldname": "label", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Shipping Rule Label", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_2", - "fieldtype": "Column Break" - }, - { - "default": "Net Total", - "doctype": "DocField", - "fieldname": "calculate_based_on", - "fieldtype": "Select", - "hidden": 1, - "in_list_view": 1, - "label": "Calculate Based On", - "options": "Net Total\nNet Weight", - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "rule_conditions_section", - "fieldtype": "Section Break", - "label": "Shipping Rule Conditions" - }, - { - "doctype": "DocField", - "fieldname": "shipping_rule_conditions", - "fieldtype": "Table", - "label": "Shipping Rule Conditions", - "options": "Shipping Rule Condition", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break_6", - "fieldtype": "Section Break" - }, - { - "description": "Specify a list of Territories, for which, this Shipping Rule is valid", - "doctype": "DocField", - "fieldname": "valid_for_territories", - "fieldtype": "Table", - "label": "Valid For Territories", - "options": "Applicable Territory", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_8", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Company", - "options": "Company", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break_10", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "account", - "fieldtype": "Link", - "label": "Shipping Account", - "options": "Account", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_12", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "label": "Cost Center", - "options": "Cost Center", - "reqd": 1 - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Accounts User" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Accounts Manager", - "write": 1 - }, - { - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/shipping_rule/test_records.json b/erpnext/accounts/doctype/shipping_rule/test_records.json new file mode 100644 index 00000000000..5477c8f9573 --- /dev/null +++ b/erpnext/accounts/doctype/shipping_rule/test_records.json @@ -0,0 +1,116 @@ +[ + { + "account": "_Test Account Shipping Charges - _TC", + "calculate_based_on": "Net Total", + "company": "_Test Company", + "cost_center": "_Test Cost Center - _TC", + "doctype": "Shipping Rule", + "label": "_Test Shipping Rule", + "name": "_Test Shipping Rule", + "shipping_rule_conditions": [ + { + "doctype": "Shipping Rule Condition", + "from_value": 0, + "parentfield": "shipping_rule_conditions", + "shipping_amount": 50.0, + "to_value": 100 + }, + { + "doctype": "Shipping Rule Condition", + "from_value": 101, + "parentfield": "shipping_rule_conditions", + "shipping_amount": 100.0, + "to_value": 200 + }, + { + "doctype": "Shipping Rule Condition", + "from_value": 201, + "parentfield": "shipping_rule_conditions", + "shipping_amount": 0.0 + } + ], + "valid_for_territories": [ + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "_Test Territory" + } + ] + }, + { + "account": "_Test Account Shipping Charges - _TC", + "calculate_based_on": "Net Total", + "company": "_Test Company", + "cost_center": "_Test Cost Center - _TC", + "doctype": "Shipping Rule", + "label": "_Test Shipping Rule - India", + "name": "_Test Shipping Rule - India", + "shipping_rule_conditions": [ + { + "doctype": "Shipping Rule Condition", + "from_value": 0, + "parentfield": "shipping_rule_conditions", + "shipping_amount": 50.0, + "to_value": 100 + }, + { + "doctype": "Shipping Rule Condition", + "from_value": 101, + "parentfield": "shipping_rule_conditions", + "shipping_amount": 100.0, + "to_value": 200 + }, + { + "doctype": "Shipping Rule Condition", + "from_value": 201, + "parentfield": "shipping_rule_conditions", + "shipping_amount": 0.0 + } + ], + "valid_for_territories": [ + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "_Test Territory India" + } + ] + }, + { + "account": "_Test Account Shipping Charges - _TC", + "calculate_based_on": "Net Total", + "company": "_Test Company", + "cost_center": "_Test Cost Center - _TC", + "doctype": "Shipping Rule", + "label": "_Test Shipping Rule - Rest of the World", + "name": "_Test Shipping Rule - Rest of the World", + "shipping_rule_conditions": [ + { + "doctype": "Shipping Rule Condition", + "from_value": 0, + "parentfield": "shipping_rule_conditions", + "shipping_amount": 500.0, + "to_value": 1000 + }, + { + "doctype": "Shipping Rule Condition", + "from_value": 1001, + "parentfield": "shipping_rule_conditions", + "shipping_amount": 1000.0, + "to_value": 2000 + }, + { + "doctype": "Shipping Rule Condition", + "from_value": 2001, + "parentfield": "shipping_rule_conditions", + "shipping_amount": 1500.0 + } + ], + "valid_for_territories": [ + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "_Test Territory Rest Of The World" + } + ] + } +] \ No newline at end of file diff --git a/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py index 40853471a7e..c53689e453e 100644 --- a/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py +++ b/erpnext/accounts/doctype/shipping_rule/test_shipping_rule.py @@ -5,15 +5,17 @@ import frappe import unittest from erpnext.accounts.doctype.shipping_rule.shipping_rule import FromGreaterThanToError, ManyBlankToValuesError, OverlappingConditionError +test_records = frappe.get_test_records('Shipping Rule') + class TestShippingRule(unittest.TestCase): def test_from_greater_than_to(self): - shipping_rule = frappe.bean(copy=test_records[0]) - shipping_rule.doclist[1].from_value = 101 + shipping_rule = frappe.copy_doc(test_records[0]) + shipping_rule.get("shipping_rule_conditions")[0].from_value = 101 self.assertRaises(FromGreaterThanToError, shipping_rule.insert) def test_many_zero_to_values(self): - shipping_rule = frappe.bean(copy=test_records[0]) - shipping_rule.doclist[1].to_value = 0 + shipping_rule = frappe.copy_doc(test_records[0]) + shipping_rule.get("shipping_rule_conditions")[0].to_value = 0 self.assertRaises(ManyBlankToValuesError, shipping_rule.insert) def test_overlapping_conditions(self): @@ -24,120 +26,9 @@ class TestShippingRule(unittest.TestCase): ((50, 150), (25, 175)), ((50, 150), (50, 150)), ]: - shipping_rule = frappe.bean(copy=test_records[0]) - shipping_rule.doclist[1].from_value = range_a[0] - shipping_rule.doclist[1].to_value = range_a[1] - shipping_rule.doclist[2].from_value = range_b[0] - shipping_rule.doclist[2].to_value = range_b[1] - self.assertRaises(OverlappingConditionError, shipping_rule.insert) - -test_records = [ - [ - { - "doctype": "Shipping Rule", - "label": "_Test Shipping Rule", - "name": "_Test Shipping Rule", - "calculate_based_on": "Net Total", - "company": "_Test Company", - "account": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 0, - "to_value": 100, - "shipping_amount": 50.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 101, - "to_value": 200, - "shipping_amount": 100.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 201, - "shipping_amount": 0.0 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory" - } - ], - [ - { - "doctype": "Shipping Rule", - "name": "_Test Shipping Rule - India", - "label": "_Test Shipping Rule - India", - "calculate_based_on": "Net Total", - "company": "_Test Company", - "account": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 0, - "to_value": 100, - "shipping_amount": 50.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 101, - "to_value": 200, - "shipping_amount": 100.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 201, - "shipping_amount": 0.0 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory India" - } - ], - [ - { - "doctype": "Shipping Rule", - "name": "_Test Shipping Rule - Rest of the World", - "label": "_Test Shipping Rule - Rest of the World", - "calculate_based_on": "Net Total", - "company": "_Test Company", - "account": "_Test Account Shipping Charges - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 0, - "to_value": 1000, - "shipping_amount": 500.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 1001, - "to_value": 2000, - "shipping_amount": 1000.0 - }, - { - "doctype": "Shipping Rule Condition", - "parentfield": "shipping_rule_conditions", - "from_value": 2001, - "shipping_amount": 1500.0 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory Rest Of The World" - } - ], -] \ No newline at end of file + shipping_rule = frappe.copy_doc(test_records[0]) + shipping_rule.get("shipping_rule_conditions")[0].from_value = range_a[0] + shipping_rule.get("shipping_rule_conditions")[0].to_value = range_a[1] + shipping_rule.get("shipping_rule_conditions")[1].from_value = range_b[0] + shipping_rule.get("shipping_rule_conditions")[1].to_value = range_b[1] + self.assertRaises(OverlappingConditionError, shipping_rule.insert) \ No newline at end of file diff --git a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.json b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.json new file mode 100644 index 00000000000..2d4cf2daba3 --- /dev/null +++ b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.json @@ -0,0 +1,40 @@ +{ + "creation": "2013-06-25 11:54:50.000000", + "description": "A condition for a Shipping Rule", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "from_value", + "fieldtype": "Float", + "in_list_view": 1, + "label": "From Value", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "to_value", + "fieldtype": "Float", + "in_list_view": 1, + "label": "To Value", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "shipping_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Shipping Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "reqd": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:21:46.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Shipping Rule Condition", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py index 968a25b6134..76d0a57b697 100644 --- a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py +++ b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ShippingRuleCondition(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt deleted file mode 100644 index 22af554466f..00000000000 --- a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt +++ /dev/null @@ -1,51 +0,0 @@ -[ - { - "creation": "2013-06-25 11:54:50", - "docstatus": 0, - "modified": "2013-12-20 19:21:46", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "A condition for a Shipping Rule", - "doctype": "DocType", - "istable": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Shipping Rule Condition", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Shipping Rule Condition" - }, - { - "doctype": "DocField", - "fieldname": "from_value", - "fieldtype": "Float", - "label": "From Value", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "to_value", - "fieldtype": "Float", - "label": "To Value", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "shipping_amount", - "fieldtype": "Currency", - "label": "Shipping Amount", - "options": "Company:company:default_currency", - "reqd": 1 - } -] \ No newline at end of file diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py index f2eef285ce5..d321d00e1ad 100644 --- a/erpnext/accounts/general_ledger.py +++ b/erpnext/accounts/general_ledger.py @@ -77,7 +77,7 @@ def save_entries(gl_map, adv_adj, update_outstanding): def make_entry(args, adv_adj, update_outstanding): args.update({"doctype": "GL Entry"}) - gle = frappe.bean([args]) + gle = frappe.get_doc(args) gle.ignore_permissions = 1 gle.insert() gle.run_method("on_update_with_args", adv_adj, update_outstanding) diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.json b/erpnext/accounts/page/accounts_browser/accounts_browser.json new file mode 100644 index 00000000000..7fb1815f70b --- /dev/null +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.json @@ -0,0 +1,22 @@ +{ + "creation": "2012-06-14 15:07:28.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-sitemap", + "idx": 1, + "modified": "2013-07-11 14:39:42.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Accounts Browser", + "owner": "Administrator", + "page_name": "Accounts Browser", + "roles": [ + { + "role": "Accounts User" + }, + { + "role": "Accounts Manager" + } + ], + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.txt b/erpnext/accounts/page/accounts_browser/accounts_browser.txt deleted file mode 100644 index e83759c44ef..00000000000 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.txt +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "creation": "2012-06-14 15:07:28", - "docstatus": 0, - "modified": "2013-07-11 14:39:42", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-sitemap", - "module": "Accounts", - "name": "__common__", - "page_name": "Accounts Browser", - "standard": "Yes" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "Accounts Browser", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "Accounts Browser" - }, - { - "doctype": "Page Role", - "role": "Accounts User" - }, - { - "doctype": "Page Role", - "role": "Accounts Manager" - } -] \ No newline at end of file diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.json b/erpnext/accounts/page/financial_analytics/financial_analytics.json new file mode 100644 index 00000000000..f551d82b1b6 --- /dev/null +++ b/erpnext/accounts/page/financial_analytics/financial_analytics.json @@ -0,0 +1,23 @@ +{ + "creation": "2013-01-27 16:30:52.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-bar-chart", + "idx": 1, + "modified": "2013-07-11 14:42:16.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "financial-analytics", + "owner": "Administrator", + "page_name": "financial-analytics", + "roles": [ + { + "role": "Analytics" + }, + { + "role": "Accounts Manager" + } + ], + "standard": "Yes", + "title": "Financial Analytics" +} \ No newline at end of file diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.txt b/erpnext/accounts/page/financial_analytics/financial_analytics.txt deleted file mode 100644 index 94a9b8e1bf7..00000000000 --- a/erpnext/accounts/page/financial_analytics/financial_analytics.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2013-01-27 16:30:52", - "docstatus": 0, - "modified": "2013-07-11 14:42:16", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-bar-chart", - "module": "Accounts", - "name": "__common__", - "page_name": "financial-analytics", - "standard": "Yes", - "title": "Financial Analytics" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "financial-analytics", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "financial-analytics" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Accounts Manager" - } -] \ No newline at end of file diff --git a/erpnext/accounts/page/trial_balance/trial_balance.json b/erpnext/accounts/page/trial_balance/trial_balance.json new file mode 100644 index 00000000000..72fb981f92e --- /dev/null +++ b/erpnext/accounts/page/trial_balance/trial_balance.json @@ -0,0 +1,23 @@ +{ + "creation": "2013-01-27 16:30:52.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-table", + "idx": 1, + "modified": "2013-07-11 14:44:49.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "trial-balance", + "owner": "Administrator", + "page_name": "trial-balance", + "roles": [ + { + "role": "Analytics" + }, + { + "role": "Accounts Manager" + } + ], + "standard": "Yes", + "title": "Trial Balance" +} \ No newline at end of file diff --git a/erpnext/accounts/page/trial_balance/trial_balance.txt b/erpnext/accounts/page/trial_balance/trial_balance.txt deleted file mode 100644 index f65146c8b29..00000000000 --- a/erpnext/accounts/page/trial_balance/trial_balance.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2013-01-27 16:30:52", - "docstatus": 0, - "modified": "2013-07-11 14:44:49", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Accounts", - "name": "__common__", - "page_name": "trial-balance", - "standard": "Yes", - "title": "Trial Balance" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "trial-balance", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "trial-balance" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Accounts Manager" - } -] \ No newline at end of file diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 97c22fd9e1c..601fcd11eed 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -25,13 +25,12 @@ def _get_party_details(party=None, account=None, party_type="Customer", company= if not ignore_permissions and not frappe.has_permission(party_type, "read", party): frappe.throw("Not Permitted", frappe.PermissionError) - party_bean = frappe.bean(party_type, party) - party = party_bean.doc + party = frappe.get_doc(party_type, party) set_address_details(out, party, party_type) set_contact_details(out, party, party_type) set_other_values(out, party, party_type) - set_price_list(out, party, price_list) + set_price_list(out, party, party_type, price_list) if not out.get("currency"): out["currency"] = currency @@ -41,7 +40,7 @@ def _get_party_details(party=None, account=None, party_type="Customer", company= out["sales_team"] = [{ "sales_person": d.sales_person, "sales_designation": d.sales_designation - } for d in party_bean.doclist.get({"doctype":"Sales Team"})] + } for d in party.get("sales_team")] return out @@ -81,7 +80,7 @@ def set_other_values(out, party, party_type): if party.get("default_" + f): out[f] = party.get("default_" + f) -def set_price_list(out, party, given_price_list): +def set_price_list(out, party, party_type, given_price_list): # price list price_list = get_restrictions().get("Price List") if isinstance(price_list, list): @@ -90,7 +89,7 @@ def set_price_list(out, party, given_price_list): if not price_list: price_list = party.default_price_list - if not price_list and party.party_type=="Customer": + if not price_list and party_type=="Customer": price_list = frappe.db.get_value("Customer Group", party.customer_group, "default_price_list") @@ -166,7 +165,7 @@ def create_party_account(party, party_type, company): frappe.throw(_("Please enter Account Receivable/Payable group in company master")) # create - account = frappe.bean({ + account = frappe.get_doc({ "doctype": "Account", 'account_name': party, 'parent_account': parent_account, @@ -178,4 +177,4 @@ def create_party_account(party, party_type, company): "report_type": "Balance Sheet" }).insert(ignore_permissions=True) - frappe.msgprint(_("Account Created") + ": " + account.doc.name) + frappe.msgprint(_("Account Created") + ": " + account.name) diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.json b/erpnext/accounts/report/accounts_payable/accounts_payable.json new file mode 100644 index 00000000000..82c9337993a --- /dev/null +++ b/erpnext/accounts/report/accounts_payable/accounts_payable.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-04-22 16:16:03.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Accounts Payable", + "owner": "Administrator", + "ref_doctype": "Purchase Invoice", + "report_name": "Accounts Payable", + "report_type": "Report Builder" +} \ No newline at end of file diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.txt b/erpnext/accounts/report/accounts_payable/accounts_payable.txt deleted file mode 100644 index 9d205103146..00000000000 --- a/erpnext/accounts/report/accounts_payable/accounts_payable.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-04-22 16:16:03", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Purchase Invoice", - "report_name": "Accounts Payable", - "report_type": "Report Builder" - }, - { - "doctype": "Report", - "name": "Accounts Payable" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.json b/erpnext/accounts/report/accounts_receivable/accounts_receivable.json new file mode 100644 index 00000000000..558a9fae04c --- /dev/null +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-04-16 11:31:13.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Accounts Receivable", + "owner": "Administrator", + "ref_doctype": "Sales Invoice", + "report_name": "Accounts Receivable", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.txt b/erpnext/accounts/report/accounts_receivable/accounts_receivable.txt deleted file mode 100644 index 6da3088abed..00000000000 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-04-16 11:31:13", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Sales Invoice", - "report_name": "Accounts Receivable", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Accounts Receivable" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.json b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.json new file mode 100644 index 00000000000..5768fb25a0b --- /dev/null +++ b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-05-01 12:13:25.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Bank Clearance Summary", + "owner": "Administrator", + "ref_doctype": "Journal Voucher", + "report_name": "Bank Clearance Summary", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.txt b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.txt deleted file mode 100644 index 3b462a0114a..00000000000 --- a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-05-01 12:13:25", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Journal Voucher", - "report_name": "Bank Clearance Summary", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Bank Clearance Summary" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.json b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.json new file mode 100644 index 00000000000..3da22e6a137 --- /dev/null +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 0, + "creation": "2013-04-30 18:30:21.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Bank Reconciliation Statement", + "owner": "Administrator", + "ref_doctype": "Journal Voucher", + "report_name": "Bank Reconciliation Statement", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.txt b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.txt deleted file mode 100644 index a2436a8eb00..00000000000 --- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-04-30 18:30:21", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 0, - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Journal Voucher", - "report_name": "Bank Reconciliation Statement", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Bank Reconciliation Statement" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/budget_variance_report/budget_variance_report.json b/erpnext/accounts/report/budget_variance_report/budget_variance_report.json new file mode 100644 index 00000000000..592ee6957ce --- /dev/null +++ b/erpnext/accounts/report/budget_variance_report/budget_variance_report.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-18 12:56:36.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Budget Variance Report", + "owner": "Administrator", + "ref_doctype": "Cost Center", + "report_name": "Budget Variance Report", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/budget_variance_report/budget_variance_report.txt b/erpnext/accounts/report/budget_variance_report/budget_variance_report.txt deleted file mode 100644 index be9ce13a22b..00000000000 --- a/erpnext/accounts/report/budget_variance_report/budget_variance_report.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-18 12:56:36", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Cost Center", - "report_name": "Budget Variance Report", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Budget Variance Report" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/customer_account_head/customer_account_head.json b/erpnext/accounts/report/customer_account_head/customer_account_head.json new file mode 100644 index 00000000000..c60f5940b1a --- /dev/null +++ b/erpnext/accounts/report/customer_account_head/customer_account_head.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-03 16:17:34.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Customer Account Head", + "owner": "Administrator", + "ref_doctype": "Account", + "report_name": "Customer Account Head", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/customer_account_head/customer_account_head.txt b/erpnext/accounts/report/customer_account_head/customer_account_head.txt deleted file mode 100644 index c2a856bb94d..00000000000 --- a/erpnext/accounts/report/customer_account_head/customer_account_head.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-03 16:17:34", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Account", - "report_name": "Customer Account Head", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Customer Account Head" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.json b/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.json new file mode 100644 index 00000000000..53af90726ed --- /dev/null +++ b/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-07-30 17:28:49.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Delivered Items To Be Billed", + "owner": "Administrator", + "query": "select\n `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n\t`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n\t`tabDelivery Note`.`posting_date` as \"Date:Date\",\n\t`tabDelivery Note`.`project_name` as \"Project\",\n\t`tabDelivery Note Item`.`item_code` as \"Item:Link/Item:120\",\n\t(`tabDelivery Note Item`.`qty` - ifnull((select sum(qty) from `tabSales Invoice Item` \n\t where `tabSales Invoice Item`.docstatus=1 and \n `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n\t `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\n\t\tas \"Qty:Float:110\",\n\t(`tabDelivery Note Item`.`base_amount` - ifnull((select sum(base_amount) from `tabSales Invoice Item` \n where `tabSales Invoice Item`.docstatus=1 and \n `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\n\t\tas \"Amount:Currency:110\",\n\t`tabDelivery Note Item`.`item_name` as \"Item Name::150\",\n\t`tabDelivery Note Item`.`description` as \"Description::200\"\nfrom `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n `tabDelivery Note`.docstatus = 1 and\n\t`tabDelivery Note`.`status` != \"Stopped\" and\n `tabDelivery Note`.name = `tabDelivery Note Item`.parent and\n (`tabDelivery Note Item`.qty > ifnull((select sum(qty) from `tabSales Invoice Item` \n where `tabSales Invoice Item`.docstatus=1 and \n `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\norder by `tabDelivery Note`.`name` desc", + "ref_doctype": "Sales Invoice", + "report_name": "Delivered Items To Be Billed", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.txt b/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.txt deleted file mode 100644 index a525d2df580..00000000000 --- a/erpnext/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-07-30 17:28:49", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "query": "select\n `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n\t`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n\t`tabDelivery Note`.`posting_date` as \"Date:Date\",\n\t`tabDelivery Note`.`project_name` as \"Project\",\n\t`tabDelivery Note Item`.`item_code` as \"Item:Link/Item:120\",\n\t(`tabDelivery Note Item`.`qty` - ifnull((select sum(qty) from `tabSales Invoice Item` \n\t where `tabSales Invoice Item`.docstatus=1 and \n `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n\t `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\n\t\tas \"Qty:Float:110\",\n\t(`tabDelivery Note Item`.`base_amount` - ifnull((select sum(base_amount) from `tabSales Invoice Item` \n where `tabSales Invoice Item`.docstatus=1 and \n `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\n\t\tas \"Amount:Currency:110\",\n\t`tabDelivery Note Item`.`item_name` as \"Item Name::150\",\n\t`tabDelivery Note Item`.`description` as \"Description::200\"\nfrom `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n `tabDelivery Note`.docstatus = 1 and\n\t`tabDelivery Note`.`status` != \"Stopped\" and\n `tabDelivery Note`.name = `tabDelivery Note Item`.parent and\n (`tabDelivery Note Item`.qty > ifnull((select sum(qty) from `tabSales Invoice Item` \n where `tabSales Invoice Item`.docstatus=1 and \n `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\norder by `tabDelivery Note`.`name` desc", - "ref_doctype": "Sales Invoice", - "report_name": "Delivered Items To Be Billed", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Delivered Items To Be Billed" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/general_ledger/general_ledger.json b/erpnext/accounts/report/general_ledger/general_ledger.json new file mode 100644 index 00000000000..59ac1a58d52 --- /dev/null +++ b/erpnext/accounts/report/general_ledger/general_ledger.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-12-06 13:22:23.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "General Ledger", + "owner": "Administrator", + "ref_doctype": "GL Entry", + "report_name": "General Ledger", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/general_ledger/general_ledger.txt b/erpnext/accounts/report/general_ledger/general_ledger.txt deleted file mode 100644 index cdfb033d0a7..00000000000 --- a/erpnext/accounts/report/general_ledger/general_ledger.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-12-06 13:22:23", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "GL Entry", - "report_name": "General Ledger", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "General Ledger" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/gross_profit/gross_profit.json b/erpnext/accounts/report/gross_profit/gross_profit.json new file mode 100644 index 00000000000..12293bc86a7 --- /dev/null +++ b/erpnext/accounts/report/gross_profit/gross_profit.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-02-25 17:03:34.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Gross Profit", + "owner": "Administrator", + "ref_doctype": "Sales Invoice", + "report_name": "Gross Profit", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/gross_profit/gross_profit.txt b/erpnext/accounts/report/gross_profit/gross_profit.txt deleted file mode 100644 index 56776600eb8..00000000000 --- a/erpnext/accounts/report/gross_profit/gross_profit.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-02-25 17:03:34", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Sales Invoice", - "report_name": "Gross Profit", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Gross Profit" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.json b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.json new file mode 100644 index 00000000000..f37db79de89 --- /dev/null +++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-06-05 15:37:30.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Item-wise Purchase Register", + "owner": "Administrator", + "ref_doctype": "Purchase Invoice", + "report_name": "Item-wise Purchase Register", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.txt b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.txt deleted file mode 100644 index 3dbd53614bb..00000000000 --- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-06-05 15:37:30", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Purchase Invoice", - "report_name": "Item-wise Purchase Register", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Item-wise Purchase Register" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.json b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.json new file mode 100644 index 00000000000..4dffc714c92 --- /dev/null +++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-05-13 17:50:55.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Item-wise Sales Register", + "owner": "Administrator", + "ref_doctype": "Sales Invoice", + "report_name": "Item-wise Sales Register", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.txt b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.txt deleted file mode 100644 index 8d30644c39c..00000000000 --- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-05-13 17:50:55", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Sales Invoice", - "report_name": "Item-wise Sales Register", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Item-wise Sales Register" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.json b/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.json new file mode 100644 index 00000000000..b734f0e09d9 --- /dev/null +++ b/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-02-21 14:26:44.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Ordered Items To Be Billed", + "owner": "Administrator", + "query": "select \n `tabSales Order`.`name` as \"Sales Order:Link/Sales Order:120\",\n `tabSales Order`.`customer` as \"Customer:Link/Customer:120\",\n `tabSales Order`.`status` as \"Status\",\n `tabSales Order`.`transaction_date` as \"Date:Date\",\n `tabSales Order`.`project_name` as \"Project\",\n `tabSales Order Item`.item_code as \"Item:Link/Item:120\",\n `tabSales Order Item`.base_amount as \"Amount:Currency:110\",\n (`tabSales Order Item`.billed_amt * ifnull(`tabSales Order`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabSales Order Item`.base_amount, 0) - (ifnull(`tabSales Order Item`.billed_amt, 0) * ifnull(`tabSales Order`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabSales Order Item`.item_name as \"Item Name::150\",\n `tabSales Order Item`.description as \"Description::200\"\nfrom\n `tabSales Order`, `tabSales Order Item`\nwhere\n `tabSales Order Item`.`parent` = `tabSales Order`.`name`\n and `tabSales Order`.docstatus = 1\n and `tabSales Order`.status != \"Stopped\"\n and ifnull(`tabSales Order Item`.billed_amt,0) < ifnull(`tabSales Order Item`.amount,0)\norder by `tabSales Order`.transaction_date asc", + "ref_doctype": "Sales Invoice", + "report_name": "Ordered Items To Be Billed", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.txt b/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.txt deleted file mode 100644 index 09b6cff9712..00000000000 --- a/erpnext/accounts/report/ordered_items_to_be_billed/ordered_items_to_be_billed.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-02-21 14:26:44", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "query": "select \n `tabSales Order`.`name` as \"Sales Order:Link/Sales Order:120\",\n `tabSales Order`.`customer` as \"Customer:Link/Customer:120\",\n `tabSales Order`.`status` as \"Status\",\n `tabSales Order`.`transaction_date` as \"Date:Date\",\n `tabSales Order`.`project_name` as \"Project\",\n `tabSales Order Item`.item_code as \"Item:Link/Item:120\",\n `tabSales Order Item`.base_amount as \"Amount:Currency:110\",\n (`tabSales Order Item`.billed_amt * ifnull(`tabSales Order`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabSales Order Item`.base_amount, 0) - (ifnull(`tabSales Order Item`.billed_amt, 0) * ifnull(`tabSales Order`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabSales Order Item`.item_name as \"Item Name::150\",\n `tabSales Order Item`.description as \"Description::200\"\nfrom\n `tabSales Order`, `tabSales Order Item`\nwhere\n `tabSales Order Item`.`parent` = `tabSales Order`.`name`\n and `tabSales Order`.docstatus = 1\n and `tabSales Order`.status != \"Stopped\"\n and ifnull(`tabSales Order Item`.billed_amt,0) < ifnull(`tabSales Order Item`.amount,0)\norder by `tabSales Order`.transaction_date asc", - "ref_doctype": "Sales Invoice", - "report_name": "Ordered Items To Be Billed", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Ordered Items To Be Billed" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.json b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.json new file mode 100644 index 00000000000..a717ff5372c --- /dev/null +++ b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-12-02 17:06:37.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Payment Period Based On Invoice Date", + "owner": "Administrator", + "ref_doctype": "Journal Voucher", + "report_name": "Payment Period Based On Invoice Date", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.txt b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.txt deleted file mode 100644 index e48ea69ecca..00000000000 --- a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-12-02 17:06:37", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Journal Voucher", - "report_name": "Payment Period Based On Invoice Date", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Payment Period Based On Invoice Date" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.json b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.json new file mode 100644 index 00000000000..26d199b1e58 --- /dev/null +++ b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-13 18:46:55.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Purchase Invoice Trends", + "owner": "Administrator", + "ref_doctype": "Purchase Invoice", + "report_name": "Purchase Invoice Trends", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.txt b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.txt deleted file mode 100644 index 20e5a53f510..00000000000 --- a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-13 18:46:55", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Purchase Invoice", - "report_name": "Purchase Invoice Trends", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Purchase Invoice Trends" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json b/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json new file mode 100644 index 00000000000..0b9804c12c7 --- /dev/null +++ b/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.json @@ -0,0 +1,17 @@ +{ + "add_total_row": 1, + "creation": "2013-05-28 15:54:16.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Purchase Order Items To Be Billed", + "owner": "Administrator", + "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.base_amount as \"Amount:Currency:100\",\n\t`tabPurchase Order Item`.billed_amt as \"Billed Amount:Currency:100\", \n\t(`tabPurchase Order Item`.base_amount - ifnull(`tabPurchase Order Item`.billed_amt, 0)) as \"Amount to Bill:Currency:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.billed_amt, 0) < ifnull(`tabPurchase Order Item`.base_amount, 0)\norder by `tabPurchase Order`.transaction_date asc", + "ref_doctype": "Purchase Invoice", + "report_name": "Purchase Order Items To Be Billed", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt b/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt deleted file mode 100644 index 88990cb6d1f..00000000000 --- a/erpnext/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "creation": "2013-05-28 15:54:16", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.base_amount as \"Amount:Currency:100\",\n\t`tabPurchase Order Item`.billed_amt as \"Billed Amount:Currency:100\", \n\t(`tabPurchase Order Item`.base_amount - ifnull(`tabPurchase Order Item`.billed_amt, 0)) as \"Amount to Bill:Currency:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.billed_amt, 0) < ifnull(`tabPurchase Order Item`.base_amount, 0)\norder by `tabPurchase Order`.transaction_date asc", - "ref_doctype": "Purchase Invoice", - "report_name": "Purchase Order Items To Be Billed", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Purchase Order Items To Be Billed" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/purchase_register/purchase_register.json b/erpnext/accounts/report/purchase_register/purchase_register.json new file mode 100644 index 00000000000..592f4101b53 --- /dev/null +++ b/erpnext/accounts/report/purchase_register/purchase_register.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-04-29 16:13:11.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Purchase Register", + "owner": "Administrator", + "ref_doctype": "Purchase Invoice", + "report_name": "Purchase Register", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/purchase_register/purchase_register.txt b/erpnext/accounts/report/purchase_register/purchase_register.txt deleted file mode 100644 index f04f8e6498a..00000000000 --- a/erpnext/accounts/report/purchase_register/purchase_register.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-04-29 16:13:11", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Purchase Invoice", - "report_name": "Purchase Register", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Purchase Register" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.json b/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.json new file mode 100644 index 00000000000..097ddd2e9de --- /dev/null +++ b/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-07-30 18:35:10.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Received Items To Be Billed", + "owner": "Administrator", + "query": "select\n `tabPurchase Receipt`.`name` as \"Purchase Receipt:Link/Purchase Receipt:120\",\n `tabPurchase Receipt`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Receipt`.`posting_date` as \"Date:Date\",\n\t`tabPurchase Receipt Item`.`project_name` as \"Project\",\n\t`tabPurchase Receipt Item`.`item_code` as \"Item:Link/Item:120\",\n\t(`tabPurchase Receipt Item`.`qty` - ifnull((select sum(qty) from `tabPurchase Invoice Item` \n\t where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n\t `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\n\t\tas \"Qty:Float:110\",\n\t(`tabPurchase Receipt Item`.`base_amount` - ifnull((select sum(base_amount) from `tabPurchase Invoice Item` \n where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\n\t\tas \"Amount:Currency:110\",\n\t`tabPurchase Receipt Item`.`item_name` as \"Item Name::150\",\n\t`tabPurchase Receipt Item`.`description` as \"Description::200\"\nfrom `tabPurchase Receipt`, `tabPurchase Receipt Item`\nwhere\n `tabPurchase Receipt`.docstatus = 1 and\n\t`tabPurchase Receipt`.`status` != \"Stopped\" and\n `tabPurchase Receipt`.name = `tabPurchase Receipt Item`.parent and\n (`tabPurchase Receipt Item`.qty > ifnull((select sum(qty) from `tabPurchase Invoice Item` \n where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\norder by `tabPurchase Receipt`.`name` desc", + "ref_doctype": "Purchase Invoice", + "report_name": "Received Items To Be Billed", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt b/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt deleted file mode 100644 index 3ecb2d8879f..00000000000 --- a/erpnext/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-07-30 18:35:10", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "query": "select\n `tabPurchase Receipt`.`name` as \"Purchase Receipt:Link/Purchase Receipt:120\",\n `tabPurchase Receipt`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Receipt`.`posting_date` as \"Date:Date\",\n\t`tabPurchase Receipt Item`.`project_name` as \"Project\",\n\t`tabPurchase Receipt Item`.`item_code` as \"Item:Link/Item:120\",\n\t(`tabPurchase Receipt Item`.`qty` - ifnull((select sum(qty) from `tabPurchase Invoice Item` \n\t where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n\t `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\n\t\tas \"Qty:Float:110\",\n\t(`tabPurchase Receipt Item`.`base_amount` - ifnull((select sum(base_amount) from `tabPurchase Invoice Item` \n where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\n\t\tas \"Amount:Currency:110\",\n\t`tabPurchase Receipt Item`.`item_name` as \"Item Name::150\",\n\t`tabPurchase Receipt Item`.`description` as \"Description::200\"\nfrom `tabPurchase Receipt`, `tabPurchase Receipt Item`\nwhere\n `tabPurchase Receipt`.docstatus = 1 and\n\t`tabPurchase Receipt`.`status` != \"Stopped\" and\n `tabPurchase Receipt`.name = `tabPurchase Receipt Item`.parent and\n (`tabPurchase Receipt Item`.qty > ifnull((select sum(qty) from `tabPurchase Invoice Item` \n where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\norder by `tabPurchase Receipt`.`name` desc", - "ref_doctype": "Purchase Invoice", - "report_name": "Received Items To Be Billed", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Received Items To Be Billed" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.json b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.json new file mode 100644 index 00000000000..768c0876eac --- /dev/null +++ b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-13 18:44:21.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Invoice Trends", + "owner": "Administrator", + "ref_doctype": "Sales Invoice", + "report_name": "Sales Invoice Trends", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.txt b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.txt deleted file mode 100644 index 4ffc3499bf3..00000000000 --- a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-13 18:44:21", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Sales Invoice", - "report_name": "Sales Invoice Trends", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Sales Invoice Trends" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/sales_partners_commission/sales_partners_commission.json b/erpnext/accounts/report/sales_partners_commission/sales_partners_commission.json new file mode 100644 index 00000000000..c4dd07481b0 --- /dev/null +++ b/erpnext/accounts/report/sales_partners_commission/sales_partners_commission.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-05-06 12:28:23.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Partners Commission", + "owner": "Administrator", + "query": "SELECT\n sales_partner as \"Sales Partner:Link/Sales Partner:150\",\n\tsum(net_total) as \"Invoiced Amount (Exculsive Tax):Currency:210\",\n\tsum(total_commission) as \"Total Commission:Currency:150\",\n\tsum(total_commission)*100/sum(net_total) as \"Average Commission Rate:Currency:170\"\nFROM\n\t`tabSales Invoice`\nWHERE\n\tdocstatus = 1 and ifnull(net_total, 0) > 0 and ifnull(total_commission, 0) > 0\nGROUP BY\n\tsales_partner\nORDER BY\n\t\"Total Commission:Currency:120\"", + "ref_doctype": "Sales Invoice", + "report_name": "Sales Partners Commission", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/sales_partners_commission/sales_partners_commission.txt b/erpnext/accounts/report/sales_partners_commission/sales_partners_commission.txt deleted file mode 100644 index e79d415b963..00000000000 --- a/erpnext/accounts/report/sales_partners_commission/sales_partners_commission.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-05-06 12:28:23", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "query": "SELECT\n sales_partner as \"Sales Partner:Link/Sales Partner:150\",\n\tsum(net_total) as \"Invoiced Amount (Exculsive Tax):Currency:210\",\n\tsum(total_commission) as \"Total Commission:Currency:150\",\n\tsum(total_commission)*100/sum(net_total) as \"Average Commission Rate:Currency:170\"\nFROM\n\t`tabSales Invoice`\nWHERE\n\tdocstatus = 1 and ifnull(net_total, 0) > 0 and ifnull(total_commission, 0) > 0\nGROUP BY\n\tsales_partner\nORDER BY\n\t\"Total Commission:Currency:120\"", - "ref_doctype": "Sales Invoice", - "report_name": "Sales Partners Commission", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Sales Partners Commission" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/sales_register/sales_register.json b/erpnext/accounts/report/sales_register/sales_register.json new file mode 100644 index 00000000000..703d903f509 --- /dev/null +++ b/erpnext/accounts/report/sales_register/sales_register.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-04-23 18:15:29.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Register", + "owner": "Administrator", + "ref_doctype": "Sales Invoice", + "report_name": "Sales Register", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/sales_register/sales_register.txt b/erpnext/accounts/report/sales_register/sales_register.txt deleted file mode 100644 index 40ac3b5018d..00000000000 --- a/erpnext/accounts/report/sales_register/sales_register.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-04-23 18:15:29", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Sales Invoice", - "report_name": "Sales Register", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Sales Register" - } -] \ No newline at end of file diff --git a/erpnext/accounts/report/supplier_account_head/supplier_account_head.json b/erpnext/accounts/report/supplier_account_head/supplier_account_head.json new file mode 100644 index 00000000000..d973c8a1743 --- /dev/null +++ b/erpnext/accounts/report/supplier_account_head/supplier_account_head.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-04 12:56:17.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Supplier Account Head", + "owner": "Administrator", + "ref_doctype": "Account", + "report_name": "Supplier Account Head", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/supplier_account_head/supplier_account_head.txt b/erpnext/accounts/report/supplier_account_head/supplier_account_head.txt deleted file mode 100644 index cf6e3220166..00000000000 --- a/erpnext/accounts/report/supplier_account_head/supplier_account_head.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-04 12:56:17", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Accounts", - "name": "__common__", - "ref_doctype": "Account", - "report_name": "Supplier Account Head", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Supplier Account Head" - } -] \ No newline at end of file diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 1b00efce0ac..e317e1141ba 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe.utils import nowdate, cstr, flt, now, getdate, add_months -from frappe.model.doc import addchild from frappe import msgprint, throw, _ from frappe.utils import formatdate from erpnext.utilities import build_filter_conditions @@ -17,7 +16,7 @@ class BudgetError(frappe.ValidationError): pass def get_fiscal_year(date=None, fiscal_year=None, label="Date", verbose=1): return get_fiscal_years(date, fiscal_year, label, verbose)[0] - + def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1): # if year start date is 2012-04-01, year end date should be 2013-03-31 (hence subdate) cond = "" @@ -28,16 +27,16 @@ def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1): (date, date) fy = frappe.db.sql("""select name, year_start_date, year_end_date from `tabFiscal Year` where %s order by year_start_date desc""" % cond) - + if not fy: error_msg = """%s %s not in any Fiscal Year""" % (label, formatdate(date)) - error_msg = """{msg}: {date}""".format(msg=_("Fiscal Year does not exist for date"), + error_msg = """{msg}: {date}""".format(msg=_("Fiscal Year does not exist for date"), date=formatdate(date)) if verbose: frappe.msgprint(error_msg) raise FiscalYearError, error_msg - + return fy - + def validate_fiscal_year(date, fiscal_year, label="Date"): years = [f[0] for f in get_fiscal_years(date, label=label)] if fiscal_year not in years: @@ -53,14 +52,14 @@ def get_balance_on(account=None, date=None): if not account and frappe.form_dict.get("account"): account = frappe.form_dict.get("account") date = frappe.form_dict.get("date") - + cond = [] if date: cond.append("posting_date <= '%s'" % date) else: # get balance of all entries that exist date = nowdate() - + try: year_start_date = get_fiscal_year(date, verbose=0)[1] except FiscalYearError, e: @@ -72,15 +71,15 @@ def get_balance_on(account=None, date=None): # this indicates that it is a date older than any existing fiscal year. # hence, assuming balance as 0.0 return 0.0 - + acc = frappe.db.get_value('Account', account, \ ['lft', 'rgt', 'report_type', 'group_or_ledger'], as_dict=1) - + # for pl accounts, get balance within a fiscal year if acc.report_type == 'Profit and Loss': cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" \ % year_start_date) - + # different filter for group and ledger - improved performance if acc.group_or_ledger=="Group": cond.append("""exists ( @@ -89,9 +88,9 @@ def get_balance_on(account=None, date=None): )""" % (acc.lft, acc.rgt)) else: cond.append("""gle.account = "%s" """ % (account.replace('"', '\"'), )) - + bal = frappe.db.sql(""" - SELECT sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) + SELECT sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) FROM `tabGL Entry` gle WHERE %s""" % " and ".join(cond))[0][0] @@ -103,25 +102,25 @@ def add_ac(args=None): if not args: args = frappe.local.form_dict args.pop("cmd") - - ac = frappe.bean(args) - ac.doc.doctype = "Account" - ac.doc.old_parent = "" - ac.doc.freeze_account = "No" + + ac = frappe.get_doc(args) + ac.doctype = "Account" + ac.old_parent = "" + ac.freeze_account = "No" ac.insert() - return ac.doc.name + return ac.name @frappe.whitelist() def add_cc(args=None): if not args: args = frappe.local.form_dict args.pop("cmd") - - cc = frappe.bean(args) - cc.doc.doctype = "Cost Center" - cc.doc.old_parent = "" + + cc = frappe.get_doc(args) + cc.doctype = "Cost Center" + cc.old_parent = "" cc.insert() - return cc.doc.name + return cc.name def reconcile_against_document(args): """ @@ -135,18 +134,19 @@ def reconcile_against_document(args): 'Sales Invoice' : 'against_invoice', 'Purchase Invoice' : 'against_voucher' } - + d['against_fld'] = against_fld[d['against_voucher_type']] # cancel JV - jv_obj = frappe.get_obj('Journal Voucher', d['voucher_no'], with_children=1) + jv_obj = frappe.get_doc('Journal Voucher', d['voucher_no']) + jv_obj.make_gl_entries(cancel=1, adv_adj=1) - + # update ref in JV Detail update_against_doc(d, jv_obj) # re-submit JV - jv_obj = frappe.get_obj('Journal Voucher', d['voucher_no'], with_children =1) + jv_obj = frappe.get_doc('Journal Voucher', d['voucher_no']) jv_obj.make_gl_entries(cancel = 0, adv_adj =1) @@ -157,13 +157,13 @@ def check_if_jv_modified(args): check if jv is submitted """ ret = frappe.db.sql(""" - select t2.%(dr_or_cr)s from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 - where t1.name = t2.parent and t2.account = '%(account)s' - and ifnull(t2.against_voucher, '')='' + select t2.%(dr_or_cr)s from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 + where t1.name = t2.parent and t2.account = '%(account)s' + and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')='' and ifnull(t2.against_jv, '')='' and t1.name = '%(voucher_no)s' and t2.name = '%(voucher_detail_no)s' and t1.docstatus=1 and t2.%(dr_or_cr)s = %(unadjusted_amt)s""" % args) - + if not ret: throw(_("""Payment Entry has been modified after you pulled it. Please pull it again.""")) @@ -171,110 +171,110 @@ def update_against_doc(d, jv_obj): """ Updates against document, if partial amount splits into rows """ + jv_detail = jv_obj.get("entries", {"name": d["voucher_detail_no"]})[0] + jv_detail.set(d["dr_or_cr"], d["allocated_amt"]) + jv_detail.set(d["against_fld"], d["against_voucher"]) - frappe.db.sql(""" - update `tabJournal Voucher Detail` t1, `tabJournal Voucher` t2 - set t1.%(dr_or_cr)s = '%(allocated_amt)s', - t1.%(against_fld)s = '%(against_voucher)s', t2.modified = now() - where t1.name = '%(voucher_detail_no)s' and t1.parent = t2.name""" % d) - if d['allocated_amt'] < d['unadjusted_amt']: - jvd = frappe.db.sql("""select cost_center, balance, against_account, is_advance + jvd = frappe.db.sql("""select cost_center, balance, against_account, is_advance from `tabJournal Voucher Detail` where name = %s""", d['voucher_detail_no']) # new entry with balance amount - ch = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail') + ch = jv_obj.append("entries") ch.account = d['account'] ch.cost_center = cstr(jvd[0][0]) ch.balance = cstr(jvd[0][1]) - ch.fields[d['dr_or_cr']] = flt(d['unadjusted_amt']) - flt(d['allocated_amt']) - ch.fields[d['dr_or_cr']== 'debit' and 'credit' or 'debit'] = 0 + ch.set(d['dr_or_cr'], flt(d['unadjusted_amt']) - flt(d['allocated_amt'])) + ch.set(d['dr_or_cr']== 'debit' and 'credit' or 'debit', 0) ch.against_account = cstr(jvd[0][2]) ch.is_advance = cstr(jvd[0][3]) ch.docstatus = 1 - ch.save(1) - + + # will work as update after submit + jv_obj.ignore_validate_update_after_submit = True + jv_obj.save() + def get_account_list(doctype, txt, searchfield, start, page_len, filters): if not filters.get("group_or_ledger"): filters["group_or_ledger"] = "Ledger" conditions, filter_values = build_filter_conditions(filters) - - return frappe.db.sql("""select name, parent_account from `tabAccount` - where docstatus < 2 %s and %s like %s order by name limit %s, %s""" % - (conditions, searchfield, "%s", "%s", "%s"), + + return frappe.db.sql("""select name, parent_account from `tabAccount` + where docstatus < 2 %s and %s like %s order by name limit %s, %s""" % + (conditions, searchfield, "%s", "%s", "%s"), tuple(filter_values + ["%%%s%%" % txt, start, page_len])) - + def get_cost_center_list(doctype, txt, searchfield, start, page_len, filters): if not filters.get("group_or_ledger"): filters["group_or_ledger"] = "Ledger" conditions, filter_values = build_filter_conditions(filters) - - return frappe.db.sql("""select name, parent_cost_center from `tabCost Center` - where docstatus < 2 %s and %s like %s order by name limit %s, %s""" % - (conditions, searchfield, "%s", "%s", "%s"), + + return frappe.db.sql("""select name, parent_cost_center from `tabCost Center` + where docstatus < 2 %s and %s like %s order by name limit %s, %s""" % + (conditions, searchfield, "%s", "%s", "%s"), tuple(filter_values + ["%%%s%%" % txt, start, page_len])) - + def remove_against_link_from_jv(ref_type, ref_no, against_field): - linked_jv = frappe.db.sql_list("""select parent from `tabJournal Voucher Detail` + linked_jv = frappe.db.sql_list("""select parent from `tabJournal Voucher Detail` where `%s`=%s and docstatus < 2""" % (against_field, "%s"), (ref_no)) - - if linked_jv: + + if linked_jv: frappe.db.sql("""update `tabJournal Voucher Detail` set `%s`=null, modified=%s, modified_by=%s - where `%s`=%s and docstatus < 2""" % (against_field, "%s", "%s", against_field, "%s"), + where `%s`=%s and docstatus < 2""" % (against_field, "%s", "%s", against_field, "%s"), (now(), frappe.session.user, ref_no)) - + frappe.db.sql("""update `tabGL Entry` set against_voucher_type=null, against_voucher=null, modified=%s, modified_by=%s where against_voucher_type=%s and against_voucher=%s and voucher_no != ifnull(against_voucher, '')""", (now(), frappe.session.user, ref_type, ref_no)) - + frappe.msgprint("{msg} {linked_jv}".format(msg = _("""Following linked Journal Vouchers \ made against this transaction has been unlinked. You can link them again with other \ transactions via Payment Reconciliation Tool."""), linked_jv="\n".join(linked_jv))) - + @frappe.whitelist() def get_company_default(company, fieldname): value = frappe.db.get_value("Company", company, fieldname) - + if not value: - throw(_("Please mention default value for '") + - _(frappe.get_doctype("company").get_label(fieldname) + + throw(_("Please mention default value for '") + + _(frappe.get_meta("Company").get_label(fieldname) + _("' in Company: ") + company)) - + return value def fix_total_debit_credit(): - vouchers = frappe.db.sql("""select voucher_type, voucher_no, - sum(debit) - sum(credit) as diff - from `tabGL Entry` + vouchers = frappe.db.sql("""select voucher_type, voucher_no, + sum(debit) - sum(credit) as diff + from `tabGL Entry` group by voucher_type, voucher_no having sum(ifnull(debit, 0)) != sum(ifnull(credit, 0))""", as_dict=1) - + for d in vouchers: if abs(d.diff) > 0: dr_or_cr = d.voucher_type == "Sales Invoice" and "credit" or "debit" - + frappe.db.sql("""update `tabGL Entry` set %s = %s + %s where voucher_type = %s and voucher_no = %s and %s > 0 limit 1""" % - (dr_or_cr, dr_or_cr, '%s', '%s', '%s', dr_or_cr), + (dr_or_cr, dr_or_cr, '%s', '%s', '%s', dr_or_cr), (d.diff, d.voucher_type, d.voucher_no)) - + def get_stock_and_account_difference(account_list=None, posting_date=None): from erpnext.stock.utils import get_stock_balance_on - + if not posting_date: posting_date = nowdate() - + difference = {} - - account_warehouse = dict(frappe.db.sql("""select name, master_name from tabAccount - where account_type = 'Warehouse' and ifnull(master_name, '') != '' + + account_warehouse = dict(frappe.db.sql("""select name, master_name from tabAccount + where account_type = 'Warehouse' and ifnull(master_name, '') != '' and name in (%s)""" % ', '.join(['%s']*len(account_list)), account_list)) - + for account, warehouse in account_warehouse.items(): account_balance = get_balance_on(account, posting_date) stock_value = get_stock_balance_on(warehouse, posting_date) @@ -287,24 +287,24 @@ def validate_expense_against_budget(args): args = frappe._dict(args) if frappe.db.get_value("Account", {"name": args.account, "report_type": "Profit and Loss"}): budget = frappe.db.sql(""" - select bd.budget_allocated, cc.distribution_id + select bd.budget_allocated, cc.distribution_id from `tabCost Center` cc, `tabBudget Detail` bd where cc.name=bd.parent and cc.name=%s and account=%s and bd.fiscal_year=%s """, (args.cost_center, args.account, args.fiscal_year), as_dict=True) - + if budget and budget[0].budget_allocated: - yearly_action, monthly_action = frappe.db.get_value("Company", args.company, + yearly_action, monthly_action = frappe.db.get_value("Company", args.company, ["yearly_bgt_flag", "monthly_bgt_flag"]) action_for = action = "" if monthly_action in ["Stop", "Warn"]: - budget_amount = get_allocated_budget(budget[0].distribution_id, + budget_amount = get_allocated_budget(budget[0].distribution_id, args.posting_date, args.fiscal_year, budget[0].budget_allocated) - - args["month_end_date"] = frappe.db.sql("select LAST_DAY(%s)", + + args["month_end_date"] = frappe.db.sql("select LAST_DAY(%s)", args.posting_date)[0][0] action_for, action = "Monthly", monthly_action - + elif yearly_action in ["Stop", "Warn"]: budget_amount = budget[0].budget_allocated action_for, action = "Monthly", yearly_action @@ -312,44 +312,44 @@ def validate_expense_against_budget(args): if action_for: actual_expense = get_actual_expense(args) if actual_expense > budget_amount: - throw(action_for + _(" budget ") + cstr(budget_amount) + - _(" for account ") + args.account + _(" against cost center ") + - args.cost_center + _(" will exceed by ") + + throw(action_for + _(" budget ") + cstr(budget_amount) + + _(" for account ") + args.account + _(" against cost center ") + + args.cost_center + _(" will exceed by ") + cstr(actual_expense - budget_amount) + _(" after this transaction.") , exc=BudgetError if action=="Stop" else False) - + def get_allocated_budget(distribution_id, posting_date, fiscal_year, yearly_budget): if distribution_id: distribution = {} - for d in frappe.db.sql("""select bdd.month, bdd.percentage_allocation + for d in frappe.db.sql("""select bdd.month, bdd.percentage_allocation from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd where bdd.parent=bd.name and bd.fiscal_year=%s""", fiscal_year, as_dict=1): distribution.setdefault(d.month, d.percentage_allocation) dt = frappe.db.get_value("Fiscal Year", fiscal_year, "year_start_date") budget_percentage = 0.0 - + while(dt <= getdate(posting_date)): if distribution_id: budget_percentage += distribution.get(getdate(dt).strftime("%B"), 0) else: budget_percentage += 100.0/12 - + dt = add_months(dt, 1) - + return yearly_budget * budget_percentage / 100 - + def get_actual_expense(args): args["condition"] = " and posting_date<='%s'" % args.month_end_date \ if args.get("month_end_date") else "" - + return frappe.db.sql(""" select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabGL Entry` - where account='%(account)s' and cost_center='%(cost_center)s' + where account='%(account)s' and cost_center='%(cost_center)s' and fiscal_year='%(fiscal_year)s' and company='%(company)s' %(condition)s """ % (args))[0][0] - + def rename_account_for(dt, olddn, newdn, merge, company): old_account = get_account_for(dt, olddn) if old_account: @@ -359,29 +359,29 @@ def rename_account_for(dt, olddn, newdn, merge, company): new_account = frappe.rename_doc("Account", old_account, newdn) else: existing_new_account = get_account_for(dt, newdn) - new_account = frappe.rename_doc("Account", old_account, + new_account = frappe.rename_doc("Account", old_account, existing_new_account or newdn, merge=True if existing_new_account else False) frappe.db.set_value("Account", new_account or old_account, "master_name", newdn) - + def add_abbr_if_missing(dn, company): from erpnext.setup.doctype.company.company import get_name_with_abbr return get_name_with_abbr(dn, company) - + def get_account_for(account_for_doctype, account_for): if account_for_doctype in ["Customer", "Supplier"]: account_for_field = "master_type" elif account_for_doctype == "Warehouse": account_for_field = "account_type" - - return frappe.db.get_value("Account", {account_for_field: account_for_doctype, + + return frappe.db.get_value("Account", {account_for_field: account_for_doctype, "master_name": account_for}) - + def get_currency_precision(currency=None): if not currency: - currency = frappe.db.get_value("Company", + currency = frappe.db.get_value("Company", frappe.db.get_default("company"), "default_currency") currency_format = frappe.db.get_value("Currency", currency, "number_format") - + from frappe.utils import get_number_format_info return get_number_format_info(currency_format)[2] diff --git a/erpnext/buying/Print Format/Purchase Order Classic/Purchase Order Classic.json b/erpnext/buying/Print Format/Purchase Order Classic/Purchase Order Classic.json new file mode 100644 index 00000000000..2df549691d6 --- /dev/null +++ b/erpnext/buying/Print Format/Purchase Order Classic/Purchase Order Classic.json @@ -0,0 +1,15 @@ +{ + "creation": "2012-04-17 11:29:12.000000", + "doc_type": "Purchase Order", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n\n", + "idx": 1, + "modified": "2014-02-11 20:00:45.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Order Classic", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/buying/Print Format/Purchase Order Classic/Purchase Order Classic.txt b/erpnext/buying/Print Format/Purchase Order Classic/Purchase Order Classic.txt deleted file mode 100644 index 88d750efc2e..00000000000 --- a/erpnext/buying/Print Format/Purchase Order Classic/Purchase Order Classic.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2012-04-17 11:29:12", - "docstatus": 0, - "modified": "2014-02-11 20:00:45", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Purchase Order", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n\n", - "module": "Buying", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Purchase Order Classic" - } -] \ No newline at end of file diff --git a/erpnext/buying/Print Format/Purchase Order Modern/Purchase Order Modern.json b/erpnext/buying/Print Format/Purchase Order Modern/Purchase Order Modern.json new file mode 100644 index 00000000000..6edb421ae52 --- /dev/null +++ b/erpnext/buying/Print Format/Purchase Order Modern/Purchase Order Modern.json @@ -0,0 +1,15 @@ +{ + "creation": "2012-04-17 11:29:12.000000", + "doc_type": "Purchase Order", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n\n", + "idx": 1, + "modified": "2014-02-11 20:12:05.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Order Modern", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/buying/Print Format/Purchase Order Modern/Purchase Order Modern.txt b/erpnext/buying/Print Format/Purchase Order Modern/Purchase Order Modern.txt deleted file mode 100644 index 73f850a0b03..00000000000 --- a/erpnext/buying/Print Format/Purchase Order Modern/Purchase Order Modern.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2012-04-17 11:29:12", - "docstatus": 0, - "modified": "2014-02-11 20:12:05", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Purchase Order", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n\n", - "module": "Buying", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Purchase Order Modern" - } -] \ No newline at end of file diff --git a/erpnext/buying/Print Format/Purchase Order Spartan/Purchase Order Spartan.json b/erpnext/buying/Print Format/Purchase Order Spartan/Purchase Order Spartan.json new file mode 100644 index 00000000000..d4347c406e7 --- /dev/null +++ b/erpnext/buying/Print Format/Purchase Order Spartan/Purchase Order Spartan.json @@ -0,0 +1,15 @@ +{ + "creation": "2012-04-17 11:29:12.000000", + "doc_type": "Purchase Order", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n\n", + "idx": 1, + "modified": "2014-02-11 20:01:38.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Order Spartan", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/buying/Print Format/Purchase Order Spartan/Purchase Order Spartan.txt b/erpnext/buying/Print Format/Purchase Order Spartan/Purchase Order Spartan.txt deleted file mode 100644 index 1d6168ed0cf..00000000000 --- a/erpnext/buying/Print Format/Purchase Order Spartan/Purchase Order Spartan.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2012-04-17 11:29:12", - "docstatus": 0, - "modified": "2014-02-11 20:01:38", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Purchase Order", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n\n", - "module": "Buying", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Purchase Order Spartan" - } -] \ No newline at end of file diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.json b/erpnext/buying/doctype/buying_settings/buying_settings.json new file mode 100644 index 00000000000..808c39d9f7d --- /dev/null +++ b/erpnext/buying/doctype/buying_settings/buying_settings.json @@ -0,0 +1,75 @@ +{ + "creation": "2013-06-25 11:04:03.000000", + "description": "Settings for Buying Module", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Other", + "fields": [ + { + "default": "Supplier Name", + "fieldname": "supp_master_name", + "fieldtype": "Select", + "label": "Supplier Naming By", + "options": "Supplier Name\nNaming Series", + "permlevel": 0 + }, + { + "fieldname": "supplier_type", + "fieldtype": "Link", + "label": "Default Supplier Type", + "options": "Supplier Type", + "permlevel": 0 + }, + { + "fieldname": "buying_price_list", + "fieldtype": "Link", + "label": "Default Buying Price List", + "options": "Price List", + "permlevel": 0 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "maintain_same_rate", + "fieldtype": "Check", + "label": "Maintain same rate throughout purchase cycle", + "permlevel": 0 + }, + { + "fieldname": "po_required", + "fieldtype": "Select", + "label": "Purchase Order Required", + "options": "No\nYes", + "permlevel": 0 + }, + { + "fieldname": "pr_required", + "fieldtype": "Select", + "label": "Purchase Receipt Required", + "options": "No\nYes", + "permlevel": 0 + } + ], + "icon": "icon-cog", + "idx": 1, + "issingle": 1, + "modified": "2014-02-19 19:02:00.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Buying Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "System Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.py b/erpnext/buying/doctype/buying_settings/buying_settings.py index 9776fda99cb..eea9f9ce190 100644 --- a/erpnext/buying/doctype/buying_settings/buying_settings.py +++ b/erpnext/buying/doctype/buying_settings/buying_settings.py @@ -6,14 +6,14 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class BuyingSettings(Document): def validate(self): for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]: - frappe.db.set_default(key, self.doc.fields.get(key, "")) + frappe.db.set_default(key, self.get(key, "")) from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series set_by_naming_series("Supplier", "supplier_name", - self.doc.get("supp_master_name")=="Naming Series", hide_name_field=False) + self.get("supp_master_name")=="Naming Series", hide_name_field=False) diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.txt b/erpnext/buying/doctype/buying_settings/buying_settings.txt deleted file mode 100644 index fbbe367a681..00000000000 --- a/erpnext/buying/doctype/buying_settings/buying_settings.txt +++ /dev/null @@ -1,94 +0,0 @@ -[ - { - "creation": "2013-06-25 11:04:03", - "docstatus": 0, - "modified": "2014-02-19 19:02:00", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Settings for Buying Module", - "doctype": "DocType", - "document_type": "Other", - "icon": "icon-cog", - "issingle": 1, - "module": "Buying", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Buying Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Buying Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "role": "System Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Buying Settings" - }, - { - "default": "Supplier Name", - "doctype": "DocField", - "fieldname": "supp_master_name", - "fieldtype": "Select", - "label": "Supplier Naming By", - "options": "Supplier Name\nNaming Series" - }, - { - "doctype": "DocField", - "fieldname": "supplier_type", - "fieldtype": "Link", - "label": "Default Supplier Type", - "options": "Supplier Type" - }, - { - "doctype": "DocField", - "fieldname": "buying_price_list", - "fieldtype": "Link", - "label": "Default Buying Price List", - "options": "Price List" - }, - { - "doctype": "DocField", - "fieldname": "column_break_3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "maintain_same_rate", - "fieldtype": "Check", - "label": "Maintain same rate throughout purchase cycle" - }, - { - "doctype": "DocField", - "fieldname": "po_required", - "fieldtype": "Select", - "label": "Purchase Order Required", - "options": "No\nYes" - }, - { - "doctype": "DocField", - "fieldname": "pr_required", - "fieldtype": "Select", - "label": "Purchase Receipt Required", - "options": "No\nYes" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 6afcd95b924..e18b3ef4e0a 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -78,7 +78,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ }, price_list_rate: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]); item.rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0), @@ -92,7 +92,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ }, rate: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["rate", "discount_percentage"]); if(item.price_list_rate) { @@ -107,7 +107,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ uom: function(doc, cdt, cdn) { var me = this; - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); if(item.item_code && item.uom) { return this.frm.call({ method: "erpnext.buying.utils.get_conversion_factor", @@ -132,7 +132,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ conversion_factor: function(doc, cdt, cdn) { if(frappe.meta.get_docfield(cdt, "stock_qty", cdn)) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["qty", "conversion_factor"]); item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item)); refresh_field("stock_qty", item.name, item.parentfield); @@ -140,7 +140,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ }, warehouse: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); if(item.item_code && item.warehouse) { return this.frm.call({ method: "erpnext.buying.utils.get_projected_qty", @@ -154,9 +154,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ }, project_name: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); if(item.project_name) { - $.each(frappe.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, {parentfield: this.fname}), + $.each(this.frm.doc[this.fname], function(i, other_item) { if(!other_item.project_name) { other_item.project_name = item.project_name; diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.json b/erpnext/buying/doctype/purchase_common/purchase_common.json new file mode 100644 index 00000000000..2f5ada864aa --- /dev/null +++ b/erpnext/buying/doctype/purchase_common/purchase_common.json @@ -0,0 +1,12 @@ +{ + "creation": "2012-03-27 14:35:51.000000", + "docstatus": 0, + "doctype": "DocType", + "idx": 1, + "issingle": 1, + "modified": "2013-12-20 19:23:27.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Common", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py index 3fefeba915d..6009c1854bd 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.py +++ b/erpnext/buying/doctype/purchase_common/purchase_common.py @@ -5,26 +5,22 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt -from frappe.model.utils import getlist from frappe import msgprint, _ from erpnext.stock.doctype.item.item import get_last_purchase_details from erpnext.controllers.buying_controller import BuyingController -class DocType(BuyingController): - def __init__(self, doc, doclist=None): - self.doc = doc - self.doclist = doclist - +class PurchaseCommon(BuyingController): + def update_last_purchase_rate(self, obj, is_submit): """updates last_purchase_rate in item table for each item""" - + import frappe.utils - this_purchase_date = frappe.utils.getdate(obj.doc.fields.get('posting_date') or obj.doc.fields.get('transaction_date')) - - for d in getlist(obj.doclist,obj.fname): + this_purchase_date = frappe.utils.getdate(obj.get('posting_date') or obj.get('transaction_date')) + + for d in obj.get(obj.fname): # get last purchase details - last_purchase_details = get_last_purchase_details(d.item_code, obj.doc.name) + last_purchase_details = get_last_purchase_details(d.item_code, obj.name) # compare last purchase date and this transaction's date last_purchase_rate = None @@ -37,20 +33,20 @@ class DocType(BuyingController): if flt(d.conversion_factor): last_purchase_rate = flt(d.base_rate) / flt(d.conversion_factor) else: - frappe.throw(_("Row ") + cstr(d.idx) + ": " + + frappe.throw(_("Row ") + cstr(d.idx) + ": " + _("UOM Conversion Factor is mandatory")) # update last purchsae rate if last_purchase_rate: frappe.db.sql("""update `tabItem` set last_purchase_rate = %s where name = %s""", (flt(last_purchase_rate), d.item_code)) - + def get_last_purchase_rate(self, obj): """get last purchase rates for all items""" - doc_name = obj.doc.name - conversion_rate = flt(obj.doc.fields.get('conversion_rate')) or 1.0 - - for d in getlist(obj.doclist, obj.fname): + doc_name = obj.name + conversion_rate = flt(obj.get('conversion_rate')) or 1.0 + + for d in obj.get(obj.fname): if d.item_code: last_purchase_details = get_last_purchase_details(d.item_code, doc_name) @@ -63,113 +59,113 @@ class DocType(BuyingController): else: # if no last purchase found, reset all values to 0 d.base_price_list_rate = d.base_rate = d.price_list_rate = d.rate = d.discount_percentage = 0 - + item_last_purchase_rate = frappe.db.get_value("Item", d.item_code, "last_purchase_rate") if item_last_purchase_rate: d.base_price_list_rate = d.base_rate = d.price_list_rate \ = d.rate = item_last_purchase_rate - + def validate_for_items(self, obj): check_list, chk_dupl_itm=[],[] - for d in getlist( obj.doclist, obj.fname): - # validation for valid qty + for d in obj.get(obj.fname): + # validation for valid qty if flt(d.qty) < 0 or (d.parenttype != 'Purchase Receipt' and not flt(d.qty)): frappe.throw("Please enter valid qty for item %s" % cstr(d.item_code)) - + # udpate with latest quantities - bin = frappe.db.sql("""select projected_qty from `tabBin` where + bin = frappe.db.sql("""select projected_qty from `tabBin` where item_code = %s and warehouse = %s""", (d.item_code, d.warehouse), as_dict=1) - + f_lst ={'projected_qty': bin and flt(bin[0]['projected_qty']) or 0, 'ordered_qty': 0, 'received_qty' : 0} if d.doctype == 'Purchase Receipt Item': f_lst.pop('received_qty') for x in f_lst : - if d.fields.has_key(x): - d.fields[x] = f_lst[x] - - item = frappe.db.sql("""select is_stock_item, is_purchase_item, + if d.meta.get_field(x): + d.set(x, f_lst[x]) + + item = frappe.db.sql("""select is_stock_item, is_purchase_item, is_sub_contracted_item, end_of_life from `tabItem` where name=%s""", d.item_code) if not item: frappe.throw("Item %s does not exist in Item Master." % cstr(d.item_code)) - + from erpnext.stock.doctype.item.item import validate_end_of_life validate_end_of_life(d.item_code, item[0][3]) - + # validate stock item if item[0][0]=='Yes' and d.qty and not d.warehouse: frappe.throw("Warehouse is mandatory for %s, since it is a stock item" % d.item_code) - + # validate purchase item if item[0][1] != 'Yes' and item[0][2] != 'Yes': frappe.throw("Item %s is not a purchase item or sub-contracted item. Please check" % (d.item_code)) - + # list criteria that should not repeat if item is stock item - e = [d.schedule_date, d.item_code, d.description, d.warehouse, d.uom, - d.fields.has_key('prevdoc_docname') and d.prevdoc_docname or d.fields.has_key('sales_order_no') and d.sales_order_no or '', - d.fields.has_key('prevdoc_detail_docname') and d.prevdoc_detail_docname or '', - d.fields.has_key('batch_no') and d.batch_no or ''] - + e = [getattr(d, "schedule_date", None), d.item_code, d.description, d.warehouse, d.uom, + d.meta.get_field('prevdoc_docname') and d.prevdoc_docname or d.meta.get_field('sales_order_no') and d.sales_order_no or '', + d.meta.get_field('prevdoc_detail_docname') and d.prevdoc_detail_docname or '', + d.meta.get_field('batch_no') and d.batch_no or ''] + # if is not stock item - f = [d.schedule_date, d.item_code, d.description] - + f = [getattr(d, "schedule_date", None), d.item_code, d.description] + ch = frappe.db.sql("""select is_stock_item from `tabItem` where name = %s""", d.item_code) - - if ch and ch[0][0] == 'Yes': + + if ch and ch[0][0] == 'Yes': # check for same items if e in check_list: - frappe.throw("""Item %s has been entered more than once with same description, schedule date, warehouse and uom.\n + frappe.throw("""Item %s has been entered more than once with same description, schedule date, warehouse and uom.\n Please change any of the field value to enter the item twice""" % d.item_code) else: check_list.append(e) - + elif ch and ch[0][0] == 'No': # check for same items if f in chk_dupl_itm: - frappe.throw("""Item %s has been entered more than once with same description, schedule date.\n + frappe.throw("""Item %s has been entered more than once with same description, schedule date.\n Please change any of the field value to enter the item twice.""" % d.item_code) else: chk_dupl_itm.append(f) - + def get_qty(self, curr_doctype, ref_tab_fname, ref_tab_dn, ref_doc_tname, transaction, curr_parent_name): # Get total Quantities of current doctype (eg. PR) except for qty of this transaction #------------------------------ # please check as UOM changes from Material Request - Purchase Order ,so doing following else uom should be same . # i.e. in PO uom is NOS then in PR uom should be NOS # but if in Material Request uom KG it can change in PO - + get_qty = (transaction == 'Material Request - Purchase Order') and 'qty * conversion_factor' or 'qty' - qty = frappe.db.sql("""select sum(%s) from `tab%s` where %s = %s and - docstatus = 1 and parent != %s""" % (get_qty, curr_doctype, ref_tab_fname, '%s', '%s'), + qty = frappe.db.sql("""select sum(%s) from `tab%s` where %s = %s and + docstatus = 1 and parent != %s""" % (get_qty, curr_doctype, ref_tab_fname, '%s', '%s'), (ref_tab_dn, curr_parent_name)) - qty = qty and flt(qty[0][0]) or 0 - + qty = qty and flt(qty[0][0]) or 0 + # get total qty of ref doctype #-------------------- - max_qty = frappe.db.sql("""select qty from `tab%s` where name = %s + max_qty = frappe.db.sql("""select qty from `tab%s` where name = %s and docstatus = 1""" % (ref_doc_tname, '%s'), ref_tab_dn) max_qty = max_qty and flt(max_qty[0][0]) or 0 - + return cstr(qty)+'~~~'+cstr(max_qty) def check_for_stopped_status(self, doctype, docname): - stopped = frappe.db.sql("""select name from `tab%s` where name = %s and + stopped = frappe.db.sql("""select name from `tab%s` where name = %s and status = 'Stopped'""" % (doctype, '%s'), docname) if stopped: - frappe.throw("One cannot do any transaction against %s : %s, it's status is 'Stopped'" % - (doctype, docname)) - + frappe.throw("One cannot do any transaction against %s : %s, it's status is 'Stopped'" % + (doctype, docname), exc=frappe.InvalidStatusError) + def check_docstatus(self, check, doctype, docname, detail_doctype = ''): if check == 'Next': - submitted = frappe.db.sql("""select t1.name from `tab%s` t1,`tab%s` t2 - where t1.name = t2.parent and t2.prevdoc_docname = %s and t1.docstatus = 1""" + submitted = frappe.db.sql("""select t1.name from `tab%s` t1,`tab%s` t2 + where t1.name = t2.parent and t2.prevdoc_docname = %s and t1.docstatus = 1""" % (doctype, detail_doctype, '%s'), docname) if submitted: - frappe.throw(cstr(doctype) + ": " + cstr(submitted[0][0]) + frappe.throw(cstr(doctype) + ": " + cstr(submitted[0][0]) + _("has already been submitted.")) if check == 'Previous': - submitted = frappe.db.sql("""select name from `tab%s` + submitted = frappe.db.sql("""select name from `tab%s` where docstatus = 1 and name = %s""" % (doctype, '%s'), docname) if not submitted: frappe.throw(cstr(doctype) + ": " + cstr(submitted[0][0]) + _("not submitted")) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.txt b/erpnext/buying/doctype/purchase_common/purchase_common.txt deleted file mode 100644 index c796c042a96..00000000000 --- a/erpnext/buying/doctype/purchase_common/purchase_common.txt +++ /dev/null @@ -1,19 +0,0 @@ -[ - { - "creation": "2012-03-27 14:35:51", - "docstatus": 0, - "modified": "2013-12-20 19:23:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "issingle": 1, - "module": "Buying", - "name": "__common__" - }, - { - "doctype": "DocType", - "name": "Purchase Common" - } -] \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index 0db8d6fd999..1dfb78e00d6 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -128,7 +128,7 @@ cur_frm.fields_dict['po_details'].grid.get_field('project_name').get_query = fun } cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){ - return $c_obj(make_doclist(doc.doctype, doc.name), 'get_last_purchase_rate', '', function(r, rt) { + return $c_obj(doc, 'get_last_purchase_rate', '', function(r, rt) { refresh_field(cur_frm.cscript.fname); var doc = locals[cdt][cdn]; cur_frm.cscript.calc_amount( doc, 2); @@ -140,7 +140,7 @@ cur_frm.cscript['Stop Purchase Order'] = function() { var check = confirm(frappe._("Do you really want to STOP ") + doc.name); if (check) { - return $c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': frappe.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) { + return $c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs':doc}, function(r,rt) { cur_frm.refresh(); }); } @@ -151,7 +151,7 @@ cur_frm.cscript['Unstop Purchase Order'] = function() { var check = confirm(frappe._("Do you really want to UNSTOP ") + doc.name); if (check) { - return $c('runserverobj', args={'method':'update_status', 'arg': 'Submitted', 'docs': frappe.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) { + return $c('runserverobj', args={'method':'update_status', 'arg': 'Submitted', 'docs':doc}, function(r,rt) { cur_frm.refresh(); }); } @@ -170,7 +170,7 @@ cur_frm.pformat.indent_no = function(doc, cdt, cdn){ out =''; - var cl = getchildren('Purchase Order Item',doc.name,'po_details'); + var cl = doc.po_details || []; // outer table var out='
-
'; diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json new file mode 100644 index 00000000000..53038fcf81a --- /dev/null +++ b/erpnext/buying/doctype/purchase_order/purchase_order.json @@ -0,0 +1,700 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-05-21 16:16:39.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "fieldname": "supplier_section", + "fieldtype": "Section Break", + "label": "Supplier", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "\nPO", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "description": "Supplier (vendor) name as entered in supplier master", + "fieldname": "supplier", + "fieldtype": "Link", + "in_filter": 1, + "label": "Supplier", + "oldfieldname": "supplier", + "oldfieldtype": "Link", + "options": "Supplier", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "supplier_name", + "fieldtype": "Data", + "hidden": 0, + "in_list_view": 1, + "label": "Name", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_mobile", + "fieldtype": "Text", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_email", + "fieldtype": "Text", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "transaction_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Purchase Order Date", + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "hidden": 0, + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0 + }, + { + "description": "Select the relevant company name if you have multiple companies", + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "no_copy": 0, + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "price_list_and_currency", + "fieldtype": "Section Break", + "label": "Currency and Price List", + "options": "icon-tag", + "permlevel": 0 + }, + { + "fieldname": "cb_currency", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "no_copy": 0, + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "description": "Rate at which supplier's currency is converted to company's base currency", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "hidden": 0, + "label": "Exchange Rate", + "no_copy": 0, + "oldfieldname": "conversion_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "fieldname": "cb_price_list", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "buying_price_list", + "fieldtype": "Link", + "label": "Price List", + "options": "Price List", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "price_list_currency", + "fieldtype": "Link", + "label": "Price List Currency", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "label": "Price List Exchange Rate", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "items", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "po_details", + "fieldtype": "Table", + "label": "Purchase Order Items", + "no_copy": 0, + "oldfieldname": "po_details", + "oldfieldtype": "Table", + "options": "Purchase Order Item", + "permlevel": 0 + }, + { + "fieldname": "sb_last_purchase", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "net_total_import", + "fieldtype": "Currency", + "label": "Net Total", + "no_copy": 0, + "oldfieldname": "net_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "get_last_purchase_rate", + "fieldtype": "Button", + "label": "Get Last Purchase Rate", + "oldfieldtype": "Button", + "permlevel": 0, + "print_hide": 0 + }, + { + "fieldname": "column_break_26", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total (Company Currency)", + "no_copy": 1, + "oldfieldname": "net_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "taxes", + "fieldtype": "Section Break", + "label": "Taxes and Charges", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "print_hide": 0 + }, + { + "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.", + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "no_copy": 0, + "oldfieldname": "purchase_other_charges", + "oldfieldtype": "Link", + "options": "Purchase Taxes and Charges Master", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "other_charges", + "fieldtype": "Table", + "label": "Purchase Taxes and Charges", + "no_copy": 0, + "oldfieldname": "purchase_tax_details", + "oldfieldtype": "Table", + "options": "Purchase Taxes and Charges", + "permlevel": 0 + }, + { + "fieldname": "other_charges_calculation", + "fieldtype": "HTML", + "label": "Taxes and Charges Calculation", + "no_copy": 1, + "oldfieldtype": "HTML", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "Totals", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0 + }, + { + "fieldname": "other_charges_added_import", + "fieldtype": "Currency", + "label": "Taxes and Charges Added", + "no_copy": 0, + "oldfieldname": "other_charges_added_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "other_charges_deducted_import", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted", + "no_copy": 0, + "oldfieldname": "other_charges_deducted_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "grand_total_import", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Grand Total", + "no_copy": 0, + "oldfieldname": "grand_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "in_words_import", + "fieldtype": "Data", + "label": "In Words", + "oldfieldname": "in_words_import", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "column_break4", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 0 + }, + { + "fieldname": "other_charges_added", + "fieldtype": "Currency", + "label": "Taxes and Charges Added (Company Currency)", + "no_copy": 0, + "oldfieldname": "other_charges_added", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "other_charges_deducted", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted (Company Currency)", + "no_copy": 0, + "oldfieldname": "other_charges_deducted", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "total_tax", + "fieldtype": "Currency", + "label": "Total Tax (Company Currency)", + "no_copy": 1, + "oldfieldname": "total_tax", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "no_copy": 1, + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total (Company Currency)", + "oldfieldname": "rounded_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "In Words will be visible once you save the Purchase Order.", + "fieldname": "in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "oldfieldtype": "Section Break", + "options": "icon-legal", + "permlevel": 0 + }, + { + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Terms and Conditions", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", + "permlevel": 0 + }, + { + "depends_on": "supplier", + "fieldname": "contact_section", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0 + }, + { + "fieldname": "supplier_address", + "fieldtype": "Link", + "in_filter": 1, + "label": "Supplier Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "cb_contact", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "contact_person", + "fieldtype": "Link", + "in_filter": 1, + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nDraft\nSubmitted\nStopped\nCancelled", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1, + "search_index": 1 + }, + { + "default": "No", + "fieldname": "is_subcontracted", + "fieldtype": "Select", + "label": "Is Subcontracted", + "options": "\nYes\nNo", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "ref_sq", + "fieldtype": "Data", + "hidden": 1, + "label": "Ref SQ", + "no_copy": 1, + "oldfieldname": "ref_sq", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Select", + "label": "Letter Head", + "oldfieldname": "letter_head", + "oldfieldtype": "Select", + "options": "link:Letter Head", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "no_copy": 0, + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + }, + { + "fieldname": "column_break5", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "print_width": "50%", + "width": "50%" + }, + { + "depends_on": "eval:!doc.__islocal", + "description": "% of materials received against this Purchase Order", + "fieldname": "per_received", + "fieldtype": "Percent", + "in_list_view": 1, + "label": "% Received", + "no_copy": 1, + "oldfieldname": "per_received", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "depends_on": "eval:!doc.__islocal", + "description": "% of materials billed against this Purchase Order.", + "fieldname": "per_billed", + "fieldtype": "Percent", + "in_list_view": 1, + "label": "% Billed", + "no_copy": 1, + "oldfieldname": "per_billed", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "Required raw materials issued to the supplier for producing a sub - contracted item.", + "fieldname": "raw_material_details", + "fieldtype": "Section Break", + "label": "Raw Materials Supplied", + "oldfieldtype": "Section Break", + "options": "icon-truck", + "permlevel": 0, + "print_hide": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "po_raw_material_details", + "fieldtype": "Table", + "label": "Purchase Order Items Supplied", + "no_copy": 0, + "oldfieldname": "po_raw_material_details", + "oldfieldtype": "Table", + "options": "Purchase Order Item Supplied", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "icon": "icon-file-text", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-29 15:26:21.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Order", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, + "write": 0 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "submit": 1, + "write": 1 + }, + { + "cancel": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Supplier" + } + ], + "read_only_onload": 1, + "search_fields": "status, transaction_date, supplier,grand_total" +} \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index fca61e36329..d39f6b67258 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -3,20 +3,16 @@ from __future__ import unicode_literals import frappe - from frappe.utils import cstr, flt -from frappe.model.bean import getlist -from frappe.model.code import get_obj from frappe import msgprint - - from erpnext.controllers.buying_controller import BuyingController -class DocType(BuyingController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.tname = 'Purchase Order Item' - self.fname = 'po_details' + +class PurchaseOrder(BuyingController): + tname = 'Purchase Order Item' + fname = 'po_details' + + def __init__(self, arg1, arg2=None): + super(PurchaseOrder, self).__init__(arg1, arg2) self.status_updater = [{ 'source_dt': 'Purchase Order Item', 'target_dt': 'Material Request Item', @@ -28,18 +24,18 @@ class DocType(BuyingController): 'source_field': 'qty', 'percent_join_field': 'prevdoc_docname', }] - + def validate(self): - super(DocType, self).validate() - - if not self.doc.status: - self.doc.status = "Draft" + super(PurchaseOrder, self).validate() + + if not self.status: + self.status = "Draft" from erpnext.utilities import validate_status - validate_status(self.doc.status, ["Draft", "Submitted", "Stopped", + validate_status(self.status, ["Draft", "Submitted", "Stopped", "Cancelled"]) - pc_obj = get_obj(dt='Purchase Common') + pc_obj = frappe.get_doc('Purchase Common') pc_obj.validate_for_items(self) self.check_for_stopped_status(pc_obj) @@ -49,71 +45,71 @@ class DocType(BuyingController): self.validate_with_previous_doc() self.validate_for_subcontracting() self.update_raw_materials_supplied("po_raw_material_details") - + def validate_with_previous_doc(self): - super(DocType, self).validate_with_previous_doc(self.tname, { + super(PurchaseOrder, self).validate_with_previous_doc(self.tname, { "Supplier Quotation": { "ref_dn_field": "supplier_quotation", "compare_fields": [["supplier", "="], ["company", "="], ["currency", "="]], }, "Supplier Quotation Item": { "ref_dn_field": "supplier_quotation_item", - "compare_fields": [["rate", "="], ["project_name", "="], ["item_code", "="], + "compare_fields": [["rate", "="], ["project_name", "="], ["item_code", "="], ["uom", "="]], "is_child_table": True } }) def get_schedule_dates(self): - for d in getlist(self.doclist, 'po_details'): + for d in self.get('po_details'): if d.prevdoc_detail_docname and not d.schedule_date: d.schedule_date = frappe.db.get_value("Material Request Item", d.prevdoc_detail_docname, "schedule_date") - - def get_last_purchase_rate(self): - get_obj('Purchase Common').get_last_purchase_rate(self) - # Check for Stopped status + def get_last_purchase_rate(self): + frappe.get_doc('Purchase Common').get_last_purchase_rate(self) + + # Check for Stopped status def check_for_stopped_status(self, pc_obj): check_list =[] - for d in getlist(self.doclist, 'po_details'): - if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list: + for d in self.get('po_details'): + if d.meta.get_field('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list: check_list.append(d.prevdoc_docname) pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname) - + def update_bin(self, is_submit, is_stopped = 0): from erpnext.stock.utils import update_bin - pc_obj = get_obj('Purchase Common') - for d in getlist(self.doclist, 'po_details'): + pc_obj = frappe.get_doc('Purchase Common') + for d in self.get('po_details'): #1. Check if is_stock_item == 'Yes' if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes": # this happens when item is changed from non-stock to stock item if not d.warehouse: continue - + ind_qty, po_qty = 0, flt(d.qty) * flt(d.conversion_factor) if is_stopped: po_qty = flt(d.qty) > flt(d.received_qty) and \ - flt( flt(flt(d.qty) - flt(d.received_qty))*flt(d.conversion_factor)) or 0 - + flt( flt(flt(d.qty) - flt(d.received_qty))*flt(d.conversion_factor)) or 0 + # No updates in Material Request on Stop / Unstop if cstr(d.prevdoc_doctype) == 'Material Request' and not is_stopped: - # get qty and pending_qty of prevdoc + # get qty and pending_qty of prevdoc curr_ref_qty = pc_obj.get_qty(d.doctype, 'prevdoc_detail_docname', - d.prevdoc_detail_docname, 'Material Request Item', - 'Material Request - Purchase Order', self.doc.name) + d.prevdoc_detail_docname, 'Material Request Item', + 'Material Request - Purchase Order', self.name) max_qty, qty, curr_qty = flt(curr_ref_qty.split('~~~')[1]), \ flt(curr_ref_qty.split('~~~')[0]), 0 - + if flt(qty) + flt(po_qty) > flt(max_qty): curr_qty = flt(max_qty) - flt(qty) - # special case as there is no restriction - # for Material Request - Purchase Order + # special case as there is no restriction + # for Material Request - Purchase Order curr_qty = curr_qty > 0 and curr_qty or 0 else: curr_qty = flt(po_qty) - + ind_qty = -flt(curr_qty) # Update ordered_qty and indented_qty in bin @@ -122,74 +118,74 @@ class DocType(BuyingController): "warehouse": d.warehouse, "ordered_qty": (is_submit and 1 or -1) * flt(po_qty), "indented_qty": (is_submit and 1 or -1) * flt(ind_qty), - "posting_date": self.doc.transaction_date + "posting_date": self.transaction_date } update_bin(args) - + def check_modified_date(self): - mod_db = frappe.db.sql("select modified from `tabPurchase Order` where name = %s", - self.doc.name) - date_diff = frappe.db.sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified))) - + mod_db = frappe.db.sql("select modified from `tabPurchase Order` where name = %s", + self.name) + date_diff = frappe.db.sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.modified))) + if date_diff and date_diff[0][0]: - msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ") + msgprint(cstr(self.doctype) +" => "+ cstr(self.name) +" has been modified. Please Refresh. ") raise Exception def update_status(self, status): self.check_modified_date() # step 1:=> Set Status - frappe.db.set(self.doc,'status',cstr(status)) + frappe.db.set(self,'status',cstr(status)) # step 2:=> Update Bin self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1) # step 3:=> Acknowledge user - msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status))) + msgprint(self.doctype + ": " + self.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status))) def on_submit(self): - purchase_controller = frappe.get_obj("Purchase Common") - + purchase_controller = frappe.get_doc("Purchase Common") + self.update_prevdoc_status() self.update_bin(is_submit = 1, is_stopped = 0) - - get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, - self.doc.company, self.doc.grand_total) - + + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, + self.company, self.grand_total) + purchase_controller.update_last_purchase_rate(self, is_submit = 1) - - frappe.db.set(self.doc,'status','Submitted') - + + frappe.db.set(self,'status','Submitted') + def on_cancel(self): - pc_obj = get_obj(dt = 'Purchase Common') + pc_obj = frappe.get_doc('Purchase Common') self.check_for_stopped_status(pc_obj) - + # Check if Purchase Receipt has been submitted against current Purchase Order - pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Receipt', docname = self.doc.name, detail_doctype = 'Purchase Receipt Item') + pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Receipt', docname = self.name, detail_doctype = 'Purchase Receipt Item') # Check if Purchase Invoice has been submitted against current Purchase Order - submitted = frappe.db.sql("""select t1.name - from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 - where t1.name = t2.parent and t2.purchase_order = %s and t1.docstatus = 1""", - self.doc.name) + submitted = frappe.db.sql("""select t1.name + from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 + where t1.name = t2.parent and t2.purchase_order = %s and t1.docstatus = 1""", + self.name) if submitted: msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !") raise Exception - frappe.db.set(self.doc,'status','Cancelled') + frappe.db.set(self,'status','Cancelled') self.update_prevdoc_status() self.update_bin( is_submit = 0, is_stopped = 0) pc_obj.update_last_purchase_rate(self, is_submit = 0) - + def on_update(self): pass - + @frappe.whitelist() -def make_purchase_receipt(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist - +def make_purchase_receipt(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc + def set_missing_values(source, target): - bean = frappe.bean(target) - bean.run_method("set_missing_values") + doc = frappe.get_doc(target) + doc.run_method("set_missing_values") def update_item(obj, target, source_parent): target.qty = flt(obj.qty) - flt(obj.received_qty) @@ -197,38 +193,38 @@ def make_purchase_receipt(source_name, target_doclist=None): target.amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.rate) target.base_amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.base_rate) - doclist = get_mapped_doclist("Purchase Order", source_name, { + doc = get_mapped_doc("Purchase Order", source_name, { "Purchase Order": { - "doctype": "Purchase Receipt", + "doctype": "Purchase Receipt", "validation": { "docstatus": ["=", 1], } - }, + }, "Purchase Order Item": { - "doctype": "Purchase Receipt Item", + "doctype": "Purchase Receipt Item", "field_map": { - "name": "prevdoc_detail_docname", - "parent": "prevdoc_docname", - "parenttype": "prevdoc_doctype", + "name": "prevdoc_detail_docname", + "parent": "prevdoc_docname", + "parenttype": "prevdoc_doctype", }, "postprocess": update_item, "condition": lambda doc: doc.received_qty < doc.qty - }, + }, "Purchase Taxes and Charges": { - "doctype": "Purchase Taxes and Charges", + "doctype": "Purchase Taxes and Charges", "add_if_empty": True } - }, target_doclist, set_missing_values) + }, target_doc, set_missing_values) + + return doc - return [d.fields for d in doclist] - @frappe.whitelist() -def make_purchase_invoice(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist - +def make_purchase_invoice(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc + def set_missing_values(source, target): - bean = frappe.bean(target) - bean.run_method("set_missing_values") + doc = frappe.get_doc(target) + doc.run_method("set_missing_values") def update_item(obj, target, source_parent): target.amount = flt(obj.amount) - flt(obj.billed_amt) @@ -236,26 +232,26 @@ def make_purchase_invoice(source_name, target_doclist=None): if flt(obj.base_rate): target.qty = target.base_amount / flt(obj.base_rate) - doclist = get_mapped_doclist("Purchase Order", source_name, { + doc = get_mapped_doc("Purchase Order", source_name, { "Purchase Order": { - "doctype": "Purchase Invoice", + "doctype": "Purchase Invoice", "validation": { "docstatus": ["=", 1], } - }, + }, "Purchase Order Item": { - "doctype": "Purchase Invoice Item", + "doctype": "Purchase Invoice Item", "field_map": { - "name": "po_detail", - "parent": "purchase_order", + "name": "po_detail", + "parent": "purchase_order", }, "postprocess": update_item, - "condition": lambda doc: doc.base_amount==0 or doc.billed_amt < doc.amount - }, + "condition": lambda doc: doc.base_amount==0 or doc.billed_amt < doc.amount + }, "Purchase Taxes and Charges": { - "doctype": "Purchase Taxes and Charges", + "doctype": "Purchase Taxes and Charges", "add_if_empty": True } - }, target_doclist, set_missing_values) + }, target_doc, set_missing_values) - return [d.fields for d in doclist] \ No newline at end of file + return doc diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.txt b/erpnext/buying/doctype/purchase_order/purchase_order.txt deleted file mode 100644 index 2dbafd228a5..00000000000 --- a/erpnext/buying/doctype/purchase_order/purchase_order.txt +++ /dev/null @@ -1,707 +0,0 @@ -[ - { - "creation": "2013-05-21 16:16:39", - "docstatus": 0, - "modified": "2014-01-29 15:26:21", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-file-text", - "is_submittable": 1, - "module": "Buying", - "name": "__common__", - "read_only_onload": 1, - "search_fields": "status, transaction_date, supplier,grand_total" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Purchase Order", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Purchase Order", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Purchase Order" - }, - { - "doctype": "DocField", - "fieldname": "supplier_section", - "fieldtype": "Section Break", - "label": "Supplier", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "\nPO", - "print_hide": 1, - "reqd": 1 - }, - { - "description": "Supplier (vendor) name as entered in supplier master", - "doctype": "DocField", - "fieldname": "supplier", - "fieldtype": "Link", - "in_filter": 1, - "label": "Supplier", - "oldfieldname": "supplier", - "oldfieldtype": "Link", - "options": "Supplier", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "supplier_name", - "fieldtype": "Data", - "hidden": 0, - "in_list_view": 1, - "label": "Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Text", - "hidden": 1, - "label": "Mobile No", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Text", - "hidden": 1, - "label": "Contact Email", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 0, - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "transaction_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Purchase Order Date", - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "hidden": 0, - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "report_hide": 0 - }, - { - "description": "Select the relevant company name if you have multiple companies", - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "no_copy": 0, - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "price_list_and_currency", - "fieldtype": "Section Break", - "label": "Currency and Price List", - "options": "icon-tag" - }, - { - "doctype": "DocField", - "fieldname": "cb_currency", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "currency", - "fieldtype": "Link", - "label": "Currency", - "no_copy": 0, - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "print_hide": 1, - "reqd": 1 - }, - { - "description": "Rate at which supplier's currency is converted to company's base currency", - "doctype": "DocField", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "hidden": 0, - "label": "Exchange Rate", - "no_copy": 0, - "oldfieldname": "conversion_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb_price_list", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "buying_price_list", - "fieldtype": "Link", - "label": "Price List", - "options": "Price List", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "price_list_currency", - "fieldtype": "Link", - "label": "Price List Currency", - "options": "Currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "label": "Price List Exchange Rate", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "items", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "po_details", - "fieldtype": "Table", - "label": "Purchase Order Items", - "no_copy": 0, - "oldfieldname": "po_details", - "oldfieldtype": "Table", - "options": "Purchase Order Item" - }, - { - "doctype": "DocField", - "fieldname": "sb_last_purchase", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total_import", - "fieldtype": "Currency", - "label": "Net Total", - "no_copy": 0, - "oldfieldname": "net_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "get_last_purchase_rate", - "fieldtype": "Button", - "label": "Get Last Purchase Rate", - "oldfieldtype": "Button", - "print_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_26", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total (Company Currency)", - "no_copy": 1, - "oldfieldname": "net_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "taxes", - "fieldtype": "Section Break", - "label": "Taxes and Charges", - "oldfieldtype": "Section Break", - "options": "icon-money", - "print_hide": 0 - }, - { - "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.", - "doctype": "DocField", - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "no_copy": 0, - "oldfieldname": "purchase_other_charges", - "oldfieldtype": "Link", - "options": "Purchase Taxes and Charges Master", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "other_charges", - "fieldtype": "Table", - "label": "Purchase Taxes and Charges", - "no_copy": 0, - "oldfieldname": "purchase_tax_details", - "oldfieldtype": "Table", - "options": "Purchase Taxes and Charges" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_calculation", - "fieldtype": "HTML", - "label": "Taxes and Charges Calculation", - "no_copy": 1, - "oldfieldtype": "HTML", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "Totals", - "oldfieldtype": "Section Break", - "options": "icon-money" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_added_import", - "fieldtype": "Currency", - "label": "Taxes and Charges Added", - "no_copy": 0, - "oldfieldname": "other_charges_added_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "read_only": 1, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_deducted_import", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted", - "no_copy": 0, - "oldfieldname": "other_charges_deducted_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "read_only": 1, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "grand_total_import", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Grand Total", - "no_copy": 0, - "oldfieldname": "grand_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "in_words_import", - "fieldtype": "Data", - "label": "In Words", - "oldfieldname": "in_words_import", - "oldfieldtype": "Data", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_added", - "fieldtype": "Currency", - "label": "Taxes and Charges Added (Company Currency)", - "no_copy": 0, - "oldfieldname": "other_charges_added", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_deducted", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted (Company Currency)", - "no_copy": 0, - "oldfieldname": "other_charges_deducted", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_tax", - "fieldtype": "Currency", - "label": "Total Tax (Company Currency)", - "no_copy": 1, - "oldfieldname": "total_tax", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "no_copy": 1, - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total (Company Currency)", - "oldfieldname": "rounded_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "description": "In Words will be visible once you save the Purchase Order.", - "doctype": "DocField", - "fieldname": "in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "oldfieldtype": "Section Break", - "options": "icon-legal" - }, - { - "doctype": "DocField", - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Terms and Conditions", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor" - }, - { - "depends_on": "supplier", - "doctype": "DocField", - "fieldname": "contact_section", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn" - }, - { - "doctype": "DocField", - "fieldname": "supplier_address", - "fieldtype": "Link", - "in_filter": 1, - "label": "Supplier Address", - "options": "Address", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb_contact", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "in_filter": 1, - "label": "Contact Person", - "options": "Contact", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nDraft\nSubmitted\nStopped\nCancelled", - "print_hide": 1, - "read_only": 1, - "reqd": 1, - "search_index": 1 - }, - { - "default": "No", - "doctype": "DocField", - "fieldname": "is_subcontracted", - "fieldtype": "Select", - "label": "Is Subcontracted", - "options": "\nYes\nNo", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "ref_sq", - "fieldtype": "Data", - "hidden": 1, - "label": "Ref SQ", - "no_copy": 1, - "oldfieldname": "ref_sq", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Select", - "label": "Letter Head", - "oldfieldname": "letter_head", - "oldfieldtype": "Select", - "options": "link:Letter Head", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "no_copy": 0, - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "print_hide": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break5", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "print_width": "50%", - "width": "50%" - }, - { - "depends_on": "eval:!doc.__islocal", - "description": "% of materials received against this Purchase Order", - "doctype": "DocField", - "fieldname": "per_received", - "fieldtype": "Percent", - "in_list_view": 1, - "label": "% Received", - "no_copy": 1, - "oldfieldname": "per_received", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1 - }, - { - "depends_on": "eval:!doc.__islocal", - "description": "% of materials billed against this Purchase Order.", - "doctype": "DocField", - "fieldname": "per_billed", - "fieldtype": "Percent", - "in_list_view": 1, - "label": "% Billed", - "no_copy": 1, - "oldfieldname": "per_billed", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1 - }, - { - "description": "Required raw materials issued to the supplier for producing a sub - contracted item.", - "doctype": "DocField", - "fieldname": "raw_material_details", - "fieldtype": "Section Break", - "label": "Raw Materials Supplied", - "oldfieldtype": "Section Break", - "options": "icon-truck", - "print_hide": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "po_raw_material_details", - "fieldtype": "Table", - "label": "Purchase Order Items Supplied", - "no_copy": 0, - "oldfieldname": "po_raw_material_details", - "oldfieldtype": "Table", - "options": "Purchase Order Item Supplied", - "print_hide": 1, - "read_only": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Material User", - "submit": 0, - "write": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Purchase Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Purchase User", - "submit": 1, - "write": 1 - }, - { - "cancel": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Supplier" - } -] \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py index d58ce17beaf..d1d183a7a14 100644 --- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py @@ -8,143 +8,106 @@ import frappe.defaults from frappe.utils import flt class TestPurchaseOrder(unittest.TestCase): - def test_make_purchase_receipt(self): + def test_make_purchase_receipt(self): from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt - po = frappe.bean(copy=test_records[0]).insert() + po = frappe.copy_doc(test_records[0]).insert() - self.assertRaises(frappe.ValidationError, make_purchase_receipt, - po.doc.name) + self.assertRaises(frappe.ValidationError, make_purchase_receipt, + po.name) - po = frappe.bean("Purchase Order", po.doc.name) + po = frappe.get_doc("Purchase Order", po.name) po.submit() - - pr = make_purchase_receipt(po.doc.name) - pr[0]["supplier_warehouse"] = "_Test Warehouse 1 - _TC" - pr[0]["posting_date"] = "2013-05-12" - self.assertEquals(pr[0]["doctype"], "Purchase Receipt") - self.assertEquals(len(pr), len(test_records[0])) - - pr[0]["naming_series"] = "_T-Purchase Receipt-" - pr_bean = frappe.bean(pr) - pr_bean.insert() - + + pr = make_purchase_receipt(po.name) + pr.supplier_warehouse = "_Test Warehouse 1 - _TC" + pr.posting_date = "2013-05-12" + self.assertEquals(pr.doctype, "Purchase Receipt") + self.assertEquals(len(pr.get("purchase_receipt_details")), len(test_records[0]["po_details"])) + + pr.naming_series = "_T-Purchase Receipt-" + frappe.get_doc(pr).insert() + def test_ordered_qty(self): frappe.db.sql("delete from tabBin") - + from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt - po = frappe.bean(copy=test_records[0]).insert() + po = frappe.copy_doc(test_records[0]).insert() - self.assertRaises(frappe.ValidationError, make_purchase_receipt, - po.doc.name) + self.assertRaises(frappe.ValidationError, make_purchase_receipt, + po.name) - po = frappe.bean("Purchase Order", po.doc.name) - po.doc.is_subcontracted = "No" - po.doclist[1].item_code = "_Test Item" + po = frappe.get_doc("Purchase Order", po.name) + po.is_subcontracted = "No" + po.get("po_details")[0].item_code = "_Test Item" po.submit() - - self.assertEquals(frappe.db.get_value("Bin", {"item_code": "_Test Item", + + self.assertEquals(frappe.db.get_value("Bin", {"item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"}, "ordered_qty"), 10) - - pr = make_purchase_receipt(po.doc.name) - - self.assertEquals(pr[0]["doctype"], "Purchase Receipt") - self.assertEquals(len(pr), len(test_records[0])) - pr[0]["posting_date"] = "2013-05-12" - pr[0]["naming_series"] = "_T-Purchase Receipt-" - pr[1]["qty"] = 4.0 - pr_bean = frappe.bean(pr) - pr_bean.insert() - pr_bean.submit() - - self.assertEquals(flt(frappe.db.get_value("Bin", {"item_code": "_Test Item", + + pr = make_purchase_receipt(po.name) + + self.assertEquals(pr.doctype, "Purchase Receipt") + self.assertEquals(len(pr.get("purchase_receipt_details", [])), len(test_records[0]["po_details"])) + pr.posting_date = "2013-05-12" + pr.naming_series = "_T-Purchase Receipt-" + pr.purchase_receipt_details[0].qty = 4.0 + pr.insert() + pr.submit() + + self.assertEquals(flt(frappe.db.get_value("Bin", {"item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"}, "ordered_qty")), 6.0) - + frappe.db.set_value('Item', '_Test Item', 'tolerance', 50) - - pr1 = make_purchase_receipt(po.doc.name) - pr1[0]["naming_series"] = "_T-Purchase Receipt-" - pr1[0]["posting_date"] = "2013-05-12" - pr1[1]["qty"] = 8 - pr1_bean = frappe.bean(pr1) - pr1_bean.insert() - pr1_bean.submit() - - self.assertEquals(flt(frappe.db.get_value("Bin", {"item_code": "_Test Item", + + pr1 = make_purchase_receipt(po.name) + pr1.naming_series = "_T-Purchase Receipt-" + pr1.posting_date = "2013-05-12" + pr1.get("purchase_receipt_details")[0].qty = 8 + pr1.insert() + pr1.submit() + + self.assertEquals(flt(frappe.db.get_value("Bin", {"item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"}, "ordered_qty")), 0.0) - + def test_make_purchase_invoice(self): from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_invoice - po = frappe.bean(copy=test_records[0]).insert() + po = frappe.copy_doc(test_records[0]).insert() - self.assertRaises(frappe.ValidationError, make_purchase_invoice, - po.doc.name) + self.assertRaises(frappe.ValidationError, make_purchase_invoice, + po.name) - po = frappe.bean("Purchase Order", po.doc.name) + po = frappe.get_doc("Purchase Order", po.name) po.submit() - pi = make_purchase_invoice(po.doc.name) - - self.assertEquals(pi[0]["doctype"], "Purchase Invoice") - self.assertEquals(len(pi), len(test_records[0])) - pi[0]["posting_date"] = "2013-05-12" - pi[0]["bill_no"] = "NA" - frappe.bean(pi).insert() - + pi = make_purchase_invoice(po.name) + + self.assertEquals(pi.doctype, "Purchase Invoice") + self.assertEquals(len(pi.get("entries", [])), len(test_records[0]["po_details"])) + pi.posting_date = "2013-05-12" + pi.bill_no = "NA" + frappe.get_doc(pi).insert() + def test_subcontracting(self): - po = frappe.bean(copy=test_records[0]) + po = frappe.copy_doc(test_records[0]) po.insert() - self.assertEquals(len(po.doclist.get({"parentfield": "po_raw_material_details"})), 2) + self.assertEquals(len(po.get("po_raw_material_details")), 2) def test_warehouse_company_validation(self): from erpnext.stock.utils import InvalidWarehouseCompany - po = frappe.bean(copy=test_records[0]) - po.doc.company = "_Test Company 1" - po.doc.conversion_rate = 0.0167 + po = frappe.copy_doc(test_records[0]) + po.company = "_Test Company 1" + po.conversion_rate = 0.0167 self.assertRaises(InvalidWarehouseCompany, po.insert) def test_uom_integer_validation(self): from erpnext.utilities.transaction_base import UOMMustBeIntegerError - po = frappe.bean(copy=test_records[0]) - po.doclist[1].qty = 3.4 + po = frappe.copy_doc(test_records[0]) + po.get("po_details")[0].qty = 3.4 self.assertRaises(UOMMustBeIntegerError, po.insert) test_dependencies = ["BOM"] -test_records = [ - [ - { - "company": "_Test Company", - "naming_series": "_T-Purchase Order-", - "conversion_rate": 1.0, - "currency": "INR", - "doctype": "Purchase Order", - "fiscal_year": "_Test Fiscal Year 2013", - "transaction_date": "2013-02-12", - "is_subcontracted": "Yes", - "supplier": "_Test Supplier", - "supplier_name": "_Test Supplier", - "net_total": 5000.0, - "grand_total": 5000.0, - "grand_total_import": 5000.0, - "buying_price_list": "_Test Price List" - }, - { - "conversion_factor": 1.0, - "description": "_Test FG Item", - "doctype": "Purchase Order Item", - "item_code": "_Test FG Item", - "item_name": "_Test FG Item", - "parentfield": "po_details", - "qty": 10.0, - "rate": 500.0, - "base_amount": 5000.0, - "warehouse": "_Test Warehouse - _TC", - "stock_uom": "_Test UOM", - "uom": "_Test UOM", - "schedule_date": "2013-03-01" - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Purchase Order') diff --git a/erpnext/buying/doctype/purchase_order/test_records.json b/erpnext/buying/doctype/purchase_order/test_records.json new file mode 100644 index 00000000000..3aaf542a327 --- /dev/null +++ b/erpnext/buying/doctype/purchase_order/test_records.json @@ -0,0 +1,35 @@ +[ + { + "buying_price_list": "_Test Price List", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "doctype": "Purchase Order", + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 5000.0, + "grand_total_import": 5000.0, + "is_subcontracted": "Yes", + "naming_series": "_T-Purchase Order-", + "net_total": 5000.0, + "po_details": [ + { + "base_amount": 5000.0, + "conversion_factor": 1.0, + "description": "_Test FG Item", + "doctype": "Purchase Order Item", + "item_code": "_Test FG Item", + "item_name": "_Test FG Item", + "parentfield": "po_details", + "qty": 10.0, + "rate": 500.0, + "schedule_date": "2013-03-01", + "stock_uom": "_Test UOM", + "uom": "_Test UOM", + "warehouse": "_Test Warehouse - _TC" + } + ], + "supplier": "_Test Supplier", + "supplier_name": "_Test Supplier", + "transaction_date": "2013-02-12" + } +] \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json new file mode 100755 index 00000000000..23fb1c0e95d --- /dev/null +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json @@ -0,0 +1,482 @@ +{ + "autoname": "POD/.#####", + "creation": "2013-05-24 19:29:06.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "description": "If Supplier Part Number exists for given Item, it gets stored here", + "fieldname": "supplier_part_no", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Supplier Part Number", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "hidden": 0, + "in_filter": 1, + "in_list_view": 0, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "schedule_date", + "fieldtype": "Date", + "hidden": 0, + "in_filter": 1, + "in_list_view": 0, + "label": "Reqd By Date", + "no_copy": 0, + "oldfieldname": "schedule_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 0, + "reqd": 1, + "width": "300px" + }, + { + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Quantity and Rate", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Quantity", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "60px", + "read_only": 0, + "reqd": 1, + "width": "60px" + }, + { + "fieldname": "uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "oldfieldname": "uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "hidden": 0, + "in_list_view": 0, + "label": "Stock UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "conversion_factor", + "fieldtype": "Float", + "hidden": 0, + "in_list_view": 0, + "label": "UOM Conversion Factor", + "oldfieldname": "conversion_factor", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "sec_break1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "discount_percentage", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Discount %", + "permlevel": 0, + "print_hide": 0, + "read_only": 0 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "base_price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "sec_break2", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "rate", + "fieldtype": "Currency", + "hidden": 0, + "in_list_view": 1, + "label": "Rate ", + "oldfieldname": "import_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 0 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "import_amount", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "base_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Rate (Company Currency)", + "oldfieldname": "purchase_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "base_amount", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Amount (Company Currency)", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "pricing_rule_for_price", + "fieldtype": "Link", + "label": "Pricing Rule For Price", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "pricing_rule_for_discount", + "fieldtype": "Link", + "label": "Pricing Rule For Discount", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "warehouse_and_reference", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Warehouse and Reference", + "permlevel": 0 + }, + { + "fieldname": "warehouse", + "fieldtype": "Link", + "hidden": 0, + "in_list_view": 0, + "label": "Warehouse", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "project_name", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 0, + "label": "Project Name", + "options": "Project", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0 + }, + { + "fieldname": "prevdoc_doctype", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Prevdoc DocType", + "no_copy": 1, + "oldfieldname": "prevdoc_doctype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "prevdoc_docname", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "in_list_view": 0, + "label": "Material Request No", + "no_copy": 1, + "oldfieldname": "prevdoc_docname", + "oldfieldtype": "Link", + "options": "Material Request", + "permlevel": 0, + "print_hide": 1, + "print_width": "120px", + "read_only": 1, + "search_index": 1, + "width": "120px" + }, + { + "fieldname": "prevdoc_detail_docname", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "Material Request Detail No", + "no_copy": 1, + "oldfieldname": "prevdoc_detail_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "supplier_quotation", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Supplier Quotation", + "no_copy": 1, + "options": "Supplier Quotation", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "supplier_quotation_item", + "fieldtype": "Link", + "hidden": 1, + "in_list_view": 1, + "label": "Supplier Quotation Item", + "no_copy": 1, + "options": "Supplier Quotation Item", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "col_break5", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "in_list_view": 1, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "brand", + "fieldtype": "Link", + "hidden": 1, + "in_list_view": 1, + "label": "Brand", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "stock_qty", + "fieldtype": "Float", + "hidden": 0, + "in_list_view": 1, + "label": "Qty as per Stock UOM", + "no_copy": 1, + "oldfieldname": "stock_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "width": "100px" + }, + { + "fieldname": "received_qty", + "fieldtype": "Float", + "hidden": 0, + "in_list_view": 1, + "label": "Received Qty", + "no_copy": 1, + "oldfieldname": "received_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "billed_amt", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Billed Amt", + "no_copy": 1, + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges", + "fieldname": "item_tax_rate", + "fieldtype": "Small Text", + "hidden": 1, + "in_list_view": 1, + "label": "Item Tax Rate", + "oldfieldname": "item_tax_rate", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "hidden": 0, + "in_list_view": 1, + "label": "Page Break", + "no_copy": 1, + "oldfieldname": "page_break", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-28 11:26:25.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Order Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py index 26c87f1c04a..8c7c0a8a473 100644 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseOrderItem(Document): + pass \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.txt b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.txt deleted file mode 100755 index 192b206461a..00000000000 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.txt +++ /dev/null @@ -1,495 +0,0 @@ -[ - { - "creation": "2013-05-24 19:29:06", - "docstatus": 0, - "modified": "2014-02-28 11:26:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "POD/.#####", - "doctype": "DocType", - "istable": 1, - "module": "Buying", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Purchase Order Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Purchase Order Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "print_hide": 0, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "description": "If Supplier Part Number exists for given Item, it gets stored here", - "doctype": "DocField", - "fieldname": "supplier_part_no", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Supplier Part Number", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "hidden": 0, - "in_filter": 1, - "in_list_view": 0, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "schedule_date", - "fieldtype": "Date", - "hidden": 0, - "in_filter": 1, - "in_list_view": 0, - "label": "Reqd By Date", - "no_copy": 0, - "oldfieldname": "schedule_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "print_width": "300px", - "read_only": 0, - "reqd": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Quantity and Rate" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Quantity", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "print_width": "60px", - "read_only": 0, - "reqd": 1, - "width": "60px" - }, - { - "doctype": "DocField", - "fieldname": "uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "oldfieldname": "uom", - "oldfieldtype": "Link", - "options": "UOM", - "print_hide": 0, - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "hidden": 0, - "in_list_view": 0, - "label": "Stock UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "conversion_factor", - "fieldtype": "Float", - "hidden": 0, - "in_list_view": 0, - "label": "UOM Conversion Factor", - "oldfieldname": "conversion_factor", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "sec_break1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate", - "options": "currency", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "discount_percentage", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Discount %", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "base_price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate (Company Currency)", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "sec_break2", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Currency", - "hidden": 0, - "in_list_view": 1, - "label": "Rate ", - "oldfieldname": "import_rate", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "import_amount", - "oldfieldtype": "Currency", - "options": "currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break4", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "base_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Rate (Company Currency)", - "oldfieldname": "purchase_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "base_amount", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Amount (Company Currency)", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_price", - "fieldtype": "Link", - "label": "Pricing Rule For Price", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_discount", - "fieldtype": "Link", - "label": "Pricing Rule For Discount", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "warehouse_and_reference", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Warehouse and Reference" - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "hidden": 0, - "in_list_view": 0, - "label": "Warehouse", - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "project_name", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 0, - "label": "Project Name", - "options": "Project", - "print_hide": 1, - "read_only": 0, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_doctype", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Prevdoc DocType", - "no_copy": 1, - "oldfieldname": "prevdoc_doctype", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_docname", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "in_list_view": 0, - "label": "Material Request No", - "no_copy": 1, - "oldfieldname": "prevdoc_docname", - "oldfieldtype": "Link", - "options": "Material Request", - "print_hide": 1, - "print_width": "120px", - "read_only": 1, - "search_index": 1, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_detail_docname", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "Material Request Detail No", - "no_copy": 1, - "oldfieldname": "prevdoc_detail_docname", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "supplier_quotation", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 0, - "in_list_view": 0, - "label": "Supplier Quotation", - "no_copy": 1, - "options": "Supplier Quotation", - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "supplier_quotation_item", - "fieldtype": "Link", - "hidden": 1, - "in_list_view": 1, - "label": "Supplier Quotation Item", - "no_copy": 1, - "options": "Supplier Quotation Item", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break5", - "fieldtype": "Column Break" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "in_list_view": 1, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "print_hide": 1, - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Link", - "hidden": 1, - "in_list_view": 1, - "label": "Brand", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "stock_qty", - "fieldtype": "Float", - "hidden": 0, - "in_list_view": 1, - "label": "Qty as per Stock UOM", - "no_copy": 1, - "oldfieldname": "stock_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "received_qty", - "fieldtype": "Float", - "hidden": 0, - "in_list_view": 1, - "label": "Received Qty", - "no_copy": 1, - "oldfieldname": "received_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "billed_amt", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Billed Amt", - "no_copy": 1, - "options": "currency", - "print_hide": 1, - "read_only": 1 - }, - { - "description": "Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges", - "doctype": "DocField", - "fieldname": "item_tax_rate", - "fieldtype": "Small Text", - "hidden": 1, - "in_list_view": 1, - "label": "Item Tax Rate", - "oldfieldname": "item_tax_rate", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 1, - "report_hide": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "page_break", - "fieldtype": "Check", - "hidden": 0, - "in_list_view": 1, - "label": "Page Break", - "no_copy": 1, - "oldfieldname": "page_break", - "oldfieldtype": "Check", - "print_hide": 1, - "read_only": 0 - } -] \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.json b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.json new file mode 100644 index 00000000000..df947e644b6 --- /dev/null +++ b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.json @@ -0,0 +1,108 @@ +{ + "creation": "2013-02-22 01:27:42.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "reference_name", + "fieldtype": "Data", + "hidden": 0, + "in_filter": 0, + "in_list_view": 1, + "label": "Reference Name", + "oldfieldname": "reference_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "bom_detail_no", + "fieldtype": "Data", + "in_list_view": 1, + "label": "BOM Detail No", + "oldfieldname": "bom_detail_no", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "main_item_code", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "main_item_code", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "rm_item_code", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Raw Material Item Code", + "oldfieldname": "rm_item_code", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "required_qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Required Qty", + "oldfieldname": "required_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "rate", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "label": "Amount", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "conversion_factor", + "fieldtype": "Float", + "hidden": 1, + "label": "Conversion Factor", + "oldfieldname": "conversion_factor", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "label": "Stock Uom", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "read_only": 1 + } + ], + "hide_toolbar": 1, + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:33.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Order Item Supplied", + "owner": "dhanalekshmi@webnotestech.com" +} \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py index 26c87f1c04a..d1542fc7a65 100644 --- a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py +++ b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseOrderItemSupplied(Document): + pass \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.txt b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.txt deleted file mode 100644 index f2860cde544..00000000000 --- a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.txt +++ /dev/null @@ -1,121 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:42", - "docstatus": 0, - "modified": "2013-12-20 19:23:33", - "modified_by": "Administrator", - "owner": "dhanalekshmi@webnotestech.com" - }, - { - "doctype": "DocType", - "hide_toolbar": 1, - "istable": 1, - "module": "Buying", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Purchase Order Item Supplied", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Purchase Order Item Supplied" - }, - { - "doctype": "DocField", - "fieldname": "reference_name", - "fieldtype": "Data", - "hidden": 0, - "in_filter": 0, - "in_list_view": 1, - "label": "Reference Name", - "oldfieldname": "reference_name", - "oldfieldtype": "Data", - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "bom_detail_no", - "fieldtype": "Data", - "in_list_view": 1, - "label": "BOM Detail No", - "oldfieldname": "bom_detail_no", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "main_item_code", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "main_item_code", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "rm_item_code", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Raw Material Item Code", - "oldfieldname": "rm_item_code", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "required_qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Required Qty", - "oldfieldname": "required_qty", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "label": "Amount", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "conversion_factor", - "fieldtype": "Float", - "hidden": 1, - "label": "Conversion Factor", - "oldfieldname": "conversion_factor", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "label": "Stock Uom", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "read_only": 1 - } -] \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.json b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.json new file mode 100644 index 00000000000..25ff1da98ff --- /dev/null +++ b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.json @@ -0,0 +1,145 @@ +{ + "creation": "2013-02-22 01:27:42.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "main_item_code", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "main_item_code", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "rm_item_code", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Raw Material Item Code", + "oldfieldname": "rm_item_code", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "300px", + "read_only": 1, + "width": "300px" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "required_qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Required Qty", + "oldfieldname": "required_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "consumed_qty", + "fieldtype": "Float", + "label": "Consumed Qty", + "oldfieldname": "consumed_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "label": "Stock Uom", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "rate", + "fieldtype": "Currency", + "label": "Rate", + "oldfieldname": "rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "label": "Amount", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "conversion_factor", + "fieldtype": "Float", + "hidden": 1, + "label": "Conversion Factor", + "oldfieldname": "conversion_factor", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "current_stock", + "fieldtype": "Float", + "hidden": 1, + "label": "Current Stock", + "oldfieldname": "current_stock", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "reference_name", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 0, + "in_list_view": 1, + "label": "Reference Name", + "oldfieldname": "reference_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "bom_detail_no", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 1, + "label": "BOM Detail No", + "oldfieldname": "bom_detail_no", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + } + ], + "hide_toolbar": 0, + "idx": 1, + "istable": 1, + "modified": "2014-02-13 11:29:35.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Receipt Item Supplied", + "owner": "wasim@webnotestech.com" +} \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py index 26c87f1c04a..1270cf0e745 100644 --- a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py +++ b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseReceiptItemSupplied(Document): + pass \ No newline at end of file diff --git a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.txt b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.txt deleted file mode 100644 index e28bdb7b26b..00000000000 --- a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.txt +++ /dev/null @@ -1,158 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:42", - "docstatus": 0, - "modified": "2014-02-13 11:29:35", - "modified_by": "Administrator", - "owner": "wasim@webnotestech.com" - }, - { - "doctype": "DocType", - "hide_toolbar": 0, - "istable": 1, - "module": "Buying", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Purchase Receipt Item Supplied", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Purchase Receipt Item Supplied" - }, - { - "doctype": "DocField", - "fieldname": "main_item_code", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "main_item_code", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "rm_item_code", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Raw Material Item Code", - "oldfieldname": "rm_item_code", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Data", - "print_width": "300px", - "read_only": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "required_qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Required Qty", - "oldfieldname": "required_qty", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "consumed_qty", - "fieldtype": "Float", - "label": "Consumed Qty", - "oldfieldname": "consumed_qty", - "oldfieldtype": "Currency", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "label": "Stock Uom", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Currency", - "label": "Rate", - "oldfieldname": "rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "label": "Amount", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "conversion_factor", - "fieldtype": "Float", - "hidden": 1, - "label": "Conversion Factor", - "oldfieldname": "conversion_factor", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "current_stock", - "fieldtype": "Float", - "hidden": 1, - "label": "Current Stock", - "oldfieldname": "current_stock", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "reference_name", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 0, - "in_list_view": 1, - "label": "Reference Name", - "oldfieldname": "reference_name", - "oldfieldtype": "Data", - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "bom_detail_no", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 1, - "label": "BOM Detail No", - "oldfieldname": "bom_detail_no", - "oldfieldtype": "Data", - "read_only": 1 - } -] \ No newline at end of file diff --git a/erpnext/buying/doctype/quality_inspection/quality_inspection.json b/erpnext/buying/doctype/quality_inspection/quality_inspection.json new file mode 100644 index 00000000000..fcd5439030e --- /dev/null +++ b/erpnext/buying/doctype/quality_inspection/quality_inspection.json @@ -0,0 +1,228 @@ +{ + "autoname": "naming_series:", + "creation": "2013-04-30 13:13:03.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "qa_inspection", + "fieldtype": "Section Break", + "label": "QA Inspection", + "no_copy": 0, + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "options": "\nQAI/11-12/", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "inspection_type", + "fieldtype": "Select", + "in_filter": 1, + "label": "Inspection Type", + "oldfieldname": "inspection_type", + "oldfieldtype": "Select", + "options": "\nIncoming\nOutgoing\nIn Process", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "report_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Report Date", + "oldfieldname": "report_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "item_code", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "sample_size", + "fieldtype": "Float", + "in_filter": 0, + "label": "Sample Size", + "oldfieldname": "sample_size", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_filter": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "search_index": 0, + "width": "300px" + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "item_serial_no", + "fieldtype": "Link", + "hidden": 0, + "label": "Item Serial No", + "oldfieldname": "item_serial_no", + "oldfieldtype": "Link", + "options": "Serial No", + "permlevel": 0, + "print_hide": 0 + }, + { + "fieldname": "batch_no", + "fieldtype": "Link", + "label": "Batch No", + "oldfieldname": "batch_no", + "oldfieldtype": "Link", + "options": "Batch", + "permlevel": 0 + }, + { + "fieldname": "purchase_receipt_no", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Purchase Receipt No", + "oldfieldname": "purchase_receipt_no", + "oldfieldtype": "Link", + "options": "Purchase Receipt", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "delivery_note_no", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Delivery Note No", + "oldfieldname": "delivery_note_no", + "oldfieldtype": "Link", + "options": "Delivery Note", + "permlevel": 0, + "print_hide": 0, + "search_index": 1 + }, + { + "fieldname": "inspected_by", + "fieldtype": "Data", + "label": "Inspected By", + "oldfieldname": "inspected_by", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "remarks", + "fieldtype": "Text", + "label": "Remarks", + "no_copy": 1, + "oldfieldname": "remarks", + "oldfieldtype": "Text", + "permlevel": 0 + }, + { + "fieldname": "verified_by", + "fieldtype": "Data", + "label": "Verified By", + "oldfieldname": "verified_by", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "specification_details", + "fieldtype": "Section Break", + "label": "Specification Details", + "oldfieldtype": "Section Break", + "options": "Simple", + "permlevel": 0 + }, + { + "fieldname": "get_specification_details", + "fieldtype": "Button", + "label": "Get Specification Details", + "options": "get_item_specification_details", + "permlevel": 0 + }, + { + "fieldname": "qa_specification_details", + "fieldtype": "Table", + "label": "Quality Inspection Readings", + "oldfieldname": "qa_specification_details", + "oldfieldtype": "Table", + "options": "Quality Inspection Reading", + "permlevel": 0 + } + ], + "icon": "icon-search", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:49:14.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Quality Inspection", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Quality Manager", + "submit": 1, + "write": 1 + } + ], + "search_fields": "item_code, report_date, purchase_receipt_no, delivery_note_no" +} \ No newline at end of file diff --git a/erpnext/buying/doctype/quality_inspection/quality_inspection.py b/erpnext/buying/doctype/quality_inspection/quality_inspection.py index 4222d68b495..3fc130a7ac1 100644 --- a/erpnext/buying/doctype/quality_inspection/quality_inspection.py +++ b/erpnext/buying/doctype/quality_inspection/quality_inspection.py @@ -4,38 +4,36 @@ from __future__ import unicode_literals import frappe -from frappe.model.doc import addchild -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class QualityInspection(Document): def get_item_specification_details(self): - self.doclist = self.doc.clear_table(self.doclist, 'qa_specification_details') + self.set('qa_specification_details', []) specification = frappe.db.sql("select specification, value from `tabItem Quality Inspection Parameter` \ - where parent = '%s' order by idx" % (self.doc.item_code)) + where parent = '%s' order by idx" % (self.item_code)) for d in specification: - child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', self.doclist) + child = self.append('qa_specification_details', {}) child.specification = d[0] child.value = d[1] child.status = 'Accepted' def on_submit(self): - if self.doc.purchase_receipt_no: + if self.purchase_receipt_no: frappe.db.sql("""update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = %s, t2.modified = %s where t1.parent = %s and t1.item_code = %s and t1.parent = t2.name""", - (self.doc.name, self.doc.modified, self.doc.purchase_receipt_no, - self.doc.item_code)) + (self.name, self.modified, self.purchase_receipt_no, + self.item_code)) def on_cancel(self): - if self.doc.purchase_receipt_no: + if self.purchase_receipt_no: frappe.db.sql("""update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '', t2.modified = %s where t1.parent = %s and t1.item_code = %s and t1.parent = t2.name""", - (self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code)) + (self.modified, self.purchase_receipt_no, self.item_code)) def item_query(doctype, txt, searchfield, start, page_len, filters): diff --git a/erpnext/buying/doctype/quality_inspection/quality_inspection.txt b/erpnext/buying/doctype/quality_inspection/quality_inspection.txt deleted file mode 100644 index 899d3f863d9..00000000000 --- a/erpnext/buying/doctype/quality_inspection/quality_inspection.txt +++ /dev/null @@ -1,247 +0,0 @@ -[ - { - "creation": "2013-04-30 13:13:03", - "docstatus": 0, - "modified": "2014-01-20 17:49:14", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "naming_series:", - "doctype": "DocType", - "icon": "icon-search", - "is_submittable": 1, - "module": "Buying", - "name": "__common__", - "search_fields": "item_code, report_date, purchase_receipt_no, delivery_note_no" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Quality Inspection", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Quality Inspection", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Quality Manager", - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Quality Inspection" - }, - { - "doctype": "DocField", - "fieldname": "qa_inspection", - "fieldtype": "Section Break", - "label": "QA Inspection", - "no_copy": 0, - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "options": "\nQAI/11-12/", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "inspection_type", - "fieldtype": "Select", - "in_filter": 1, - "label": "Inspection Type", - "oldfieldname": "inspection_type", - "oldfieldtype": "Select", - "options": "\nIncoming\nOutgoing\nIn Process", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "report_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Report Date", - "oldfieldname": "report_date", - "oldfieldtype": "Date", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "sample_size", - "fieldtype": "Float", - "in_filter": 0, - "label": "Sample Size", - "oldfieldname": "sample_size", - "oldfieldtype": "Currency", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_filter": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "search_index": 0, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "item_serial_no", - "fieldtype": "Link", - "hidden": 0, - "label": "Item Serial No", - "oldfieldname": "item_serial_no", - "oldfieldtype": "Link", - "options": "Serial No", - "print_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "batch_no", - "fieldtype": "Link", - "label": "Batch No", - "oldfieldname": "batch_no", - "oldfieldtype": "Link", - "options": "Batch" - }, - { - "doctype": "DocField", - "fieldname": "purchase_receipt_no", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Purchase Receipt No", - "oldfieldname": "purchase_receipt_no", - "oldfieldtype": "Link", - "options": "Purchase Receipt", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "delivery_note_no", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Delivery Note No", - "oldfieldname": "delivery_note_no", - "oldfieldtype": "Link", - "options": "Delivery Note", - "print_hide": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "inspected_by", - "fieldtype": "Data", - "label": "Inspected By", - "oldfieldname": "inspected_by", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "remarks", - "fieldtype": "Text", - "label": "Remarks", - "no_copy": 1, - "oldfieldname": "remarks", - "oldfieldtype": "Text" - }, - { - "doctype": "DocField", - "fieldname": "verified_by", - "fieldtype": "Data", - "label": "Verified By", - "oldfieldname": "verified_by", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "specification_details", - "fieldtype": "Section Break", - "label": "Specification Details", - "oldfieldtype": "Section Break", - "options": "Simple" - }, - { - "doctype": "DocField", - "fieldname": "get_specification_details", - "fieldtype": "Button", - "label": "Get Specification Details", - "options": "get_item_specification_details" - }, - { - "doctype": "DocField", - "fieldname": "qa_specification_details", - "fieldtype": "Table", - "label": "Quality Inspection Readings", - "oldfieldname": "qa_specification_details", - "oldfieldtype": "Table", - "options": "Quality Inspection Reading" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.json b/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.json new file mode 100644 index 00000000000..21712efe212 --- /dev/null +++ b/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.json @@ -0,0 +1,128 @@ +{ + "autoname": "QASD/.#####", + "creation": "2013-02-22 01:27:43.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "specification", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Parameter", + "oldfieldname": "specification", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "value", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Acceptance Criteria", + "oldfieldname": "value", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "reading_1", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Reading 1", + "oldfieldname": "reading_1", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "reading_2", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Reading 2", + "oldfieldname": "reading_2", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "reading_3", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Reading 3", + "oldfieldname": "reading_3", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "reading_4", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Reading 4", + "oldfieldname": "reading_4", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "reading_5", + "fieldtype": "Data", + "label": "Reading 5", + "oldfieldname": "reading_5", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "reading_6", + "fieldtype": "Data", + "label": "Reading 6", + "oldfieldname": "reading_6", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "reading_7", + "fieldtype": "Data", + "label": "Reading 7", + "oldfieldname": "reading_7", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "reading_8", + "fieldtype": "Data", + "label": "Reading 8", + "oldfieldname": "reading_8", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "reading_9", + "fieldtype": "Data", + "label": "Reading 9", + "oldfieldname": "reading_9", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "reading_10", + "fieldtype": "Data", + "label": "Reading 10", + "oldfieldname": "reading_10", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "default": "Accepted", + "fieldname": "status", + "fieldtype": "Select", + "label": "Status", + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "Accepted\nRejected", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:39.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Quality Inspection Reading", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py b/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py index 26c87f1c04a..1e36103dd09 100644 --- a/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py +++ b/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class QualityInspectionReading(Document): + pass \ No newline at end of file diff --git a/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.txt b/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.txt deleted file mode 100644 index f08e7cd5d2f..00000000000 --- a/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.txt +++ /dev/null @@ -1,141 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:43", - "docstatus": 0, - "modified": "2013-12-20 19:23:39", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "QASD/.#####", - "doctype": "DocType", - "istable": 1, - "module": "Buying", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Quality Inspection Reading", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Quality Inspection Reading" - }, - { - "doctype": "DocField", - "fieldname": "specification", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Parameter", - "oldfieldname": "specification", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "value", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Acceptance Criteria", - "oldfieldname": "value", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "reading_1", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Reading 1", - "oldfieldname": "reading_1", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "reading_2", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Reading 2", - "oldfieldname": "reading_2", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "reading_3", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Reading 3", - "oldfieldname": "reading_3", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "reading_4", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Reading 4", - "oldfieldname": "reading_4", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "reading_5", - "fieldtype": "Data", - "label": "Reading 5", - "oldfieldname": "reading_5", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "reading_6", - "fieldtype": "Data", - "label": "Reading 6", - "oldfieldname": "reading_6", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "reading_7", - "fieldtype": "Data", - "label": "Reading 7", - "oldfieldname": "reading_7", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "reading_8", - "fieldtype": "Data", - "label": "Reading 8", - "oldfieldname": "reading_8", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "reading_9", - "fieldtype": "Data", - "label": "Reading 9", - "oldfieldname": "reading_9", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "reading_10", - "fieldtype": "Data", - "label": "Reading 10", - "oldfieldname": "reading_10", - "oldfieldtype": "Data" - }, - { - "default": "Accepted", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "label": "Status", - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "Accepted\nRejected" - } -] \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index cfe526fc584..05288c38825 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -17,7 +17,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.cscript.make_contact(doc,dt,dn); cur_frm.communication_view = new frappe.views.CommunicationList({ - list: frappe.model.get("Communication", {"supplier": doc.name}), + list: frappe.get_list("Communication", {"supplier": doc.name}), parent: cur_frm.fields_dict.communication_html.wrapper, doc: doc }) diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json new file mode 100644 index 00000000000..e43c628b8bf --- /dev/null +++ b/erpnext/buying/doctype/supplier/supplier.json @@ -0,0 +1,222 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "naming_series:", + "creation": "2013-01-10 16:34:11.000000", + "description": "Supplier of Goods or Services.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "basic_info", + "fieldtype": "Section Break", + "label": "Basic Info", + "oldfieldtype": "Section Break", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "\nSUPP\nSUPP/10-11/", + "permlevel": 0 + }, + { + "fieldname": "supplier_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Supplier Name", + "no_copy": 1, + "oldfieldname": "supplier_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "supplier_type", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Supplier Type", + "oldfieldname": "supplier_type", + "oldfieldtype": "Link", + "options": "Supplier Type", + "permlevel": 0, + "reqd": 1 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "address_contacts", + "fieldtype": "Section Break", + "label": "Address & Contacts", + "oldfieldtype": "Column Break", + "options": "icon-map-marker", + "permlevel": 0 + }, + { + "fieldname": "address_html", + "fieldtype": "HTML", + "label": "Address HTML", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "contact_html", + "fieldtype": "HTML", + "label": "Contact HTML", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "communication_history", + "fieldtype": "Section Break", + "label": "Communication History", + "options": "icon-comments", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "communication_html", + "fieldtype": "HTML", + "label": "Communication HTML", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0 + }, + { + "description": "Enter the company name under which Account Head will be created for this Supplier", + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "default_currency", + "fieldtype": "Link", + "label": "Default Currency", + "no_copy": 1, + "options": "Currency", + "permlevel": 0 + }, + { + "fieldname": "default_price_list", + "fieldtype": "Link", + "label": "Price List", + "options": "Price List", + "permlevel": 0 + }, + { + "fieldname": "default_taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "options": "Purchase Taxes and Charges Master", + "permlevel": 0 + }, + { + "fieldname": "credit_days", + "fieldtype": "Int", + "label": "Credit Days", + "permlevel": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "website", + "fieldtype": "Data", + "label": "Website", + "oldfieldname": "website", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "description": "Statutory info and other general information about your Supplier", + "fieldname": "supplier_details", + "fieldtype": "Text", + "label": "Supplier Details", + "oldfieldname": "supplier_details", + "oldfieldtype": "Code", + "permlevel": 0 + }, + { + "fieldname": "communications", + "fieldtype": "Table", + "hidden": 1, + "label": "Communications", + "options": "Communication", + "permlevel": 0, + "print_hide": 1 + } + ], + "icon": "icon-user", + "idx": 1, + "modified": "2014-01-28 19:05:55.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Supplier", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Manager", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Master Manager", + "submit": 0, + "write": 1 + } + ], + "search_fields": "supplier_name,supplier_type" +} \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index f937958eda4..e48c0bfc3d1 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -7,58 +7,54 @@ import frappe.defaults from frappe.utils import cint from frappe import msgprint, _ -from frappe.model.doc import make_autoname +from frappe.model.naming import make_autoname from erpnext.accounts.party import create_party_account from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class Supplier(TransactionBase): def autoname(self): supp_master_name = frappe.defaults.get_global_default('supp_master_name') - if supp_master_name == 'Supplier Name': - if frappe.db.exists("Customer", self.doc.supplier_name): + if frappe.db.exists("Customer", self.supplier_name): frappe.msgprint(_("A Customer exists with same name"), raise_exception=1) - self.doc.name = self.doc.supplier_name + self.name = self.supplier_name else: - self.doc.name = make_autoname(self.doc.naming_series + '.#####') + self.name = make_autoname(self.naming_series + '.#####') def update_address(self): frappe.db.sql("""update `tabAddress` set supplier_name=%s, modified=NOW() - where supplier=%s""", (self.doc.supplier_name, self.doc.name)) + where supplier=%s""", (self.supplier_name, self.name)) def update_contact(self): frappe.db.sql("""update `tabContact` set supplier_name=%s, modified=NOW() - where supplier=%s""", (self.doc.supplier_name, self.doc.name)) + where supplier=%s""", (self.supplier_name, self.name)) def update_credit_days_limit(self): frappe.db.sql("""update tabAccount set credit_days = %s where name = %s""", - (cint(self.doc.credit_days), self.doc.name + " - " + self.get_company_abbr())) + (cint(self.credit_days), self.name + " - " + self.get_company_abbr())) def on_update(self): - if not self.doc.naming_series: - self.doc.naming_series = '' + if not self.naming_series: + self.naming_series = '' self.update_address() self.update_contact() # create account head - create_party_account(self.doc.name, "Supplier", self.doc.company) + create_party_account(self.name, "Supplier", self.company) # update credit days and limit in account self.update_credit_days_limit() def get_company_abbr(self): - return frappe.db.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0] + return frappe.db.sql("select abbr from tabCompany where name=%s", self.company)[0][0] def validate(self): #validation for Naming Series mandatory field... if frappe.defaults.get_global_default('supp_master_name') == 'Naming Series': - if not self.doc.naming_series: + if not self.naming_series: msgprint("Series is Mandatory.", raise_exception=1) def get_contacts(self,nm): @@ -70,18 +66,18 @@ class DocType(TransactionBase): return '' def delete_supplier_address(self): - for rec in frappe.db.sql("select * from `tabAddress` where supplier=%s", (self.doc.name,), as_dict=1): + for rec in frappe.db.sql("select * from `tabAddress` where supplier=%s", (self.name,), as_dict=1): frappe.db.sql("delete from `tabAddress` where name=%s",(rec['name'])) def delete_supplier_contact(self): for contact in frappe.db.sql_list("""select name from `tabContact` - where supplier=%s""", self.doc.name): + where supplier=%s""", self.name): frappe.delete_doc("Contact", contact) def delete_supplier_account(self): """delete supplier's ledger if exist and check balance before deletion""" acc = frappe.db.sql("select name from `tabAccount` where master_type = 'Supplier' \ - and master_name = %s and docstatus < 2", self.doc.name) + and master_name = %s and docstatus < 2", self.name) if acc: frappe.delete_doc('Account', acc[0][0]) @@ -92,12 +88,12 @@ class DocType(TransactionBase): def before_rename(self, olddn, newdn, merge=False): from erpnext.accounts.utils import rename_account_for - rename_account_for("Supplier", olddn, newdn, merge, self.doc.company) + rename_account_for("Supplier", olddn, newdn, merge, self.company) def after_rename(self, olddn, newdn, merge=False): set_field = '' if frappe.defaults.get_global_default('supp_master_name') == 'Supplier Name': - frappe.db.set(self.doc, "supplier_name", newdn) + frappe.db.set(self, "supplier_name", newdn) self.update_contact() set_field = ", supplier_name=%(newdn)s" self.update_supplier_address(newdn, set_field) diff --git a/erpnext/buying/doctype/supplier/supplier.txt b/erpnext/buying/doctype/supplier/supplier.txt deleted file mode 100644 index a5d100fdd52..00000000000 --- a/erpnext/buying/doctype/supplier/supplier.txt +++ /dev/null @@ -1,234 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:11", - "docstatus": 0, - "modified": "2014-01-28 19:05:55", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "naming_series:", - "description": "Supplier of Goods or Services.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-user", - "module": "Buying", - "name": "__common__", - "search_fields": "supplier_name,supplier_type" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Supplier", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Supplier", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Supplier" - }, - { - "doctype": "DocField", - "fieldname": "basic_info", - "fieldtype": "Section Break", - "label": "Basic Info", - "oldfieldtype": "Section Break", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "\nSUPP\nSUPP/10-11/" - }, - { - "doctype": "DocField", - "fieldname": "supplier_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Supplier Name", - "no_copy": 1, - "oldfieldname": "supplier_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "supplier_type", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Supplier Type", - "oldfieldname": "supplier_type", - "oldfieldtype": "Link", - "options": "Supplier Type", - "reqd": 1 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "address_contacts", - "fieldtype": "Section Break", - "label": "Address & Contacts", - "oldfieldtype": "Column Break", - "options": "icon-map-marker" - }, - { - "doctype": "DocField", - "fieldname": "address_html", - "fieldtype": "HTML", - "label": "Address HTML", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "contact_html", - "fieldtype": "HTML", - "label": "Contact HTML", - "read_only": 1 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "communication_history", - "fieldtype": "Section Break", - "label": "Communication History", - "options": "icon-comments", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "communication_html", - "fieldtype": "HTML", - "label": "Communication HTML", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text" - }, - { - "description": "Enter the company name under which Account Head will be created for this Supplier", - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "default_currency", - "fieldtype": "Link", - "label": "Default Currency", - "no_copy": 1, - "options": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "default_price_list", - "fieldtype": "Link", - "label": "Price List", - "options": "Price List" - }, - { - "doctype": "DocField", - "fieldname": "default_taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "options": "Purchase Taxes and Charges Master" - }, - { - "doctype": "DocField", - "fieldname": "credit_days", - "fieldtype": "Int", - "label": "Credit Days" - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "website", - "fieldtype": "Data", - "label": "Website", - "oldfieldname": "website", - "oldfieldtype": "Data" - }, - { - "description": "Statutory info and other general information about your Supplier", - "doctype": "DocField", - "fieldname": "supplier_details", - "fieldtype": "Text", - "label": "Supplier Details", - "oldfieldname": "supplier_details", - "oldfieldtype": "Code" - }, - { - "doctype": "DocField", - "fieldname": "communications", - "fieldtype": "Table", - "hidden": 1, - "label": "Communications", - "options": "Communication", - "print_hide": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase Manager", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Purchase Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier/test_records.json b/erpnext/buying/doctype/supplier/test_records.json new file mode 100644 index 00000000000..a1d1054ff2c --- /dev/null +++ b/erpnext/buying/doctype/supplier/test_records.json @@ -0,0 +1,8 @@ +[ + { + "company": "_Test Company", + "doctype": "Supplier", + "supplier_name": "_Test Supplier", + "supplier_type": "_Test Supplier Type" + } +] \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier/test_supplier.py b/erpnext/buying/doctype/supplier/test_supplier.py index d5bd4cb24b5..1f7c3e0b813 100644 --- a/erpnext/buying/doctype/supplier/test_supplier.py +++ b/erpnext/buying/doctype/supplier/test_supplier.py @@ -1,11 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Supplier", - "supplier_name": "_Test Supplier", - "supplier_type": "_Test Supplier Type", - "company": "_Test Company" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Supplier') \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json new file mode 100644 index 00000000000..ba098c03d51 --- /dev/null +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json @@ -0,0 +1,644 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-05-21 16:16:45.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "fieldname": "supplier_section", + "fieldtype": "Section Break", + "label": "Supplier", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "SQTN", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "description": "Supplier (vendor) name as entered in supplier master", + "fieldname": "supplier", + "fieldtype": "Link", + "in_filter": 1, + "label": "Supplier", + "oldfieldname": "supplier", + "oldfieldtype": "Link", + "options": "Supplier", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "supplier_name", + "fieldtype": "Data", + "hidden": 0, + "in_list_view": 1, + "label": "Name", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_mobile", + "fieldtype": "Text", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_email", + "fieldtype": "Text", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "transaction_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Quotation Date", + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "hidden": 1, + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0 + }, + { + "description": "Select the relevant company name if you have multiple companies", + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "no_copy": 0, + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "currency_price_list", + "fieldtype": "Section Break", + "label": "Currency and Price List", + "options": "icon-tag", + "permlevel": 0 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "no_copy": 0, + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "description": "Rate at which supplier's currency is converted to company's base currency", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "hidden": 0, + "label": "Exchange Rate", + "no_copy": 1, + "oldfieldname": "conversion_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "fieldname": "cb_price_list", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "buying_price_list", + "fieldtype": "Link", + "label": "Price List", + "options": "Price List", + "permlevel": 0, + "print_hide": 1 + }, + { + "depends_on": "buying_price_list", + "fieldname": "price_list_currency", + "fieldtype": "Link", + "label": "Price List Currency", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "depends_on": "buying_price_list", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "label": "Price List Exchange Rate", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "items", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "quotation_items", + "fieldtype": "Table", + "label": "Quotation Items", + "no_copy": 0, + "oldfieldname": "po_details", + "oldfieldtype": "Table", + "options": "Supplier Quotation Item", + "permlevel": 0 + }, + { + "fieldname": "section_break_22", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "net_total_import", + "fieldtype": "Currency", + "label": "Net Total", + "no_copy": 0, + "oldfieldname": "net_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "column_break_24", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total (Company Currency)", + "no_copy": 1, + "oldfieldname": "net_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "taxes", + "fieldtype": "Section Break", + "label": "Taxes and Charges", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0 + }, + { + "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.", + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "no_copy": 1, + "oldfieldname": "purchase_other_charges", + "oldfieldtype": "Link", + "options": "Purchase Taxes and Charges Master", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "other_charges", + "fieldtype": "Table", + "label": "Purchase Taxes and Charges", + "no_copy": 0, + "oldfieldname": "purchase_tax_details", + "oldfieldtype": "Table", + "options": "Purchase Taxes and Charges", + "permlevel": 0 + }, + { + "fieldname": "other_charges_calculation", + "fieldtype": "HTML", + "label": "Taxes and Charges Calculation", + "no_copy": 1, + "oldfieldtype": "HTML", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "Totals", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0 + }, + { + "fieldname": "other_charges_added_import", + "fieldtype": "Currency", + "label": "Taxes and Charges Added", + "no_copy": 0, + "oldfieldname": "other_charges_added_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "other_charges_deducted_import", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted", + "no_copy": 0, + "oldfieldname": "other_charges_deducted_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "grand_total_import", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Grand Total", + "no_copy": 0, + "oldfieldname": "grand_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "in_words_import", + "fieldtype": "Data", + "label": "In Words", + "oldfieldname": "in_words_import", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "column_break4", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 0 + }, + { + "fieldname": "other_charges_added", + "fieldtype": "Currency", + "label": "Taxes and Charges Added (Company Currency)", + "no_copy": 0, + "oldfieldname": "other_charges_added", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "other_charges_deducted", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted (Company Currency)", + "no_copy": 0, + "oldfieldname": "other_charges_deducted", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "total_tax", + "fieldtype": "Currency", + "label": "Total Tax (Company Currency)", + "no_copy": 1, + "oldfieldname": "total_tax", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "no_copy": 1, + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total (Company Currency)", + "oldfieldname": "rounded_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "In Words will be visible once you save the Purchase Order.", + "fieldname": "in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "oldfieldtype": "Section Break", + "options": "icon-legal", + "permlevel": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Select", + "label": "Letter Head", + "oldfieldname": "letter_head", + "oldfieldtype": "Select", + "options": "link:Letter Head", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "get_terms", + "fieldtype": "Button", + "label": "Get Terms and Conditions", + "oldfieldtype": "Button", + "permlevel": 0 + }, + { + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Terms and Conditions", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", + "permlevel": 0 + }, + { + "depends_on": "supplier", + "fieldname": "contact_section", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0 + }, + { + "fieldname": "supplier_address", + "fieldtype": "Link", + "in_filter": 1, + "label": "Supplier Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "contact_person", + "fieldtype": "Link", + "in_filter": 1, + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0 + }, + { + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nDraft\nSubmitted\nStopped\nCancelled", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1, + "search_index": 1 + }, + { + "default": "No", + "fieldname": "is_subcontracted", + "fieldtype": "Select", + "label": "Is Subcontracted", + "options": "\nYes\nNo", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "column_break_57", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "no_copy": 0, + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + } + ], + "icon": "icon-shopping-cart", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-29 15:25:52.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Supplier Quotation", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Manufacturing Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Supplier", + "submit": 0, + "write": 0 + } + ], + "read_only_onload": 1, + "search_fields": "status, transaction_date, supplier,grand_total" +} \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index f6a3ffc516e..fa484887661 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -3,22 +3,20 @@ from __future__ import unicode_literals import frappe -from frappe.model.code import get_obj from erpnext.controllers.buying_controller import BuyingController -class DocType(BuyingController): - def __init__(self, doc, doclist=None): - self.doc, self.doclist = doc, doclist or [] - self.tname, self.fname = "Supplier Quotation Item", "quotation_items" +class SupplierQuotation(BuyingController): + tname = "Supplier Quotation Item" + fname = "quotation_items" def validate(self): - super(DocType, self).validate() + super(SupplierQuotation, self).validate() - if not self.doc.status: - self.doc.status = "Draft" + if not self.status: + self.status = "Draft" from erpnext.utilities import validate_status - validate_status(self.doc.status, ["Draft", "Submitted", "Stopped", + validate_status(self.status, ["Draft", "Submitted", "Stopped", "Cancelled"]) self.validate_common() @@ -26,16 +24,16 @@ class DocType(BuyingController): self.validate_uom_is_integer("uom", "qty") def on_submit(self): - frappe.db.set(self.doc, "status", "Submitted") + frappe.db.set(self, "status", "Submitted") def on_cancel(self): - frappe.db.set(self.doc, "status", "Cancelled") + frappe.db.set(self, "status", "Cancelled") def on_trash(self): pass def validate_with_previous_doc(self): - super(DocType, self).validate_with_previous_doc(self.tname, { + super(SupplierQuotation, self).validate_with_previous_doc(self.tname, { "Material Request": { "ref_dn_field": "prevdoc_docname", "compare_fields": [["company", "="]], @@ -49,22 +47,22 @@ class DocType(BuyingController): def validate_common(self): - pc = get_obj('Purchase Common') + pc = frappe.get_doc('Purchase Common') pc.validate_for_items(self) @frappe.whitelist() -def make_purchase_order(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist +def make_purchase_order(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc def set_missing_values(source, target): - bean = frappe.bean(target) - bean.run_method("set_missing_values") - bean.run_method("get_schedule_dates") + doc = frappe.get_doc(target) + doc.run_method("set_missing_values") + doc.run_method("get_schedule_dates") def update_item(obj, target, source_parent): target.conversion_factor = 1 - doclist = get_mapped_doclist("Supplier Quotation", source_name, { + doclist = get_mapped_doc("Supplier Quotation", source_name, { "Supplier Quotation": { "doctype": "Purchase Order", "validation": { @@ -88,6 +86,6 @@ def make_purchase_order(source_name, target_doclist=None): "doctype": "Purchase Taxes and Charges", "add_if_empty": True }, - }, target_doclist, set_missing_values) + }, target_doc, set_missing_values) - return [d.fields for d in doclist] \ No newline at end of file + return doclist \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.txt b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.txt deleted file mode 100644 index 0a4a3ec6632..00000000000 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.txt +++ /dev/null @@ -1,647 +0,0 @@ -[ - { - "creation": "2013-05-21 16:16:45", - "docstatus": 0, - "modified": "2014-01-29 15:25:52", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-shopping-cart", - "is_submittable": 1, - "module": "Buying", - "name": "__common__", - "read_only_onload": 1, - "search_fields": "status, transaction_date, supplier,grand_total" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Supplier Quotation", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Supplier Quotation", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Supplier Quotation" - }, - { - "doctype": "DocField", - "fieldname": "supplier_section", - "fieldtype": "Section Break", - "label": "Supplier", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "SQTN", - "print_hide": 1, - "reqd": 1 - }, - { - "description": "Supplier (vendor) name as entered in supplier master", - "doctype": "DocField", - "fieldname": "supplier", - "fieldtype": "Link", - "in_filter": 1, - "label": "Supplier", - "oldfieldname": "supplier", - "oldfieldtype": "Link", - "options": "Supplier", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "supplier_name", - "fieldtype": "Data", - "hidden": 0, - "in_list_view": 1, - "label": "Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Text", - "hidden": 1, - "label": "Mobile No", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Text", - "hidden": 1, - "label": "Contact Email", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 0, - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "transaction_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Quotation Date", - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "hidden": 1, - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "report_hide": 0 - }, - { - "description": "Select the relevant company name if you have multiple companies", - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "no_copy": 0, - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "currency_price_list", - "fieldtype": "Section Break", - "label": "Currency and Price List", - "options": "icon-tag" - }, - { - "doctype": "DocField", - "fieldname": "currency", - "fieldtype": "Link", - "label": "Currency", - "no_copy": 0, - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "print_hide": 1, - "reqd": 1 - }, - { - "description": "Rate at which supplier's currency is converted to company's base currency", - "doctype": "DocField", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "hidden": 0, - "label": "Exchange Rate", - "no_copy": 1, - "oldfieldname": "conversion_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb_price_list", - "fieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "buying_price_list", - "fieldtype": "Link", - "label": "Price List", - "options": "Price List", - "print_hide": 1 - }, - { - "depends_on": "buying_price_list", - "doctype": "DocField", - "fieldname": "price_list_currency", - "fieldtype": "Link", - "label": "Price List Currency", - "options": "Currency", - "print_hide": 1, - "read_only": 1 - }, - { - "depends_on": "buying_price_list", - "doctype": "DocField", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "label": "Price List Exchange Rate", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "items", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "quotation_items", - "fieldtype": "Table", - "label": "Quotation Items", - "no_copy": 0, - "oldfieldname": "po_details", - "oldfieldtype": "Table", - "options": "Supplier Quotation Item" - }, - { - "doctype": "DocField", - "fieldname": "section_break_22", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total_import", - "fieldtype": "Currency", - "label": "Net Total", - "no_copy": 0, - "oldfieldname": "net_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_24", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total (Company Currency)", - "no_copy": 1, - "oldfieldname": "net_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "taxes", - "fieldtype": "Section Break", - "label": "Taxes and Charges", - "oldfieldtype": "Section Break", - "options": "icon-money" - }, - { - "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.", - "doctype": "DocField", - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "no_copy": 1, - "oldfieldname": "purchase_other_charges", - "oldfieldtype": "Link", - "options": "Purchase Taxes and Charges Master", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "other_charges", - "fieldtype": "Table", - "label": "Purchase Taxes and Charges", - "no_copy": 0, - "oldfieldname": "purchase_tax_details", - "oldfieldtype": "Table", - "options": "Purchase Taxes and Charges" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_calculation", - "fieldtype": "HTML", - "label": "Taxes and Charges Calculation", - "no_copy": 1, - "oldfieldtype": "HTML", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "Totals", - "oldfieldtype": "Section Break", - "options": "icon-money" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_added_import", - "fieldtype": "Currency", - "label": "Taxes and Charges Added", - "no_copy": 0, - "oldfieldname": "other_charges_added_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "read_only": 1, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_deducted_import", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted", - "no_copy": 0, - "oldfieldname": "other_charges_deducted_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "read_only": 1, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "grand_total_import", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Grand Total", - "no_copy": 0, - "oldfieldname": "grand_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "in_words_import", - "fieldtype": "Data", - "label": "In Words", - "oldfieldname": "in_words_import", - "oldfieldtype": "Data", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_added", - "fieldtype": "Currency", - "label": "Taxes and Charges Added (Company Currency)", - "no_copy": 0, - "oldfieldname": "other_charges_added", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_deducted", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted (Company Currency)", - "no_copy": 0, - "oldfieldname": "other_charges_deducted", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_tax", - "fieldtype": "Currency", - "label": "Total Tax (Company Currency)", - "no_copy": 1, - "oldfieldname": "total_tax", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "no_copy": 1, - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total (Company Currency)", - "oldfieldname": "rounded_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "description": "In Words will be visible once you save the Purchase Order.", - "doctype": "DocField", - "fieldname": "in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "oldfieldtype": "Section Break", - "options": "icon-legal" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Select", - "label": "Letter Head", - "oldfieldname": "letter_head", - "oldfieldtype": "Select", - "options": "link:Letter Head", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "get_terms", - "fieldtype": "Button", - "label": "Get Terms and Conditions", - "oldfieldtype": "Button" - }, - { - "doctype": "DocField", - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Terms and Conditions", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor" - }, - { - "depends_on": "supplier", - "doctype": "DocField", - "fieldname": "contact_section", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn" - }, - { - "doctype": "DocField", - "fieldname": "supplier_address", - "fieldtype": "Link", - "in_filter": 1, - "label": "Supplier Address", - "options": "Address", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "in_filter": 1, - "label": "Contact Person", - "options": "Contact", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text" - }, - { - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nDraft\nSubmitted\nStopped\nCancelled", - "print_hide": 1, - "read_only": 1, - "reqd": 1, - "search_index": 1 - }, - { - "default": "No", - "doctype": "DocField", - "fieldname": "is_subcontracted", - "fieldtype": "Select", - "label": "Is Subcontracted", - "options": "\nYes\nNo", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_57", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "no_copy": 0, - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "print_hide": 1, - "report_hide": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Manufacturing Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Purchase Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 0, - "create": 1, - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase User", - "submit": 0, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Material User", - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Supplier", - "submit": 0, - "write": 0 - } -] \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation/test_records.json b/erpnext/buying/doctype/supplier_quotation/test_records.json new file mode 100644 index 00000000000..90807d4674a --- /dev/null +++ b/erpnext/buying/doctype/supplier_quotation/test_records.json @@ -0,0 +1,32 @@ +[ + { + "buying_price_list": "_Test Price List", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "doctype": "Supplier Quotation", + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 5000.0, + "grand_total_import": 5000.0, + "is_subcontracted": "No", + "naming_series": "_T-Supplier Quotation-", + "net_total": 5000.0, + "quotation_items": [ + { + "base_amount": 5000.0, + "description": "_Test FG Item", + "doctype": "Supplier Quotation Item", + "item_code": "_Test FG Item", + "item_name": "_Test FG Item", + "parentfield": "quotation_items", + "qty": 10.0, + "rate": 500.0, + "uom": "_Test UOM", + "warehouse": "_Test Warehouse - _TC" + } + ], + "supplier": "_Test Supplier", + "supplier_name": "_Test Supplier", + "transaction_date": "2013-02-12" + } +] \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py index a5374fbe553..3f22fd50a48 100644 --- a/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/test_supplier_quotation.py @@ -11,55 +11,24 @@ class TestPurchaseOrder(unittest.TestCase): def test_make_purchase_order(self): from erpnext.buying.doctype.supplier_quotation.supplier_quotation import make_purchase_order - sq = frappe.bean(copy=test_records[0]).insert() + sq = frappe.copy_doc(test_records[0]).insert() - self.assertRaises(frappe.ValidationError, make_purchase_order, - sq.doc.name) + self.assertRaises(frappe.ValidationError, make_purchase_order, + sq.name) - sq = frappe.bean("Supplier Quotation", sq.doc.name) + sq = frappe.get_doc("Supplier Quotation", sq.name) sq.submit() - po = make_purchase_order(sq.doc.name) - - self.assertEquals(po[0]["doctype"], "Purchase Order") - self.assertEquals(len(po), len(sq.doclist)) - - po[0]["naming_series"] = "_T-Purchase Order-" + po = make_purchase_order(sq.name) - for doc in po: + self.assertEquals(po.doctype, "Purchase Order") + self.assertEquals(len(po.get("po_details")), len(sq.get("quotation_items"))) + + po.naming_series = "_T-Purchase Order-" + + for doc in po.get("po_details"): if doc.get("item_code"): - doc["schedule_date"] = "2013-04-12" + doc.set("schedule_date", "2013-04-12") - frappe.bean(po).insert() - -test_records = [ - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "doctype": "Supplier Quotation", - "fiscal_year": "_Test Fiscal Year 2013", - "transaction_date": "2013-02-12", - "is_subcontracted": "No", - "supplier": "_Test Supplier", - "supplier_name": "_Test Supplier", - "net_total": 5000.0, - "grand_total": 5000.0, - "grand_total_import": 5000.0, - "naming_series": "_T-Supplier Quotation-", - "buying_price_list": "_Test Price List" - }, - { - "description": "_Test FG Item", - "doctype": "Supplier Quotation Item", - "item_code": "_Test FG Item", - "item_name": "_Test FG Item", - "parentfield": "quotation_items", - "qty": 10.0, - "rate": 500.0, - "base_amount": 5000.0, - "warehouse": "_Test Warehouse - _TC", - "uom": "_Test UOM", - } - ], -] \ No newline at end of file + po.insert() + +test_records = frappe.get_test_records('Supplier Quotation') diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json new file mode 100644 index 00000000000..11cb9d9627e --- /dev/null +++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json @@ -0,0 +1,362 @@ +{ + "autoname": "SQI-.#####", + "creation": "2013-05-22 12:43:10.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "description": "If Supplier Part Number exists for given Item, it gets stored here", + "fieldname": "supplier_part_no", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Supplier Part Number", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "hidden": 0, + "in_filter": 1, + "in_list_view": 0, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 0, + "reqd": 1, + "width": "300px" + }, + { + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Quantity and Rate", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Quantity", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "60px", + "read_only": 0, + "reqd": 1, + "width": "60px" + }, + { + "fieldname": "price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "discount_percentage", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Discount %", + "permlevel": 0, + "print_hide": 0, + "read_only": 0 + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "oldfieldname": "uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "base_price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "sec_break1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "rate", + "fieldtype": "Currency", + "hidden": 0, + "in_list_view": 1, + "label": "Rate ", + "oldfieldname": "import_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 0 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "import_amount", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "base_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Rate (Company Currency)", + "oldfieldname": "purchase_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "base_amount", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Amount (Company Currency)", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "pricing_rule_for_price", + "fieldtype": "Link", + "label": "Pricing Rule For Price", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "pricing_rule_for_discount", + "fieldtype": "Link", + "label": "Pricing Rule For Discount", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "warehouse_and_reference", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Warehouse and Reference", + "permlevel": 0 + }, + { + "fieldname": "warehouse", + "fieldtype": "Link", + "hidden": 0, + "in_list_view": 0, + "label": "Warehouse", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "project_name", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 0, + "label": "Project Name", + "options": "Project", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0 + }, + { + "fieldname": "prevdoc_doctype", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Prevdoc DocType", + "no_copy": 1, + "oldfieldname": "prevdoc_doctype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "prevdoc_docname", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "in_list_view": 0, + "label": "Material Request No", + "no_copy": 1, + "oldfieldname": "prevdoc_docname", + "oldfieldtype": "Link", + "options": "Material Request", + "permlevel": 0, + "print_hide": 1, + "print_width": "120px", + "read_only": 1, + "search_index": 1, + "width": "120px" + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "prevdoc_detail_docname", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "Material Request Detail No", + "no_copy": 1, + "oldfieldname": "prevdoc_detail_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "brand", + "fieldtype": "Link", + "hidden": 0, + "in_list_view": 0, + "label": "Brand", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "in_list_view": 0, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 0 + }, + { + "description": "Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges", + "fieldname": "item_tax_rate", + "fieldtype": "Small Text", + "hidden": 1, + "in_list_view": 0, + "label": "Item Tax Rate", + "oldfieldname": "item_tax_rate", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "hidden": 0, + "in_list_view": 0, + "label": "Page Break", + "no_copy": 1, + "oldfieldname": "page_break", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-28 11:25:38.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Supplier Quotation Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py index 26c87f1c04a..16e6e126eb2 100644 --- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py +++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SupplierQuotationItem(Document): + pass \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt deleted file mode 100644 index 18b9216daf5..00000000000 --- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt +++ /dev/null @@ -1,375 +0,0 @@ -[ - { - "creation": "2013-05-22 12:43:10", - "docstatus": 0, - "modified": "2014-02-28 11:25:38", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "SQI-.#####", - "doctype": "DocType", - "istable": 1, - "module": "Buying", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Supplier Quotation Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Supplier Quotation Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "print_hide": 0, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "description": "If Supplier Part Number exists for given Item, it gets stored here", - "doctype": "DocField", - "fieldname": "supplier_part_no", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Supplier Part Number", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "hidden": 0, - "in_filter": 1, - "in_list_view": 0, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "print_width": "300px", - "read_only": 0, - "reqd": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Quantity and Rate" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Quantity", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "print_width": "60px", - "read_only": 0, - "reqd": 1, - "width": "60px" - }, - { - "doctype": "DocField", - "fieldname": "price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate", - "options": "currency", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "discount_percentage", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Discount %", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "oldfieldname": "uom", - "oldfieldtype": "Link", - "options": "UOM", - "print_hide": 0, - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "base_price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate (Company Currency)", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "sec_break1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Currency", - "hidden": 0, - "in_list_view": 1, - "label": "Rate ", - "oldfieldname": "import_rate", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "import_amount", - "oldfieldtype": "Currency", - "options": "currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "base_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Rate (Company Currency)", - "oldfieldname": "purchase_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "base_amount", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Amount (Company Currency)", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_price", - "fieldtype": "Link", - "label": "Pricing Rule For Price", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_discount", - "fieldtype": "Link", - "label": "Pricing Rule For Discount", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "warehouse_and_reference", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Warehouse and Reference" - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "hidden": 0, - "in_list_view": 0, - "label": "Warehouse", - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "project_name", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 0, - "label": "Project Name", - "options": "Project", - "print_hide": 1, - "read_only": 0, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_doctype", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Prevdoc DocType", - "no_copy": 1, - "oldfieldname": "prevdoc_doctype", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_docname", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "in_list_view": 0, - "label": "Material Request No", - "no_copy": 1, - "oldfieldname": "prevdoc_docname", - "oldfieldtype": "Link", - "options": "Material Request", - "print_hide": 1, - "print_width": "120px", - "read_only": 1, - "search_index": 1, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "col_break4", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_detail_docname", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "Material Request Detail No", - "no_copy": 1, - "oldfieldname": "prevdoc_detail_docname", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Link", - "hidden": 0, - "in_list_view": 0, - "label": "Brand", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "print_hide": 1, - "read_only": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "in_list_view": 0, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "print_hide": 1, - "read_only": 1, - "search_index": 0 - }, - { - "description": "Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges", - "doctype": "DocField", - "fieldname": "item_tax_rate", - "fieldtype": "Small Text", - "hidden": 1, - "in_list_view": 0, - "label": "Item Tax Rate", - "oldfieldname": "item_tax_rate", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 1, - "report_hide": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "page_break", - "fieldtype": "Check", - "hidden": 0, - "in_list_view": 0, - "label": "Page Break", - "no_copy": 1, - "oldfieldname": "page_break", - "oldfieldtype": "Check", - "print_hide": 1, - "read_only": 0 - } -] \ No newline at end of file diff --git a/erpnext/buying/page/purchase_analytics/purchase_analytics.json b/erpnext/buying/page/purchase_analytics/purchase_analytics.json new file mode 100644 index 00000000000..407d888c280 --- /dev/null +++ b/erpnext/buying/page/purchase_analytics/purchase_analytics.json @@ -0,0 +1,23 @@ +{ + "creation": "2012-09-21 20:15:16.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-bar-chart", + "idx": 1, + "modified": "2013-07-11 14:43:52.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "purchase-analytics", + "owner": "Administrator", + "page_name": "purchase-analytics", + "roles": [ + { + "role": "Analytics" + }, + { + "role": "Purchase Manager" + } + ], + "standard": "Yes", + "title": "Purchase Analytics" +} \ No newline at end of file diff --git a/erpnext/buying/page/purchase_analytics/purchase_analytics.txt b/erpnext/buying/page/purchase_analytics/purchase_analytics.txt deleted file mode 100644 index 34ba8e1a8be..00000000000 --- a/erpnext/buying/page/purchase_analytics/purchase_analytics.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2012-09-21 20:15:16", - "docstatus": 0, - "modified": "2013-07-11 14:43:52", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-bar-chart", - "module": "Buying", - "name": "__common__", - "page_name": "purchase-analytics", - "standard": "Yes", - "title": "Purchase Analytics" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "purchase-analytics", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "purchase-analytics" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Purchase Manager" - } -] \ No newline at end of file diff --git a/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.json b/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.json new file mode 100644 index 00000000000..b15a5714604 --- /dev/null +++ b/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.json @@ -0,0 +1,17 @@ +{ + "add_total_row": 1, + "creation": "2013-05-03 14:55:53.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Item-wise Purchase History", + "owner": "Administrator", + "query": "select\n po_item.item_code as \"Item Code:Link/Item:120\",\n\tpo_item.item_name as \"Item Name::120\",\n\tpo_item.description as \"Description::150\",\n\tpo_item.qty as \"Qty:Float:100\",\n\tpo_item.stock_uom as \"UOM:Link/UOM:80\",\n\tpo_item.base_rate as \"Rate:Currency:120\",\n\tpo_item.base_amount as \"Amount:Currency:120\",\n\tpo.name as \"Purchase Order:Link/Purchase Order:120\",\n\tpo.transaction_date as \"Transaction Date:Date:140\",\n\tpo.supplier as \"Supplier:Link/Supplier:130\",\n\tpo_item.project_name as \"Project:Link/Project:130\",\n\tifnull(po_item.received_qty, 0) as \"Received Qty:Float:120\"\nfrom\n\t`tabPurchase Order` po, `tabPurchase Order Item` po_item\nwhere\n\tpo.name = po_item.parent and po.docstatus = 1\norder by po.name desc", + "ref_doctype": "Purchase Order", + "report_name": "Item-wise Purchase History", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt b/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt deleted file mode 100644 index 199599005d1..00000000000 --- a/erpnext/buying/report/item_wise_purchase_history/item_wise_purchase_history.txt +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "creation": "2013-05-03 14:55:53", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Buying", - "name": "__common__", - "query": "select\n po_item.item_code as \"Item Code:Link/Item:120\",\n\tpo_item.item_name as \"Item Name::120\",\n\tpo_item.description as \"Description::150\",\n\tpo_item.qty as \"Qty:Float:100\",\n\tpo_item.stock_uom as \"UOM:Link/UOM:80\",\n\tpo_item.base_rate as \"Rate:Currency:120\",\n\tpo_item.base_amount as \"Amount:Currency:120\",\n\tpo.name as \"Purchase Order:Link/Purchase Order:120\",\n\tpo.transaction_date as \"Transaction Date:Date:140\",\n\tpo.supplier as \"Supplier:Link/Supplier:130\",\n\tpo_item.project_name as \"Project:Link/Project:130\",\n\tifnull(po_item.received_qty, 0) as \"Received Qty:Float:120\"\nfrom\n\t`tabPurchase Order` po, `tabPurchase Order Item` po_item\nwhere\n\tpo.name = po_item.parent and po.docstatus = 1\norder by po.name desc", - "ref_doctype": "Purchase Order", - "report_name": "Item-wise Purchase History", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Item-wise Purchase History" - } -] \ No newline at end of file diff --git a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.json b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.json new file mode 100644 index 00000000000..e33c657e336 --- /dev/null +++ b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-13 18:45:01.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Purchase Order Trends", + "owner": "Administrator", + "ref_doctype": "Purchase Order", + "report_name": "Purchase Order Trends", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.txt b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.txt deleted file mode 100644 index 683279fc209..00000000000 --- a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-13 18:45:01", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Buying", - "name": "__common__", - "ref_doctype": "Purchase Order", - "report_name": "Purchase Order Trends", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Purchase Order Trends" - } -] \ No newline at end of file diff --git a/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.json b/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.json new file mode 100644 index 00000000000..76dec76efd7 --- /dev/null +++ b/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.json @@ -0,0 +1,17 @@ +{ + "add_total_row": 1, + "creation": "2013-05-13 16:10:02.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Requested Items To Be Ordered", + "owner": "Administrator", + "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tsum(ifnull(mr_item.qty, 0)) as \"Qty:Float:100\",\n\tsum(ifnull(mr_item.ordered_qty, 0)) as \"Ordered Qty:Float:100\", \n\t(sum(mr_item.qty) - sum(ifnull(mr_item.ordered_qty, 0))) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\ngroup by mr.name, mr_item.item_code\nhaving\n\tsum(ifnull(mr_item.ordered_qty, 0)) < sum(ifnull(mr_item.qty, 0))\norder by mr.transaction_date asc", + "ref_doctype": "Purchase Order", + "report_name": "Requested Items To Be Ordered", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt b/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt deleted file mode 100644 index c3e91ae29d3..00000000000 --- a/erpnext/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "creation": "2013-05-13 16:10:02", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Buying", - "name": "__common__", - "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tsum(ifnull(mr_item.qty, 0)) as \"Qty:Float:100\",\n\tsum(ifnull(mr_item.ordered_qty, 0)) as \"Ordered Qty:Float:100\", \n\t(sum(mr_item.qty) - sum(ifnull(mr_item.ordered_qty, 0))) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\ngroup by mr.name, mr_item.item_code\nhaving\n\tsum(ifnull(mr_item.ordered_qty, 0)) < sum(ifnull(mr_item.qty, 0))\norder by mr.transaction_date asc", - "ref_doctype": "Purchase Order", - "report_name": "Requested Items To Be Ordered", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Requested Items To Be Ordered" - } -] \ No newline at end of file diff --git a/erpnext/buying/report/supplier_addresses_and_contacts/supplier_addresses_and_contacts.json b/erpnext/buying/report/supplier_addresses_and_contacts/supplier_addresses_and_contacts.json new file mode 100644 index 00000000000..69c9d8fc528 --- /dev/null +++ b/erpnext/buying/report/supplier_addresses_and_contacts/supplier_addresses_and_contacts.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-10-09 10:38:40.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Buying", + "name": "Supplier Addresses and Contacts", + "owner": "Administrator", + "query": "SELECT\n `tabSupplier`.name as \"Supplier:Link/Supplier:120\",\n\t`tabSupplier`.supplier_name as \"Supplier Name::120\",\n\t`tabSupplier`.supplier_type as \"Supplier Type:Link/Supplier Type:120\",\n\tconcat_ws(', ', \n\t\ttrim(',' from `tabAddress`.address_line1), \n\t\ttrim(',' from tabAddress.address_line2), \n\t\ttabAddress.state, tabAddress.pincode, tabAddress.country\n\t) as 'Address::180',\n concat_ws(', ', `tabContact`.first_name, `tabContact`.last_name) as 'Contact Name::180',\n\t`tabContact`.phone as \"Phone\",\n\t`tabContact`.mobile_no as \"Mobile No\",\n\t`tabContact`.email_id as \"Email Id::120\",\n\t`tabContact`.is_primary_contact as \"Is Primary Contact::120\"\nFROM\n\t`tabSupplier`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.supplier=`tabSupplier`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.supplier=`tabSupplier`.name\n\t)\nWHERE\n\t`tabSupplier`.docstatus<2\nORDER BY\n\t`tabSupplier`.name asc", + "ref_doctype": "Supplier", + "report_name": "Supplier Addresses and Contacts", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/buying/report/supplier_addresses_and_contacts/supplier_addresses_and_contacts.txt b/erpnext/buying/report/supplier_addresses_and_contacts/supplier_addresses_and_contacts.txt deleted file mode 100644 index 25c11e73c38..00000000000 --- a/erpnext/buying/report/supplier_addresses_and_contacts/supplier_addresses_and_contacts.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-10-09 10:38:40", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Buying", - "name": "__common__", - "query": "SELECT\n `tabSupplier`.name as \"Supplier:Link/Supplier:120\",\n\t`tabSupplier`.supplier_name as \"Supplier Name::120\",\n\t`tabSupplier`.supplier_type as \"Supplier Type:Link/Supplier Type:120\",\n\tconcat_ws(', ', \n\t\ttrim(',' from `tabAddress`.address_line1), \n\t\ttrim(',' from tabAddress.address_line2), \n\t\ttabAddress.state, tabAddress.pincode, tabAddress.country\n\t) as 'Address::180',\n concat_ws(', ', `tabContact`.first_name, `tabContact`.last_name) as 'Contact Name::180',\n\t`tabContact`.phone as \"Phone\",\n\t`tabContact`.mobile_no as \"Mobile No\",\n\t`tabContact`.email_id as \"Email Id::120\",\n\t`tabContact`.is_primary_contact as \"Is Primary Contact::120\"\nFROM\n\t`tabSupplier`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.supplier=`tabSupplier`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.supplier=`tabSupplier`.name\n\t)\nWHERE\n\t`tabSupplier`.docstatus<2\nORDER BY\n\t`tabSupplier`.name asc", - "ref_doctype": "Supplier", - "report_name": "Supplier Addresses and Contacts", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Supplier Addresses and Contacts" - } -] \ No newline at end of file diff --git a/erpnext/config/setup.py b/erpnext/config/setup.py index e5393906cfb..5be7e8cdd7c 100644 --- a/erpnext/config/setup.py +++ b/erpnext/config/setup.py @@ -15,6 +15,27 @@ data = [ } ] }, + { + "label": _("Printing and Branding"), + "icon": "icon-print", + "items": [ + { + "type": "doctype", + "name": "Letter Head", + "description": _("Letter Heads for print templates.") + }, + { + "type": "doctype", + "name": "Print Heading", + "description": _("Titles for print templates e.g. Proforma Invoice.") + }, + { + "type": "doctype", + "name": "Terms and Conditions", + "description": _("Standard contract terms for Sales or Purchase.") + }, + ] + }, { "label": _("Customize"), "icon": "icon-glass", diff --git a/erpnext/contacts/__init__.py b/erpnext/contacts/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/contacts/doctype/__init__.py b/erpnext/contacts/doctype/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/contacts/doctype/party_type/__init__.py b/erpnext/contacts/doctype/party_type/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/contacts/doctype/party_type/party_type.json b/erpnext/contacts/doctype/party_type/party_type.json new file mode 100644 index 00000000000..b667b6e0537 --- /dev/null +++ b/erpnext/contacts/doctype/party_type/party_type.json @@ -0,0 +1,302 @@ +{ + "_last_update": null, + "_user_tags": null, + "allow_attach": null, + "allow_copy": null, + "allow_email": null, + "allow_import": null, + "allow_print": null, + "allow_rename": null, + "allow_trash": null, + "autoname": "field:party_type_name", + "change_log": null, + "client_script": null, + "client_script_core": null, + "client_string": null, + "colour": null, + "creation": "2014-04-07 12:32:18.010384", + "custom": null, + "default_print_format": null, + "description": null, + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "dt_template": null, + "fields": [ + { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, + "fieldname": "party_type_name", + "fieldtype": "Data", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": 1, + "label": "Party Type Name", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": null, + "permlevel": 0, + "print_hide": null, + "print_width": null, + "read_only": null, + "report_hide": null, + "reqd": 1, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null + }, + { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, + "fieldname": "parent_party_type", + "fieldtype": "Link", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, + "label": "Parent Party Type", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": "Party Type", + "permlevel": 0, + "print_hide": null, + "print_width": null, + "read_only": null, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null + }, + { + "allow_on_submit": null, + "default": "Yes", + "depends_on": null, + "description": null, + "fieldname": "allow_children", + "fieldtype": "Select", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, + "label": "Allow Children", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": "Yes\nNo", + "permlevel": 0, + "print_hide": null, + "print_width": null, + "read_only": null, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null + }, + { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, + "fieldname": "default_price_list", + "fieldtype": "Link", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, + "label": "Default Price List", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": "Price List", + "permlevel": 0, + "print_hide": null, + "print_width": null, + "read_only": null, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null + }, + { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, + "fieldname": "lft", + "fieldtype": "Int", + "hidden": 1, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, + "label": "LFT", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": null, + "permlevel": 0, + "print_hide": null, + "print_width": null, + "read_only": 1, + "report_hide": null, + "reqd": null, + "search_index": 1, + "set_only_once": null, + "trigger": null, + "width": null + }, + { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, + "fieldname": "rgt", + "fieldtype": "Int", + "hidden": 1, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, + "label": "RGT", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": null, + "permlevel": 0, + "print_hide": null, + "print_width": null, + "read_only": 1, + "report_hide": null, + "reqd": null, + "search_index": 1, + "set_only_once": null, + "trigger": null, + "width": null + }, + { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, + "fieldname": "old_parent", + "fieldtype": "Data", + "hidden": 1, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, + "label": "Old Parent", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": null, + "permlevel": 0, + "print_hide": null, + "print_width": null, + "read_only": 1, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null + } + ], + "hide_heading": null, + "hide_toolbar": null, + "icon": null, + "idx": null, + "in_create": null, + "in_dialog": null, + "is_submittable": null, + "is_transaction_doc": null, + "issingle": null, + "istable": null, + "max_attachments": null, + "menu_index": null, + "modified": "2014-04-07 12:54:46.254776", + "modified_by": "Administrator", + "module": "Contacts", + "name": "Party Type", + "name_case": null, + "owner": "Administrator", + "parent": null, + "parent_node": null, + "parentfield": null, + "parenttype": null, + "permissions": [ + { + "amend": null, + "cancel": null, + "create": 1, + "delete": null, + "email": null, + "export": null, + "import": null, + "match": null, + "permlevel": 0, + "print": null, + "read": 1, + "report": null, + "restrict": null, + "restricted": null, + "role": "Sales User", + "submit": null, + "write": 1 + }, + { + "amend": null, + "cancel": null, + "create": 1, + "delete": null, + "email": null, + "export": null, + "import": null, + "match": null, + "permlevel": 0, + "print": null, + "read": 1, + "report": null, + "restrict": null, + "restricted": null, + "role": "Purchase User", + "submit": null, + "write": 1 + } + ], + "plugin": null, + "print_outline": null, + "read_only": null, + "read_only_onload": null, + "search_fields": null, + "section_style": null, + "server_code": null, + "server_code_compiled": null, + "server_code_core": null, + "server_code_error": null, + "show_in_menu": null, + "smallicon": null, + "subject": null, + "tag_fields": null, + "title_field": null, + "use_template": null, + "version": null +} \ No newline at end of file diff --git a/erpnext/contacts/doctype/party_type/party_type.py b/erpnext/contacts/doctype/party_type/party_type.py new file mode 100644 index 00000000000..3f752edc5b1 --- /dev/null +++ b/erpnext/contacts/doctype/party_type/party_type.py @@ -0,0 +1,9 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.utils.nestedset import NestedSet + +class PartyType(NestedSet): + nsm_parent_field = 'parent_party_type'; diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 7ad5d86c62c..ec6fe1fa413 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe import _, throw from frappe.utils import flt, cint, today, cstr -from frappe.model.code import get_obj from erpnext.setup.utils import get_company_currency from erpnext.accounts.utils import get_fiscal_year, validate_fiscal_year from erpnext.utilities.transaction_base import TransactionBase @@ -19,16 +18,16 @@ class AccountsController(TransactionBase): self.calculate_taxes_and_totals() self.validate_value("grand_total", ">=", 0) self.set_total_in_words() - + self.validate_for_freezed_account() - + def set_missing_values(self, for_validate=False): for fieldname in ["posting_date", "transaction_date"]: - if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname): - self.doc.fields[fieldname] = today() - if not self.doc.fiscal_year: - self.doc.fiscal_year = get_fiscal_year(self.doc.fields[fieldname])[0] - + if not self.get(fieldname) and self.meta.get_field(fieldname): + self.set(fieldname, today()) + if not self.fiscal_year: + self.fiscal_year = get_fiscal_year(self.get(fieldname))[0] + def validate_date_with_fiscal_year(self): if self.meta.get_field("fiscal_year") : date_field = "" @@ -36,48 +35,48 @@ class AccountsController(TransactionBase): date_field = "posting_date" elif self.meta.get_field("transaction_date"): date_field = "transaction_date" - - if date_field and self.doc.fields[date_field]: - validate_fiscal_year(self.doc.fields[date_field], self.doc.fiscal_year, + + if date_field and self.get(date_field): + validate_fiscal_year(self.get(date_field), self.fiscal_year, label=self.meta.get_label(date_field)) - + def validate_for_freezed_account(self): for fieldname in ["customer", "supplier"]: - if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname): - accounts = frappe.db.get_values("Account", - {"master_type": fieldname.title(), "master_name": self.doc.fields[fieldname], - "company": self.doc.company}, "name") + if self.meta.get_field(fieldname) and self.get(fieldname): + accounts = frappe.db.get_values("Account", + {"master_type": fieldname.title(), "master_name": self.get(fieldname), + "company": self.company}, "name") if accounts: from erpnext.accounts.doctype.gl_entry.gl_entry import validate_frozen_account - for account in accounts: + for account in accounts: validate_frozen_account(account[0]) - + def set_price_list_currency(self, buying_or_selling): if self.meta.get_field("currency"): - company_currency = get_company_currency(self.doc.company) - + company_currency = get_company_currency(self.company) + # price list part fieldname = "selling_price_list" if buying_or_selling.lower() == "selling" \ else "buying_price_list" - if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname): - self.doc.price_list_currency = frappe.db.get_value("Price List", - self.doc.fields.get(fieldname), "currency") - - if self.doc.price_list_currency == company_currency: - self.doc.plc_conversion_rate = 1.0 + if self.meta.get_field(fieldname) and self.get(fieldname): + self.price_list_currency = frappe.db.get_value("Price List", + self.get(fieldname), "currency") + + if self.price_list_currency == company_currency: + self.plc_conversion_rate = 1.0 + + elif not self.plc_conversion_rate: + self.plc_conversion_rate = self.get_exchange_rate( + self.price_list_currency, company_currency) - elif not self.doc.plc_conversion_rate: - self.doc.plc_conversion_rate = self.get_exchange_rate( - self.doc.price_list_currency, company_currency) - # currency - if not self.doc.currency: - self.doc.currency = self.doc.price_list_currency - self.doc.conversion_rate = self.doc.plc_conversion_rate - elif self.doc.currency == company_currency: - self.doc.conversion_rate = 1.0 - elif not self.doc.conversion_rate: - self.doc.conversion_rate = self.get_exchange_rate(self.doc.currency, + if not self.currency: + self.currency = self.price_list_currency + self.conversion_rate = self.plc_conversion_rate + elif self.currency == company_currency: + self.conversion_rate = 1.0 + elif not self.conversion_rate: + self.conversion_rate = self.get_exchange_rate(self.currency, company_currency) def get_exchange_rate(self, from_currency, to_currency): @@ -87,106 +86,100 @@ class AccountsController(TransactionBase): def set_missing_item_details(self): """set missing item values""" from erpnext.stock.get_item_details import get_item_details - for item in self.doclist.get({"parentfield": self.fname}): - if item.fields.get("item_code"): - args = item.fields.copy() - args.update(self.doc.fields) - ret = get_item_details(args) - for fieldname, value in ret.items(): - if self.meta.get_field(fieldname, parentfield=self.fname) and \ - item.fields.get(fieldname) is None and value is not None: - item.fields[fieldname] = value - + if hasattr(self, "fname"): + for item in self.get(self.fname): + if item.get("item_code"): + args = item.as_dict() + args.update(self.as_dict()) + ret = get_item_details(args) + for fieldname, value in ret.items(): + if item.meta.get_field(fieldname) and \ + item.get(fieldname) is None and value is not None: + item.set(fieldname, value) + def set_taxes(self, tax_parentfield, tax_master_field): if not self.meta.get_field(tax_parentfield): return - + tax_master_doctype = self.meta.get_field(tax_master_field).options - - if not self.doclist.get({"parentfield": tax_parentfield}): - if not self.doc.fields.get(tax_master_field): + + if not self.get(tax_parentfield): + if not self.get(tax_master_field): # get the default tax master - self.doc.fields[tax_master_field] = \ - frappe.db.get_value(tax_master_doctype, {"is_default": 1}) - + self.set(tax_master_field, frappe.db.get_value(tax_master_doctype, {"is_default": 1})) + self.append_taxes_from_master(tax_parentfield, tax_master_field, tax_master_doctype) - + def append_taxes_from_master(self, tax_parentfield, tax_master_field, tax_master_doctype=None): - if self.doc.fields.get(tax_master_field): + if self.get(tax_master_field): if not tax_master_doctype: tax_master_doctype = self.meta.get_field(tax_master_field).options - + tax_doctype = self.meta.get_field(tax_parentfield).options - + from frappe.model import default_fields - tax_master = frappe.bean(tax_master_doctype, self.doc.fields.get(tax_master_field)) - - for i, tax in enumerate(tax_master.doclist.get({"parentfield": tax_parentfield})): + tax_master = frappe.get_doc(tax_master_doctype, self.get(tax_master_field)) + + for i, tax in enumerate(tax_master.get(tax_parentfield)): for fieldname in default_fields: - tax.fields[fieldname] = None - - tax.fields.update({ - "doctype": tax_doctype, - "parentfield": tax_parentfield, - "idx": i+1 - }) - - self.doclist.append(tax) + tax.set(fieldname, None) + + self.append(tax_parentfield, tax) def get_other_charges(self): - self.doclist = self.doc.clear_table(self.doclist, "other_charges") + self.set("other_charges", []) self.set_taxes("other_charges", "taxes_and_charges") - + def calculate_taxes_and_totals(self): self.discount_amount_applied = False self._calculate_taxes_and_totals() - + if self.meta.get_field("discount_amount"): self.apply_discount_amount() def _calculate_taxes_and_totals(self): # validate conversion rate - company_currency = get_company_currency(self.doc.company) - if not self.doc.currency or self.doc.currency == company_currency: - self.doc.currency = company_currency - self.doc.conversion_rate = 1.0 + company_currency = get_company_currency(self.company) + if not self.currency or self.currency == company_currency: + self.currency = company_currency + self.conversion_rate = 1.0 else: from erpnext.setup.doctype.currency.currency import validate_conversion_rate - validate_conversion_rate(self.doc.currency, self.doc.conversion_rate, - self.meta.get_label("conversion_rate"), self.doc.company) + validate_conversion_rate(self.currency, self.conversion_rate, + self.meta.get_label("conversion_rate"), self.company) + + self.conversion_rate = flt(self.conversion_rate) + self.item_doclist = self.get(self.fname) + self.tax_doclist = self.get(self.other_fname) - self.doc.conversion_rate = flt(self.doc.conversion_rate) - self.item_doclist = self.doclist.get({"parentfield": self.fname}) - self.tax_doclist = self.doclist.get({"parentfield": self.other_fname}) - self.calculate_item_values() self.initialize_taxes() - + if hasattr(self, "determine_exclusive_rate"): self.determine_exclusive_rate() - + self.calculate_net_total() self.calculate_taxes() self.calculate_totals() self._cleanup() - + def initialize_taxes(self): for tax in self.tax_doclist: tax.item_wise_tax_detail = {} - tax_fields = ["total", "tax_amount_after_discount_amount", - "tax_amount_for_current_item", "grand_total_for_current_item", + tax_fields = ["total", "tax_amount_after_discount_amount", + "tax_amount_for_current_item", "grand_total_for_current_item", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"] if not self.discount_amount_applied: tax_fields.append("tax_amount") for fieldname in tax_fields: - tax.fields[fieldname] = 0.0 + tax.set(fieldname, 0.0) self.validate_on_previous_row(tax) self.validate_inclusive_tax(tax) self.round_floats_in(tax) - + def validate_on_previous_row(self, tax): """ validate if a valid row id is mentioned in case of @@ -201,7 +194,7 @@ class AccountsController(TransactionBase): "row_id_label": self.meta.get_label("row_id", parentfield=self.other_fname) }) - + def validate_inclusive_tax(self, tax): def _on_previous_row_error(row_range): throw((_("Row") + " # %(idx)s [%(doctype)s]: " + @@ -209,24 +202,21 @@ class AccountsController(TransactionBase): " [" + _("Row") + " # %(row_range)s] " + _("also be included in Item's rate")) % { "idx": tax.idx, "doctype": tax.doctype, - "inclusive_label": self.meta.get_label("included_in_print_rate", - parentfield=self.other_fname), - "charge_type_label": self.meta.get_label("charge_type", - parentfield=self.other_fname), + "inclusive_label": frappe.get_meta(tax.doctype).get_label("included_in_print_rate"), + "charge_type_label": frappe.get_meta(tax.doctype).get_label("charge_type"), "charge_type": tax.charge_type, "row_range": row_range }) - - if cint(tax.included_in_print_rate): + + if cint(getattr(tax, "included_in_print_rate", None)): if tax.charge_type == "Actual": # inclusive tax cannot be of type Actual - throw((_("Row") - + " # %(idx)s [%(doctype)s]: %(charge_type_label)s = \"%(charge_type)s\" " + throw((_("Row") + + " # %(idx)s [%(doctype)s]: %(charge_type_label)s = \"%(charge_type)s\" " + "cannot be included in Item's rate") % { "idx": tax.idx, "doctype": tax.doctype, - "charge_type_label": self.meta.get_label("charge_type", - parentfield=self.other_fname), + "charge_type_label": frappe.get_meta(tax.doctype).get_label("charge_type"), "charge_type": tax.charge_type, }) elif tax.charge_type == "On Previous Row Amount" and \ @@ -237,10 +227,10 @@ class AccountsController(TransactionBase): not all([cint(t.included_in_print_rate) for t in self.tax_doclist[:cint(tax.row_id) - 1]]): # all rows about the reffered tax should be inclusive _on_previous_row_error("1 - %d" % (tax.row_id,)) - + def calculate_taxes(self): # maintain actual tax rate based on idx - actual_tax_dict = dict([[tax.idx, tax.rate] for tax in self.tax_doclist + actual_tax_dict = dict([[tax.idx, tax.rate] for tax in self.tax_doclist if tax.charge_type == "Actual"]) for n, item in enumerate(self.item_doclist): @@ -265,26 +255,26 @@ class AccountsController(TransactionBase): tax.tax_amount += current_tax_amount tax.tax_amount_after_discount_amount += current_tax_amount - - if tax.category: + + if getattr(tax, "category", None): # if just for valuation, do not add the tax amount in total # hence, setting it as 0 for further steps current_tax_amount = 0.0 if (tax.category == "Valuation") \ else current_tax_amount - + current_tax_amount *= -1.0 if (tax.add_deduct_tax == "Deduct") else 1.0 - + # Calculate tax.total viz. grand total till that step - # note: grand_total_for_current_item contains the contribution of + # note: grand_total_for_current_item contains the contribution of # item's amount, previously applied tax and the current tax on that item if i==0: tax.grand_total_for_current_item = flt(item.base_amount + current_tax_amount, self.precision("total", tax)) else: tax.grand_total_for_current_item = \ - flt(self.tax_doclist[i-1].grand_total_for_current_item + + flt(self.tax_doclist[i-1].grand_total_for_current_item + current_tax_amount, self.precision("total", tax)) - + # in tax.total, accumulate grand total of each item tax.total += tax.grand_total_for_current_item @@ -299,12 +289,12 @@ class AccountsController(TransactionBase): def round_off_totals(self, tax): tax.total = flt(tax.total, self.precision("total", tax)) tax.tax_amount = flt(tax.tax_amount, self.precision("tax_amount", tax)) - tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, + tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, self.precision("tax_amount", tax)) def adjust_discount_amount_loss(self, tax): - discount_amount_loss = self.doc.grand_total - flt(self.doc.discount_amount) - tax.total - tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount + + discount_amount_loss = self.grand_total - flt(self.discount_amount) - tax.total + tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount + discount_amount_loss, self.precision("tax_amount", tax)) tax.total = flt(tax.total + discount_amount_loss, self.precision("total", tax)) @@ -315,8 +305,8 @@ class AccountsController(TransactionBase): if tax.charge_type == "Actual": # distribute the tax amount proportionally to each item row actual = flt(tax.rate, self.precision("tax_amount", tax)) - current_tax_amount = (self.doc.net_total - and ((item.base_amount / self.doc.net_total) * actual) + current_tax_amount = (self.net_total + and ((item.base_amount / self.net_total) * actual) or 0) elif tax.charge_type == "On Net Total": current_tax_amount = (tax_rate / 100.0) * item.base_amount @@ -338,160 +328,153 @@ class AccountsController(TransactionBase): tax.item_wise_tax_detail[key] = [tax_rate, current_tax_amount] return current_tax_amount - + def _load_item_tax_rate(self, item_tax_rate): return json.loads(item_tax_rate) if item_tax_rate else {} - + def _get_tax_rate(self, tax, item_tax_map): if item_tax_map.has_key(tax.account_head): return flt(item_tax_map.get(tax.account_head), self.precision("rate", tax)) else: return tax.rate - + def _cleanup(self): for tax in self.tax_doclist: - for fieldname in ("grand_total_for_current_item", - "tax_amount_for_current_item", - "tax_fraction_for_current_item", - "grand_total_fraction_for_current_item"): - if fieldname in tax.fields: - del tax.fields[fieldname] - tax.item_wise_tax_detail = json.dumps(tax.item_wise_tax_detail) - + def _set_in_company_currency(self, item, print_field, base_field): """set values in base currency""" - item.fields[base_field] = flt((flt(item.fields[print_field], - self.precision(print_field, item)) * self.doc.conversion_rate), + value_in_company_currency = flt(self.conversion_rate * + flt(item.get(print_field), self.precision(print_field, item)), self.precision(base_field, item)) - - def calculate_total_advance(self, parenttype, advance_parentfield): - if self.doc.doctype == parenttype and self.doc.docstatus < 2: - sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv)) - for adv in self.doclist.get({"parentfield": advance_parentfield})]) + item.set(base_field, value_in_company_currency) + + def calculate_total_advance(self, parenttype, advance_parentfield): + if self.doctype == parenttype and self.docstatus < 2: + sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv)) + for adv in self.get(advance_parentfield)]) + + self.total_advance = flt(sum_of_allocated_amount, self.precision("total_advance")) - self.doc.total_advance = flt(sum_of_allocated_amount, self.precision("total_advance")) - self.calculate_outstanding_amount() def get_gl_dict(self, args): """this method populates the common properties of a gl entry record""" gl_dict = frappe._dict({ - 'company': self.doc.company, - 'posting_date': self.doc.posting_date, - 'voucher_type': self.doc.doctype, - 'voucher_no': self.doc.name, - 'aging_date': self.doc.fields.get("aging_date") or self.doc.posting_date, - 'remarks': self.doc.remarks, - 'fiscal_year': self.doc.fiscal_year, + 'company': self.company, + 'posting_date': self.posting_date, + 'voucher_type': self.doctype, + 'voucher_no': self.name, + 'aging_date': self.get("aging_date") or self.posting_date, + 'remarks': self.get("remarks"), + 'fiscal_year': self.fiscal_year, 'debit': 0, 'credit': 0, - 'is_opening': self.doc.fields.get("is_opening") or "No", + 'is_opening': self.get("is_opening") or "No", }) gl_dict.update(args) return gl_dict - + def clear_unallocated_advances(self, childtype, parentfield): - self.doclist.remove_items({"parentfield": parentfield, "allocated_amount": ["in", [0, None, ""]]}) - - frappe.db.sql("""delete from `tab%s` where parentfield=%s and parent = %s - and ifnull(allocated_amount, 0) = 0""" % (childtype, '%s', '%s'), (parentfield, self.doc.name)) - + self.set(parentfield, self.get(parentfield, {"allocated_amount": ["not in", [0, None, ""]]})) + + frappe.db.sql("""delete from `tab%s` where parentfield=%s and parent = %s + and ifnull(allocated_amount, 0) = 0""" % (childtype, '%s', '%s'), (parentfield, self.name)) + def get_advances(self, account_head, child_doctype, parentfield, dr_or_cr): - res = frappe.db.sql("""select t1.name as jv_no, t1.remark, + res = frappe.db.sql("""select t1.name as jv_no, t1.remark, t2.%s as amount, t2.name as jv_detail_no - from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 - where t1.name = t2.parent and t2.account = %s and t2.is_advance = 'Yes' + from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 + where t1.name = t2.parent and t2.account = %s and t2.is_advance = 'Yes' and (t2.against_voucher is null or t2.against_voucher = '') - and (t2.against_invoice is null or t2.against_invoice = '') - and (t2.against_jv is null or t2.against_jv = '') - and t1.docstatus = 1 order by t1.posting_date""" % + and (t2.against_invoice is null or t2.against_invoice = '') + and (t2.against_jv is null or t2.against_jv = '') + and t1.docstatus = 1 order by t1.posting_date""" % (dr_or_cr, '%s'), account_head, as_dict=1) - - self.doclist = self.doc.clear_table(self.doclist, parentfield) + + self.set(parentfield, []) for d in res: - self.doclist.append({ + self.append(parentfield, { "doctype": child_doctype, - "parentfield": parentfield, "journal_voucher": d.jv_no, "jv_detail_no": d.jv_detail_no, "remarks": d.remark, "advance_amount": flt(d.amount), "allocate_amount": 0 }) - + def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield): from erpnext.controllers.status_updater import get_tolerance_for item_tolerance = {} global_tolerance = None - - for item in self.doclist.get({"parentfield": "entries"}): - if item.fields.get(item_ref_dn): - ref_amt = flt(frappe.db.get_value(ref_dt + " Item", - item.fields[item_ref_dn], based_on), self.precision(based_on, item)) + + for item in self.get("entries"): + if item.get(item_ref_dn): + ref_amt = flt(frappe.db.get_value(ref_dt + " Item", + item.get(item_ref_dn), based_on), self.precision(based_on, item)) if not ref_amt: - frappe.msgprint(_("As amount for item") + ": " + item.item_code + _(" in ") + + frappe.msgprint(_("As amount for item") + ": " + item.item_code + _(" in ") + ref_dt + _(" is zero, system will not check for over-billed")) else: - already_billed = frappe.db.sql("""select sum(%s) from `tab%s` - where %s=%s and docstatus=1 and parent != %s""" % - (based_on, self.tname, item_ref_dn, '%s', '%s'), - (item.fields[item_ref_dn], self.doc.name))[0][0] - - total_billed_amt = flt(flt(already_billed) + flt(item.fields[based_on]), + already_billed = frappe.db.sql("""select sum(%s) from `tab%s` + where %s=%s and docstatus=1 and parent != %s""" % + (based_on, self.tname, item_ref_dn, '%s', '%s'), + (item.get(item_ref_dn), self.name))[0][0] + + total_billed_amt = flt(flt(already_billed) + flt(item.get(based_on)), self.precision(based_on, item)) - - tolerance, item_tolerance, global_tolerance = get_tolerance_for(item.item_code, + + tolerance, item_tolerance, global_tolerance = get_tolerance_for(item.item_code, item_tolerance, global_tolerance) - + max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100) - + if total_billed_amt - max_allowed_amt > 0.01: reduce_by = total_billed_amt - max_allowed_amt - - frappe.throw(_("Row #") + cstr(item.idx) + ": " + - _(" Max amount allowed for Item ") + cstr(item.item_code) + - _(" against ") + ref_dt + " " + - cstr(item.fields[ref_dt.lower().replace(" ", "_")]) + _(" is ") + - cstr(max_allowed_amt) + ". \n" + + + frappe.throw(_("Row #") + cstr(item.idx) + ": " + + _(" Max amount allowed for Item ") + cstr(item.item_code) + + _(" against ") + ref_dt + " " + + cstr(item.get(ref_dt.lower().replace(" ", "_"))) + _(" is ") + + cstr(max_allowed_amt) + ". \n" + _("""If you want to increase your overflow tolerance, please increase \ - tolerance % in Global Defaults or Item master. - Or, you must reduce the amount by """) + cstr(reduce_by) + "\n" + + tolerance % in Global Defaults or Item master. + Or, you must reduce the amount by """) + cstr(reduce_by) + "\n" + _("""Also, please check if the order item has already been billed \ in the Sales Order""")) - + def get_company_default(self, fieldname): from erpnext.accounts.utils import get_company_default - return get_company_default(self.doc.company, fieldname) - + return get_company_default(self.company, fieldname) + def get_stock_items(self): stock_items = [] - item_codes = list(set(item.item_code for item in - self.doclist.get({"parentfield": self.fname}))) + item_codes = list(set(item.item_code for item in + self.get(self.fname))) if item_codes: stock_items = [r[0] for r in frappe.db.sql("""select name from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \ (", ".join((["%s"]*len(item_codes))),), item_codes)] - + return stock_items - + @property def company_abbr(self): if not hasattr(self, "_abbr"): - self._abbr = frappe.db.get_value("Company", self.doc.company, "abbr") - + self._abbr = frappe.db.get_value("Company", self.company, "abbr") + return self._abbr def check_credit_limit(self, account): total_outstanding = frappe.db.sql(""" - select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) + select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabGL Entry` where account = %s""", account) - + total_outstanding = total_outstanding[0][0] if total_outstanding else 0 if total_outstanding: - get_obj('Account', account).check_credit_limit(total_outstanding) + frappe.get_doc('Account', account).check_credit_limit(total_outstanding) @frappe.whitelist() def get_tax_rate(account_head): - return frappe.db.get_value("Account", account_head, "tax_rate") \ No newline at end of file + return frappe.db.get_value("Account", account_head, "tax_rate") diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 4ca6c195b48..3bde28b3794 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -17,9 +17,9 @@ class BuyingController(StockController): def validate(self): super(BuyingController, self).validate() - if self.doc.supplier and not self.doc.supplier_name: - self.doc.supplier_name = frappe.db.get_value("Supplier", - self.doc.supplier, "supplier_name") + if getattr(self, "supplier", None) and not self.supplier_name: + self.supplier_name = frappe.db.get_value("Supplier", + self.supplier, "supplier_name") self.is_item_table_empty() self.validate_stock_or_nonstock_items() self.validate_warehouse() @@ -31,46 +31,46 @@ class BuyingController(StockController): self.set_price_list_currency("Buying") # set contact and address details for supplier, if they are not mentioned - if self.doc.supplier: - self.doc.update_if_missing(get_party_details(self.doc.supplier, party_type="Supplier")) + if getattr(self, "supplier", None): + self.update_if_missing(get_party_details(self.supplier, party_type="Supplier")) self.set_missing_item_details() - if self.doc.fields.get("__islocal"): + if self.get("__islocal"): self.set_taxes("other_charges", "taxes_and_charges") def set_supplier_from_item_default(self): - if self.meta.get_field("supplier") and not self.doc.supplier: - for d in self.doclist.get({"doctype": self.tname}): + if self.meta.get_field("supplier") and not self.supplier: + for d in self.get(self.fname): supplier = frappe.db.get_value("Item", d.item_code, "default_supplier") if supplier: - self.doc.supplier = supplier + self.supplier = supplier break def validate_warehouse(self): from erpnext.stock.utils import validate_warehouse_company warehouses = list(set([d.warehouse for d in - self.doclist.get({"doctype": self.tname}) if d.warehouse])) + self.get(self.fname) if getattr(d, "warehouse", None)])) for w in warehouses: - validate_warehouse_company(w, self.doc.company) + validate_warehouse_company(w, self.company) def validate_stock_or_nonstock_items(self): if not self.get_stock_items(): tax_for_valuation = [d.account_head for d in - self.doclist.get({"parentfield": "other_charges"}) + self.get("other_charges") if d.category in ["Valuation", "Valuation and Total"]] if tax_for_valuation: frappe.msgprint(_("""Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items"""), raise_exception=1) def set_total_in_words(self): from frappe.utils import money_in_words - company_currency = get_company_currency(self.doc.company) + company_currency = get_company_currency(self.company) if self.meta.get_field("in_words"): - self.doc.in_words = money_in_words(self.doc.grand_total, company_currency) + self.in_words = money_in_words(self.grand_total, company_currency) if self.meta.get_field("in_words_import"): - self.doc.in_words_import = money_in_words(self.doc.grand_total_import, - self.doc.currency) + self.in_words_import = money_in_words(self.grand_total_import, + self.currency) def calculate_taxes_and_totals(self): self.other_fname = "other_charges" @@ -97,68 +97,56 @@ class BuyingController(StockController): def calculate_net_total(self): - self.doc.net_total = self.doc.net_total_import = 0.0 + self.net_total = self.net_total_import = 0.0 for item in self.item_doclist: - self.doc.net_total += item.base_amount - self.doc.net_total_import += item.amount + self.net_total += item.base_amount + self.net_total_import += item.amount - self.round_floats_in(self.doc, ["net_total", "net_total_import"]) + self.round_floats_in(self, ["net_total", "net_total_import"]) def calculate_totals(self): - self.doc.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist - else self.doc.net_total, self.precision("grand_total")) - self.doc.grand_total_import = flt(self.doc.grand_total / self.doc.conversion_rate, + self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist + else self.net_total, self.precision("grand_total")) + self.grand_total_import = flt(self.grand_total / self.conversion_rate, self.precision("grand_total_import")) - self.doc.total_tax = flt(self.doc.grand_total - self.doc.net_total, + self.total_tax = flt(self.grand_total - self.net_total, self.precision("total_tax")) if self.meta.get_field("rounded_total"): - self.doc.rounded_total = _round(self.doc.grand_total) + self.rounded_total = _round(self.grand_total) if self.meta.get_field("rounded_total_import"): - self.doc.rounded_total_import = _round(self.doc.grand_total_import) + self.rounded_total_import = _round(self.grand_total_import) if self.meta.get_field("other_charges_added"): - self.doc.other_charges_added = flt(sum([flt(d.tax_amount) for d in self.tax_doclist + self.other_charges_added = flt(sum([flt(d.tax_amount) for d in self.tax_doclist if d.add_deduct_tax=="Add" and d.category in ["Valuation and Total", "Total"]]), self.precision("other_charges_added")) if self.meta.get_field("other_charges_deducted"): - self.doc.other_charges_deducted = flt(sum([flt(d.tax_amount) for d in self.tax_doclist + self.other_charges_deducted = flt(sum([flt(d.tax_amount) for d in self.tax_doclist if d.add_deduct_tax=="Deduct" and d.category in ["Valuation and Total", "Total"]]), self.precision("other_charges_deducted")) if self.meta.get_field("other_charges_added_import"): - self.doc.other_charges_added_import = flt(self.doc.other_charges_added / - self.doc.conversion_rate, self.precision("other_charges_added_import")) + self.other_charges_added_import = flt(self.other_charges_added / + self.conversion_rate, self.precision("other_charges_added_import")) if self.meta.get_field("other_charges_deducted_import"): - self.doc.other_charges_deducted_import = flt(self.doc.other_charges_deducted / - self.doc.conversion_rate, self.precision("other_charges_deducted_import")) + self.other_charges_deducted_import = flt(self.other_charges_deducted / + self.conversion_rate, self.precision("other_charges_deducted_import")) def calculate_outstanding_amount(self): - if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus == 0: - self.doc.total_advance = flt(self.doc.total_advance, + if self.doctype == "Purchase Invoice" and self.docstatus == 0: + self.total_advance = flt(self.total_advance, self.precision("total_advance")) - self.doc.total_amount_to_pay = flt(self.doc.grand_total - flt(self.doc.write_off_amount, + self.total_amount_to_pay = flt(self.grand_total - flt(self.write_off_amount, self.precision("write_off_amount")), self.precision("total_amount_to_pay")) - self.doc.outstanding_amount = flt(self.doc.total_amount_to_pay - self.doc.total_advance, + self.outstanding_amount = flt(self.total_amount_to_pay - self.total_advance, self.precision("outstanding_amount")) - def _cleanup(self): - super(BuyingController, self)._cleanup() - - if not self.meta.get_field("item_tax_amount", parentfield=self.fname): - for item in self.item_doclist: - del item.fields["item_tax_amount"] - - if not self.meta.get_field("tax_amount_after_discount_amount", - parentfield=self.other_fname): - for tax in self.tax_doclist: - del tax.fields["tax_amount_after_discount_amount"] - # update valuation rate def update_valuation_rate(self, parentfield): """ @@ -171,19 +159,19 @@ class BuyingController(StockController): stock_items_qty, stock_items_amount = 0, 0 last_stock_item_idx = 1 - for d in self.doclist.get({"parentfield": parentfield}): + for d in self.get(parentfield): if d.item_code and d.item_code in stock_items: stock_items_qty += flt(d.qty) stock_items_amount += flt(d.base_amount) last_stock_item_idx = d.idx total_valuation_amount = sum([flt(d.tax_amount) for d in - self.doclist.get({"parentfield": "other_charges"}) + self.get("other_charges") if d.category in ["Valuation", "Valuation and Total"]]) valuation_amount_adjustment = total_valuation_amount - for i, item in enumerate(self.doclist.get({"parentfield": parentfield})): + for i, item in enumerate(self.get(parentfield)): if item.item_code and item.qty and item.item_code in stock_items: item_proportion = flt(item.base_amount) / stock_items_amount if stock_items_amount \ else flt(item.qty) / stock_items_qty @@ -208,19 +196,19 @@ class BuyingController(StockController): item.valuation_rate = 0.0 def validate_for_subcontracting(self): - if not self.doc.is_subcontracted and self.sub_contracted_items: + if not self.is_subcontracted and self.sub_contracted_items: frappe.msgprint(_("""Please enter whether %s is made for subcontracting or purchasing, - in 'Is Subcontracted' field""" % self.doc.doctype), raise_exception=1) + in 'Is Subcontracted' field""" % self.doctype), raise_exception=1) - if self.doc.doctype == "Purchase Receipt" and self.doc.is_subcontracted=="Yes" \ - and not self.doc.supplier_warehouse: + if self.doctype == "Purchase Receipt" and self.is_subcontracted=="Yes" \ + and not self.supplier_warehouse: frappe.msgprint(_("Supplier Warehouse mandatory subcontracted purchase receipt"), raise_exception=1) def update_raw_materials_supplied(self, raw_material_table): - self.doclist = self.doc.clear_table(self.doclist, raw_material_table) - if self.doc.is_subcontracted=="Yes": - for item in self.doclist.get({"parentfield": self.fname}): + self.set(raw_material_table, []) + if self.is_subcontracted=="Yes": + for item in self.get(self.fname): if item.item_code in self.sub_contracted_items: self.add_bom_items(item, raw_material_table) @@ -230,8 +218,7 @@ class BuyingController(StockController): for item in bom_items: required_qty = flt(item.qty_consumed_per_unit) * flt(d.qty) * flt(d.conversion_factor) rm_doclist = { - "parentfield": raw_material_table, - "doctype": self.doc.doctype + " Item Supplied", + "doctype": self.doctype + " Item Supplied", "reference_name": d.name, "bom_detail_no": item.name, "main_item_code": d.item_code, @@ -242,17 +229,17 @@ class BuyingController(StockController): "rate": item.rate, "amount": required_qty * flt(item.rate) } - if self.doc.doctype == "Purchase Receipt": + if self.doctype == "Purchase Receipt": rm_doclist.update({ "consumed_qty": required_qty, "description": item.description, }) - self.doclist.append(rm_doclist) + self.append(raw_material_table, rm_doclist) raw_materials_cost += required_qty * flt(item.rate) - if self.doc.doctype == "Purchase Receipt": + if self.doctype == "Purchase Receipt": d.rm_supp_cost = raw_materials_cost def get_items_from_default_bom(self, item_code): @@ -271,7 +258,7 @@ class BuyingController(StockController): if not hasattr(self, "_sub_contracted_items"): self._sub_contracted_items = [] item_codes = list(set(item.item_code for item in - self.doclist.get({"parentfield": self.fname}))) + self.get(self.fname))) if item_codes: self._sub_contracted_items = [r[0] for r in frappe.db.sql("""select name from `tabItem` where name in (%s) and is_sub_contracted_item='Yes'""" % \ @@ -284,7 +271,7 @@ class BuyingController(StockController): if not hasattr(self, "_purchase_items"): self._purchase_items = [] item_codes = list(set(item.item_code for item in - self.doclist.get({"parentfield": self.fname}))) + self.get(self.fname))) if item_codes: self._purchase_items = [r[0] for r in frappe.db.sql("""select name from `tabItem` where name in (%s) and is_purchase_item='Yes'""" % \ @@ -294,5 +281,5 @@ class BuyingController(StockController): def is_item_table_empty(self): - if not len(self.doclist.get({"parentfield": self.fname})): + if not len(self.get(self.fname)): frappe.throw(_("Item table can not be blank")) \ No newline at end of file diff --git a/erpnext/controllers/js/contact_address_common.js b/erpnext/controllers/js/contact_address_common.js index 6a66469d636..d06f6a02650 100644 --- a/erpnext/controllers/js/contact_address_common.js +++ b/erpnext/controllers/js/contact_address_common.js @@ -23,7 +23,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { "Installation Note", "Opportunity", "Customer Issue", "Maintenance Visit", "Maintenance Schedule"] .indexOf(doctype)!==-1) { - var refdoc = frappe.model.get_doc(doctype, docname); + var refdoc = frappe.get_doc(doctype, docname); if(refdoc.doctype == "Quotation" ? refdoc.quotation_to=="Customer" : true) { cur_frm.set_value("customer", refdoc.customer || refdoc.name); @@ -34,7 +34,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { } if(["Supplier", "Supplier Quotation", "Purchase Order", "Purchase Invoice", "Purchase Receipt"] .indexOf(doctype)!==-1) { - var refdoc = frappe.model.get_doc(doctype, docname); + var refdoc = frappe.get_doc(doctype, docname); cur_frm.set_value("supplier", refdoc.supplier || refdoc.name); cur_frm.set_value("supplier_name", refdoc.supplier_name); if(cur_frm.doc.doctype==="Address") @@ -42,7 +42,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { } if(["Lead", "Quotation"] .indexOf(doctype)!==-1) { - var refdoc = frappe.model.get_doc(doctype, docname); + var refdoc = frappe.get_doc(doctype, docname); if(refdoc.doctype == "Quotation" ? refdoc.quotation_to=="Lead" : true) { cur_frm.set_value("lead", refdoc.lead || refdoc.name); diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index f58366830c6..3f78fe69cbf 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -13,141 +13,140 @@ class SellingController(StockController): def onload_post_render(self): # contact, address, item details and pos details (if applicable) self.set_missing_values() - + def validate(self): super(SellingController, self).validate() self.validate_max_discount() check_active_sales_items(self) - + def get_sender(self, comm): return frappe.db.get_value('Sales Email Settings', None, 'email_id') - + def set_missing_values(self, for_validate=False): super(SellingController, self).set_missing_values(for_validate) - + # set contact and address details for customer, if they are not mentioned self.set_missing_lead_customer_details() self.set_price_list_and_item_details() - if self.doc.fields.get("__islocal"): + if self.get("__islocal"): self.set_taxes("other_charges", "taxes_and_charges") - + def set_missing_lead_customer_details(self): - if self.doc.customer: + if getattr(self, "customer", None): from erpnext.accounts.party import _get_party_details - self.doc.update_if_missing(_get_party_details(self.doc.customer, - ignore_permissions=self.bean.ignore_permissions)) - - elif self.doc.lead: + self.update_if_missing(_get_party_details(self.customer, + ignore_permissions=getattr(self, "ignore_permissions", None))) + + elif getattr(self, "lead", None): from erpnext.selling.doctype.lead.lead import get_lead_details - self.doc.update_if_missing(get_lead_details(self.doc.lead)) - + self.update_if_missing(get_lead_details(self.lead)) + def set_price_list_and_item_details(self): self.set_price_list_currency("Selling") self.set_missing_item_details() - + def apply_shipping_rule(self): - if self.doc.shipping_rule: - shipping_rule = frappe.bean("Shipping Rule", self.doc.shipping_rule) - value = self.doc.net_total - + if self.shipping_rule: + shipping_rule = frappe.get_doc("Shipping Rule", self.shipping_rule) + value = self.net_total + # TODO # shipping rule calculation based on item's net weight - + shipping_amount = 0.0 - for condition in shipping_rule.doclist.get({"parentfield": "shipping_rule_conditions"}): + for condition in shipping_rule.get("shipping_rule_conditions"): if not condition.to_value or (flt(condition.from_value) <= value <= flt(condition.to_value)): shipping_amount = condition.shipping_amount break - - self.doclist.append({ + + self.append("other_charges", { "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", "charge_type": "Actual", - "account_head": shipping_rule.doc.account, - "cost_center": shipping_rule.doc.cost_center, - "description": shipping_rule.doc.label, + "account_head": shipping_rule.account, + "cost_center": shipping_rule.cost_center, + "description": shipping_rule.label, "rate": shipping_amount }) - + def set_total_in_words(self): from frappe.utils import money_in_words - company_currency = get_company_currency(self.doc.company) - - disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, + company_currency = get_company_currency(self.company) + + disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total")) - + if self.meta.get_field("in_words"): - self.doc.in_words = money_in_words(disable_rounded_total and - self.doc.grand_total or self.doc.rounded_total, company_currency) + self.in_words = money_in_words(disable_rounded_total and + self.grand_total or self.rounded_total, company_currency) if self.meta.get_field("in_words_export"): - self.doc.in_words_export = money_in_words(disable_rounded_total and - self.doc.grand_total_export or self.doc.rounded_total_export, self.doc.currency) - + self.in_words_export = money_in_words(disable_rounded_total and + self.grand_total_export or self.rounded_total_export, self.currency) + def calculate_taxes_and_totals(self): self.other_fname = "other_charges" - + super(SellingController, self).calculate_taxes_and_totals() - + self.calculate_total_advance("Sales Invoice", "advance_adjustment_details") self.calculate_commission() self.calculate_contribution() - + def determine_exclusive_rate(self): if not any((cint(tax.included_in_print_rate) for tax in self.tax_doclist)): # no inclusive tax return - + for item in self.item_doclist: item_tax_map = self._load_item_tax_rate(item.item_tax_rate) cumulated_tax_fraction = 0 for i, tax in enumerate(self.tax_doclist): tax.tax_fraction_for_current_item = self.get_current_tax_fraction(tax, item_tax_map) - + if i==0: tax.grand_total_fraction_for_current_item = 1 + tax.tax_fraction_for_current_item else: tax.grand_total_fraction_for_current_item = \ self.tax_doclist[i-1].grand_total_fraction_for_current_item \ + tax.tax_fraction_for_current_item - + cumulated_tax_fraction += tax.tax_fraction_for_current_item - + if cumulated_tax_fraction and not self.discount_amount_applied: - item.base_amount = flt((item.amount * self.doc.conversion_rate) / + item.base_amount = flt((item.amount * self.conversion_rate) / (1 + cumulated_tax_fraction), self.precision("base_amount", item)) - + item.base_rate = flt(item.base_amount / item.qty, self.precision("base_rate", item)) - + if item.discount_percentage == 100: item.base_price_list_rate = item.base_rate item.base_rate = 0.0 else: item.base_price_list_rate = flt(item.base_rate / (1 - (item.discount_percentage / 100.0)), self.precision("base_price_list_rate", item)) - + def get_current_tax_fraction(self, tax, item_tax_map): """ Get tax fraction for calculating tax exclusive amount from tax inclusive amount """ current_tax_fraction = 0 - + if cint(tax.included_in_print_rate): tax_rate = self._get_tax_rate(tax, item_tax_map) - + if tax.charge_type == "On Net Total": current_tax_fraction = tax_rate / 100.0 - + elif tax.charge_type == "On Previous Row Amount": current_tax_fraction = (tax_rate / 100.0) * \ self.tax_doclist[cint(tax.row_id) - 1].tax_fraction_for_current_item - + elif tax.charge_type == "On Previous Row Total": current_tax_fraction = (tax_rate / 100.0) * \ self.tax_doclist[cint(tax.row_id) - 1].grand_total_fraction_for_current_item - + return current_tax_fraction - + def calculate_item_values(self): if not self.discount_amount_applied: for item in self.item_doclist: @@ -167,38 +166,38 @@ class SellingController(StockController): self._set_in_company_currency(item, "amount", "base_amount") def calculate_net_total(self): - self.doc.net_total = self.doc.net_total_export = 0.0 + self.net_total = self.net_total_export = 0.0 for item in self.item_doclist: - self.doc.net_total += item.base_amount - self.doc.net_total_export += item.amount - - self.round_floats_in(self.doc, ["net_total", "net_total_export"]) - + self.net_total += item.base_amount + self.net_total_export += item.amount + + self.round_floats_in(self, ["net_total", "net_total_export"]) + def calculate_totals(self): - self.doc.grand_total = flt(self.tax_doclist and \ - self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total")) - self.doc.grand_total_export = flt(self.doc.grand_total / self.doc.conversion_rate, + self.grand_total = flt(self.tax_doclist and \ + self.tax_doclist[-1].total or self.net_total, self.precision("grand_total")) + self.grand_total_export = flt(self.grand_total / self.conversion_rate, self.precision("grand_total_export")) - - self.doc.other_charges_total = flt(self.doc.grand_total - self.doc.net_total, + + self.other_charges_total = flt(self.grand_total - self.net_total, self.precision("other_charges_total")) - self.doc.other_charges_total_export = flt(self.doc.grand_total_export - - self.doc.net_total_export + flt(self.doc.discount_amount), + self.other_charges_total_export = flt(self.grand_total_export - + self.net_total_export + flt(self.discount_amount), self.precision("other_charges_total_export")) - - self.doc.rounded_total = _round(self.doc.grand_total) - self.doc.rounded_total_export = _round(self.doc.grand_total_export) + + self.rounded_total = _round(self.grand_total) + self.rounded_total_export = _round(self.grand_total_export) def apply_discount_amount(self): - if self.doc.discount_amount: + if self.discount_amount: grand_total_for_discount_amount = self.get_grand_total_for_discount_amount() if grand_total_for_discount_amount: # calculate item amount after Discount Amount for item in self.item_doclist: - distributed_amount = flt(self.doc.discount_amount) * item.base_amount / grand_total_for_discount_amount + distributed_amount = flt(self.discount_amount) * item.base_amount / grand_total_for_discount_amount item.base_amount = flt(item.base_amount - distributed_amount, self.precision("base_amount", item)) self.discount_amount_applied = True @@ -215,107 +214,107 @@ class SellingController(StockController): flt(tax.rate) / 100 actual_taxes_dict.setdefault(tax.idx, actual_tax_amount) - grand_total_for_discount_amount = flt(self.doc.grand_total - sum(actual_taxes_dict.values()), + grand_total_for_discount_amount = flt(self.grand_total - sum(actual_taxes_dict.values()), self.precision("grand_total")) return grand_total_for_discount_amount def calculate_outstanding_amount(self): - # NOTE: + # NOTE: # write_off_amount is only for POS Invoice # total_advance is only for non POS Invoice - if self.doc.doctype == "Sales Invoice" and self.doc.docstatus == 0: - self.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount", + if self.doctype == "Sales Invoice" and self.docstatus == 0: + self.round_floats_in(self, ["grand_total", "total_advance", "write_off_amount", "paid_amount"]) - total_amount_to_pay = self.doc.grand_total - self.doc.write_off_amount - self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance \ - - self.doc.paid_amount, self.precision("outstanding_amount")) - + total_amount_to_pay = self.grand_total - self.write_off_amount + self.outstanding_amount = flt(total_amount_to_pay - self.total_advance \ + - self.paid_amount, self.precision("outstanding_amount")) + def calculate_commission(self): if self.meta.get_field("commission_rate"): - self.round_floats_in(self.doc, ["net_total", "commission_rate"]) - if self.doc.commission_rate > 100.0: - msgprint(_(self.meta.get_label("commission_rate")) + " " + + self.round_floats_in(self, ["net_total", "commission_rate"]) + if self.commission_rate > 100.0: + msgprint(_(self.meta.get_label("commission_rate")) + " " + _("cannot be greater than 100"), raise_exception=True) - - self.doc.total_commission = flt(self.doc.net_total * self.doc.commission_rate / 100.0, + + self.total_commission = flt(self.net_total * self.commission_rate / 100.0, self.precision("total_commission")) def calculate_contribution(self): total = 0.0 - sales_team = self.doclist.get({"parentfield": "sales_team"}) + sales_team = self.get("sales_team") for sales_person in sales_team: self.round_floats_in(sales_person) sales_person.allocated_amount = flt( - self.doc.net_total * sales_person.allocated_percentage / 100.0, + self.net_total * sales_person.allocated_percentage / 100.0, self.precision("allocated_amount", sales_person)) - + total += sales_person.allocated_percentage - + if sales_team and total != 100.0: - msgprint(_("Total") + " " + - _(self.meta.get_label("allocated_percentage", parentfield="sales_team")) + + msgprint(_("Total") + " " + + _(self.meta.get_label("allocated_percentage", parentfield="sales_team")) + " " + _("should be 100%"), raise_exception=True) - + def validate_order_type(self): valid_types = ["Sales", "Maintenance", "Shopping Cart"] - if not self.doc.order_type: - self.doc.order_type = "Sales" - elif self.doc.order_type not in valid_types: - msgprint(_(self.meta.get_label("order_type")) + " " + + if not self.order_type: + self.order_type = "Sales" + elif self.order_type not in valid_types: + msgprint(_(self.meta.get_label("order_type")) + " " + _("must be one of") + ": " + comma_or(valid_types), raise_exception=True) - + def check_credit(self, grand_total): - customer_account = frappe.db.get_value("Account", {"company": self.doc.company, - "master_name": self.doc.customer}, "name") + customer_account = frappe.db.get_value("Account", {"company": self.company, + "master_name": self.customer}, "name") if customer_account: - total_outstanding = frappe.db.sql("""select - sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) + total_outstanding = frappe.db.sql("""select + sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabGL Entry` where account = %s""", customer_account) total_outstanding = total_outstanding[0][0] if total_outstanding else 0 - + outstanding_including_current = flt(total_outstanding) + flt(grand_total) - frappe.bean('Account', customer_account).run_method("check_credit_limit", + frappe.get_doc('Account', customer_account).run_method("check_credit_limit", outstanding_including_current) - + def validate_max_discount(self): - for d in self.doclist.get({"parentfield": self.fname}): + for d in self.get(self.fname): discount = flt(frappe.db.get_value("Item", d.item_code, "max_discount")) - + if discount and flt(d.discount_percentage) > discount: - frappe.throw(_("You cannot give more than ") + cstr(discount) + "% " + + frappe.throw(_("You cannot give more than ") + cstr(discount) + "% " + _("discount on Item Code") + ": " + cstr(d.item_code)) - + def get_item_list(self): il = [] - for d in self.doclist.get({"parentfield": self.fname}): + for d in self.get(self.fname): reserved_warehouse = "" reserved_qty_for_main_item = 0 - - if self.doc.doctype == "Sales Order": - if (frappe.db.get_value("Item", d.item_code, "is_stock_item") == 'Yes' or + + if self.doctype == "Sales Order": + if (frappe.db.get_value("Item", d.item_code, "is_stock_item") == 'Yes' or self.has_sales_bom(d.item_code)) and not d.warehouse: - frappe.throw(_("Please enter Reserved Warehouse for item ") + + frappe.throw(_("Please enter Reserved Warehouse for item ") + d.item_code + _(" as it is stock Item or packing item")) reserved_warehouse = d.warehouse if flt(d.qty) > flt(d.delivered_qty): reserved_qty_for_main_item = flt(d.qty) - flt(d.delivered_qty) - - if self.doc.doctype == "Delivery Note" and d.against_sales_order: + + elif self.doctype == "Delivery Note" and d.against_sales_order: # if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12. # But in this case reserved qty should only be reduced by 10 and not 12 - - already_delivered_qty = self.get_already_delivered_qty(self.doc.name, + + already_delivered_qty = self.get_already_delivered_qty(self.name, d.against_sales_order, d.prevdoc_detail_docname) so_qty, reserved_warehouse = self.get_so_qty_and_warehouse(d.prevdoc_detail_docname) - + if already_delivered_qty + d.qty > so_qty: reserved_qty_for_main_item = -(so_qty - already_delivered_qty) else: reserved_qty_for_main_item = -flt(d.qty) if self.has_sales_bom(d.item_code): - for p in self.doclist.get({"parentfield": "packing_details"}): + for p in self.get("packing_details"): if p.parent_detail_docname == d.name and p.parent_item == d.item_code: # the packing details table's qty is already multiplied with parent's qty il.append(frappe._dict({ @@ -337,20 +336,20 @@ class SellingController(StockController): 'qty': d.qty, 'reserved_qty': reserved_qty_for_main_item, 'uom': d.stock_uom, - 'batch_no': cstr(d.batch_no).strip(), - 'serial_no': cstr(d.serial_no).strip(), + 'batch_no': cstr(d.get("batch_no")).strip(), + 'serial_no': cstr(d.get("serial_no")).strip(), 'name': d.name })) return il - + def has_sales_bom(self, item_code): - return frappe.db.sql("""select name from `tabSales BOM` + return frappe.db.sql("""select name from `tabSales BOM` where new_item_code=%s and docstatus != 2""", item_code) - + def get_already_delivered_qty(self, dn, so, so_detail): - qty = frappe.db.sql("""select sum(qty) from `tabDelivery Note Item` - where prevdoc_detail_docname = %s and docstatus = 1 - and against_sales_order = %s + qty = frappe.db.sql("""select sum(qty) from `tabDelivery Note Item` + where prevdoc_detail_docname = %s and docstatus = 1 + and against_sales_order = %s and parent != %s""", (so_detail, so, dn)) return qty and flt(qty[0][0]) or 0.0 @@ -360,24 +359,24 @@ class SellingController(StockController): so_qty = so_item and flt(so_item[0]["qty"]) or 0.0 so_warehouse = so_item and so_item[0]["warehouse"] or "" return so_qty, so_warehouse - + def check_stop_sales_order(self, ref_fieldname): - for d in self.doclist.get({"parentfield": self.fname}): - if d.fields.get(ref_fieldname): - status = frappe.db.get_value("Sales Order", d.fields[ref_fieldname], "status") + for d in self.get(self.fname): + if d.get(ref_fieldname): + status = frappe.db.get_value("Sales Order", d.get(ref_fieldname), "status") if status == "Stopped": - frappe.throw(self.doc.doctype + - _(" can not be created/modified against stopped Sales Order ") + - d.fields[ref_fieldname]) - + frappe.throw(self.doctype + + _(" can not be created/modified against stopped Sales Order ") + + d.get(ref_fieldname)) + def check_active_sales_items(obj): - for d in obj.doclist.get({"parentfield": obj.fname}): + for d in obj.get(obj.fname): if d.item_code: - item = frappe.db.sql("""select docstatus, is_sales_item, - is_service_item, income_account from tabItem where name = %s""", + item = frappe.db.sql("""select docstatus, is_sales_item, + is_service_item, income_account from tabItem where name = %s""", d.item_code, as_dict=True)[0] if item.is_sales_item == 'No' and item.is_service_item == 'No': frappe.throw(_("Item is neither Sales nor Service Item") + ": " + d.item_code) - if d.income_account and not item.income_account: - frappe.db.set_value("Item", d.item_code, "income_account", + if getattr(d, "income_account", None) and not item.income_account: + frappe.db.set_value("Item", d.item_code, "income_account", d.income_account) diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 7411d092e2c..0fceebf84bb 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -25,27 +25,27 @@ status_map = { ], "Opportunity": [ ["Draft", None], - ["Submitted", "eval:self.doc.docstatus==1"], - ["Lost", "eval:self.doc.status=='Lost'"], + ["Submitted", "eval:self.docstatus==1"], + ["Lost", "eval:self.status=='Lost'"], ["Quotation", "has_quotation"], ["Replied", "communication_sent"], - ["Cancelled", "eval:self.doc.docstatus==2"], + ["Cancelled", "eval:self.docstatus==2"], ["Open", "communication_received"], ], "Quotation": [ ["Draft", None], - ["Submitted", "eval:self.doc.docstatus==1"], - ["Lost", "eval:self.doc.status=='Lost'"], + ["Submitted", "eval:self.docstatus==1"], + ["Lost", "eval:self.status=='Lost'"], ["Ordered", "has_sales_order"], ["Replied", "communication_sent"], - ["Cancelled", "eval:self.doc.docstatus==2"], + ["Cancelled", "eval:self.docstatus==2"], ["Open", "communication_received"], ], "Sales Order": [ ["Draft", None], - ["Submitted", "eval:self.doc.docstatus==1"], - ["Stopped", "eval:self.doc.status=='Stopped'"], - ["Cancelled", "eval:self.doc.docstatus==2"], + ["Submitted", "eval:self.docstatus==1"], + ["Stopped", "eval:self.status=='Stopped'"], + ["Cancelled", "eval:self.docstatus==2"], ], "Support Ticket": [ ["Replied", "communication_sent"], @@ -64,64 +64,64 @@ class StatusUpdater(DocListController): def update_prevdoc_status(self): self.update_qty() self.validate_qty() - + def set_status(self, update=False): - if self.doc.get("__islocal"): + if self.get("__islocal"): return - - if self.doc.doctype in status_map: - sl = status_map[self.doc.doctype][:] + + if self.doctype in status_map: + sl = status_map[self.doctype][:] sl.reverse() for s in sl: if not s[1]: - self.doc.status = s[0] + self.status = s[0] break elif s[1].startswith("eval:"): if eval(s[1][5:]): - self.doc.status = s[0] + self.status = s[0] break elif getattr(self, s[1])(): - self.doc.status = s[0] + self.status = s[0] break - + if update: - frappe.db.set_value(self.doc.doctype, self.doc.name, "status", self.doc.status) - + frappe.db.set_value(self.doctype, self.name, "status", self.status) + def on_communication(self): self.communication_set = True self.set_status(update=True) del self.communication_set - + def communication_received(self): if getattr(self, "communication_set", False): - last_comm = self.doclist.get({"doctype":"Communication"}) + last_comm = self.get("communications") if last_comm: return last_comm[-1].sent_or_received == "Received" def communication_sent(self): if getattr(self, "communication_set", False): - last_comm = self.doclist.get({"doctype":"Communication"}) + last_comm = self.get("communications") if last_comm: return last_comm[-1].sent_or_received == "Sent" - + def validate_qty(self): """ Validates qty at row level """ self.tolerance = {} self.global_tolerance = None - + for args in self.status_updater: # get unique transactions to update - for d in self.doclist: - if d.doctype == args['source_dt'] and d.fields.get(args["join_field"]): - args['name'] = d.fields[args['join_field']] + for d in self.get_all_children(): + if d.doctype == args['source_dt'] and d.get(args["join_field"]): + args['name'] = d.get(args['join_field']) # get all qty where qty > target_field - item = frappe.db.sql("""select item_code, `{target_ref_field}`, - `{target_field}`, parenttype, parent from `tab{target_dt}` - where `{target_ref_field}` < `{target_field}` - and name=%s and docstatus=1""".format(**args), + item = frappe.db.sql("""select item_code, `{target_ref_field}`, + `{target_field}`, parenttype, parent from `tab{target_dt}` + where `{target_ref_field}` < `{target_field}` + and name=%s and docstatus=1""".format(**args), args['name'], as_dict=1) if item: item = item[0] @@ -142,38 +142,37 @@ class StatusUpdater(DocListController): is """ % item + cstr(item[args['target_ref_field']]) + """.
You must reduce the %(target_ref_field)s by \ %(reduce_by)s""" % item, raise_exception=1) - + else: self.check_overflow_with_tolerance(item, args) - + def check_overflow_with_tolerance(self, item, args): """ Checks if there is overflow condering a relaxation tolerance """ - # check if overflow is within tolerance - tolerance, self.tolerance, self.global_tolerance = get_tolerance_for(item['item_code'], + tolerance, self.tolerance, self.global_tolerance = get_tolerance_for(item['item_code'], self.tolerance, self.global_tolerance) - - overflow_percent = ((item[args['target_field']] - item[args['target_ref_field']]) / + + overflow_percent = ((item[args['target_field']] - item[args['target_ref_field']]) / item[args['target_ref_field']]) * 100 - + if overflow_percent - tolerance > 0.01: item['max_allowed'] = flt(item[args['target_ref_field']] * (100+tolerance)/100) item['reduce_by'] = item[args['target_field']] - item['max_allowed'] - + msgprint(""" Row #%(idx)s: Max %(target_ref_field)s allowed for Item %(item_code)s \ - against %(parenttype)s %(parent)s is %(max_allowed)s. - + against %(parenttype)s %(parent)s is %(max_allowed)s. + If you want to increase your overflow tolerance, please increase tolerance %% in \ - Global Defaults or Item master. - + Global Defaults or Item master. + Or, you must reduce the %(target_ref_field)s by %(reduce_by)s - - Also, please check if the order item has already been billed in the Sales Order""" % + + Also, please check if the order item has already been billed in the Sales Order""" % item, raise_exception=1) - + def update_qty(self, change_modified=True): """ @@ -181,109 +180,107 @@ class StatusUpdater(DocListController): """ for args in self.status_updater: # condition to include current record (if submit or no if cancel) - if self.doc.docstatus == 1: - args['cond'] = ' or parent="%s"' % self.doc.name.replace('"', '\"') + if self.docstatus == 1: + args['cond'] = ' or parent="%s"' % self.name.replace('"', '\"') else: - args['cond'] = ' and parent!="%s"' % self.doc.name.replace('"', '\"') - + args['cond'] = ' and parent!="%s"' % self.name.replace('"', '\"') + args['modified_cond'] = '' if change_modified: args['modified_cond'] = ', modified = now()' - + # update quantities in child table - for d in self.doclist: + for d in self.get_all_children(): if d.doctype == args['source_dt']: # updates qty in the child table - args['detail_id'] = d.fields.get(args['join_field']) - + args['detail_id'] = d.get(args['join_field']) + args['second_source_condition'] = "" if args.get('second_source_dt') and args.get('second_source_field') \ and args.get('second_join_field'): - args['second_source_condition'] = """ + (select sum(%(second_source_field)s) - from `tab%(second_source_dt)s` - where `%(second_join_field)s`="%(detail_id)s" + args['second_source_condition'] = """ + (select sum(%(second_source_field)s) + from `tab%(second_source_dt)s` + where `%(second_join_field)s`="%(detail_id)s" and (docstatus=1))""" % args - + if args['detail_id']: - frappe.db.sql("""update `tab%(target_dt)s` - set %(target_field)s = (select sum(%(source_field)s) - from `tab%(source_dt)s` where `%(join_field)s`="%(detail_id)s" + frappe.db.sql("""update `tab%(target_dt)s` + set %(target_field)s = (select sum(%(source_field)s) + from `tab%(source_dt)s` where `%(join_field)s`="%(detail_id)s" and (docstatus=1 %(cond)s)) %(second_source_condition)s where name='%(detail_id)s'""" % args) - + # get unique transactions to update - for name in set([d.fields.get(args['percent_join_field']) for d in self.doclist - if d.doctype == args['source_dt']]): + for name in set([d.get(args['percent_join_field']) for d in self.get_all_children(args['source_dt'])]): if name: args['name'] = name - + # update percent complete in the parent table - frappe.db.sql("""update `tab%(target_parent_dt)s` - set %(target_parent_field)s = (select sum(if(%(target_ref_field)s > - ifnull(%(target_field)s, 0), %(target_field)s, - %(target_ref_field)s))/sum(%(target_ref_field)s)*100 + frappe.db.sql("""update `tab%(target_parent_dt)s` + set %(target_parent_field)s = (select sum(if(%(target_ref_field)s > + ifnull(%(target_field)s, 0), %(target_field)s, + %(target_ref_field)s))/sum(%(target_ref_field)s)*100 from `tab%(target_dt)s` where parent="%(name)s") %(modified_cond)s where name='%(name)s'""" % args) # update field if args.get('status_field'): - frappe.db.sql("""update `tab%(target_parent_dt)s` - set %(status_field)s = if(ifnull(%(target_parent_field)s,0)<0.001, - 'Not %(keyword)s', if(%(target_parent_field)s>=99.99, + frappe.db.sql("""update `tab%(target_parent_dt)s` + set %(status_field)s = if(ifnull(%(target_parent_field)s,0)<0.001, + 'Not %(keyword)s', if(%(target_parent_field)s>=99.99, 'Fully %(keyword)s', 'Partly %(keyword)s')) where name='%(name)s'""" % args) - - + + def update_billing_status_for_zero_amount_refdoc(self, ref_dt): ref_fieldname = ref_dt.lower().replace(" ", "_") zero_amount_refdoc = [] - all_zero_amount_refdoc = frappe.db.sql_list("""select name from `tab%s` + all_zero_amount_refdoc = frappe.db.sql_list("""select name from `tab%s` where docstatus=1 and net_total = 0""" % ref_dt) - - for item in self.doclist.get({"parentfield": "entries"}): - if item.fields.get(ref_fieldname) \ - and item.fields.get(ref_fieldname) in all_zero_amount_refdoc \ - and item.fields.get(ref_fieldname) not in zero_amount_refdoc: - zero_amount_refdoc.append(item.fields[ref_fieldname]) - + + for item in self.get("entries"): + if item.get(ref_fieldname) \ + and item.get(ref_fieldname) in all_zero_amount_refdoc \ + and item.get(ref_fieldname) not in zero_amount_refdoc: + zero_amount_refdoc.append(item.get(ref_fieldname)) + if zero_amount_refdoc: self.update_biling_status(zero_amount_refdoc, ref_dt, ref_fieldname) - + def update_biling_status(self, zero_amount_refdoc, ref_dt, ref_fieldname): for ref_dn in zero_amount_refdoc: - ref_doc_qty = flt(frappe.db.sql("""select sum(ifnull(qty, 0)) from `tab%s Item` + ref_doc_qty = flt(frappe.db.sql("""select sum(ifnull(qty, 0)) from `tab%s Item` where parent=%s""" % (ref_dt, '%s'), (ref_dn))[0][0]) - - billed_qty = flt(frappe.db.sql("""select sum(ifnull(qty, 0)) - from `tab%s Item` where %s=%s and docstatus=1""" % - (self.doc.doctype, ref_fieldname, '%s'), (ref_dn))[0][0]) - + + billed_qty = flt(frappe.db.sql("""select sum(ifnull(qty, 0)) + from `tab%s Item` where %s=%s and docstatus=1""" % + (self.doctype, ref_fieldname, '%s'), (ref_dn))[0][0]) + per_billed = ((ref_doc_qty if billed_qty > ref_doc_qty else billed_qty)\ / ref_doc_qty)*100 frappe.db.set_value(ref_dt, ref_dn, "per_billed", per_billed) - - from frappe.model.meta import has_field - if has_field(ref_dt, "billing_status"): + + if frappe.get_meta(ref_dt).get_field("billing_status"): if per_billed < 0.001: billing_status = "Not Billed" elif per_billed >= 99.99: billing_status = "Fully Billed" else: billing_status = "Partly Billed" - + frappe.db.set_value(ref_dt, ref_dn, "billing_status", billing_status) - + def get_tolerance_for(item_code, item_tolerance={}, global_tolerance=None): """ Returns the tolerance for the item, if not set, returns global tolerance """ if item_tolerance.get(item_code): return item_tolerance[item_code], item_tolerance, global_tolerance - + tolerance = flt(frappe.db.get_value('Item',item_code,'tolerance') or 0) if not tolerance: if global_tolerance == None: - global_tolerance = flt(frappe.db.get_value('Global Defaults', None, + global_tolerance = flt(frappe.db.get_value('Global Defaults', None, 'tolerance')) tolerance = global_tolerance - + item_tolerance[item_code] = tolerance - return tolerance, item_tolerance, global_tolerance \ No newline at end of file + return tolerance, item_tolerance, global_tolerance diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 47bcdd4d738..6aeb9402f61 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -12,31 +12,31 @@ from erpnext.accounts.general_ledger import make_gl_entries, delete_gl_entries class StockController(AccountsController): def make_gl_entries(self, repost_future_gle=True): - if self.doc.docstatus == 2: - delete_gl_entries(voucher_type=self.doc.doctype, voucher_no=self.doc.name) - + if self.docstatus == 2: + delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name) + if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): warehouse_account = self.get_warehouse_account() - - if self.doc.docstatus==1: + + if self.docstatus==1: gl_entries = self.get_gl_entries(warehouse_account) make_gl_entries(gl_entries) if repost_future_gle: items, warehouse_account = self.get_items_and_warehouse_accounts(warehouse_account) - update_gl_entries_after(self.doc.posting_date, self.doc.posting_time, + update_gl_entries_after(self.posting_date, self.posting_time, warehouse_account, items) - + def get_gl_entries(self, warehouse_account=None, default_expense_account=None, default_cost_center=None): from erpnext.accounts.general_ledger import process_gl_map if not warehouse_account: warehouse_account = get_warehouse_account() - + stock_ledger = self.get_stock_ledger_details() - voucher_details = self.get_voucher_details(stock_ledger, default_expense_account, + voucher_details = self.get_voucher_details(stock_ledger, default_expense_account, default_cost_center) - + gl_list = [] warehouse_with_no_account = [] for detail in voucher_details: @@ -49,7 +49,7 @@ class StockController(AccountsController): "account": warehouse_account[sle.warehouse], "against": detail.expense_account, "cost_center": detail.cost_center, - "remarks": self.doc.remarks or "Accounting Entry for Stock", + "remarks": self.get("remarks") or "Accounting Entry for Stock", "debit": flt(sle.stock_value_difference, 2) })) @@ -58,72 +58,79 @@ class StockController(AccountsController): "account": detail.expense_account, "against": warehouse_account[sle.warehouse], "cost_center": detail.cost_center, - "remarks": self.doc.remarks or "Accounting Entry for Stock", + "remarks": self.get("remarks") or "Accounting Entry for Stock", "credit": flt(sle.stock_value_difference, 2) })) elif sle.warehouse not in warehouse_with_no_account: warehouse_with_no_account.append(sle.warehouse) - - if warehouse_with_no_account: - msgprint(_("No accounting entries for following warehouses") + ": \n" + + + if warehouse_with_no_account: + msgprint(_("No accounting entries for following warehouses") + ": \n" + "\n".join(warehouse_with_no_account)) - + return process_gl_map(gl_list) - + def get_voucher_details(self, stock_ledger, default_expense_account, default_cost_center): if not default_expense_account: - details = self.doclist.get({"parentfield": self.fname}) + details = self.get(self.fname) for d in details: self.check_expense_account(d) else: details = [frappe._dict({ - "name":d, - "expense_account": default_expense_account, + "name":d, + "expense_account": default_expense_account, "cost_center": default_cost_center }) for d in stock_ledger.keys()] - + return details - + def get_items_and_warehouse_accounts(self, warehouse_account=None): items, warehouses = [], [] if not warehouse_account: warehouse_account = get_warehouse_account() - + if hasattr(self, "fname"): - item_doclist = self.doclist.get({"parentfield": self.fname}) - elif self.doc.doctype == "Stock Reconciliation": + item_doclist = self.get(self.fname) + elif self.doctype == "Stock Reconciliation": import json item_doclist = [] - data = json.loads(self.doc.reconciliation_json) + data = json.loads(self.reconciliation_json) for row in data[data.index(self.head_row)+1:]: d = frappe._dict(zip(["item_code", "warehouse", "qty", "valuation_rate"], row)) item_doclist.append(d) - + if item_doclist: for d in item_doclist: if d.item_code and d.item_code not in items: items.append(d.item_code) - if d.warehouse and d.warehouse not in warehouses: + + if d.get("warehouse") and d.warehouse not in warehouses: warehouses.append(d.warehouse) - warehouse_account = {wh: warehouse_account[wh] for wh in warehouses + if self.doctype == "Stock Entry": + if d.get("s_warehouse") and d.s_warehouse not in warehouses: + warehouses.append(d.s_warehouse) + if d.get("t_warehouse") and d.t_warehouse not in warehouses: + warehouses.append(d.t_warehouse) + + warehouse_account = {wh: warehouse_account[wh] for wh in warehouses if warehouse_account.get(wh)} - + return items, warehouse_account - + def get_stock_ledger_details(self): stock_ledger = {} for sle in frappe.db.sql("""select warehouse, stock_value_difference, voucher_detail_no from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""", - (self.doc.doctype, self.doc.name), as_dict=True): + (self.doctype, self.name), as_dict=True): stock_ledger.setdefault(sle.voucher_detail_no, []).append(sle) return stock_ledger - + def get_warehouse_account(self): - warehouse_account = dict(frappe.db.sql("""select master_name, name from tabAccount + warehouse_account = dict(frappe.db.sql("""select master_name, name from tabAccount where account_type = 'Warehouse' and ifnull(master_name, '') != ''""")) return warehouse_account - + def update_gl_entries_after(self, warehouse_account=None): future_stock_vouchers = self.get_future_stock_vouchers() gle = self.get_voucherwise_gl_entries(future_stock_vouchers) @@ -131,7 +138,7 @@ class StockController(AccountsController): warehouse_account = self.get_warehouse_account() for voucher_type, voucher_no in future_stock_vouchers: existing_gle = gle.get((voucher_type, voucher_no), []) - voucher_obj = frappe.get_obj(voucher_type, voucher_no) + voucher_obj = frappe.get_doc(voucher_type, voucher_no) expected_gle = voucher_obj.get_gl_entries(warehouse_account) if expected_gle: matched = True @@ -146,53 +153,53 @@ class StockController(AccountsController): break else: matched = False - + if not matched: self.delete_gl_entries(voucher_type, voucher_no) voucher_obj.make_gl_entries(repost_future_gle=False) else: self.delete_gl_entries(voucher_type, voucher_no) - - + + def get_future_stock_vouchers(self): future_stock_vouchers = [] - + if hasattr(self, "fname"): - item_list = [d.item_code for d in self.doclist.get({"parentfield": self.fname})] + item_list = [d.item_code for d in self.get(self.fname)] condition = ''.join(['and item_code in (\'', '\', \''.join(item_list) ,'\')']) else: condition = "" - - for d in frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no + + for d in frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no from `tabStock Ledger Entry` sle where timestamp(sle.posting_date, sle.posting_time) >= timestamp(%s, %s) %s - order by timestamp(sle.posting_date, sle.posting_time) asc, name asc""" % - ('%s', '%s', condition), (self.doc.posting_date, self.doc.posting_time), + order by timestamp(sle.posting_date, sle.posting_time) asc, name asc""" % + ('%s', '%s', condition), (self.posting_date, self.posting_time), as_dict=True): future_stock_vouchers.append([d.voucher_type, d.voucher_no]) - + return future_stock_vouchers - + def get_voucherwise_gl_entries(self, future_stock_vouchers): gl_entries = {} if future_stock_vouchers: - for d in frappe.db.sql("""select * from `tabGL Entry` - where posting_date >= %s and voucher_no in (%s)""" % - ('%s', ', '.join(['%s']*len(future_stock_vouchers))), - tuple([self.doc.posting_date] + [d[1] for d in future_stock_vouchers]), as_dict=1): + for d in frappe.db.sql("""select * from `tabGL Entry` + where posting_date >= %s and voucher_no in (%s)""" % + ('%s', ', '.join(['%s']*len(future_stock_vouchers))), + tuple([self.posting_date] + [d[1] for d in future_stock_vouchers]), as_dict=1): gl_entries.setdefault((d.voucher_type, d.voucher_no), []).append(d) - + return gl_entries - + def delete_gl_entries(self, voucher_type, voucher_no): - frappe.db.sql("""delete from `tabGL Entry` + frappe.db.sql("""delete from `tabGL Entry` where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no)) - + def make_adjustment_entry(self, expected_gle, voucher_obj): from erpnext.accounts.utils import get_stock_and_account_difference account_list = [d.account for d in expected_gle] acc_diff = get_stock_and_account_difference(account_list, expected_gle[0].posting_date) - + cost_center = self.get_company_default("cost_center") stock_adjustment_account = self.get_company_default("stock_adjustment_account") @@ -207,7 +214,7 @@ class StockController(AccountsController): "debit": diff, "remarks": "Adjustment Accounting Entry for Stock", }), - + # account against stock in hand voucher_obj.get_gl_dict({ "account": stock_adjustment_account, @@ -217,75 +224,75 @@ class StockController(AccountsController): "remarks": "Adjustment Accounting Entry for Stock", }), ]) - + if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries make_gl_entries(gl_entries) - + def check_expense_account(self, item): - if item.fields.has_key("expense_account") and not item.expense_account: - msgprint(_("""Expense/Difference account is mandatory for item: """) + item.item_code, + if item.meta.get_field("expense_account") and not item.expense_account: + msgprint(_("""Expense/Difference account is mandatory for item: """) + item.item_code, raise_exception=1) - - if item.fields.has_key("expense_account") and not item.cost_center: - msgprint(_("""Cost Center is mandatory for item: """) + item.item_code, + + if item.meta.get_field("expense_account") and not item.cost_center: + msgprint(_("""Cost Center is mandatory for item: """) + item.item_code, raise_exception=1) - - def get_sl_entries(self, d, args): + + def get_sl_entries(self, d, args): sl_dict = { "item_code": d.item_code, - "warehouse": d.warehouse, - "posting_date": self.doc.posting_date, - "posting_time": self.doc.posting_time, - "voucher_type": self.doc.doctype, - "voucher_no": self.doc.name, + "warehouse": d.get("warehouse", None), + "posting_date": self.posting_date, + "posting_time": self.posting_time, + "voucher_type": self.doctype, + "voucher_no": self.name, "voucher_detail_no": d.name, - "actual_qty": (self.doc.docstatus==1 and 1 or -1)*flt(d.stock_qty), + "actual_qty": (self.docstatus==1 and 1 or -1)*flt(d.get("stock_qty")), "stock_uom": d.stock_uom, "incoming_rate": 0, - "company": self.doc.company, - "fiscal_year": self.doc.fiscal_year, + "company": self.company, + "fiscal_year": self.fiscal_year, "batch_no": cstr(d.batch_no).strip(), "serial_no": d.serial_no, - "project": d.project_name, - "is_cancelled": self.doc.docstatus==2 and "Yes" or "No" + "project": d.get("project_name"), + "is_cancelled": self.docstatus==2 and "Yes" or "No" } - + sl_dict.update(args) return sl_dict - + def make_sl_entries(self, sl_entries, is_amended=None): from erpnext.stock.stock_ledger import make_sl_entries make_sl_entries(sl_entries, is_amended) - + def make_cancel_gl_entries(self): - if frappe.db.sql("""select name from `tabGL Entry` where voucher_type=%s - and voucher_no=%s""", (self.doc.doctype, self.doc.name)): + if frappe.db.sql("""select name from `tabGL Entry` where voucher_type=%s + and voucher_no=%s""", (self.doctype, self.name)): self.make_gl_entries() - + def update_gl_entries_after(posting_date, posting_time, warehouse_account=None, for_items=None): def _delete_gl_entries(voucher_type, voucher_no): - frappe.db.sql("""delete from `tabGL Entry` + frappe.db.sql("""delete from `tabGL Entry` where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no)) - + if not warehouse_account: warehouse_account = get_warehouse_account() - future_stock_vouchers = get_future_stock_vouchers(posting_date, posting_time, + future_stock_vouchers = get_future_stock_vouchers(posting_date, posting_time, warehouse_account, for_items) gle = get_voucherwise_gl_entries(future_stock_vouchers, posting_date) for voucher_type, voucher_no in future_stock_vouchers: existing_gle = gle.get((voucher_type, voucher_no), []) - voucher_obj = frappe.get_obj(voucher_type, voucher_no) + voucher_obj = frappe.get_doc(voucher_type, voucher_no) expected_gle = voucher_obj.get_gl_entries(warehouse_account) if expected_gle: - if not existing_gle or not compare_existing_and_expected_gle(existing_gle, + if not existing_gle or not compare_existing_and_expected_gle(existing_gle, expected_gle): _delete_gl_entries(voucher_type, voucher_no) voucher_obj.make_gl_entries(repost_future_gle=False) else: _delete_gl_entries(voucher_type, voucher_no) - + def compare_existing_and_expected_gle(existing_gle, expected_gle): matched = True for entry in expected_gle: @@ -299,36 +306,36 @@ def compare_existing_and_expected_gle(existing_gle, expected_gle): def get_future_stock_vouchers(posting_date, posting_time, warehouse_account=None, for_items=None): future_stock_vouchers = [] - + condition = "" if for_items: condition = ''.join([' and item_code in (\'', '\', \''.join(for_items) ,'\')']) - + if warehouse_account: condition += ''.join([' and warehouse in (\'', '\', \''.join(warehouse_account.keys()) ,'\')']) - - for d in frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no + + for d in frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no from `tabStock Ledger Entry` sle where timestamp(sle.posting_date, sle.posting_time) >= timestamp(%s, %s) %s - order by timestamp(sle.posting_date, sle.posting_time) asc, name asc""" % - ('%s', '%s', condition), (posting_date, posting_time), + order by timestamp(sle.posting_date, sle.posting_time) asc, name asc""" % + ('%s', '%s', condition), (posting_date, posting_time), as_dict=True): future_stock_vouchers.append([d.voucher_type, d.voucher_no]) - + return future_stock_vouchers - + def get_voucherwise_gl_entries(future_stock_vouchers, posting_date): gl_entries = {} if future_stock_vouchers: - for d in frappe.db.sql("""select * from `tabGL Entry` - where posting_date >= %s and voucher_no in (%s)""" % - ('%s', ', '.join(['%s']*len(future_stock_vouchers))), + for d in frappe.db.sql("""select * from `tabGL Entry` + where posting_date >= %s and voucher_no in (%s)""" % + ('%s', ', '.join(['%s']*len(future_stock_vouchers))), tuple([posting_date] + [d[1] for d in future_stock_vouchers]), as_dict=1): gl_entries.setdefault((d.voucher_type, d.voucher_no), []).append(d) - + return gl_entries def get_warehouse_account(): - warehouse_account = dict(frappe.db.sql("""select master_name, name from tabAccount + warehouse_account = dict(frappe.db.sql("""select master_name, name from tabAccount where account_type = 'Warehouse' and ifnull(master_name, '') != ''""")) - return warehouse_account \ No newline at end of file + return warehouse_account diff --git a/erpnext/home/__init__.py b/erpnext/home/__init__.py index 2aae0b0b0c0..15c98190da6 100644 --- a/erpnext/home/__init__.py +++ b/erpnext/home/__init__.py @@ -1,16 +1,16 @@ # ERPNext - web based ERP (http://erpnext.com) # Copyright (C) 2012 Web Notes Technologies Pvt Ltd -# +# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program. If not, see . @@ -20,37 +20,37 @@ from frappe import msgprint feed_dict = { # Project - 'Project': ['[%(status)s]', '#000080'], - 'Task': ['[%(status)s] %(subject)s', '#000080'], + 'Project': ['[%(status)s]', '#000080'], + 'Task': ['[%(status)s] %(subject)s', '#000080'], # Sales - 'Lead': ['%(lead_name)s', '#000080'], - 'Quotation': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'], - 'Sales Order': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'], + 'Lead': ['%(lead_name)s', '#000080'], + 'Quotation': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'], + 'Sales Order': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'], # Purchase - 'Supplier': ['%(supplier_name)s, %(supplier_type)s', '#6495ED'], - 'Purchase Order': ['[%(status)s] %(name)s To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'], + 'Supplier': ['%(supplier_name)s, %(supplier_type)s', '#6495ED'], + 'Purchase Order': ['[%(status)s] %(name)s To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'], # Stock - 'Delivery Note': ['[%(status)s] To %(customer_name)s', '#4169E1'], + 'Delivery Note': ['[%(status)s] To %(customer_name)s', '#4169E1'], 'Purchase Receipt': ['[%(status)s] From %(supplier)s', '#4169E1'], # Accounts - 'Journal Voucher': ['[%(voucher_type)s] %(name)s', '#4169E1'], - 'Purchase Invoice': ['To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'], - 'Sales Invoice':['To %(customer_name)s for %(currency)s %(grand_total_export)s', '#4169E1'], + 'Journal Voucher': ['[%(voucher_type)s] %(name)s', '#4169E1'], + 'Purchase Invoice': ['To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'], + 'Sales Invoice': ['To %(customer_name)s for %(currency)s %(grand_total_export)s', '#4169E1'], # HR - 'Expense Claim': ['[%(approval_status)s] %(name)s by %(employee_name)s', '#4169E1'], - 'Salary Slip': ['%(employee_name)s for %(month)s %(fiscal_year)s', '#4169E1'], - 'Leave Transaction':['%(leave_type)s for %(employee)s', '#4169E1'], + 'Expense Claim': ['[%(approval_status)s] %(name)s by %(employee_name)s', '#4169E1'], + 'Salary Slip': ['%(employee_name)s for %(month)s %(fiscal_year)s', '#4169E1'], + 'Leave Transaction': ['%(leave_type)s for %(employee)s', '#4169E1'], # Support - 'Customer Issue': ['[%(status)s] %(description)s by %(customer_name)s', '#000080'], - 'Maintenance Visit':['To %(customer_name)s', '#4169E1'], - 'Support Ticket': ["[%(status)s] %(subject)s", '#000080'], - + 'Customer Issue': ['[%(status)s] %(description)s by %(customer_name)s', '#000080'], + 'Maintenance Visit': ['To %(customer_name)s', '#4169E1'], + 'Support Ticket': ["[%(status)s] %(subject)s", '#000080'], + # Website 'Web Page': ['%(title)s', '#000080'], 'Blog': ['%(title)s', '#000080'] @@ -59,20 +59,19 @@ feed_dict = { def make_feed(feedtype, doctype, name, owner, subject, color): "makes a new Feed record" #msgprint(subject) - from frappe.model.doc import Document from frappe.utils import get_fullname if feedtype in ('Login', 'Comment', 'Assignment'): # delete old login, comment feed - frappe.db.sql("""delete from tabFeed where + frappe.db.sql("""delete from tabFeed where datediff(curdate(), creation) > 7 and doc_type in ('Comment', 'Login', 'Assignment')""") else: # one feed per item frappe.db.sql("""delete from tabFeed - where doc_type=%s and doc_name=%s + where doc_type=%s and doc_name=%s and ifnull(feed_type,'') != 'Comment'""", (doctype, name)) - f = Document('Feed') + f = frappe.new_doc('Feed') f.owner = owner f.feed_type = feedtype f.doc_type = doctype @@ -80,18 +79,17 @@ def make_feed(feedtype, doctype, name, owner, subject, color): f.subject = subject f.color = color f.full_name = get_fullname(owner) - f.save() + f.save(ignore_permissions=True) -def update_feed(bean, method=None): +def update_feed(doc, method=None): "adds a new feed" - doc = bean.doc if method in ['on_update', 'on_submit']: subject, color = feed_dict.get(doc.doctype, [None, None]) if subject: - make_feed('', doc.doctype, doc.name, doc.owner, subject % doc.fields, color) + make_feed('', doc.doctype, doc.name, doc.owner, subject % doc.as_dict(), color) -def make_comment_feed(bean, method): +def make_comment_feed(doc, method): """add comment to feed""" - doc = bean.doc make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by, - '"' + doc.comment + '"', '#6B24B3') \ No newline at end of file + '"' + doc.comment + '"', '#6B24B3') + diff --git a/erpnext/home/doctype/feed/feed.json b/erpnext/home/doctype/feed/feed.json new file mode 100644 index 00000000000..755b8b83c74 --- /dev/null +++ b/erpnext/home/doctype/feed/feed.json @@ -0,0 +1,61 @@ +{ + "autoname": "hash", + "creation": "2012-07-03 13:29:42.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "feed_type", + "fieldtype": "Select", + "label": "Feed Type", + "permlevel": 0 + }, + { + "fieldname": "doc_type", + "fieldtype": "Data", + "label": "Doc Type", + "permlevel": 0 + }, + { + "fieldname": "doc_name", + "fieldtype": "Data", + "label": "Doc Name", + "permlevel": 0 + }, + { + "fieldname": "subject", + "fieldtype": "Data", + "label": "Subject", + "permlevel": 0 + }, + { + "fieldname": "color", + "fieldtype": "Data", + "label": "Color", + "permlevel": 0 + }, + { + "fieldname": "full_name", + "fieldtype": "Data", + "label": "Full Name", + "permlevel": 0 + } + ], + "icon": "icon-rss", + "idx": 1, + "modified": "2013-12-20 19:24:05.000000", + "modified_by": "Administrator", + "module": "Home", + "name": "Feed", + "owner": "Administrator", + "permissions": [ + { + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager" + } + ] +} diff --git a/erpnext/home/doctype/feed/feed.py b/erpnext/home/doctype/feed/feed.py index 0a12d26f8a6..45d8ea1ac40 100644 --- a/erpnext/home/doctype/feed/feed.py +++ b/erpnext/home/doctype/feed/feed.py @@ -4,15 +4,10 @@ from __future__ import unicode_literals import frappe -from frappe.model import db_exists -from frappe.model.bean import copy_doclist +from frappe.model.document import Document - - - -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d, dl +class Feed(Document): + pass def on_doctype_update(): if not frappe.db.sql("""show index from `tabFeed` diff --git a/erpnext/home/doctype/feed/feed.txt b/erpnext/home/doctype/feed/feed.txt deleted file mode 100644 index 8821b7d36fd..00000000000 --- a/erpnext/home/doctype/feed/feed.txt +++ /dev/null @@ -1,80 +0,0 @@ -[ - { - "creation": "2012-07-03 13:29:42", - "docstatus": 0, - "modified": "2013-12-20 19:24:07", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "_FEED.#####", - "doctype": "DocType", - "icon": "icon-rss", - "module": "Home", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Feed", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Feed", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager" - }, - { - "doctype": "DocType", - "name": "Feed" - }, - { - "doctype": "DocField", - "fieldname": "feed_type", - "fieldtype": "Select", - "label": "Feed Type" - }, - { - "doctype": "DocField", - "fieldname": "doc_type", - "fieldtype": "Data", - "label": "Doc Type" - }, - { - "doctype": "DocField", - "fieldname": "doc_name", - "fieldtype": "Data", - "label": "Doc Name" - }, - { - "doctype": "DocField", - "fieldname": "subject", - "fieldtype": "Data", - "label": "Subject" - }, - { - "doctype": "DocField", - "fieldname": "color", - "fieldtype": "Data", - "label": "Color" - }, - { - "doctype": "DocField", - "fieldname": "full_name", - "fieldtype": "Data", - "label": "Full Name" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/home/page/activity/activity.json b/erpnext/home/page/activity/activity.json new file mode 100644 index 00000000000..a65057e7782 --- /dev/null +++ b/erpnext/home/page/activity/activity.json @@ -0,0 +1,20 @@ +{ + "creation": "2013-04-09 11:45:31.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-play", + "idx": 1, + "modified": "2013-07-11 14:40:20.000000", + "modified_by": "Administrator", + "module": "Home", + "name": "activity", + "owner": "Administrator", + "page_name": "activity", + "roles": [ + { + "role": "All" + } + ], + "standard": "Yes", + "title": "Activity" +} \ No newline at end of file diff --git a/erpnext/home/page/activity/activity.py b/erpnext/home/page/activity/activity.py index 8fab54a4b90..aeb73894908 100644 --- a/erpnext/home/page/activity/activity.py +++ b/erpnext/home/page/activity/activity.py @@ -3,10 +3,11 @@ from __future__ import unicode_literals import frappe +from frappe.utils import cint @frappe.whitelist() def get_feed(arg=None): - """get feed""" + """get feed""" roles = frappe.get_roles() return frappe.db.sql("""select distinct t1.name, t1.feed_type, t1.doc_type, t1.doc_name, t1.subject, t1.owner, @@ -17,6 +18,6 @@ def get_feed(arg=None): and t2.permlevel = 0 and ifnull(t2.`read`,0) = 1 order by t1.modified desc - limit %s, %s""" % (','.join(['%s']*len(roles)), '%s', '%s'), - tuple(roles + [frappe.form_dict['limit_start'], frappe.form_dict['limit_page_length']]), - as_dict=1) \ No newline at end of file + limit %s, %s""" % (','.join(['%s']*len(roles)), '%s', '%s'), + tuple(roles + [cint(frappe.form_dict['limit_start']), cint(frappe.form_dict['limit_page_length'])]), + as_dict=1) diff --git a/erpnext/home/page/activity/activity.txt b/erpnext/home/page/activity/activity.txt deleted file mode 100644 index 7c9783dbea5..00000000000 --- a/erpnext/home/page/activity/activity.txt +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "creation": "2013-04-09 11:45:31", - "docstatus": 0, - "modified": "2013-07-11 14:40:20", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-play", - "module": "Home", - "name": "__common__", - "page_name": "activity", - "standard": "Yes", - "title": "Activity" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "activity", - "parentfield": "roles", - "parenttype": "Page", - "role": "All" - }, - { - "doctype": "Page", - "name": "activity" - }, - { - "doctype": "Page Role" - } -] \ No newline at end of file diff --git a/erpnext/hooks.txt b/erpnext/hooks.txt index f07def6692f..d84b369fef0 100644 --- a/erpnext/hooks.txt +++ b/erpnext/hooks.txt @@ -25,12 +25,12 @@ on_session_creation = erpnext.startup.event_handlers.on_session_creation # Bean Events # ------------------------- -bean_event:*:on_update = erpnext.home.update_feed -bean_event:*:on_submit = erpnext.home.update_feed -bean_event:Comment:on_update = erpnext.home.make_comment_feed +doc_event:*:on_update = erpnext.home.update_feed +doc_event:*:on_submit = erpnext.home.update_feed +doc_event:Comment:on_update = erpnext.home.make_comment_feed -bean_event:Stock Entry:on_submit = erpnext.stock.doctype.material_request.material_request.update_completed_qty -bean_event:Stock Entry:on_cancel = erpnext.stock.doctype.material_request.material_request.update_completed_qty +doc_event:Stock Entry:on_submit = erpnext.stock.doctype.material_request.material_request.update_completed_qty +doc_event:Stock Entry:on_cancel = erpnext.stock.doctype.material_request.material_request.update_completed_qty standard_queries = Customer:erpnext.selling.doctype.customer.customer.get_customer_list diff --git a/erpnext/hr/doctype/appraisal/appraisal.js b/erpnext/hr/doctype/appraisal/appraisal.js index 5bcb96d82c3..a87607c03f2 100644 --- a/erpnext/hr/doctype/appraisal/appraisal.js +++ b/erpnext/hr/doctype/appraisal/appraisal.js @@ -32,7 +32,7 @@ cur_frm.cscript.kra_template = function(doc, dt, dn) { cur_frm.cscript.calculate_total_score = function(doc,cdt,cdn){ //return get_server_fields('calculate_total','','',doc,cdt,cdn,1); - var val = getchildren('Appraisal Goal', doc.name, 'appraisal_details', doc.doctype); + var val = doc.appraisal_details || []; var total =0; for(var i = 0; i getdate(self.doc.end_date): - msgprint("End Date can not be less than Start Date") - raise Exception + if getdate(self.start_date) > getdate(self.end_date): + frappe.throw(_("End Date can not be less than Start Date")) def validate_existing_appraisal(self): chk = frappe.db.sql("""select name from `tabAppraisal` where employee=%s and (status='Submitted' or status='Completed') and ((start_date>=%s and start_date<=%s) - or (end_date>=%s and end_date<=%s))""",(self.doc.employee,self.doc.start_date,self.doc.end_date,self.doc.start_date,self.doc.end_date)) + or (end_date>=%s and end_date<=%s))""", + (self.employee,self.start_date,self.end_date,self.start_date,self.end_date)) if chk: - msgprint("You have already created Appraisal "\ + frappe.throw("You have already created Appraisal "\ +cstr(chk[0][0])+" in the current date range for employee "\ - +cstr(self.doc.employee_name)) - raise Exception + +cstr(self.employee_name)) def calculate_total(self): total, total_w = 0, 0 - for d in getlist(self.doclist, 'appraisal_details'): + for d in self.get('appraisal_details'): if d.score: d.score_earned = flt(d.score) * flt(d.per_weightage) / 100 total = total + d.score_earned @@ -55,29 +50,27 @@ class DocType: msgprint("Total weightage assigned should be 100%. It is :" + str(total_w) + "%", raise_exception=1) - if frappe.db.get_value("Employee", self.doc.employee, "user_id") != \ + if frappe.db.get_value("Employee", self.employee, "user_id") != \ frappe.session.user and total == 0: msgprint("Total can't be zero. You must atleast give some points!", raise_exception=1) - self.doc.total_score = total + self.total_score = total def on_submit(self): - frappe.db.set(self.doc, 'status', 'Submitted') + frappe.db.set(self, 'status', 'Submitted') def on_cancel(self): - frappe.db.set(self.doc, 'status', 'Cancelled') + frappe.db.set(self, 'status', 'Cancelled') @frappe.whitelist() -def fetch_appraisal_template(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist - - doclist = get_mapped_doclist("Appraisal Template", source_name, { +def fetch_appraisal_template(source_name, target_doc=None): + target_doc = get_mapped_doc("Appraisal Template", source_name, { "Appraisal Template": { "doctype": "Appraisal", }, "Appraisal Template Goal": { "doctype": "Appraisal Goal", } - }, target_doclist) + }, target_doc) - return [d.fields for d in doclist] \ No newline at end of file + return target_doc \ No newline at end of file diff --git a/erpnext/hr/doctype/appraisal/appraisal.txt b/erpnext/hr/doctype/appraisal/appraisal.txt deleted file mode 100644 index da57097b525..00000000000 --- a/erpnext/hr/doctype/appraisal/appraisal.txt +++ /dev/null @@ -1,256 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:12", - "docstatus": 0, - "modified": "2014-01-22 16:05:34", - "modified_by": "Administrator", - "owner": "ashwini@webnotestech.com" - }, - { - "autoname": "APRSL.#####", - "doctype": "DocType", - "icon": "icon-thumbs-up", - "is_submittable": 1, - "module": "HR", - "name": "__common__", - "search_fields": "status, employee, employee_name" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Appraisal", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Appraisal", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Appraisal" - }, - { - "doctype": "DocField", - "fieldname": "employee_details", - "fieldtype": "Section Break", - "label": "Employee Details", - "oldfieldtype": "Section Break" - }, - { - "description": "Select template from which you want to get the Goals", - "doctype": "DocField", - "fieldname": "kra_template", - "fieldtype": "Link", - "label": "Appraisal Template", - "oldfieldname": "kra_template", - "oldfieldtype": "Link", - "options": "Appraisal Template", - "reqd": 1 - }, - { - "depends_on": "kra_template", - "description": "Select the Employee for whom you are creating the Appraisal.", - "doctype": "DocField", - "fieldname": "employee", - "fieldtype": "Link", - "in_filter": 1, - "label": "For Employee", - "oldfieldname": "employee", - "oldfieldtype": "Link", - "options": "Employee", - "reqd": 1, - "search_index": 1 - }, - { - "depends_on": "kra_template", - "doctype": "DocField", - "fieldname": "employee_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "For Employee Name", - "oldfieldname": "employee_name", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "depends_on": "kra_template", - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "default": "Draft", - "depends_on": "kra_template", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nDraft\nSubmitted\nCompleted\nCancelled", - "read_only": 1, - "reqd": 1, - "search_index": 1 - }, - { - "depends_on": "kra_template", - "doctype": "DocField", - "fieldname": "start_date", - "fieldtype": "Date", - "in_filter": 1, - "in_list_view": 1, - "label": "Start Date", - "oldfieldname": "start_date", - "oldfieldtype": "Date", - "reqd": 1 - }, - { - "depends_on": "kra_template", - "doctype": "DocField", - "fieldname": "end_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "End Date", - "oldfieldname": "end_date", - "oldfieldtype": "Date", - "reqd": 1 - }, - { - "depends_on": "kra_template", - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "label": "Goals", - "oldfieldtype": "Section Break", - "options": "Simple" - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "appraisal_details", - "fieldtype": "Table", - "label": "Appraisal Goals", - "oldfieldname": "appraisal_details", - "oldfieldtype": "Table", - "options": "Appraisal Goal" - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "calculate_total_score", - "fieldtype": "Button", - "label": "Calculate Total Score", - "oldfieldtype": "Button", - "options": "calculate_total" - }, - { - "doctype": "DocField", - "fieldname": "total_score", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Total Score (Out of 5)", - "no_copy": 1, - "oldfieldname": "total_score", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "depends_on": "kra_template", - "doctype": "DocField", - "fieldname": "section_break1", - "fieldtype": "Section Break" - }, - { - "description": "Any other comments, noteworthy effort that should go in the records.", - "doctype": "DocField", - "fieldname": "comments", - "fieldtype": "Text", - "label": "Comments" - }, - { - "depends_on": "kra_template", - "doctype": "DocField", - "fieldname": "other_details", - "fieldtype": "Section Break", - "label": "Other Details" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "link:Company", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "hidden": 1, - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "report_hide": 1, - "width": "150px" - }, - { - "cancel": 0, - "delete": 0, - "doctype": "DocPerm", - "restricted": 1, - "role": "Employee", - "submit": 0 - }, - { - "amend": 1, - "cancel": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "System Manager", - "submit": 1 - }, - { - "amend": 1, - "cancel": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "HR User", - "submit": 1 - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/appraisal_goal/appraisal_goal.json b/erpnext/hr/doctype/appraisal_goal/appraisal_goal.json new file mode 100644 index 00000000000..a40b2bc57e9 --- /dev/null +++ b/erpnext/hr/doctype/appraisal_goal/appraisal_goal.json @@ -0,0 +1,67 @@ +{ + "autoname": "APRSLD.#####", + "creation": "2013-02-22 01:27:44.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Key Responsibility Area", + "fieldname": "kra", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Goal", + "oldfieldname": "kra", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "240px", + "reqd": 1, + "width": "240px" + }, + { + "fieldname": "per_weightage", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Weightage (%)", + "oldfieldname": "per_weightage", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "70px", + "reqd": 1, + "width": "70px" + }, + { + "allow_on_submit": 1, + "fieldname": "score", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Score (0-5)", + "no_copy": 1, + "oldfieldname": "score", + "oldfieldtype": "Select", + "options": "\n0\n1\n2\n3\n4\n5", + "permlevel": 0, + "print_width": "70px", + "width": "70px" + }, + { + "fieldname": "score_earned", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Score Earned", + "no_copy": 1, + "oldfieldname": "score_earned", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "70px", + "read_only": 1, + "width": "70px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:22:53.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Appraisal Goal", + "owner": "ashwini@webnotestech.com" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py b/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py index 26c87f1c04a..c13c42bd034 100644 --- a/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py +++ b/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class AppraisalGoal(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/appraisal_goal/appraisal_goal.txt b/erpnext/hr/doctype/appraisal_goal/appraisal_goal.txt deleted file mode 100644 index 5c15ac6edcf..00000000000 --- a/erpnext/hr/doctype/appraisal_goal/appraisal_goal.txt +++ /dev/null @@ -1,77 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:44", - "docstatus": 0, - "modified": "2013-12-20 19:22:53", - "modified_by": "Administrator", - "owner": "ashwini@webnotestech.com" - }, - { - "autoname": "APRSLD.#####", - "doctype": "DocType", - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Appraisal Goal", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Appraisal Goal" - }, - { - "description": "Key Responsibility Area", - "doctype": "DocField", - "fieldname": "kra", - "fieldtype": "Small Text", - "label": "Goal", - "oldfieldname": "kra", - "oldfieldtype": "Small Text", - "print_width": "240px", - "reqd": 1, - "width": "240px" - }, - { - "doctype": "DocField", - "fieldname": "per_weightage", - "fieldtype": "Float", - "label": "Weightage (%)", - "oldfieldname": "per_weightage", - "oldfieldtype": "Currency", - "print_width": "70px", - "reqd": 1, - "width": "70px" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "score", - "fieldtype": "Float", - "label": "Score (0-5)", - "no_copy": 1, - "oldfieldname": "score", - "oldfieldtype": "Select", - "options": "\n0\n1\n2\n3\n4\n5", - "print_width": "70px", - "width": "70px" - }, - { - "doctype": "DocField", - "fieldname": "score_earned", - "fieldtype": "Float", - "label": "Score Earned", - "no_copy": 1, - "oldfieldname": "score_earned", - "oldfieldtype": "Currency", - "print_width": "70px", - "read_only": 1, - "width": "70px" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/appraisal_template/appraisal_template.json b/erpnext/hr/doctype/appraisal_template/appraisal_template.json new file mode 100644 index 00000000000..1ef6307be81 --- /dev/null +++ b/erpnext/hr/doctype/appraisal_template/appraisal_template.json @@ -0,0 +1,63 @@ +{ + "allow_import": 1, + "autoname": "field:kra_title", + "creation": "2012-07-03 13:30:39.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "kra_title", + "fieldtype": "Data", + "label": "Appraisal Template Title", + "oldfieldname": "kra_title", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "width": "300px" + }, + { + "fieldname": "kra_sheet", + "fieldtype": "Table", + "label": "Appraisal Template Goal", + "oldfieldname": "kra_sheet", + "oldfieldtype": "Table", + "options": "Appraisal Template Goal", + "permlevel": 0 + }, + { + "fieldname": "total_points", + "fieldtype": "Int", + "label": "Total Points", + "permlevel": 0 + } + ], + "icon": "icon-file-text", + "idx": 1, + "modified": "2013-12-20 19:23:55.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Appraisal Template", + "owner": "ashwini@webnotestech.com", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/appraisal_template/appraisal_template.py b/erpnext/hr/doctype/appraisal_template/appraisal_template.py index 0f78a4a76a5..930d509a7aa 100644 --- a/erpnext/hr/doctype/appraisal_template/appraisal_template.py +++ b/erpnext/hr/doctype/appraisal_template/appraisal_template.py @@ -5,16 +5,15 @@ from __future__ import unicode_literals import frappe from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - +from frappe.model.document import Document + +class AppraisalTemplate(Document): def validate(self): - self.doc.total_points = 0 - for d in self.doclist.get({"doctype":"Appraisal Template Goal"}): - self.doc.total_points += int(d.per_weightage or 0) + self.total_points = 0 + for d in self.get("kra_sheet"): + self.total_points += int(d.per_weightage or 0) - if int(self.doc.total_points) != 100: + if int(self.total_points) != 100: frappe.msgprint(_("Total (sum of) points distribution for all goals should be 100.") \ - + " " + _("Not") + " " + str(self.doc.total_points), + + " " + _("Not") + " " + str(self.total_points), raise_exception=True) \ No newline at end of file diff --git a/erpnext/hr/doctype/appraisal_template/appraisal_template.txt b/erpnext/hr/doctype/appraisal_template/appraisal_template.txt deleted file mode 100644 index ff887c449aa..00000000000 --- a/erpnext/hr/doctype/appraisal_template/appraisal_template.txt +++ /dev/null @@ -1,82 +0,0 @@ -[ - { - "creation": "2012-07-03 13:30:39", - "docstatus": 0, - "modified": "2013-12-20 19:23:55", - "modified_by": "Administrator", - "owner": "ashwini@webnotestech.com" - }, - { - "allow_import": 1, - "autoname": "field:kra_title", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-file-text", - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Appraisal Template", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Appraisal Template", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "HR User", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Appraisal Template" - }, - { - "doctype": "DocField", - "fieldname": "kra_title", - "fieldtype": "Data", - "label": "Appraisal Template Title", - "oldfieldname": "kra_title", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "print_width": "300px", - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "kra_sheet", - "fieldtype": "Table", - "label": "Appraisal Template Goal", - "oldfieldname": "kra_sheet", - "oldfieldtype": "Table", - "options": "Appraisal Template Goal" - }, - { - "doctype": "DocField", - "fieldname": "total_points", - "fieldtype": "Int", - "label": "Total Points" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.json b/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.json new file mode 100644 index 00000000000..f23ec8c00fa --- /dev/null +++ b/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.json @@ -0,0 +1,40 @@ +{ + "autoname": "KSHEET.#####", + "creation": "2013-02-22 01:27:44.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Key Performance Area", + "fieldname": "kra", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "KRA", + "oldfieldname": "kra", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "200px", + "reqd": 1, + "width": "200px" + }, + { + "fieldname": "per_weightage", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Weightage (%)", + "oldfieldname": "per_weightage", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "100px", + "reqd": 1, + "width": "100px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:22:54.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Appraisal Template Goal", + "owner": "ashwini@webnotestech.com" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py b/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py index 26c87f1c04a..0cdd921e059 100644 --- a/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py +++ b/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class AppraisalTemplateGoal(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.txt b/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.txt deleted file mode 100644 index 0657f64e1c0..00000000000 --- a/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.txt +++ /dev/null @@ -1,51 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:44", - "docstatus": 0, - "modified": "2013-12-20 19:22:54", - "modified_by": "Administrator", - "owner": "ashwini@webnotestech.com" - }, - { - "autoname": "KSHEET.#####", - "doctype": "DocType", - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Appraisal Template Goal", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocType", - "name": "Appraisal Template Goal" - }, - { - "description": "Key Performance Area", - "doctype": "DocField", - "fieldname": "kra", - "fieldtype": "Small Text", - "label": "KRA", - "oldfieldname": "kra", - "oldfieldtype": "Small Text", - "print_width": "200px", - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "per_weightage", - "fieldtype": "Float", - "label": "Weightage (%)", - "oldfieldname": "per_weightage", - "oldfieldtype": "Currency", - "print_width": "100px", - "width": "100px" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/attendance/attendance.json b/erpnext/hr/doctype/attendance/attendance.json new file mode 100644 index 00000000000..101f618e1f6 --- /dev/null +++ b/erpnext/hr/doctype/attendance/attendance.json @@ -0,0 +1,179 @@ +{ + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-01-10 16:34:13.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "attendance_details", + "fieldtype": "Section Break", + "label": "Attendance Details", + "oldfieldtype": "Section Break", + "options": "Simple", + "permlevel": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "ATT", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "employee", + "fieldtype": "Link", + "in_filter": 1, + "label": "Employee", + "oldfieldname": "employee", + "oldfieldtype": "Link", + "options": "Employee", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "employee_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Employee Name", + "oldfieldname": "employee_name", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "default": "Present", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nPresent\nAbsent\nHalf Day", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "leave_type", + "fieldtype": "Link", + "hidden": 1, + "in_list_view": 1, + "label": "Leave Type", + "oldfieldname": "leave_type", + "oldfieldtype": "Link", + "options": "Leave Type", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "att_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Attendance Date", + "oldfieldname": "att_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "company", + "fieldtype": "Select", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "link:Company", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "options": "Attendance", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "icon": "icon-ok", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:48:23.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Attendance", + "owner": "ashwini@webnotestech.com", + "permissions": [ + { + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "submit": 1, + "write": 1 + }, + { + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 1, + "write": 1 + }, + { + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR Manager", + "submit": 1, + "write": 1 + } + ], + "search_fields": "employee, employee_name, att_date, status" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/attendance/attendance.py b/erpnext/hr/doctype/attendance/attendance.py index 9abef7677e9..8c1c3f0a4e7 100644 --- a/erpnext/hr/doctype/attendance/attendance.py +++ b/erpnext/hr/doctype/attendance/attendance.py @@ -6,50 +6,46 @@ import frappe from frappe.utils import getdate, nowdate from frappe import msgprint, _ +from frappe.model.document import Document - -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - +class Attendance(Document): def validate_duplicate_record(self): res = frappe.db.sql("""select name from `tabAttendance` where employee = %s and att_date = %s and name != %s and docstatus = 1""", - (self.doc.employee, self.doc.att_date, self.doc.name)) + (self.employee, self.att_date, self.name)) if res: - msgprint(_("Attendance for the employee: ") + self.doc.employee + + msgprint(_("Attendance for the employee: ") + self.employee + _(" already marked"), raise_exception=1) def check_leave_record(self): - if self.doc.status == 'Present': + if self.status == 'Present': leave = frappe.db.sql("""select name from `tabLeave Application` where employee = %s and %s between from_date and to_date and status = 'Approved' - and docstatus = 1""", (self.doc.employee, self.doc.att_date)) + and docstatus = 1""", (self.employee, self.att_date)) if leave: - frappe.msgprint(_("Employee: ") + self.doc.employee + _(" was on leave on ") - + self.doc.att_date + _(". You can not mark his attendance as 'Present'"), + frappe.msgprint(_("Employee: ") + self.employee + _(" was on leave on ") + + self.att_date + _(". You can not mark his attendance as 'Present'"), raise_exception=1) def validate_fiscal_year(self): from erpnext.accounts.utils import validate_fiscal_year - validate_fiscal_year(self.doc.att_date, self.doc.fiscal_year) + validate_fiscal_year(self.att_date, self.fiscal_year) def validate_att_date(self): - if getdate(self.doc.att_date) > getdate(nowdate()): + if getdate(self.att_date) > getdate(nowdate()): msgprint(_("Attendance can not be marked for future dates"), raise_exception=1) def validate_employee(self): emp = frappe.db.sql("select name from `tabEmployee` where name = %s and status = 'Active'", - self.doc.employee) + self.employee) if not emp: - msgprint(_("Employee: ") + self.doc.employee + + msgprint(_("Employee: ") + self.employee + _(" not active or does not exists in the system"), raise_exception=1) def validate(self): from erpnext.utilities import validate_status - validate_status(self.doc.status, ["Present", "Absent", "Half Day"]) + validate_status(self.status, ["Present", "Absent", "Half Day"]) self.validate_fiscal_year() self.validate_att_date() self.validate_duplicate_record() @@ -58,5 +54,5 @@ class DocType: def on_update(self): # this is done because sometimes user entered wrong employee name # while uploading employee attendance - employee_name = frappe.db.get_value("Employee", self.doc.employee, "employee_name") - frappe.db.set(self.doc, 'employee_name', employee_name) \ No newline at end of file + employee_name = frappe.db.get_value("Employee", self.employee, "employee_name") + frappe.db.set(self, 'employee_name', employee_name) \ No newline at end of file diff --git a/erpnext/hr/doctype/attendance/attendance.txt b/erpnext/hr/doctype/attendance/attendance.txt deleted file mode 100644 index 894e981860a..00000000000 --- a/erpnext/hr/doctype/attendance/attendance.txt +++ /dev/null @@ -1,180 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:13", - "docstatus": 0, - "modified": "2014-01-20 17:48:23", - "modified_by": "Administrator", - "owner": "ashwini@webnotestech.com" - }, - { - "allow_import": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-ok", - "is_submittable": 1, - "module": "HR", - "name": "__common__", - "search_fields": "employee, employee_name, att_date, status" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Attendance", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Attendance", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Attendance" - }, - { - "doctype": "DocField", - "fieldname": "attendance_details", - "fieldtype": "Section Break", - "label": "Attendance Details", - "oldfieldtype": "Section Break", - "options": "Simple" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "ATT", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "employee", - "fieldtype": "Link", - "in_filter": 1, - "label": "Employee", - "oldfieldname": "employee", - "oldfieldtype": "Link", - "options": "Employee", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "employee_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Employee Name", - "oldfieldname": "employee_name", - "oldfieldtype": "Data" - }, - { - "default": "Present", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nPresent\nAbsent\nHalf Day", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "leave_type", - "fieldtype": "Link", - "hidden": 1, - "in_list_view": 1, - "label": "Leave Type", - "oldfieldname": "leave_type", - "oldfieldtype": "Link", - "options": "Leave Type", - "print_hide": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "att_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Attendance Date", - "oldfieldname": "att_date", - "oldfieldtype": "Date", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "link:Company", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "options": "Attendance", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocPerm", - "role": "System Manager" - }, - { - "doctype": "DocPerm", - "role": "HR User" - }, - { - "doctype": "DocPerm", - "role": "HR Manager" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/branch/branch.json b/erpnext/hr/doctype/branch/branch.json new file mode 100644 index 00000000000..28bc74ad98a --- /dev/null +++ b/erpnext/hr/doctype/branch/branch.json @@ -0,0 +1,64 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:branch", + "creation": "2013-01-10 16:34:13.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "branch", + "fieldtype": "Data", + "label": "Branch", + "oldfieldname": "branch", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-code-fork", + "idx": 1, + "modified": "2014-01-20 17:48:26.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Branch", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/branch/branch.py b/erpnext/hr/doctype/branch/branch.py index 58ecbe8902b..f5dbe18e472 100644 --- a/erpnext/hr/doctype/branch/branch.py +++ b/erpnext/hr/doctype/branch/branch.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - +from frappe.model.document import Document + +class Branch(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/branch/branch.txt b/erpnext/hr/doctype/branch/branch.txt deleted file mode 100644 index 6ef13e2abbd..00000000000 --- a/erpnext/hr/doctype/branch/branch.txt +++ /dev/null @@ -1,74 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:13", - "docstatus": 0, - "modified": "2014-01-20 17:48:26", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:branch", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-code-fork", - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Branch", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Branch", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Branch" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "branch", - "fieldtype": "Data", - "label": "Branch", - "oldfieldname": "branch", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocPerm", - "role": "HR User" - }, - { - "doctype": "DocPerm", - "role": "HR Manager" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/branch/test_branch.py b/erpnext/hr/doctype/branch/test_branch.py index ec847413263..52f2fe42e7f 100644 --- a/erpnext/hr/doctype/branch/test_branch.py +++ b/erpnext/hr/doctype/branch/test_branch.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{"doctype":"Branch", "branch":"_Test Branch"}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Branch') \ No newline at end of file diff --git a/erpnext/hr/doctype/branch/test_records.json b/erpnext/hr/doctype/branch/test_records.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/erpnext/hr/doctype/branch/test_records.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/erpnext/hr/doctype/deduction_type/deduction_type.json b/erpnext/hr/doctype/deduction_type/deduction_type.json new file mode 100644 index 00000000000..ccfbf037928 --- /dev/null +++ b/erpnext/hr/doctype/deduction_type/deduction_type.json @@ -0,0 +1,60 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:deduction_name", + "creation": "2013-01-22 16:50:30.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "deduction_name", + "fieldtype": "Data", + "label": "Name", + "oldfieldname": "deduction_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "width": "300px" + } + ], + "icon": "icon-flag", + "idx": 1, + "modified": "2014-01-20 17:48:34.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Deduction Type", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/deduction_type/deduction_type.py b/erpnext/hr/doctype/deduction_type/deduction_type.py index 26c87f1c04a..c18f5692bbb 100644 --- a/erpnext/hr/doctype/deduction_type/deduction_type.py +++ b/erpnext/hr/doctype/deduction_type/deduction_type.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class DeductionType(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/deduction_type/deduction_type.txt b/erpnext/hr/doctype/deduction_type/deduction_type.txt deleted file mode 100644 index b70cf35b915..00000000000 --- a/erpnext/hr/doctype/deduction_type/deduction_type.txt +++ /dev/null @@ -1,79 +0,0 @@ -[ - { - "creation": "2013-01-22 16:50:30", - "docstatus": 0, - "modified": "2014-01-20 17:48:34", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:deduction_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-flag", - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Deduction Type", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Deduction Type", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "HR User", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Deduction Type" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "deduction_name", - "fieldtype": "Data", - "label": "Name", - "oldfieldname": "deduction_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "width": "300px" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/deduction_type/test_deduction_type.py b/erpnext/hr/doctype/deduction_type/test_deduction_type.py index ff3db8cbf4b..577edc41a5c 100644 --- a/erpnext/hr/doctype/deduction_type/test_deduction_type.py +++ b/erpnext/hr/doctype/deduction_type/test_deduction_type.py @@ -1,13 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Deduction Type", - "deduction_name": "_Test Professional Tax" - }], - [{ - "doctype": "Deduction Type", - "deduction_name": "_Test TDS" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Deduction Type') \ No newline at end of file diff --git a/erpnext/hr/doctype/deduction_type/test_records.json b/erpnext/hr/doctype/deduction_type/test_records.json new file mode 100644 index 00000000000..25dab0fe160 --- /dev/null +++ b/erpnext/hr/doctype/deduction_type/test_records.json @@ -0,0 +1,10 @@ +[ + { + "doctype": "Deduction Type", + "deduction_name": "_Test Professional Tax" + }, + { + "doctype": "Deduction Type", + "deduction_name": "_Test TDS" + } +] \ No newline at end of file diff --git a/erpnext/hr/doctype/department/department.json b/erpnext/hr/doctype/department/department.json new file mode 100644 index 00000000000..927f56477ed --- /dev/null +++ b/erpnext/hr/doctype/department/department.json @@ -0,0 +1,58 @@ +{ + "allow_import": 1, + "autoname": "field:department_name", + "creation": "2013-02-05 11:48:26.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "department_name", + "fieldtype": "Data", + "label": "Department", + "oldfieldname": "department_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "Days for which Holidays are blocked for this department.", + "fieldname": "leave_block_list", + "fieldtype": "Link", + "label": "Leave Block List", + "options": "Leave Block List", + "permlevel": 0 + } + ], + "icon": "icon-sitemap", + "idx": 1, + "modified": "2014-01-20 17:48:38.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Department", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/department/department.py b/erpnext/hr/doctype/department/department.py index 5015bed79ce..bf154914d7d 100644 --- a/erpnext/hr/doctype/department/department.py +++ b/erpnext/hr/doctype/department/department.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - \ No newline at end of file +from frappe.model.document import Document + +class Department(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/department/department.txt b/erpnext/hr/doctype/department/department.txt deleted file mode 100644 index 269afa758fb..00000000000 --- a/erpnext/hr/doctype/department/department.txt +++ /dev/null @@ -1,77 +0,0 @@ -[ - { - "creation": "2013-02-05 11:48:26", - "docstatus": 0, - "modified": "2014-01-20 17:48:38", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:department_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-sitemap", - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Department", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Department", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "HR User", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Department" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "department_name", - "fieldtype": "Data", - "label": "Department", - "oldfieldname": "department_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "description": "Days for which Holidays are blocked for this department.", - "doctype": "DocField", - "fieldname": "leave_block_list", - "fieldtype": "Link", - "label": "Leave Block List", - "options": "Leave Block List" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/department/test_department.py b/erpnext/hr/doctype/department/test_department.py index 6fa2dce9271..6642bc2bf14 100644 --- a/erpnext/hr/doctype/department/test_department.py +++ b/erpnext/hr/doctype/department/test_department.py @@ -3,7 +3,6 @@ test_ignore = ["Leave Block List"] -test_records = [ - [{"doctype":"Department", "department_name":"_Test Department"}], - [{"doctype":"Department", "department_name":"_Test Department 1"}] -] + +import frappe +test_records = frappe.get_test_records('Department') \ No newline at end of file diff --git a/erpnext/hr/doctype/department/test_records.json b/erpnext/hr/doctype/department/test_records.json new file mode 100644 index 00000000000..5bb5871d4cd --- /dev/null +++ b/erpnext/hr/doctype/department/test_records.json @@ -0,0 +1,4 @@ +[ + {"doctype":"Department", "department_name":"_Test Department"}, + {"doctype":"Department", "department_name":"_Test Department 1"} +] \ No newline at end of file diff --git a/erpnext/hr/doctype/designation/designation.json b/erpnext/hr/doctype/designation/designation.json new file mode 100644 index 00000000000..39a4eee2292 --- /dev/null +++ b/erpnext/hr/doctype/designation/designation.json @@ -0,0 +1,51 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:designation_name", + "creation": "2013-01-10 16:34:13.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "designation_name", + "fieldtype": "Data", + "label": "Designation", + "oldfieldname": "designation_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-bookmark", + "idx": 1, + "modified": "2014-01-20 17:48:38.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Designation", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/designation/designation.py b/erpnext/hr/doctype/designation/designation.py index 58ecbe8902b..fb530478c32 100644 --- a/erpnext/hr/doctype/designation/designation.py +++ b/erpnext/hr/doctype/designation/designation.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - +from frappe.model.document import Document + +class Designation(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/designation/designation.txt b/erpnext/hr/doctype/designation/designation.txt deleted file mode 100644 index e8debd1b2fa..00000000000 --- a/erpnext/hr/doctype/designation/designation.txt +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:13", - "docstatus": 0, - "modified": "2014-01-20 17:48:38", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:designation_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-bookmark", - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Designation", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Designation", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "HR User", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Designation" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "designation_name", - "fieldtype": "Data", - "label": "Designation", - "oldfieldname": "designation_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/designation/test_designation.py b/erpnext/hr/doctype/designation/test_designation.py index 8b28fa54b55..cb327e7d05a 100644 --- a/erpnext/hr/doctype/designation/test_designation.py +++ b/erpnext/hr/doctype/designation/test_designation.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{"doctype":"Designation", "designation_name":"_Test Designation"}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Designation') \ No newline at end of file diff --git a/erpnext/hr/doctype/designation/test_records.json b/erpnext/hr/doctype/designation/test_records.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/erpnext/hr/doctype/designation/test_records.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/erpnext/hr/doctype/earning_type/earning_type.json b/erpnext/hr/doctype/earning_type/earning_type.json new file mode 100644 index 00000000000..f4678b48e82 --- /dev/null +++ b/erpnext/hr/doctype/earning_type/earning_type.json @@ -0,0 +1,81 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:earning_name", + "creation": "2013-01-24 11:03:32.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "earning_name", + "fieldtype": "Data", + "label": "Name", + "oldfieldname": "earning_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "reqd": 0, + "width": "300px" + }, + { + "fieldname": "taxable", + "fieldtype": "Select", + "label": "Taxable", + "oldfieldname": "taxable", + "oldfieldtype": "Select", + "options": "\nYes\nNo", + "permlevel": 0, + "reqd": 1 + }, + { + "depends_on": "eval:doc.taxable=='No'", + "fieldname": "exemption_limit", + "fieldtype": "Float", + "hidden": 0, + "label": "Exemption Limit", + "oldfieldname": "exemption_limit", + "oldfieldtype": "Currency", + "permlevel": 0 + } + ], + "icon": "icon-flag", + "idx": 1, + "modified": "2014-01-20 17:48:38.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Earning Type", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/earning_type/earning_type.py b/erpnext/hr/doctype/earning_type/earning_type.py index 26c87f1c04a..8f7450ef338 100644 --- a/erpnext/hr/doctype/earning_type/earning_type.py +++ b/erpnext/hr/doctype/earning_type/earning_type.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class EarningType(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/earning_type/earning_type.txt b/erpnext/hr/doctype/earning_type/earning_type.txt deleted file mode 100644 index 9d3b90f80f5..00000000000 --- a/erpnext/hr/doctype/earning_type/earning_type.txt +++ /dev/null @@ -1,100 +0,0 @@ -[ - { - "creation": "2013-01-24 11:03:32", - "docstatus": 0, - "modified": "2014-01-20 17:48:38", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:earning_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-flag", - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Earning Type", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Earning Type", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "HR User", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Earning Type" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "earning_name", - "fieldtype": "Data", - "label": "Name", - "oldfieldname": "earning_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "reqd": 0, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "taxable", - "fieldtype": "Select", - "label": "Taxable", - "oldfieldname": "taxable", - "oldfieldtype": "Select", - "options": "\nYes\nNo", - "reqd": 1 - }, - { - "depends_on": "eval:doc.taxable=='No'", - "doctype": "DocField", - "fieldname": "exemption_limit", - "fieldtype": "Float", - "hidden": 0, - "label": "Exemption Limit", - "oldfieldname": "exemption_limit", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/earning_type/test_earning_type.py b/erpnext/hr/doctype/earning_type/test_earning_type.py index 5d838a27e50..7b84af6e2ab 100644 --- a/erpnext/hr/doctype/earning_type/test_earning_type.py +++ b/erpnext/hr/doctype/earning_type/test_earning_type.py @@ -1,15 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Earning Type", - "earning_name": "_Test Basic Salary", - "taxable": "Yes" - }], - [{ - "doctype": "Earning Type", - "earning_name": "_Test Allowance", - "taxable": "Yes" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Earning Type') \ No newline at end of file diff --git a/erpnext/hr/doctype/earning_type/test_records.json b/erpnext/hr/doctype/earning_type/test_records.json new file mode 100644 index 00000000000..659ab520407 --- /dev/null +++ b/erpnext/hr/doctype/earning_type/test_records.json @@ -0,0 +1,12 @@ +[ + { + "doctype": "Earning Type", + "earning_name": "_Test Basic Salary", + "taxable": "Yes" + }, + { + "doctype": "Earning Type", + "earning_name": "_Test Allowance", + "taxable": "Yes" + } +] \ No newline at end of file diff --git a/erpnext/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js index c27a4c56a22..72f540437fc 100644 --- a/erpnext/hr/doctype/employee/employee.js +++ b/erpnext/hr/doctype/employee/employee.js @@ -13,7 +13,7 @@ erpnext.hr.EmployeeController = frappe.ui.form.Controller.extend({ onload: function() { this.setup_leave_approver_select(); this.frm.toggle_display(["esic_card_no", "gratuity_lic_id", "pan_number", "pf_number"], - frappe.control_panel.country==="India"); + frappe.boot.sysdefaults.country==="India"); if(this.frm.doc.__islocal) this.frm.set_value("employee_name", ""); }, @@ -68,7 +68,7 @@ erpnext.hr.EmployeeController = frappe.ui.form.Controller.extend({ Go to the active Salary Structure and set \"Is Active\" = \"No\"")); } else if(!r.exc) { frappe.model.map({ - source: frappe.model.get_doclist(me.frm.doc.doctype, me.frm.doc.name), + source: me.frm.doc, target: "Salary Structure" }); } diff --git a/erpnext/hr/doctype/employee/employee.json b/erpnext/hr/doctype/employee/employee.json new file mode 100644 index 00000000000..e80dabe0215 --- /dev/null +++ b/erpnext/hr/doctype/employee/employee.json @@ -0,0 +1,777 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "allow_rename": 1, + "autoname": "naming_series:", + "creation": "2013-03-07 09:04:18.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "basic_information", + "fieldtype": "Section Break", + "label": "Basic Information", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "image_view", + "fieldtype": "Image", + "in_list_view": 0, + "label": "Image View", + "options": "image", + "permlevel": 0 + }, + { + "fieldname": "employee", + "fieldtype": "Data", + "hidden": 1, + "label": "Employee", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "EMP/", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "salutation", + "fieldtype": "Select", + "label": "Salutation", + "oldfieldname": "salutation", + "oldfieldtype": "Select", + "options": "\nMr\nMs", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "employee_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Full Name", + "oldfieldname": "employee_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "image", + "fieldtype": "Select", + "label": "Image", + "options": "attach_files:", + "permlevel": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "description": "System User (login) ID. If set, it will become default for all HR forms.", + "fieldname": "user_id", + "fieldtype": "Link", + "label": "User ID", + "options": "User", + "permlevel": 0 + }, + { + "fieldname": "employee_number", + "fieldtype": "Data", + "in_filter": 1, + "label": "Employee Number", + "oldfieldname": "employee_number", + "oldfieldtype": "Data", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "date_of_joining", + "fieldtype": "Date", + "label": "Date of Joining", + "oldfieldname": "date_of_joining", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "You can enter any date manually", + "fieldname": "date_of_birth", + "fieldtype": "Date", + "in_filter": 1, + "label": "Date of Birth", + "oldfieldname": "date_of_birth", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "gender", + "fieldtype": "Select", + "in_filter": 1, + "label": "Gender", + "oldfieldname": "gender", + "oldfieldtype": "Select", + "options": "\nMale\nFemale", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "company", + "fieldtype": "Select", + "in_filter": 1, + "label": "Company", + "options": "link:Company", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "fieldname": "employment_details", + "fieldtype": "Section Break", + "label": "Employment Details", + "permlevel": 0 + }, + { + "fieldname": "col_break_21", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": "Active", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Status", + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nActive\nLeft", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "employment_type", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Employment Type", + "oldfieldname": "employment_type", + "oldfieldtype": "Link", + "options": "Employment Type", + "permlevel": 0, + "search_index": 0 + }, + { + "description": "Applicable Holiday List", + "fieldname": "holiday_list", + "fieldtype": "Link", + "label": "Holiday List", + "oldfieldname": "holiday_list", + "oldfieldtype": "Link", + "options": "Holiday List", + "permlevel": 0 + }, + { + "fieldname": "col_break_22", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "scheduled_confirmation_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Offer Date", + "oldfieldname": "scheduled_confirmation_date", + "oldfieldtype": "Date", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "final_confirmation_date", + "fieldtype": "Date", + "label": "Confirmation Date", + "oldfieldname": "final_confirmation_date", + "oldfieldtype": "Date", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "contract_end_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Contract End Date", + "oldfieldname": "contract_end_date", + "oldfieldtype": "Date", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "date_of_retirement", + "fieldtype": "Date", + "label": "Date Of Retirement", + "oldfieldname": "date_of_retirement", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "job_profile", + "fieldtype": "Section Break", + "label": "Job Profile", + "permlevel": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "branch", + "fieldtype": "Link", + "in_filter": 1, + "label": "Branch", + "oldfieldname": "branch", + "oldfieldtype": "Link", + "options": "Branch", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "department", + "fieldtype": "Link", + "in_filter": 1, + "label": "Department", + "oldfieldname": "department", + "oldfieldtype": "Link", + "options": "Department", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "designation", + "fieldtype": "Link", + "in_filter": 1, + "label": "Designation", + "oldfieldname": "designation", + "oldfieldtype": "Link", + "options": "Designation", + "permlevel": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "grade", + "fieldtype": "Link", + "in_filter": 1, + "label": "Grade", + "oldfieldname": "grade", + "oldfieldtype": "Link", + "options": "Grade", + "permlevel": 0, + "reqd": 0 + }, + { + "description": "Provide email id registered in company", + "fieldname": "company_email", + "fieldtype": "Data", + "in_filter": 1, + "label": "Company Email", + "oldfieldname": "company_email", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "notice_number_of_days", + "fieldtype": "Int", + "label": "Notice (days)", + "oldfieldname": "notice_number_of_days", + "oldfieldtype": "Int", + "permlevel": 0 + }, + { + "fieldname": "salary_information", + "fieldtype": "Column Break", + "label": "Salary Information", + "oldfieldtype": "Section Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "salary_mode", + "fieldtype": "Select", + "label": "Salary Mode", + "oldfieldname": "salary_mode", + "oldfieldtype": "Select", + "options": "\nBank\nCash\nCheque", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.salary_mode == 'Bank'", + "fieldname": "bank_name", + "fieldtype": "Data", + "hidden": 0, + "in_filter": 1, + "label": "Bank Name", + "oldfieldname": "bank_name", + "oldfieldtype": "Link", + "options": "Suggest", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.salary_mode == 'Bank'", + "fieldname": "bank_ac_no", + "fieldtype": "Data", + "hidden": 0, + "label": "Bank A/C No.", + "oldfieldname": "bank_ac_no", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "esic_card_no", + "fieldtype": "Data", + "label": "ESIC CARD No", + "oldfieldname": "esic_card_no", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "pf_number", + "fieldtype": "Data", + "label": "PF Number", + "oldfieldname": "pf_number", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "gratuity_lic_id", + "fieldtype": "Data", + "label": "Gratuity LIC ID", + "oldfieldname": "gratuity_lic_id", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "organization_profile", + "fieldtype": "Section Break", + "label": "Organization Profile", + "permlevel": 0 + }, + { + "fieldname": "reports_to", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Reports to", + "oldfieldname": "reports_to", + "oldfieldtype": "Link", + "options": "Employee", + "permlevel": 0 + }, + { + "description": "The first Leave Approver in the list will be set as the default Leave Approver", + "fieldname": "employee_leave_approvers", + "fieldtype": "Table", + "label": "Leave Approvers", + "options": "Employee Leave Approver", + "permlevel": 0 + }, + { + "fieldname": "contact_details", + "fieldtype": "Section Break", + "label": "Contact Details", + "permlevel": 0 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "cell_number", + "fieldtype": "Data", + "label": "Cell Number", + "permlevel": 0 + }, + { + "fieldname": "personal_email", + "fieldtype": "Data", + "label": "Personal Email", + "permlevel": 0 + }, + { + "fieldname": "unsubscribed", + "fieldtype": "Check", + "label": "Unsubscribed", + "permlevel": 0 + }, + { + "fieldname": "emergency_contact_details", + "fieldtype": "HTML", + "label": "Emergency Contact Details", + "options": "

Emergency Contact Details

", + "permlevel": 0 + }, + { + "fieldname": "person_to_be_contacted", + "fieldtype": "Data", + "label": "Emergency Contact", + "permlevel": 0 + }, + { + "fieldname": "relation", + "fieldtype": "Data", + "label": "Relation", + "permlevel": 0 + }, + { + "fieldname": "emergency_phone_number", + "fieldtype": "Data", + "label": "Emergency Phone", + "permlevel": 0 + }, + { + "fieldname": "column_break4", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "permanent_accommodation_type", + "fieldtype": "Select", + "label": "Permanent Address Is", + "options": "\nRented\nOwned", + "permlevel": 0 + }, + { + "fieldname": "permanent_address", + "fieldtype": "Small Text", + "label": "Permanent Address", + "permlevel": 0 + }, + { + "fieldname": "current_accommodation_type", + "fieldtype": "Select", + "label": "Current Address Is", + "options": "\nRented\nOwned", + "permlevel": 0 + }, + { + "fieldname": "current_address", + "fieldtype": "Small Text", + "label": "Current Address", + "permlevel": 0 + }, + { + "fieldname": "sb53", + "fieldtype": "Section Break", + "label": "Bio", + "permlevel": 0 + }, + { + "description": "Short biography for website and other publications.", + "fieldname": "bio", + "fieldtype": "Text Editor", + "label": "Bio", + "permlevel": 0 + }, + { + "fieldname": "personal_details", + "fieldtype": "Section Break", + "label": "Personal Details", + "permlevel": 0 + }, + { + "fieldname": "column_break5", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "pan_number", + "fieldtype": "Data", + "label": "PAN Number", + "permlevel": 0 + }, + { + "fieldname": "passport_number", + "fieldtype": "Data", + "label": "Passport Number", + "permlevel": 0 + }, + { + "fieldname": "date_of_issue", + "fieldtype": "Date", + "label": "Date of Issue", + "permlevel": 0 + }, + { + "fieldname": "valid_upto", + "fieldtype": "Date", + "label": "Valid Upto", + "permlevel": 0 + }, + { + "fieldname": "place_of_issue", + "fieldtype": "Data", + "label": "Place of Issue", + "permlevel": 0 + }, + { + "fieldname": "column_break6", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "marital_status", + "fieldtype": "Select", + "label": "Marital Status", + "options": "\nSingle\nMarried\nDivorced\nWidowed", + "permlevel": 0 + }, + { + "fieldname": "blood_group", + "fieldtype": "Select", + "label": "Blood Group", + "options": "\nA+\nA-\nB+\nB-\nAB+\nAB-\nO+\nO-", + "permlevel": 0 + }, + { + "description": "Here you can maintain family details like name and occupation of parent, spouse and children", + "fieldname": "family_background", + "fieldtype": "Small Text", + "label": "Family Background", + "permlevel": 0 + }, + { + "description": "Here you can maintain height, weight, allergies, medical concerns etc", + "fieldname": "health_details", + "fieldtype": "Small Text", + "label": "Health Details", + "permlevel": 0 + }, + { + "fieldname": "educational_qualification", + "fieldtype": "Section Break", + "label": "Educational Qualification", + "permlevel": 0 + }, + { + "fieldname": "educational_qualification_details", + "fieldtype": "Table", + "label": "Educational Qualification Details", + "options": "Employee Education", + "permlevel": 0 + }, + { + "fieldname": "previous_work_experience", + "fieldtype": "Section Break", + "label": "Previous Work Experience", + "options": "Simple", + "permlevel": 0 + }, + { + "fieldname": "previous_experience_details", + "fieldtype": "Table", + "label": "Employee External Work History", + "options": "Employee External Work History", + "permlevel": 0 + }, + { + "fieldname": "history_in_company", + "fieldtype": "Section Break", + "label": "History In Company", + "options": "Simple", + "permlevel": 0 + }, + { + "fieldname": "experience_in_company_details", + "fieldtype": "Table", + "label": "Employee Internal Work Historys", + "options": "Employee Internal Work History", + "permlevel": 0 + }, + { + "fieldname": "exit", + "fieldtype": "Section Break", + "label": "Exit", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "column_break7", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "resignation_letter_date", + "fieldtype": "Date", + "label": "Resignation Letter Date", + "oldfieldname": "resignation_letter_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "relieving_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Relieving Date", + "oldfieldname": "relieving_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "reason_for_leaving", + "fieldtype": "Data", + "label": "Reason for Leaving", + "oldfieldname": "reason_for_leaving", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "leave_encashed", + "fieldtype": "Select", + "label": "Leave Encashed?", + "oldfieldname": "leave_encashed", + "oldfieldtype": "Select", + "options": "\nYes\nNo", + "permlevel": 0 + }, + { + "fieldname": "encashment_date", + "fieldtype": "Date", + "label": "Encashment Date", + "oldfieldname": "encashment_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "exit_interview_details", + "fieldtype": "Column Break", + "label": "Exit Interview Details", + "oldfieldname": "col_brk6", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "held_on", + "fieldtype": "Date", + "label": "Held On", + "oldfieldname": "held_on", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "reason_for_resignation", + "fieldtype": "Select", + "label": "Reason for Resignation", + "oldfieldname": "reason_for_resignation", + "oldfieldtype": "Select", + "options": "\nBetter Prospects\nHealth Concerns", + "permlevel": 0 + }, + { + "fieldname": "new_workplace", + "fieldtype": "Data", + "label": "New Workplace", + "oldfieldname": "new_workplace", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "feedback", + "fieldtype": "Small Text", + "label": "Feedback", + "oldfieldname": "feedback", + "oldfieldtype": "Text", + "permlevel": 0 + }, + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-user", + "idx": 1, + "modified": "2014-02-03 18:06:04.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Employee", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Employee", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "restrict": 0, + "role": "HR User", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "restrict": 1, + "role": "HR Manager", + "submit": 0, + "write": 1 + } + ], + "search_fields": "employee_name" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py index 3ec44e66d2e..914d80db630 100644 --- a/erpnext/hr/doctype/employee/employee.py +++ b/erpnext/hr/doctype/employee/employee.py @@ -5,41 +5,41 @@ from __future__ import unicode_literals import frappe from frappe.utils import getdate, validate_email_add, cstr, cint -from frappe.model.doc import make_autoname +from frappe.model.naming import make_autoname from frappe import msgprint, throw, _ import frappe.permissions from frappe.defaults import get_restrictions from frappe.model.controller import DocListController -class DocType(DocListController): +class Employee(DocListController): def autoname(self): naming_method = frappe.db.get_value("HR Settings", None, "emp_created_by") if not naming_method: throw(_("Please setup Employee Naming System in Human Resource > HR Settings")) else: if naming_method=='Naming Series': - self.doc.name = make_autoname(self.doc.naming_series + '.####') + self.name = make_autoname(self.naming_series + '.####') elif naming_method=='Employee Number': - self.doc.name = self.doc.employee_number + self.name = self.employee_number - self.doc.employee = self.doc.name + self.employee = self.name def validate(self): from erpnext.utilities import validate_status - validate_status(self.doc.status, ["Active", "Left"]) + validate_status(self.status, ["Active", "Left"]) - self.doc.employee = self.doc.name + self.employee = self.name self.validate_date() self.validate_email() self.validate_status() self.validate_employee_leave_approver() - if self.doc.user_id: + if self.user_id: self.validate_for_enabled_user_id() self.validate_duplicate_user_id() def on_update(self): - if self.doc.user_id and frappe.db.get_value("User", self.doc.user_id, 'docstatus') == 0: + if self.user_id and frappe.db.get_value("User", self.user_id, 'docstatus') == 0: self.restrict_user() self.update_user_default() self.update_user() @@ -49,17 +49,17 @@ class DocType(DocListController): def restrict_user(self): """restrict to this employee for user""" - self.add_restriction_if_required("Employee", self.doc.user_id) + self.add_restriction_if_required("Employee", self.user_id) def update_user_default(self): - frappe.db.set_default("employee_name", self.doc.employee_name, self.doc.user_id) - frappe.db.set_default("company", self.doc.company, self.doc.user_id) + frappe.db.set_default("employee_name", self.employee_name, self.user_id) + frappe.db.set_default("company", self.company, self.user_id) def restrict_leave_approver(self): """restrict to this employee for leave approver""" - employee_leave_approvers = [d.leave_approver for d in self.doclist.get({"parentfield": "employee_leave_approvers"})] - if self.doc.reports_to and self.doc.reports_to not in employee_leave_approvers: - employee_leave_approvers.append(frappe.db.get_value("Employee", self.doc.reports_to, "user_id")) + employee_leave_approvers = [d.leave_approver for d in self.get("employee_leave_approvers")] + if self.reports_to and self.reports_to not in employee_leave_approvers: + employee_leave_approvers.append(frappe.db.get_value("Employee", self.reports_to, "user_id")) for user in employee_leave_approvers: self.add_restriction_if_required("Employee", user) @@ -67,45 +67,45 @@ class DocType(DocListController): def add_restriction_if_required(self, doctype, user): if frappe.permissions.has_only_non_restrict_role(doctype, user) \ - and self.doc.name not in get_restrictions(user).get("Employee", []): + and self.name not in get_restrictions(user).get("Employee", []): - frappe.defaults.add_default("Employee", self.doc.name, user, "Restriction") + frappe.defaults.add_default("Employee", self.name, user, "Restriction") def update_user(self): # add employee role if missing if not "Employee" in frappe.db.sql_list("""select role from tabUserRole - where parent=%s""", self.doc.user_id): + where parent=%s""", self.user_id): from frappe.utils.user import add_role - add_role(self.doc.user_id, "Employee") + add_role(self.user_id, "Employee") - user_wrapper = frappe.bean("User", self.doc.user_id) + user_wrapper = frappe.get_doc("User", self.user_id) # copy details like Fullname, DOB and Image to User - if self.doc.employee_name: - employee_name = self.doc.employee_name.split(" ") + if self.employee_name: + employee_name = self.employee_name.split(" ") if len(employee_name) >= 3: - user_wrapper.doc.last_name = " ".join(employee_name[2:]) - user_wrapper.doc.middle_name = employee_name[1] + user_wrapper.last_name = " ".join(employee_name[2:]) + user_wrapper.middle_name = employee_name[1] elif len(employee_name) == 2: - user_wrapper.doc.last_name = employee_name[1] + user_wrapper.last_name = employee_name[1] - user_wrapper.doc.first_name = employee_name[0] + user_wrapper.first_name = employee_name[0] - if self.doc.date_of_birth: - user_wrapper.doc.birth_date = self.doc.date_of_birth + if self.date_of_birth: + user_wrapper.birth_date = self.date_of_birth - if self.doc.gender: - user_wrapper.doc.gender = self.doc.gender + if self.gender: + user_wrapper.gender = self.gender - if self.doc.image: - if not user_wrapper.doc.user_image == self.doc.image: - user_wrapper.doc.user_image = self.doc.image + if self.image: + if not user_wrapper.user_image == self.image: + user_wrapper.user_image = self.image try: - frappe.doc({ + frappe.get_doc({ "doctype": "File Data", - "file_name": self.doc.image, + "file_name": self.image, "attached_to_doctype": "User", - "attached_to_name": self.doc.user_id + "attached_to_name": self.user_id }).insert() except frappe.DuplicateEntryError, e: # already exists @@ -114,51 +114,51 @@ class DocType(DocListController): user_wrapper.save() def validate_date(self): - if self.doc.date_of_birth and self.doc.date_of_joining and getdate(self.doc.date_of_birth) >= getdate(self.doc.date_of_joining): + if self.date_of_birth and self.date_of_joining and getdate(self.date_of_birth) >= getdate(self.date_of_joining): throw(_("Date of Joining must be greater than Date of Birth")) - elif self.doc.scheduled_confirmation_date and self.doc.date_of_joining and (getdate(self.doc.scheduled_confirmation_date) < getdate(self.doc.date_of_joining)): + elif self.scheduled_confirmation_date and self.date_of_joining and (getdate(self.scheduled_confirmation_date) < getdate(self.date_of_joining)): throw(_("Scheduled Confirmation Date must be greater than Date of Joining")) - elif self.doc.final_confirmation_date and self.doc.date_of_joining and (getdate(self.doc.final_confirmation_date) < getdate(self.doc.date_of_joining)): + elif self.final_confirmation_date and self.date_of_joining and (getdate(self.final_confirmation_date) < getdate(self.date_of_joining)): throw(_("Final Confirmation Date must be greater than Date of Joining")) - elif self.doc.date_of_retirement and self.doc.date_of_joining and (getdate(self.doc.date_of_retirement) <= getdate(self.doc.date_of_joining)): + elif self.date_of_retirement and self.date_of_joining and (getdate(self.date_of_retirement) <= getdate(self.date_of_joining)): throw(_("Date Of Retirement must be greater than Date of Joining")) - elif self.doc.relieving_date and self.doc.date_of_joining and (getdate(self.doc.relieving_date) <= getdate(self.doc.date_of_joining)): + elif self.relieving_date and self.date_of_joining and (getdate(self.relieving_date) <= getdate(self.date_of_joining)): throw(_("Relieving Date must be greater than Date of Joining")) - elif self.doc.contract_end_date and self.doc.date_of_joining and (getdate(self.doc.contract_end_date)<=getdate(self.doc.date_of_joining)): + elif self.contract_end_date and self.date_of_joining and (getdate(self.contract_end_date)<=getdate(self.date_of_joining)): throw(_("Contract End Date must be greater than Date of Joining")) def validate_email(self): - if self.doc.company_email and not validate_email_add(self.doc.company_email): + if self.company_email and not validate_email_add(self.company_email): throw(_("Please enter valid Company Email")) - if self.doc.personal_email and not validate_email_add(self.doc.personal_email): + if self.personal_email and not validate_email_add(self.personal_email): throw(_("Please enter valid Personal Email")) def validate_status(self): - if self.doc.status == 'Left' and not self.doc.relieving_date: + if self.status == 'Left' and not self.relieving_date: throw(_("Please enter relieving date.")) def validate_for_enabled_user_id(self): enabled = frappe.db.sql("""select name from `tabUser` where - name=%s and enabled=1""", self.doc.user_id) + name=%s and enabled=1""", self.user_id) if not enabled: throw("{id}: {user_id} {msg}".format(**{ "id": _("User ID"), - "user_id": self.doc.user_id, + "user_id": self.user_id, "msg": _("is disabled.") })) def validate_duplicate_user_id(self): employee = frappe.db.sql_list("""select name from `tabEmployee` where - user_id=%s and status='Active' and name!=%s""", (self.doc.user_id, self.doc.name)) + user_id=%s and status='Active' and name!=%s""", (self.user_id, self.name)) if employee: throw("{id}: {user_id} {msg}: {employee}".format(**{ "id": _("User ID"), - "user_id": self.doc.user_id, + "user_id": self.user_id, "msg": _("is already assigned to Employee"), "employee": employee[0] })) @@ -167,30 +167,30 @@ class DocType(DocListController): from frappe.utils.user import User from erpnext.hr.doctype.leave_application.leave_application import InvalidLeaveApproverError - for l in self.doclist.get({"parentfield": "employee_leave_approvers"}): + for l in self.get("employee_leave_approvers"): if "Leave Approver" not in User(l.leave_approver).get_roles(): throw(_("Invalid Leave Approver") + ": \"" + l.leave_approver + "\"", exc=InvalidLeaveApproverError) def update_dob_event(self): - if self.doc.status == "Active" and self.doc.date_of_birth \ + if self.status == "Active" and self.date_of_birth \ and not cint(frappe.db.get_value("HR Settings", None, "stop_birthday_reminders")): birthday_event = frappe.db.sql("""select name from `tabEvent` where repeat_on='Every Year' - and ref_type='Employee' and ref_name=%s""", self.doc.name) + and ref_type='Employee' and ref_name=%s""", self.name) - starts_on = self.doc.date_of_birth + " 00:00:00" - ends_on = self.doc.date_of_birth + " 00:15:00" + starts_on = self.date_of_birth + " 00:00:00" + ends_on = self.date_of_birth + " 00:15:00" if birthday_event: - event = frappe.bean("Event", birthday_event[0][0]) - event.doc.starts_on = starts_on - event.doc.ends_on = ends_on + event = frappe.get_doc("Event", birthday_event[0][0]) + event.starts_on = starts_on + event.ends_on = ends_on event.save() else: - frappe.bean({ + frappe.get_doc({ "doctype": "Event", - "subject": _("Birthday") + ": " + self.doc.employee_name, - "description": _("Happy Birthday!") + " " + self.doc.employee_name, + "subject": _("Birthday") + ": " + self.employee_name, + "description": _("Happy Birthday!") + " " + self.employee_name, "starts_on": starts_on, "ends_on": ends_on, "event_type": "Public", @@ -199,11 +199,11 @@ class DocType(DocListController): "repeat_this_event": 1, "repeat_on": "Every Year", "ref_type": "Employee", - "ref_name": self.doc.name + "ref_name": self.name }).insert() else: frappe.db.sql("""delete from `tabEvent` where repeat_on='Every Year' and - ref_type='Employee' and ref_name=%s""", self.doc.name) + ref_type='Employee' and ref_name=%s""", self.name) @frappe.whitelist() def get_retirement_date(date_of_birth=None): diff --git a/erpnext/hr/doctype/employee/employee.txt b/erpnext/hr/doctype/employee/employee.txt deleted file mode 100644 index bc21ff95a0e..00000000000 --- a/erpnext/hr/doctype/employee/employee.txt +++ /dev/null @@ -1,782 +0,0 @@ -[ - { - "creation": "2013-03-07 09:04:18", - "docstatus": 0, - "modified": "2014-02-03 18:06:04", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "allow_rename": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-user", - "module": "HR", - "name": "__common__", - "search_fields": "employee_name" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Employee", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Employee", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Employee" - }, - { - "doctype": "DocField", - "fieldname": "basic_information", - "fieldtype": "Section Break", - "label": "Basic Information", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "image_view", - "fieldtype": "Image", - "in_list_view": 0, - "label": "Image View", - "options": "image" - }, - { - "doctype": "DocField", - "fieldname": "employee", - "fieldtype": "Data", - "hidden": 1, - "label": "Employee", - "no_copy": 1, - "print_hide": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "EMP/", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "salutation", - "fieldtype": "Select", - "label": "Salutation", - "oldfieldname": "salutation", - "oldfieldtype": "Select", - "options": "\nMr\nMs", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "employee_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Full Name", - "oldfieldname": "employee_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "image", - "fieldtype": "Select", - "label": "Image", - "options": "attach_files:" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "description": "System User (login) ID. If set, it will become default for all HR forms.", - "doctype": "DocField", - "fieldname": "user_id", - "fieldtype": "Link", - "label": "User ID", - "options": "User" - }, - { - "doctype": "DocField", - "fieldname": "employee_number", - "fieldtype": "Data", - "in_filter": 1, - "label": "Employee Number", - "oldfieldname": "employee_number", - "oldfieldtype": "Data", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "date_of_joining", - "fieldtype": "Date", - "label": "Date of Joining", - "oldfieldname": "date_of_joining", - "oldfieldtype": "Date", - "reqd": 1 - }, - { - "description": "You can enter any date manually", - "doctype": "DocField", - "fieldname": "date_of_birth", - "fieldtype": "Date", - "in_filter": 1, - "label": "Date of Birth", - "oldfieldname": "date_of_birth", - "oldfieldtype": "Date", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "gender", - "fieldtype": "Select", - "in_filter": 1, - "label": "Gender", - "oldfieldname": "gender", - "oldfieldtype": "Select", - "options": "\nMale\nFemale", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "in_filter": 1, - "label": "Company", - "options": "link:Company", - "print_hide": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "employment_details", - "fieldtype": "Section Break", - "label": "Employment Details" - }, - { - "doctype": "DocField", - "fieldname": "col_break_21", - "fieldtype": "Column Break" - }, - { - "default": "Active", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Status", - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nActive\nLeft", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "employment_type", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Employment Type", - "oldfieldname": "employment_type", - "oldfieldtype": "Link", - "options": "Employment Type", - "search_index": 0 - }, - { - "description": "Applicable Holiday List", - "doctype": "DocField", - "fieldname": "holiday_list", - "fieldtype": "Link", - "label": "Holiday List", - "oldfieldname": "holiday_list", - "oldfieldtype": "Link", - "options": "Holiday List" - }, - { - "doctype": "DocField", - "fieldname": "col_break_22", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "scheduled_confirmation_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Offer Date", - "oldfieldname": "scheduled_confirmation_date", - "oldfieldtype": "Date", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "final_confirmation_date", - "fieldtype": "Date", - "label": "Confirmation Date", - "oldfieldname": "final_confirmation_date", - "oldfieldtype": "Date", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "contract_end_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Contract End Date", - "oldfieldname": "contract_end_date", - "oldfieldtype": "Date", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "date_of_retirement", - "fieldtype": "Date", - "label": "Date Of Retirement", - "oldfieldname": "date_of_retirement", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "job_profile", - "fieldtype": "Section Break", - "label": "Job Profile" - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "branch", - "fieldtype": "Link", - "in_filter": 1, - "label": "Branch", - "oldfieldname": "branch", - "oldfieldtype": "Link", - "options": "Branch", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "department", - "fieldtype": "Link", - "in_filter": 1, - "label": "Department", - "oldfieldname": "department", - "oldfieldtype": "Link", - "options": "Department", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "designation", - "fieldtype": "Link", - "in_filter": 1, - "label": "Designation", - "oldfieldname": "designation", - "oldfieldtype": "Link", - "options": "Designation", - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "grade", - "fieldtype": "Link", - "in_filter": 1, - "label": "Grade", - "oldfieldname": "grade", - "oldfieldtype": "Link", - "options": "Grade", - "reqd": 0 - }, - { - "description": "Provide email id registered in company", - "doctype": "DocField", - "fieldname": "company_email", - "fieldtype": "Data", - "in_filter": 1, - "label": "Company Email", - "oldfieldname": "company_email", - "oldfieldtype": "Data", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "notice_number_of_days", - "fieldtype": "Int", - "label": "Notice (days)", - "oldfieldname": "notice_number_of_days", - "oldfieldtype": "Int" - }, - { - "doctype": "DocField", - "fieldname": "salary_information", - "fieldtype": "Column Break", - "label": "Salary Information", - "oldfieldtype": "Section Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "salary_mode", - "fieldtype": "Select", - "label": "Salary Mode", - "oldfieldname": "salary_mode", - "oldfieldtype": "Select", - "options": "\nBank\nCash\nCheque" - }, - { - "depends_on": "eval:doc.salary_mode == 'Bank'", - "doctype": "DocField", - "fieldname": "bank_name", - "fieldtype": "Data", - "hidden": 0, - "in_filter": 1, - "label": "Bank Name", - "oldfieldname": "bank_name", - "oldfieldtype": "Link", - "options": "Suggest" - }, - { - "depends_on": "eval:doc.salary_mode == 'Bank'", - "doctype": "DocField", - "fieldname": "bank_ac_no", - "fieldtype": "Data", - "hidden": 0, - "label": "Bank A/C No.", - "oldfieldname": "bank_ac_no", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "esic_card_no", - "fieldtype": "Data", - "label": "ESIC CARD No", - "oldfieldname": "esic_card_no", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "pf_number", - "fieldtype": "Data", - "label": "PF Number", - "oldfieldname": "pf_number", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "gratuity_lic_id", - "fieldtype": "Data", - "label": "Gratuity LIC ID", - "oldfieldname": "gratuity_lic_id", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "organization_profile", - "fieldtype": "Section Break", - "label": "Organization Profile" - }, - { - "doctype": "DocField", - "fieldname": "reports_to", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Reports to", - "oldfieldname": "reports_to", - "oldfieldtype": "Link", - "options": "Employee" - }, - { - "description": "The first Leave Approver in the list will be set as the default Leave Approver", - "doctype": "DocField", - "fieldname": "employee_leave_approvers", - "fieldtype": "Table", - "label": "Leave Approvers", - "options": "Employee Leave Approver" - }, - { - "doctype": "DocField", - "fieldname": "contact_details", - "fieldtype": "Section Break", - "label": "Contact Details" - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "cell_number", - "fieldtype": "Data", - "label": "Cell Number" - }, - { - "doctype": "DocField", - "fieldname": "personal_email", - "fieldtype": "Data", - "label": "Personal Email" - }, - { - "doctype": "DocField", - "fieldname": "unsubscribed", - "fieldtype": "Check", - "label": "Unsubscribed" - }, - { - "doctype": "DocField", - "fieldname": "emergency_contact_details", - "fieldtype": "HTML", - "label": "Emergency Contact Details", - "options": "

Emergency Contact Details

" - }, - { - "doctype": "DocField", - "fieldname": "person_to_be_contacted", - "fieldtype": "Data", - "label": "Emergency Contact" - }, - { - "doctype": "DocField", - "fieldname": "relation", - "fieldtype": "Data", - "label": "Relation" - }, - { - "doctype": "DocField", - "fieldname": "emergency_phone_number", - "fieldtype": "Data", - "label": "Emergency Phone" - }, - { - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "permanent_accommodation_type", - "fieldtype": "Select", - "label": "Permanent Address Is", - "options": "\nRented\nOwned" - }, - { - "doctype": "DocField", - "fieldname": "permanent_address", - "fieldtype": "Small Text", - "label": "Permanent Address" - }, - { - "doctype": "DocField", - "fieldname": "current_accommodation_type", - "fieldtype": "Select", - "label": "Current Address Is", - "options": "\nRented\nOwned" - }, - { - "doctype": "DocField", - "fieldname": "current_address", - "fieldtype": "Small Text", - "label": "Current Address" - }, - { - "doctype": "DocField", - "fieldname": "sb53", - "fieldtype": "Section Break", - "label": "Bio" - }, - { - "description": "Short biography for website and other publications.", - "doctype": "DocField", - "fieldname": "bio", - "fieldtype": "Text Editor", - "label": "Bio" - }, - { - "doctype": "DocField", - "fieldname": "personal_details", - "fieldtype": "Section Break", - "label": "Personal Details" - }, - { - "doctype": "DocField", - "fieldname": "column_break5", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "pan_number", - "fieldtype": "Data", - "label": "PAN Number" - }, - { - "doctype": "DocField", - "fieldname": "passport_number", - "fieldtype": "Data", - "label": "Passport Number" - }, - { - "doctype": "DocField", - "fieldname": "date_of_issue", - "fieldtype": "Date", - "label": "Date of Issue" - }, - { - "doctype": "DocField", - "fieldname": "valid_upto", - "fieldtype": "Date", - "label": "Valid Upto" - }, - { - "doctype": "DocField", - "fieldname": "place_of_issue", - "fieldtype": "Data", - "label": "Place of Issue" - }, - { - "doctype": "DocField", - "fieldname": "column_break6", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "marital_status", - "fieldtype": "Select", - "label": "Marital Status", - "options": "\nSingle\nMarried\nDivorced\nWidowed" - }, - { - "doctype": "DocField", - "fieldname": "blood_group", - "fieldtype": "Select", - "label": "Blood Group", - "options": "\nA+\nA-\nB+\nB-\nAB+\nAB-\nO+\nO-" - }, - { - "description": "Here you can maintain family details like name and occupation of parent, spouse and children", - "doctype": "DocField", - "fieldname": "family_background", - "fieldtype": "Small Text", - "label": "Family Background" - }, - { - "description": "Here you can maintain height, weight, allergies, medical concerns etc", - "doctype": "DocField", - "fieldname": "health_details", - "fieldtype": "Small Text", - "label": "Health Details" - }, - { - "doctype": "DocField", - "fieldname": "educational_qualification", - "fieldtype": "Section Break", - "label": "Educational Qualification" - }, - { - "doctype": "DocField", - "fieldname": "educational_qualification_details", - "fieldtype": "Table", - "label": "Educational Qualification Details", - "options": "Employee Education" - }, - { - "doctype": "DocField", - "fieldname": "previous_work_experience", - "fieldtype": "Section Break", - "label": "Previous Work Experience", - "options": "Simple" - }, - { - "doctype": "DocField", - "fieldname": "previous_experience_details", - "fieldtype": "Table", - "label": "Employee External Work History", - "options": "Employee External Work History" - }, - { - "doctype": "DocField", - "fieldname": "history_in_company", - "fieldtype": "Section Break", - "label": "History In Company", - "options": "Simple" - }, - { - "doctype": "DocField", - "fieldname": "experience_in_company_details", - "fieldtype": "Table", - "label": "Employee Internal Work Historys", - "options": "Employee Internal Work History" - }, - { - "doctype": "DocField", - "fieldname": "exit", - "fieldtype": "Section Break", - "label": "Exit", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "column_break7", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "resignation_letter_date", - "fieldtype": "Date", - "label": "Resignation Letter Date", - "oldfieldname": "resignation_letter_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "relieving_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Relieving Date", - "oldfieldname": "relieving_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "reason_for_leaving", - "fieldtype": "Data", - "label": "Reason for Leaving", - "oldfieldname": "reason_for_leaving", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "leave_encashed", - "fieldtype": "Select", - "label": "Leave Encashed?", - "oldfieldname": "leave_encashed", - "oldfieldtype": "Select", - "options": "\nYes\nNo" - }, - { - "doctype": "DocField", - "fieldname": "encashment_date", - "fieldtype": "Date", - "label": "Encashment Date", - "oldfieldname": "encashment_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "exit_interview_details", - "fieldtype": "Column Break", - "label": "Exit Interview Details", - "oldfieldname": "col_brk6", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "held_on", - "fieldtype": "Date", - "label": "Held On", - "oldfieldname": "held_on", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "reason_for_resignation", - "fieldtype": "Select", - "label": "Reason for Resignation", - "oldfieldname": "reason_for_resignation", - "oldfieldtype": "Select", - "options": "\nBetter Prospects\nHealth Concerns" - }, - { - "doctype": "DocField", - "fieldname": "new_workplace", - "fieldtype": "Data", - "label": "New Workplace", - "oldfieldname": "new_workplace", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "feedback", - "fieldtype": "Small Text", - "label": "Feedback", - "oldfieldname": "feedback", - "oldfieldtype": "Text" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Employee", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "restrict": 0, - "role": "HR User", - "write": 1 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "restrict": 1, - "role": "HR Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/employee/test_employee.py b/erpnext/hr/doctype/employee/test_employee.py index cfafb63dce1..699e439c530 100644 --- a/erpnext/hr/doctype/employee/test_employee.py +++ b/erpnext/hr/doctype/employee/test_employee.py @@ -1,40 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{ - "doctype":"Employee", - "employee_name": "_Test Employee", - "naming_series": "_T-Employee-", - "date_of_joining": "2010-01-01", - "date_of_birth": "1980-01-01", - "gender": "Female", - "status": "Active", - "company": "_Test Company", - "user_id": "test@example.com", - "department": "_Test Department" -}], -[{ - "doctype":"Employee", - "employee_name": "_Test Employee 1", - "naming_series": "_T-Employee-", - "date_of_joining": "2010-01-01", - "date_of_birth": "1980-01-01", - "gender": "Male", - "status": "Active", - "company": "_Test Company", - "user_id": "test1@example.com", - "department": "_Test Department 1" -}], -[{ - "doctype":"Employee", - "employee_name": "_Test Employee 2", - "naming_series": "_T-Employee-", - "date_of_joining": "2010-01-01", - "date_of_birth": "1980-01-01", - "gender": "Male", - "status": "Active", - "company": "_Test Company", - "user_id": "test2@example.com", - "department": "_Test Department 1" -}] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Employee') \ No newline at end of file diff --git a/erpnext/hr/doctype/employee/test_records.json b/erpnext/hr/doctype/employee/test_records.json new file mode 100644 index 00000000000..087265fa481 --- /dev/null +++ b/erpnext/hr/doctype/employee/test_records.json @@ -0,0 +1,38 @@ +[ + { + "company": "_Test Company", + "date_of_birth": "1980-01-01", + "date_of_joining": "2010-01-01", + "department": "_Test Department", + "doctype": "Employee", + "employee_name": "_Test Employee", + "gender": "Female", + "naming_series": "_T-Employee-", + "status": "Active", + "user_id": "test@example.com" + }, + { + "company": "_Test Company", + "date_of_birth": "1980-01-01", + "date_of_joining": "2010-01-01", + "department": "_Test Department 1", + "doctype": "Employee", + "employee_name": "_Test Employee 1", + "gender": "Male", + "naming_series": "_T-Employee-", + "status": "Active", + "user_id": "test1@example.com" + }, + { + "company": "_Test Company", + "date_of_birth": "1980-01-01", + "date_of_joining": "2010-01-01", + "department": "_Test Department 1", + "doctype": "Employee", + "employee_name": "_Test Employee 2", + "gender": "Male", + "naming_series": "_T-Employee-", + "status": "Active", + "user_id": "test2@example.com" + } +] \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_education/employee_education.json b/erpnext/hr/doctype/employee_education/employee_education.json new file mode 100644 index 00000000000..e1dbb1a649a --- /dev/null +++ b/erpnext/hr/doctype/employee_education/employee_education.json @@ -0,0 +1,71 @@ +{ + "creation": "2013-02-22 01:27:45.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "school_univ", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "School/University", + "oldfieldname": "school_univ", + "oldfieldtype": "Small Text", + "permlevel": 0 + }, + { + "fieldname": "qualification", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Qualification", + "oldfieldname": "qualification", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "100px", + "width": "100px" + }, + { + "fieldname": "level", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Level", + "oldfieldname": "level", + "oldfieldtype": "Select", + "options": "Graduate\nPost Graduate\nUnder Graduate", + "permlevel": 0 + }, + { + "fieldname": "year_of_passing", + "fieldtype": "Int", + "in_list_view": 1, + "label": "Year of Passing", + "oldfieldname": "year_of_passing", + "oldfieldtype": "Int", + "permlevel": 0 + }, + { + "fieldname": "class_per", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Class / Percentage", + "oldfieldname": "class_per", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "maj_opt_subj", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Major/Optional Subjects", + "oldfieldname": "maj_opt_subj", + "oldfieldtype": "Text", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:12.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Employee Education", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_education/employee_education.py b/erpnext/hr/doctype/employee_education/employee_education.py index 26c87f1c04a..2cc0f260378 100644 --- a/erpnext/hr/doctype/employee_education/employee_education.py +++ b/erpnext/hr/doctype/employee_education/employee_education.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class EmployeeEducation(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_education/employee_education.txt b/erpnext/hr/doctype/employee_education/employee_education.txt deleted file mode 100644 index 9204c63779e..00000000000 --- a/erpnext/hr/doctype/employee_education/employee_education.txt +++ /dev/null @@ -1,79 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:45", - "docstatus": 0, - "modified": "2013-12-20 19:23:12", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Employee Education", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Employee Education" - }, - { - "doctype": "DocField", - "fieldname": "school_univ", - "fieldtype": "Small Text", - "label": "School/University", - "oldfieldname": "school_univ", - "oldfieldtype": "Small Text" - }, - { - "doctype": "DocField", - "fieldname": "qualification", - "fieldtype": "Data", - "label": "Qualification", - "oldfieldname": "qualification", - "oldfieldtype": "Data", - "print_width": "100px", - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "level", - "fieldtype": "Select", - "label": "Level", - "oldfieldname": "level", - "oldfieldtype": "Select", - "options": "Graduate\nPost Graduate\nUnder Graduate" - }, - { - "doctype": "DocField", - "fieldname": "year_of_passing", - "fieldtype": "Int", - "label": "Year of Passing", - "oldfieldname": "year_of_passing", - "oldfieldtype": "Int" - }, - { - "doctype": "DocField", - "fieldname": "class_per", - "fieldtype": "Data", - "label": "Class / Percentage", - "oldfieldname": "class_per", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "maj_opt_subj", - "fieldtype": "Text", - "label": "Major/Optional Subjects", - "oldfieldname": "maj_opt_subj", - "oldfieldtype": "Text" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.json b/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.json new file mode 100644 index 00000000000..41a110f85ce --- /dev/null +++ b/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.json @@ -0,0 +1,69 @@ +{ + "creation": "2013-02-22 01:27:45.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "company_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Company", + "oldfieldname": "company_name", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "designation", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Designation", + "oldfieldname": "designation", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "salary", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Salary", + "oldfieldname": "salary", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "address", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Address", + "oldfieldname": "address", + "oldfieldtype": "Small Text", + "permlevel": 0 + }, + { + "fieldname": "contact", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Contact", + "oldfieldname": "contact", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "total_experience", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Total Experience", + "oldfieldname": "total_experience", + "oldfieldtype": "Data", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:12.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Employee External Work History", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py b/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py index 26c87f1c04a..a99e4de8c27 100644 --- a/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py +++ b/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class EmployeeExternalWorkHistory(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.txt b/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.txt deleted file mode 100644 index 962c98194e0..00000000000 --- a/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.txt +++ /dev/null @@ -1,77 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:45", - "docstatus": 0, - "modified": "2013-12-20 19:23:12", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Employee External Work History", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Employee External Work History" - }, - { - "doctype": "DocField", - "fieldname": "company_name", - "fieldtype": "Data", - "label": "Company", - "oldfieldname": "company_name", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "designation", - "fieldtype": "Data", - "label": "Designation", - "oldfieldname": "designation", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "salary", - "fieldtype": "Currency", - "label": "Salary", - "oldfieldname": "salary", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "address", - "fieldtype": "Small Text", - "label": "Address", - "oldfieldname": "address", - "oldfieldtype": "Small Text" - }, - { - "doctype": "DocField", - "fieldname": "contact", - "fieldtype": "Data", - "label": "Contact", - "oldfieldname": "contact", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "total_experience", - "fieldtype": "Data", - "label": "Total Experience", - "oldfieldname": "total_experience", - "oldfieldtype": "Data" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.json b/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.json new file mode 100644 index 00000000000..d3589908d11 --- /dev/null +++ b/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.json @@ -0,0 +1,72 @@ +{ + "creation": "2013-02-22 01:27:45.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "branch", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Branch", + "oldfieldname": "branch", + "oldfieldtype": "Select", + "options": "link:Branch", + "permlevel": 0 + }, + { + "fieldname": "department", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Department", + "oldfieldname": "department", + "oldfieldtype": "Select", + "options": "link:Department", + "permlevel": 0 + }, + { + "fieldname": "designation", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Designation", + "oldfieldname": "designation", + "oldfieldtype": "Select", + "options": "link:Designation", + "permlevel": 0 + }, + { + "fieldname": "grade", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Grade", + "oldfieldname": "grade", + "oldfieldtype": "Select", + "options": "link:Grade", + "permlevel": 0 + }, + { + "fieldname": "from_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "From Date", + "oldfieldname": "from_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "to_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "To Date", + "oldfieldname": "to_date", + "oldfieldtype": "Date", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:12.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Employee Internal Work History", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py b/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py index 26c87f1c04a..65dfa44a6a3 100644 --- a/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py +++ b/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class EmployeeInternalWorkHistory(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.txt b/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.txt deleted file mode 100644 index 2c964faba83..00000000000 --- a/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.txt +++ /dev/null @@ -1,80 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:45", - "docstatus": 0, - "modified": "2013-12-20 19:23:12", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Employee Internal Work History", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Employee Internal Work History" - }, - { - "doctype": "DocField", - "fieldname": "branch", - "fieldtype": "Select", - "label": "Branch", - "oldfieldname": "branch", - "oldfieldtype": "Select", - "options": "link:Branch" - }, - { - "doctype": "DocField", - "fieldname": "department", - "fieldtype": "Select", - "label": "Department", - "oldfieldname": "department", - "oldfieldtype": "Select", - "options": "link:Department" - }, - { - "doctype": "DocField", - "fieldname": "designation", - "fieldtype": "Select", - "label": "Designation", - "oldfieldname": "designation", - "oldfieldtype": "Select", - "options": "link:Designation" - }, - { - "doctype": "DocField", - "fieldname": "grade", - "fieldtype": "Select", - "label": "Grade", - "oldfieldname": "grade", - "oldfieldtype": "Select", - "options": "link:Grade" - }, - { - "doctype": "DocField", - "fieldname": "from_date", - "fieldtype": "Date", - "label": "From Date", - "oldfieldname": "from_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "to_date", - "fieldtype": "Date", - "label": "To Date", - "oldfieldname": "to_date", - "oldfieldtype": "Date" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.json b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.json new file mode 100644 index 00000000000..c0cb78d894b --- /dev/null +++ b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.json @@ -0,0 +1,27 @@ +{ + "allow_import": 0, + "autoname": "LAPPR-/.#####", + "creation": "2013-04-12 06:56:15.000000", + "description": "Users who can approve a specific employee's leave applications", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "leave_approver", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Leave Approver", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "width": "200" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:12.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Employee Leave Approver", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py index 968a25b6134..8736c4fe774 100644 --- a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py +++ b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class EmployeeLeaveApprover(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.txt b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.txt deleted file mode 100644 index 4b176d1c0f4..00000000000 --- a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.txt +++ /dev/null @@ -1,40 +0,0 @@ -[ - { - "creation": "2013-04-12 06:56:15", - "docstatus": 0, - "modified": "2013-12-20 19:23:12", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 0, - "autoname": "LAPPR-/.#####", - "description": "Users who can approve a specific employee's leave applications", - "doctype": "DocType", - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "leave_approver", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Leave Approver", - "name": "__common__", - "parent": "Employee Leave Approver", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "print_hide": 1, - "reqd": 1, - "width": "200" - }, - { - "doctype": "DocType", - "name": "Employee Leave Approver" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/employment_type/employment_type.json b/erpnext/hr/doctype/employment_type/employment_type.json new file mode 100644 index 00000000000..4fa41fe345b --- /dev/null +++ b/erpnext/hr/doctype/employment_type/employment_type.json @@ -0,0 +1,63 @@ +{ + "allow_import": 1, + "autoname": "field:employee_type_name", + "creation": "2013-01-10 16:34:14.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "employee_type_name", + "fieldtype": "Data", + "label": "Employment Type", + "oldfieldname": "employee_type_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-flag", + "idx": 1, + "modified": "2014-01-20 17:48:43.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Employment Type", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/employment_type/employment_type.py b/erpnext/hr/doctype/employment_type/employment_type.py index 5015bed79ce..87a8634d66e 100644 --- a/erpnext/hr/doctype/employment_type/employment_type.py +++ b/erpnext/hr/doctype/employment_type/employment_type.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - \ No newline at end of file +from frappe.model.document import Document + +class EmploymentType(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/employment_type/employment_type.txt b/erpnext/hr/doctype/employment_type/employment_type.txt deleted file mode 100644 index a91e145a5e3..00000000000 --- a/erpnext/hr/doctype/employment_type/employment_type.txt +++ /dev/null @@ -1,73 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:14", - "docstatus": 0, - "modified": "2014-01-20 17:48:43", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:employee_type_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-flag", - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Employment Type", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Employment Type", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Employment Type" - }, - { - "doctype": "DocField", - "fieldname": "employee_type_name", - "fieldtype": "Data", - "label": "Employment Type", - "oldfieldname": "employee_type_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocPerm", - "role": "HR User" - }, - { - "doctype": "DocPerm", - "role": "HR Manager" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/employment_type/test_employment_type.py b/erpnext/hr/doctype/employment_type/test_employment_type.py index d2624dc7039..8a080f9b6d2 100644 --- a/erpnext/hr/doctype/employment_type/test_employment_type.py +++ b/erpnext/hr/doctype/employment_type/test_employment_type.py @@ -1,5 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{"doctype":"Employment Type", - "employee_type_name": "_Test Employment Type"}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Employment Type') \ No newline at end of file diff --git a/erpnext/hr/doctype/employment_type/test_records.json b/erpnext/hr/doctype/employment_type/test_records.json new file mode 100644 index 00000000000..fa571798a0c --- /dev/null +++ b/erpnext/hr/doctype/employment_type/test_records.json @@ -0,0 +1,6 @@ +[ + { + "doctype": "Employment Type", + "employee_type_name": "_Test Employment Type" + } +] \ No newline at end of file diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index 6ff1d3f261c..a399d5f0aa7 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -69,8 +69,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn) { } cur_frm.cscript.clear_sanctioned = function(doc) { - var val = getchildren('Expense Claim Detail', doc.name, - 'expense_voucher_details', doc.doctype); + var val = doc.expense_voucher_details || []; for(var i = 0; i%s""" % \ - (self.doc.leave_type, self.doc.employee, self.doc.fiscal_year, + (self.leave_type, self.employee, self.fiscal_year, leave_allocation[0][0], leave_allocation[0][0]), raise_exception=1) def validate_new_leaves_allocated(self): """check if Total Leaves Allocated >= Leave Applications""" - self.doc.total_leaves_allocated = flt(self.doc.carry_forwarded_leaves) + \ - flt(self.doc.new_leaves_allocated) - leaves_applied = self.get_leaves_applied(self.doc.fiscal_year) - if leaves_applied > self.doc.total_leaves_allocated: - expected_new_leaves = flt(self.doc.new_leaves_allocated) + \ - (leaves_applied - self.doc.total_leaves_allocated) + self.total_leaves_allocated = flt(self.carry_forwarded_leaves) + \ + flt(self.new_leaves_allocated) + leaves_applied = self.get_leaves_applied(self.fiscal_year) + if leaves_applied > self.total_leaves_allocated: + expected_new_leaves = flt(self.new_leaves_allocated) + \ + (leaves_applied - self.total_leaves_allocated) msgprint("""Employee: %s has already applied for %s leaves. Hence, New Leaves Allocated should be atleast %s""" % \ - (self.doc.employee, leaves_applied, expected_new_leaves), + (self.employee, leaves_applied, expected_new_leaves), raise_exception=1) def get_leave_bal(self, prev_fyear): @@ -66,57 +65,57 @@ class DocType: leaves_applied = frappe.db.sql("""select SUM(ifnull(total_leave_days, 0)) from `tabLeave Application` where employee=%s and leave_type=%s and fiscal_year=%s and docstatus=1""", - (self.doc.employee, self.doc.leave_type, fiscal_year)) + (self.employee, self.leave_type, fiscal_year)) return leaves_applied and flt(leaves_applied[0][0]) or 0 def get_leaves_allocated(self, fiscal_year): leaves_allocated = frappe.db.sql("""select SUM(ifnull(total_leaves_allocated, 0)) from `tabLeave Allocation` where employee=%s and leave_type=%s and fiscal_year=%s and docstatus=1 and name!=%s""", - (self.doc.employee, self.doc.leave_type, fiscal_year, self.doc.name)) + (self.employee, self.leave_type, fiscal_year, self.name)) return leaves_allocated and flt(leaves_allocated[0][0]) or 0 def allow_carry_forward(self): """check whether carry forward is allowed or not for this leave type""" cf = frappe.db.sql("""select is_carry_forward from `tabLeave Type` where name = %s""", - self.doc.leave_type) + self.leave_type) cf = cf and cint(cf[0][0]) or 0 if not cf: - frappe.db.set(self.doc,'carry_forward',0) - msgprint("Sorry! You cannot carry forward %s" % (self.doc.leave_type), + frappe.db.set(self,'carry_forward',0) + msgprint("Sorry! You cannot carry forward %s" % (self.leave_type), raise_exception=1) def get_carry_forwarded_leaves(self): - if self.doc.carry_forward: + if self.carry_forward: self.allow_carry_forward() prev_fiscal_year = frappe.db.sql("""select name from `tabFiscal Year` where year_start_date = (select date_add(year_start_date, interval -1 year) from `tabFiscal Year` where name=%s) - order by name desc limit 1""", self.doc.fiscal_year) + order by name desc limit 1""", self.fiscal_year) prev_fiscal_year = prev_fiscal_year and prev_fiscal_year[0][0] or '' prev_bal = 0 - if prev_fiscal_year and cint(self.doc.carry_forward) == 1: + if prev_fiscal_year and cint(self.carry_forward) == 1: prev_bal = self.get_leave_bal(prev_fiscal_year) ret = { 'carry_forwarded_leaves': prev_bal, - 'total_leaves_allocated': flt(prev_bal) + flt(self.doc.new_leaves_allocated) + 'total_leaves_allocated': flt(prev_bal) + flt(self.new_leaves_allocated) } return ret def get_total_allocated_leaves(self): leave_det = self.get_carry_forwarded_leaves() - frappe.db.set(self.doc,'carry_forwarded_leaves',flt(leave_det['carry_forwarded_leaves'])) - frappe.db.set(self.doc,'total_leaves_allocated',flt(leave_det['total_leaves_allocated'])) + frappe.db.set(self,'carry_forwarded_leaves',flt(leave_det['carry_forwarded_leaves'])) + frappe.db.set(self,'total_leaves_allocated',flt(leave_det['total_leaves_allocated'])) def check_for_leave_application(self): exists = frappe.db.sql("""select name from `tabLeave Application` where employee=%s and leave_type=%s and fiscal_year=%s and docstatus=1""", - (self.doc.employee, self.doc.leave_type, self.doc.fiscal_year)) + (self.employee, self.leave_type, self.fiscal_year)) if exists: msgprint("""Cannot cancel this Leave Allocation as \ Employee : %s has already applied for %s. Please check Leave Application: \ %s""" % \ - (self.doc.employee, self.doc.leave_type, exists[0][0], exists[0][0])) + (self.employee, self.leave_type, exists[0][0], exists[0][0])) raise Exception diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.txt b/erpnext/hr/doctype/leave_allocation/leave_allocation.txt deleted file mode 100644 index 60f25239413..00000000000 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation.txt +++ /dev/null @@ -1,181 +0,0 @@ -[ - { - "creation": "2013-02-20 19:10:38", - "docstatus": 0, - "modified": "2014-01-22 16:05:35", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "LAL/.#####", - "doctype": "DocType", - "icon": "icon-ok", - "is_submittable": 1, - "module": "HR", - "name": "__common__", - "search_fields": "employee,employee_name,leave_type,total_leaves_allocated,fiscal_year" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Leave Allocation", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Leave Allocation", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Leave Allocation" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "employee", - "fieldtype": "Link", - "in_filter": 1, - "label": "Employee", - "oldfieldname": "employee", - "oldfieldtype": "Link", - "options": "Employee", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "employee_name", - "fieldtype": "Data", - "in_filter": 1, - "label": "Employee Name", - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "leave_type", - "fieldtype": "Select", - "in_filter": 1, - "label": "Leave Type", - "oldfieldname": "leave_type", - "oldfieldtype": "Link", - "options": "link:Leave Type", - "reqd": 1, - "search_index": 1 - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "hidden": 0, - "label": "Posting Date", - "no_copy": 1, - "oldfieldname": "date", - "oldfieldtype": "Date", - "read_only": 1, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Data", - "options": "link:Fiscal Year", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "hidden": 0, - "label": "Description", - "oldfieldname": "reason", - "oldfieldtype": "Small Text", - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "carry_forward", - "fieldtype": "Check", - "label": "Carry Forward" - }, - { - "depends_on": "carry_forward", - "doctype": "DocField", - "fieldname": "carry_forwarded_leaves", - "fieldtype": "Float", - "label": "Carry Forwarded Leaves", - "read_only": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "new_leaves_allocated", - "fieldtype": "Float", - "label": "New Leaves Allocated" - }, - { - "doctype": "DocField", - "fieldname": "total_leaves_allocated", - "fieldtype": "Float", - "label": "Total Leaves Allocated", - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "hidden": 0, - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocPerm", - "restricted": 1, - "role": "HR User" - }, - { - "doctype": "DocPerm", - "role": "HR Manager" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_application/leave_application.json b/erpnext/hr/doctype/leave_application/leave_application.json new file mode 100644 index 00000000000..777d036d37d --- /dev/null +++ b/erpnext/hr/doctype/leave_application/leave_application.json @@ -0,0 +1,267 @@ +{ + "allow_attach": 1, + "autoname": "LAP/.#####", + "creation": "2013-02-20 11:18:11.000000", + "description": "Apply / Approve Leaves", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "default": "Open", + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "options": "Open\nApproved\nRejected", + "permlevel": 1 + }, + { + "description": "Leave can be approved by users with Role, \"Leave Approver\"", + "fieldname": "leave_approver", + "fieldtype": "Select", + "label": "Leave Approver", + "options": "link:User", + "permlevel": 0 + }, + { + "fieldname": "leave_type", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Leave Type", + "options": "link:Leave Type", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "from_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "From Date", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "to_date", + "fieldtype": "Date", + "in_list_view": 0, + "label": "To Date", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "half_day", + "fieldtype": "Check", + "label": "Half Day", + "permlevel": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "label": "Reason", + "permlevel": 0 + }, + { + "fieldname": "employee", + "fieldtype": "Link", + "in_filter": 1, + "label": "Employee", + "options": "Employee", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "employee_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Employee Name", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "leave_balance", + "fieldtype": "Float", + "label": "Leave Balance Before Application", + "no_copy": 1, + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "total_leave_days", + "fieldtype": "Float", + "label": "Total Leave Days", + "no_copy": 1, + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "sb10", + "fieldtype": "Section Break", + "label": "More Info", + "permlevel": 0 + }, + { + "allow_on_submit": 1, + "default": "1", + "fieldname": "follow_via_email", + "fieldtype": "Check", + "label": "Follow via Email", + "permlevel": 0, + "print_hide": 1 + }, + { + "default": "Today", + "fieldname": "posting_date", + "fieldtype": "Date", + "label": "Posting Date", + "no_copy": 1, + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "options": "link:Fiscal Year", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "column_break_17", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "letter_head", + "fieldtype": "Link", + "label": "Letter Head", + "options": "Letter Head", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "options": "Leave Application", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "icon": "icon-calendar", + "idx": 1, + "is_submittable": 1, + "max_attachments": 3, + "modified": "2014-01-20 17:48:56.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Leave Application", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Employee", + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "permlevel": 1, + "read": 1, + "role": "All", + "submit": 0 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "restrict": 1, + "role": "HR User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Leave Approver", + "submit": 1, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "permlevel": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "permlevel": 1, + "read": 1, + "report": 1, + "role": "Leave Approver", + "submit": 0, + "write": 1 + } + ], + "search_fields": "employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 1630e1485e5..5de3495ff38 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -15,10 +15,10 @@ class InvalidLeaveApproverError(frappe.ValidationError): pass class LeaveApproverIdentityError(frappe.ValidationError): pass from frappe.model.controller import DocListController -class DocType(DocListController): +class LeaveApplication(DocListController): def setup(self): - if frappe.db.exists(self.doc.doctype, self.doc.name): - self.previous_doc = frappe.doc(self.doc.doctype, self.doc.name) + if not getattr(self, "__islocal", None) and frappe.db.exists(self.doctype, self.name): + self.previous_doc = frappe.db.get_value(self.doctype, self.name, "*", as_dict=True) else: self.previous_doc = None @@ -32,22 +32,22 @@ class DocType(DocListController): self.validate_leave_approver() def on_update(self): - if (not self.previous_doc and self.doc.leave_approver) or (self.previous_doc and \ - self.doc.status == "Open" and self.previous_doc.leave_approver != self.doc.leave_approver): + if (not self.previous_doc and self.leave_approver) or (self.previous_doc and \ + self.status == "Open" and self.previous_doc.leave_approver != self.leave_approver): # notify leave approver about creation self.notify_leave_approver() elif self.previous_doc and \ - self.previous_doc.status == "Open" and self.doc.status == "Rejected": + self.previous_doc.status == "Open" and self.status == "Rejected": # notify employee about rejection - self.notify_employee(self.doc.status) + self.notify_employee(self.status) def on_submit(self): - if self.doc.status != "Approved": + if self.status != "Approved": frappe.msgprint("""Only Leave Applications with status 'Approved' can be Submitted.""", raise_exception=True) # notify leave applier about approval - self.notify_employee(self.doc.status) + self.notify_employee(self.status) def on_cancel(self): # notify leave applier about cancellation @@ -56,8 +56,8 @@ class DocType(DocListController): def show_block_day_warning(self): from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates - block_dates = get_applicable_block_dates(self.doc.from_date, self.doc.to_date, - self.doc.employee, self.doc.company, all_lists=True) + block_dates = get_applicable_block_dates(self.from_date, self.to_date, + self.employee, self.company, all_lists=True) if block_dates: frappe.msgprint(_("Warning: Leave application contains following block dates") + ":") @@ -67,30 +67,30 @@ class DocType(DocListController): def validate_block_days(self): from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates - block_dates = get_applicable_block_dates(self.doc.from_date, self.doc.to_date, - self.doc.employee, self.doc.company) + block_dates = get_applicable_block_dates(self.from_date, self.to_date, + self.employee, self.company) if block_dates: - if self.doc.status == "Approved": + if self.status == "Approved": frappe.msgprint(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates.")) raise LeaveDayBlockedError def get_holidays(self): tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2, `tabEmployee` e1 where e1.name = %s and h1.parent = h2.name and e1.holiday_list = h2.name - and h1.holiday_date between %s and %s""", (self.doc.employee, self.doc.from_date, self.doc.to_date)) + and h1.holiday_date between %s and %s""", (self.employee, self.from_date, self.to_date)) if not tot_hol: tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2 where h1.parent = h2.name and h1.holiday_date between %s and %s and ifnull(h2.is_default,0) = 1 and h2.fiscal_year = %s""", - (self.doc.from_date, self.doc.to_date, self.doc.fiscal_year)) + (self.from_date, self.to_date, self.fiscal_year)) return tot_hol and flt(tot_hol[0][0]) or 0 def get_total_leave_days(self): """Calculates total leave days based on input and holidays""" ret = {'total_leave_days' : 0.5} - if not self.doc.half_day: - tot_days = date_diff(self.doc.to_date, self.doc.from_date) + 1 + if not self.half_day: + tot_days = date_diff(self.to_date, self.from_date) + 1 holidays = self.get_holidays() ret = { 'total_leave_days' : flt(tot_days)-flt(holidays) @@ -98,33 +98,33 @@ class DocType(DocListController): return ret def validate_to_date(self): - if self.doc.from_date and self.doc.to_date and \ - (getdate(self.doc.to_date) < getdate(self.doc.from_date)): + if self.from_date and self.to_date and \ + (getdate(self.to_date) < getdate(self.from_date)): msgprint("To date cannot be before from date") raise Exception def validate_balance_leaves(self): - if self.doc.from_date and self.doc.to_date: - self.doc.total_leave_days = self.get_total_leave_days()["total_leave_days"] + if self.from_date and self.to_date: + self.total_leave_days = self.get_total_leave_days()["total_leave_days"] - if self.doc.total_leave_days == 0: + if self.total_leave_days == 0: msgprint(_("The day(s) on which you are applying for leave coincide with holiday(s). You need not apply for leave."), raise_exception=1) - if not is_lwp(self.doc.leave_type): - self.doc.leave_balance = get_leave_balance(self.doc.employee, - self.doc.leave_type, self.doc.fiscal_year)["leave_balance"] + if not is_lwp(self.leave_type): + self.leave_balance = get_leave_balance(self.employee, + self.leave_type, self.fiscal_year)["leave_balance"] - if self.doc.status != "Rejected" \ - and self.doc.leave_balance - self.doc.total_leave_days < 0: + if self.status != "Rejected" \ + and self.leave_balance - self.total_leave_days < 0: #check if this leave type allow the remaining balance to be in negative. If yes then warn the user and continue to save else warn the user and don't save. msgprint("There is not enough leave balance for Leave Type: %s" % \ - (self.doc.leave_type,), - raise_exception=not(frappe.db.get_value("Leave Type", self.doc.leave_type,"allow_negative") or None)) + (self.leave_type,), + raise_exception=not(frappe.db.get_value("Leave Type", self.leave_type,"allow_negative") or None)) def validate_leave_overlap(self): - if not self.doc.name: - self.doc.name = "New Leave Application" + if not self.name: + self.name = "New Leave Application" for d in frappe.db.sql("""select name, leave_type, posting_date, from_date, to_date @@ -136,45 +136,45 @@ class DocType(DocListController): and (from_date between %(from_date)s and %(to_date)s or to_date between %(from_date)s and %(to_date)s or %(from_date)s between from_date and to_date) - and name != %(name)s""", self.doc.fields, as_dict = 1): + and name != %(name)s""", self.as_dict(), as_dict = 1): - msgprint("Employee : %s has already applied for %s between %s and %s on %s. Please refer Leave Application : %s" % (self.doc.employee, cstr(d['leave_type']), formatdate(d['from_date']), formatdate(d['to_date']), formatdate(d['posting_date']), d['name'], d['name']), raise_exception = OverlapError) + msgprint("Employee : %s has already applied for %s between %s and %s on %s. Please refer Leave Application : %s" % (self.employee, cstr(d['leave_type']), formatdate(d['from_date']), formatdate(d['to_date']), formatdate(d['posting_date']), d['name'], d['name']), raise_exception = OverlapError) def validate_max_days(self): - max_days = frappe.db.get_value("Leave Type", self.doc.leave_type, "max_days_allowed") - if max_days and self.doc.total_leave_days > max_days: + max_days = frappe.db.get_value("Leave Type", self.leave_type, "max_days_allowed") + if max_days and self.total_leave_days > max_days: frappe.throw("Sorry ! You cannot apply for %s for more than %s days" % - (self.doc.leave_type, max_days)) + (self.leave_type, max_days)) def validate_leave_approver(self): - employee = frappe.bean("Employee", self.doc.employee) + employee = frappe.get_doc("Employee", self.employee) leave_approvers = [l.leave_approver for l in - employee.doclist.get({"parentfield": "employee_leave_approvers"})] + employee.get("employee_leave_approvers")] - if len(leave_approvers) and self.doc.leave_approver not in leave_approvers: - msgprint(("[" + _("For Employee") + ' "' + self.doc.employee + '"] ' + if len(leave_approvers) and self.leave_approver not in leave_approvers: + msgprint(("[" + _("For Employee") + ' "' + self.employee + '"] ' + _("Leave Approver can be one of") + ": " + comma_or(leave_approvers)), raise_exception=InvalidLeaveApproverError) - elif self.doc.leave_approver and not frappe.db.sql("""select name from `tabUserRole` - where parent=%s and role='Leave Approver'""", self.doc.leave_approver): - msgprint(get_fullname(self.doc.leave_approver) + ": " \ + elif self.leave_approver and not frappe.db.sql("""select name from `tabUserRole` + where parent=%s and role='Leave Approver'""", self.leave_approver): + msgprint(get_fullname(self.leave_approver) + ": " \ + _("does not have role 'Leave Approver'"), raise_exception=InvalidLeaveApproverError) - elif self.doc.docstatus==1 and len(leave_approvers) and self.doc.leave_approver != frappe.session.user: + elif self.docstatus==1 and len(leave_approvers) and self.leave_approver != frappe.session.user: msgprint(_("Only the selected Leave Approver can submit this Leave Application"), raise_exception=LeaveApproverIdentityError) def notify_employee(self, status): - employee = frappe.doc("Employee", self.doc.employee) + employee = frappe.get_doc("Employee", self.employee) if not employee.user_id: return def _get_message(url=False): if url: - name = get_url_to_form(self.doc.doctype, self.doc.name) + name = get_url_to_form(self.doctype, self.name) else: - name = self.doc.name + name = self.name return (_("Leave Application") + ": %s - %s") % (name, _(status)) @@ -186,21 +186,21 @@ class DocType(DocListController): }) def notify_leave_approver(self): - employee = frappe.doc("Employee", self.doc.employee) + employee = frappe.get_doc("Employee", self.employee) def _get_message(url=False): - name = self.doc.name + name = self.name employee_name = cstr(employee.employee_name) if url: - name = get_url_to_form(self.doc.doctype, self.doc.name) - employee_name = get_url_to_form("Employee", self.doc.employee, label=employee_name) + name = get_url_to_form(self.doctype, self.name) + employee_name = get_url_to_form("Employee", self.employee, label=employee_name) return (_("New Leave Application") + ": %s - " + _("Employee") + ": %s") % (name, employee_name) self.notify({ # for post in messages "message": _get_message(url=True), - "message_to": self.doc.leave_approver, + "message_to": self.leave_approver, # for email "subject": _get_message() @@ -210,7 +210,7 @@ class DocType(DocListController): args = frappe._dict(args) from frappe.core.page.messages.messages import post post({"txt": args.message, "contact": args.message_to, "subject": args.subject, - "notify": cint(self.doc.follow_via_email)}) + "notify": cint(self.follow_via_email)}) @frappe.whitelist() def get_leave_balance(employee, leave_type, fiscal_year): diff --git a/erpnext/hr/doctype/leave_application/leave_application.txt b/erpnext/hr/doctype/leave_application/leave_application.txt deleted file mode 100644 index b56a0ed1204..00000000000 --- a/erpnext/hr/doctype/leave_application/leave_application.txt +++ /dev/null @@ -1,305 +0,0 @@ -[ - { - "creation": "2013-02-20 11:18:11", - "docstatus": 0, - "modified": "2014-01-20 17:48:56", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "autoname": "LAP/.#####", - "description": "Apply / Approve Leaves", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-calendar", - "is_submittable": 1, - "max_attachments": 3, - "module": "HR", - "name": "__common__", - "search_fields": "employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Leave Application", - "parentfield": "fields", - "parenttype": "DocType" - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "Leave Application", - "parentfield": "permissions", - "parenttype": "DocType", - "read": 1 - }, - { - "doctype": "DocType", - "name": "Leave Application" - }, - { - "default": "Open", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "options": "Open\nApproved\nRejected", - "permlevel": 1 - }, - { - "description": "Leave can be approved by users with Role, \"Leave Approver\"", - "doctype": "DocField", - "fieldname": "leave_approver", - "fieldtype": "Select", - "label": "Leave Approver", - "options": "link:User", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "leave_type", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Leave Type", - "options": "link:Leave Type", - "permlevel": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "from_date", - "fieldtype": "Date", - "in_list_view": 1, - "label": "From Date", - "permlevel": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "to_date", - "fieldtype": "Date", - "in_list_view": 0, - "label": "To Date", - "permlevel": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "half_day", - "fieldtype": "Check", - "label": "Half Day", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "permlevel": 0, - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "label": "Reason", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "employee", - "fieldtype": "Link", - "in_filter": 1, - "label": "Employee", - "options": "Employee", - "permlevel": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "employee_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Employee Name", - "permlevel": 0, - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "leave_balance", - "fieldtype": "Float", - "label": "Leave Balance Before Application", - "no_copy": 1, - "permlevel": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_leave_days", - "fieldtype": "Float", - "label": "Total Leave Days", - "no_copy": 1, - "permlevel": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "sb10", - "fieldtype": "Section Break", - "label": "More Info", - "permlevel": 0 - }, - { - "allow_on_submit": 1, - "default": "1", - "doctype": "DocField", - "fieldname": "follow_via_email", - "fieldtype": "Check", - "label": "Follow via Email", - "permlevel": 0, - "print_hide": 1 - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "label": "Posting Date", - "no_copy": 1, - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "options": "link:Fiscal Year", - "permlevel": 0, - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_17", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Link", - "label": "Letter Head", - "options": "Letter Head", - "permlevel": 0, - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "options": "Leave Application", - "permlevel": 0, - "print_hide": 1, - "read_only": 1 - }, - { - "create": 1, - "delete": 0, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "report": 1, - "role": "Employee", - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "All", - "submit": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "report": 1, - "restrict": 1, - "role": "HR User", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "report": 1, - "role": "Leave Approver", - "submit": 1, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "permlevel": 1, - "report": 1, - "role": "HR User", - "submit": 0, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "permlevel": 1, - "report": 1, - "role": "Leave Approver", - "submit": 0, - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 30f0cb7db9e..89c98332fbe 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -23,19 +23,18 @@ class TestLeaveApplication(unittest.TestCase): def _add_employee_leave_approver(self, employee, leave_approver): temp_session_user = frappe.session.user frappe.set_user("Administrator") - employee = frappe.bean("Employee", employee) - employee.doclist.append({ + employee = frappe.get_doc("Employee", employee) + employee.append("employee_leave_approvers", { "doctype": "Employee Leave Approver", - "parentfield": "employee_leave_approvers", "leave_approver": leave_approver }) employee.save() frappe.set_user(temp_session_user) - def get_application(self, doclist): - application = frappe.bean(copy=doclist) - application.doc.from_date = "2013-01-01" - application.doc.to_date = "2013-01-05" + def get_application(self, doc): + application = frappe.copy_doc(doc) + application.from_date = "2013-01-01" + application.to_date = "2013-01-05" return application def test_block_list(self): @@ -49,7 +48,7 @@ class TestLeaveApplication(unittest.TestCase): application = self.get_application(test_records[1]) application.insert() - application.doc.status = "Approved" + application.status = "Approved" self.assertRaises(LeaveDayBlockedError, application.submit) frappe.set_user("test1@example.com") @@ -70,11 +69,11 @@ class TestLeaveApplication(unittest.TestCase): frappe.set_user("test@example.com") application = self.get_application(test_records[1]) - application.doc.leave_approver = "test2@example.com" + application.leave_approver = "test2@example.com" application.insert() application = self.get_application(test_records[1]) - application.doc.leave_approver = "test2@example.com" + application.leave_approver = "test2@example.com" self.assertRaises(OverlapError, application.insert) def test_global_block_list(self): @@ -85,7 +84,7 @@ class TestLeaveApplication(unittest.TestCase): add_role("test@example.com", "Leave Approver") application = self.get_application(test_records[3]) - application.doc.leave_approver = "test@example.com" + application.leave_approver = "test@example.com" frappe.db.set_value("Leave Block List", "_Test Leave Block List", "applies_to_all_departments", 1) @@ -96,7 +95,7 @@ class TestLeaveApplication(unittest.TestCase): application.insert() frappe.set_user("test@example.com") - application.doc.status = "Approved" + application.status = "Approved" self.assertRaises(LeaveDayBlockedError, application.submit) frappe.db.set_value("Leave Block List", "_Test Leave Block List", @@ -121,14 +120,14 @@ class TestLeaveApplication(unittest.TestCase): # create leave application as Employee frappe.set_user("test@example.com") application = self.get_application(test_records[1]) - application.doc.leave_approver = "test1@example.com" + application.leave_approver = "test1@example.com" application.insert() # submit leave application by Leave Approver frappe.set_user("test1@example.com") - application.doc.status = "Approved" + application.status = "Approved" application.submit() - self.assertEqual(frappe.db.get_value("Leave Application", application.doc.name, + self.assertEqual(frappe.db.get_value("Leave Application", application.name, "docstatus"), 1) def _test_leave_approval_invalid_leave_approver_insert(self): @@ -144,7 +143,7 @@ class TestLeaveApplication(unittest.TestCase): application = self.get_application(test_records[1]) frappe.set_user("test@example.com") - application.doc.leave_approver = "test1@example.com" + application.leave_approver = "test1@example.com" self.assertRaises(InvalidLeaveApproverError, application.insert) frappe.db.sql("""delete from `tabEmployee Leave Approver` where parent=%s""", @@ -158,10 +157,10 @@ class TestLeaveApplication(unittest.TestCase): # but submit as invalid leave approver - should raise exception frappe.set_user("test@example.com") application = self.get_application(test_records[1]) - application.doc.leave_approver = "test2@example.com" + application.leave_approver = "test2@example.com" application.insert() frappe.set_user("test1@example.com") - application.doc.status = "Approved" + application.status = "Approved" from erpnext.hr.doctype.leave_application.leave_application import LeaveApproverIdentityError self.assertRaises(LeaveApproverIdentityError, application.submit) @@ -178,14 +177,14 @@ class TestLeaveApplication(unittest.TestCase): frappe.set_user("test@example.com") application = self.get_application(test_records[1]) - application.doc.leave_approver = "test2@example.com" + application.leave_approver = "test2@example.com" application.insert() # change to valid leave approver and try to submit leave application frappe.set_user("test2@example.com") - application.doc.status = "Approved" + application.status = "Approved" application.submit() - self.assertEqual(frappe.db.get_value("Leave Application", application.doc.name, + self.assertEqual(frappe.db.get_value("Leave Application", application.name, "docstatus"), 1) frappe.db.sql("""delete from `tabEmployee Leave Approver` where parent=%s""", @@ -195,51 +194,4 @@ class TestLeaveApplication(unittest.TestCase): test_dependencies = ["Leave Block List"] -test_records = [ - [{ - "doctype": "Leave Allocation", - "leave_type": "_Test Leave Type", - "fiscal_year": "_Test Fiscal Year 2013", - "employee":"_T-Employee-0001", - "new_leaves_allocated": 15, - "docstatus": 1 - }], - [{ - "doctype": "Leave Application", - "leave_type": "_Test Leave Type", - "from_date": "2013-05-01", - "to_date": "2013-05-05", - "posting_date": "2013-01-02", - "fiscal_year": "_Test Fiscal Year 2013", - "employee": "_T-Employee-0001", - "company": "_Test Company" - }], - [{ - "doctype": "Leave Allocation", - "leave_type": "_Test Leave Type", - "fiscal_year": "_Test Fiscal Year 2013", - "employee":"_T-Employee-0002", - "new_leaves_allocated": 15, - "docstatus": 1 - }], - [{ - "doctype": "Leave Application", - "leave_type": "_Test Leave Type", - "from_date": "2013-05-01", - "to_date": "2013-05-05", - "posting_date": "2013-01-02", - "fiscal_year": "_Test Fiscal Year 2013", - "employee": "_T-Employee-0002", - "company": "_Test Company" - }], - [{ - "doctype": "Leave Application", - "leave_type": "_Test Leave Type LWP", - "from_date": "2013-01-15", - "to_date": "2013-01-15", - "posting_date": "2013-01-02", - "fiscal_year": "_Test Fiscal Year 2013", - "employee": "_T-Employee-0001", - "company": "_Test Company", - }] -] +test_records = frappe.get_test_records('Leave Application') \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_application/test_records.json b/erpnext/hr/doctype/leave_application/test_records.json new file mode 100644 index 00000000000..aac41fb2352 --- /dev/null +++ b/erpnext/hr/doctype/leave_application/test_records.json @@ -0,0 +1,48 @@ +[ + { + "docstatus": 1, + "doctype": "Leave Allocation", + "employee": "_T-Employee-0001", + "fiscal_year": "_Test Fiscal Year 2013", + "leave_type": "_Test Leave Type", + "new_leaves_allocated": 15 + }, + { + "company": "_Test Company", + "doctype": "Leave Application", + "employee": "_T-Employee-0001", + "fiscal_year": "_Test Fiscal Year 2013", + "from_date": "2013-05-01", + "leave_type": "_Test Leave Type", + "posting_date": "2013-01-02", + "to_date": "2013-05-05" + }, + { + "docstatus": 1, + "doctype": "Leave Allocation", + "employee": "_T-Employee-0002", + "fiscal_year": "_Test Fiscal Year 2013", + "leave_type": "_Test Leave Type", + "new_leaves_allocated": 15 + }, + { + "company": "_Test Company", + "doctype": "Leave Application", + "employee": "_T-Employee-0002", + "fiscal_year": "_Test Fiscal Year 2013", + "from_date": "2013-05-01", + "leave_type": "_Test Leave Type", + "posting_date": "2013-01-02", + "to_date": "2013-05-05" + }, + { + "company": "_Test Company", + "doctype": "Leave Application", + "employee": "_T-Employee-0001", + "fiscal_year": "_Test Fiscal Year 2013", + "from_date": "2013-01-15", + "leave_type": "_Test Leave Type LWP", + "posting_date": "2013-01-02", + "to_date": "2013-01-15" + } +] \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list/leave_block_list.json b/erpnext/hr/doctype/leave_block_list/leave_block_list.json new file mode 100644 index 00000000000..cb3b6537a44 --- /dev/null +++ b/erpnext/hr/doctype/leave_block_list/leave_block_list.json @@ -0,0 +1,87 @@ +{ + "allow_import": 1, + "autoname": "field:leave_block_list_name", + "creation": "2013-02-18 17:43:12.000000", + "description": "Block Holidays on important days.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "leave_block_list_name", + "fieldtype": "Data", + "label": "Leave Block List Name", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "year", + "fieldtype": "Link", + "label": "Year", + "options": "Fiscal Year", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "If not checked, the list will have to be added to each Department where it has to be applied.", + "fieldname": "applies_to_all_departments", + "fieldtype": "Check", + "label": "Applies to Company", + "permlevel": 0 + }, + { + "description": "Stop users from making Leave Applications on following days.", + "fieldname": "block_days", + "fieldtype": "Section Break", + "label": "Block Days", + "permlevel": 0 + }, + { + "fieldname": "leave_block_list_dates", + "fieldtype": "Table", + "label": "Leave Block List Dates", + "options": "Leave Block List Date", + "permlevel": 0 + }, + { + "description": "Allow the following users to approve Leave Applications for block days.", + "fieldname": "allow_list", + "fieldtype": "Section Break", + "label": "Allow Users", + "permlevel": 0 + }, + { + "fieldname": "leave_block_list_allowed", + "fieldtype": "Table", + "label": "Leave Block List Allowed", + "options": "Leave Block List Allow", + "permlevel": 0 + } + ], + "icon": "icon-calendar", + "idx": 1, + "modified": "2013-12-20 19:24:13.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Leave Block List", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "HR User", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list/leave_block_list.py b/erpnext/hr/doctype/leave_block_list/leave_block_list.py index cdbb2d03753..e9bc6ab7f91 100644 --- a/erpnext/hr/doctype/leave_block_list/leave_block_list.py +++ b/erpnext/hr/doctype/leave_block_list/leave_block_list.py @@ -8,15 +8,15 @@ import frappe from erpnext.accounts.utils import validate_fiscal_year from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class LeaveBlockList(Document): def validate(self): dates = [] - for d in self.doclist.get({"doctype":"Leave Block List Date"}): + for d in self.get("leave_block_list_dates"): # validate fiscal year - validate_fiscal_year(d.block_date, self.doc.year, _("Block Date")) + validate_fiscal_year(d.block_date, self.year, _("Block Date")) # date is not repeated if d.block_date in dates: diff --git a/erpnext/hr/doctype/leave_block_list/leave_block_list.txt b/erpnext/hr/doctype/leave_block_list/leave_block_list.txt deleted file mode 100644 index 6f331b0c53f..00000000000 --- a/erpnext/hr/doctype/leave_block_list/leave_block_list.txt +++ /dev/null @@ -1,106 +0,0 @@ -[ - { - "creation": "2013-02-18 17:43:12", - "docstatus": 0, - "modified": "2013-12-20 19:24:13", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:leave_block_list_name", - "description": "Block Holidays on important days.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-calendar", - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Leave Block List", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Leave Block List", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "role": "HR User", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Leave Block List" - }, - { - "doctype": "DocField", - "fieldname": "leave_block_list_name", - "fieldtype": "Data", - "label": "Leave Block List Name", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "year", - "fieldtype": "Link", - "label": "Year", - "options": "Fiscal Year", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company", - "reqd": 1 - }, - { - "description": "If not checked, the list will have to be added to each Department where it has to be applied.", - "doctype": "DocField", - "fieldname": "applies_to_all_departments", - "fieldtype": "Check", - "label": "Applies to Company" - }, - { - "description": "Stop users from making Leave Applications on following days.", - "doctype": "DocField", - "fieldname": "block_days", - "fieldtype": "Section Break", - "label": "Block Days" - }, - { - "doctype": "DocField", - "fieldname": "leave_block_list_dates", - "fieldtype": "Table", - "label": "Leave Block List Dates", - "options": "Leave Block List Date" - }, - { - "description": "Allow the following users to approve Leave Applications for block days.", - "doctype": "DocField", - "fieldname": "allow_list", - "fieldtype": "Section Break", - "label": "Allow Users" - }, - { - "doctype": "DocField", - "fieldname": "leave_block_list_allowed", - "fieldtype": "Table", - "label": "Leave Block List Allowed", - "options": "Leave Block List Allow" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list/test_leave_block_list.py b/erpnext/hr/doctype/leave_block_list/test_leave_block_list.py index 811d8978276..88786587e4b 100644 --- a/erpnext/hr/doctype/leave_block_list/test_leave_block_list.py +++ b/erpnext/hr/doctype/leave_block_list/test_leave_block_list.py @@ -32,23 +32,4 @@ class TestLeaveBlockList(unittest.TestCase): test_dependencies = ["Employee"] -test_records = [[{ - "doctype":"Leave Block List", - "leave_block_list_name": "_Test Leave Block List", - "year": "_Test Fiscal Year 2013", - "company": "_Test Company" - }, { - "doctype": "Leave Block List Date", - "parent": "_Test Leave Block List", - "parenttype": "Leave Block List", - "parentfield": "leave_block_list_dates", - "block_date": "2013-01-02", - "reason": "First work day" - }, { - "doctype": "Leave Block List Allow", - "parent": "_Test Leave Block List", - "parenttype": "Leave Block List", - "parentfield": "leave_block_list_allowed", - "allow_user": "test1@example.com", - } - ]] \ No newline at end of file +test_records = frappe.get_test_records('Leave Block List') \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list/test_records.json b/erpnext/hr/doctype/leave_block_list/test_records.json new file mode 100644 index 00000000000..04565116d12 --- /dev/null +++ b/erpnext/hr/doctype/leave_block_list/test_records.json @@ -0,0 +1,27 @@ +[ + { + "company": "_Test Company", + "doctype": "Leave Block List", + "leave_block_list_allowed": [ + { + "allow_user": "test1@example.com", + "doctype": "Leave Block List Allow", + "parent": "_Test Leave Block List", + "parentfield": "leave_block_list_allowed", + "parenttype": "Leave Block List" + } + ], + "leave_block_list_dates": [ + { + "block_date": "2013-01-02", + "doctype": "Leave Block List Date", + "parent": "_Test Leave Block List", + "parentfield": "leave_block_list_dates", + "parenttype": "Leave Block List", + "reason": "First work day" + } + ], + "leave_block_list_name": "_Test Leave Block List", + "year": "_Test Fiscal Year 2013" + } +] \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.json b/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.json new file mode 100644 index 00000000000..bec2313b60c --- /dev/null +++ b/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.json @@ -0,0 +1,25 @@ +{ + "creation": "2013-02-22 01:27:47.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "allow_user", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Allow User", + "options": "User", + "permlevel": 0, + "print_width": "200px", + "reqd": 1, + "width": "200px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:18.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Leave Block List Allow", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py b/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py index 968a25b6134..684e178d5bb 100644 --- a/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py +++ b/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class LeaveBlockListAllow(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.txt b/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.txt deleted file mode 100644 index ea548004ce4..00000000000 --- a/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.txt +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:47", - "docstatus": 0, - "modified": "2013-12-20 19:23:18", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "allow_user", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Allow User", - "name": "__common__", - "options": "User", - "parent": "Leave Block List Allow", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "print_width": "200px", - "reqd": 1, - "width": "200px" - }, - { - "doctype": "DocType", - "name": "Leave Block List Allow" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.json b/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.json new file mode 100644 index 00000000000..f620501b492 --- /dev/null +++ b/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.json @@ -0,0 +1,34 @@ +{ + "creation": "2013-02-22 01:27:47.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "block_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Block Date", + "permlevel": 0, + "print_width": "200px", + "reqd": 1, + "width": "200px" + }, + { + "fieldname": "reason", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Reason", + "permlevel": 0, + "print_width": "200px", + "reqd": 1, + "width": "200px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:19.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Leave Block List Date", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py b/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py index 968a25b6134..3db479841e2 100644 --- a/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py +++ b/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class LeaveBlockListDate(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.txt b/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.txt deleted file mode 100644 index 138c9e47b58..00000000000 --- a/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.txt +++ /dev/null @@ -1,43 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:47", - "docstatus": 0, - "modified": "2013-12-20 19:23:19", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Leave Block List Date", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "print_width": "200px", - "reqd": 1, - "width": "200px" - }, - { - "doctype": "DocType", - "name": "Leave Block List Date" - }, - { - "doctype": "DocField", - "fieldname": "block_date", - "fieldtype": "Date", - "label": "Block Date" - }, - { - "doctype": "DocField", - "fieldname": "reason", - "fieldtype": "Text", - "label": "Reason" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js index be9096c23a7..16ede6782da 100644 --- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js +++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js @@ -9,7 +9,7 @@ cur_frm.cscript.onload = function(doc, dt, dn){ } cur_frm.cscript.to_date = function(doc, cdt, cdn) { - return $c('runserverobj', args={'method':'to_date_validation','docs':frappe.model.compress(make_doclist(doc.doctype, doc.name))}, + return $c('runserverobj', args={'method':'to_date_validation','docs':doc}, function(r, rt) { var doc = locals[cdt][cdn]; if (r.message) { diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.json b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.json new file mode 100644 index 00000000000..65fa38d80ad --- /dev/null +++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.json @@ -0,0 +1,122 @@ +{ + "allow_copy": 1, + "allow_email": 1, + "allow_print": 1, + "creation": "2013-01-10 16:34:15.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "description": "Leave blank if considered for all employee types", + "fieldname": "employee_type", + "fieldtype": "Select", + "label": "Employee Type", + "options": "link:Employment Type", + "permlevel": 0 + }, + { + "description": "Leave blank if considered for all branches", + "fieldname": "branch", + "fieldtype": "Select", + "label": "Branch", + "options": "link:Branch", + "permlevel": 0 + }, + { + "description": "Leave blank if considered for all departments", + "fieldname": "department", + "fieldtype": "Select", + "label": "Department", + "options": "link:Department", + "permlevel": 0 + }, + { + "description": "Leave blank if considered for all designations", + "fieldname": "designation", + "fieldtype": "Select", + "label": "Designation", + "options": "link:Designation", + "permlevel": 0 + }, + { + "description": "Leave blank if considered for all grades", + "fieldname": "grade", + "fieldtype": "Select", + "label": "Grade", + "options": "link:Grade", + "permlevel": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "options": "link:Fiscal Year", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "leave_type", + "fieldtype": "Select", + "label": "Leave Type", + "options": "link:Leave Type", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "Please select Carry Forward if you also want to include previous fiscal year's balance leaves to this fiscal year", + "fieldname": "carry_forward", + "fieldtype": "Check", + "label": "Carry Forward", + "permlevel": 0 + }, + { + "fieldname": "no_of_days", + "fieldtype": "Float", + "label": "New Leaves Allocated (In Days)", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "allocate", + "fieldtype": "Button", + "label": "Allocate", + "options": "allocate_leave", + "permlevel": 0 + } + ], + "hide_heading": 0, + "hide_toolbar": 0, + "icon": "icon-cog", + "idx": 1, + "issingle": 1, + "modified": "2013-07-05 14:44:50.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Leave Control Panel", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "permlevel": 0, + "read": 1, + "report": 0, + "role": "HR User", + "submit": 0, + "write": 1 + } + ], + "read_only": 1 +} \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py index 001d0d58483..4a8795affdf 100644 --- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py +++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py @@ -5,21 +5,16 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, cstr, flt, nowdate -from frappe.model.doc import Document -from frappe.model.code import get_obj from frappe import msgprint, _ -class DocType: - def __init__(self, doc, doclist): - self.doc = doc - self.doclist = doclist - +from frappe.model.document import Document +class LeaveControlPanel(Document): def get_employees(self): - lst1 = [[self.doc.employee_type,"employment_type"],[self.doc.branch,"branch"],[self.doc.designation,"designation"],[self.doc.department, "department"],[self.doc.grade,"grade"]] + lst1 = [[self.employee_type,"employment_type"],[self.branch,"branch"],[self.designation,"designation"],[self.department, "department"],[self.grade,"grade"]] condition = "where " flag = 0 for l in lst1: @@ -36,10 +31,9 @@ class DocType: return e def validate_values(self): - meta = frappe.get_doctype(self.doc.doctype) for f in ["fiscal_year", "leave_type", "no_of_days"]: - if not self.doc.fields[f]: - frappe.throw(_(meta.get_label(f)) + _(" is mandatory")) + if not self.get(f): + frappe.throw(_(self.meta.get_label(f)) + _(" is mandatory")) def allocate_leave(self): self.validate_values() @@ -50,19 +44,17 @@ class DocType: for d in self.get_employees(): try: - la = Document('Leave Allocation') + la = frappe.get_doc('Leave Allocation') + la.set("__islocal", 1) la.employee = cstr(d[0]) la.employee_name = frappe.db.get_value('Employee',cstr(d[0]),'employee_name') - la.leave_type = self.doc.leave_type - la.fiscal_year = self.doc.fiscal_year + la.leave_type = self.leave_type + la.fiscal_year = self.fiscal_year la.posting_date = nowdate() - la.carry_forward = cint(self.doc.carry_forward) - la.new_leaves_allocated = flt(self.doc.no_of_days) - la_obj = get_obj(doc=la) - la_obj.doc.docstatus = 1 - la_obj.validate() - la_obj.on_update() - la_obj.doc.save(1) + la.carry_forward = cint(self.carry_forward) + la.new_leaves_allocated = flt(self.no_of_days) + la.docstatus = 1 + la.save() leave_allocated_for.append(d[0]) except: pass diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.txt b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.txt deleted file mode 100644 index bee3123399a..00000000000 --- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.txt +++ /dev/null @@ -1,141 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:15", - "docstatus": 0, - "modified": "2013-07-05 14:44:50", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_copy": 1, - "allow_email": 1, - "allow_print": 1, - "doctype": "DocType", - "hide_heading": 0, - "hide_toolbar": 0, - "icon": "icon-cog", - "issingle": 1, - "module": "HR", - "name": "__common__", - "read_only": 1 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Leave Control Panel", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Leave Control Panel", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 0, - "role": "HR User", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Leave Control Panel" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "description": "Leave blank if considered for all employee types", - "doctype": "DocField", - "fieldname": "employee_type", - "fieldtype": "Select", - "label": "Employee Type", - "options": "link:Employment Type" - }, - { - "description": "Leave blank if considered for all branches", - "doctype": "DocField", - "fieldname": "branch", - "fieldtype": "Select", - "label": "Branch", - "options": "link:Branch" - }, - { - "description": "Leave blank if considered for all departments", - "doctype": "DocField", - "fieldname": "department", - "fieldtype": "Select", - "label": "Department", - "options": "link:Department" - }, - { - "description": "Leave blank if considered for all designations", - "doctype": "DocField", - "fieldname": "designation", - "fieldtype": "Select", - "label": "Designation", - "options": "link:Designation" - }, - { - "description": "Leave blank if considered for all grades", - "doctype": "DocField", - "fieldname": "grade", - "fieldtype": "Select", - "label": "Grade", - "options": "link:Grade" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "options": "link:Fiscal Year", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "leave_type", - "fieldtype": "Select", - "label": "Leave Type", - "options": "link:Leave Type", - "reqd": 1 - }, - { - "description": "Please select Carry Forward if you also want to include previous fiscal year's balance leaves to this fiscal year", - "doctype": "DocField", - "fieldname": "carry_forward", - "fieldtype": "Check", - "label": "Carry Forward" - }, - { - "doctype": "DocField", - "fieldname": "no_of_days", - "fieldtype": "Float", - "label": "New Leaves Allocated (In Days)", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "allocate", - "fieldtype": "Button", - "label": "Allocate", - "options": "allocate_leave" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_type/leave_type.json b/erpnext/hr/doctype/leave_type/leave_type.json new file mode 100644 index 00000000000..be3123f2e5b --- /dev/null +++ b/erpnext/hr/doctype/leave_type/leave_type.json @@ -0,0 +1,103 @@ +{ + "allow_import": 1, + "autoname": "field:leave_type_name", + "creation": "2013-02-21 09:55:58.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "leave_type_name", + "fieldtype": "Data", + "label": "Leave Type Name", + "oldfieldname": "leave_type_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "max_days_allowed", + "fieldtype": "Data", + "label": "Max Days Leave Allowed", + "oldfieldname": "max_days_allowed", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "is_carry_forward", + "fieldtype": "Check", + "label": "Is Carry Forward", + "oldfieldname": "is_carry_forward", + "oldfieldtype": "Check", + "permlevel": 0 + }, + { + "fieldname": "is_encash", + "fieldtype": "Check", + "hidden": 1, + "label": "Is Encash", + "oldfieldname": "is_encash", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + }, + { + "fieldname": "is_lwp", + "fieldtype": "Check", + "label": "Is LWP", + "permlevel": 0 + }, + { + "fieldname": "allow_negative", + "fieldtype": "Check", + "label": "Allow Negative Balance", + "permlevel": 0 + } + ], + "icon": "icon-flag", + "idx": 1, + "modified": "2014-01-20 17:48:56.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Leave Type", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_type/leave_type.py b/erpnext/hr/doctype/leave_type/leave_type.py index 5015bed79ce..426bc73ca58 100644 --- a/erpnext/hr/doctype/leave_type/leave_type.py +++ b/erpnext/hr/doctype/leave_type/leave_type.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - \ No newline at end of file +from frappe.model.document import Document + +class LeaveType(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_type/leave_type.txt b/erpnext/hr/doctype/leave_type/leave_type.txt deleted file mode 100644 index 13d7e725bed..00000000000 --- a/erpnext/hr/doctype/leave_type/leave_type.txt +++ /dev/null @@ -1,113 +0,0 @@ -[ - { - "creation": "2013-02-21 09:55:58", - "docstatus": 0, - "modified": "2014-01-20 17:48:56", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:leave_type_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-flag", - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Leave Type", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Leave Type", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Leave Type" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "leave_type_name", - "fieldtype": "Data", - "label": "Leave Type Name", - "oldfieldname": "leave_type_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "max_days_allowed", - "fieldtype": "Data", - "label": "Max Days Leave Allowed", - "oldfieldname": "max_days_allowed", - "oldfieldtype": "Data", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "is_carry_forward", - "fieldtype": "Check", - "label": "Is Carry Forward", - "oldfieldname": "is_carry_forward", - "oldfieldtype": "Check" - }, - { - "doctype": "DocField", - "fieldname": "is_encash", - "fieldtype": "Check", - "hidden": 1, - "label": "Is Encash", - "oldfieldname": "is_encash", - "oldfieldtype": "Check", - "print_hide": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "is_lwp", - "fieldtype": "Check", - "label": "Is LWP" - }, - { - "doctype": "DocField", - "fieldname": "allow_negative", - "fieldtype": "Check", - "label": "Allow Negative Balance" - }, - { - "doctype": "DocPerm", - "role": "HR User" - }, - { - "doctype": "DocPerm", - "role": "HR Manager" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_type/test_leave_type.py b/erpnext/hr/doctype/leave_type/test_leave_type.py index 50c3e795ccc..59fff57cc68 100644 --- a/erpnext/hr/doctype/leave_type/test_leave_type.py +++ b/erpnext/hr/doctype/leave_type/test_leave_type.py @@ -1,14 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "leave_type_name": "_Test Leave Type", - "doctype": "Leave Type" - }], - [{ - "leave_type_name": "_Test Leave Type LWP", - "doctype": "Leave Type", - "is_lwp": 1 - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Leave Type') \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_type/test_records.json b/erpnext/hr/doctype/leave_type/test_records.json new file mode 100644 index 00000000000..8042e30f528 --- /dev/null +++ b/erpnext/hr/doctype/leave_type/test_records.json @@ -0,0 +1,11 @@ +[ + { + "doctype": "Leave Type", + "leave_type_name": "_Test Leave Type" + }, + { + "doctype": "Leave Type", + "is_lwp": 1, + "leave_type_name": "_Test Leave Type LWP" + } +] \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_manager/salary_manager.js b/erpnext/hr/doctype/salary_manager/salary_manager.js index 312a06d5c2d..3745ee5a948 100644 --- a/erpnext/hr/doctype/salary_manager/salary_manager.js +++ b/erpnext/hr/doctype/salary_manager/salary_manager.js @@ -15,7 +15,7 @@ cur_frm.cscript.create_salary_slip = function(doc, cdt, cdn) { if (r.message) display_activity_log(r.message); } - return $c('runserverobj', args={'method':'create_sal_slip','docs':frappe.model.compress(make_doclist (cdt, cdn))},callback); + return $c('runserverobj', args={'method':'create_sal_slip','docs':doc},callback); } cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) { @@ -25,7 +25,7 @@ cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) { if (r.message) display_activity_log(r.message); } - return $c('runserverobj', args={'method':'submit_salary_slip','docs':frappe.model.compress(make_doclist (cdt, cdn))},callback); + return $c('runserverobj', args={'method':'submit_salary_slip','docs':doc},callback); } } @@ -59,5 +59,5 @@ cur_frm.cscript.make_jv = function(doc, dt, dn) { loaddoc('Journal Voucher', jv.name); } - return $c_obj(make_doclist(dt, dn), 'get_acc_details', '', call_back); + return $c_obj(doc, 'get_acc_details', '', call_back); } diff --git a/erpnext/hr/doctype/salary_manager/salary_manager.json b/erpnext/hr/doctype/salary_manager/salary_manager.json new file mode 100644 index 00000000000..7a65b3f1b06 --- /dev/null +++ b/erpnext/hr/doctype/salary_manager/salary_manager.json @@ -0,0 +1,166 @@ +{ + "allow_copy": 1, + "allow_email": 1, + "allow_print": 1, + "creation": "2012-03-27 14:35:59.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Other", + "fields": [ + { + "fieldname": "document_description", + "fieldtype": "HTML", + "label": "Document Description", + "options": "
You can generate multiple salary slips based on the selected criteria, submit and mail those to the employee directly from here
", + "permlevel": 0 + }, + { + "fieldname": "section_break0", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "company", + "fieldtype": "Select", + "label": "Company", + "options": "link:Company", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "branch", + "fieldtype": "Link", + "label": "Branch", + "options": "Branch", + "permlevel": 0 + }, + { + "fieldname": "department", + "fieldtype": "Link", + "label": "Department", + "options": "Department", + "permlevel": 0 + }, + { + "fieldname": "designation", + "fieldtype": "Link", + "label": "Designation", + "options": "Designation", + "permlevel": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "grade", + "fieldtype": "Select", + "label": "Grade", + "options": "link:Grade", + "permlevel": 0 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "label": "Fiscal Year", + "options": "link:Fiscal Year", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "month", + "fieldtype": "Select", + "label": "Month", + "options": "\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "Check if you want to send salary slip in mail to each employee while submitting salary slip", + "fieldname": "send_email", + "fieldtype": "Check", + "label": "Send Email", + "permlevel": 0 + }, + { + "fieldname": "section_break1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "description": "Creates salary slip for above mentioned criteria.", + "fieldname": "create_salary_slip", + "fieldtype": "Button", + "label": "Create Salary Slip", + "permlevel": 0 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "25%" + }, + { + "description": "Submit all salary slips for the above selected criteria", + "fieldname": "submit_salary_slip", + "fieldtype": "Button", + "label": "Submit Salary Slip", + "permlevel": 0 + }, + { + "fieldname": "column_break4", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "25%" + }, + { + "description": "Create Bank Voucher for the total salary paid for the above selected criteria", + "fieldname": "make_bank_voucher", + "fieldtype": "Button", + "label": "Make Bank Voucher", + "permlevel": 0 + }, + { + "fieldname": "section_break2", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "activity_log", + "fieldtype": "HTML", + "label": "Activity Log", + "permlevel": 0 + } + ], + "icon": "icon-cog", + "idx": 1, + "issingle": 1, + "modified": "2013-07-22 15:22:58.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Salary Manager", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "permlevel": 0, + "read": 1, + "role": "HR Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_manager/salary_manager.py b/erpnext/hr/doctype/salary_manager/salary_manager.py index 0420f774099..05d73c7f498 100644 --- a/erpnext/hr/doctype/salary_manager/salary_manager.py +++ b/erpnext/hr/doctype/salary_manager/salary_manager.py @@ -4,13 +4,11 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, flt -from frappe.model.code import get_obj from frappe import msgprint -class DocType: - def __init__(self, doc, doclist): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class SalaryManager(Document): def get_emp_list(self): """ @@ -36,14 +34,14 @@ class DocType: cond = '' for f in ['company', 'branch', 'department', 'designation', 'grade']: - if self.doc.fields.get(f): - cond += " and t1." + f + " = '" + self.doc.fields.get(f).replace("'", "\'") + "'" + if self.get(f): + cond += " and t1." + f + " = '" + self.get(f).replace("'", "\'") + "'" return cond def get_joining_releiving_condition(self): - m = self.get_month_details(self.doc.fiscal_year, self.doc.month) + m = self.get_month_details(self.fiscal_year, self.month) cond = """ and ifnull(t1.date_of_joining, '0000-00-00') <= '%(month_end_date)s' and ifnull(t1.relieving_date, '2199-12-31') >= '%(month_start_date)s' @@ -53,7 +51,7 @@ class DocType: def check_mandatory(self): for f in ['company', 'month', 'fiscal_year']: - if not self.doc.fields[f]: + if not self.get(f): msgprint("Please select %s to proceed" % f, raise_exception=1) @@ -86,17 +84,17 @@ class DocType: for emp in emp_list: if not frappe.db.sql("""select name from `tabSalary Slip` where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s - """, (emp[0], self.doc.month, self.doc.fiscal_year, self.doc.company)): - ss = frappe.bean({ + """, (emp[0], self.month, self.fiscal_year, self.company)): + ss = frappe.get_doc({ "doctype": "Salary Slip", - "fiscal_year": self.doc.fiscal_year, + "fiscal_year": self.fiscal_year, "employee": emp[0], - "month": self.doc.month, - "email_check": self.doc.send_email, - "company": self.doc.company, + "month": self.month, + "email_check": self.send_email, + "company": self.company, }) ss.insert() - ss_list.append(ss.doc.name) + ss_list.append(ss.name) return self.create_log(ss_list) @@ -118,7 +116,7 @@ class DocType: ss_list = frappe.db.sql(""" select t1.name from `tabSalary Slip` t1 where t1.docstatus = 0 and month = %s and fiscal_year = %s %s - """ % ('%s', '%s', cond), (self.doc.month, self.doc.fiscal_year)) + """ % ('%s', '%s', cond), (self.month, self.fiscal_year)) return ss_list @@ -129,13 +127,13 @@ class DocType: ss_list = self.get_sal_slip_list() not_submitted_ss = [] for ss in ss_list: - ss_obj = get_obj("Salary Slip",ss[0],with_children=1) + ss_obj = frappe.get_doc("Salary Slip",ss[0]) try: - frappe.db.set(ss_obj.doc, 'email_check', cint(self.doc.send_mail)) - if cint(self.doc.send_email) == 1: + frappe.db.set(ss_obj, 'email_check', cint(self.send_mail)) + if cint(self.send_email) == 1: ss_obj.send_mail_funct() - frappe.db.set(ss_obj.doc, 'docstatus', 1) + frappe.db.set(ss_obj, 'docstatus', 1) except Exception,e: not_submitted_ss.append(ss[0]) msgprint(e) @@ -153,7 +151,7 @@ class DocType: submitted_ss = list(set(all_ss) - set(not_submitted_ss)) if submitted_ss: - mail_sent_msg = self.doc.send_email and " (Mail has been sent to the employee)" or "" + mail_sent_msg = self.send_email and " (Mail has been sent to the employee)" or "" log = """ Submitted Salary Slips%s:\

%s

@@ -180,7 +178,7 @@ class DocType: tot = frappe.db.sql(""" select sum(rounded_total) from `tabSalary Slip` t1 where t1.docstatus = 1 and month = %s and fiscal_year = %s %s - """ % ('%s', '%s', cond), (self.doc.month, self.doc.fiscal_year)) + """ % ('%s', '%s', cond), (self.month, self.fiscal_year)) return flt(tot[0][0]) @@ -190,7 +188,7 @@ class DocType: get default bank account,default salary acount from company """ amt = self.get_total_salary() - default_bank_account = frappe.db.get_value("Company", self.doc.company, + default_bank_account = frappe.db.get_value("Company", self.company, "default_bank_account") if not default_bank_account: msgprint("You can set Default Bank Account in Company master.") diff --git a/erpnext/hr/doctype/salary_manager/salary_manager.txt b/erpnext/hr/doctype/salary_manager/salary_manager.txt deleted file mode 100644 index 423e7896355..00000000000 --- a/erpnext/hr/doctype/salary_manager/salary_manager.txt +++ /dev/null @@ -1,185 +0,0 @@ -[ - { - "creation": "2012-03-27 14:35:59", - "docstatus": 0, - "modified": "2013-07-22 15:22:58", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_copy": 1, - "allow_email": 1, - "allow_print": 1, - "doctype": "DocType", - "document_type": "Other", - "icon": "icon-cog", - "issingle": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Salary Manager", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Salary Manager", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "role": "HR Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Salary Manager" - }, - { - "doctype": "DocField", - "fieldname": "document_description", - "fieldtype": "HTML", - "label": "Document Description", - "options": "
You can generate multiple salary slips based on the selected criteria, submit and mail those to the employee directly from here
" - }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "label": "Company", - "options": "link:Company", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "branch", - "fieldtype": "Link", - "label": "Branch", - "options": "Branch" - }, - { - "doctype": "DocField", - "fieldname": "department", - "fieldtype": "Link", - "label": "Department", - "options": "Department" - }, - { - "doctype": "DocField", - "fieldname": "designation", - "fieldtype": "Link", - "label": "Designation", - "options": "Designation" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "grade", - "fieldtype": "Select", - "label": "Grade", - "options": "link:Grade" - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "label": "Fiscal Year", - "options": "link:Fiscal Year", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "month", - "fieldtype": "Select", - "label": "Month", - "options": "\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12", - "reqd": 1 - }, - { - "description": "Check if you want to send salary slip in mail to each employee while submitting salary slip", - "doctype": "DocField", - "fieldname": "send_email", - "fieldtype": "Check", - "label": "Send Email" - }, - { - "doctype": "DocField", - "fieldname": "section_break1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "description": "Creates salary slip for above mentioned criteria.", - "doctype": "DocField", - "fieldname": "create_salary_slip", - "fieldtype": "Button", - "label": "Create Salary Slip" - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "width": "25%" - }, - { - "description": "Submit all salary slips for the above selected criteria", - "doctype": "DocField", - "fieldname": "submit_salary_slip", - "fieldtype": "Button", - "label": "Submit Salary Slip" - }, - { - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "width": "25%" - }, - { - "description": "Create Bank Voucher for the total salary paid for the above selected criteria", - "doctype": "DocField", - "fieldname": "make_bank_voucher", - "fieldtype": "Button", - "label": "Make Bank Voucher" - }, - { - "doctype": "DocField", - "fieldname": "section_break2", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "activity_log", - "fieldtype": "HTML", - "label": "Activity Log" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.js b/erpnext/hr/doctype/salary_slip/salary_slip.js index ceab14843ec..3c11f9d073a 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.js +++ b/erpnext/hr/doctype/salary_slip/salary_slip.js @@ -21,7 +21,7 @@ cur_frm.cscript.onload = function(doc,dt,dn){ // Get leave details //--------------------------------------------------------------------- cur_frm.cscript.fiscal_year = function(doc,dt,dn){ - return $c_obj(make_doclist(doc.doctype,doc.name), 'get_emp_and_leave_details','',function(r, rt) { + return $c_obj(doc, 'get_emp_and_leave_details','',function(r, rt) { var doc = locals[dt][dn]; cur_frm.refresh(); calculate_all(doc, dt, dn); @@ -32,7 +32,7 @@ cur_frm.cscript.month = cur_frm.cscript.employee = cur_frm.cscript.fiscal_year; cur_frm.cscript.leave_without_pay = function(doc,dt,dn){ if (doc.employee && doc.fiscal_year && doc.month) { - return $c_obj(make_doclist(doc.doctype,doc.name), 'get_leave_details',doc.leave_without_pay,function(r, rt) { + return $c_obj(doc, 'get_leave_details',doc.leave_without_pay,function(r, rt) { var doc = locals[dt][dn]; cur_frm.refresh(); calculate_all(doc, dt, dn); @@ -65,7 +65,7 @@ cur_frm.cscript.d_depends_on_lwp = cur_frm.cscript.d_modified_amount; // Calculate earning total // ------------------------------------------------------------------------ var calculate_earning_total = function(doc, dt, dn) { - var tbl = getchildren('Salary Slip Earning', doc.name, 'earning_details', doc.doctype); + var tbl = doc.earning_details || []; var total_earn = 0; for(var i = 0; i < tbl.length; i++){ @@ -82,7 +82,7 @@ var calculate_earning_total = function(doc, dt, dn) { // Calculate deduction total // ------------------------------------------------------------------------ var calculate_ded_total = function(doc, dt, dn) { - var tbl = getchildren('Salary Slip Deduction', doc.name, 'deduction_details', doc.doctype); + var tbl = doc.deduction_details || []; var total_ded = 0; for(var i = 0; i < tbl.length; i++){ diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.json b/erpnext/hr/doctype/salary_slip/salary_slip.json new file mode 100644 index 00000000000..2896f11f50f --- /dev/null +++ b/erpnext/hr/doctype/salary_slip/salary_slip.json @@ -0,0 +1,392 @@ +{ + "creation": "2013-01-10 16:34:15.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "employee", + "fieldtype": "Link", + "in_filter": 1, + "label": "Employee", + "oldfieldname": "employee", + "oldfieldtype": "Link", + "options": "Employee", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "employee_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Employee Name", + "oldfieldname": "employee_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "department", + "fieldtype": "Link", + "in_filter": 1, + "label": "Department", + "oldfieldname": "department", + "oldfieldtype": "Link", + "options": "Department", + "permlevel": 0, + "read_only": 1, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "designation", + "fieldtype": "Link", + "in_filter": 1, + "label": "Designation", + "oldfieldname": "designation", + "oldfieldtype": "Link", + "options": "Designation", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "branch", + "fieldtype": "Link", + "in_filter": 1, + "label": "Branch", + "oldfieldname": "branch", + "oldfieldtype": "Link", + "options": "Branch", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "grade", + "fieldtype": "Link", + "in_filter": 1, + "label": "Grade", + "oldfieldname": "grade", + "oldfieldtype": "Link", + "options": "Grade", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "pf_no", + "fieldtype": "Data", + "label": "PF No.", + "oldfieldname": "pf_no", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "esic_no", + "fieldtype": "Data", + "label": "ESIC No.", + "oldfieldname": "esic_no", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "letter_head", + "fieldtype": "Link", + "label": "Letter Head", + "options": "Letter Head", + "permlevel": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Data", + "options": "Fiscal Year", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "company", + "fieldtype": "Select", + "in_filter": 1, + "label": "Company", + "options": "link:Company", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "month", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Month", + "oldfieldname": "month", + "oldfieldtype": "Select", + "options": "\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12", + "permlevel": 0, + "reqd": 1, + "search_index": 1, + "width": "37%" + }, + { + "fieldname": "total_days_in_month", + "fieldtype": "Data", + "label": "Total Working Days In The Month", + "oldfieldname": "total_days_in_month", + "oldfieldtype": "Int", + "permlevel": 0, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "leave_without_pay", + "fieldtype": "Float", + "label": "Leave Without Pay", + "oldfieldname": "leave_without_pay", + "oldfieldtype": "Currency", + "permlevel": 0 + }, + { + "fieldname": "payment_days", + "fieldtype": "Float", + "label": "Payment Days", + "oldfieldname": "payment_days", + "oldfieldtype": "Float", + "permlevel": 0, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "bank_name", + "fieldtype": "Data", + "label": "Bank Name", + "oldfieldname": "bank_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "bank_account_no", + "fieldtype": "Data", + "label": "Bank Account No.", + "oldfieldname": "bank_account_no", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "email_check", + "fieldtype": "Check", + "label": "Email", + "no_copy": 1, + "oldfieldname": "email_check", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "hidden": 0, + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "report_hide": 0 + }, + { + "fieldname": "earning_deduction", + "fieldtype": "Section Break", + "label": "Earning & Deduction", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "earning", + "fieldtype": "Column Break", + "label": "Earning", + "oldfieldtype": "Column Break", + "permlevel": 0, + "reqd": 0, + "width": "50%" + }, + { + "fieldname": "earning_details", + "fieldtype": "Table", + "label": "Salary Structure Earnings", + "oldfieldname": "earning_details", + "oldfieldtype": "Table", + "options": "Salary Slip Earning", + "permlevel": 0 + }, + { + "fieldname": "deduction", + "fieldtype": "Column Break", + "label": "Deduction", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "deduction_details", + "fieldtype": "Table", + "label": "Deductions", + "oldfieldname": "deduction_details", + "oldfieldtype": "Table", + "options": "Salary Slip Deduction", + "permlevel": 0 + }, + { + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "Totals", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "arrear_amount", + "fieldtype": "Currency", + "label": "Arrear Amount", + "oldfieldname": "arrear_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "leave_encashment_amount", + "fieldtype": "Currency", + "label": "Leave Encashment Amount", + "oldfieldname": "encashment_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "gross_pay", + "fieldtype": "Currency", + "label": "Gross Pay", + "oldfieldname": "gross_pay", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "total_deduction", + "fieldtype": "Currency", + "label": "Total Deduction", + "oldfieldname": "total_deduction", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "description": "Gross Pay + Arrear Amount +Encashment Amount - Total Deduction", + "fieldname": "net_pay", + "fieldtype": "Currency", + "label": "Net Pay", + "oldfieldname": "net_pay", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "description": "Net Pay (in words) will be visible once you save the Salary Slip.", + "fieldname": "total_in_words", + "fieldtype": "Data", + "label": "Total in words", + "oldfieldname": "net_pay_in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-file-text", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:49:18.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Salary Slip", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR Manager", + "submit": 1, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index a264c1c2d5b..8c340375161 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -5,25 +5,20 @@ from __future__ import unicode_literals import frappe from frappe.utils import add_days, cint, cstr, flt, getdate, nowdate, _round -from frappe.model.doc import make_autoname -from frappe.model.bean import getlist -from frappe.model.code import get_obj +from frappe.model.naming import make_autoname + from frappe import msgprint, _ from erpnext.setup.utils import get_company_currency from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self,doc,doclist=[]): - self.doc = doc - self.doclist = doclist - +class SalarySlip(TransactionBase): def autoname(self): - self.doc.name = make_autoname('Sal Slip/' +self.doc.employee + '/.#####') + self.name = make_autoname('Sal Slip/' +self.employee + '/.#####') def get_emp_and_leave_details(self): - if self.doc.employee: + if self.employee: self.get_leave_details() struct = self.check_sal_struct() if struct: @@ -31,32 +26,32 @@ class DocType(TransactionBase): def check_sal_struct(self): struct = frappe.db.sql("""select name from `tabSalary Structure` - where employee=%s and is_active = 'Yes'""", self.doc.employee) + where employee=%s and is_active = 'Yes'""", self.employee) if not struct: - msgprint("Please create Salary Structure for employee '%s'" % self.doc.employee) - self.doc.employee = None + msgprint("Please create Salary Structure for employee '%s'" % self.employee) + self.employee = None return struct and struct[0][0] or '' def pull_sal_struct(self, struct): - from erpnext.hr.doctype.salary_structure.salary_structure import get_mapped_doclist - self.doclist = get_mapped_doclist(struct, self.doclist) + from erpnext.hr.doctype.salary_structure.salary_structure import get_mapped_doc + self.update(get_mapped_doc(struct, self)) def pull_emp_details(self): - emp = frappe.db.get_value("Employee", self.doc.employee, + emp = frappe.db.get_value("Employee", self.employee, ["bank_name", "bank_ac_no", "esic_card_no", "pf_number"], as_dict=1) if emp: - self.doc.bank_name = emp.bank_name - self.doc.bank_account_no = emp.bank_ac_no - self.doc.esic_no = emp.esic_card_no - self.doc.pf_no = emp.pf_number + self.bank_name = emp.bank_name + self.bank_account_no = emp.bank_ac_no + self.esic_no = emp.esic_card_no + self.pf_no = emp.pf_number def get_leave_details(self, lwp=None): - if not self.doc.fiscal_year: - self.doc.fiscal_year = frappe.get_default("fiscal_year") - if not self.doc.month: - self.doc.month = "%02d" % getdate(nowdate()).month + if not self.fiscal_year: + self.fiscal_year = frappe.get_default("fiscal_year") + if not self.month: + self.month = "%02d" % getdate(nowdate()).month - m = get_obj('Salary Manager').get_month_details(self.doc.fiscal_year, self.doc.month) + m = frappe.get_doc('Salary Manager').get_month_details(self.fiscal_year, self.month) holidays = self.get_holidays_for_employee(m) if not cint(frappe.db.get_value("HR Settings", "HR Settings", @@ -68,16 +63,16 @@ class DocType(TransactionBase): if not lwp: lwp = self.calculate_lwp(holidays, m) - self.doc.total_days_in_month = m['month_days'] - self.doc.leave_without_pay = lwp + self.total_days_in_month = m['month_days'] + self.leave_without_pay = lwp payment_days = flt(self.get_payment_days(m)) - flt(lwp) - self.doc.payment_days = payment_days > 0 and payment_days or 0 + self.payment_days = payment_days > 0 and payment_days or 0 def get_payment_days(self, m): payment_days = m['month_days'] emp = frappe.db.sql("select date_of_joining, relieving_date from `tabEmployee` \ - where name = %s", self.doc.employee, as_dict=1)[0] + where name = %s", self.employee, as_dict=1)[0] if emp['relieving_date']: if getdate(emp['relieving_date']) > m['month_start_date'] and \ @@ -102,13 +97,13 @@ class DocType(TransactionBase): from `tabHoliday` t1, tabEmployee t2 where t1.parent = t2.holiday_list and t2.name = %s and t1.holiday_date between %s and %s""", - (self.doc.employee, m['month_start_date'], m['month_end_date'])) + (self.employee, m['month_start_date'], m['month_end_date'])) if not holidays: holidays = frappe.db.sql("""select t1.holiday_date from `tabHoliday` t1, `tabHoliday List` t2 where t1.parent = t2.name and ifnull(t2.is_default, 0) = 1 and t2.fiscal_year = %s - and t1.holiday_date between %s and %s""", (self.doc.fiscal_year, + and t1.holiday_date between %s and %s""", (self.fiscal_year, m['month_start_date'], m['month_end_date'])) holidays = [cstr(i[0]) for i in holidays] return holidays @@ -126,7 +121,7 @@ class DocType(TransactionBase): and t1.docstatus = 1 and t1.employee = %s and %s between from_date and to_date - """, (self.doc.employee, dt)) + """, (self.employee, dt)) if leave: lwp = cint(leave[0][1]) and (lwp + 0.5) or (lwp + 1) return lwp @@ -135,74 +130,74 @@ class DocType(TransactionBase): ret_exist = frappe.db.sql("""select name from `tabSalary Slip` where month = %s and fiscal_year = %s and docstatus != 2 and employee = %s and name != %s""", - (self.doc.month, self.doc.fiscal_year, self.doc.employee, self.doc.name)) + (self.month, self.fiscal_year, self.employee, self.name)) if ret_exist: - self.doc.employee = '' + self.employee = '' msgprint("Salary Slip of employee '%s' already created for this month" - % self.doc.employee, raise_exception=1) + % self.employee, raise_exception=1) def validate(self): from frappe.utils import money_in_words self.check_existing() - if not (len(self.doclist.get({"parentfield": "earning_details"})) or - len(self.doclist.get({"parentfield": "deduction_details"}))): + if not (len(self.get("earning_details")) or + len(self.get("deduction_details"))): self.get_emp_and_leave_details() else: - self.get_leave_details(self.doc.leave_without_pay) + self.get_leave_details(self.leave_without_pay) - if not self.doc.net_pay: + if not self.net_pay: self.calculate_net_pay() - company_currency = get_company_currency(self.doc.company) - self.doc.total_in_words = money_in_words(self.doc.rounded_total, company_currency) + company_currency = get_company_currency(self.company) + self.total_in_words = money_in_words(self.rounded_total, company_currency) def calculate_earning_total(self): - self.doc.gross_pay = flt(self.doc.arrear_amount) + flt(self.doc.leave_encashment_amount) - for d in self.doclist.get({"parentfield": "earning_details"}): + self.gross_pay = flt(self.arrear_amount) + flt(self.leave_encashment_amount) + for d in self.get("earning_details"): if cint(d.e_depends_on_lwp) == 1: - d.e_modified_amount = _round(flt(d.e_amount) * flt(self.doc.payment_days) - / cint(self.doc.total_days_in_month), 2) - elif not self.doc.payment_days: + d.e_modified_amount = _round(flt(d.e_amount) * flt(self.payment_days) + / cint(self.total_days_in_month), 2) + elif not self.payment_days: d.e_modified_amount = 0 else: d.e_modified_amount = d.e_amount - self.doc.gross_pay += flt(d.e_modified_amount) + self.gross_pay += flt(d.e_modified_amount) def calculate_ded_total(self): - self.doc.total_deduction = 0 - for d in getlist(self.doclist, 'deduction_details'): + self.total_deduction = 0 + for d in self.get('deduction_details'): if cint(d.d_depends_on_lwp) == 1: - d.d_modified_amount = _round(flt(d.d_amount) * flt(self.doc.payment_days) - / cint(self.doc.total_days_in_month), 2) - elif not self.doc.payment_days: + d.d_modified_amount = _round(flt(d.d_amount) * flt(self.payment_days) + / cint(self.total_days_in_month), 2) + elif not self.payment_days: d.d_modified_amount = 0 else: d.d_modified_amount = d.d_amount - self.doc.total_deduction += flt(d.d_modified_amount) + self.total_deduction += flt(d.d_modified_amount) def calculate_net_pay(self): self.calculate_earning_total() self.calculate_ded_total() - self.doc.net_pay = flt(self.doc.gross_pay) - flt(self.doc.total_deduction) - self.doc.rounded_total = _round(self.doc.net_pay) + self.net_pay = flt(self.gross_pay) - flt(self.total_deduction) + self.rounded_total = _round(self.net_pay) def on_submit(self): - if(self.doc.email_check == 1): + if(self.email_check == 1): self.send_mail_funct() def send_mail_funct(self): from frappe.utils.email_lib import sendmail - receiver = frappe.db.get_value("Employee", self.doc.employee, "company_email") + receiver = frappe.db.get_value("Employee", self.employee, "company_email") if receiver: - subj = 'Salary Slip - ' + cstr(self.doc.month) +'/'+cstr(self.doc.fiscal_year) + subj = 'Salary Slip - ' + cstr(self.month) +'/'+cstr(self.fiscal_year) earn_ret=frappe.db.sql("""select e_type, e_modified_amount from `tabSalary Slip Earning` - where parent = %s""", self.doc.name) + where parent = %s""", self.name) ded_ret=frappe.db.sql("""select d_type, d_modified_amount from `tabSalary Slip Deduction` - where parent = %s""", self.doc.name) + where parent = %s""", self.name) earn_table = '' ded_table = '' @@ -292,13 +287,13 @@ class DocType(TransactionBase):
Net Pay(in words) : %s
''' % (cstr(letter_head), cstr(self.doc.employee), - cstr(self.doc.employee_name), cstr(self.doc.month), cstr(self.doc.fiscal_year), - cstr(self.doc.department), cstr(self.doc.branch), cstr(self.doc.designation), - cstr(self.doc.grade), cstr(self.doc.bank_account_no), cstr(self.doc.bank_name), - cstr(self.doc.arrear_amount), cstr(self.doc.payment_days), earn_table, ded_table, - cstr(flt(self.doc.gross_pay)), cstr(flt(self.doc.total_deduction)), - cstr(flt(self.doc.net_pay)), cstr(self.doc.total_in_words)) +
''' % (cstr(letter_head), cstr(self.employee), + cstr(self.employee_name), cstr(self.month), cstr(self.fiscal_year), + cstr(self.department), cstr(self.branch), cstr(self.designation), + cstr(self.grade), cstr(self.bank_account_no), cstr(self.bank_name), + cstr(self.arrear_amount), cstr(self.payment_days), earn_table, ded_table, + cstr(flt(self.gross_pay)), cstr(flt(self.total_deduction)), + cstr(flt(self.net_pay)), cstr(self.total_in_words)) sendmail([receiver], subject=subj, msg = msg) else: diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.txt b/erpnext/hr/doctype/salary_slip/salary_slip.txt deleted file mode 100644 index e47e8d834e4..00000000000 --- a/erpnext/hr/doctype/salary_slip/salary_slip.txt +++ /dev/null @@ -1,404 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:15", - "docstatus": 0, - "modified": "2014-01-20 17:49:18", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "icon": "icon-file-text", - "is_submittable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Salary Slip", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Salary Slip", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Salary Slip" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "employee", - "fieldtype": "Link", - "in_filter": 1, - "label": "Employee", - "oldfieldname": "employee", - "oldfieldtype": "Link", - "options": "Employee", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "employee_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Employee Name", - "oldfieldname": "employee_name", - "oldfieldtype": "Data", - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "department", - "fieldtype": "Link", - "in_filter": 1, - "label": "Department", - "oldfieldname": "department", - "oldfieldtype": "Link", - "options": "Department", - "read_only": 1, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "designation", - "fieldtype": "Link", - "in_filter": 1, - "label": "Designation", - "oldfieldname": "designation", - "oldfieldtype": "Link", - "options": "Designation", - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "branch", - "fieldtype": "Link", - "in_filter": 1, - "label": "Branch", - "oldfieldname": "branch", - "oldfieldtype": "Link", - "options": "Branch", - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "grade", - "fieldtype": "Link", - "in_filter": 1, - "label": "Grade", - "oldfieldname": "grade", - "oldfieldtype": "Link", - "options": "Grade", - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "pf_no", - "fieldtype": "Data", - "label": "PF No.", - "oldfieldname": "pf_no", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "esic_no", - "fieldtype": "Data", - "label": "ESIC No.", - "oldfieldname": "esic_no", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Link", - "label": "Letter Head", - "options": "Letter Head" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Data", - "options": "Fiscal Year", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "in_filter": 1, - "label": "Company", - "options": "link:Company", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "month", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Month", - "oldfieldname": "month", - "oldfieldtype": "Select", - "options": "\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12", - "reqd": 1, - "search_index": 1, - "width": "37%" - }, - { - "doctype": "DocField", - "fieldname": "total_days_in_month", - "fieldtype": "Data", - "label": "Total Working Days In The Month", - "oldfieldname": "total_days_in_month", - "oldfieldtype": "Int", - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "leave_without_pay", - "fieldtype": "Float", - "label": "Leave Without Pay", - "oldfieldname": "leave_without_pay", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "payment_days", - "fieldtype": "Float", - "label": "Payment Days", - "oldfieldname": "payment_days", - "oldfieldtype": "Float", - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "bank_name", - "fieldtype": "Data", - "label": "Bank Name", - "oldfieldname": "bank_name", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "bank_account_no", - "fieldtype": "Data", - "label": "Bank Account No.", - "oldfieldname": "bank_account_no", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "email_check", - "fieldtype": "Check", - "label": "Email", - "no_copy": 1, - "oldfieldname": "email_check", - "oldfieldtype": "Check", - "print_hide": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "hidden": 0, - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "earning_deduction", - "fieldtype": "Section Break", - "label": "Earning & Deduction", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "earning", - "fieldtype": "Column Break", - "label": "Earning", - "oldfieldtype": "Column Break", - "reqd": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "earning_details", - "fieldtype": "Table", - "label": "Salary Structure Earnings", - "oldfieldname": "earning_details", - "oldfieldtype": "Table", - "options": "Salary Slip Earning" - }, - { - "doctype": "DocField", - "fieldname": "deduction", - "fieldtype": "Column Break", - "label": "Deduction", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "deduction_details", - "fieldtype": "Table", - "label": "Deductions", - "oldfieldname": "deduction_details", - "oldfieldtype": "Table", - "options": "Salary Slip Deduction" - }, - { - "doctype": "DocField", - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "Totals", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "arrear_amount", - "fieldtype": "Currency", - "label": "Arrear Amount", - "oldfieldname": "arrear_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "leave_encashment_amount", - "fieldtype": "Currency", - "label": "Leave Encashment Amount", - "oldfieldname": "encashment_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "gross_pay", - "fieldtype": "Currency", - "label": "Gross Pay", - "oldfieldname": "gross_pay", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_deduction", - "fieldtype": "Currency", - "label": "Total Deduction", - "oldfieldname": "total_deduction", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "description": "Gross Pay + Arrear Amount +Encashment Amount - Total Deduction", - "doctype": "DocField", - "fieldname": "net_pay", - "fieldtype": "Currency", - "label": "Net Pay", - "oldfieldname": "net_pay", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "description": "Net Pay (in words) will be visible once you save the Salary Slip.", - "doctype": "DocField", - "fieldname": "total_in_words", - "fieldtype": "Data", - "label": "Total in words", - "oldfieldname": "net_pay_in_words", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "amend": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "HR User" - }, - { - "amend": 1, - "cancel": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "HR Manager" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip/test_records.json b/erpnext/hr/doctype/salary_slip/test_records.json new file mode 100644 index 00000000000..3e750cf462b --- /dev/null +++ b/erpnext/hr/doctype/salary_slip/test_records.json @@ -0,0 +1,44 @@ +[ + { + "company": "_Test Company", + "deduction_details": [ + { + "d_amount": 100, + "d_depends_on_lwp": 0, + "d_type": "_Test Professional Tax", + "doctype": "Salary Slip Deduction", + "parentfield": "deduction_details" + }, + { + "d_amount": 50, + "d_depends_on_lwp": 1, + "d_type": "_Test TDS", + "doctype": "Salary Slip Deduction", + "parentfield": "deduction_details" + } + ], + "doctype": "Salary Slip", + "earning_details": [ + { + "doctype": "Salary Slip Earning", + "e_amount": 15000, + "e_depends_on_lwp": 1, + "e_type": "_Test Basic Salary", + "parentfield": "earning_details" + }, + { + "doctype": "Salary Slip Earning", + "e_amount": 500, + "e_depends_on_lwp": 0, + "e_type": "_Test Allowance", + "parentfield": "earning_details" + } + ], + "employee": "_T-Employee-0001", + "employee_name": "_Test Employee", + "fiscal_year": "_Test Fiscal Year 2013", + "month": "01", + "payment_days": 31, + "total_days_in_month": 31 + } +] \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py index b667f9cd951..e8c978e639e 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -9,9 +9,9 @@ class TestSalarySlip(unittest.TestCase): frappe.db.sql("""delete from `tabLeave Application`""") frappe.db.sql("""delete from `tabSalary Slip`""") from erpnext.hr.doctype.leave_application.test_leave_application import test_records as leave_applications - la = frappe.bean(copy=leave_applications[4]) + la = frappe.copy_doc(leave_applications[4]) la.insert() - la.doc.status = "Approved" + la.status = "Approved" la.submit() def tearDown(self): @@ -19,70 +19,29 @@ class TestSalarySlip(unittest.TestCase): def test_salary_slip_with_holidays_included(self): frappe.db.set_value("HR Settings", "HR Settings", "include_holidays_in_total_working_days", 1) - ss = frappe.bean(copy=test_records[0]) + ss = frappe.copy_doc(test_records[0]) ss.insert() - self.assertEquals(ss.doc.total_days_in_month, 31) - self.assertEquals(ss.doc.payment_days, 30) - self.assertEquals(ss.doclist[1].e_modified_amount, 14516.13) - self.assertEquals(ss.doclist[2].e_modified_amount, 500) - self.assertEquals(ss.doclist[3].d_modified_amount, 100) - self.assertEquals(ss.doclist[4].d_modified_amount, 48.39) - self.assertEquals(ss.doc.gross_pay, 15016.13) - self.assertEquals(ss.doc.net_pay, 14867.74) + self.assertEquals(ss.total_days_in_month, 31) + self.assertEquals(ss.payment_days, 30) + self.assertEquals(ss.earning_details[0].e_modified_amount, 14516.13) + self.assertEquals(ss.earning_details[1].e_modified_amount, 500) + self.assertEquals(ss.deduction_details[0].d_modified_amount, 100) + self.assertEquals(ss.deduction_details[1].d_modified_amount, 48.39) + self.assertEquals(ss.gross_pay, 15016.13) + self.assertEquals(ss.net_pay, 14867.74) def test_salary_slip_with_holidays_excluded(self): - ss = frappe.bean(copy=test_records[0]) + ss = frappe.copy_doc(test_records[0]) ss.insert() - self.assertEquals(ss.doc.total_days_in_month, 30) - self.assertEquals(ss.doc.payment_days, 29) - self.assertEquals(ss.doclist[1].e_modified_amount, 14500) - self.assertEquals(ss.doclist[2].e_modified_amount, 500) - self.assertEquals(ss.doclist[3].d_modified_amount, 100) - self.assertEquals(ss.doclist[4].d_modified_amount, 48.33) - self.assertEquals(ss.doc.gross_pay, 15000) - self.assertEquals(ss.doc.net_pay, 14851.67) + self.assertEquals(ss.total_days_in_month, 30) + self.assertEquals(ss.payment_days, 29) + self.assertEquals(ss.earning_details[0].e_modified_amount, 14500) + self.assertEquals(ss.earning_details[1].e_modified_amount, 500) + self.assertEquals(ss.deduction_details[0].d_modified_amount, 100) + self.assertEquals(ss.deduction_details[1].d_modified_amount, 48.33) + self.assertEquals(ss.gross_pay, 15000) + self.assertEquals(ss.net_pay, 14851.67) test_dependencies = ["Leave Application"] -test_records = [ - [ - { - "doctype": "Salary Slip", - "employee": "_T-Employee-0001", - "employee_name": "_Test Employee", - "company": "_Test Company", - "fiscal_year": "_Test Fiscal Year 2013", - "month": "01", - "total_days_in_month": 31, - "payment_days": 31 - }, - { - "doctype": "Salary Slip Earning", - "parentfield": "earning_details", - "e_type": "_Test Basic Salary", - "e_amount": 15000, - "e_depends_on_lwp": 1 - }, - { - "doctype": "Salary Slip Earning", - "parentfield": "earning_details", - "e_type": "_Test Allowance", - "e_amount": 500, - "e_depends_on_lwp": 0 - }, - { - "doctype": "Salary Slip Deduction", - "parentfield": "deduction_details", - "d_type": "_Test Professional Tax", - "d_amount": 100, - "d_depends_on_lwp": 0 - }, - { - "doctype": "Salary Slip Deduction", - "parentfield": "deduction_details", - "d_type": "_Test TDS", - "d_amount": 50, - "d_depends_on_lwp": 1 - }, - ] -] \ No newline at end of file +test_records = frappe.get_test_records('Salary Slip') \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.json b/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.json new file mode 100644 index 00000000000..ae07c2c523c --- /dev/null +++ b/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.json @@ -0,0 +1,52 @@ +{ + "creation": "2013-02-22 01:27:48.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "d_type", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Type", + "oldfieldname": "d_type", + "oldfieldtype": "Data", + "options": "Deduction Type", + "permlevel": 0, + "print_width": "200px", + "width": "200px" + }, + { + "fieldname": "d_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "d_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "d_modified_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Modified Amount", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "d_depends_on_lwp", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Depends on LWP", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:42.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Salary Slip Deduction", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py b/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py index 26c87f1c04a..422ee28338e 100644 --- a/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py +++ b/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalarySlipDeduction(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.txt b/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.txt deleted file mode 100644 index 2b2909038cf..00000000000 --- a/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.txt +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:48", - "docstatus": 0, - "modified": "2013-12-20 19:23:42", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Salary Slip Deduction", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Salary Slip Deduction" - }, - { - "doctype": "DocField", - "fieldname": "d_type", - "fieldtype": "Link", - "label": "Type", - "oldfieldname": "d_type", - "oldfieldtype": "Data", - "options": "Deduction Type", - "print_width": "200px", - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "d_amount", - "fieldtype": "Currency", - "label": "Amount", - "oldfieldname": "d_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "d_modified_amount", - "fieldtype": "Currency", - "label": "Modified Amount", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "d_depends_on_lwp", - "fieldtype": "Check", - "label": "Depends on LWP" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.json b/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.json new file mode 100644 index 00000000000..eae64473a3e --- /dev/null +++ b/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.json @@ -0,0 +1,52 @@ +{ + "creation": "2013-02-22 01:27:48.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "e_type", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Type", + "oldfieldname": "e_type", + "oldfieldtype": "Data", + "options": "Earning Type", + "permlevel": 0, + "print_width": "200px", + "width": "200px" + }, + { + "fieldname": "e_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "e_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "e_modified_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Modified Amount", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "e_depends_on_lwp", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Depends on LWP", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:43.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Salary Slip Earning", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py b/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py index 26c87f1c04a..c4a7b4e2e2c 100644 --- a/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py +++ b/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalarySlipEarning(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.txt b/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.txt deleted file mode 100644 index 3375ab55d13..00000000000 --- a/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.txt +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:48", - "docstatus": 0, - "modified": "2013-12-20 19:23:43", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Salary Slip Earning", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Salary Slip Earning" - }, - { - "doctype": "DocField", - "fieldname": "e_type", - "fieldtype": "Link", - "label": "Type", - "oldfieldname": "e_type", - "oldfieldtype": "Data", - "options": "Earning Type", - "print_width": "200px", - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "e_amount", - "fieldtype": "Currency", - "label": "Amount", - "oldfieldname": "e_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "e_modified_amount", - "fieldtype": "Currency", - "label": "Modified Amount", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "e_depends_on_lwp", - "fieldtype": "Check", - "label": "Depends on LWP" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.js b/erpnext/hr/doctype/salary_structure/salary_structure.js index 3b90ee62456..0cfb6c4437e 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.js +++ b/erpnext/hr/doctype/salary_structure/salary_structure.js @@ -4,10 +4,10 @@ cur_frm.add_fetch('employee', 'company', 'company'); cur_frm.cscript.onload = function(doc, dt, dn){ - e_tbl = getchildren('Salary Structure Earning', doc.name, 'earning_details', doc.doctype); - d_tbl = getchildren('Salary Structure Deduction', doc.name, 'deduction_details', doc.doctype); + e_tbl = doc.earning_details || []; + d_tbl = doc.deduction_details || []; if (e_tbl.length == 0 && d_tbl.length == 0) - return $c_obj(make_doclist(doc.doctype,doc.name),'make_earn_ded_table','', function(r, rt) { refresh_many(['earning_details', 'deduction_details']);}); + return $c_obj(doc,'make_earn_ded_table','', function(r, rt) { refresh_many(['earning_details', 'deduction_details']);}); } cur_frm.cscript.refresh = function(doc, dt, dn){ @@ -39,8 +39,8 @@ cur_frm.cscript.d_modified_amt = function(doc, cdt, cdn){ } var calculate_totals = function(doc, cdt, cdn) { - var tbl1 = getchildren('Salary Structure Earning', doc.name, 'earning_details', doc.doctype); - var tbl2 = getchildren('Salary Structure Deduction', doc.name, 'deduction_details', doc.doctype); + var tbl1 = doc.earning_details || []; + var tbl2 = doc.deduction_details || []; var total_earn = 0; var total_ded = 0; for(var i = 0; i < tbl1.length; i++){ diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.json b/erpnext/hr/doctype/salary_structure/salary_structure.json new file mode 100644 index 00000000000..9394fce1c7e --- /dev/null +++ b/erpnext/hr/doctype/salary_structure/salary_structure.json @@ -0,0 +1,273 @@ +{ + "allow_import": 1, + "creation": "2013-03-07 18:50:29.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "employee", + "fieldtype": "Link", + "in_filter": 1, + "label": "Employee", + "oldfieldname": "employee", + "oldfieldtype": "Link", + "options": "Employee", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "employee_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Employee Name", + "oldfieldname": "employee_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "branch", + "fieldtype": "Select", + "in_filter": 1, + "label": "Branch", + "oldfieldname": "branch", + "oldfieldtype": "Select", + "options": "link:Branch", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "designation", + "fieldtype": "Select", + "in_filter": 1, + "label": "Designation", + "oldfieldname": "designation", + "oldfieldtype": "Select", + "options": "link:Designation", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "department", + "fieldtype": "Select", + "in_filter": 1, + "label": "Department", + "oldfieldname": "department", + "oldfieldtype": "Select", + "options": "link:Department", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "grade", + "fieldtype": "Select", + "in_filter": 1, + "label": "Grade", + "oldfieldname": "grade", + "oldfieldtype": "Select", + "options": "link:Grade", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "default": "Yes", + "fieldname": "is_active", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Is Active", + "oldfieldname": "is_active", + "oldfieldtype": "Select", + "options": "\nYes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "from_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "From Date", + "oldfieldname": "from_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "to_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "To Date", + "oldfieldname": "to_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "company", + "fieldtype": "Select", + "in_filter": 1, + "label": "Company", + "options": "link:Company", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "description": "Salary breakup based on Earning and Deduction.", + "fieldname": "earning_deduction", + "fieldtype": "Section Break", + "label": "Monthly Earning & Deduction", + "oldfieldname": "earning_deduction", + "oldfieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "earning", + "fieldtype": "Column Break", + "hidden": 0, + "label": "Earning", + "oldfieldname": "col_brk2", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "earning_details", + "fieldtype": "Table", + "hidden": 0, + "label": "Earning1", + "oldfieldname": "earning_details", + "oldfieldtype": "Table", + "options": "Salary Structure Earning", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "deduction", + "fieldtype": "Column Break", + "hidden": 0, + "label": "Deduction", + "oldfieldname": "col_brk3", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "deduction_details", + "fieldtype": "Table", + "hidden": 0, + "label": "Deduction1", + "oldfieldname": "deduction_details", + "oldfieldtype": "Table", + "options": "Salary Structure Deduction", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "section_break0", + "fieldtype": "Section Break", + "options": "Simple", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "total_earning", + "fieldtype": "Currency", + "label": "Total Earning", + "oldfieldname": "total_earning", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "total_deduction", + "fieldtype": "Currency", + "label": "Total Deduction", + "oldfieldname": "total_deduction", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "net_pay", + "fieldtype": "Currency", + "label": "Net Pay", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-file-text", + "idx": 1, + "modified": "2013-12-20 19:24:28.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Salary Structure", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py index 8d59f2b926f..2bbc99bf6bb 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/salary_structure.py @@ -5,22 +5,20 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt -from frappe.model.doc import addchild, make_autoname +from frappe.model.naming import make_autoname from frappe import msgprint, _ -class DocType: - def __init__(self,doc,doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document +class SalaryStructure(Document): def autoname(self): - self.doc.name = make_autoname(self.doc.employee + '/.SST' + '/.#####') + self.name = make_autoname(self.employee + '/.SST' + '/.#####') def get_employee_details(self): ret = {} det = frappe.db.sql("""select employee_name, branch, designation, department, grade - from `tabEmployee` where name = %s""", self.doc.employee) + from `tabEmployee` where name = %s""", self.employee) if det: ret = { 'employee_name': cstr(det[0][0]), @@ -28,7 +26,7 @@ class DocType: 'designation': cstr(det[0][2]), 'department': cstr(det[0][3]), 'grade': cstr(det[0][4]), - 'backup_employee': cstr(self.doc.employee) + 'backup_employee': cstr(self.employee) } return ret @@ -44,7 +42,7 @@ class DocType: def make_table(self, doct_name, tab_fname, tab_name): list1 = frappe.db.sql("select name from `tab%s` where docstatus != 2" % doct_name) for li in list1: - child = addchild(self.doc, tab_fname, tab_name, self.doclist) + child = self.append(tab_fname, {}) if(tab_fname == 'earning_details'): child.e_type = cstr(li[0]) child.modified_value = 0 @@ -58,13 +56,13 @@ class DocType: def check_existing(self): ret = frappe.db.sql("""select name from `tabSalary Structure` where is_active = 'Yes' - and employee = %s and name!=%s""", (self.doc.employee,self.doc.name)) - if ret and self.doc.is_active=='Yes': + and employee = %s and name!=%s""", (self.employee,self.name)) + if ret and self.is_active=='Yes': msgprint(_("""Another Salary Structure '%s' is active for employee '%s'. Please make its status 'Inactive' to proceed.""") % - (cstr(ret), self.doc.employee), raise_exception=1) + (cstr(ret), self.employee), raise_exception=1) def validate_amount(self): - if flt(self.doc.net_pay) < 0: + if flt(self.net_pay) < 0: msgprint(_("Net pay can not be negative"), raise_exception=1) def validate(self): @@ -72,19 +70,19 @@ class DocType: self.validate_amount() @frappe.whitelist() -def make_salary_slip(source_name, target_doclist=None): - return [d.fields for d in get_mapped_doclist(source_name, target_doclist)] +def make_salary_slip(source_name, target_doc=None): + return get_mapped_doc(source_name, target_doc).as_dict() -def get_mapped_doclist(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist +def get_mapped_doc(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc def postprocess(source, target): - sal_slip = frappe.bean(target) + sal_slip = frappe.get_doc(target) sal_slip.run_method("pull_emp_details") sal_slip.run_method("get_leave_details") sal_slip.run_method("calculate_net_pay") - doclist = get_mapped_doclist("Salary Structure", source_name, { + doc = get_mapped_doc("Salary Structure", source_name, { "Salary Structure": { "doctype": "Salary Slip", "field_map": { @@ -109,6 +107,6 @@ def get_mapped_doclist(source_name, target_doclist=None): ], "add_if_empty": True } - }, target_doclist, postprocess) + }, target_doc, postprocess) - return doclist + return doc diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.txt b/erpnext/hr/doctype/salary_structure/salary_structure.txt deleted file mode 100644 index e54ebd7e592..00000000000 --- a/erpnext/hr/doctype/salary_structure/salary_structure.txt +++ /dev/null @@ -1,284 +0,0 @@ -[ - { - "creation": "2013-03-07 18:50:29", - "docstatus": 0, - "modified": "2013-12-20 19:24:28", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "doctype": "DocType", - "icon": "icon-file-text", - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Salary Structure", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Salary Structure", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Salary Structure" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "employee", - "fieldtype": "Link", - "in_filter": 1, - "label": "Employee", - "oldfieldname": "employee", - "oldfieldtype": "Link", - "options": "Employee", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "employee_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Employee Name", - "oldfieldname": "employee_name", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "branch", - "fieldtype": "Select", - "in_filter": 1, - "label": "Branch", - "oldfieldname": "branch", - "oldfieldtype": "Select", - "options": "link:Branch", - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "designation", - "fieldtype": "Select", - "in_filter": 1, - "label": "Designation", - "oldfieldname": "designation", - "oldfieldtype": "Select", - "options": "link:Designation", - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "department", - "fieldtype": "Select", - "in_filter": 1, - "label": "Department", - "oldfieldname": "department", - "oldfieldtype": "Select", - "options": "link:Department", - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "grade", - "fieldtype": "Select", - "in_filter": 1, - "label": "Grade", - "oldfieldname": "grade", - "oldfieldtype": "Select", - "options": "link:Grade", - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "default": "Yes", - "doctype": "DocField", - "fieldname": "is_active", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Is Active", - "oldfieldname": "is_active", - "oldfieldtype": "Select", - "options": "\nYes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "from_date", - "fieldtype": "Date", - "in_list_view": 1, - "label": "From Date", - "oldfieldname": "from_date", - "oldfieldtype": "Date", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "to_date", - "fieldtype": "Date", - "in_list_view": 1, - "label": "To Date", - "oldfieldname": "to_date", - "oldfieldtype": "Date", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "in_filter": 1, - "label": "Company", - "options": "link:Company", - "read_only": 0, - "reqd": 1 - }, - { - "description": "Salary breakup based on Earning and Deduction.", - "doctype": "DocField", - "fieldname": "earning_deduction", - "fieldtype": "Section Break", - "label": "Monthly Earning & Deduction", - "oldfieldname": "earning_deduction", - "oldfieldtype": "Section Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "earning", - "fieldtype": "Column Break", - "hidden": 0, - "label": "Earning", - "oldfieldname": "col_brk2", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "earning_details", - "fieldtype": "Table", - "hidden": 0, - "label": "Earning1", - "oldfieldname": "earning_details", - "oldfieldtype": "Table", - "options": "Salary Structure Earning", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "deduction", - "fieldtype": "Column Break", - "hidden": 0, - "label": "Deduction", - "oldfieldname": "col_brk3", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "deduction_details", - "fieldtype": "Table", - "hidden": 0, - "label": "Deduction1", - "oldfieldname": "deduction_details", - "oldfieldtype": "Table", - "options": "Salary Structure Deduction", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "options": "Simple", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "total_earning", - "fieldtype": "Currency", - "label": "Total Earning", - "oldfieldname": "total_earning", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_deduction", - "fieldtype": "Currency", - "label": "Total Deduction", - "oldfieldname": "total_deduction", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "net_pay", - "fieldtype": "Currency", - "label": "Net Pay", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocPerm", - "role": "HR User" - }, - { - "doctype": "DocPerm", - "role": "HR Manager" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.json b/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.json new file mode 100644 index 00000000000..7f9f1a48796 --- /dev/null +++ b/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.json @@ -0,0 +1,46 @@ +{ + "creation": "2013-02-22 01:27:48.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "d_type", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Type", + "oldfieldname": "d_type", + "oldfieldtype": "Select", + "options": "Deduction Type", + "permlevel": 0, + "print_width": "200px", + "reqd": 1, + "width": "200px" + }, + { + "fieldname": "d_modified_amt", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "d_modified_amt", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "depend_on_lwp", + "fieldtype": "Check", + "in_list_view": 0, + "label": "Reduce Deduction for Leave Without Pay (LWP)", + "oldfieldname": "depend_on_lwp", + "oldfieldtype": "Check", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:43.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Salary Structure Deduction", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py b/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py index 26c87f1c04a..95300e15e1b 100644 --- a/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py +++ b/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalaryStructureDeduction(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.txt b/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.txt deleted file mode 100644 index 845a70fde74..00000000000 --- a/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.txt +++ /dev/null @@ -1,59 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:48", - "docstatus": 0, - "modified": "2013-12-20 19:23:43", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Salary Structure Deduction", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Salary Structure Deduction" - }, - { - "doctype": "DocField", - "fieldname": "d_type", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Type", - "oldfieldname": "d_type", - "oldfieldtype": "Select", - "options": "Deduction Type", - "print_width": "200px", - "reqd": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "d_modified_amt", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "d_modified_amt", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "depend_on_lwp", - "fieldtype": "Check", - "in_list_view": 0, - "label": "Reduce Deduction for Leave Without Pay (LWP)", - "oldfieldname": "depend_on_lwp", - "oldfieldtype": "Check" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.json b/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.json new file mode 100644 index 00000000000..534ff29d70d --- /dev/null +++ b/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.json @@ -0,0 +1,48 @@ +{ + "creation": "2013-02-22 01:27:48.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "e_type", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Type", + "oldfieldname": "e_type", + "oldfieldtype": "Data", + "options": "Earning Type", + "permlevel": 0, + "print_width": "200px", + "reqd": 1, + "width": "200px" + }, + { + "fieldname": "modified_value", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "modified_value", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "depend_on_lwp", + "fieldtype": "Check", + "in_list_view": 0, + "label": "Reduce Earning for Leave Without Pay (LWP)", + "oldfieldname": "depend_on_lwp", + "oldfieldtype": "Check", + "permlevel": 0 + } + ], + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:43.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Salary Structure Earning", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py b/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py index 26c87f1c04a..79f7972f816 100644 --- a/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py +++ b/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalaryStructureEarning(Document): + pass \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.txt b/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.txt deleted file mode 100644 index d90c3cdd3be..00000000000 --- a/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.txt +++ /dev/null @@ -1,61 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:48", - "docstatus": 0, - "modified": "2013-12-20 19:23:43", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "hide_heading": 0, - "hide_toolbar": 0, - "istable": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Salary Structure Earning", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Salary Structure Earning" - }, - { - "doctype": "DocField", - "fieldname": "e_type", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Type", - "oldfieldname": "e_type", - "oldfieldtype": "Data", - "options": "Earning Type", - "print_width": "200px", - "reqd": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "modified_value", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "modified_value", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "depend_on_lwp", - "fieldtype": "Check", - "in_list_view": 0, - "label": "Reduce Earning for Leave Without Pay (LWP)", - "oldfieldname": "depend_on_lwp", - "oldfieldtype": "Check" - } -] \ No newline at end of file diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.json b/erpnext/hr/doctype/upload_attendance/upload_attendance.json new file mode 100644 index 00000000000..5037b3e6939 --- /dev/null +++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.json @@ -0,0 +1,90 @@ +{ + "allow_attach": 0, + "creation": "2013-01-25 11:34:53.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Download the Template, fill appropriate data and attach the modified file.\nAll dates and employee combination in the selected period will come in the template, with existing attendance records", + "fieldname": "download_template", + "fieldtype": "Section Break", + "label": "Download Template", + "permlevel": 0 + }, + { + "fieldname": "att_fr_date", + "fieldtype": "Date", + "label": "Attendance From Date", + "oldfieldname": "attenadnce_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "att_to_date", + "fieldtype": "Date", + "label": "Attendance To Date", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "get_template", + "fieldtype": "Button", + "label": "Get Template", + "oldfieldtype": "Button", + "permlevel": 0 + }, + { + "fieldname": "upload_attendance_data", + "fieldtype": "Section Break", + "label": "Import Attendance", + "permlevel": 0 + }, + { + "fieldname": "upload_html", + "fieldtype": "HTML", + "label": "Upload HTML", + "permlevel": 0 + }, + { + "fieldname": "import_log", + "fieldtype": "HTML", + "hidden": 0, + "label": "Import Log", + "permlevel": 0 + } + ], + "icon": "icon-upload-alt", + "idx": 1, + "issingle": 1, + "max_attachments": 1, + "modified": "2013-12-20 19:21:54.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Upload Attendance", + "owner": "harshada@webnotestech.com", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "HR User", + "submit": 0, + "write": 1 + }, + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "HR Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.py b/erpnext/hr/doctype/upload_attendance/upload_attendance.py index 3da10786fe9..1ba31e9f20b 100644 --- a/erpnext/hr/doctype/upload_attendance/upload_attendance.py +++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.py @@ -8,14 +8,10 @@ import frappe from frappe.utils import cstr, add_days, date_diff from frappe import msgprint, _ from frappe.utils.datautils import UnicodeWriter +from frappe.model.document import Document -# doclist = None -doclist = frappe.local('uploadattendance_doclist') - -class DocType(): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class UploadAttendance(Document): + pass @frappe.whitelist() def get_template(): @@ -23,7 +19,6 @@ def get_template(): raise frappe.PermissionError args = frappe.local.form_dict - frappe.local.uploadattendance_doclist = frappe.model.doctype.get("Attendance") w = UnicodeWriter() w = add_header(w) @@ -35,13 +30,8 @@ def get_template(): frappe.response['type'] = 'csv' frappe.response['doctype'] = "Attendance" -def getdocfield(fieldname): - """get docfield from doclist of doctype""" - l = [d for d in doclist if d.doctype=='DocField' and d.fieldname==fieldname] - return l and l[0] or None - def add_header(w): - status = ", ".join(getdocfield("status").options.strip().split("\n")) + status = ", ".join((frappe.get_meta("Attendance").get_field("status").options or "").strip().split("\n")) w.writerow(["Notes:"]) w.writerow(["Please do not change the template headings"]) w.writerow(["Status should be one of these values: " + status]) @@ -95,7 +85,7 @@ def get_existing_attendance_records(args): return existing_attendance def get_naming_series(): - series = getdocfield("naming_series").options.strip().split("\n") + series = frappe.get_meta("Attendance").get_field("naming_series").options.strip().split("\n") if not series: msgprint("""Please create naming series for Attendance \ through Setup -> Numbering Series.""", raise_exception=1) @@ -121,7 +111,7 @@ def upload(): error = False from frappe.utils.datautils import check_record, import_doc - doctype_dl = frappe.get_doctype("Attendance") + doctype_dl = frappe.get_meta("Attendance") for i, row in enumerate(rows[5:]): if not row: continue @@ -132,7 +122,7 @@ def upload(): d["docstatus"] = frappe.db.get_value("Attendance", d.name, "docstatus") try: - check_record(d, doctype_dl=doctype_dl) + check_record(d) ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True)) except Exception, e: error = True diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.txt b/erpnext/hr/doctype/upload_attendance/upload_attendance.txt deleted file mode 100644 index 5c727619ed9..00000000000 --- a/erpnext/hr/doctype/upload_attendance/upload_attendance.txt +++ /dev/null @@ -1,102 +0,0 @@ -[ - { - "creation": "2013-01-25 11:34:53", - "docstatus": 0, - "modified": "2013-12-20 19:21:54", - "modified_by": "Administrator", - "owner": "harshada@webnotestech.com" - }, - { - "allow_attach": 0, - "doctype": "DocType", - "icon": "icon-upload-alt", - "issingle": 1, - "max_attachments": 1, - "module": "HR", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Upload Attendance", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Upload Attendance", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Upload Attendance" - }, - { - "description": "Download the Template, fill appropriate data and attach the modified file.\nAll dates and employee combination in the selected period will come in the template, with existing attendance records", - "doctype": "DocField", - "fieldname": "download_template", - "fieldtype": "Section Break", - "label": "Download Template" - }, - { - "doctype": "DocField", - "fieldname": "att_fr_date", - "fieldtype": "Date", - "label": "Attendance From Date", - "oldfieldname": "attenadnce_date", - "oldfieldtype": "Date", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "att_to_date", - "fieldtype": "Date", - "label": "Attendance To Date", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "get_template", - "fieldtype": "Button", - "label": "Get Template", - "oldfieldtype": "Button" - }, - { - "doctype": "DocField", - "fieldname": "upload_attendance_data", - "fieldtype": "Section Break", - "label": "Import Attendance" - }, - { - "doctype": "DocField", - "fieldname": "upload_html", - "fieldtype": "HTML", - "label": "Upload HTML" - }, - { - "doctype": "DocField", - "fieldname": "import_log", - "fieldtype": "HTML", - "hidden": 0, - "label": "Import Log" - }, - { - "doctype": "DocPerm", - "role": "HR User" - }, - { - "doctype": "DocPerm", - "role": "HR Manager" - } -] \ No newline at end of file diff --git a/erpnext/hr/report/employee_birthday/employee_birthday.json b/erpnext/hr/report/employee_birthday/employee_birthday.json new file mode 100644 index 00000000000..5839d01c614 --- /dev/null +++ b/erpnext/hr/report/employee_birthday/employee_birthday.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-05-06 17:56:03.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Employee Birthday", + "owner": "Administrator", + "ref_doctype": "Employee", + "report_name": "Employee Birthday", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/hr/report/employee_birthday/employee_birthday.txt b/erpnext/hr/report/employee_birthday/employee_birthday.txt deleted file mode 100644 index a114e5c181f..00000000000 --- a/erpnext/hr/report/employee_birthday/employee_birthday.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-05-06 17:56:03", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "HR", - "name": "__common__", - "ref_doctype": "Employee", - "report_name": "Employee Birthday", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Employee Birthday" - } -] \ No newline at end of file diff --git a/erpnext/hr/report/employee_information/employee_information.json b/erpnext/hr/report/employee_information/employee_information.json new file mode 100644 index 00000000000..0dc3d4066ac --- /dev/null +++ b/erpnext/hr/report/employee_information/employee_information.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-05-06 18:43:53.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "json": "{\"filters\":[],\"columns\":[[\"name\",\"Employee\"],[\"employee_number\",\"Employee\"],[\"date_of_joining\",\"Employee\"],[\"branch\",\"Employee\"],[\"department\",\"Employee\"],[\"designation\",\"Employee\"],[\"gender\",\"Employee\"],[\"status\",\"Employee\"],[\"company\",\"Employee\"],[\"employment_type\",\"Employee\"],[\"grade\",\"Employee\"],[\"reports_to\",\"Employee\"],[\"company_email\",\"Employee\"]],\"sort_by\":\"Employee.bank_ac_no\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Employee Information", + "owner": "Administrator", + "ref_doctype": "Employee", + "report_name": "Employee Information", + "report_type": "Report Builder" +} \ No newline at end of file diff --git a/erpnext/hr/report/employee_information/employee_information.txt b/erpnext/hr/report/employee_information/employee_information.txt deleted file mode 100644 index 8bd3c4c2684..00000000000 --- a/erpnext/hr/report/employee_information/employee_information.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-05-06 18:43:53", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "json": "{\"filters\":[],\"columns\":[[\"name\",\"Employee\"],[\"employee_number\",\"Employee\"],[\"date_of_joining\",\"Employee\"],[\"branch\",\"Employee\"],[\"department\",\"Employee\"],[\"designation\",\"Employee\"],[\"gender\",\"Employee\"],[\"status\",\"Employee\"],[\"company\",\"Employee\"],[\"employment_type\",\"Employee\"],[\"grade\",\"Employee\"],[\"reports_to\",\"Employee\"],[\"company_email\",\"Employee\"]],\"sort_by\":\"Employee.bank_ac_no\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", - "module": "HR", - "name": "__common__", - "ref_doctype": "Employee", - "report_name": "Employee Information", - "report_type": "Report Builder" - }, - { - "doctype": "Report", - "name": "Employee Information" - } -] \ No newline at end of file diff --git a/erpnext/hr/report/employee_leave_balance/employee_leave_balance.json b/erpnext/hr/report/employee_leave_balance/employee_leave_balance.json new file mode 100644 index 00000000000..4ffd7c89d71 --- /dev/null +++ b/erpnext/hr/report/employee_leave_balance/employee_leave_balance.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-02-22 15:29:34.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Employee Leave Balance", + "owner": "Administrator", + "ref_doctype": "Employee", + "report_name": "Employee Leave Balance", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/hr/report/employee_leave_balance/employee_leave_balance.txt b/erpnext/hr/report/employee_leave_balance/employee_leave_balance.txt deleted file mode 100644 index f682c64217b..00000000000 --- a/erpnext/hr/report/employee_leave_balance/employee_leave_balance.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-02-22 15:29:34", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "HR", - "name": "__common__", - "ref_doctype": "Employee", - "report_name": "Employee Leave Balance", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Employee Leave Balance" - } -] \ No newline at end of file diff --git a/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.json b/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.json new file mode 100644 index 00000000000..5f55fee5b52 --- /dev/null +++ b/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 0, + "creation": "2013-05-13 14:04:03.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Monthly Attendance Sheet", + "owner": "Administrator", + "ref_doctype": "Attendance", + "report_name": "Monthly Attendance Sheet", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt b/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt deleted file mode 100644 index 5c51c4ba6e5..00000000000 --- a/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-05-13 14:04:03", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 0, - "doctype": "Report", - "is_standard": "Yes", - "module": "HR", - "name": "__common__", - "ref_doctype": "Attendance", - "report_name": "Monthly Attendance Sheet", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Monthly Attendance Sheet" - } -] \ No newline at end of file diff --git a/erpnext/hr/report/monthly_salary_register/monthly_salary_register.json b/erpnext/hr/report/monthly_salary_register/monthly_salary_register.json new file mode 100644 index 00000000000..51b8e2c21c2 --- /dev/null +++ b/erpnext/hr/report/monthly_salary_register/monthly_salary_register.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-05-07 18:09:42.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "HR", + "name": "Monthly Salary Register", + "owner": "Administrator", + "ref_doctype": "Salary Slip", + "report_name": "Monthly Salary Register", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/hr/report/monthly_salary_register/monthly_salary_register.txt b/erpnext/hr/report/monthly_salary_register/monthly_salary_register.txt deleted file mode 100644 index 80b0c136a71..00000000000 --- a/erpnext/hr/report/monthly_salary_register/monthly_salary_register.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-05-07 18:09:42", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "HR", - "name": "__common__", - "ref_doctype": "Salary Slip", - "report_name": "Monthly Salary Register", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Monthly Salary Register" - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index 363ab7578d6..d0e9cc71f3f 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -34,7 +34,7 @@ cur_frm.cscript.operation_no = function(doc, cdt, cdn) { } var set_operation_no = function(doc) { - var op_table = getchildren('BOM Operation', doc.name, 'bom_operations'); + var op_table = doc.bom_operations || []; var operations = []; for (var i=0, j=op_table.length; i count ): - boms = frappe.db.sql(" select %s from `tabBOM Item` where %s = %s " % + boms = frappe.db.sql(" select %s from `tabBOM Item` where %s = %s " % (d[0], d[1], '%s'), cstr(bom_list[count])) count = count + 1 for b in boms: - if b[0] == self.doc.name: + if b[0] == self.name: msgprint("""Recursion Occured => '%s' cannot be '%s' of '%s'. - """ % (cstr(b[0]), cstr(d[2]), self.doc.name), raise_exception = 1) + """ % (cstr(b[0]), cstr(d[2]), self.name), raise_exception = 1) if b[0]: bom_list.append(b[0]) - + def update_cost_and_exploded_items(self, bom_list=[]): bom_list = self.traverse_tree(bom_list) for bom in bom_list: - bom_obj = get_obj("BOM", bom, with_children=1) + bom_obj = frappe.get_doc("BOM", bom) bom_obj.on_update() - + return bom_list - + def traverse_tree(self, bom_list=[]): def _get_children(bom_no): - return [cstr(d[0]) for d in frappe.db.sql("""select bom_no from `tabBOM Item` + return [cstr(d[0]) for d in frappe.db.sql("""select bom_no from `tabBOM Item` where parent = %s and ifnull(bom_no, '') != ''""", bom_no)] - + count = 0 - if self.doc.name not in bom_list: - bom_list.append(self.doc.name) - + if self.name not in bom_list: + bom_list.append(self.name) + while(count < len(bom_list)): for child_bom in _get_children(bom_list[count]): if child_bom not in bom_list: @@ -305,35 +297,35 @@ class DocType: count += 1 bom_list.reverse() return bom_list - + def calculate_cost(self): """Calculate bom totals""" self.calculate_op_cost() self.calculate_rm_cost() - self.doc.total_cost = self.doc.raw_material_cost + self.doc.operating_cost + self.total_cost = self.raw_material_cost + self.operating_cost def calculate_op_cost(self): """Update workstation rate and calculates totals""" total_op_cost = 0 - for d in getlist(self.doclist, 'bom_operations'): + for d in self.get('bom_operations'): if d.workstation and not d.hour_rate: d.hour_rate = frappe.db.get_value("Workstation", d.workstation, "hour_rate") if d.hour_rate and d.time_in_mins: d.operating_cost = flt(d.hour_rate) * flt(d.time_in_mins) / 60.0 total_op_cost += flt(d.operating_cost) - self.doc.operating_cost = total_op_cost - + self.operating_cost = total_op_cost + def calculate_rm_cost(self): """Fetch RM rate as per today's valuation rate and calculate totals""" total_rm_cost = 0 - for d in getlist(self.doclist, 'bom_materials'): + for d in self.get('bom_materials'): if d.bom_no: d.rate = self.get_bom_unitcost(d.bom_no) d.amount = flt(d.rate) * flt(d.qty) - d.qty_consumed_per_unit = flt(d.qty) / flt(self.doc.quantity) + d.qty_consumed_per_unit = flt(d.qty) / flt(self.quantity) total_rm_cost += d.amount - - self.doc.raw_material_cost = total_rm_cost + + self.raw_material_cost = total_rm_cost def update_exploded_items(self): """ Update Flat BOM, following will be correct data""" @@ -343,85 +335,86 @@ class DocType: def get_exploded_items(self): """ Get all raw materials including items from child bom""" self.cur_exploded_items = {} - for d in getlist(self.doclist, 'bom_materials'): + for d in self.get('bom_materials'): if d.bom_no: self.get_child_exploded_items(d.bom_no, d.qty) else: self.add_to_cur_exploded_items(frappe._dict({ - 'item_code' : d.item_code, - 'description' : d.description, - 'stock_uom' : d.stock_uom, + 'item_code' : d.item_code, + 'description' : d.description, + 'stock_uom' : d.stock_uom, 'qty' : flt(d.qty), 'rate' : flt(d.rate), })) - + def add_to_cur_exploded_items(self, args): if self.cur_exploded_items.get(args.item_code): self.cur_exploded_items[args.item_code]["qty"] += args.qty else: self.cur_exploded_items[args.item_code] = args - + def get_child_exploded_items(self, bom_no, qty): """ Add all items from Flat BOM of child BOM""" - - child_fb_items = frappe.db.sql("""select item_code, description, stock_uom, qty, rate, - qty_consumed_per_unit from `tabBOM Explosion Item` + + child_fb_items = frappe.db.sql("""select item_code, description, stock_uom, qty, rate, + qty_consumed_per_unit from `tabBOM Explosion Item` where parent = %s and docstatus = 1""", bom_no, as_dict = 1) - + for d in child_fb_items: self.add_to_cur_exploded_items(frappe._dict({ - 'item_code' : d['item_code'], - 'description' : d['description'], - 'stock_uom' : d['stock_uom'], + 'item_code' : d['item_code'], + 'description' : d['description'], + 'stock_uom' : d['stock_uom'], 'qty' : flt(d['qty_consumed_per_unit'])*qty, 'rate' : flt(d['rate']), })) def add_exploded_items(self): "Add items to Flat BOM table" - self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details', 1) + frappe.db.sql("""delete from `tabBOM Explosion Item` where parent=%s""", self.name) for d in self.cur_exploded_items: - ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', self.doclist) + ch = self.append('flat_bom_details', {}) for i in self.cur_exploded_items[d].keys(): - ch.fields[i] = self.cur_exploded_items[d][i] + ch.set(i, self.cur_exploded_items[d][i]) ch.amount = flt(ch.qty) * flt(ch.rate) - ch.qty_consumed_per_unit = flt(ch.qty) / flt(self.doc.quantity) - ch.docstatus = self.doc.docstatus - ch.save(1) + ch.qty_consumed_per_unit = flt(ch.qty) / flt(self.quantity) + ch.docstatus = self.docstatus + ch.db_insert() def validate_bom_links(self): - if not self.doc.is_active: + if not self.is_active: act_pbom = frappe.db.sql("""select distinct bom_item.parent from `tabBOM Item` bom_item where bom_item.bom_no = %s and bom_item.docstatus = 1 and exists (select * from `tabBOM` where name = bom_item.parent - and docstatus = 1 and is_active = 1)""", self.doc.name) + and docstatus = 1 and is_active = 1)""", self.name) if act_pbom and act_pbom[0][0]: - action = self.doc.docstatus < 2 and _("deactivate") or _("cancel") + action = self.docstatus < 2 and _("deactivate") or _("cancel") msgprint(_("Cannot ") + action + _(": It is linked to other active BOM(s)"), raise_exception=1) def get_bom_items_as_dict(bom, qty=1, fetch_exploded=1): + import json item_dict = {} - - query = """select + + query = """select bom_item.item_code, item.item_name, - ifnull(sum(bom_item.qty_consumed_per_unit),0) * %(qty)s as qty, - item.description, + ifnull(sum(bom_item.qty_consumed_per_unit),0) * %(qty)s as qty, + item.description, item.stock_uom, item.default_warehouse, item.expense_account as expense_account, item.buying_cost_center as cost_center - from - `tab%(table)s` bom_item, `tabItem` item - where - bom_item.docstatus < 2 + from + `tab%(table)s` bom_item, `tabItem` item + where + bom_item.docstatus < 2 and bom_item.parent = "%(bom)s" - and item.name = bom_item.item_code + and item.name = bom_item.item_code %(conditions)s group by item_code, stock_uom""" - + if fetch_exploded: items = frappe.db.sql(query % { "qty": qty, @@ -444,7 +437,7 @@ def get_bom_items_as_dict(bom, qty=1, fetch_exploded=1): item_dict[item.item_code]["qty"] += flt(item.qty) else: item_dict[item.item_code] = item - + return item_dict @frappe.whitelist() diff --git a/erpnext/manufacturing/doctype/bom/bom.txt b/erpnext/manufacturing/doctype/bom/bom.txt deleted file mode 100644 index 4afc160fb8f..00000000000 --- a/erpnext/manufacturing/doctype/bom/bom.txt +++ /dev/null @@ -1,281 +0,0 @@ -[ - { - "creation": "2013-01-22 15:11:38", - "docstatus": 0, - "modified": "2014-01-20 17:48:26", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 0, - "allow_copy": 0, - "allow_import": 1, - "allow_rename": 0, - "doctype": "DocType", - "document_type": "Master", - "hide_heading": 0, - "hide_toolbar": 0, - "icon": "icon-sitemap", - "in_create": 0, - "is_submittable": 1, - "issingle": 0, - "istable": 0, - "module": "Manufacturing", - "name": "__common__", - "read_only": 0, - "search_fields": "item" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "BOM", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "BOM", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "BOM" - }, - { - "description": "Item to be manufactured or repacked", - "doctype": "DocField", - "fieldname": "item", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 0, - "label": "Item", - "oldfieldname": "item", - "oldfieldtype": "Link", - "options": "Item", - "reqd": 1, - "search_index": 1 - }, - { - "allow_on_submit": 1, - "default": "1", - "doctype": "DocField", - "fieldname": "is_active", - "fieldtype": "Check", - "hidden": 0, - "in_list_view": 1, - "label": "Is Active", - "no_copy": 1, - "oldfieldname": "is_active", - "oldfieldtype": "Select", - "reqd": 0 - }, - { - "allow_on_submit": 1, - "default": "1", - "doctype": "DocField", - "fieldname": "is_default", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Is Default", - "no_copy": 1, - "oldfieldname": "is_default", - "oldfieldtype": "Check" - }, - { - "doctype": "DocField", - "fieldname": "cb0", - "fieldtype": "Column Break" - }, - { - "description": "Manage cost of operations", - "doctype": "DocField", - "fieldname": "with_operations", - "fieldtype": "Check", - "label": "With Operations" - }, - { - "doctype": "DocField", - "fieldname": "rm_cost_as_per", - "fieldtype": "Select", - "label": "Rate Of Materials Based On", - "options": "Valuation Rate\nLast Purchase Rate\nPrice List" - }, - { - "depends_on": "eval:doc.rm_cost_as_per===\"Price List\"", - "doctype": "DocField", - "fieldname": "buying_price_list", - "fieldtype": "Link", - "label": "Price List", - "options": "Price List" - }, - { - "depends_on": "with_operations", - "description": "Specify the operations, operating cost and give a unique Operation no to your operations.", - "doctype": "DocField", - "fieldname": "operations", - "fieldtype": "Section Break", - "label": "Operations", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "bom_operations", - "fieldtype": "Table", - "label": "BOM Operations", - "oldfieldname": "bom_operations", - "oldfieldtype": "Table", - "options": "BOM Operation" - }, - { - "doctype": "DocField", - "fieldname": "materials", - "fieldtype": "Section Break", - "label": "Materials", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "bom_materials", - "fieldtype": "Table", - "label": "BOM Item", - "oldfieldname": "bom_materials", - "oldfieldtype": "Table", - "options": "BOM Item" - }, - { - "doctype": "DocField", - "fieldname": "costing", - "fieldtype": "Section Break", - "label": "Costing", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "total_cost", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Total Cost", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "raw_material_cost", - "fieldtype": "Float", - "label": "Total Raw Material Cost", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "operating_cost", - "fieldtype": "Float", - "label": "Total Operating Cost", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "more_info_section", - "fieldtype": "Section Break", - "label": "More Info" - }, - { - "default": "1", - "description": "Quantity of item obtained after manufacturing / repacking from given quantities of raw materials", - "doctype": "DocField", - "fieldname": "quantity", - "fieldtype": "Float", - "label": "Quantity", - "oldfieldname": "quantity", - "oldfieldtype": "Currency", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "uom", - "fieldtype": "Select", - "label": "Item UOM", - "options": "link:UOM", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break23", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "project_name", - "fieldtype": "Link", - "in_filter": 1, - "label": "Project Name", - "oldfieldname": "project_name", - "oldfieldtype": "Link", - "options": "Project" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Item Desription", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "options": "BOM", - "print_hide": 1, - "read_only": 1 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "hidden": 0, - "label": "Materials Required (Exploded)", - "print_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "flat_bom_details", - "fieldtype": "Table", - "hidden": 0, - "label": "Materials Required (Exploded)", - "no_copy": 1, - "oldfieldname": "flat_bom_details", - "oldfieldtype": "Table", - "options": "BOM Explosion Item", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocPerm", - "role": "Manufacturing Manager" - }, - { - "doctype": "DocPerm", - "role": "Manufacturing User" - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py index 9bd9a074094..28ee49acbc2 100644 --- a/erpnext/manufacturing/doctype/bom/test_bom.py +++ b/erpnext/manufacturing/doctype/bom/test_bom.py @@ -6,114 +6,25 @@ from __future__ import unicode_literals import unittest import frappe -test_records = [ - [ - { - "doctype": "BOM", - "item": "_Test Item Home Desktop Manufactured", - "quantity": 1.0, - "is_active": 1, - "is_default": 1, - "docstatus": 1 - }, - { - "doctype": "BOM Item", - "item_code": "_Test Serialized Item With Series", - "parentfield": "bom_materials", - "qty": 1.0, - "rate": 5000.0, - "amount": 5000.0, - "stock_uom": "_Test UOM" - }, - { - "doctype": "BOM Item", - "item_code": "_Test Item 2", - "parentfield": "bom_materials", - "qty": 2.0, - "rate": 1000.0, - "amount": 2000.0, - "stock_uom": "_Test UOM" - } - ], - - [ - { - "doctype": "BOM", - "item": "_Test FG Item", - "quantity": 1.0, - "is_active": 1, - "is_default": 1, - "docstatus": 1 - }, - { - "doctype": "BOM Item", - "item_code": "_Test Item", - "parentfield": "bom_materials", - "qty": 1.0, - "rate": 5000.0, - "amount": 5000.0, - "stock_uom": "_Test UOM" - }, - { - "doctype": "BOM Item", - "item_code": "_Test Item Home Desktop 100", - "parentfield": "bom_materials", - "qty": 2.0, - "rate": 1000.0, - "amount": 2000.0, - "stock_uom": "_Test UOM" - } - ], - - [ - { - "doctype": "BOM", - "item": "_Test FG Item 2", - "quantity": 1.0, - "is_active": 1, - "is_default": 1, - "docstatus": 1 - }, - { - "doctype": "BOM Item", - "item_code": "_Test Item", - "parentfield": "bom_materials", - "qty": 1.0, - "rate": 5000.0, - "amount": 5000.0, - "stock_uom": "_Test UOM" - }, - { - "doctype": "BOM Item", - "item_code": "_Test Item Home Desktop Manufactured", - "bom_no": "BOM/_Test Item Home Desktop Manufactured/001", - "parentfield": "bom_materials", - "qty": 2.0, - "rate": 1000.0, - "amount": 2000.0, - "stock_uom": "_Test UOM" - } - ], -] +test_records = frappe.get_test_records('Bom') class TestBOM(unittest.TestCase): def test_get_items(self): from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict items_dict = get_bom_items_as_dict(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=0) - self.assertTrue(test_records[2][1]["item_code"] in items_dict) - self.assertTrue(test_records[2][2]["item_code"] in items_dict) + self.assertTrue(test_records[2]["bom_materials"][0]["item_code"] in items_dict) + self.assertTrue(test_records[2]["bom_materials"][1]["item_code"] in items_dict) self.assertEquals(len(items_dict.values()), 2) - + def test_get_items_exploded(self): from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict items_dict = get_bom_items_as_dict(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=1) - self.assertTrue(test_records[2][1]["item_code"] in items_dict) - self.assertFalse(test_records[2][2]["item_code"] in items_dict) - self.assertTrue(test_records[0][1]["item_code"] in items_dict) - self.assertTrue(test_records[0][2]["item_code"] in items_dict) + self.assertTrue(test_records[2]["bom_materials"][0]["item_code"] in items_dict) + self.assertFalse(test_records[2]["bom_materials"][1]["item_code"] in items_dict) + self.assertTrue(test_records[0]["bom_materials"][0]["item_code"] in items_dict) + self.assertTrue(test_records[0]["bom_materials"][1]["item_code"] in items_dict) self.assertEquals(len(items_dict.values()), 3) - + def test_get_items_list(self): from erpnext.manufacturing.doctype.bom.bom import get_bom_items self.assertEquals(len(get_bom_items(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=1)), 3) - diff --git a/erpnext/manufacturing/doctype/bom/test_records.json b/erpnext/manufacturing/doctype/bom/test_records.json new file mode 100644 index 00000000000..efd26c243f6 --- /dev/null +++ b/erpnext/manufacturing/doctype/bom/test_records.json @@ -0,0 +1,87 @@ +[ + { + "bom_materials": [ + { + "amount": 5000.0, + "doctype": "BOM Item", + "item_code": "_Test Serialized Item With Series", + "parentfield": "bom_materials", + "qty": 1.0, + "rate": 5000.0, + "stock_uom": "_Test UOM" + }, + { + "amount": 2000.0, + "doctype": "BOM Item", + "item_code": "_Test Item 2", + "parentfield": "bom_materials", + "qty": 2.0, + "rate": 1000.0, + "stock_uom": "_Test UOM" + } + ], + "docstatus": 1, + "doctype": "BOM", + "is_active": 1, + "is_default": 1, + "item": "_Test Item Home Desktop Manufactured", + "quantity": 1.0 + }, + { + "bom_materials": [ + { + "amount": 5000.0, + "doctype": "BOM Item", + "item_code": "_Test Item", + "parentfield": "bom_materials", + "qty": 1.0, + "rate": 5000.0, + "stock_uom": "_Test UOM" + }, + { + "amount": 2000.0, + "doctype": "BOM Item", + "item_code": "_Test Item Home Desktop 100", + "parentfield": "bom_materials", + "qty": 2.0, + "rate": 1000.0, + "stock_uom": "_Test UOM" + } + ], + "docstatus": 1, + "doctype": "BOM", + "is_active": 1, + "is_default": 1, + "item": "_Test FG Item", + "quantity": 1.0 + }, + { + "bom_materials": [ + { + "amount": 5000.0, + "doctype": "BOM Item", + "item_code": "_Test Item", + "parentfield": "bom_materials", + "qty": 1.0, + "rate": 5000.0, + "stock_uom": "_Test UOM" + }, + { + "amount": 2000.0, + "bom_no": "BOM/_Test Item Home Desktop Manufactured/001", + "doctype": "BOM Item", + "item_code": "_Test Item Home Desktop Manufactured", + "parentfield": "bom_materials", + "qty": 2.0, + "rate": 1000.0, + "stock_uom": "_Test UOM" + } + ], + "docstatus": 1, + "doctype": "BOM", + "is_active": 1, + "is_default": 1, + "item": "_Test FG Item 2", + "quantity": 1.0 + } +] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json new file mode 100644 index 00000000000..6465e6aee91 --- /dev/null +++ b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json @@ -0,0 +1,91 @@ +{ + "autoname": "FBD/.######", + "creation": "2013-03-07 11:42:57.000000", + "default_print_format": "Standard", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 1, + "width": "300px" + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Qty", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "rate", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "standard_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "amount_as_per_sr", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Stock UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "qty_consumed_per_unit", + "fieldtype": "Float", + "hidden": 0, + "in_list_view": 1, + "label": "Qty Consumed Per Unit", + "no_copy": 0, + "permlevel": 0, + "read_only": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:22:57.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "BOM Explosion Item", + "owner": "Administrator", + "read_only": 0 +} \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py index 26c87f1c04a..48ea3c0830b 100644 --- a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py +++ b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class BOMExplosionItem(Document): + pass \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt deleted file mode 100644 index 55342aa59f0..00000000000 --- a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt +++ /dev/null @@ -1,98 +0,0 @@ -[ - { - "creation": "2013-03-07 11:42:57", - "docstatus": 0, - "modified": "2013-12-20 19:22:57", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "FBD/.######", - "default_print_format": "Standard", - "doctype": "DocType", - "istable": 1, - "module": "Manufacturing", - "name": "__common__", - "read_only": 0 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "BOM Explosion Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "read_only": 1 - }, - { - "doctype": "DocType", - "name": "BOM Explosion Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "print_width": "300px", - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Qty", - "oldfieldname": "qty", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "standard_rate", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "amount_as_per_sr", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Stock UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Link", - "options": "UOM" - }, - { - "doctype": "DocField", - "fieldname": "qty_consumed_per_unit", - "fieldtype": "Float", - "hidden": 0, - "in_list_view": 1, - "label": "Qty Consumed Per Unit", - "no_copy": 0 - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.json b/erpnext/manufacturing/doctype/bom_item/bom_item.json new file mode 100644 index 00000000000..fbf478c7560 --- /dev/null +++ b/erpnext/manufacturing/doctype/bom_item/bom_item.json @@ -0,0 +1,141 @@ +{ + "creation": "2013-02-22 01:27:49.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "operation_no", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Operation No", + "oldfieldname": "operation_no", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "bom_no", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "BOM No", + "oldfieldname": "bom_no", + "oldfieldtype": "Link", + "options": "BOM", + "permlevel": 0, + "print_width": "150px", + "reqd": 0, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "label": "Item Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "250px", + "reqd": 0, + "width": "250px" + }, + { + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "label": "Quantity and Rate", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Qty", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "See \"Rate Of Materials Based On\" in Costing Section", + "fieldname": "rate", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Rate", + "permlevel": 0 + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Stock UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "amount_as_per_mar", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "scrap", + "fieldtype": "Float", + "label": "Scrap %", + "oldfieldname": "scrap", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "qty_consumed_per_unit", + "fieldtype": "Float", + "hidden": 1, + "label": "Qty Consumed Per Unit", + "oldfieldname": "qty_consumed_per_unit", + "oldfieldtype": "Float", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-03 12:47:39.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "BOM Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.py b/erpnext/manufacturing/doctype/bom_item/bom_item.py index 26c87f1c04a..ff3a06f2d8c 100644 --- a/erpnext/manufacturing/doctype/bom_item/bom_item.py +++ b/erpnext/manufacturing/doctype/bom_item/bom_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class BOMItem(Document): + pass \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.txt b/erpnext/manufacturing/doctype/bom_item/bom_item.txt deleted file mode 100644 index 6949b75e4fc..00000000000 --- a/erpnext/manufacturing/doctype/bom_item/bom_item.txt +++ /dev/null @@ -1,154 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:49", - "docstatus": 0, - "modified": "2014-02-03 12:47:39", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Manufacturing", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "BOM Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "BOM Item" - }, - { - "doctype": "DocField", - "fieldname": "operation_no", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Operation No", - "oldfieldname": "operation_no", - "oldfieldtype": "Data", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "bom_no", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "BOM No", - "oldfieldname": "bom_no", - "oldfieldtype": "Link", - "options": "BOM", - "print_width": "150px", - "reqd": 0, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "label": "Item Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "print_width": "250px", - "reqd": 0, - "width": "250px" - }, - { - "doctype": "DocField", - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "label": "Quantity and Rate" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Qty", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "reqd": 1 - }, - { - "description": "See \"Rate Of Materials Based On\" in Costing Section", - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Rate" - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Stock UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "amount_as_per_mar", - "oldfieldtype": "Currency", - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "scrap", - "fieldtype": "Float", - "label": "Scrap %", - "oldfieldname": "scrap", - "oldfieldtype": "Currency", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "qty_consumed_per_unit", - "fieldtype": "Float", - "hidden": 1, - "label": "Qty Consumed Per Unit", - "oldfieldname": "qty_consumed_per_unit", - "oldfieldtype": "Float", - "print_hide": 1, - "read_only": 1 - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_operation/bom_operation.json b/erpnext/manufacturing/doctype/bom_operation/bom_operation.json new file mode 100644 index 00000000000..3bf5862c198 --- /dev/null +++ b/erpnext/manufacturing/doctype/bom_operation/bom_operation.json @@ -0,0 +1,81 @@ +{ + "creation": "2013-02-22 01:27:49.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "operation_no", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Operation No", + "oldfieldname": "operation_no", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "opn_description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Operation Description", + "oldfieldname": "opn_description", + "oldfieldtype": "Text", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "workstation", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Workstation", + "oldfieldname": "workstation", + "oldfieldtype": "Link", + "options": "Workstation", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "hour_rate", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Hour Rate", + "oldfieldname": "hour_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "time_in_mins", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Operation Time (mins)", + "oldfieldname": "time_in_mins", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 0 + }, + { + "allow_on_submit": 0, + "fieldname": "operating_cost", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Operating Cost", + "oldfieldname": "operating_cost", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-03 12:53:03.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "BOM Operation", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_operation/bom_operation.py b/erpnext/manufacturing/doctype/bom_operation/bom_operation.py index 26c87f1c04a..8c03fafcb18 100644 --- a/erpnext/manufacturing/doctype/bom_operation/bom_operation.py +++ b/erpnext/manufacturing/doctype/bom_operation/bom_operation.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class BOMOperation(Document): + pass \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_operation/bom_operation.txt b/erpnext/manufacturing/doctype/bom_operation/bom_operation.txt deleted file mode 100644 index b2628c14158..00000000000 --- a/erpnext/manufacturing/doctype/bom_operation/bom_operation.txt +++ /dev/null @@ -1,94 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:49", - "docstatus": 0, - "modified": "2014-02-03 12:53:03", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Manufacturing", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "BOM Operation", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "BOM Operation" - }, - { - "doctype": "DocField", - "fieldname": "operation_no", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Operation No", - "oldfieldname": "operation_no", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "opn_description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Operation Description", - "oldfieldname": "opn_description", - "oldfieldtype": "Text", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "workstation", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Workstation", - "oldfieldname": "workstation", - "oldfieldtype": "Link", - "options": "Workstation", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "hour_rate", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Hour Rate", - "oldfieldname": "hour_rate", - "oldfieldtype": "Currency", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "time_in_mins", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Operation Time (mins)", - "oldfieldname": "time_in_mins", - "oldfieldtype": "Currency", - "reqd": 0 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "operating_cost", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Operating Cost", - "oldfieldname": "operating_cost", - "oldfieldtype": "Currency", - "reqd": 0 - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.json b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.json new file mode 100644 index 00000000000..a5e3b4d6295 --- /dev/null +++ b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.json @@ -0,0 +1,63 @@ +{ + "allow_copy": 1, + "allow_email": 1, + "allow_print": 1, + "creation": "2012-12-06 12:10:10.000000", + "description": "Replace a particular BOM in all other BOMs where it is used. It will replace the old BOM link, update cost and regenerate \"BOM Explosion Item\" table as per new BOM", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Other", + "fields": [ + { + "description": "The BOM which will be replaced", + "fieldname": "current_bom", + "fieldtype": "Link", + "label": "Current BOM", + "options": "BOM", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "description": "The new BOM after replacement", + "fieldname": "new_bom", + "fieldtype": "Link", + "label": "New BOM", + "options": "BOM", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "replace", + "fieldtype": "Button", + "label": "Replace", + "options": "replace_bom", + "permlevel": 0, + "read_only": 0 + } + ], + "hide_heading": 1, + "hide_toolbar": 1, + "icon": "icon-magic", + "idx": 1, + "in_create": 1, + "issingle": 1, + "modified": "2013-07-05 14:27:52.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "BOM Replace Tool", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "permlevel": 0, + "read": 1, + "report": 0, + "role": "Manufacturing Manager", + "submit": 0, + "write": 1 + } + ], + "read_only": 1 +} \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py index 598d822cd5b..b772fcb3d3b 100644 --- a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py +++ b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py @@ -4,38 +4,35 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt -from frappe.model.code import get_obj from frappe import msgprint, _ -class DocType: - def __init__( self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - +from frappe.model.document import Document + +class BOMReplaceTool(Document): def replace_bom(self): self.validate_bom() self.update_new_bom() bom_list = self.get_parent_boms() updated_bom = [] for bom in bom_list: - bom_obj = get_obj("BOM", bom, with_children=1) + bom_obj = frappe.get_doc("BOM", bom) updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom) frappe.msgprint(_("BOM replaced")) def validate_bom(self): - if cstr(self.doc.current_bom) == cstr(self.doc.new_bom): + if cstr(self.current_bom) == cstr(self.new_bom): msgprint("Current BOM and New BOM can not be same", raise_exception=1) def update_new_bom(self): current_bom_unitcost = frappe.db.sql("""select total_cost/quantity - from `tabBOM` where name = %s""", self.doc.current_bom) + from `tabBOM` where name = %s""", self.current_bom) current_bom_unitcost = current_bom_unitcost and flt(current_bom_unitcost[0][0]) or 0 frappe.db.sql("""update `tabBOM Item` set bom_no=%s, rate=%s, amount=qty*%s where bom_no = %s and docstatus < 2""", - (self.doc.new_bom, current_bom_unitcost, current_bom_unitcost, self.doc.current_bom)) + (self.new_bom, current_bom_unitcost, current_bom_unitcost, self.current_bom)) def get_parent_boms(self): return [d[0] for d in frappe.db.sql("""select distinct parent from `tabBOM Item` where ifnull(bom_no, '') = %s and docstatus < 2""", - self.doc.new_bom)] \ No newline at end of file + self.new_bom)] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.txt b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.txt deleted file mode 100644 index cdb65ee24a9..00000000000 --- a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.txt +++ /dev/null @@ -1,80 +0,0 @@ -[ - { - "creation": "2012-12-06 12:10:10", - "docstatus": 0, - "modified": "2013-07-05 14:27:52", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_copy": 1, - "allow_email": 1, - "allow_print": 1, - "description": "Replace a particular BOM in all other BOMs where it is used. It will replace the old BOM link, update cost and regenerate \"BOM Explosion Item\" table as per new BOM", - "doctype": "DocType", - "document_type": "Other", - "hide_heading": 1, - "hide_toolbar": 1, - "icon": "icon-magic", - "in_create": 1, - "issingle": 1, - "module": "Manufacturing", - "name": "__common__", - "read_only": 1 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "BOM Replace Tool", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "read_only": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "BOM Replace Tool", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 0, - "role": "Manufacturing Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "BOM Replace Tool" - }, - { - "description": "The BOM which will be replaced", - "doctype": "DocField", - "fieldname": "current_bom", - "fieldtype": "Link", - "label": "Current BOM", - "options": "BOM", - "reqd": 1 - }, - { - "description": "The new BOM after replacement", - "doctype": "DocField", - "fieldname": "new_bom", - "fieldtype": "Link", - "label": "New BOM", - "options": "BOM", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "replace", - "fieldtype": "Button", - "label": "Replace", - "options": "replace_bom" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js index 86580d611c8..59017319b96 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.js +++ b/erpnext/manufacturing/doctype/production_order/production_order.js @@ -70,7 +70,7 @@ cur_frm.cscript['Stop Production Order'] = function() { var doc = cur_frm.doc; var check = confirm(frappe._("Do you really want to stop production order: " + doc.name)); if (check) { - return $c_obj(make_doclist(doc.doctype, doc.name), 'stop_unstop', 'Stopped', function(r, rt) {cur_frm.refresh();}); + return $c_obj(doc, 'stop_unstop', 'Stopped', function(r, rt) {cur_frm.refresh();}); } } @@ -78,7 +78,7 @@ cur_frm.cscript['Unstop Production Order'] = function() { var doc = cur_frm.doc; var check = confirm(frappe._("Do really want to unstop production order: " + doc.name)); if (check) - return $c_obj(make_doclist(doc.doctype, doc.name), 'stop_unstop', 'Unstopped', function(r, rt) {cur_frm.refresh();}); + return $c_obj(doc, 'stop_unstop', 'Unstopped', function(r, rt) {cur_frm.refresh();}); } cur_frm.cscript['Transfer Raw Materials'] = function() { diff --git a/erpnext/manufacturing/doctype/production_order/production_order.json b/erpnext/manufacturing/doctype/production_order/production_order.json new file mode 100644 index 00000000000..b1ff6289fe8 --- /dev/null +++ b/erpnext/manufacturing/doctype/production_order/production_order.json @@ -0,0 +1,248 @@ +{ + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-01-10 16:34:16.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item", + "fieldtype": "Section Break", + "label": "Item", + "options": "icon-gift", + "permlevel": 0 + }, + { + "default": "PRO", + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "options": "\nPRO", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "production_item", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item To Manufacture", + "oldfieldname": "production_item", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "depends_on": "production_item", + "description": "Bill of Material to be considered for manufacturing", + "fieldname": "bom_no", + "fieldtype": "Link", + "in_list_view": 1, + "label": "BOM No", + "oldfieldname": "bom_no", + "oldfieldtype": "Link", + "options": "BOM", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "default": "1", + "description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.", + "fieldname": "use_multi_level_bom", + "fieldtype": "Check", + "label": "Use Multi-Level BOM", + "permlevel": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "description": "Manufacture against Sales Order", + "fieldname": "sales_order", + "fieldtype": "Link", + "label": "Sales Order", + "options": "Sales Order", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "production_item", + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Qty To Manufacture", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "depends_on": "eval:doc.docstatus==1", + "description": "Automatically updated via Stock Entry of type Manufacture/Repack", + "fieldname": "produced_qty", + "fieldtype": "Float", + "label": "Manufactured Qty", + "no_copy": 1, + "oldfieldname": "produced_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "sales_order", + "fieldname": "expected_delivery_date", + "fieldtype": "Date", + "label": "Expected Delivery Date", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "warehouses", + "fieldtype": "Section Break", + "label": "Warehouses", + "options": "icon-building", + "permlevel": 0 + }, + { + "depends_on": "production_item", + "description": "Manufactured quantity will be updated in this warehouse", + "fieldname": "fg_warehouse", + "fieldtype": "Link", + "in_list_view": 1, + "label": "For Warehouse", + "options": "Warehouse", + "permlevel": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "column_break_12", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "wip_warehouse", + "fieldtype": "Link", + "label": "Work-in-Progress Warehouse", + "options": "Warehouse", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "options": "icon-file-text", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nDraft\nSubmitted\nStopped\nIn Process\nCompleted\nCancelled", + "permlevel": 0, + "read_only": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "label": "Item Description", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "project_name", + "fieldtype": "Link", + "in_filter": 1, + "label": "Project Name", + "oldfieldname": "project_name", + "oldfieldtype": "Link", + "options": "Project", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "depends_on": "production_item", + "fieldname": "stock_uom", + "fieldtype": "Link", + "label": "Stock UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-cogs", + "idx": 1, + "in_create": 0, + "is_submittable": 1, + "modified": "2014-01-20 17:49:01.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Production Order", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Manufacturing User", + "submit": 1, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index abc6cfd466a..af92413be62 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -5,22 +5,20 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt, nowdate -from frappe.model.code import get_obj from frappe import msgprint, _ class OverProductionError(frappe.ValidationError): pass -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class ProductionOrder(Document): def validate(self): - if self.doc.docstatus == 0: - self.doc.status = "Draft" + if self.docstatus == 0: + self.status = "Draft" from erpnext.utilities import validate_status - validate_status(self.doc.status, ["Draft", "Submitted", "Stopped", + validate_status(self.status, ["Draft", "Submitted", "Stopped", "In Process", "Completed", "Cancelled"]) self.validate_bom_no() @@ -28,106 +26,106 @@ class DocType: self.validate_warehouse() from erpnext.utilities.transaction_base import validate_uom_is_integer - validate_uom_is_integer(self.doclist, "stock_uom", ["qty", "produced_qty"]) + validate_uom_is_integer(self, "stock_uom", ["qty", "produced_qty"]) def validate_bom_no(self): - if self.doc.bom_no: + if self.bom_no: bom = frappe.db.sql("""select name from `tabBOM` where name=%s and docstatus=1 and is_active=1 and item=%s""" - , (self.doc.bom_no, self.doc.production_item), as_dict =1) + , (self.bom_no, self.production_item), as_dict =1) if not bom: frappe.throw("""Incorrect BOM: %s entered. May be BOM not exists or inactive or not submitted - or for some other item.""" % cstr(self.doc.bom_no)) + or for some other item.""" % cstr(self.bom_no)) def validate_sales_order(self): - if self.doc.sales_order: + if self.sales_order: so = frappe.db.sql("""select name, delivery_date from `tabSales Order` - where name=%s and docstatus = 1""", self.doc.sales_order, as_dict=1)[0] + where name=%s and docstatus = 1""", self.sales_order, as_dict=1)[0] if not so.name: - frappe.throw("Sales Order: %s is not valid" % self.doc.sales_order) + frappe.throw("Sales Order: %s is not valid" % self.sales_order) - if not self.doc.expected_delivery_date: - self.doc.expected_delivery_date = so.delivery_date + if not self.expected_delivery_date: + self.expected_delivery_date = so.delivery_date self.validate_production_order_against_so() def validate_warehouse(self): from erpnext.stock.utils import validate_warehouse_company - for w in [self.doc.fg_warehouse, self.doc.wip_warehouse]: - validate_warehouse_company(w, self.doc.company) + for w in [self.fg_warehouse, self.wip_warehouse]: + validate_warehouse_company(w, self.company) def validate_production_order_against_so(self): # already ordered qty ordered_qty_against_so = frappe.db.sql("""select sum(qty) from `tabProduction Order` where production_item = %s and sales_order = %s and docstatus < 2 and name != %s""", - (self.doc.production_item, self.doc.sales_order, self.doc.name))[0][0] + (self.production_item, self.sales_order, self.name))[0][0] - total_qty = flt(ordered_qty_against_so) + flt(self.doc.qty) + total_qty = flt(ordered_qty_against_so) + flt(self.qty) # get qty from Sales Order Item table so_item_qty = frappe.db.sql("""select sum(qty) from `tabSales Order Item` where parent = %s and item_code = %s""", - (self.doc.sales_order, self.doc.production_item))[0][0] + (self.sales_order, self.production_item))[0][0] # get qty from Packing Item table dnpi_qty = frappe.db.sql("""select sum(qty) from `tabPacked Item` where parent = %s and parenttype = 'Sales Order' and item_code = %s""", - (self.doc.sales_order, self.doc.production_item))[0][0] + (self.sales_order, self.production_item))[0][0] # total qty in SO so_qty = flt(so_item_qty) + flt(dnpi_qty) if total_qty > so_qty: frappe.throw(_("Total production order qty for item") + ": " + - cstr(self.doc.production_item) + _(" against sales order") + ": " + - cstr(self.doc.sales_order) + _(" will be ") + cstr(total_qty) + ", " + + cstr(self.production_item) + _(" against sales order") + ": " + + cstr(self.sales_order) + _(" will be ") + cstr(total_qty) + ", " + _("which is greater than sales order qty ") + "(" + cstr(so_qty) + ")" + _("Please reduce qty."), exc=OverProductionError) def stop_unstop(self, status): """ Called from client side on Stop/Unstop event""" self.update_status(status) - qty = (flt(self.doc.qty)-flt(self.doc.produced_qty)) * ((status == 'Stopped') and -1 or 1) + qty = (flt(self.qty)-flt(self.produced_qty)) * ((status == 'Stopped') and -1 or 1) self.update_planned_qty(qty) msgprint("Production Order has been %s" % status) def update_status(self, status): if status == 'Stopped': - frappe.db.set(self.doc, 'status', cstr(status)) + frappe.db.set(self, 'status', cstr(status)) else: - if flt(self.doc.qty) == flt(self.doc.produced_qty): - frappe.db.set(self.doc, 'status', 'Completed') - if flt(self.doc.qty) > flt(self.doc.produced_qty): - frappe.db.set(self.doc, 'status', 'In Process') - if flt(self.doc.produced_qty) == 0: - frappe.db.set(self.doc, 'status', 'Submitted') + if flt(self.qty) == flt(self.produced_qty): + frappe.db.set(self, 'status', 'Completed') + if flt(self.qty) > flt(self.produced_qty): + frappe.db.set(self, 'status', 'In Process') + if flt(self.produced_qty) == 0: + frappe.db.set(self, 'status', 'Submitted') def on_submit(self): - if not self.doc.wip_warehouse: + if not self.wip_warehouse: frappe.throw(_("WIP Warehouse required before Submit")) - frappe.db.set(self.doc,'status', 'Submitted') - self.update_planned_qty(self.doc.qty) + frappe.db.set(self,'status', 'Submitted') + self.update_planned_qty(self.qty) def on_cancel(self): # Check whether any stock entry exists against this Production Order stock_entry = frappe.db.sql("""select name from `tabStock Entry` - where production_order = %s and docstatus = 1""", self.doc.name) + where production_order = %s and docstatus = 1""", self.name) if stock_entry: frappe.throw("""Submitted Stock Entry %s exists against this production order. Hence can not be cancelled.""" % stock_entry[0][0]) - frappe.db.set(self.doc,'status', 'Cancelled') - self.update_planned_qty(-self.doc.qty) + frappe.db.set(self,'status', 'Cancelled') + self.update_planned_qty(-self.qty) def update_planned_qty(self, qty): """update planned qty in bin""" args = { - "item_code": self.doc.production_item, - "warehouse": self.doc.fg_warehouse, + "item_code": self.production_item, + "warehouse": self.fg_warehouse, "posting_date": nowdate(), "planned_qty": flt(qty) } @@ -153,21 +151,21 @@ def get_item_details(item): @frappe.whitelist() def make_stock_entry(production_order_id, purpose): - production_order = frappe.bean("Production Order", production_order_id) + production_order = frappe.get_doc("Production Order", production_order_id) - stock_entry = frappe.new_bean("Stock Entry") - stock_entry.doc.purpose = purpose - stock_entry.doc.production_order = production_order_id - stock_entry.doc.company = production_order.doc.company - stock_entry.doc.bom_no = production_order.doc.bom_no - stock_entry.doc.use_multi_level_bom = production_order.doc.use_multi_level_bom - stock_entry.doc.fg_completed_qty = flt(production_order.doc.qty) - flt(production_order.doc.produced_qty) + stock_entry = frappe.new_doc("Stock Entry") + stock_entry.purpose = purpose + stock_entry.production_order = production_order_id + stock_entry.company = production_order.company + stock_entry.bom_no = production_order.bom_no + stock_entry.use_multi_level_bom = production_order.use_multi_level_bom + stock_entry.fg_completed_qty = flt(production_order.qty) - flt(production_order.produced_qty) if purpose=="Material Transfer": - stock_entry.doc.to_warehouse = production_order.doc.wip_warehouse + stock_entry.to_warehouse = production_order.wip_warehouse else: - stock_entry.doc.from_warehouse = production_order.doc.wip_warehouse - stock_entry.doc.to_warehouse = production_order.doc.fg_warehouse + stock_entry.from_warehouse = production_order.wip_warehouse + stock_entry.to_warehouse = production_order.fg_warehouse stock_entry.run_method("get_items") - return [d.fields for d in stock_entry.doclist] + return stock_entry.as_dict() diff --git a/erpnext/manufacturing/doctype/production_order/production_order.txt b/erpnext/manufacturing/doctype/production_order/production_order.txt deleted file mode 100644 index 41ef1ce6396..00000000000 --- a/erpnext/manufacturing/doctype/production_order/production_order.txt +++ /dev/null @@ -1,267 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:16", - "docstatus": 0, - "modified": "2014-01-20 17:49:01", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "icon": "icon-cogs", - "in_create": 0, - "is_submittable": 1, - "module": "Manufacturing", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Production Order", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Production Order", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Manufacturing User", - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Production Order" - }, - { - "doctype": "DocField", - "fieldname": "item", - "fieldtype": "Section Break", - "label": "Item", - "options": "icon-gift" - }, - { - "default": "PRO", - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "options": "\nPRO", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "production_item", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item To Manufacture", - "oldfieldname": "production_item", - "oldfieldtype": "Link", - "options": "Item", - "read_only": 0, - "reqd": 1 - }, - { - "depends_on": "production_item", - "description": "Bill of Material to be considered for manufacturing", - "doctype": "DocField", - "fieldname": "bom_no", - "fieldtype": "Link", - "in_list_view": 1, - "label": "BOM No", - "oldfieldname": "bom_no", - "oldfieldtype": "Link", - "options": "BOM", - "read_only": 0, - "reqd": 1 - }, - { - "default": "1", - "description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.", - "doctype": "DocField", - "fieldname": "use_multi_level_bom", - "fieldtype": "Check", - "label": "Use Multi-Level BOM" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "description": "Manufacture against Sales Order", - "doctype": "DocField", - "fieldname": "sales_order", - "fieldtype": "Link", - "label": "Sales Order", - "options": "Sales Order", - "read_only": 0 - }, - { - "depends_on": "production_item", - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Qty To Manufacture", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "read_only": 0, - "reqd": 1 - }, - { - "depends_on": "eval:doc.docstatus==1", - "description": "Automatically updated via Stock Entry of type Manufacture/Repack", - "doctype": "DocField", - "fieldname": "produced_qty", - "fieldtype": "Float", - "label": "Manufactured Qty", - "no_copy": 1, - "oldfieldname": "produced_qty", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "depends_on": "sales_order", - "doctype": "DocField", - "fieldname": "expected_delivery_date", - "fieldtype": "Date", - "label": "Expected Delivery Date", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "warehouses", - "fieldtype": "Section Break", - "label": "Warehouses", - "options": "icon-building" - }, - { - "depends_on": "production_item", - "description": "Manufactured quantity will be updated in this warehouse", - "doctype": "DocField", - "fieldname": "fg_warehouse", - "fieldtype": "Link", - "in_list_view": 1, - "label": "For Warehouse", - "options": "Warehouse", - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_12", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "wip_warehouse", - "fieldtype": "Link", - "label": "Work-in-Progress Warehouse", - "options": "Warehouse", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "options": "icon-file-text", - "read_only": 0 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nDraft\nSubmitted\nStopped\nIn Process\nCompleted\nCancelled", - "read_only": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "label": "Item Description", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "project_name", - "fieldtype": "Link", - "in_filter": 1, - "label": "Project Name", - "oldfieldname": "project_name", - "oldfieldtype": "Link", - "options": "Project", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "depends_on": "production_item", - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "label": "Stock UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_order/test_production_order.py b/erpnext/manufacturing/doctype/production_order/test_production_order.py index 928abaea322..9bc001d9b48 100644 --- a/erpnext/manufacturing/doctype/production_order/test_production_order.py +++ b/erpnext/manufacturing/doctype/production_order/test_production_order.py @@ -16,64 +16,53 @@ class TestProductionOrder(unittest.TestCase): frappe.db.sql("delete from `tabStock Ledger Entry`") frappe.db.sql("""delete from `tabBin`""") frappe.db.sql("""delete from `tabGL Entry`""") - - pro_bean = frappe.bean(copy = test_records[0]) - pro_bean.insert() - pro_bean.submit() - + + pro_doc = frappe.copy_doc(test_records[0]) + pro_doc.insert() + pro_doc.submit() + from erpnext.stock.doctype.stock_entry.test_stock_entry import test_records as se_test_records - mr1 = frappe.bean(copy = se_test_records[0]) + mr1 = frappe.copy_doc(se_test_records[0]) mr1.insert() mr1.submit() - - mr2 = frappe.bean(copy = se_test_records[0]) - mr2.doclist[1].item_code = "_Test Item Home Desktop 100" + + mr2 = frappe.copy_doc(se_test_records[0]) + mr2.get("mtn_details")[0].item_code = "_Test Item Home Desktop 100" mr2.insert() mr2.submit() - - stock_entry = make_stock_entry(pro_bean.doc.name, "Manufacture/Repack") - stock_entry = frappe.bean(stock_entry) - stock_entry.doc.fiscal_year = "_Test Fiscal Year 2013" - stock_entry.doc.fg_completed_qty = 4 - stock_entry.doc.posting_date = "2013-05-12" - stock_entry.doc.fiscal_year = "_Test Fiscal Year 2013" + + stock_entry = make_stock_entry(pro_doc.name, "Manufacture/Repack") + stock_entry = frappe.get_doc(stock_entry) + stock_entry.fiscal_year = "_Test Fiscal Year 2013" + stock_entry.fg_completed_qty = 4 + stock_entry.posting_date = "2013-05-12" + stock_entry.fiscal_year = "_Test Fiscal Year 2013" + stock_entry.set("mtn_details", []) stock_entry.run_method("get_items") stock_entry.submit() - - self.assertEqual(frappe.db.get_value("Production Order", pro_bean.doc.name, + + self.assertEqual(frappe.db.get_value("Production Order", pro_doc.name, "produced_qty"), 4) - self.assertEqual(frappe.db.get_value("Bin", {"item_code": "_Test FG Item", + self.assertEqual(frappe.db.get_value("Bin", {"item_code": "_Test FG Item", "warehouse": "_Test Warehouse 1 - _TC"}, "planned_qty"), 6) - - return pro_bean.doc.name - + + return pro_doc.name + def test_over_production(self): from erpnext.stock.doctype.stock_entry.stock_entry import StockOverProductionError pro_order = self.test_planned_qty() - + stock_entry = make_stock_entry(pro_order, "Manufacture/Repack") - stock_entry = frappe.bean(stock_entry) - stock_entry.doc.posting_date = "2013-05-12" - stock_entry.doc.fiscal_year = "_Test Fiscal Year 2013" - stock_entry.doc.fg_completed_qty = 15 + stock_entry = frappe.get_doc(stock_entry) + stock_entry.posting_date = "2013-05-12" + stock_entry.fiscal_year = "_Test Fiscal Year 2013" + stock_entry.fg_completed_qty = 15 + stock_entry.set("mtn_details", []) stock_entry.run_method("get_items") stock_entry.insert() - - self.assertRaises(StockOverProductionError, stock_entry.submit) - - -test_records = [ - [ - { - "bom_no": "BOM/_Test FG Item/001", - "company": "_Test Company", - "doctype": "Production Order", - "production_item": "_Test FG Item", - "qty": 10.0, - "fg_warehouse": "_Test Warehouse 1 - _TC", - "wip_warehouse": "_Test Warehouse - _TC", - "stock_uom": "Nos" - } - ] -] \ No newline at end of file + self.assertRaises(StockOverProductionError, stock_entry.submit) + + + +test_records = frappe.get_test_records('Production Order') diff --git a/erpnext/manufacturing/doctype/production_order/test_records.json b/erpnext/manufacturing/doctype/production_order/test_records.json new file mode 100644 index 00000000000..d6afc065f1f --- /dev/null +++ b/erpnext/manufacturing/doctype/production_order/test_records.json @@ -0,0 +1,12 @@ +[ + { + "bom_no": "BOM/_Test FG Item/001", + "company": "_Test Company", + "doctype": "Production Order", + "fg_warehouse": "_Test Warehouse 1 - _TC", + "production_item": "_Test FG Item", + "qty": 10.0, + "stock_uom": "Nos", + "wip_warehouse": "_Test Warehouse - _TC" + } +] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.json b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.json new file mode 100644 index 00000000000..cb5d24f8c93 --- /dev/null +++ b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.json @@ -0,0 +1,112 @@ +{ + "autoname": "PPID/.#####", + "creation": "2013-02-22 01:27:49.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_width": "150px", + "reqd": 1, + "width": "150px" + }, + { + "fieldname": "bom_no", + "fieldtype": "Link", + "in_list_view": 1, + "label": "BOM No", + "oldfieldname": "bom_no", + "oldfieldtype": "Link", + "options": "BOM", + "permlevel": 0, + "print_width": "100px", + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "planned_qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Planned Qty", + "oldfieldname": "planned_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "100px", + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "sales_order", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Sales Order", + "oldfieldname": "source_docname", + "oldfieldtype": "Data", + "options": "Sales Order", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "so_pending_qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "SO Pending Qty", + "oldfieldname": "prevdoc_reqd_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "width": "100px" + }, + { + "description": "Reserved Warehouse in Sales Order / Finished Goods Warehouse", + "fieldname": "warehouse", + "fieldtype": "Link", + "label": "Warehouse", + "options": "Warehouse", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "print_width": "80px", + "read_only": 1, + "reqd": 1, + "width": "80px" + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "200px", + "read_only": 1, + "width": "200px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:25.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Production Plan Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py index 26c87f1c04a..a9a9c61f0dd 100644 --- a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py +++ b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ProductionPlanItem(Document): + pass \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.txt b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.txt deleted file mode 100644 index 20681881c31..00000000000 --- a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.txt +++ /dev/null @@ -1,125 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:49", - "docstatus": 0, - "modified": "2013-12-20 19:23:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "PPID/.#####", - "doctype": "DocType", - "istable": 1, - "module": "Manufacturing", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Production Plan Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Production Plan Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "print_width": "150px", - "reqd": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "bom_no", - "fieldtype": "Link", - "in_list_view": 1, - "label": "BOM No", - "oldfieldname": "bom_no", - "oldfieldtype": "Link", - "options": "BOM", - "print_width": "100px", - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "planned_qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Planned Qty", - "oldfieldname": "planned_qty", - "oldfieldtype": "Currency", - "print_width": "100px", - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "sales_order", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Sales Order", - "oldfieldname": "source_docname", - "oldfieldtype": "Data", - "options": "Sales Order", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "so_pending_qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "SO Pending Qty", - "oldfieldname": "prevdoc_reqd_qty", - "oldfieldtype": "Currency", - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "description": "Reserved Warehouse in Sales Order / Finished Goods Warehouse", - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "label": "Warehouse", - "options": "Warehouse", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "print_width": "80px", - "read_only": 1, - "reqd": 1, - "width": "80px" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "print_width": "200px", - "read_only": 1, - "width": "200px" - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.json b/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.json new file mode 100644 index 00000000000..2b6c39314d8 --- /dev/null +++ b/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.json @@ -0,0 +1,61 @@ +{ + "autoname": "PP/.SO/.#####", + "creation": "2013-02-22 01:27:49.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "sales_order", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Sales Order", + "oldfieldname": "prevdoc_docname", + "oldfieldtype": "Data", + "options": "Sales Order", + "permlevel": 0, + "print_width": "150px", + "width": "150px" + }, + { + "fieldname": "sales_order_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "SO Date", + "oldfieldname": "document_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_width": "120px", + "read_only": 1, + "width": "120px" + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Customer", + "options": "Customer", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "grand_total", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Grand Total", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_width": "120px", + "read_only": 1, + "width": "120px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:25.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Production Plan Sales Order", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py b/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py index 26c87f1c04a..c0be09e9c51 100644 --- a/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py +++ b/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ProductionPlanSalesOrder(Document): + pass \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.txt b/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.txt deleted file mode 100644 index 11a02a56aa7..00000000000 --- a/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.txt +++ /dev/null @@ -1,71 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:49", - "docstatus": 0, - "modified": "2013-12-20 19:23:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "PP/.SO/.#####", - "doctype": "DocType", - "istable": 1, - "module": "Manufacturing", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Production Plan Sales Order", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Production Plan Sales Order" - }, - { - "doctype": "DocField", - "fieldname": "sales_order", - "fieldtype": "Link", - "label": "Sales Order", - "oldfieldname": "prevdoc_docname", - "oldfieldtype": "Data", - "options": "Sales Order", - "print_width": "150px", - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "sales_order_date", - "fieldtype": "Date", - "label": "SO Date", - "oldfieldname": "document_date", - "oldfieldtype": "Date", - "print_width": "120px", - "read_only": 1, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "label": "Customer", - "options": "Customer", - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "grand_total", - "fieldtype": "Currency", - "label": "Grand Total", - "options": "Company:company:default_currency", - "print_width": "120px", - "read_only": 1, - "width": "120px" - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js index fdd4db1d77c..fc7abde06cf 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js @@ -25,9 +25,9 @@ cur_frm.cscript.item_code = function(doc,cdt,cdn) { } cur_frm.cscript.download_materials_required = function(doc, cdt, cdn) { - return $c_obj(make_doclist(cdt, cdn), 'validate_data', '', function(r, rt) { + return $c_obj(doc, 'validate_data', '', function(r, rt) { if (!r['exc']) - $c_obj_csv(make_doclist(cdt, cdn), 'download_raw_materials', '', ''); + $c_obj_csv(doc, 'download_raw_materials', '', ''); }); } diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json new file mode 100644 index 00000000000..bdfab41fba7 --- /dev/null +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json @@ -0,0 +1,177 @@ +{ + "creation": "2013-01-21 12:03:47.000000", + "default_print_format": "Standard", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Select Sales Orders from which you want to create Production Orders.", + "fieldname": "select_sales_orders", + "fieldtype": "Section Break", + "label": "Select Sales Orders", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "fg_item", + "fieldtype": "Link", + "label": "Filter based on item", + "options": "Item", + "permlevel": 0 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "label": "Filter based on customer", + "options": "Customer", + "permlevel": 0 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "from_date", + "fieldtype": "Date", + "label": "From Date", + "permlevel": 0 + }, + { + "fieldname": "to_date", + "fieldtype": "Date", + "label": "To Date", + "permlevel": 0 + }, + { + "fieldname": "section_break1", + "fieldtype": "Section Break", + "options": "Simple", + "permlevel": 0 + }, + { + "description": "Pull sales orders (pending to deliver) based on the above criteria", + "fieldname": "get_sales_orders", + "fieldtype": "Button", + "label": "Get Sales Orders", + "options": "get_open_sales_orders", + "permlevel": 0 + }, + { + "fieldname": "pp_so_details", + "fieldtype": "Table", + "label": "Production Plan Sales Orders", + "options": "Production Plan Sales Order", + "permlevel": 0 + }, + { + "fieldname": "items_for_production", + "fieldtype": "Section Break", + "label": "Select Items", + "permlevel": 0 + }, + { + "fieldname": "get_items_from_so", + "fieldtype": "Button", + "label": "Get Items From Sales Orders", + "options": "get_items_from_so", + "permlevel": 0 + }, + { + "default": "1", + "description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.", + "fieldname": "use_multi_level_bom", + "fieldtype": "Check", + "label": "Use Multi-Level BOM", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "pp_details", + "fieldtype": "Table", + "label": "Production Plan Items", + "options": "Production Plan Item", + "permlevel": 0 + }, + { + "description": "Enter items and planned qty for which you want to raise production orders or download raw materials for analysis.", + "fieldname": "create_production_orders", + "fieldtype": "Section Break", + "label": "Production Orders", + "permlevel": 0 + }, + { + "description": "Separate production order will be created for each finished good item.", + "fieldname": "raise_production_order", + "fieldtype": "Button", + "label": "Create Production Orders", + "options": "raise_production_order", + "permlevel": 0 + }, + { + "fieldname": "sb5", + "fieldtype": "Section Break", + "label": "Material Requirement", + "permlevel": 0 + }, + { + "fieldname": "purchase_request_for_warehouse", + "fieldtype": "Link", + "label": "Material Request For Warehouse", + "options": "Warehouse", + "permlevel": 0 + }, + { + "description": "Items to be requested which are \"Out of Stock\" considering all warehouses based on projected qty and minimum order qty", + "fieldname": "raise_purchase_request", + "fieldtype": "Button", + "label": "Create Material Requests", + "options": "raise_purchase_request", + "permlevel": 0 + }, + { + "description": "Download a report containing all raw materials with their latest inventory status", + "fieldname": "download_materials_required", + "fieldtype": "Button", + "label": "Download Materials Required", + "permlevel": 0 + } + ], + "icon": "icon-calendar", + "idx": 1, + "in_create": 1, + "issingle": 1, + "modified": "2013-12-20 19:23:25.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Production Planning Tool", + "owner": "jai@webnotestech.com", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "Manufacturing User", + "submit": 0, + "write": 1 + } + ], + "read_only": 1 +} \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py index 60007cd8397..e3fe7c3d9a6 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -4,15 +4,14 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt, cint, nowdate, add_days -from frappe.model.doc import addchild, Document -from frappe.model.bean import getlist -from frappe.model.code import get_obj + from frappe import msgprint, _ -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class ProductionPlanningTool(Document): + def __init__(self, arg1, arg2=None): + super(ProductionPlanningTool, self).__init__(arg1, arg2) self.item_dict = {} def get_so_details(self, so): @@ -39,27 +38,27 @@ class DocType: return ret def clear_so_table(self): - self.doclist = self.doc.clear_table(self.doclist, 'pp_so_details') + self.set('pp_so_details', []) def clear_item_table(self): - self.doclist = self.doc.clear_table(self.doclist, 'pp_details') + self.set('pp_details', []) def validate_company(self): - if not self.doc.company: + if not self.company: frappe.throw(_("Please enter Company")) def get_open_sales_orders(self): """ Pull sales orders which are pending to deliver based on criteria selected""" so_filter = item_filter = "" - if self.doc.from_date: - so_filter += ' and so.transaction_date >= "' + self.doc.from_date + '"' - if self.doc.to_date: - so_filter += ' and so.transaction_date <= "' + self.doc.to_date + '"' - if self.doc.customer: - so_filter += ' and so.customer = "' + self.doc.customer + '"' + if self.from_date: + so_filter += ' and so.transaction_date >= "' + self.from_date + '"' + if self.to_date: + so_filter += ' and so.transaction_date <= "' + self.to_date + '"' + if self.customer: + so_filter += ' and so.customer = "' + self.customer + '"' - if self.doc.fg_item: - item_filter += ' and item.name = "' + self.doc.fg_item + '"' + if self.fg_item: + item_filter += ' and item.name = "' + self.fg_item + '"' open_so = frappe.db.sql(""" select distinct so.name, so.transaction_date, so.customer, so.grand_total @@ -76,7 +75,7 @@ class DocType: and exists (select name from `tabItem` item where item.name=pi.item_code and (ifnull(item.is_pro_applicable, 'No') = 'Yes' or ifnull(item.is_sub_contracted_item, 'No') = 'Yes') %s))) - """ % ('%s', so_filter, item_filter, item_filter), self.doc.company, as_dict=1) + """ % ('%s', so_filter, item_filter, item_filter), self.company, as_dict=1) self.add_so_in_table(open_so) @@ -84,11 +83,10 @@ class DocType: """ Add sales orders in the table""" self.clear_so_table() - so_list = [d.sales_order for d in getlist(self.doclist, 'pp_so_details')] + so_list = [d.sales_order for d in self.get('pp_so_details')] for r in open_so: if cstr(r['name']) not in so_list: - pp_so = addchild(self.doc, 'pp_so_details', - 'Production Plan Sales Order', self.doclist) + pp_so = self.append('pp_so_details', {}) pp_so.sales_order = r['name'] pp_so.sales_order_date = cstr(r['transaction_date']) pp_so.customer = cstr(r['customer']) @@ -103,7 +101,7 @@ class DocType: self.add_items(items) def get_items(self): - so_list = filter(None, [d.sales_order for d in getlist(self.doclist, 'pp_so_details')]) + so_list = filter(None, [d.sales_order for d in self.get('pp_so_details')]) if not so_list: msgprint(_("Please enter sales order in the above table")) return [] @@ -138,7 +136,7 @@ class DocType: for p in items: item_details = frappe.db.sql("""select description, stock_uom, default_bom from tabItem where name=%s""", p['item_code']) - pi = addchild(self.doc, 'pp_details', 'Production Plan Item', self.doclist) + pi = self.append('pp_details', {}) pi.sales_order = p['parent'] pi.warehouse = p['warehouse'] pi.item_code = p['item_code'] @@ -151,7 +149,7 @@ class DocType: def validate_data(self): self.validate_company() - for d in getlist(self.doclist, 'pp_details'): + for d in self.get('pp_details'): self.validate_bom_no(d) if not flt(d.planned_qty): frappe.throw("Please Enter Planned Qty for item: %s at row no: %s" % @@ -175,7 +173,7 @@ class DocType: self.validate_data() from erpnext.utilities.transaction_base import validate_uom_is_integer - validate_uom_is_integer(self.doclist, "stock_uom", "planned_qty") + validate_uom_is_integer(self, "stock_uom", "planned_qty") items = self.get_distinct_items_and_boms()[1] pro = self.create_production_order(items) @@ -193,7 +191,7 @@ class DocType: } """ item_dict, bom_dict = {}, {} - for d in self.doclist.get({"parentfield": "pp_details"}): + for d in self.get("pp_details"): bom_dict.setdefault(d.bom_no, []).append([d.sales_order, flt(d.planned_qty)]) item_dict[(d.item_code, d.sales_order, d.warehouse)] = { "production_item" : d.item_code, @@ -203,7 +201,7 @@ class DocType: "bom_no" : d.bom_no, "description" : d.description, "stock_uom" : d.stock_uom, - "company" : self.doc.company, + "company" : self.company, "wip_warehouse" : "", "fg_warehouse" : d.warehouse, "status" : "Draft", @@ -216,13 +214,13 @@ class DocType: pro_list = [] for key in items: - pro = frappe.new_bean("Production Order") - pro.doc.fields.update(items[key]) + pro = frappe.new_doc("Production Order") + pro.update(items[key]) frappe.flags.mute_messages = True try: pro.insert() - pro_list.append(pro.doc.name) + pro_list.append(pro.name) except OverProductionError, e: pass @@ -247,7 +245,7 @@ class DocType: for bom, so_wise_qty in bom_dict.items(): bom_wise_item_details = {} - if self.doc.use_multi_level_bom: + if self.use_multi_level_bom: # get all raw materials with sub assembly childs for d in frappe.db.sql("""select fb.item_code, ifnull(sum(fb.qty_consumed_per_unit), 0) as qty, @@ -306,7 +304,7 @@ class DocType: Requested qty should be shortage qty considering minimum order qty """ self.validate_data() - if not self.doc.purchase_request_for_warehouse: + if not self.purchase_request_for_warehouse: frappe.throw(_("Please enter Warehouse for which Material Request will be raised")) bom_dict = self.get_distinct_items_and_boms()[0] @@ -368,39 +366,37 @@ class DocType: purchase_request_list = [] if items_to_be_requested: for item in items_to_be_requested: - item_wrapper = frappe.bean("Item", item) - pr_doclist = [{ + item_wrapper = frappe.get_doc("Item", item) + pr_doc = frappe.get_doc({ "doctype": "Material Request", "__islocal": 1, "naming_series": "IDT", "transaction_date": nowdate(), "status": "Draft", - "company": self.doc.company, + "company": self.company, "fiscal_year": fiscal_year, "requested_by": frappe.session.user, "material_request_type": "Purchase" - }] + }) for sales_order, requested_qty in items_to_be_requested[item].items(): - pr_doclist.append({ + pr_doc.append("indent_details", { "doctype": "Material Request Item", "__islocal": 1, - "parentfield": "indent_details", "item_code": item, - "item_name": item_wrapper.doc.item_name, - "description": item_wrapper.doc.description, - "uom": item_wrapper.doc.stock_uom, - "item_group": item_wrapper.doc.item_group, - "brand": item_wrapper.doc.brand, + "item_name": item_wrapper.item_name, + "description": item_wrapper.description, + "uom": item_wrapper.stock_uom, + "item_group": item_wrapper.item_group, + "brand": item_wrapper.brand, "qty": requested_qty, - "schedule_date": add_days(nowdate(), cint(item_wrapper.doc.lead_time_days)), - "warehouse": self.doc.purchase_request_for_warehouse, + "schedule_date": add_days(nowdate(), cint(item_wrapper.lead_time_days)), + "warehouse": self.purchase_request_for_warehouse, "sales_order_no": sales_order if sales_order!="No Sales Order" else None }) - pr_wrapper = frappe.bean(pr_doclist) - pr_wrapper.ignore_permissions = 1 - pr_wrapper.submit() - purchase_request_list.append(pr_wrapper.doc.name) + pr_doc.ignore_permissions = 1 + pr_doc.submit() + purchase_request_list.append(pr_doc.name) if purchase_request_list: pur_req = ["""%s""" % \ diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.txt b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.txt deleted file mode 100644 index 4c3b065f4a9..00000000000 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.txt +++ /dev/null @@ -1,196 +0,0 @@ -[ - { - "creation": "2013-01-21 12:03:47", - "docstatus": 0, - "modified": "2013-12-20 19:23:25", - "modified_by": "Administrator", - "owner": "jai@webnotestech.com" - }, - { - "default_print_format": "Standard", - "doctype": "DocType", - "icon": "icon-calendar", - "in_create": 1, - "issingle": 1, - "module": "Manufacturing", - "name": "__common__", - "read_only": 1 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Production Planning Tool", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Production Planning Tool", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "role": "Manufacturing User", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Production Planning Tool" - }, - { - "description": "Select Sales Orders from which you want to create Production Orders.", - "doctype": "DocField", - "fieldname": "select_sales_orders", - "fieldtype": "Section Break", - "label": "Select Sales Orders" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "fg_item", - "fieldtype": "Link", - "label": "Filter based on item", - "options": "Item" - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "label": "Filter based on customer", - "options": "Customer" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "from_date", - "fieldtype": "Date", - "label": "From Date" - }, - { - "doctype": "DocField", - "fieldname": "to_date", - "fieldtype": "Date", - "label": "To Date" - }, - { - "doctype": "DocField", - "fieldname": "section_break1", - "fieldtype": "Section Break", - "options": "Simple" - }, - { - "description": "Pull sales orders (pending to deliver) based on the above criteria", - "doctype": "DocField", - "fieldname": "get_sales_orders", - "fieldtype": "Button", - "label": "Get Sales Orders", - "options": "get_open_sales_orders" - }, - { - "doctype": "DocField", - "fieldname": "pp_so_details", - "fieldtype": "Table", - "label": "Production Plan Sales Orders", - "options": "Production Plan Sales Order" - }, - { - "doctype": "DocField", - "fieldname": "items_for_production", - "fieldtype": "Section Break", - "label": "Select Items" - }, - { - "doctype": "DocField", - "fieldname": "get_items_from_so", - "fieldtype": "Button", - "label": "Get Items From Sales Orders", - "options": "get_items_from_so" - }, - { - "default": "1", - "description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.", - "doctype": "DocField", - "fieldname": "use_multi_level_bom", - "fieldtype": "Check", - "label": "Use Multi-Level BOM", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "pp_details", - "fieldtype": "Table", - "label": "Production Plan Items", - "options": "Production Plan Item" - }, - { - "description": "Enter items and planned qty for which you want to raise production orders or download raw materials for analysis.", - "doctype": "DocField", - "fieldname": "create_production_orders", - "fieldtype": "Section Break", - "label": "Production Orders" - }, - { - "description": "Separate production order will be created for each finished good item.", - "doctype": "DocField", - "fieldname": "raise_production_order", - "fieldtype": "Button", - "label": "Create Production Orders", - "options": "raise_production_order" - }, - { - "doctype": "DocField", - "fieldname": "sb5", - "fieldtype": "Section Break", - "label": "Material Requirement" - }, - { - "doctype": "DocField", - "fieldname": "purchase_request_for_warehouse", - "fieldtype": "Link", - "label": "Material Request For Warehouse", - "options": "Warehouse" - }, - { - "description": "Items to be requested which are \"Out of Stock\" considering all warehouses based on projected qty and minimum order qty", - "doctype": "DocField", - "fieldname": "raise_purchase_request", - "fieldtype": "Button", - "label": "Create Material Requests", - "options": "raise_purchase_request" - }, - { - "description": "Download a report containing all raw materials with their latest inventory status", - "doctype": "DocField", - "fieldname": "download_materials_required", - "fieldtype": "Button", - "label": "Download Materials Required" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/workstation/workstation.json b/erpnext/manufacturing/doctype/workstation/workstation.json new file mode 100644 index 00000000000..db3b440ab81 --- /dev/null +++ b/erpnext/manufacturing/doctype/workstation/workstation.json @@ -0,0 +1,149 @@ +{ + "allow_import": 1, + "autoname": "field:workstation_name", + "creation": "2013-01-10 16:34:17.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "workstation_name", + "fieldtype": "Data", + "label": "Workstation Name", + "oldfieldname": "workstation_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "warehouse", + "fieldtype": "Link", + "label": "Warehouse", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "width": "300px" + }, + { + "fieldname": "capacity", + "fieldtype": "Data", + "hidden": 1, + "label": "Capacity", + "oldfieldname": "capacity", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "capacity_units", + "fieldtype": "Select", + "hidden": 1, + "label": "Capacity Units", + "oldfieldname": "capacity_units", + "oldfieldtype": "Select", + "options": "\nUnits/Shifts\nUnits/Hour", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "hour_rate_labour", + "fieldtype": "Float", + "label": "Hour Rate Labour", + "oldfieldname": "hour_rate_labour", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "over_heads", + "fieldtype": "Section Break", + "label": "Overheads", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "description": "Electricity cost per hour", + "fieldname": "hour_rate_electricity", + "fieldtype": "Float", + "label": "Electricity Cost", + "oldfieldname": "hour_rate_electricity", + "oldfieldtype": "Currency", + "permlevel": 0 + }, + { + "description": "Consumable cost per hour", + "fieldname": "hour_rate_consumable", + "fieldtype": "Float", + "label": "Consumable Cost", + "oldfieldname": "hour_rate_consumable", + "oldfieldtype": "Currency", + "permlevel": 0 + }, + { + "description": "Rent per hour", + "fieldname": "hour_rate_rent", + "fieldtype": "Float", + "label": "Rent Cost", + "oldfieldname": "hour_rate_rent", + "oldfieldtype": "Currency", + "permlevel": 0 + }, + { + "fieldname": "overhead", + "fieldtype": "Float", + "label": "Overhead", + "oldfieldname": "overhead", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "hour_rate_section_break", + "fieldtype": "Section Break", + "label": "Hour Rate", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "hour_rate", + "fieldtype": "Float", + "label": "Hour Rate", + "oldfieldname": "hour_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-wrench", + "idx": 1, + "modified": "2014-01-20 17:49:35.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Workstation", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Manufacturing User", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/workstation/workstation.py b/erpnext/manufacturing/doctype/workstation/workstation.py index 2829f41ed87..ec026c5c29f 100644 --- a/erpnext/manufacturing/doctype/workstation/workstation.py +++ b/erpnext/manufacturing/doctype/workstation/workstation.py @@ -5,21 +5,19 @@ from __future__ import unicode_literals import frappe from frappe.utils import flt -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document - def update_bom_operation(self): - bom_list = frappe.db.sql("""select DISTINCT parent from `tabBOM Operation` - where workstation = %s""", self.doc.name) - for bom_no in bom_list: - frappe.db.sql("""update `tabBOM Operation` set hour_rate = %s - where parent = %s and workstation = %s""", - (self.doc.hour_rate, bom_no[0], self.doc.name)) - - def on_update(self): - frappe.db.set(self.doc, 'overhead', flt(self.doc.hour_rate_electricity) + - flt(self.doc.hour_rate_consumable) + flt(self.doc.hour_rate_rent)) - frappe.db.set(self.doc, 'hour_rate', flt(self.doc.hour_rate_labour) + flt(self.doc.overhead)) - self.update_bom_operation() \ No newline at end of file +class Workstation(Document): + def update_bom_operation(self): + bom_list = frappe.db.sql("""select DISTINCT parent from `tabBOM Operation` + where workstation = %s""", self.name) + for bom_no in bom_list: + frappe.db.sql("""update `tabBOM Operation` set hour_rate = %s + where parent = %s and workstation = %s""", + (self.hour_rate, bom_no[0], self.name)) + + def on_update(self): + frappe.db.set(self, 'overhead', flt(self.hour_rate_electricity) + + flt(self.hour_rate_consumable) + flt(self.hour_rate_rent)) + frappe.db.set(self, 'hour_rate', flt(self.hour_rate_labour) + flt(self.overhead)) + self.update_bom_operation() \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/workstation/workstation.txt b/erpnext/manufacturing/doctype/workstation/workstation.txt deleted file mode 100644 index b8355bfe6dd..00000000000 --- a/erpnext/manufacturing/doctype/workstation/workstation.txt +++ /dev/null @@ -1,168 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:17", - "docstatus": 0, - "modified": "2014-01-20 17:49:35", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:workstation_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-wrench", - "module": "Manufacturing", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Workstation", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Workstation", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Manufacturing User", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Workstation" - }, - { - "doctype": "DocField", - "fieldname": "workstation_name", - "fieldtype": "Data", - "label": "Workstation Name", - "oldfieldname": "workstation_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "label": "Warehouse", - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "capacity", - "fieldtype": "Data", - "hidden": 1, - "label": "Capacity", - "oldfieldname": "capacity", - "oldfieldtype": "Data", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "capacity_units", - "fieldtype": "Select", - "hidden": 1, - "label": "Capacity Units", - "oldfieldname": "capacity_units", - "oldfieldtype": "Select", - "options": "\nUnits/Shifts\nUnits/Hour", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "hour_rate_labour", - "fieldtype": "Float", - "label": "Hour Rate Labour", - "oldfieldname": "hour_rate_labour", - "oldfieldtype": "Currency", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "over_heads", - "fieldtype": "Section Break", - "label": "Overheads", - "oldfieldtype": "Section Break" - }, - { - "description": "Electricity cost per hour", - "doctype": "DocField", - "fieldname": "hour_rate_electricity", - "fieldtype": "Float", - "label": "Electricity Cost", - "oldfieldname": "hour_rate_electricity", - "oldfieldtype": "Currency" - }, - { - "description": "Consumable cost per hour", - "doctype": "DocField", - "fieldname": "hour_rate_consumable", - "fieldtype": "Float", - "label": "Consumable Cost", - "oldfieldname": "hour_rate_consumable", - "oldfieldtype": "Currency" - }, - { - "description": "Rent per hour", - "doctype": "DocField", - "fieldname": "hour_rate_rent", - "fieldtype": "Float", - "label": "Rent Cost", - "oldfieldname": "hour_rate_rent", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "overhead", - "fieldtype": "Float", - "label": "Overhead", - "oldfieldname": "overhead", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "hour_rate_section_break", - "fieldtype": "Section Break", - "label": "Hour Rate", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "hour_rate", - "fieldtype": "Float", - "label": "Hour Rate", - "oldfieldname": "hour_rate", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/report/completed_production_orders/completed_production_orders.json b/erpnext/manufacturing/report/completed_production_orders/completed_production_orders.json new file mode 100644 index 00000000000..dbfd405b461 --- /dev/null +++ b/erpnext/manufacturing/report/completed_production_orders/completed_production_orders.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-08-12 12:44:27.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Completed Production Orders", + "owner": "Administrator", + "query": "SELECT\n `tabProduction Order`.name as \"Production Order:Link/Production Order:200\",\n `tabProduction Order`.creation as \"Date:Date:120\",\n `tabProduction Order`.production_item as \"Item:Link/Item:150\",\n `tabProduction Order`.qty as \"To Produce:Int:100\",\n `tabProduction Order`.produced_qty as \"Produced:Int:100\"\nFROM\n `tabProduction Order`\nWHERE\n `tabProduction Order`.docstatus=1\n AND ifnull(`tabProduction Order`.produced_qty,0) = `tabProduction Order`.qty", + "ref_doctype": "Production Order", + "report_name": "Completed Production Orders", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/manufacturing/report/completed_production_orders/completed_production_orders.txt b/erpnext/manufacturing/report/completed_production_orders/completed_production_orders.txt deleted file mode 100644 index 558ef3eedda..00000000000 --- a/erpnext/manufacturing/report/completed_production_orders/completed_production_orders.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-08-12 12:44:27", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Manufacturing", - "name": "__common__", - "query": "SELECT\n `tabProduction Order`.name as \"Production Order:Link/Production Order:200\",\n `tabProduction Order`.creation as \"Date:Date:120\",\n `tabProduction Order`.production_item as \"Item:Link/Item:150\",\n `tabProduction Order`.qty as \"To Produce:Int:100\",\n `tabProduction Order`.produced_qty as \"Produced:Int:100\"\nFROM\n `tabProduction Order`\nWHERE\n `tabProduction Order`.docstatus=1\n AND ifnull(`tabProduction Order`.produced_qty,0) = `tabProduction Order`.qty", - "ref_doctype": "Production Order", - "report_name": "Completed Production Orders", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Completed Production Orders" - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.json b/erpnext/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.json new file mode 100644 index 00000000000..35f7225165d --- /dev/null +++ b/erpnext/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.json @@ -0,0 +1,17 @@ +{ + "add_total_row": 0, + "creation": "2013-05-03 17:48:46.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Issued Items Against Production Order", + "owner": "Administrator", + "query": "select\n ste.production_order as \"Production Order:Link/Production Order:120\",\n ste.posting_date as \"Issue Date:Date:140\",\n ste_item.item_code as \"Item Code:Link/Item:120\",\n\tste_item.description as \"Description::150\",\n\tste_item.transfer_qty as \"Qty:Float:100\",\n\tste_item.stock_uom as \"UOM:Link/UOM:80\",\n\tste_item.amount as \"Amount:Currency:120\",\n\tste_item.serial_no as \"Serial No:Link/Serial No:80\",\n\tste_item.s_warehouse as \"Source Warehouse:Link/Warehouse:120\",\n\tste_item.t_warehouse as \"Target Warehouse:Link/Warehouse:120\",\n\tpro.production_item as \"Finished Goods:Link/Item:120\", \n\tste.name as \"Stock Entry:Link/Stock Entry:120\"\nfrom\n\t`tabStock Entry` ste, `tabStock Entry Detail` ste_item, `tabProduction Order` pro\nwhere\n\tifnull(ste.production_order, '') != '' and ste.name = ste_item.parent \n\tand ste.production_order = pro.name and ste.docstatus = 1 \n\tand ste.purpose = 'Manufacture/Repack'\norder by ste.posting_date, ste.production_order, ste_item.item_code", + "ref_doctype": "Production Order", + "report_name": "Issued Items Against Production Order", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt b/erpnext/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt deleted file mode 100644 index cb0808b9fdb..00000000000 --- a/erpnext/manufacturing/report/issued_items_against_production_order/issued_items_against_production_order.txt +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "creation": "2013-05-03 17:48:46", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 0, - "doctype": "Report", - "is_standard": "Yes", - "module": "Manufacturing", - "name": "__common__", - "query": "select\n ste.production_order as \"Production Order:Link/Production Order:120\",\n ste.posting_date as \"Issue Date:Date:140\",\n ste_item.item_code as \"Item Code:Link/Item:120\",\n\tste_item.description as \"Description::150\",\n\tste_item.transfer_qty as \"Qty:Float:100\",\n\tste_item.stock_uom as \"UOM:Link/UOM:80\",\n\tste_item.amount as \"Amount:Currency:120\",\n\tste_item.serial_no as \"Serial No:Link/Serial No:80\",\n\tste_item.s_warehouse as \"Source Warehouse:Link/Warehouse:120\",\n\tste_item.t_warehouse as \"Target Warehouse:Link/Warehouse:120\",\n\tpro.production_item as \"Finished Goods:Link/Item:120\", \n\tste.name as \"Stock Entry:Link/Stock Entry:120\"\nfrom\n\t`tabStock Entry` ste, `tabStock Entry Detail` ste_item, `tabProduction Order` pro\nwhere\n\tifnull(ste.production_order, '') != '' and ste.name = ste_item.parent \n\tand ste.production_order = pro.name and ste.docstatus = 1 \n\tand ste.purpose = 'Manufacture/Repack'\norder by ste.posting_date, ste.production_order, ste_item.item_code", - "ref_doctype": "Production Order", - "report_name": "Issued Items Against Production Order", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Issued Items Against Production Order" - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/report/open_production_orders/open_production_orders.json b/erpnext/manufacturing/report/open_production_orders/open_production_orders.json new file mode 100644 index 00000000000..4fbcc464823 --- /dev/null +++ b/erpnext/manufacturing/report/open_production_orders/open_production_orders.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-08-12 12:32:30.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Open Production Orders", + "owner": "Administrator", + "query": "SELECT\n `tabProduction Order`.name as \"Production Order:Link/Production Order:200\",\n `tabProduction Order`.creation as \"Date:Date:120\",\n `tabProduction Order`.production_item as \"Item:Link/Item:150\",\n `tabProduction Order`.qty as \"To Produce:Int:100\",\n `tabProduction Order`.produced_qty as \"Produced:Int:100\"\nFROM\n `tabProduction Order`\nWHERE\n `tabProduction Order`.docstatus=1\n AND ifnull(`tabProduction Order`.produced_qty,0) < `tabProduction Order`.qty\n AND NOT EXISTS (SELECT name from `tabStock Entry` where production_order =`tabProduction Order`.name) ", + "ref_doctype": "Production Order", + "report_name": "Open Production Orders", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/manufacturing/report/open_production_orders/open_production_orders.txt b/erpnext/manufacturing/report/open_production_orders/open_production_orders.txt deleted file mode 100644 index 861392548a3..00000000000 --- a/erpnext/manufacturing/report/open_production_orders/open_production_orders.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-08-12 12:32:30", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Manufacturing", - "name": "__common__", - "query": "SELECT\n `tabProduction Order`.name as \"Production Order:Link/Production Order:200\",\n `tabProduction Order`.creation as \"Date:Date:120\",\n `tabProduction Order`.production_item as \"Item:Link/Item:150\",\n `tabProduction Order`.qty as \"To Produce:Int:100\",\n `tabProduction Order`.produced_qty as \"Produced:Int:100\"\nFROM\n `tabProduction Order`\nWHERE\n `tabProduction Order`.docstatus=1\n AND ifnull(`tabProduction Order`.produced_qty,0) < `tabProduction Order`.qty\n AND NOT EXISTS (SELECT name from `tabStock Entry` where production_order =`tabProduction Order`.name) ", - "ref_doctype": "Production Order", - "report_name": "Open Production Orders", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Open Production Orders" - } -] \ No newline at end of file diff --git a/erpnext/manufacturing/report/production_orders_in_progress/production_orders_in_progress.json b/erpnext/manufacturing/report/production_orders_in_progress/production_orders_in_progress.json new file mode 100644 index 00000000000..11f5b2b3ff1 --- /dev/null +++ b/erpnext/manufacturing/report/production_orders_in_progress/production_orders_in_progress.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-08-12 12:43:47.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Manufacturing", + "name": "Production Orders in Progress", + "owner": "Administrator", + "query": "SELECT\n `tabProduction Order`.name as \"Production Order:Link/Production Order:200\",\n `tabProduction Order`.creation as \"Date:Date:120\",\n `tabProduction Order`.production_item as \"Item:Link/Item:150\",\n `tabProduction Order`.qty as \"To Produce:Int:100\",\n `tabProduction Order`.produced_qty as \"Produced:Int:100\"\nFROM\n `tabProduction Order`\nWHERE\n `tabProduction Order`.docstatus=1\n AND ifnull(`tabProduction Order`.produced_qty,0) < `tabProduction Order`.qty\n AND EXISTS (SELECT name from `tabStock Entry` where production_order =`tabProduction Order`.name) ", + "ref_doctype": "Production Order", + "report_name": "Production Orders in Progress", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/manufacturing/report/production_orders_in_progress/production_orders_in_progress.txt b/erpnext/manufacturing/report/production_orders_in_progress/production_orders_in_progress.txt deleted file mode 100644 index 8c4e1d2fbfe..00000000000 --- a/erpnext/manufacturing/report/production_orders_in_progress/production_orders_in_progress.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-08-12 12:43:47", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Manufacturing", - "name": "__common__", - "query": "SELECT\n `tabProduction Order`.name as \"Production Order:Link/Production Order:200\",\n `tabProduction Order`.creation as \"Date:Date:120\",\n `tabProduction Order`.production_item as \"Item:Link/Item:150\",\n `tabProduction Order`.qty as \"To Produce:Int:100\",\n `tabProduction Order`.produced_qty as \"Produced:Int:100\"\nFROM\n `tabProduction Order`\nWHERE\n `tabProduction Order`.docstatus=1\n AND ifnull(`tabProduction Order`.produced_qty,0) < `tabProduction Order`.qty\n AND EXISTS (SELECT name from `tabStock Entry` where production_order =`tabProduction Order`.name) ", - "ref_doctype": "Production Order", - "report_name": "Production Orders in Progress", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Production Orders in Progress" - } -] \ No newline at end of file diff --git a/erpnext/modules.txt b/erpnext/modules.txt index f7857e43341..92614d87e57 100644 --- a/erpnext/modules.txt +++ b/erpnext/modules.txt @@ -8,4 +8,5 @@ selling setup stock support -utilities \ No newline at end of file +utilities +contacts diff --git a/erpnext/patches/4_0/customer_discount_to_pricing_rule.py b/erpnext/patches/4_0/customer_discount_to_pricing_rule.py index 156630138c7..a92568e8d4f 100644 --- a/erpnext/patches/4_0/customer_discount_to_pricing_rule.py +++ b/erpnext/patches/4_0/customer_discount_to_pricing_rule.py @@ -17,7 +17,7 @@ def execute(): else: item_group = d.item_group - frappe.bean([{ + frappe.get_doc({ "doctype": "Pricing Rule", "apply_on": "Item Group", "item_group": item_group, @@ -25,7 +25,7 @@ def execute(): "customer": d.parent, "price_or_discount": "Discount", "discount_percentage": d.discount - }]).insert() + }).insert() frappe.db.auto_commit_on_many_writes = False diff --git a/erpnext/patches/4_0/fix_contact_address.py b/erpnext/patches/4_0/fix_contact_address.py index 4bf81b3ad88..91d1a0b0c6f 100644 --- a/erpnext/patches/4_0/fix_contact_address.py +++ b/erpnext/patches/4_0/fix_contact_address.py @@ -4,9 +4,9 @@ def execute(): frappe.reload_doc("website", "doctype", "contact_us_settings") address = frappe.db.get_value("Contact Us Settings", None, "address") if address: - address = frappe.doc("Address", address) - contact = frappe.bean("Contact Us Settings", "Contact Us Settings") + address = frappe.get_doc("Address", address) + contact = frappe.get_doc("Contact Us Settings", "Contact Us Settings") for f in ("address_title", "address_line1", "address_line2", "city", "state", "country", "pincode"): - contact.doc.fields[f] = address.get(f) + contact.set(f, address.get(f)) contact.save() \ No newline at end of file diff --git a/erpnext/patches/4_0/split_email_settings.py b/erpnext/patches/4_0/split_email_settings.py index e73095e7937..40aad390b1d 100644 --- a/erpnext/patches/4_0/split_email_settings.py +++ b/erpnext/patches/4_0/split_email_settings.py @@ -8,13 +8,13 @@ def execute(): frappe.reload_doc("core", "doctype", "outgoing_email_settings") frappe.reload_doc("support", "doctype", "support_email_settings") - email_settings = frappe.bean("Email Settings") + email_settings = frappe.get_doc("Email Settings") map_outgoing_email_settings(email_settings) map_support_email_settings(email_settings) frappe.delete_doc("Doctype", "Email Settings") def map_outgoing_email_settings(email_settings): - outgoing_email_settings = frappe.bean("Outgoing Email Settings") + outgoing_email_settings = frappe.get_doc("Outgoing Email Settings") for fieldname in (("outgoing_mail_server", "mail_server"), "use_ssl", "mail_port", "mail_login", "mail_password", "always_use_login_id_as_sender", @@ -25,12 +25,12 @@ def map_outgoing_email_settings(email_settings): else: from_fieldname = to_fieldname = fieldname - outgoing_email_settings.doc.fields[to_fieldname] = email_settings.doc.fields.get(from_fieldname) + outgoing_email_settings.set(to_fieldname, email_settings.get(from_fieldname)) outgoing_email_settings.save() def map_support_email_settings(email_settings): - support_email_settings = frappe.bean("Support Email Settings") + support_email_settings = frappe.get_doc("Support Email Settings") for fieldname in ("sync_support_mails", "support_email", ("support_host", "mail_server"), @@ -44,7 +44,7 @@ def map_support_email_settings(email_settings): else: from_fieldname = to_fieldname = fieldname - support_email_settings.doc.fields[to_fieldname] = email_settings.doc.fields.get(from_fieldname) + support_email_settings.set(to_fieldname, email_settings.get(from_fieldname)) support_email_settings.save() diff --git a/erpnext/patches/4_0/update_user_properties.py b/erpnext/patches/4_0/update_user_properties.py index 6dac125c1cb..2e224ce91ba 100644 --- a/erpnext/patches/4_0/update_user_properties.py +++ b/erpnext/patches/4_0/update_user_properties.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals import frappe import frappe.permissions -import frappe.model.doctype import frappe.defaults def execute(): @@ -21,7 +20,7 @@ def update_user_properties(): frappe.reload_doc("core", "doctype", "docfield") for d in frappe.db.sql("""select parent, defkey, defvalue from tabDefaultValue - where parent not in ('__global', 'Control Panel')""", as_dict=True): + where parent not in ('__global', '__default')""", as_dict=True): df = frappe.db.sql("""select options from tabDocField where fieldname=%s and fieldtype='Link'""", d.defkey, as_dict=True) @@ -29,7 +28,7 @@ def update_user_properties(): frappe.db.sql("""update tabDefaultValue set defkey=%s, parenttype='Restriction' where defkey=%s and - parent not in ('__global', 'Control Panel')""", (df[0].options, d.defkey)) + parent not in ('__global', '__default')""", (df[0].options, d.defkey)) def update_user_match(): import frappe.defaults @@ -39,7 +38,7 @@ def update_user_match(): doctype_matches.setdefault(doctype, []).append(match) for doctype, user_matches in doctype_matches.items(): - meta = frappe.get_doctype(doctype) + meta = frappe.get_meta(doctype) # for each user with roles of this doctype, check if match condition applies for user in frappe.db.sql_list("""select name from `tabUser` @@ -79,7 +78,7 @@ def add_employee_restrictions_to_leave_approver(): # add restrict rights to HR User and HR Manager frappe.db.sql("""update `tabDocPerm` set `restrict`=1 where parent in ('Employee', 'Leave Application') and role in ('HR User', 'HR Manager') and permlevel=0 and `read`=1""") - frappe.model.doctype.clear_cache() + frappe.clear_cache() # add Employee restrictions (in on_update method) for employee in frappe.db.sql_list("""select name from `tabEmployee` @@ -87,7 +86,7 @@ def add_employee_restrictions_to_leave_approver(): where `tabEmployee Leave Approver`.parent=`tabEmployee`.name) or ifnull(`reports_to`, '')!=''"""): - frappe.bean("Employee", employee).save() + frappe.get_doc("Employee", employee).save() def update_permissions(): # clear match conditions other than owner @@ -98,7 +97,7 @@ def remove_duplicate_restrictions(): # remove duplicate restrictions (if they exist) for d in frappe.db.sql("""select parent, defkey, defvalue, count(*) as cnt from tabDefaultValue - where parent not in ('__global', 'Control Panel') + where parent not in ('__global', '__default') group by parent, defkey, defvalue""", as_dict=1): if d.cnt > 1: # order by parenttype so that restriction does not get removed! diff --git a/erpnext/projects/doctype/activity_type/activity_type.json b/erpnext/projects/doctype/activity_type/activity_type.json new file mode 100644 index 00000000000..7ef2ec1b9ed --- /dev/null +++ b/erpnext/projects/doctype/activity_type/activity_type.json @@ -0,0 +1,47 @@ +{ + "allow_import": 1, + "autoname": "field:activity_type", + "creation": "2013-03-05 10:14:59.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "activity_type", + "fieldtype": "Data", + "label": "Activity Type", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-flag", + "idx": 1, + "in_dialog": 0, + "modified": "2013-12-20 19:23:54.000000", + "modified_by": "Administrator", + "module": "Projects", + "name": "Activity Type", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "write": 1 + }, + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Projects User", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/projects/doctype/activity_type/activity_type.py b/erpnext/projects/doctype/activity_type/activity_type.py index 26c87f1c04a..a98d8cf0ec2 100644 --- a/erpnext/projects/doctype/activity_type/activity_type.py +++ b/erpnext/projects/doctype/activity_type/activity_type.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ActivityType(Document): + pass \ No newline at end of file diff --git a/erpnext/projects/doctype/activity_type/activity_type.txt b/erpnext/projects/doctype/activity_type/activity_type.txt deleted file mode 100644 index d8a50c519dc..00000000000 --- a/erpnext/projects/doctype/activity_type/activity_type.txt +++ /dev/null @@ -1,60 +0,0 @@ -[ - { - "creation": "2013-03-05 10:14:59", - "docstatus": 0, - "modified": "2013-12-20 19:23:54", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:activity_type", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-flag", - "in_dialog": 0, - "module": "Projects", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "activity_type", - "fieldtype": "Data", - "label": "Activity Type", - "name": "__common__", - "parent": "Activity Type", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Activity Type", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Activity Type" - }, - { - "doctype": "DocField" - }, - { - "doctype": "DocPerm", - "role": "System Manager" - }, - { - "doctype": "DocPerm", - "role": "Projects User" - } -] \ No newline at end of file diff --git a/erpnext/projects/doctype/activity_type/test_activity_type.py b/erpnext/projects/doctype/activity_type/test_activity_type.py index b8933170f0d..ec319799b32 100644 --- a/erpnext/projects/doctype/activity_type/test_activity_type.py +++ b/erpnext/projects/doctype/activity_type/test_activity_type.py @@ -1,8 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{"activity_type":"_Test Activity Type"}], - [{"activity_type":"_Test Activity Type 1"}], - [{"activity_type":"_Test Activity Type 2"}] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Activity Type') \ No newline at end of file diff --git a/erpnext/projects/doctype/activity_type/test_records.json b/erpnext/projects/doctype/activity_type/test_records.json new file mode 100644 index 00000000000..45fc1496fbe --- /dev/null +++ b/erpnext/projects/doctype/activity_type/test_records.json @@ -0,0 +1,11 @@ +[ + { + "activity_type": "_Test Activity Type" + }, + { + "activity_type": "_Test Activity Type 1" + }, + { + "activity_type": "_Test Activity Type 2" + } +] \ No newline at end of file diff --git a/erpnext/projects/doctype/project/project.json b/erpnext/projects/doctype/project/project.json new file mode 100644 index 00000000000..b757bedacc8 --- /dev/null +++ b/erpnext/projects/doctype/project/project.json @@ -0,0 +1,294 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "autoname": "field:project_name", + "creation": "2013-03-07 11:55:07.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "overview", + "fieldtype": "Section Break", + "label": "Overview", + "options": "icon-file", + "permlevel": 0 + }, + { + "fieldname": "cb_project_status", + "fieldtype": "Column Break", + "label": "Status", + "permlevel": 0 + }, + { + "description": "Project will get saved and will be searchable with project name given", + "fieldname": "project_name", + "fieldtype": "Data", + "label": "Project Name", + "no_copy": 0, + "oldfieldname": "project_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "default": "Open", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "Open\nCompleted\nCancelled", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "is_active", + "fieldtype": "Select", + "label": "Is Active", + "no_copy": 0, + "oldfieldname": "is_active", + "oldfieldtype": "Select", + "options": "Yes\nNo", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "priority", + "fieldtype": "Select", + "label": "Priority", + "no_copy": 0, + "oldfieldname": "priority", + "oldfieldtype": "Select", + "options": "Medium\nLow\nHigh", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "cb_project_dates", + "fieldtype": "Column Break", + "label": "Dates", + "permlevel": 0 + }, + { + "fieldname": "project_start_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Project Start Date", + "no_copy": 0, + "oldfieldname": "project_start_date", + "oldfieldtype": "Date", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "completion_date", + "fieldtype": "Date", + "label": "Completion Date", + "no_copy": 0, + "oldfieldname": "completion_date", + "oldfieldtype": "Date", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "act_completion_date", + "fieldtype": "Date", + "label": "Actual Completion Date", + "no_copy": 0, + "oldfieldname": "act_completion_date", + "oldfieldtype": "Date", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "project_type", + "fieldtype": "Select", + "label": "Project Type", + "no_copy": 0, + "oldfieldname": "project_type", + "oldfieldtype": "Data", + "options": "Internal\nExternal\nOther", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "sb_milestones", + "fieldtype": "Section Break", + "label": "Milestones", + "oldfieldtype": "Section Break", + "options": "icon-flag", + "permlevel": 0 + }, + { + "description": "Milestones will be added as Events in the Calendar", + "fieldname": "project_milestones", + "fieldtype": "Table", + "label": "Project Milestones", + "no_copy": 0, + "oldfieldname": "project_milestones", + "oldfieldtype": "Table", + "options": "Project Milestone", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "section_break0", + "fieldtype": "Section Break", + "label": "Project Details", + "oldfieldtype": "Section Break", + "options": "icon-list", + "permlevel": 0 + }, + { + "fieldname": "notes", + "fieldtype": "Text Editor", + "label": "Notes", + "no_copy": 0, + "oldfieldname": "notes", + "oldfieldtype": "Text Editor", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "percent_complete", + "fieldtype": "Percent", + "in_list_view": 1, + "label": "Percent Complete", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0 + }, + { + "fieldname": "project_details", + "fieldtype": "Section Break", + "label": "Project Costing", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0 + }, + { + "fieldname": "project_value", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Project Value", + "no_copy": 0, + "oldfieldname": "project_value", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "est_material_cost", + "fieldtype": "Currency", + "label": "Estimated Material Cost", + "no_copy": 0, + "oldfieldname": "est_material_cost", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "label": "Margin", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "gross_margin_value", + "fieldtype": "Currency", + "label": "Gross Margin Value", + "no_copy": 0, + "oldfieldname": "gross_margin_value", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "per_gross_margin", + "fieldtype": "Currency", + "label": "Gross Margin %", + "no_copy": 0, + "oldfieldname": "per_gross_margin", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "customer_details", + "fieldtype": "Section Break", + "label": "Customer Details", + "oldfieldtype": "Section Break", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "in_filter": 1, + "label": "Customer", + "no_copy": 0, + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "reqd": 0, + "search_index": 1 + } + ], + "icon": "icon-puzzle-piece", + "idx": 1, + "max_attachments": 4, + "modified": "2014-01-20 17:49:02.000000", + "modified_by": "Administrator", + "module": "Projects", + "name": "Project", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Projects User", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "permlevel": 1, + "read": 1, + "report": 1, + "role": "All", + "submit": 0 + } + ], + "search_fields": "customer, status, priority, is_active" +} \ No newline at end of file diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index deac722ae98..2225acd53b9 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -8,23 +8,22 @@ from frappe.utils import flt, getdate from frappe import msgprint from erpnext.utilities.transaction_base import delete_events -class DocType: - def __init__(self, doc, doclist=None): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class Project(Document): def get_gross_profit(self): pft, per_pft =0, 0 - pft = flt(self.doc.project_value) - flt(self.doc.est_material_cost) + pft = flt(self.project_value) - flt(self.est_material_cost) #if pft > 0: - per_pft = (flt(pft) / flt(self.doc.project_value)) * 100 + per_pft = (flt(pft) / flt(self.project_value)) * 100 ret = {'gross_margin_value': pft, 'per_gross_margin': per_pft} return ret def validate(self): """validate start date before end date""" - if self.doc.project_start_date and self.doc.completion_date: - if getdate(self.doc.completion_date) < getdate(self.doc.project_start_date): + if self.project_start_date and self.completion_date: + if getdate(self.completion_date) < getdate(self.project_start_date): msgprint("Expected Completion Date can not be less than Project Start Date") raise Exception @@ -33,31 +32,31 @@ class DocType: def update_percent_complete(self): total = frappe.db.sql("""select count(*) from tabTask where project=%s""", - self.doc.name)[0][0] + self.name)[0][0] if total: completed = frappe.db.sql("""select count(*) from tabTask where - project=%s and status in ('Closed', 'Cancelled')""", self.doc.name)[0][0] - frappe.db.set_value("Project", self.doc.name, "percent_complete", + project=%s and status in ('Closed', 'Cancelled')""", self.name)[0][0] + frappe.db.set_value("Project", self.name, "percent_complete", int(float(completed) / total * 100)) def add_calendar_event(self): # delete any earlier event for this project - delete_events(self.doc.doctype, self.doc.name) + delete_events(self.doctype, self.name) # add events - for milestone in self.doclist.get({"parentfield": "project_milestones"}): + for milestone in self.get("project_milestones"): if milestone.milestone_date: - description = (milestone.milestone or "Milestone") + " for " + self.doc.name - frappe.bean({ + description = (milestone.milestone or "Milestone") + " for " + self.name + frappe.get_doc({ "doctype": "Event", - "owner": self.doc.owner, + "owner": self.owner, "subject": description, "description": description, "starts_on": milestone.milestone_date + " 10:00:00", "event_type": "Private", - "ref_type": self.doc.doctype, - "ref_name": self.doc.name + "ref_type": self.doctype, + "ref_name": self.name }).insert() def on_trash(self): - delete_events(self.doc.doctype, self.doc.name) + delete_events(self.doctype, self.name) diff --git a/erpnext/projects/doctype/project/project.txt b/erpnext/projects/doctype/project/project.txt deleted file mode 100644 index 4f7e38dcc38..00000000000 --- a/erpnext/projects/doctype/project/project.txt +++ /dev/null @@ -1,309 +0,0 @@ -[ - { - "creation": "2013-03-07 11:55:07", - "docstatus": 0, - "modified": "2014-01-20 17:49:02", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "autoname": "field:project_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-puzzle-piece", - "max_attachments": 4, - "module": "Projects", - "name": "__common__", - "search_fields": "customer, status, priority, is_active" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Project", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Project", - "parentfield": "permissions", - "parenttype": "DocType", - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Project" - }, - { - "doctype": "DocField", - "fieldname": "overview", - "fieldtype": "Section Break", - "label": "Overview", - "options": "icon-file" - }, - { - "doctype": "DocField", - "fieldname": "cb_project_status", - "fieldtype": "Column Break", - "label": "Status" - }, - { - "description": "Project will get saved and will be searchable with project name given", - "doctype": "DocField", - "fieldname": "project_name", - "fieldtype": "Data", - "label": "Project Name", - "no_copy": 0, - "oldfieldname": "project_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "default": "Open", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "Open\nCompleted\nCancelled", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "is_active", - "fieldtype": "Select", - "label": "Is Active", - "no_copy": 0, - "oldfieldname": "is_active", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "priority", - "fieldtype": "Select", - "label": "Priority", - "no_copy": 0, - "oldfieldname": "priority", - "oldfieldtype": "Select", - "options": "Medium\nLow\nHigh", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "cb_project_dates", - "fieldtype": "Column Break", - "label": "Dates" - }, - { - "doctype": "DocField", - "fieldname": "project_start_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Project Start Date", - "no_copy": 0, - "oldfieldname": "project_start_date", - "oldfieldtype": "Date", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "completion_date", - "fieldtype": "Date", - "label": "Completion Date", - "no_copy": 0, - "oldfieldname": "completion_date", - "oldfieldtype": "Date", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "act_completion_date", - "fieldtype": "Date", - "label": "Actual Completion Date", - "no_copy": 0, - "oldfieldname": "act_completion_date", - "oldfieldtype": "Date", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "project_type", - "fieldtype": "Select", - "label": "Project Type", - "no_copy": 0, - "oldfieldname": "project_type", - "oldfieldtype": "Data", - "options": "Internal\nExternal\nOther", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "sb_milestones", - "fieldtype": "Section Break", - "label": "Milestones", - "oldfieldtype": "Section Break", - "options": "icon-flag" - }, - { - "description": "Milestones will be added as Events in the Calendar", - "doctype": "DocField", - "fieldname": "project_milestones", - "fieldtype": "Table", - "label": "Project Milestones", - "no_copy": 0, - "oldfieldname": "project_milestones", - "oldfieldtype": "Table", - "options": "Project Milestone", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "label": "Project Details", - "oldfieldtype": "Section Break", - "options": "icon-list" - }, - { - "doctype": "DocField", - "fieldname": "notes", - "fieldtype": "Text Editor", - "label": "Notes", - "no_copy": 0, - "oldfieldname": "notes", - "oldfieldtype": "Text Editor", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "percent_complete", - "fieldtype": "Percent", - "in_list_view": 1, - "label": "Percent Complete", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company" - }, - { - "doctype": "DocField", - "fieldname": "project_details", - "fieldtype": "Section Break", - "label": "Project Costing", - "oldfieldtype": "Section Break", - "options": "icon-money" - }, - { - "doctype": "DocField", - "fieldname": "project_value", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Project Value", - "no_copy": 0, - "oldfieldname": "project_value", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "est_material_cost", - "fieldtype": "Currency", - "label": "Estimated Material Cost", - "no_copy": 0, - "oldfieldname": "est_material_cost", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "label": "Margin", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "gross_margin_value", - "fieldtype": "Currency", - "label": "Gross Margin Value", - "no_copy": 0, - "oldfieldname": "gross_margin_value", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "per_gross_margin", - "fieldtype": "Currency", - "label": "Gross Margin %", - "no_copy": 0, - "oldfieldname": "per_gross_margin", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "customer_details", - "fieldtype": "Section Break", - "label": "Customer Details", - "oldfieldtype": "Section Break", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "in_filter": 1, - "label": "Customer", - "no_copy": 0, - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "reqd": 0, - "search_index": 1 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "role": "Projects User", - "write": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "All" - } -] \ No newline at end of file diff --git a/erpnext/projects/doctype/project/test_project.py b/erpnext/projects/doctype/project/test_project.py index b4ea021698c..7769ff421f1 100644 --- a/erpnext/projects/doctype/project/test_project.py +++ b/erpnext/projects/doctype/project/test_project.py @@ -1,11 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{ - "project_name": "_Test Project", - "status": "Open" -}], -[{ - "project_name": "_Test Project 1", - "status": "Open" -}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Project') \ No newline at end of file diff --git a/erpnext/projects/doctype/project/test_records.json b/erpnext/projects/doctype/project/test_records.json new file mode 100644 index 00000000000..69226f0cc9c --- /dev/null +++ b/erpnext/projects/doctype/project/test_records.json @@ -0,0 +1,10 @@ +[ + { + "project_name": "_Test Project", + "status": "Open" + }, + { + "project_name": "_Test Project 1", + "status": "Open" + } +] \ No newline at end of file diff --git a/erpnext/projects/doctype/project_milestone/project_milestone.json b/erpnext/projects/doctype/project_milestone/project_milestone.json new file mode 100644 index 00000000000..7de99487534 --- /dev/null +++ b/erpnext/projects/doctype/project_milestone/project_milestone.json @@ -0,0 +1,45 @@ +{ + "creation": "2013-02-22 01:27:50.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "milestone_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Milestone Date", + "oldfieldname": "milestone_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "milestone", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Milestone", + "oldfieldname": "milestone", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "300px", + "width": "300px" + }, + { + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "Pending\nCompleted", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:27.000000", + "modified_by": "Administrator", + "module": "Projects", + "name": "Project Milestone", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/projects/doctype/project_milestone/project_milestone.py b/erpnext/projects/doctype/project_milestone/project_milestone.py index 26c87f1c04a..57bcfc40345 100644 --- a/erpnext/projects/doctype/project_milestone/project_milestone.py +++ b/erpnext/projects/doctype/project_milestone/project_milestone.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ProjectMilestone(Document): + pass \ No newline at end of file diff --git a/erpnext/projects/doctype/project_milestone/project_milestone.txt b/erpnext/projects/doctype/project_milestone/project_milestone.txt deleted file mode 100644 index d5be81e9d88..00000000000 --- a/erpnext/projects/doctype/project_milestone/project_milestone.txt +++ /dev/null @@ -1,56 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:50", - "docstatus": 0, - "modified": "2013-12-20 19:23:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Projects", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Project Milestone", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Project Milestone" - }, - { - "doctype": "DocField", - "fieldname": "milestone_date", - "fieldtype": "Date", - "label": "Milestone Date", - "oldfieldname": "milestone_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "milestone", - "fieldtype": "Text", - "label": "Milestone", - "oldfieldname": "milestone", - "oldfieldtype": "Text", - "print_width": "300px", - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "Pending\nCompleted" - } -] \ No newline at end of file diff --git a/erpnext/projects/doctype/task/task.json b/erpnext/projects/doctype/task/task.json new file mode 100644 index 00000000000..71327bbc0af --- /dev/null +++ b/erpnext/projects/doctype/task/task.json @@ -0,0 +1,243 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "autoname": "TASK.#####", + "creation": "2013-01-29 19:25:50.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "task_details", + "fieldtype": "Section Break", + "label": "Task Details", + "oldfieldtype": "Section Break", + "permlevel": 0, + "print_width": "50%", + "search_index": 0, + "width": "50%" + }, + { + "fieldname": "subject", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Subject", + "oldfieldname": "subject", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "exp_start_date", + "fieldtype": "Date", + "label": "Expected Start Date", + "oldfieldname": "exp_start_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "exp_end_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Expected End Date", + "oldfieldname": "exp_end_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "project", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Project", + "oldfieldname": "project", + "oldfieldtype": "Link", + "options": "Project", + "permlevel": 0 + }, + { + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "Open\nWorking\nPending Review\nClosed\nCancelled", + "permlevel": 0 + }, + { + "fieldname": "priority", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Priority", + "oldfieldname": "priority", + "oldfieldtype": "Select", + "options": "Low\nMedium\nHigh\nUrgent", + "permlevel": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "section_break0", + "fieldtype": "Section Break", + "oldfieldtype": "Section Break", + "options": "Simple", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Text Editor", + "label": "Details", + "oldfieldname": "description", + "oldfieldtype": "Text Editor", + "permlevel": 0, + "print_width": "300px", + "reqd": 0, + "width": "300px" + }, + { + "fieldname": "time_and_budget", + "fieldtype": "Section Break", + "label": "Time and Budget", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "expected", + "fieldtype": "Column Break", + "label": "Expected", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "exp_total_hrs", + "fieldtype": "Data", + "label": "Total Hours (Expected)", + "oldfieldname": "exp_total_hrs", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "allocated_budget", + "fieldtype": "Currency", + "label": "Allocated Budget", + "oldfieldname": "allocated_budget", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "actual", + "fieldtype": "Column Break", + "label": "Actual", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "act_start_date", + "fieldtype": "Date", + "label": "Actual Start Date", + "oldfieldname": "act_start_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "act_end_date", + "fieldtype": "Date", + "label": "Actual End Date", + "oldfieldname": "act_end_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "actual_budget", + "fieldtype": "Currency", + "label": "Actual Budget", + "oldfieldname": "actual_budget", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "more_details", + "fieldtype": "Section Break", + "label": "More Details", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.status == \"Closed\" || doc.status == \"Pending Review\"", + "fieldname": "review_date", + "fieldtype": "Date", + "hidden": 0, + "label": "Review Date", + "oldfieldname": "review_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.status == \"Closed\"", + "fieldname": "closing_date", + "fieldtype": "Date", + "hidden": 0, + "label": "Closing Date", + "oldfieldname": "closing_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "column_break_22", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0 + } + ], + "icon": "icon-check", + "idx": 1, + "max_attachments": 5, + "modified": "2014-01-24 13:01:46.000000", + "modified_by": "Administrator", + "module": "Projects", + "name": "Task", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Projects User", + "submit": 0, + "write": 1 + } + ], + "search_fields": "subject", + "title_field": "subject" +} \ No newline at end of file diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py index 0e7678118f5..a4dfb4776be 100644 --- a/erpnext/projects/doctype/task/task.py +++ b/erpnext/projects/doctype/task/task.py @@ -5,50 +5,46 @@ from __future__ import unicode_literals import frappe, json from frappe.utils import getdate, today -from frappe.model import db_exists -from frappe.model.bean import copy_doclist from frappe import msgprint -class DocType: - def __init__(self,doc,doclist=[]): - self.doc = doc - self.doclist = doclist - +from frappe.model.document import Document + +class Task(Document): def get_project_details(self): return { - "project": self.doc.project + "project": self.project } def get_customer_details(self): - cust = frappe.db.sql("select customer_name from `tabCustomer` where name=%s", self.doc.customer) + cust = frappe.db.sql("select customer_name from `tabCustomer` where name=%s", self.customer) if cust: ret = {'customer_name': cust and cust[0][0] or ''} return ret def validate(self): - if self.doc.exp_start_date and self.doc.exp_end_date and getdate(self.doc.exp_start_date) > getdate(self.doc.exp_end_date): + if self.exp_start_date and self.exp_end_date and getdate(self.exp_start_date) > getdate(self.exp_end_date): msgprint("'Expected Start Date' can not be greater than 'Expected End Date'") raise Exception - if self.doc.act_start_date and self.doc.act_end_date and getdate(self.doc.act_start_date) > getdate(self.doc.act_end_date): + if self.act_start_date and self.act_end_date and getdate(self.act_start_date) > getdate(self.act_end_date): msgprint("'Actual Start Date' can not be greater than 'Actual End Date'") raise Exception self.update_status() def update_status(self): - status = frappe.db.get_value("Task", self.doc.name, "status") - if self.doc.status=="Working" and status !="Working" and not self.doc.act_start_date: - self.doc.act_start_date = today() + status = frappe.db.get_value("Task", self.name, "status") + if self.status=="Working" and status !="Working" and not self.act_start_date: + self.act_start_date = today() - if self.doc.status=="Closed" and status != "Closed" and not self.doc.act_end_date: - self.doc.act_end_date = today() + if self.status=="Closed" and status != "Closed" and not self.act_end_date: + self.act_end_date = today() def on_update(self): """update percent complete in project""" - if self.doc.project: - project = frappe.bean("Project", self.doc.project) + if self.project: + project = frappe.get_doc("Project", self.project) project.run_method("update_percent_complete") @frappe.whitelist() diff --git a/erpnext/projects/doctype/task/task.txt b/erpnext/projects/doctype/task/task.txt deleted file mode 100644 index 2dce94f921a..00000000000 --- a/erpnext/projects/doctype/task/task.txt +++ /dev/null @@ -1,262 +0,0 @@ -[ - { - "creation": "2013-01-29 19:25:50", - "docstatus": 0, - "modified": "2014-01-24 13:01:46", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "autoname": "TASK.#####", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-check", - "max_attachments": 5, - "module": "Projects", - "name": "__common__", - "search_fields": "subject", - "title_field": "subject" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Task", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Task", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Projects User", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Task" - }, - { - "doctype": "DocField", - "fieldname": "task_details", - "fieldtype": "Section Break", - "label": "Task Details", - "oldfieldtype": "Section Break", - "print_width": "50%", - "search_index": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "subject", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Subject", - "oldfieldname": "subject", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "exp_start_date", - "fieldtype": "Date", - "label": "Expected Start Date", - "oldfieldname": "exp_start_date", - "oldfieldtype": "Date", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "exp_end_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Expected End Date", - "oldfieldname": "exp_end_date", - "oldfieldtype": "Date", - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "project", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Project", - "oldfieldname": "project", - "oldfieldtype": "Link", - "options": "Project" - }, - { - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "Open\nWorking\nPending Review\nClosed\nCancelled" - }, - { - "doctype": "DocField", - "fieldname": "priority", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Priority", - "oldfieldname": "priority", - "oldfieldtype": "Select", - "options": "Low\nMedium\nHigh\nUrgent", - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "oldfieldtype": "Section Break", - "options": "Simple" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text Editor", - "label": "Details", - "oldfieldname": "description", - "oldfieldtype": "Text Editor", - "print_width": "300px", - "reqd": 0, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "time_and_budget", - "fieldtype": "Section Break", - "label": "Time and Budget", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "expected", - "fieldtype": "Column Break", - "label": "Expected", - "oldfieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "exp_total_hrs", - "fieldtype": "Data", - "label": "Total Hours (Expected)", - "oldfieldname": "exp_total_hrs", - "oldfieldtype": "Data", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "allocated_budget", - "fieldtype": "Currency", - "label": "Allocated Budget", - "oldfieldname": "allocated_budget", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "actual", - "fieldtype": "Column Break", - "label": "Actual", - "oldfieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "act_start_date", - "fieldtype": "Date", - "label": "Actual Start Date", - "oldfieldname": "act_start_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "act_end_date", - "fieldtype": "Date", - "label": "Actual End Date", - "oldfieldname": "act_end_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "actual_budget", - "fieldtype": "Currency", - "label": "Actual Budget", - "oldfieldname": "actual_budget", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "more_details", - "fieldtype": "Section Break", - "label": "More Details" - }, - { - "depends_on": "eval:doc.status == \"Closed\" || doc.status == \"Pending Review\"", - "doctype": "DocField", - "fieldname": "review_date", - "fieldtype": "Date", - "hidden": 0, - "label": "Review Date", - "oldfieldname": "review_date", - "oldfieldtype": "Date" - }, - { - "depends_on": "eval:doc.status == \"Closed\"", - "doctype": "DocField", - "fieldname": "closing_date", - "fieldtype": "Date", - "hidden": 0, - "label": "Closing Date", - "oldfieldname": "closing_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "column_break_22", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/projects/doctype/task/test_records.json b/erpnext/projects/doctype/task/test_records.json new file mode 100644 index 00000000000..1f98172b704 --- /dev/null +++ b/erpnext/projects/doctype/task/test_records.json @@ -0,0 +1,15 @@ +[ + { + "project": "_Test Project", + "status": "Open", + "subject": "_Test Task" + }, + { + "status": "Open", + "subject": "_Test Task 1" + }, + { + "status": "Open", + "subject": "_Test Task 2" + } +] \ No newline at end of file diff --git a/erpnext/projects/doctype/task/test_task.py b/erpnext/projects/doctype/task/test_task.py index af7ad288f07..c345649c44c 100644 --- a/erpnext/projects/doctype/task/test_task.py +++ b/erpnext/projects/doctype/task/test_task.py @@ -1,10 +1,8 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{"subject": "_Test Task", "project":"_Test Project", "status":"Open"}], - [{"subject": "_Test Task 1", "status":"Open"}], - [{"subject": "_Test Task 2", "status":"Open"}] -] + +import frappe +test_records = frappe.get_test_records('Task') test_ignore = ["Customer"] \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log/test_records.json b/erpnext/projects/doctype/time_log/test_records.json new file mode 100644 index 00000000000..0ef276ecbe7 --- /dev/null +++ b/erpnext/projects/doctype/time_log/test_records.json @@ -0,0 +1,10 @@ +[ + { + "activity_type": "_Test Activity Type", + "docstatus": 1, + "doctype": "Time Log", + "from_time": "2013-01-01 10:00:00.000000", + "note": "_Test Note", + "to_time": "2013-01-01 11:00:00.000000" + } +] \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log/test_time_log.py b/erpnext/projects/doctype/time_log/test_time_log.py index b6e27417237..7aadf5c2861 100644 --- a/erpnext/projects/doctype/time_log/test_time_log.py +++ b/erpnext/projects/doctype/time_log/test_time_log.py @@ -7,17 +7,9 @@ import unittest from erpnext.projects.doctype.time_log.time_log import OverlapError class TestTimeLog(unittest.TestCase): - def test_duplication(self): - ts = frappe.bean(frappe.copy_doclist(test_records[0])) + def test_duplication(self): + ts = frappe.get_doc(frappe.copy_doc(test_records[0])) self.assertRaises(OverlapError, ts.insert) -test_records = [[{ - "doctype": "Time Log", - "from_time": "2013-01-01 10:00:00.000000", - "to_time": "2013-01-01 11:00:00.000000", - "activity_type": "_Test Activity Type", - "note": "_Test Note", - "docstatus": 1 -}]] - -test_ignore = ["Sales Invoice", "Time Log Batch"] \ No newline at end of file +test_records = frappe.get_test_records('Time Log') +test_ignore = ["Time Log Batch", "Sales Invoice"] diff --git a/erpnext/projects/doctype/time_log/time_log.json b/erpnext/projects/doctype/time_log/time_log.json new file mode 100644 index 00000000000..cd5a8d14996 --- /dev/null +++ b/erpnext/projects/doctype/time_log/time_log.json @@ -0,0 +1,189 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-04-03 16:38:41.000000", + "description": "Log of Activities performed by users against Tasks that can be used for tracking time, billing.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "options": "TL-", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "from_time", + "fieldtype": "Datetime", + "in_list_view": 1, + "label": "From Time", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "to_time", + "fieldtype": "Datetime", + "in_list_view": 0, + "label": "To Time", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "hours", + "fieldtype": "Float", + "label": "Hours", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Status", + "options": "Draft\nSubmitted\nBatched for Billing\nBilled\nCancelled", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "activity_type", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Activity Type", + "options": "Activity Type", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "task", + "fieldtype": "Link", + "label": "Task", + "options": "Task", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "billable", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Billable", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "section_break_7", + "fieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "note", + "fieldtype": "Text Editor", + "label": "Note", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "section_break_9", + "fieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "project", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Project", + "options": "Project", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Will be updated when batched.", + "fieldname": "time_log_batch", + "fieldtype": "Link", + "label": "Time Log Batch", + "options": "Time Log Batch", + "permlevel": 0, + "read_only": 1 + }, + { + "description": "Will be updated when billed.", + "fieldname": "sales_invoice", + "fieldtype": "Link", + "label": "Sales Invoice", + "options": "Sales Invoice", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break_16", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "options": "Time Log", + "permlevel": 1, + "print_hide": 1, + "read_only": 0 + } + ], + "icon": "icon-time", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-22 16:05:35.000000", + "modified_by": "Administrator", + "module": "Projects", + "name": "Time Log", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "restricted": 1, + "role": "Projects User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Projects Manager", + "submit": 1, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py index 690eb9270ec..f184db37f4b 100644 --- a/erpnext/projects/doctype/time_log/time_log.py +++ b/erpnext/projects/doctype/time_log/time_log.py @@ -11,9 +11,9 @@ from frappe.utils import cstr class OverlapError(frappe.ValidationError): pass -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class TimeLog(Document): def validate(self): self.set_status() @@ -22,20 +22,20 @@ class DocType: def calculate_total_hours(self): from frappe.utils import time_diff_in_hours - self.doc.hours = time_diff_in_hours(self.doc.to_time, self.doc.from_time) + self.hours = time_diff_in_hours(self.to_time, self.from_time) def set_status(self): - self.doc.status = { + self.status = { 0: "Draft", 1: "Submitted", 2: "Cancelled" - }[self.doc.docstatus or 0] + }[self.docstatus or 0] - if self.doc.time_log_batch: - self.doc.status="Batched for Billing" + if self.time_log_batch: + self.status="Batched for Billing" - if self.doc.sales_invoice: - self.doc.status="Billed" + if self.sales_invoice: + self.status="Billed" def validate_overlap(self): existing = frappe.db.sql_list("""select name from `tabTime Log` where owner=%s and @@ -46,9 +46,9 @@ class DocType: and name!=%s and ifnull(task, "")=%s and docstatus < 2""", - (self.doc.owner, self.doc.from_time, self.doc.to_time, self.doc.from_time, - self.doc.to_time, self.doc.from_time, self.doc.name or "No Name", - cstr(self.doc.task))) + (self.owner, self.from_time, self.to_time, self.from_time, + self.to_time, self.from_time, self.name or "No Name", + cstr(self.task))) if existing: frappe.msgprint(_("This Time Log conflicts with") + ":" + ', '.join(existing), diff --git a/erpnext/projects/doctype/time_log/time_log.txt b/erpnext/projects/doctype/time_log/time_log.txt deleted file mode 100644 index 11fa7d6e6e0..00000000000 --- a/erpnext/projects/doctype/time_log/time_log.txt +++ /dev/null @@ -1,215 +0,0 @@ -[ - { - "creation": "2013-04-03 16:38:41", - "docstatus": 0, - "modified": "2014-01-22 16:05:35", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "autoname": "naming_series:", - "description": "Log of Activities performed by users against Tasks that can be used for tracking time, billing.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-time", - "is_submittable": 1, - "module": "Projects", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Time Log", - "parentfield": "fields", - "parenttype": "DocType" - }, - { - "amend": 1, - "cancel": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Time Log", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Time Log" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "options": "TL-", - "permlevel": 0, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "from_time", - "fieldtype": "Datetime", - "in_list_view": 1, - "label": "From Time", - "permlevel": 0, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "to_time", - "fieldtype": "Datetime", - "in_list_view": 0, - "label": "To Time", - "permlevel": 0, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "hours", - "fieldtype": "Float", - "label": "Hours", - "permlevel": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_3", - "fieldtype": "Column Break", - "permlevel": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Status", - "options": "Draft\nSubmitted\nBatched for Billing\nBilled\nCancelled", - "permlevel": 0, - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "activity_type", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Activity Type", - "options": "Activity Type", - "permlevel": 0, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "task", - "fieldtype": "Link", - "label": "Task", - "options": "Task", - "permlevel": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "billable", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Billable", - "permlevel": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_7", - "fieldtype": "Section Break", - "permlevel": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "note", - "fieldtype": "Text Editor", - "label": "Note", - "permlevel": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_9", - "fieldtype": "Section Break", - "permlevel": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "project", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Project", - "options": "Project", - "permlevel": 0, - "read_only": 0 - }, - { - "description": "Will be updated when batched.", - "doctype": "DocField", - "fieldname": "time_log_batch", - "fieldtype": "Link", - "label": "Time Log Batch", - "options": "Time Log Batch", - "permlevel": 0, - "read_only": 1 - }, - { - "description": "Will be updated when billed.", - "doctype": "DocField", - "fieldname": "sales_invoice", - "fieldtype": "Link", - "label": "Sales Invoice", - "options": "Sales Invoice", - "permlevel": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_16", - "fieldtype": "Column Break", - "permlevel": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "options": "Time Log", - "permlevel": 1, - "print_hide": 1, - "read_only": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "restricted": 1, - "role": "Projects User" - }, - { - "doctype": "DocPerm", - "role": "Projects Manager" - } -] \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log_batch/test_records.json b/erpnext/projects/doctype/time_log_batch/test_records.json new file mode 100644 index 00000000000..d386000e34a --- /dev/null +++ b/erpnext/projects/doctype/time_log_batch/test_records.json @@ -0,0 +1,14 @@ +[ + { + "doctype": "Time Log Batch", + "rate": "500", + "time_log_batch_details": [ + { + "doctype": "Time Log Batch Detail", + "parentfield": "time_log_batch_details", + "parenttype": "Time Log Batch", + "time_log": "_T-Time Log-00001" + } + ] + } +] \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py b/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py index 5649687ce7d..fdbc2102c2b 100644 --- a/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py +++ b/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py @@ -6,34 +6,25 @@ import frappe, unittest class TimeLogBatchTest(unittest.TestCase): def test_time_log_status(self): from erpnext.projects.doctype.time_log.test_time_log import test_records as time_log_records - time_log = frappe.bean(copy=time_log_records[0]) - time_log.doc.fields.update({ + time_log = frappe.copy_doc(time_log_records[0]) + time_log.update({ "from_time": "2013-01-02 10:00:00.000000", "to_time": "2013-01-02 11:00:00.000000", "docstatus": 0 }) time_log.insert() time_log.submit() - - self.assertEquals(frappe.db.get_value("Time Log", time_log.doc.name, "status"), "Submitted") - tlb = frappe.bean(copy=test_records[0]) - tlb.doclist[1].time_log = time_log.doc.name + + self.assertEquals(frappe.db.get_value("Time Log", time_log.name, "status"), "Submitted") + tlb = frappe.copy_doc(test_records[0]) + tlb.get("time_log_batch_details")[0].time_log = time_log.name tlb.insert() tlb.submit() - self.assertEquals(frappe.db.get_value("Time Log", time_log.doc.name, "status"), "Batched for Billing") + self.assertEquals(frappe.db.get_value("Time Log", time_log.name, "status"), "Batched for Billing") tlb.cancel() - self.assertEquals(frappe.db.get_value("Time Log", time_log.doc.name, "status"), "Submitted") + self.assertEquals(frappe.db.get_value("Time Log", time_log.name, "status"), "Submitted") -test_records = [[ - { - "doctype": "Time Log Batch", - "rate": "500" - }, - { - "doctype": "Time Log Batch Detail", - "parenttype": "Time Log Batch", - "parentfield": "time_log_batch_details", - "time_log": "_T-Time Log-00001", - } -]] \ No newline at end of file +test_records = frappe.get_test_records('Time Log Batch') +test_dependencies = ["Time Log"] +test_ignore = ["Sales Invoice"] diff --git a/erpnext/projects/doctype/time_log_batch/time_log_batch.js b/erpnext/projects/doctype/time_log_batch/time_log_batch.js index 7aa3e160977..7f3a17e6ef4 100644 --- a/erpnext/projects/doctype/time_log_batch/time_log_batch.js +++ b/erpnext/projects/doctype/time_log_batch/time_log_batch.js @@ -30,9 +30,8 @@ $.extend(cur_frm.cscript, { } }, make_invoice: function() { - var doc = cur_frm.doc; frappe.model.map({ - source: frappe.model.get_doclist(doc.doctype, doc.name), + source: cur_frm.doc, target: "Sales Invoice" }); } diff --git a/erpnext/projects/doctype/time_log_batch/time_log_batch.json b/erpnext/projects/doctype/time_log_batch/time_log_batch.json new file mode 100644 index 00000000000..9d98a34b6be --- /dev/null +++ b/erpnext/projects/doctype/time_log_batch/time_log_batch.json @@ -0,0 +1,107 @@ +{ + "autoname": "naming_series:", + "creation": "2013-02-28 17:57:33.000000", + "description": "Batch Time Logs for Billing.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "options": "TLB-", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "For Sales Invoice", + "fieldname": "rate", + "fieldtype": "Currency", + "label": "Rate", + "permlevel": 0 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": "Draft", + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Status", + "options": "Draft\nSubmitted\nBilled\nCancelled", + "permlevel": 0, + "read_only": 1 + }, + { + "description": "Will be updated after Sales Invoice is Submitted.", + "fieldname": "sales_invoice", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Sales Invoice", + "options": "Sales Invoice", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "section_break_5", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "time_log_batch_details", + "fieldtype": "Table", + "label": "Time Log Batch Details", + "options": "Time Log Batch Detail", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "In Hours", + "fieldname": "total_hours", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Total Hours", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "options": "Time Log Batch", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "icon": "icon-time", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:49:34.000000", + "modified_by": "Administrator", + "module": "Projects", + "name": "Time Log Batch", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Projects User", + "submit": 1, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log_batch/time_log_batch.py b/erpnext/projects/doctype/time_log_batch/time_log_batch.py index 3c3e6e06b00..b8204e48559 100644 --- a/erpnext/projects/doctype/time_log_batch/time_log_batch.py +++ b/erpnext/projects/doctype/time_log_batch/time_log_batch.py @@ -7,54 +7,54 @@ from __future__ import unicode_literals import frappe from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class TimeLogBatch(Document): def validate(self): self.set_status() - self.doc.total_hours = 0.0 - for d in self.doclist.get({"doctype":"Time Log Batch Detail"}): - tl = frappe.doc("Time Log", d.time_log) + self.total_hours = 0.0 + for d in self.get("time_log_batch_details"): + tl = frappe.get_doc("Time Log", d.time_log) self.update_time_log_values(d, tl) self.validate_time_log_is_submitted(tl) - self.doc.total_hours += float(tl.hours or 0.0) + self.total_hours += float(tl.hours or 0.0) def update_time_log_values(self, d, tl): - d.fields.update({ + d.update({ "hours": tl.hours, "activity_type": tl.activity_type, "created_by": tl.owner }) def validate_time_log_is_submitted(self, tl): - if tl.status != "Submitted" and self.doc.docstatus == 0: + if tl.status != "Submitted" and self.docstatus == 0: frappe.msgprint(_("Time Log must have status 'Submitted'") + \ " :" + tl.name + " (" + _(tl.status) + ")", raise_exception=True) - + def set_status(self): - self.doc.status = { + self.status = { "0": "Draft", "1": "Submitted", "2": "Cancelled" - }[str(self.doc.docstatus or 0)] - - if self.doc.sales_invoice: - self.doc.status = "Billed" - + }[str(self.docstatus or 0)] + + if self.sales_invoice: + self.status = "Billed" + def on_submit(self): - self.update_status(self.doc.name) + self.update_status(self.name) def before_cancel(self): self.update_status(None) def before_update_after_submit(self): - self.update_status(self.doc.name) + self.update_status(self.name) def update_status(self, time_log_batch): self.set_status() - for d in self.doclist.get({"doctype":"Time Log Batch Detail"}): - tl = frappe.bean("Time Log", d.time_log) - tl.doc.time_log_batch = time_log_batch - tl.doc.sales_invoice = self.doc.sales_invoice - tl.update_after_submit() \ No newline at end of file + for d in self.get("time_log_batch_details"): + tl = frappe.get_doc("Time Log", d.time_log) + tl.time_log_batch = time_log_batch + tl.sales_invoice = self.sales_invoice + tl.save() diff --git a/erpnext/projects/doctype/time_log_batch/time_log_batch.txt b/erpnext/projects/doctype/time_log_batch/time_log_batch.txt deleted file mode 100644 index bc803ea2b67..00000000000 --- a/erpnext/projects/doctype/time_log_batch/time_log_batch.txt +++ /dev/null @@ -1,126 +0,0 @@ -[ - { - "creation": "2013-02-28 17:57:33", - "docstatus": 0, - "modified": "2014-01-20 17:49:34", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "naming_series:", - "description": "Batch Time Logs for Billing.", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-time", - "is_submittable": 1, - "module": "Projects", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Time Log Batch", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Time Log Batch", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Projects User", - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Time Log Batch" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "options": "TLB-", - "reqd": 1 - }, - { - "description": "For Sales Invoice", - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Currency", - "label": "Rate" - }, - { - "doctype": "DocField", - "fieldname": "column_break_3", - "fieldtype": "Column Break" - }, - { - "default": "Draft", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Status", - "options": "Draft\nSubmitted\nBilled\nCancelled", - "read_only": 1 - }, - { - "description": "Will be updated after Sales Invoice is Submitted.", - "doctype": "DocField", - "fieldname": "sales_invoice", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Sales Invoice", - "options": "Sales Invoice", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break_5", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "time_log_batch_details", - "fieldtype": "Table", - "label": "Time Log Batch Details", - "options": "Time Log Batch Detail", - "reqd": 1 - }, - { - "description": "In Hours", - "doctype": "DocField", - "fieldname": "total_hours", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Total Hours", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "options": "Time Log Batch", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.json b/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.json new file mode 100644 index 00000000000..15e7e8e29b7 --- /dev/null +++ b/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.json @@ -0,0 +1,49 @@ +{ + "creation": "2013-03-05 09:11:06.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "time_log", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Time Log", + "options": "Time Log", + "permlevel": 0, + "print_width": "200px", + "reqd": 1, + "width": "200px" + }, + { + "fieldname": "created_by", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Created By", + "options": "User", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "activity_type", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Activity Type", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "hours", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Hours", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:21:54.000000", + "modified_by": "Administrator", + "module": "Projects", + "name": "Time Log Batch Detail", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py b/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py index 968a25b6134..f0c4c1b49c5 100644 --- a/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py +++ b/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class TimeLogBatchDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.txt b/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.txt deleted file mode 100644 index 3531a877dff..00000000000 --- a/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.txt +++ /dev/null @@ -1,59 +0,0 @@ -[ - { - "creation": "2013-03-05 09:11:06", - "docstatus": 0, - "modified": "2013-12-20 19:21:54", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Projects", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Time Log Batch Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Time Log Batch Detail" - }, - { - "doctype": "DocField", - "fieldname": "time_log", - "fieldtype": "Link", - "label": "Time Log", - "options": "Time Log", - "print_width": "200px", - "reqd": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "created_by", - "fieldtype": "Link", - "label": "Created By", - "options": "User", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "activity_type", - "fieldtype": "Data", - "label": "Activity Type", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "hours", - "fieldtype": "Float", - "label": "Hours" - } -] \ No newline at end of file diff --git a/erpnext/projects/report/daily_time_log_summary/daily_time_log_summary.json b/erpnext/projects/report/daily_time_log_summary/daily_time_log_summary.json new file mode 100644 index 00000000000..1be419a6287 --- /dev/null +++ b/erpnext/projects/report/daily_time_log_summary/daily_time_log_summary.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-03 11:27:52.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Projects", + "name": "Daily Time Log Summary", + "owner": "Administrator", + "ref_doctype": "Time Log", + "report_name": "Daily Time Log Summary", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/projects/report/daily_time_log_summary/daily_time_log_summary.txt b/erpnext/projects/report/daily_time_log_summary/daily_time_log_summary.txt deleted file mode 100644 index fe8feb0a5be..00000000000 --- a/erpnext/projects/report/daily_time_log_summary/daily_time_log_summary.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-03 11:27:52", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Projects", - "name": "__common__", - "ref_doctype": "Time Log", - "report_name": "Daily Time Log Summary", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Daily Time Log Summary" - } -] \ No newline at end of file diff --git a/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.json b/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.json new file mode 100644 index 00000000000..467c83eaac3 --- /dev/null +++ b/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-03 17:37:41.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Projects", + "name": "Project wise Stock Tracking", + "owner": "Administrator", + "ref_doctype": "Project", + "report_name": "Project wise Stock Tracking ", + "report_type": "Report Builder" +} \ No newline at end of file diff --git a/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.txt b/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.txt deleted file mode 100644 index 4a8953696d5..00000000000 --- a/erpnext/projects/report/project_wise_stock_tracking/project_wise_stock_tracking.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-03 17:37:41", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Projects", - "name": "__common__", - "ref_doctype": "Project", - "report_name": "Project wise Stock Tracking ", - "report_type": "Report Builder" - }, - { - "doctype": "Report", - "name": "Project wise Stock Tracking" - } -] \ No newline at end of file diff --git a/erpnext/public/js/controllers/stock_controller.js b/erpnext/public/js/controllers/stock_controller.js index 9f793e47c5e..65b81bb2b9d 100644 --- a/erpnext/public/js/controllers/stock_controller.js +++ b/erpnext/public/js/controllers/stock_controller.js @@ -39,7 +39,7 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({ copy_account_in_all_row: function(doc, dt, dn, fieldname) { var d = locals[dt][dn]; if(d[fieldname]){ - var cl = getchildren(this.frm.cscript.tname, doc.name, this.frm.cscript.fname, doc.doctype); + var cl = doc[this.frm.cscript.fname] || []; for(var i = 0; i < cl.length; i++) { if(!cl[i][fieldname]) cl[i][fieldname] = d[fieldname]; } diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 2f89470b59f..cb868b24f41 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -46,7 +46,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ freeze: true, callback: function(r) { // remove this call when using client side mapper - me.set_default_values(); me.set_dynamic_labels(); me.calculate_taxes_and_totals(); } @@ -114,7 +113,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ item_code: function(doc, cdt, cdn) { var me = this; - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); if(item.item_code || item.barcode || item.serial_no) { if(!this.validate_company_and_party()) { cur_frm.fields_dict[me.frm.cscript.fname].grid.grid_rows[item.idx - 1].remove(); @@ -157,7 +156,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ serial_no: function(doc, cdt, cdn) { var me = this; - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); if (item.serial_no) { if (!item.item_code) { @@ -192,18 +191,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ validate: function() { this.calculate_taxes_and_totals(); }, - - set_default_values: function() { - $.each(frappe.model.get_doclist(this.frm.doctype, this.frm.docname), function(i, doc) { - var updated = frappe.model.set_default_values(doc); - if(doc.parentfield) { - refresh_field(doc.parentfield); - } else { - refresh_field(updated); - } - }); - }, - + company: function() { if(this.frm.doc.company && this.frm.fields_dict.currency) { var company_currency = this.get_company_currency(); @@ -274,7 +262,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ get_exchange_rate: function(from_currency, to_currency, callback) { var exchange_name = from_currency + "-" + to_currency; frappe.model.with_doc("Currency Exchange", exchange_name, function(name) { - var exchange_doc = frappe.model.get_doc("Currency Exchange", exchange_name); + var exchange_doc = frappe.get_doc("Currency Exchange", exchange_name); callback(exchange_doc ? flt(exchange_doc.exchange_rate) : 0); }); }, @@ -316,7 +304,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ }, row_id: function(doc, cdt, cdn) { - var tax = frappe.model.get_doc(cdt, cdn); + var tax = frappe.get_doc(cdt, cdn); try { this.validate_on_previous_row(tax); this.calculate_taxes_and_totals(); @@ -351,7 +339,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ }, included_in_print_rate: function(doc, cdt, cdn) { - var tax = frappe.model.get_doc(cdt, cdn); + var tax = frappe.get_doc(cdt, cdn); try { this.validate_on_previous_row(tax); this.validate_inclusive_tax(tax); @@ -517,13 +505,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ }, get_item_doclist: function() { - return frappe.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, - {parentfield: this.fname}); + return this.frm.doc[this.fname] || []; }, get_tax_doclist: function() { - return frappe.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, - {parentfield: this.other_fname}); + return this.frm.doc[this.other_fname] || []; }, validate_conversion_rate: function() { @@ -716,8 +702,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ calculate_total_advance: function(parenttype, advance_parentfield) { if(this.frm.doc.doctype == parenttype && this.frm.doc.docstatus < 2) { - var advance_doclist = frappe.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, - {parentfield: advance_parentfield}); + var advance_doclist = this.frm.doc[advance_parentfield] || []; this.frm.doc.total_advance = flt(frappe.utils.sum( $.map(advance_doclist, function(adv) { return adv.allocated_amount }) ), precision("total_advance")); diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index c5d3e0b729b..868ea0e2da2 100644 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -7,7 +7,7 @@ $.extend(erpnext, { if(!company && cur_frm) company = cur_frm.doc.company; if(company) - return frappe.model.get_doc(":Company", company).default_currency || frappe.boot.sysdefaults.currency; + return frappe.get_doc(":Company", company).default_currency || frappe.boot.sysdefaults.currency; else return frappe.boot.sysdefaults.currency; }, @@ -29,8 +29,7 @@ $.extend(erpnext, { }, add_applicable_territory: function() { - if(cur_frm.doc.__islocal && - frappe.model.get_doclist(cur_frm.doc.doctype, cur_frm.doc.name).length === 1) { + if(cur_frm.doc.__islocal && (cur_frm.doc.valid_for_territories || []).length===0) { var default_territory = frappe.defaults.get_user_default("territory"); if(default_territory) { var territory = frappe.model.add_child(cur_frm.doc, "Applicable Territory", diff --git a/erpnext/selling/Print Format/Quotation Classic/Quotation Classic.json b/erpnext/selling/Print Format/Quotation Classic/Quotation Classic.json new file mode 100644 index 00000000000..977a2257997 --- /dev/null +++ b/erpnext/selling/Print Format/Quotation Classic/Quotation Classic.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:30:51.000000", + "doc_type": "Quotation", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:45:37.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Quotation Classic", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/selling/Print Format/Quotation Classic/Quotation Classic.txt b/erpnext/selling/Print Format/Quotation Classic/Quotation Classic.txt deleted file mode 100644 index c858c26cd77..00000000000 --- a/erpnext/selling/Print Format/Quotation Classic/Quotation Classic.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:30:51", - "docstatus": 0, - "modified": "2014-02-11 17:45:37", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Quotation", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Selling", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Quotation Classic" - } -] \ No newline at end of file diff --git a/erpnext/selling/Print Format/Quotation Modern/Quotation Modern.json b/erpnext/selling/Print Format/Quotation Modern/Quotation Modern.json new file mode 100644 index 00000000000..6b0ed48ccf3 --- /dev/null +++ b/erpnext/selling/Print Format/Quotation Modern/Quotation Modern.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:30:51.000000", + "doc_type": "Quotation", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:45:15.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Quotation Modern", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/selling/Print Format/Quotation Modern/Quotation Modern.txt b/erpnext/selling/Print Format/Quotation Modern/Quotation Modern.txt deleted file mode 100644 index b7c38308087..00000000000 --- a/erpnext/selling/Print Format/Quotation Modern/Quotation Modern.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:30:51", - "docstatus": 0, - "modified": "2014-02-11 17:45:15", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Quotation", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Selling", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Quotation Modern" - } -] \ No newline at end of file diff --git a/erpnext/selling/Print Format/Quotation Spartan/Quotation Spartan.json b/erpnext/selling/Print Format/Quotation Spartan/Quotation Spartan.json new file mode 100644 index 00000000000..5e21b6cbf8e --- /dev/null +++ b/erpnext/selling/Print Format/Quotation Spartan/Quotation Spartan.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:30:51.000000", + "doc_type": "Quotation", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:45:50.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Quotation Spartan", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/selling/Print Format/Quotation Spartan/Quotation Spartan.txt b/erpnext/selling/Print Format/Quotation Spartan/Quotation Spartan.txt deleted file mode 100644 index f4be36e5618..00000000000 --- a/erpnext/selling/Print Format/Quotation Spartan/Quotation Spartan.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:30:51", - "docstatus": 0, - "modified": "2014-02-11 17:45:50", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Quotation", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Selling", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Quotation Spartan" - } -] \ No newline at end of file diff --git a/erpnext/selling/Print Format/Sales Order Classic/Sales Order Classic.json b/erpnext/selling/Print Format/Sales Order Classic/Sales Order Classic.json new file mode 100644 index 00000000000..3aee798d12f --- /dev/null +++ b/erpnext/selling/Print Format/Sales Order Classic/Sales Order Classic.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:30:51.000000", + "doc_type": "Sales Order", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:35:51.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Order Classic", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/selling/Print Format/Sales Order Classic/Sales Order Classic.txt b/erpnext/selling/Print Format/Sales Order Classic/Sales Order Classic.txt deleted file mode 100644 index 8c0b807036f..00000000000 --- a/erpnext/selling/Print Format/Sales Order Classic/Sales Order Classic.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:30:51", - "docstatus": 0, - "modified": "2014-02-11 17:35:51", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Sales Order", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Selling", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Sales Order Classic" - } -] \ No newline at end of file diff --git a/erpnext/selling/Print Format/Sales Order Modern/Sales Order Modern.json b/erpnext/selling/Print Format/Sales Order Modern/Sales Order Modern.json new file mode 100644 index 00000000000..76ee34af4dc --- /dev/null +++ b/erpnext/selling/Print Format/Sales Order Modern/Sales Order Modern.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:30:51.000000", + "doc_type": "Sales Order", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:34:24.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Order Modern", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/selling/Print Format/Sales Order Modern/Sales Order Modern.txt b/erpnext/selling/Print Format/Sales Order Modern/Sales Order Modern.txt deleted file mode 100644 index a901ae25cd5..00000000000 --- a/erpnext/selling/Print Format/Sales Order Modern/Sales Order Modern.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:30:51", - "docstatus": 0, - "modified": "2014-02-11 17:34:24", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Sales Order", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Selling", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Sales Order Modern" - } -] \ No newline at end of file diff --git a/erpnext/selling/Print Format/Sales Order Spartan/Sales Order Spartan.json b/erpnext/selling/Print Format/Sales Order Spartan/Sales Order Spartan.json new file mode 100644 index 00000000000..1628da71a64 --- /dev/null +++ b/erpnext/selling/Print Format/Sales Order Spartan/Sales Order Spartan.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:30:51.000000", + "doc_type": "Sales Order", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:35:29.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Order Spartan", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/selling/Print Format/Sales Order Spartan/Sales Order Spartan.txt b/erpnext/selling/Print Format/Sales Order Spartan/Sales Order Spartan.txt deleted file mode 100644 index 481da0d5e55..00000000000 --- a/erpnext/selling/Print Format/Sales Order Spartan/Sales Order Spartan.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:30:51", - "docstatus": 0, - "modified": "2014-02-11 17:35:29", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Sales Order", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Selling", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Sales Order Spartan" - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/campaign/campaign.json b/erpnext/selling/doctype/campaign/campaign.json new file mode 100644 index 00000000000..9b45c6afa14 --- /dev/null +++ b/erpnext/selling/doctype/campaign/campaign.json @@ -0,0 +1,98 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:campaign_name", + "creation": "2013-01-10 16:34:18.000000", + "description": "Keep Track of Sales Campaigns. Keep track of Leads, Quotations, Sales Order etc from Campaigns to gauge Return on Investment. ", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "campaign", + "fieldtype": "Section Break", + "label": "Campaign", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "campaign_name", + "fieldtype": "Data", + "label": "Campaign Name", + "oldfieldname": "campaign_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "width": "300px" + } + ], + "icon": "icon-bullhorn", + "idx": 1, + "modified": "2014-01-20 17:48:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Campaign", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "Sales Manager", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/selling/doctype/campaign/campaign.py b/erpnext/selling/doctype/campaign/campaign.py index 5015bed79ce..523c62d03f4 100644 --- a/erpnext/selling/doctype/campaign/campaign.py +++ b/erpnext/selling/doctype/campaign/campaign.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - \ No newline at end of file +from frappe.model.document import Document + +class Campaign(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/campaign/campaign.txt b/erpnext/selling/doctype/campaign/campaign.txt deleted file mode 100644 index 55c459cea33..00000000000 --- a/erpnext/selling/doctype/campaign/campaign.txt +++ /dev/null @@ -1,105 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:18", - "docstatus": 0, - "modified": "2014-01-20 17:48:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:campaign_name", - "description": "Keep Track of Sales Campaigns. Keep track of Leads, Quotations, Sales Order etc from Campaigns to gauge Return on Investment. ", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-bullhorn", - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Campaign", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Campaign", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Campaign" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "campaign", - "fieldtype": "Section Break", - "label": "Campaign", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "campaign_name", - "fieldtype": "Data", - "label": "Campaign Name", - "oldfieldname": "campaign_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "width": "300px" - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "import": 0, - "report": 0, - "role": "Sales Manager", - "write": 0 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "report": 1, - "role": "Sales User", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "report": 1, - "role": "Sales Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/campaign/test_campaign.py b/erpnext/selling/doctype/campaign/test_campaign.py index d3bf61e80a8..5d7c9a4649f 100644 --- a/erpnext/selling/doctype/campaign/test_campaign.py +++ b/erpnext/selling/doctype/campaign/test_campaign.py @@ -1,7 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{"doctype":"Campaign", "campaign_name":"_Test Campaign"}], - [{"doctype":"Campaign", "campaign_name":"_Test Campaign 1"}], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Campaign') \ No newline at end of file diff --git a/erpnext/selling/doctype/campaign/test_records.json b/erpnext/selling/doctype/campaign/test_records.json new file mode 100644 index 00000000000..625d3b377b2 --- /dev/null +++ b/erpnext/selling/doctype/campaign/test_records.json @@ -0,0 +1,10 @@ +[ + { + "campaign_name": "_Test Campaign", + "doctype": "Campaign" + }, + { + "campaign_name": "_Test Campaign 1", + "doctype": "Campaign" + } +] \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json new file mode 100644 index 00000000000..2bb65f347bd --- /dev/null +++ b/erpnext/selling/doctype/customer/customer.json @@ -0,0 +1,333 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "naming_series:", + "creation": "2013-06-11 14:26:44.000000", + "description": "Buyer of Goods and Services.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "basic_info", + "fieldtype": "Section Break", + "label": "Basic Info", + "oldfieldtype": "Section Break", + "options": "icon-user", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "options": "\nCUST\nCUSTMUM", + "permlevel": 0, + "print_hide": 0 + }, + { + "fieldname": "customer_name", + "fieldtype": "Data", + "hidden": 0, + "in_filter": 1, + "in_list_view": 1, + "label": "Full Name", + "no_copy": 1, + "oldfieldname": "customer_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "customer_type", + "fieldtype": "Select", + "label": "Type", + "oldfieldname": "customer_type", + "oldfieldtype": "Select", + "options": "\nCompany\nIndividual", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "lead_name", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "From Lead", + "no_copy": 1, + "oldfieldname": "lead_name", + "oldfieldtype": "Link", + "options": "Lead", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "description": "Add / Edit", + "fieldname": "customer_group", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Group", + "oldfieldname": "customer_group", + "oldfieldtype": "Link", + "options": "Customer Group", + "permlevel": 0, + "print_hide": 0, + "reqd": 1, + "search_index": 1 + }, + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Territory", + "oldfieldname": "territory", + "oldfieldtype": "Link", + "options": "Territory", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "address_contacts", + "fieldtype": "Section Break", + "label": "Address & Contacts", + "options": "icon-map-marker", + "permlevel": 0 + }, + { + "fieldname": "address_html", + "fieldtype": "HTML", + "label": "Address HTML", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "contact_html", + "fieldtype": "HTML", + "label": "Contact HTML", + "oldfieldtype": "HTML", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "communication_history", + "fieldtype": "Section Break", + "label": "Communication History", + "options": "icon-comments", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "communication_html", + "fieldtype": "HTML", + "label": "Communication HTML", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "description": "To create an Account Head under a different company, select the company and save customer.", + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "description": "Your Customer's TAX registration numbers (if applicable) or any general information", + "fieldname": "customer_details", + "fieldtype": "Text", + "label": "Customer Details", + "oldfieldname": "customer_details", + "oldfieldtype": "Code", + "permlevel": 0 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "default_currency", + "fieldtype": "Link", + "label": "Currency", + "no_copy": 1, + "options": "Currency", + "permlevel": 0 + }, + { + "fieldname": "default_price_list", + "fieldtype": "Link", + "label": "Price List", + "options": "Price List", + "permlevel": 0 + }, + { + "fieldname": "default_taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "options": "Sales Taxes and Charges Master", + "permlevel": 0 + }, + { + "fieldname": "credit_days", + "fieldtype": "Int", + "label": "Credit Days", + "oldfieldname": "credit_days", + "oldfieldtype": "Int", + "permlevel": 1 + }, + { + "fieldname": "credit_limit", + "fieldtype": "Currency", + "label": "Credit Limit", + "oldfieldname": "credit_limit", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 1 + }, + { + "fieldname": "website", + "fieldtype": "Data", + "label": "Website", + "permlevel": 0 + }, + { + "fieldname": "sales_team_section_break", + "fieldtype": "Section Break", + "label": "Sales Team", + "oldfieldtype": "Section Break", + "options": "icon-group", + "permlevel": 0 + }, + { + "fieldname": "default_sales_partner", + "fieldtype": "Link", + "label": "Sales Partner", + "oldfieldname": "default_sales_partner", + "oldfieldtype": "Link", + "options": "Sales Partner", + "permlevel": 0 + }, + { + "fieldname": "default_commission_rate", + "fieldtype": "Float", + "label": "Commission Rate", + "oldfieldname": "default_commission_rate", + "oldfieldtype": "Currency", + "permlevel": 0 + }, + { + "fieldname": "sales_team", + "fieldtype": "Table", + "label": "Sales Team Details", + "oldfieldname": "sales_team", + "oldfieldtype": "Table", + "options": "Sales Team", + "permlevel": 0 + }, + { + "fieldname": "communications", + "fieldtype": "Table", + "hidden": 1, + "label": "Communications", + "options": "Communication", + "permlevel": 0, + "print_hide": 1 + } + ], + "icon": "icon-user", + "idx": 1, + "modified": "2014-03-03 19:05:58.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Customer", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "delete": 0, + "permlevel": 1, + "read": 1, + "role": "Sales User" + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "restrict": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "delete": 0, + "permlevel": 1, + "read": 1, + "role": "Sales Master Manager", + "write": 1 + } + ], + "search_fields": "customer_name,customer_group,territory" +} \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index d8a095f7e50..361f4fa4ffd 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import frappe -from frappe.model.doc import Document, make_autoname +from frappe.model.naming import make_autoname from frappe import msgprint, _ import frappe.defaults @@ -11,108 +11,105 @@ import frappe.defaults from erpnext.utilities.transaction_base import TransactionBase from erpnext.accounts.party import create_party_account -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - +class Customer(TransactionBase): + def autoname(self): cust_master_name = frappe.defaults.get_global_default('cust_master_name') if cust_master_name == 'Customer Name': - if frappe.db.exists("Supplier", self.doc.customer_name): + if frappe.db.exists("Supplier", self.customer_name): msgprint(_("A Supplier exists with same name"), raise_exception=1) - self.doc.name = self.doc.customer_name + self.name = self.customer_name else: - self.doc.name = make_autoname(self.doc.naming_series+'.#####') + self.name = make_autoname(self.naming_series+'.#####') def get_company_abbr(self): - return frappe.db.get_value('Company', self.doc.company, 'abbr') - + return frappe.db.get_value('Company', self.company, 'abbr') + def validate_values(self): - if frappe.defaults.get_global_default('cust_master_name') == 'Naming Series' and not self.doc.naming_series: + if frappe.defaults.get_global_default('cust_master_name') == 'Naming Series' and not self.naming_series: frappe.throw("Series is Mandatory.", frappe.MandatoryError) def validate(self): self.validate_values() def update_lead_status(self): - if self.doc.lead_name: - frappe.db.sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name) + if self.lead_name: + frappe.db.sql("update `tabLead` set status='Converted' where name = %s", self.lead_name) def update_address(self): - frappe.db.sql("""update `tabAddress` set customer_name=%s, modified=NOW() - where customer=%s""", (self.doc.customer_name, self.doc.name)) + frappe.db.sql("""update `tabAddress` set customer_name=%s, modified=NOW() + where customer=%s""", (self.customer_name, self.name)) def update_contact(self): - frappe.db.sql("""update `tabContact` set customer_name=%s, modified=NOW() - where customer=%s""", (self.doc.customer_name, self.doc.name)) + frappe.db.sql("""update `tabContact` set customer_name=%s, modified=NOW() + where customer=%s""", (self.customer_name, self.name)) def update_credit_days_limit(self): - frappe.db.sql("""update tabAccount set credit_days = %s, credit_limit = %s - where master_type='Customer' and master_name = %s""", - (self.doc.credit_days or 0, self.doc.credit_limit or 0, self.doc.name)) + frappe.db.sql("""update tabAccount set credit_days = %s, credit_limit = %s + where master_type='Customer' and master_name = %s""", + (self.credit_days or 0, self.credit_limit or 0, self.name)) def create_lead_address_contact(self): - if self.doc.lead_name: - if not frappe.db.get_value("Address", {"lead": self.doc.lead_name, "customer": self.doc.customer}): - frappe.db.sql("""update `tabAddress` set customer=%s, customer_name=%s where lead=%s""", - (self.doc.name, self.doc.customer_name, self.doc.lead_name)) + if self.lead_name: + if not frappe.db.get_value("Address", {"lead": self.lead_name, "customer": self.name}): + frappe.db.sql("""update `tabAddress` set customer=%s, customer_name=%s where lead=%s""", + (self.name, self.customer_name, self.lead_name)) - lead = frappe.db.get_value("Lead", self.doc.lead_name, ["lead_name", "email_id", "phone", "mobile_no"], as_dict=True) - c = Document('Contact') - c.first_name = lead.lead_name + lead = frappe.db.get_value("Lead", self.lead_name, ["lead_name", "email_id", "phone", "mobile_no"], as_dict=True) + c = frappe.new_doc('Contact') + c.first_name = lead.lead_name c.email_id = lead.email_id c.phone = lead.phone c.mobile_no = lead.mobile_no - c.customer = self.doc.name - c.customer_name = self.doc.customer_name + c.customer = self.name + c.customer_name = self.customer_name c.is_primary_contact = 1 try: - c.save(1) + c.save() except NameError, e: pass def on_update(self): self.validate_name_with_customer_group() - + self.update_lead_status() self.update_address() self.update_contact() # create account head - create_party_account(self.doc.name, "Customer", self.doc.company) + create_party_account(self.name, "Customer", self.company) # update credit days and limit in account self.update_credit_days_limit() #create address and contact from lead self.create_lead_address_contact() - + def validate_name_with_customer_group(self): - if frappe.db.exists("Customer Group", self.doc.name): + if frappe.db.exists("Customer Group", self.name): frappe.msgprint("An Customer Group exists with same name (%s), \ - please change the Customer name or rename the Customer Group" % - self.doc.name, raise_exception=1) + please change the Customer name or rename the Customer Group" % + self.name, raise_exception=1) def delete_customer_address(self): addresses = frappe.db.sql("""select name, lead from `tabAddress` - where customer=%s""", (self.doc.name,)) - + where customer=%s""", (self.name,)) + for name, lead in addresses: if lead: frappe.db.sql("""update `tabAddress` set customer=null, customer_name=null where name=%s""", name) else: frappe.db.sql("""delete from `tabAddress` where name=%s""", name) - + def delete_customer_contact(self): - for contact in frappe.db.sql_list("""select name from `tabContact` - where customer=%s""", self.doc.name): + for contact in frappe.db.sql_list("""select name from `tabContact` + where customer=%s""", self.name): frappe.delete_doc("Contact", contact) - + def delete_customer_account(self): """delete customer's ledger if exist and check balance before deletion""" acc = frappe.db.sql("select name from `tabAccount` where master_type = 'Customer' \ - and master_name = %s and docstatus < 2", self.doc.name) + and master_name = %s and docstatus < 2", self.name) if acc: frappe.delete_doc('Account', acc[0][0]) @@ -120,23 +117,23 @@ class DocType(TransactionBase): self.delete_customer_address() self.delete_customer_contact() self.delete_customer_account() - if self.doc.lead_name: - frappe.db.sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name) - + if self.lead_name: + frappe.db.sql("update `tabLead` set status='Interested' where name=%s",self.lead_name) + def before_rename(self, olddn, newdn, merge=False): from erpnext.accounts.utils import rename_account_for - rename_account_for("Customer", olddn, newdn, merge, self.doc.company) + rename_account_for("Customer", olddn, newdn, merge, self.company) def after_rename(self, olddn, newdn, merge=False): set_field = '' if frappe.defaults.get_global_default('cust_master_name') == 'Customer Name': - frappe.db.set(self.doc, "customer_name", newdn) + frappe.db.set(self, "customer_name", newdn) self.update_contact() set_field = ", customer_name=%(newdn)s" self.update_customer_address(newdn, set_field) def update_customer_address(self, newdn, set_field): - frappe.db.sql("""update `tabAddress` set address_title=%(newdn)s + frappe.db.sql("""update `tabAddress` set address_title=%(newdn)s {set_field} where customer=%(newdn)s"""\ .format(set_field=set_field), ({"newdn": newdn})) @@ -144,21 +141,21 @@ class DocType(TransactionBase): def get_dashboard_info(customer): if not frappe.has_permission("Customer", "read", customer): frappe.msgprint("No Permission", raise_exception=True) - + out = {} for doctype in ["Opportunity", "Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]: - out[doctype] = frappe.db.get_value(doctype, + out[doctype] = frappe.db.get_value(doctype, {"customer": customer, "docstatus": ["!=", 2] }, "count(*)") - - billing = frappe.db.sql("""select sum(grand_total), sum(outstanding_amount) - from `tabSales Invoice` - where customer=%s + + billing = frappe.db.sql("""select sum(grand_total), sum(outstanding_amount) + from `tabSales Invoice` + where customer=%s and docstatus = 1 and fiscal_year = %s""", (customer, frappe.db.get_default("fiscal_year"))) - + out["total_billing"] = billing[0][0] out["total_unpaid"] = billing[0][1] - + return out @@ -167,11 +164,11 @@ def get_customer_list(doctype, txt, searchfield, start, page_len, filters): fields = ["name", "customer_group", "territory"] else: fields = ["name", "customer_name", "customer_group", "territory"] - - return frappe.db.sql("""select %s from `tabCustomer` where docstatus < 2 - and (%s like %s or customer_name like %s) order by + + return frappe.db.sql("""select %s from `tabCustomer` where docstatus < 2 + and (%s like %s or customer_name like %s) order by case when name like %s then 0 else 1 end, case when customer_name like %s then 0 else 1 end, - name, customer_name limit %s, %s""" % - (", ".join(fields), searchfield, "%s", "%s", "%s", "%s", "%s", "%s"), - ("%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, start, page_len)) \ No newline at end of file + name, customer_name limit %s, %s""" % + (", ".join(fields), searchfield, "%s", "%s", "%s", "%s", "%s", "%s"), + ("%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, start, page_len)) diff --git a/erpnext/selling/doctype/customer/customer.txt b/erpnext/selling/doctype/customer/customer.txt deleted file mode 100644 index 56051d53c4a..00000000000 --- a/erpnext/selling/doctype/customer/customer.txt +++ /dev/null @@ -1,378 +0,0 @@ -[ - { - "creation": "2013-06-11 14:26:44", - "docstatus": 0, - "modified": "2014-03-03 19:05:58", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "naming_series:", - "description": "Buyer of Goods and Services.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-user", - "module": "Selling", - "name": "__common__", - "search_fields": "customer_name,customer_group,territory" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Customer", - "parentfield": "fields", - "parenttype": "DocType" - }, - { - "cancel": 0, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Customer", - "parentfield": "permissions", - "parenttype": "DocType", - "read": 1 - }, - { - "doctype": "DocType", - "name": "Customer" - }, - { - "doctype": "DocField", - "fieldname": "basic_info", - "fieldtype": "Section Break", - "label": "Basic Info", - "oldfieldtype": "Section Break", - "options": "icon-user", - "permlevel": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "options": "\nCUST\nCUSTMUM", - "permlevel": 0, - "print_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "hidden": 0, - "in_filter": 1, - "in_list_view": 1, - "label": "Full Name", - "no_copy": 1, - "oldfieldname": "customer_name", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer_type", - "fieldtype": "Select", - "label": "Type", - "oldfieldname": "customer_type", - "oldfieldtype": "Select", - "options": "\nCompany\nIndividual", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "lead_name", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "From Lead", - "no_copy": 1, - "oldfieldname": "lead_name", - "oldfieldtype": "Link", - "options": "Lead", - "permlevel": 0, - "print_hide": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "permlevel": 0, - "width": "50%" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Group", - "oldfieldname": "customer_group", - "oldfieldtype": "Link", - "options": "Customer Group", - "permlevel": 0, - "print_hide": 0, - "reqd": 1, - "search_index": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Territory", - "oldfieldname": "territory", - "oldfieldtype": "Link", - "options": "Territory", - "permlevel": 0, - "print_hide": 1, - "reqd": 1 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "address_contacts", - "fieldtype": "Section Break", - "label": "Address & Contacts", - "options": "icon-map-marker", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "address_html", - "fieldtype": "HTML", - "label": "Address HTML", - "permlevel": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "permlevel": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "contact_html", - "fieldtype": "HTML", - "label": "Contact HTML", - "oldfieldtype": "HTML", - "permlevel": 0, - "read_only": 1 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "communication_history", - "fieldtype": "Section Break", - "label": "Communication History", - "options": "icon-comments", - "permlevel": 0, - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "communication_html", - "fieldtype": "HTML", - "label": "Communication HTML", - "permlevel": 0, - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "permlevel": 0, - "width": "50%" - }, - { - "description": "To create an Account Head under a different company, select the company and save customer.", - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "permlevel": 0, - "reqd": 1, - "search_index": 1 - }, - { - "description": "Your Customer's TAX registration numbers (if applicable) or any general information", - "doctype": "DocField", - "fieldname": "customer_details", - "fieldtype": "Text", - "label": "Customer Details", - "oldfieldname": "customer_details", - "oldfieldtype": "Code", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "permlevel": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "default_currency", - "fieldtype": "Link", - "label": "Currency", - "no_copy": 1, - "options": "Currency", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "default_price_list", - "fieldtype": "Link", - "label": "Price List", - "options": "Price List", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "default_taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "options": "Sales Taxes and Charges Master", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "credit_days", - "fieldtype": "Int", - "label": "Credit Days", - "oldfieldname": "credit_days", - "oldfieldtype": "Int", - "permlevel": 1 - }, - { - "doctype": "DocField", - "fieldname": "credit_limit", - "fieldtype": "Currency", - "label": "Credit Limit", - "oldfieldname": "credit_limit", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "permlevel": 1 - }, - { - "doctype": "DocField", - "fieldname": "website", - "fieldtype": "Data", - "label": "Website", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "sales_team_section_break", - "fieldtype": "Section Break", - "label": "Sales Team", - "oldfieldtype": "Section Break", - "options": "icon-group", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "default_sales_partner", - "fieldtype": "Link", - "label": "Sales Partner", - "oldfieldname": "default_sales_partner", - "oldfieldtype": "Link", - "options": "Sales Partner", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "default_commission_rate", - "fieldtype": "Float", - "label": "Commission Rate", - "oldfieldname": "default_commission_rate", - "oldfieldtype": "Currency", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "sales_team", - "fieldtype": "Table", - "label": "Sales Team Details", - "oldfieldname": "sales_team", - "oldfieldtype": "Table", - "options": "Sales Team", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "communications", - "fieldtype": "Table", - "hidden": 1, - "label": "Communications", - "options": "Communication", - "permlevel": 0, - "print_hide": 1 - }, - { - "amend": 0, - "create": 1, - "delete": 0, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "report": 1, - "role": "Sales User", - "submit": 0, - "write": 1 - }, - { - "delete": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "Sales User" - }, - { - "amend": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "report": 1, - "restrict": 1, - "role": "Sales Master Manager", - "submit": 0, - "write": 1 - }, - { - "delete": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "Sales Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index b6a7116843a..19bcce8ee54 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -8,6 +8,9 @@ import unittest from frappe.test_runner import make_test_records +test_ignore = ["Price List"] + +test_records = frappe.get_test_records('Customer') class TestCustomer(unittest.TestCase): def test_party_details(self): @@ -47,31 +50,3 @@ class TestCustomer(unittest.TestCase): frappe.rename_doc("Customer", "_Test Customer 1 Renamed", "_Test Customer 1") -test_ignore = ["Price List"] - -test_records = [ - [{ - "doctype": "Customer", - "customer_name": "_Test Customer", - "customer_type": "Individual", - "customer_group": "_Test Customer Group", - "territory": "_Test Territory", - "company": "_Test Company" - }], - [{ - "doctype": "Customer", - "customer_name": "_Test Customer 1", - "customer_type": "Individual", - "customer_group": "_Test Customer Group", - "territory": "_Test Territory", - "company": "_Test Company" - }], - [{ - "doctype": "Customer", - "customer_name": "_Test Customer 2", - "customer_type": "Individual", - "customer_group": "_Test Customer Group", - "territory": "_Test Territory", - "company": "_Test Company" - }] -] \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/test_records.json b/erpnext/selling/doctype/customer/test_records.json new file mode 100644 index 00000000000..b4fb6e59445 --- /dev/null +++ b/erpnext/selling/doctype/customer/test_records.json @@ -0,0 +1,26 @@ +[ + { + "company": "_Test Company", + "customer_group": "_Test Customer Group", + "customer_name": "_Test Customer", + "customer_type": "Individual", + "doctype": "Customer", + "territory": "_Test Territory" + }, + { + "company": "_Test Company", + "customer_group": "_Test Customer Group", + "customer_name": "_Test Customer 1", + "customer_type": "Individual", + "doctype": "Customer", + "territory": "_Test Territory" + }, + { + "company": "_Test Company", + "customer_group": "_Test Customer Group", + "customer_name": "_Test Customer 2", + "customer_type": "Individual", + "doctype": "Customer", + "territory": "_Test Territory" + } +] \ No newline at end of file diff --git a/erpnext/selling/doctype/industry_type/industry_type.json b/erpnext/selling/doctype/industry_type/industry_type.json new file mode 100644 index 00000000000..2beda937187 --- /dev/null +++ b/erpnext/selling/doctype/industry_type/industry_type.json @@ -0,0 +1,56 @@ +{ + "allow_import": 1, + "autoname": "field:industry", + "creation": "2012-03-27 14:36:09.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "industry", + "fieldtype": "Data", + "label": "Industry", + "oldfieldname": "industry", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-flag", + "idx": 1, + "modified": "2013-12-20 19:24:08.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Industry Type", + "owner": "harshada@webnotestech.com", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "write": 1 + }, + { + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User" + }, + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/selling/doctype/industry_type/industry_type.py b/erpnext/selling/doctype/industry_type/industry_type.py index 5015bed79ce..f6bf2c81326 100644 --- a/erpnext/selling/doctype/industry_type/industry_type.py +++ b/erpnext/selling/doctype/industry_type/industry_type.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - \ No newline at end of file +from frappe.model.document import Document + +class IndustryType(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/industry_type/industry_type.txt b/erpnext/selling/doctype/industry_type/industry_type.txt deleted file mode 100644 index e65fc3812ae..00000000000 --- a/erpnext/selling/doctype/industry_type/industry_type.txt +++ /dev/null @@ -1,67 +0,0 @@ -[ - { - "creation": "2012-03-27 14:36:09", - "docstatus": 0, - "modified": "2013-12-20 19:24:08", - "modified_by": "Administrator", - "owner": "harshada@webnotestech.com" - }, - { - "allow_import": 1, - "autoname": "field:industry", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-flag", - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "industry", - "fieldtype": "Data", - "label": "Industry", - "name": "__common__", - "oldfieldname": "industry", - "oldfieldtype": "Data", - "parent": "Industry Type", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Industry Type", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Industry Type" - }, - { - "doctype": "DocField" - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "Sales Manager", - "write": 1 - }, - { - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/industry_type/test_industry_type.py b/erpnext/selling/doctype/industry_type/test_industry_type.py index 91679c77bbe..31c5bb26721 100644 --- a/erpnext/selling/doctype/industry_type/test_industry_type.py +++ b/erpnext/selling/doctype/industry_type/test_industry_type.py @@ -1,7 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{"doctype":"Industry Type", "industry":"_Test Industry"}], - [{"doctype":"Industry Type", "industry":"_Test Industry 1"}], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Industry Type') \ No newline at end of file diff --git a/erpnext/selling/doctype/industry_type/test_records.json b/erpnext/selling/doctype/industry_type/test_records.json new file mode 100644 index 00000000000..2b593bb3ac2 --- /dev/null +++ b/erpnext/selling/doctype/industry_type/test_records.json @@ -0,0 +1,10 @@ +[ + { + "doctype": "Industry Type", + "industry": "_Test Industry" + }, + { + "doctype": "Industry Type", + "industry": "_Test Industry 1" + } +] \ No newline at end of file diff --git a/erpnext/selling/doctype/installation_note/installation_note.json b/erpnext/selling/doctype/installation_note/installation_note.json new file mode 100644 index 00000000000..cffd39d3f92 --- /dev/null +++ b/erpnext/selling/doctype/installation_note/installation_note.json @@ -0,0 +1,268 @@ +{ + "autoname": "naming_series:", + "creation": "2013-04-30 13:13:06.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "installation_note", + "fieldtype": "Section Break", + "label": "Installation Note", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "\nIN", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "label": "Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "depends_on": "customer", + "fieldname": "customer_address", + "fieldtype": "Link", + "label": "Customer Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1 + }, + { + "depends_on": "customer", + "fieldname": "contact_person", + "fieldtype": "Link", + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "customer_name", + "fieldtype": "Data", + "label": "Name", + "oldfieldname": "customer_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "customer", + "fieldname": "contact_mobile", + "fieldtype": "Text", + "label": "Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "customer", + "fieldname": "contact_email", + "fieldtype": "Text", + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "depends_on": "customer", + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "in_filter": 1, + "label": "Territory", + "options": "Territory", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "depends_on": "customer", + "description": "Add / Edit", + "fieldname": "customer_group", + "fieldtype": "Link", + "label": "Customer Group", + "options": "Customer Group", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "inst_date", + "fieldtype": "Date", + "label": "Installation Date", + "oldfieldname": "inst_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "inst_time", + "fieldtype": "Time", + "label": "Installation Time", + "oldfieldname": "inst_time", + "oldfieldtype": "Time", + "permlevel": 0 + }, + { + "default": "Draft", + "fieldname": "status", + "fieldtype": "Select", + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "Draft\nSubmitted\nCancelled", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "description": "Select the relevant company name if you have multiple companies.", + "fieldname": "company", + "fieldtype": "Select", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Select", + "options": "link:Company", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "remarks", + "fieldtype": "Small Text", + "label": "Remarks", + "oldfieldname": "remarks", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "item_details", + "fieldtype": "Section Break", + "label": "Item Details", + "oldfieldtype": "Section Break", + "options": "Simple", + "permlevel": 0 + }, + { + "fieldname": "installed_item_details", + "fieldtype": "Table", + "label": "Installation Note Item", + "oldfieldname": "installed_item_details", + "oldfieldtype": "Table", + "options": "Installation Note Item", + "permlevel": 0 + } + ], + "icon": "icon-wrench", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:48:47.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Installation Note", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 1, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "permlevel": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0 + } + ] +} \ No newline at end of file diff --git a/erpnext/selling/doctype/installation_note/installation_note.py b/erpnext/selling/doctype/installation_note/installation_note.py index 3d57db734a1..1fa91ccc7c0 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.py +++ b/erpnext/selling/doctype/installation_note/installation_note.py @@ -5,18 +5,18 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, getdate -from frappe.model.bean import getlist + from frappe import msgprint -from erpnext.stock.utils import get_valid_serial_nos +from erpnext.stock.utils import get_valid_serial_nos from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.tname = 'Installation Note Item' - self.fname = 'installed_item_details' +class InstallationNote(TransactionBase): + tname = 'Installation Note Item' + fname = 'installed_item_details' + + def __init__(self, arg1, arg2=None): + super(InstallationNote, self).__init__(arg1, arg2) self.status_updater = [{ 'source_dt': 'Installation Note Item', 'target_dt': 'Delivery Note Item', @@ -35,87 +35,87 @@ class DocType(TransactionBase): self.validate_fiscal_year() self.validate_installation_date() self.check_item_table() - + from erpnext.controllers.selling_controller import check_active_sales_items check_active_sales_items(self) def validate_fiscal_year(self): from erpnext.accounts.utils import validate_fiscal_year - validate_fiscal_year(self.doc.inst_date, self.doc.fiscal_year, "Installation Date") - + validate_fiscal_year(self.inst_date, self.fiscal_year, "Installation Date") + def is_serial_no_added(self, item_code, serial_no): ar_required = frappe.db.get_value("Item", item_code, "has_serial_no") if ar_required == 'Yes' and not serial_no: msgprint("Serial No is mandatory for item: " + item_code, raise_exception=1) elif ar_required != 'Yes' and cstr(serial_no).strip(): - msgprint("If serial no required, please select 'Yes' in 'Has Serial No' in Item :" + + msgprint("If serial no required, please select 'Yes' in 'Has Serial No' in Item :" + item_code, raise_exception=1) - + def is_serial_no_exist(self, item_code, serial_no): for x in serial_no: if not frappe.db.exists("Serial No", x): msgprint("Serial No " + x + " does not exist in the system", raise_exception=1) - + def is_serial_no_installed(self,cur_s_no,item_code): for x in cur_s_no: status = frappe.db.sql("select status from `tabSerial No` where name = %s", x) status = status and status[0][0] or '' - + if status == 'Installed': - msgprint("Item "+item_code+" with serial no. " + x + " already installed", + msgprint("Item "+item_code+" with serial no. " + x + " already installed", raise_exception=1) - + def get_prevdoc_serial_no(self, prevdoc_detail_docname): - serial_nos = frappe.db.get_value("Delivery Note Item", + serial_nos = frappe.db.get_value("Delivery Note Item", prevdoc_detail_docname, "serial_no") return get_valid_serial_nos(serial_nos) - + def is_serial_no_match(self, cur_s_no, prevdoc_s_no, prevdoc_docname): for sr in cur_s_no: if sr not in prevdoc_s_no: - msgprint("Serial No. " + sr + " is not matching with the Delivery Note " + + msgprint("Serial No. " + sr + " is not matching with the Delivery Note " + prevdoc_docname, raise_exception = 1) def validate_serial_no(self): cur_s_no, prevdoc_s_no, sr_list = [], [], [] - for d in getlist(self.doclist, 'installed_item_details'): + for d in self.get('installed_item_details'): self.is_serial_no_added(d.item_code, d.serial_no) if d.serial_no: sr_list = get_valid_serial_nos(d.serial_no, d.qty, d.item_code) self.is_serial_no_exist(d.item_code, sr_list) - + prevdoc_s_no = self.get_prevdoc_serial_no(d.prevdoc_detail_docname) if prevdoc_s_no: self.is_serial_no_match(sr_list, prevdoc_s_no, d.prevdoc_docname) - + self.is_serial_no_installed(sr_list, d.item_code) def validate_installation_date(self): - for d in getlist(self.doclist, 'installed_item_details'): + for d in self.get('installed_item_details'): if d.prevdoc_docname: - d_date = frappe.db.get_value("Delivery Note", d.prevdoc_docname, "posting_date") - if d_date > getdate(self.doc.inst_date): - msgprint("Installation Date can not be before Delivery Date " + cstr(d_date) + + d_date = frappe.db.get_value("Delivery Note", d.prevdoc_docname, "posting_date") + if d_date > getdate(self.inst_date): + msgprint("Installation Date can not be before Delivery Date " + cstr(d_date) + " for item "+d.item_code, raise_exception=1) - + def check_item_table(self): - if not(getlist(self.doclist, 'installed_item_details')): + if not(self.get('installed_item_details')): msgprint("Please fetch items from Delivery Note selected", raise_exception=1) - + def on_update(self): - frappe.db.set(self.doc, 'status', 'Draft') - + frappe.db.set(self, 'status', 'Draft') + def on_submit(self): self.validate_serial_no() self.update_prevdoc_status() - frappe.db.set(self.doc, 'status', 'Submitted') - + frappe.db.set(self, 'status', 'Submitted') + def on_cancel(self): - for d in getlist(self.doclist, 'installed_item_details'): + for d in self.get('installed_item_details'): if d.serial_no: d.serial_no = d.serial_no.replace(",", "\n") for sr_no in d.serial_no.split("\n"): frappe.db.set_value("Serial No", sr_no, "status", "Delivered") self.update_prevdoc_status() - frappe.db.set(self.doc, 'status', 'Cancelled') + frappe.db.set(self, 'status', 'Cancelled') diff --git a/erpnext/selling/doctype/installation_note/installation_note.txt b/erpnext/selling/doctype/installation_note/installation_note.txt deleted file mode 100644 index 5e519829df2..00000000000 --- a/erpnext/selling/doctype/installation_note/installation_note.txt +++ /dev/null @@ -1,285 +0,0 @@ -[ - { - "creation": "2013-04-30 13:13:06", - "docstatus": 0, - "modified": "2014-01-20 17:48:47", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "naming_series:", - "doctype": "DocType", - "icon": "icon-wrench", - "is_submittable": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Installation Note", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "Installation Note", - "parentfield": "permissions", - "parenttype": "DocType", - "read": 1, - "report": 1, - "role": "Sales User" - }, - { - "doctype": "DocType", - "name": "Installation Note" - }, - { - "doctype": "DocField", - "fieldname": "installation_note", - "fieldtype": "Section Break", - "label": "Installation Note", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "\nIN", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "label": "Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "customer_address", - "fieldtype": "Link", - "label": "Customer Address", - "options": "Address", - "print_hide": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "label": "Contact Person", - "options": "Contact", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "label": "Name", - "oldfieldname": "customer_name", - "oldfieldtype": "Data", - "read_only": 1, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "read_only": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Text", - "label": "Mobile No", - "read_only": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Text", - "label": "Contact Email", - "print_hide": 1, - "read_only": 1 - }, - { - "depends_on": "customer", - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "in_filter": 1, - "label": "Territory", - "options": "Territory", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "depends_on": "customer", - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "label": "Customer Group", - "options": "Customer Group", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "inst_date", - "fieldtype": "Date", - "label": "Installation Date", - "oldfieldname": "inst_date", - "oldfieldtype": "Date", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "inst_time", - "fieldtype": "Time", - "label": "Installation Time", - "oldfieldname": "inst_time", - "oldfieldtype": "Time" - }, - { - "default": "Draft", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "Draft\nSubmitted\nCancelled", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "description": "Select the relevant company name if you have multiple companies.", - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Select", - "options": "link:Company", - "print_hide": 1, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "remarks", - "fieldtype": "Small Text", - "label": "Remarks", - "oldfieldname": "remarks", - "oldfieldtype": "Small Text", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_details", - "fieldtype": "Section Break", - "label": "Item Details", - "oldfieldtype": "Section Break", - "options": "Simple" - }, - { - "doctype": "DocField", - "fieldname": "installed_item_details", - "fieldtype": "Table", - "label": "Installation Note Item", - "oldfieldname": "installed_item_details", - "oldfieldtype": "Table", - "options": "Installation Note Item" - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "submit": 1, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "permlevel": 1, - "submit": 0 - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/installation_note_item/installation_note_item.json b/erpnext/selling/doctype/installation_note_item/installation_note_item.json new file mode 100644 index 00000000000..0e94d10013c --- /dev/null +++ b/erpnext/selling/doctype/installation_note_item/installation_note_item.json @@ -0,0 +1,108 @@ +{ + "autoname": "IID/.#####", + "creation": "2013-02-22 01:27:51.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "300px", + "read_only": 1, + "width": "300px" + }, + { + "fieldname": "serial_no", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Serial No", + "oldfieldname": "serial_no", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "180px", + "width": "180px" + }, + { + "fieldname": "prevdoc_detail_docname", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Against Document Detail No", + "no_copy": 1, + "oldfieldname": "prevdoc_detail_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "prevdoc_docname", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "Against Document No", + "no_copy": 1, + "oldfieldname": "prevdoc_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "prevdoc_doctype", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "Document Type", + "no_copy": 1, + "oldfieldname": "prevdoc_doctype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Installed Qty", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:14.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Installation Note Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/selling/doctype/installation_note_item/installation_note_item.py b/erpnext/selling/doctype/installation_note_item/installation_note_item.py index 26c87f1c04a..ac3aacfab67 100644 --- a/erpnext/selling/doctype/installation_note_item/installation_note_item.py +++ b/erpnext/selling/doctype/installation_note_item/installation_note_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class InstallationNoteItem(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/installation_note_item/installation_note_item.txt b/erpnext/selling/doctype/installation_note_item/installation_note_item.txt deleted file mode 100644 index 94f648e3a67..00000000000 --- a/erpnext/selling/doctype/installation_note_item/installation_note_item.txt +++ /dev/null @@ -1,121 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:51", - "docstatus": 0, - "modified": "2013-12-20 19:23:14", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "IID/.#####", - "doctype": "DocType", - "istable": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Installation Note Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Installation Note Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Data", - "print_width": "300px", - "read_only": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Serial No", - "oldfieldname": "serial_no", - "oldfieldtype": "Small Text", - "print_width": "180px", - "width": "180px" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_detail_docname", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Against Document Detail No", - "no_copy": 1, - "oldfieldname": "prevdoc_detail_docname", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_docname", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "Against Document No", - "no_copy": 1, - "oldfieldname": "prevdoc_docname", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_doctype", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "Document Type", - "no_copy": 1, - "oldfieldname": "prevdoc_doctype", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Installed Qty", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "reqd": 1 - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/lead/get_leads.py b/erpnext/selling/doctype/lead/get_leads.py index 77a94f7269f..b765db62372 100644 --- a/erpnext/selling/doctype/lead/get_leads.py +++ b/erpnext/selling/doctype/lead/get_leads.py @@ -14,7 +14,7 @@ def add_sales_communication(subject, content, sender, real_name, mail=None, if not (lead_name or contact_name): # none, create a new Lead - lead = frappe.bean({ + lead = frappe.get_doc({ "doctype":"Lead", "lead_name": real_name or sender, "email_id": sender, @@ -24,7 +24,7 @@ def add_sales_communication(subject, content, sender, real_name, mail=None, lead.ignore_permissions = True lead.ignore_mandatory = True lead.insert() - lead_name = lead.doc.name + lead_name = lead.name parent_doctype = "Contact" if contact_name else "Lead" parent_name = contact_name or lead_name @@ -34,12 +34,12 @@ def add_sales_communication(subject, content, sender, real_name, mail=None, if mail: # save attachments to parent if from mail - bean = frappe.bean(parent_doctype, parent_name) - mail.save_attachments_in_doc(bean.doc) + doc = frappe.get_doc(parent_doctype, parent_name) + mail.save_attachments_in_doc(doc) class SalesMailbox(POP3Mailbox): def setup(self, args=None): - self.settings = args or frappe.doc("Sales Email Settings", "Sales Email Settings") + self.settings = args or frappe.get_doc("Sales Email Settings", "Sales Email Settings") def process_message(self, mail): if mail.from_email == self.settings.email_id: diff --git a/erpnext/selling/doctype/lead/lead.js b/erpnext/selling/doctype/lead/lead.js index c942be19e01..570a5e05d61 100644 --- a/erpnext/selling/doctype/lead/lead.js +++ b/erpnext/selling/doctype/lead/lead.js @@ -41,7 +41,7 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({ } cur_frm.communication_view = new frappe.views.CommunicationList({ - list: frappe.model.get("Communication", {"parenttype": "Lead", "parent":this.frm.doc.name}), + list: frappe.get_list("Communication", {"parenttype": "Lead", "parent":this.frm.doc.name}), parent: this.frm.fields_dict.communication_html.wrapper, doc: this.frm.doc, recipients: this.frm.doc.email_id diff --git a/erpnext/selling/doctype/lead/lead.json b/erpnext/selling/doctype/lead/lead.json new file mode 100644 index 00000000000..c423bfaa855 --- /dev/null +++ b/erpnext/selling/doctype/lead/lead.json @@ -0,0 +1,401 @@ +{ + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-04-10 11:45:37.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "lead_details", + "fieldtype": "Section Break", + "label": "Lead Details", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "LEAD\nLEAD/10-11/\nLEAD/MUMBAI/", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "lead_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Contact Name", + "oldfieldname": "lead_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "company_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Organization Name", + "oldfieldname": "company_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "email_id", + "fieldtype": "Data", + "label": "Email Id", + "oldfieldname": "email_id", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "cb6", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": "Lead", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "Lead\nOpen\nReplied\nOpportunity\nInterested\nConverted\nDo Not Contact", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "source", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Source", + "no_copy": 1, + "oldfieldname": "source", + "oldfieldtype": "Select", + "options": "\nAdvertisement\nBlog Post\nCampaign\nCall\nCustomer\nExhibition\nSupplier\nWebsite\nEmail", + "permlevel": 0, + "reqd": 0, + "search_index": 0 + }, + { + "depends_on": "eval:doc.source == 'Customer'", + "fieldname": "customer", + "fieldtype": "Link", + "hidden": 0, + "label": "From Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.source == 'Campaign'", + "description": "Enter campaign name if the source of lead is campaign.", + "fieldname": "campaign_name", + "fieldtype": "Link", + "hidden": 0, + "label": "Campaign Name", + "oldfieldname": "campaign_name", + "oldfieldtype": "Link", + "options": "Campaign", + "permlevel": 0 + }, + { + "fieldname": "communication_history", + "fieldtype": "Section Break", + "label": "Communication", + "options": "icon-comments", + "permlevel": 0, + "print_hide": 1 + }, + { + "default": "__user", + "fieldname": "lead_owner", + "fieldtype": "Link", + "in_filter": 1, + "label": "Lead Owner", + "oldfieldname": "lead_owner", + "oldfieldtype": "Link", + "options": "User", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "col_break123", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "allow_on_submit": 0, + "fieldname": "contact_by", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Next Contact By", + "oldfieldname": "contact_by", + "oldfieldtype": "Link", + "options": "User", + "permlevel": 0, + "print_hide": 0, + "reqd": 0, + "width": "100px" + }, + { + "allow_on_submit": 0, + "description": "Add to calendar on this date", + "fieldname": "contact_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Next Contact Date", + "no_copy": 1, + "oldfieldname": "contact_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "sec_break123", + "fieldtype": "Section Break", + "options": "Simple", + "permlevel": 0 + }, + { + "allow_on_submit": 0, + "fieldname": "communication_html", + "fieldtype": "HTML", + "label": "Communication HTML", + "oldfieldname": "follow_up", + "oldfieldtype": "Table", + "permlevel": 0 + }, + { + "fieldname": "contact_info", + "fieldtype": "Section Break", + "label": "Address & Contact", + "oldfieldtype": "Column Break", + "options": "icon-map-marker", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.__islocal", + "fieldname": "address_desc", + "fieldtype": "HTML", + "hidden": 0, + "label": "Address Desc", + "options": "Addresses will appear only when you save the lead", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "address_html", + "fieldtype": "HTML", + "hidden": 0, + "label": "Address HTML", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "phone", + "fieldtype": "Data", + "label": "Phone", + "oldfieldname": "contact_no", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "mobile_no", + "fieldtype": "Data", + "label": "Mobile No.", + "oldfieldname": "mobile_no", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "fax", + "fieldtype": "Data", + "label": "Fax", + "oldfieldname": "fax", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "website", + "fieldtype": "Data", + "label": "Website", + "oldfieldname": "website", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "label": "Territory", + "oldfieldname": "territory", + "oldfieldtype": "Link", + "options": "Territory", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0 + }, + { + "fieldname": "type", + "fieldtype": "Select", + "in_filter": 1, + "label": "Lead Type", + "oldfieldname": "type", + "oldfieldtype": "Select", + "options": "\nClient\nChannel Partner\nConsultant", + "permlevel": 0 + }, + { + "fieldname": "market_segment", + "fieldtype": "Select", + "hidden": 0, + "in_filter": 1, + "label": "Market Segment", + "oldfieldname": "market_segment", + "oldfieldtype": "Select", + "options": "\nLower Income\nMiddle Income\nUpper Income", + "permlevel": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "industry", + "fieldtype": "Link", + "label": "Industry", + "oldfieldname": "industry", + "oldfieldtype": "Link", + "options": "Industry Type", + "permlevel": 0 + }, + { + "fieldname": "request_type", + "fieldtype": "Select", + "label": "Request Type", + "oldfieldname": "request_type", + "oldfieldtype": "Select", + "options": "\nProduct Enquiry\nRequest for Information\nSuggestions\nOther", + "permlevel": 0 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "hidden": 1, + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "unsubscribed", + "fieldtype": "Check", + "label": "Unsubscribed", + "permlevel": 0 + }, + { + "fieldname": "blog_subscriber", + "fieldtype": "Check", + "label": "Blog Subscriber", + "permlevel": 0 + }, + { + "fieldname": "communications", + "fieldtype": "Table", + "hidden": 1, + "label": "Communications", + "options": "Communication", + "permlevel": 0, + "print_hide": 1 + } + ], + "icon": "icon-user", + "idx": 1, + "modified": "2014-01-20 17:48:54.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Lead", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 1 + } + ], + "search_fields": "lead_name,lead_owner,status" +} \ No newline at end of file diff --git a/erpnext/selling/doctype/lead/lead.py b/erpnext/selling/doctype/lead/lead.py index 614a9c2d65e..8163be3111f 100644 --- a/erpnext/selling/doctype/lead/lead.py +++ b/erpnext/selling/doctype/lead/lead.py @@ -10,31 +10,27 @@ from frappe import session from erpnext.controllers.selling_controller import SellingController -class DocType(SellingController): - def __init__(self, doc, doclist): - self.doc = doc - self.doclist = doclist - - self._prev = frappe._dict({ - "contact_date": frappe.db.get_value("Lead", self.doc.name, "contact_date") if \ - (not cint(self.doc.fields.get("__islocal"))) else None, - "contact_by": frappe.db.get_value("Lead", self.doc.name, "contact_by") if \ - (not cint(self.doc.fields.get("__islocal"))) else None, - }) - +class Lead(SellingController): def onload(self): - customer = frappe.db.get_value("Customer", {"lead_name": self.doc.name}) + customer = frappe.db.get_value("Customer", {"lead_name": self.name}) if customer: - self.doc.fields["__is_customer"] = customer + self.set("__is_customer", customer) def validate(self): + self._prev = frappe._dict({ + "contact_date": frappe.db.get_value("Lead", self.name, "contact_date") if \ + (not cint(self.get("__islocal"))) else None, + "contact_by": frappe.db.get_value("Lead", self.name, "contact_by") if \ + (not cint(self.get("__islocal"))) else None, + }) + self.set_status() - if self.doc.source == 'Campaign' and not self.doc.campaign_name and session['user'] != 'Guest': + if self.source == 'Campaign' and not self.campaign_name and session['user'] != 'Guest': frappe.throw("Please specify campaign name") - if self.doc.email_id: - if not validate_email_add(self.doc.email_id): + if self.email_id: + if not validate_email_add(self.email_id): frappe.throw('Please enter valid email id.') def on_update(self): @@ -42,55 +38,54 @@ class DocType(SellingController): self.add_calendar_event() def add_calendar_event(self, opts=None, force=False): - super(DocType, self).add_calendar_event({ - "owner": self.doc.lead_owner, - "subject": ('Contact ' + cstr(self.doc.lead_name)), - "description": ('Contact ' + cstr(self.doc.lead_name)) + \ - (self.doc.contact_by and ('. By : ' + cstr(self.doc.contact_by)) or '') + \ - (self.doc.remark and ('.To Discuss : ' + cstr(self.doc.remark)) or '') + super(Lead, self).add_calendar_event({ + "owner": self.lead_owner, + "subject": ('Contact ' + cstr(self.lead_name)), + "description": ('Contact ' + cstr(self.lead_name)) + \ + (self.contact_by and ('. By : ' + cstr(self.contact_by)) or '') }, force) def check_email_id_is_unique(self): - if self.doc.email_id: + if self.email_id: # validate email is unique email_list = frappe.db.sql("""select name from tabLead where email_id=%s""", - self.doc.email_id) + self.email_id) if len(email_list) > 1: - items = [e[0] for e in email_list if e[0]!=self.doc.name] + items = [e[0] for e in email_list if e[0]!=self.name] frappe.msgprint(_("""Email Id must be unique, already exists for: """) + \ ", ".join(items), raise_exception=True) def on_trash(self): frappe.db.sql("""update `tabSupport Ticket` set lead='' where lead=%s""", - self.doc.name) + self.name) self.delete_events() def has_customer(self): - return frappe.db.get_value("Customer", {"lead_name": self.doc.name}) + return frappe.db.get_value("Customer", {"lead_name": self.name}) def has_opportunity(self): - return frappe.db.get_value("Opportunity", {"lead": self.doc.name, "docstatus": 1, + return frappe.db.get_value("Opportunity", {"lead": self.name, "docstatus": 1, "status": ["!=", "Lost"]}) @frappe.whitelist() -def make_customer(source_name, target_doclist=None): - return _make_customer(source_name, target_doclist) +def make_customer(source_name, target_doc=None): + return _make_customer(source_name, target_doc) -def _make_customer(source_name, target_doclist=None, ignore_permissions=False): - from frappe.model.mapper import get_mapped_doclist +def _make_customer(source_name, target_doc=None, ignore_permissions=False): + from frappe.model.mapper import get_mapped_doc def set_missing_values(source, target): - if source.doc.company_name: - target[0].customer_type = "Company" - target[0].customer_name = source.doc.company_name + if source.company_name: + target.customer_type = "Company" + target.customer_name = source.company_name else: - target[0].customer_type = "Individual" - target[0].customer_name = source.doc.lead_name + target.customer_type = "Individual" + target.customer_name = source.lead_name - target[0].customer_group = frappe.db.get_default("customer_group") + target.customer_group = frappe.db.get_default("customer_group") - doclist = get_mapped_doclist("Lead", source_name, + doclist = get_mapped_doc("Lead", source_name, {"Lead": { "doctype": "Customer", "field_map": { @@ -99,15 +94,15 @@ def _make_customer(source_name, target_doclist=None, ignore_permissions=False): "contact_no": "phone_1", "fax": "fax_1" } - }}, target_doclist, set_missing_values, ignore_permissions=ignore_permissions) + }}, target_doc, set_missing_values, ignore_permissions=ignore_permissions) - return [d.fields for d in doclist] + return doclist @frappe.whitelist() -def make_opportunity(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist +def make_opportunity(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc - doclist = get_mapped_doclist("Lead", source_name, + doclist = get_mapped_doc("Lead", source_name, {"Lead": { "doctype": "Opportunity", "field_map": { @@ -119,9 +114,9 @@ def make_opportunity(source_name, target_doclist=None): "email_id": "contact_email", "mobile_no": "contact_mobile" } - }}, target_doclist) + }}, target_doc) - return [d if isinstance(d, dict) else d.fields for d in doclist] + return doclist @frappe.whitelist() def get_lead_details(lead): @@ -130,8 +125,8 @@ def get_lead_details(lead): from erpnext.accounts.party import set_address_details out = frappe._dict() - lead_bean = frappe.bean("Lead", lead) - lead = lead_bean.doc + lead_doc = frappe.get_doc("Lead", lead) + lead = lead_doc out.update({ "territory": lead.territory, diff --git a/erpnext/selling/doctype/lead/lead.txt b/erpnext/selling/doctype/lead/lead.txt deleted file mode 100644 index ba04cb97fdf..00000000000 --- a/erpnext/selling/doctype/lead/lead.txt +++ /dev/null @@ -1,411 +0,0 @@ -[ - { - "creation": "2013-04-10 11:45:37", - "docstatus": 0, - "modified": "2014-01-20 17:48:54", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-user", - "module": "Selling", - "name": "__common__", - "search_fields": "lead_name,lead_owner,status" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Lead", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Lead", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Lead" - }, - { - "doctype": "DocField", - "fieldname": "lead_details", - "fieldtype": "Section Break", - "label": "Lead Details", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "LEAD\nLEAD/10-11/\nLEAD/MUMBAI/", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "lead_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Contact Name", - "oldfieldname": "lead_name", - "oldfieldtype": "Data", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "company_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Organization Name", - "oldfieldname": "company_name", - "oldfieldtype": "Data", - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "email_id", - "fieldtype": "Data", - "label": "Email Id", - "oldfieldname": "email_id", - "oldfieldtype": "Data", - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb6", - "fieldtype": "Column Break" - }, - { - "default": "Lead", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "Lead\nOpen\nReplied\nOpportunity\nInterested\nConverted\nDo Not Contact", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "source", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Source", - "no_copy": 1, - "oldfieldname": "source", - "oldfieldtype": "Select", - "options": "\nAdvertisement\nBlog Post\nCampaign\nCall\nCustomer\nExhibition\nSupplier\nWebsite\nEmail", - "reqd": 0, - "search_index": 0 - }, - { - "depends_on": "eval:doc.source == 'Customer'", - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "hidden": 0, - "label": "From Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer" - }, - { - "depends_on": "eval:doc.source == 'Campaign'", - "description": "Enter campaign name if the source of lead is campaign.", - "doctype": "DocField", - "fieldname": "campaign_name", - "fieldtype": "Link", - "hidden": 0, - "label": "Campaign Name", - "oldfieldname": "campaign_name", - "oldfieldtype": "Link", - "options": "Campaign" - }, - { - "doctype": "DocField", - "fieldname": "communication_history", - "fieldtype": "Section Break", - "label": "Communication", - "options": "icon-comments", - "print_hide": 1 - }, - { - "default": "__user", - "doctype": "DocField", - "fieldname": "lead_owner", - "fieldtype": "Link", - "in_filter": 1, - "label": "Lead Owner", - "oldfieldname": "lead_owner", - "oldfieldtype": "Link", - "options": "User", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break123", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "contact_by", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Next Contact By", - "oldfieldname": "contact_by", - "oldfieldtype": "Link", - "options": "User", - "print_hide": 0, - "reqd": 0, - "width": "100px" - }, - { - "allow_on_submit": 0, - "description": "Add to calendar on this date", - "doctype": "DocField", - "fieldname": "contact_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Next Contact Date", - "no_copy": 1, - "oldfieldname": "contact_date", - "oldfieldtype": "Date", - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "sec_break123", - "fieldtype": "Section Break", - "options": "Simple" - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "communication_html", - "fieldtype": "HTML", - "label": "Communication HTML", - "oldfieldname": "follow_up", - "oldfieldtype": "Table" - }, - { - "doctype": "DocField", - "fieldname": "contact_info", - "fieldtype": "Section Break", - "label": "Address & Contact", - "oldfieldtype": "Column Break", - "options": "icon-map-marker" - }, - { - "depends_on": "eval:doc.__islocal", - "doctype": "DocField", - "fieldname": "address_desc", - "fieldtype": "HTML", - "hidden": 0, - "label": "Address Desc", - "options": "Addresses will appear only when you save the lead", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_html", - "fieldtype": "HTML", - "hidden": 0, - "label": "Address HTML", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "phone", - "fieldtype": "Data", - "label": "Phone", - "oldfieldname": "contact_no", - "oldfieldtype": "Data", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "mobile_no", - "fieldtype": "Data", - "label": "Mobile No.", - "oldfieldname": "mobile_no", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "fax", - "fieldtype": "Data", - "label": "Fax", - "oldfieldname": "fax", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "website", - "fieldtype": "Data", - "label": "Website", - "oldfieldname": "website", - "oldfieldtype": "Data" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "label": "Territory", - "oldfieldname": "territory", - "oldfieldtype": "Link", - "options": "Territory", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text" - }, - { - "doctype": "DocField", - "fieldname": "type", - "fieldtype": "Select", - "in_filter": 1, - "label": "Lead Type", - "oldfieldname": "type", - "oldfieldtype": "Select", - "options": "\nClient\nChannel Partner\nConsultant" - }, - { - "doctype": "DocField", - "fieldname": "market_segment", - "fieldtype": "Select", - "hidden": 0, - "in_filter": 1, - "label": "Market Segment", - "oldfieldname": "market_segment", - "oldfieldtype": "Select", - "options": "\nLower Income\nMiddle Income\nUpper Income", - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "industry", - "fieldtype": "Link", - "label": "Industry", - "oldfieldname": "industry", - "oldfieldtype": "Link", - "options": "Industry Type" - }, - { - "doctype": "DocField", - "fieldname": "request_type", - "fieldtype": "Select", - "label": "Request Type", - "oldfieldname": "request_type", - "oldfieldtype": "Select", - "options": "\nProduct Enquiry\nRequest for Information\nSuggestions\nOther" - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "hidden": 1, - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year" - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "unsubscribed", - "fieldtype": "Check", - "label": "Unsubscribed" - }, - { - "doctype": "DocField", - "fieldname": "blog_subscriber", - "fieldtype": "Check", - "label": "Blog Subscriber" - }, - { - "doctype": "DocField", - "fieldname": "communications", - "fieldtype": "Table", - "hidden": 1, - "label": "Communications", - "options": "Communication", - "print_hide": 1 - }, - { - "delete": 1, - "doctype": "DocPerm", - "role": "Sales Manager" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User" - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/lead/test_lead.py b/erpnext/selling/doctype/lead/test_lead.py index 1e64851e024..606e328a627 100644 --- a/erpnext/selling/doctype/lead/test_lead.py +++ b/erpnext/selling/doctype/lead/test_lead.py @@ -3,30 +3,19 @@ from __future__ import unicode_literals -test_records = [ - [{"doctype":"Lead", "lead_name": "_Test Lead", "status":"Open", - "email_id":"test_lead@example.com", "territory": "_Test Territory"}], - [{"doctype":"Lead", "lead_name": "_Test Lead 1", "status":"Open", - "email_id":"test_lead1@example.com"}], - [{"doctype":"Lead", "lead_name": "_Test Lead 2", "status":"Contacted", - "email_id":"test_lead2@example.com"}], - [{"doctype":"Lead", "lead_name": "_Test Lead 3", "status":"Converted", - "email_id":"test_lead3@example.com"}], -] - import frappe import unittest +test_records = frappe.get_test_records('Lead') + class TestLead(unittest.TestCase): def test_make_customer(self): - print "test_make_customer" from erpnext.selling.doctype.lead.lead import make_customer customer = make_customer("_T-Lead-00001") - self.assertEquals(customer[0]["doctype"], "Customer") - self.assertEquals(customer[0]["lead_name"], "_T-Lead-00001") - - customer[0]["company"] = "_Test Company" - customer[0]["customer_group"] = "_Test Customer Group" - frappe.bean(customer).insert() - \ No newline at end of file + self.assertEquals(customer.doctype, "Customer") + self.assertEquals(customer.lead_name, "_T-Lead-00001") + + customer.company = "_Test Company" + customer.customer_group = "_Test Customer Group" + customer.insert() diff --git a/erpnext/selling/doctype/lead/test_records.json b/erpnext/selling/doctype/lead/test_records.json new file mode 100644 index 00000000000..89eeab7a9c2 --- /dev/null +++ b/erpnext/selling/doctype/lead/test_records.json @@ -0,0 +1,27 @@ +[ + { + "doctype": "Lead", + "email_id": "test_lead@example.com", + "lead_name": "_Test Lead", + "status": "Open", + "territory": "_Test Territory" + }, + { + "doctype": "Lead", + "email_id": "test_lead1@example.com", + "lead_name": "_Test Lead 1", + "status": "Open" + }, + { + "doctype": "Lead", + "email_id": "test_lead2@example.com", + "lead_name": "_Test Lead 2", + "status": "Contacted" + }, + { + "doctype": "Lead", + "email_id": "test_lead3@example.com", + "lead_name": "_Test Lead 3", + "status": "Converted" + } +] \ No newline at end of file diff --git a/erpnext/selling/doctype/opportunity/opportunity.js b/erpnext/selling/doctype/opportunity/opportunity.js index 06cf4b117e5..1dc4c1ecac2 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.js +++ b/erpnext/selling/doctype/opportunity/opportunity.js @@ -30,7 +30,7 @@ erpnext.selling.Opportunity = frappe.ui.form.Controller.extend({ if(!this.frm.doc.__islocal) { cur_frm.communication_view = new frappe.views.CommunicationList({ - list: frappe.model.get("Communication", {"opportunity": this.frm.doc.name}), + list: frappe.get_list("Communication", {"opportunity": this.frm.doc.name}), parent: cur_frm.fields_dict.communication_html.wrapper, doc: this.frm.doc, recipients: this.frm.doc.contact_email diff --git a/erpnext/selling/doctype/opportunity/opportunity.json b/erpnext/selling/doctype/opportunity/opportunity.json new file mode 100644 index 00000000000..51129c5d46c --- /dev/null +++ b/erpnext/selling/doctype/opportunity/opportunity.json @@ -0,0 +1,448 @@ +{ + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-03-07 18:50:30.000000", + "description": "Potential Sales Deal", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "fieldname": "from_section", + "fieldtype": "Section Break", + "label": "From", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "OPPT", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "enquiry_from", + "fieldtype": "Select", + "label": "Opportunity From", + "oldfieldname": "enquiry_from", + "oldfieldtype": "Select", + "options": "\nLead\nCustomer", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 1 + }, + { + "depends_on": "eval:doc.enquiry_from===\"Customer\"", + "fieldname": "customer", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "in_list_view": 1, + "label": "Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0, + "search_index": 0 + }, + { + "depends_on": "eval:doc.enquiry_from===\"Lead\"", + "fieldname": "lead", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "in_list_view": 1, + "label": "Lead", + "oldfieldname": "lead", + "oldfieldtype": "Link", + "options": "Lead", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "default": "Draft", + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "Draft\nSubmitted\nQuotation\nLost\nCancelled\nReplied\nOpen", + "permlevel": 0, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "enquiry_type", + "fieldtype": "Select", + "label": "Opportunity Type", + "oldfieldname": "enquiry_type", + "oldfieldtype": "Select", + "options": "\nSales\nMaintenance", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "items", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Items which do not exist in Item master can also be entered on customer's request", + "fieldname": "enquiry_details", + "fieldtype": "Table", + "label": "Opportunity Items", + "oldfieldname": "enquiry_details", + "oldfieldtype": "Table", + "options": "Opportunity Item", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Keep a track of communication related to this enquiry which will help for future reference.", + "fieldname": "communication_history", + "fieldtype": "Section Break", + "label": "Communication History", + "oldfieldtype": "Section Break", + "options": "icon-comments", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "communication_html", + "fieldtype": "HTML", + "label": "Communication HTML", + "oldfieldname": "follow_up", + "oldfieldtype": "Table", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.lead || doc.customer", + "fieldname": "contact_info", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.customer || doc.lead", + "fieldname": "customer_address", + "fieldtype": "Link", + "in_filter": 1, + "label": "Customer / Lead Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "oldfieldname": "address", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "customer", + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "in_filter": 1, + "label": "Territory", + "options": "Territory", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0, + "search_index": 1 + }, + { + "depends_on": "customer", + "description": "Add / Edit", + "fieldname": "customer_group", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Customer Group", + "oldfieldname": "customer_group", + "oldfieldtype": "Link", + "options": "Customer Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "customer", + "fieldname": "customer_name", + "fieldtype": "Data", + "label": "Customer Name", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "depends_on": "eval:doc.lead || doc.customer", + "fieldname": "contact_person", + "fieldtype": "Link", + "in_filter": 1, + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "customer", + "fieldname": "contact_display", + "fieldtype": "Small Text", + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "eval:doc.lead || doc.customer", + "fieldname": "contact_email", + "fieldtype": "Text", + "label": "Contact Email", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "eval:doc.lead || doc.customer", + "fieldname": "contact_mobile", + "fieldtype": "Text", + "label": "Contact Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "default": "Today", + "fieldname": "transaction_date", + "fieldtype": "Date", + "label": "Opportunity Date", + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "width": "50px" + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "source", + "fieldtype": "Select", + "label": "Source", + "oldfieldname": "source", + "oldfieldtype": "Select", + "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign\nWalk In", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Enter name of campaign if source of enquiry is campaign", + "fieldname": "campaign", + "fieldtype": "Link", + "label": "Campaign", + "oldfieldname": "campaign", + "oldfieldtype": "Link", + "options": "Campaign", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "order_lost_reason", + "fieldtype": "Text", + "label": "Lost Reason", + "no_copy": 1, + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "description": "Your sales person who will contact the customer in future", + "fieldname": "contact_by", + "fieldtype": "Link", + "in_filter": 1, + "label": "Next Contact By", + "oldfieldname": "contact_by", + "oldfieldtype": "Link", + "options": "User", + "permlevel": 0, + "read_only": 0, + "width": "75px" + }, + { + "description": "Your sales person will get a reminder on this date to contact the customer", + "fieldname": "contact_date", + "fieldtype": "Date", + "label": "Next Contact Date", + "oldfieldname": "contact_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "to_discuss", + "fieldtype": "Small Text", + "label": "To Discuss", + "no_copy": 1, + "oldfieldname": "to_discuss", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "communications", + "fieldtype": "Table", + "hidden": 1, + "label": "Communications", + "options": "Communication", + "permlevel": 0, + "print_hide": 1 + } + ], + "icon": "icon-info-sign", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:48:59.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Opportunity", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "submit": 1, + "write": 1 + } + ], + "search_fields": "status,transaction_date,customer,lead,enquiry_type,territory,company" +} \ No newline at end of file diff --git a/erpnext/selling/doctype/opportunity/opportunity.py b/erpnext/selling/doctype/opportunity/opportunity.py index d2f7a2eb75f..c87c9836fe6 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.py +++ b/erpnext/selling/doctype/opportunity/opportunity.py @@ -5,25 +5,15 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, cint -from frappe.model.bean import getlist + from frappe import msgprint, _ from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self,doc,doclist): - self.doc = doc - self.doclist = doclist - self.fname = 'enq_details' - self.tname = 'Opportunity Item' - - self._prev = frappe._dict({ - "contact_date": frappe.db.get_value("Opportunity", self.doc.name, "contact_date") if \ - (not cint(self.doc.fields.get("__islocal"))) else None, - "contact_by": frappe.db.get_value("Opportunity", self.doc.name, "contact_by") if \ - (not cint(self.doc.fields.get("__islocal"))) else None, - }) +class Opportunity(TransactionBase): + fname = 'enq_details' + tname = 'Opportunity Item' def get_item_details(self, item_code): item = frappe.db.sql("""select item_name, stock_uom, description_html, description, item_group, brand @@ -71,48 +61,55 @@ class DocType(TransactionBase): opts.description = "" - if self.doc.customer: - if self.doc.contact_person: - opts.description = 'Contact '+cstr(self.doc.contact_person) + if self.customer: + if self.contact_person: + opts.description = 'Contact '+cstr(self.contact_person) else: - opts.description = 'Contact customer '+cstr(self.doc.customer) - elif self.doc.lead: - if self.doc.contact_display: - opts.description = 'Contact '+cstr(self.doc.contact_display) + opts.description = 'Contact customer '+cstr(self.customer) + elif self.lead: + if self.contact_display: + opts.description = 'Contact '+cstr(self.contact_display) else: - opts.description = 'Contact lead '+cstr(self.doc.lead) + opts.description = 'Contact lead '+cstr(self.lead) opts.subject = opts.description - opts.description += '. By : ' + cstr(self.doc.contact_by) + opts.description += '. By : ' + cstr(self.contact_by) - if self.doc.to_discuss: - opts.description += ' To Discuss : ' + cstr(self.doc.to_discuss) + if self.to_discuss: + opts.description += ' To Discuss : ' + cstr(self.to_discuss) - super(DocType, self).add_calendar_event(opts, force) + super(Opportunity, self).add_calendar_event(opts, force) def validate_item_details(self): - if not getlist(self.doclist, 'enquiry_details'): + if not self.get('enquiry_details'): msgprint("Please select items for which enquiry needs to be made") raise Exception def validate_lead_cust(self): - if self.doc.enquiry_from == 'Lead' and not self.doc.lead: + if self.enquiry_from == 'Lead' and not self.lead: msgprint("Lead Id is mandatory if 'Opportunity From' is selected as Lead", raise_exception=1) - elif self.doc.enquiry_from == 'Customer' and not self.doc.customer: + elif self.enquiry_from == 'Customer' and not self.customer: msgprint("Customer is mandatory if 'Opportunity From' is selected as Customer", raise_exception=1) def validate(self): + self._prev = frappe._dict({ + "contact_date": frappe.db.get_value("Opportunity", self.name, "contact_date") if \ + (not cint(self.get("__islocal"))) else None, + "contact_by": frappe.db.get_value("Opportunity", self.name, "contact_by") if \ + (not cint(self.get("__islocal"))) else None, + }) + self.set_status() self.validate_item_details() self.validate_uom_is_integer("uom", "qty") self.validate_lead_cust() from erpnext.accounts.utils import validate_fiscal_year - validate_fiscal_year(self.doc.transaction_date, self.doc.fiscal_year, "Opportunity Date") + validate_fiscal_year(self.transaction_date, self.fiscal_year, "Opportunity Date") def on_submit(self): - if self.doc.lead: - frappe.bean("Lead", self.doc.lead).get_controller().set_status(update=True) + if self.lead: + frappe.get_doc("Lead", self.lead).set_status(update=True) def on_cancel(self): if self.has_quotation(): @@ -121,8 +118,8 @@ class DocType(TransactionBase): def declare_enquiry_lost(self,arg): if not self.has_quotation(): - frappe.db.set(self.doc, 'status', 'Lost') - frappe.db.set(self.doc, 'order_lost_reason', arg) + frappe.db.set(self, 'status', 'Lost') + frappe.db.set(self, 'order_lost_reason', arg) else: frappe.throw(_("Cannot declare as lost, because Quotation has been made.")) @@ -130,18 +127,18 @@ class DocType(TransactionBase): self.delete_events() def has_quotation(self): - return frappe.db.get_value("Quotation Item", {"prevdoc_docname": self.doc.name, "docstatus": 1}) + return frappe.db.get_value("Quotation Item", {"prevdoc_docname": self.name, "docstatus": 1}) @frappe.whitelist() -def make_quotation(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist +def make_quotation(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc def set_missing_values(source, target): - quotation = frappe.bean(target) + quotation = frappe.get_doc(target) quotation.run_method("onload_post_render") quotation.run_method("calculate_taxes_and_totals") - doclist = get_mapped_doclist("Opportunity", source_name, { + doclist = get_mapped_doc("Opportunity", source_name, { "Opportunity": { "doctype": "Quotation", "field_map": { @@ -162,6 +159,6 @@ def make_quotation(source_name, target_doclist=None): }, "add_if_empty": True } - }, target_doclist, set_missing_values) + }, target_doc, set_missing_values) - return [d.fields for d in doclist] \ No newline at end of file + return doclist \ No newline at end of file diff --git a/erpnext/selling/doctype/opportunity/opportunity.txt b/erpnext/selling/doctype/opportunity/opportunity.txt deleted file mode 100644 index fd59a31e925..00000000000 --- a/erpnext/selling/doctype/opportunity/opportunity.txt +++ /dev/null @@ -1,457 +0,0 @@ -[ - { - "creation": "2013-03-07 18:50:30", - "docstatus": 0, - "modified": "2014-01-20 17:48:59", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "naming_series:", - "description": "Potential Sales Deal", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-info-sign", - "is_submittable": 1, - "module": "Selling", - "name": "__common__", - "search_fields": "status,transaction_date,customer,lead,enquiry_type,territory,company" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Opportunity", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Opportunity", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Opportunity" - }, - { - "doctype": "DocField", - "fieldname": "from_section", - "fieldtype": "Section Break", - "label": "From", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "OPPT", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "enquiry_from", - "fieldtype": "Select", - "label": "Opportunity From", - "oldfieldname": "enquiry_from", - "oldfieldtype": "Select", - "options": "\nLead\nCustomer", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 1 - }, - { - "depends_on": "eval:doc.enquiry_from===\"Customer\"", - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "in_list_view": 1, - "label": "Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "read_only": 0, - "reqd": 0, - "search_index": 0 - }, - { - "depends_on": "eval:doc.enquiry_from===\"Lead\"", - "doctype": "DocField", - "fieldname": "lead", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "in_list_view": 1, - "label": "Lead", - "oldfieldname": "lead", - "oldfieldtype": "Link", - "options": "Lead", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "default": "Draft", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "Draft\nSubmitted\nQuotation\nLost\nCancelled\nReplied\nOpen", - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "enquiry_type", - "fieldtype": "Select", - "label": "Opportunity Type", - "oldfieldname": "enquiry_type", - "oldfieldtype": "Select", - "options": "\nSales\nMaintenance", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "items", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart", - "read_only": 0 - }, - { - "description": "Items which do not exist in Item master can also be entered on customer's request", - "doctype": "DocField", - "fieldname": "enquiry_details", - "fieldtype": "Table", - "label": "Opportunity Items", - "oldfieldname": "enquiry_details", - "oldfieldtype": "Table", - "options": "Opportunity Item", - "read_only": 0 - }, - { - "description": "Keep a track of communication related to this enquiry which will help for future reference.", - "doctype": "DocField", - "fieldname": "communication_history", - "fieldtype": "Section Break", - "label": "Communication History", - "oldfieldtype": "Section Break", - "options": "icon-comments", - "read_only": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "communication_html", - "fieldtype": "HTML", - "label": "Communication HTML", - "oldfieldname": "follow_up", - "oldfieldtype": "Table", - "read_only": 0 - }, - { - "depends_on": "eval:doc.lead || doc.customer", - "doctype": "DocField", - "fieldname": "contact_info", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn", - "read_only": 0 - }, - { - "depends_on": "eval:doc.customer || doc.lead", - "doctype": "DocField", - "fieldname": "customer_address", - "fieldtype": "Link", - "in_filter": 1, - "label": "Customer / Lead Address", - "options": "Address", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "oldfieldname": "address", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "depends_on": "customer", - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "in_filter": 1, - "label": "Territory", - "options": "Territory", - "print_hide": 1, - "read_only": 0, - "reqd": 0, - "search_index": 1 - }, - { - "depends_on": "customer", - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Customer Group", - "oldfieldname": "customer_group", - "oldfieldtype": "Link", - "options": "Customer Group", - "print_hide": 1, - "read_only": 0, - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "label": "Customer Name", - "print_hide": 0, - "read_only": 1 - }, - { - "depends_on": "eval:doc.lead || doc.customer", - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "in_filter": 1, - "label": "Contact Person", - "options": "Contact", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "label": "Contact", - "read_only": 1 - }, - { - "depends_on": "eval:doc.lead || doc.customer", - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Text", - "label": "Contact Email", - "read_only": 1 - }, - { - "depends_on": "eval:doc.lead || doc.customer", - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Text", - "label": "Contact Mobile No", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "transaction_date", - "fieldtype": "Date", - "label": "Opportunity Date", - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "read_only": 0, - "reqd": 1, - "width": "50px" - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "source", - "fieldtype": "Select", - "label": "Source", - "oldfieldname": "source", - "oldfieldtype": "Select", - "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign\nWalk In", - "read_only": 0 - }, - { - "description": "Enter name of campaign if source of enquiry is campaign", - "doctype": "DocField", - "fieldname": "campaign", - "fieldtype": "Link", - "label": "Campaign", - "oldfieldname": "campaign", - "oldfieldtype": "Link", - "options": "Campaign", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "order_lost_reason", - "fieldtype": "Text", - "label": "Lost Reason", - "no_copy": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "description": "Your sales person who will contact the customer in future", - "doctype": "DocField", - "fieldname": "contact_by", - "fieldtype": "Link", - "in_filter": 1, - "label": "Next Contact By", - "oldfieldname": "contact_by", - "oldfieldtype": "Link", - "options": "User", - "read_only": 0, - "width": "75px" - }, - { - "description": "Your sales person will get a reminder on this date to contact the customer", - "doctype": "DocField", - "fieldname": "contact_date", - "fieldtype": "Date", - "label": "Next Contact Date", - "oldfieldname": "contact_date", - "oldfieldtype": "Date", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "to_discuss", - "fieldtype": "Small Text", - "label": "To Discuss", - "no_copy": 1, - "oldfieldname": "to_discuss", - "oldfieldtype": "Small Text", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "communications", - "fieldtype": "Table", - "hidden": 1, - "label": "Communications", - "options": "Communication", - "print_hide": 1 - }, - { - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "doctype": "DocPerm", - "role": "Sales Manager" - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/opportunity_item/opportunity_item.json b/erpnext/selling/doctype/opportunity_item/opportunity_item.json new file mode 100644 index 00000000000..55c33e5c5fe --- /dev/null +++ b/erpnext/selling/doctype/opportunity_item/opportunity_item.json @@ -0,0 +1,123 @@ +{ + "creation": "2013-02-22 01:27:51.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "hidden": 1, + "in_list_view": 0, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "search_index": 0 + }, + { + "fieldname": "brand", + "fieldtype": "Link", + "hidden": 1, + "in_list_view": 0, + "label": "Brand", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "print_hide": 1, + "search_index": 0 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "300px", + "reqd": 1, + "width": "300px" + }, + { + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Quantity and Rate", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Qty", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0 + }, + { + "fieldname": "basic_rate", + "fieldtype": "Currency", + "hidden": 1, + "in_list_view": 0, + "label": "Basic Rate", + "oldfieldname": "basic_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "oldfieldname": "uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0, + "search_index": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-03 12:40:44.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Opportunity Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/selling/doctype/opportunity_item/opportunity_item.py b/erpnext/selling/doctype/opportunity_item/opportunity_item.py index 26c87f1c04a..26b2999ebb7 100644 --- a/erpnext/selling/doctype/opportunity_item/opportunity_item.py +++ b/erpnext/selling/doctype/opportunity_item/opportunity_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class OpportunityItem(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/opportunity_item/opportunity_item.txt b/erpnext/selling/doctype/opportunity_item/opportunity_item.txt deleted file mode 100644 index 22023ed65c9..00000000000 --- a/erpnext/selling/doctype/opportunity_item/opportunity_item.txt +++ /dev/null @@ -1,136 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:51", - "docstatus": 0, - "modified": "2014-02-03 12:40:44", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Opportunity Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Opportunity Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 1, - "in_list_view": 0, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "print_hide": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Link", - "hidden": 1, - "in_list_view": 0, - "label": "Brand", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "print_hide": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "print_width": "300px", - "reqd": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Quantity and Rate" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Qty", - "oldfieldname": "qty", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "basic_rate", - "fieldtype": "Currency", - "hidden": 1, - "in_list_view": 0, - "label": "Basic Rate", - "oldfieldname": "basic_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "oldfieldname": "uom", - "oldfieldtype": "Link", - "options": "UOM", - "search_index": 0 - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 28a588a3845..ff0894a263f 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -55,7 +55,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ if (!doc.__islocal) { cur_frm.communication_view = new frappe.views.CommunicationList({ - list: frappe.model.get("Communication", {"parent": doc.name, "parenttype": "Quotation"}), + list: frappe.get_list("Communication", {"parent": doc.name, "parenttype": "Quotation"}), parent: cur_frm.fields_dict.communication_html.wrapper, doc: doc, recipients: doc.contact_email diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json new file mode 100644 index 00000000000..4b99d9e3e71 --- /dev/null +++ b/erpnext/selling/doctype/quotation/quotation.json @@ -0,0 +1,900 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-05-24 19:29:08.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "fieldname": "customer_section", + "fieldtype": "Section Break", + "label": "Customer", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "QTN", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "default": "Customer", + "fieldname": "quotation_to", + "fieldtype": "Select", + "in_filter": 1, + "label": "Quotation To", + "oldfieldname": "quotation_to", + "oldfieldtype": "Select", + "options": "\nLead\nCustomer", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 1 + }, + { + "depends_on": "eval:doc.quotation_to == \"Customer\"", + "fieldname": "customer", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "search_index": 1 + }, + { + "depends_on": "eval:doc.quotation_to == \"Lead\"", + "fieldname": "lead", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Lead", + "oldfieldname": "lead", + "oldfieldtype": "Link", + "options": "Lead", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "customer_name", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 1, + "label": "Customer Name", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "in_filter": 0, + "label": "Address", + "oldfieldname": "customer_address", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "in_filter": 0, + "label": "Contact", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "contact_mobile", + "fieldtype": "Text", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "contact_email", + "fieldtype": "Text", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "width": "150px" + }, + { + "description": "Select the relevant company name if you have multiple companies.", + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0, + "width": "150px" + }, + { + "default": "Today", + "fieldname": "transaction_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Quotation Date", + "no_copy": 1, + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 1, + "width": "100px" + }, + { + "default": "Sales", + "fieldname": "order_type", + "fieldtype": "Select", + "in_filter": 1, + "label": "Order Type", + "oldfieldname": "order_type", + "oldfieldtype": "Select", + "options": "\nSales\nMaintenance\nShopping Cart", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "section_break0", + "fieldtype": "Section Break", + "label": "Currency and Price List", + "options": "icon-tag", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "in_filter": 1, + "label": "Currency", + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0, + "width": "100px" + }, + { + "description": "Rate at which customer's currency is converted to company's base currency", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "label": "Exchange Rate", + "oldfieldname": "conversion_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "selling_price_list", + "fieldtype": "Link", + "in_filter": 1, + "label": "Price List", + "oldfieldname": "price_list_name", + "oldfieldtype": "Select", + "options": "Price List", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "price_list_currency", + "fieldtype": "Link", + "label": "Price List Currency", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "description": "Rate at which Price list currency is converted to company's base currency", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "label": "Price List Exchange Rate", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "items", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "search_index": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "quotation_details", + "fieldtype": "Table", + "label": "Quotation Items", + "oldfieldname": "quotation_details", + "oldfieldtype": "Table", + "options": "Quotation Item", + "permlevel": 0, + "read_only": 0, + "reqd": 0, + "width": "40px" + }, + { + "fieldname": "sec_break23", + "fieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "net_total_export", + "fieldtype": "Currency", + "label": "Net Total", + "options": "currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break_28", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total (Company Currency)", + "no_copy": 0, + "oldfieldname": "net_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "taxes", + "fieldtype": "Section Break", + "label": "Taxes and Charges", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "hidden": 0, + "label": "Taxes and Charges", + "oldfieldname": "charge", + "oldfieldtype": "Link", + "options": "Sales Taxes and Charges Master", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break_34", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "shipping_rule", + "fieldtype": "Link", + "hidden": 0, + "label": "Shipping Rule", + "oldfieldtype": "Button", + "options": "Shipping Rule", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break_36", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "other_charges", + "fieldtype": "Table", + "label": "Sales Taxes and Charges", + "oldfieldname": "other_charges", + "oldfieldtype": "Table", + "options": "Sales Taxes and Charges", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "other_charges_calculation", + "fieldtype": "HTML", + "label": "Taxes and Charges Calculation", + "oldfieldtype": "HTML", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break_39", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "other_charges_total_export", + "fieldtype": "Currency", + "label": "Taxes and Charges Total", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_42", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "other_charges_total", + "fieldtype": "Currency", + "label": "Taxes and Charges Total (Company Currency)", + "oldfieldname": "other_charges_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "Totals", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "grand_total_export", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Grand Total", + "no_copy": 0, + "oldfieldname": "grand_total_export", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "reqd": 0, + "width": "200px" + }, + { + "fieldname": "rounded_total_export", + "fieldtype": "Currency", + "label": "Rounded Total", + "no_copy": 0, + "oldfieldname": "rounded_total_export", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "reqd": 0, + "width": "200px" + }, + { + "fieldname": "in_words_export", + "fieldtype": "Data", + "label": "In Words", + "no_copy": 0, + "oldfieldname": "in_words_export", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "width": "200px" + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "no_copy": 0, + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0, + "width": "200px" + }, + { + "fieldname": "rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total (Company Currency)", + "no_copy": 0, + "oldfieldname": "rounded_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "width": "200px" + }, + { + "description": "In Words will be visible once you save the Quotation.", + "fieldname": "in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "no_copy": 0, + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "width": "200px" + }, + { + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "oldfieldtype": "Section Break", + "options": "icon-legal", + "permlevel": 0, + "print_hide": 0, + "read_only": 0 + }, + { + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Term Details", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "contact_section", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Territory", + "options": "Territory", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "depends_on": "customer", + "description": "Add / Edit", + "fieldname": "customer_group", + "fieldtype": "Link", + "in_filter": 1, + "label": "Customer Group", + "oldfieldname": "customer_group", + "oldfieldtype": "Link", + "options": "Customer Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "shipping_address_name", + "fieldtype": "Link", + "hidden": 0, + "label": "Shipping Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "shipping_address", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Shipping Address", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "depends_on": "customer", + "fieldname": "col_break98", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "customer_address", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Customer Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "eval:doc.customer", + "fieldname": "contact_person", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Contact Person", + "oldfieldname": "contact_person", + "oldfieldtype": "Link", + "options": "Contact", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "campaign", + "fieldtype": "Link", + "hidden": 0, + "label": "Campaign", + "no_copy": 0, + "oldfieldname": "campaign", + "oldfieldtype": "Link", + "options": "Campaign", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0 + }, + { + "fieldname": "source", + "fieldtype": "Select", + "hidden": 0, + "label": "Source", + "no_copy": 0, + "oldfieldname": "source", + "oldfieldtype": "Select", + "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0 + }, + { + "allow_on_submit": 0, + "default": "Draft", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "Draft\nSubmitted\nOrdered\nLost\nCancelled", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1, + "search_index": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "order_lost_reason", + "fieldtype": "Small Text", + "label": "Quotation Lost Reason", + "no_copy": 1, + "oldfieldname": "order_lost_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break4", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "50%" + }, + { + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Select", + "label": "Letter Head", + "oldfieldname": "letter_head", + "oldfieldtype": "Select", + "options": "link:Letter Head", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "enq_det", + "fieldtype": "Text", + "hidden": 1, + "label": "Opportunity Item", + "no_copy": 0, + "oldfieldname": "enq_det", + "oldfieldtype": "Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0 + }, + { + "fieldname": "communication_history", + "fieldtype": "Section Break", + "label": "Communication History", + "oldfieldtype": "Section Break", + "options": "icon-comments", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "depends_on": "eval:!doc.__islocal", + "fieldname": "communication_html", + "fieldtype": "HTML", + "label": "Communication HTML", + "oldfieldname": "follow_up", + "oldfieldtype": "Table", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "40px" + }, + { + "fieldname": "communications", + "fieldtype": "Table", + "hidden": 1, + "label": "Communications", + "options": "Communication", + "permlevel": 0, + "print_hide": 1 + } + ], + "hide_toolbar": 0, + "icon": "icon-shopping-cart", + "idx": 1, + "is_submittable": 1, + "max_attachments": 1, + "modified": "2014-01-31 19:43:00.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Quotation", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 1, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Customer", + "submit": 0, + "write": 0 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Maintenance Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Maintenance User", + "submit": 1, + "write": 1 + } + ], + "read_only_onload": 1, + "search_fields": "status,transaction_date,customer,lead,order_type" +} \ No newline at end of file diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 484c487548a..d6ade9e0cbc 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -4,25 +4,21 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr -from frappe.model.bean import getlist -from frappe.model.code import get_obj + from frappe import _, msgprint from erpnext.controllers.selling_controller import SellingController -class DocType(SellingController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.tname = 'Quotation Item' - self.fname = 'quotation_details' +class Quotation(SellingController): + tname = 'Quotation Item' + fname = 'quotation_details' def has_sales_order(self): - return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.doc.name, "docstatus": 1}) + return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.name, "docstatus": 1}) def validate_for_items(self): chk_dupl_itm = [] - for d in getlist(self.doclist,'quotation_details'): + for d in self.get('quotation_details'): if [cstr(d.item_code),cstr(d.description)] in chk_dupl_itm: msgprint("Item %s has been entered twice. Please change description atleast to continue" % d.item_code) raise Exception @@ -30,10 +26,10 @@ class DocType(SellingController): chk_dupl_itm.append([cstr(d.item_code),cstr(d.description)]) def validate_order_type(self): - super(DocType, self).validate_order_type() + super(Quotation, self).validate_order_type() - if self.doc.order_type in ['Maintenance', 'Service']: - for d in getlist(self.doclist, 'quotation_details'): + if self.order_type in ['Maintenance', 'Service']: + for d in self.get('quotation_details'): is_service_item = frappe.db.sql("select is_service_item from `tabItem` where name=%s", d.item_code) is_service_item = is_service_item and is_service_item[0][0] or 'No' @@ -41,7 +37,7 @@ class DocType(SellingController): msgprint("You can not select non service item "+d.item_code+" in Maintenance Quotation") raise Exception else: - for d in getlist(self.doclist, 'quotation_details'): + for d in self.get('quotation_details'): is_sales_item = frappe.db.sql("select is_sales_item from `tabItem` where name=%s", d.item_code) is_sales_item = is_sales_item and is_sales_item[0][0] or 'No' @@ -50,26 +46,27 @@ class DocType(SellingController): raise Exception def validate(self): - super(DocType, self).validate() + super(Quotation, self).validate() self.set_status() self.validate_order_type() self.validate_for_items() self.validate_uom_is_integer("stock_uom", "qty") def update_opportunity(self): - for opportunity in self.doclist.get_distinct_values("prevdoc_docname"): - frappe.bean("Opportunity", opportunity).get_controller().set_status(update=True) + for opportunity in list(set([d.prevdoc_docname for d in self.get("quotation_details")])): + if opportunity: + frappe.get_doc("Opportunity", opportunity).set_status(update=True) def declare_order_lost(self, arg): if not self.has_sales_order(): - frappe.db.set(self.doc, 'status', 'Lost') - frappe.db.set(self.doc, 'order_lost_reason', arg) + frappe.db.set(self, 'status', 'Lost') + frappe.db.set(self, 'order_lost_reason', arg) self.update_opportunity() else: frappe.throw(_("Cannot set as Lost as Sales Order is made.")) def check_item_table(self): - if not getlist(self.doclist, 'quotation_details'): + if not self.get('quotation_details'): msgprint("Please enter item details") raise Exception @@ -77,7 +74,7 @@ class DocType(SellingController): self.check_item_table() # Check for Approving Authority - get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total, self) + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total, self) #update enquiry status self.update_opportunity() @@ -89,7 +86,7 @@ class DocType(SellingController): def print_other_charges(self,docname): print_lst = [] - for d in getlist(self.doclist,'other_charges'): + for d in self.get('other_charges'): lst1 = [] lst1.append(d.description) lst1.append(d.total) @@ -98,24 +95,24 @@ class DocType(SellingController): @frappe.whitelist() -def make_sales_order(source_name, target_doclist=None): - return _make_sales_order(source_name, target_doclist) +def make_sales_order(source_name, target_doc=None): + return _make_sales_order(source_name, target_doc) -def _make_sales_order(source_name, target_doclist=None, ignore_permissions=False): - from frappe.model.mapper import get_mapped_doclist +def _make_sales_order(source_name, target_doc=None, ignore_permissions=False): + from frappe.model.mapper import get_mapped_doc customer = _make_customer(source_name, ignore_permissions) def set_missing_values(source, target): if customer: - target[0].customer = customer.doc.name - target[0].customer_name = customer.doc.customer_name + target.customer = customer.name + target.customer_name = customer.customer_name - si = frappe.bean(target) + si = frappe.get_doc(target) si.ignore_permissions = ignore_permissions si.run_method("onload_post_render") - doclist = get_mapped_doclist("Quotation", source_name, { + doclist = get_mapped_doc("Quotation", source_name, { "Quotation": { "doctype": "Sales Order", "validation": { @@ -136,11 +133,11 @@ def _make_sales_order(source_name, target_doclist=None, ignore_permissions=False "doctype": "Sales Team", "add_if_empty": True } - }, target_doclist, set_missing_values, ignore_permissions=ignore_permissions) + }, target_doc, set_missing_values, ignore_permissions=ignore_permissions) # postprocess: fetch shipping address, set missing values - return [d.fields for d in doclist] + return doclist def _make_customer(source_name, ignore_permissions=False): quotation = frappe.db.get_value("Quotation", source_name, ["lead", "order_type"]) @@ -150,10 +147,10 @@ def _make_customer(source_name, ignore_permissions=False): if not customer_name: from erpnext.selling.doctype.lead.lead import _make_customer customer_doclist = _make_customer(lead_name, ignore_permissions=ignore_permissions) - customer = frappe.bean(customer_doclist) + customer = frappe.get_doc(customer_doclist) customer.ignore_permissions = ignore_permissions if quotation[1] == "Shopping Cart": - customer.doc.customer_group = frappe.db.get_value("Shopping Cart Settings", None, + customer.customer_group = frappe.db.get_value("Shopping Cart Settings", None, "default_customer_group") try: @@ -162,7 +159,7 @@ def _make_customer(source_name, ignore_permissions=False): except NameError: if frappe.defaults.get_global_default('cust_master_name') == "Customer Name": customer.run_method("autoname") - customer.doc.name += "-" + lead_name + customer.name += "-" + lead_name customer.insert() return customer else: diff --git a/erpnext/selling/doctype/quotation/quotation.txt b/erpnext/selling/doctype/quotation/quotation.txt deleted file mode 100644 index 0508e5dbb47..00000000000 --- a/erpnext/selling/doctype/quotation/quotation.txt +++ /dev/null @@ -1,903 +0,0 @@ -[ - { - "creation": "2013-05-24 19:29:08", - "docstatus": 0, - "modified": "2014-01-31 19:43:00", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "document_type": "Transaction", - "hide_toolbar": 0, - "icon": "icon-shopping-cart", - "is_submittable": 1, - "max_attachments": 1, - "module": "Selling", - "name": "__common__", - "read_only_onload": 1, - "search_fields": "status,transaction_date,customer,lead,order_type" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Quotation", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Quotation", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Quotation" - }, - { - "doctype": "DocField", - "fieldname": "customer_section", - "fieldtype": "Section Break", - "label": "Customer", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "QTN", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "default": "Customer", - "doctype": "DocField", - "fieldname": "quotation_to", - "fieldtype": "Select", - "in_filter": 1, - "label": "Quotation To", - "oldfieldname": "quotation_to", - "oldfieldtype": "Select", - "options": "\nLead\nCustomer", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 1 - }, - { - "depends_on": "eval:doc.quotation_to == \"Customer\"", - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "read_only": 0, - "search_index": 1 - }, - { - "depends_on": "eval:doc.quotation_to == \"Lead\"", - "doctype": "DocField", - "fieldname": "lead", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Lead", - "oldfieldname": "lead", - "oldfieldtype": "Link", - "options": "Lead", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 1, - "label": "Customer Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "in_filter": 0, - "label": "Address", - "oldfieldname": "customer_address", - "oldfieldtype": "Small Text", - "print_hide": 0, - "read_only": 1, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "in_filter": 0, - "label": "Contact", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Text", - "hidden": 1, - "label": "Mobile No", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Text", - "hidden": 1, - "label": "Contact Email", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "width": "150px" - }, - { - "description": "Select the relevant company name if you have multiple companies.", - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0, - "width": "150px" - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "transaction_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Quotation Date", - "no_copy": 1, - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "read_only": 0, - "reqd": 1, - "search_index": 1, - "width": "100px" - }, - { - "default": "Sales", - "doctype": "DocField", - "fieldname": "order_type", - "fieldtype": "Select", - "in_filter": 1, - "label": "Order Type", - "oldfieldname": "order_type", - "oldfieldtype": "Select", - "options": "\nSales\nMaintenance\nShopping Cart", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "label": "Currency and Price List", - "options": "icon-tag", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "currency", - "fieldtype": "Link", - "in_filter": 1, - "label": "Currency", - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0, - "width": "100px" - }, - { - "description": "Rate at which customer's currency is converted to company's base currency", - "doctype": "DocField", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "label": "Exchange Rate", - "oldfieldname": "conversion_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "selling_price_list", - "fieldtype": "Link", - "in_filter": 1, - "label": "Price List", - "oldfieldname": "price_list_name", - "oldfieldtype": "Select", - "options": "Price List", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "price_list_currency", - "fieldtype": "Link", - "label": "Price List Currency", - "options": "Currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "description": "Rate at which Price list currency is converted to company's base currency", - "doctype": "DocField", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "label": "Price List Exchange Rate", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "items", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart", - "print_hide": 0, - "read_only": 0, - "search_index": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "quotation_details", - "fieldtype": "Table", - "label": "Quotation Items", - "oldfieldname": "quotation_details", - "oldfieldtype": "Table", - "options": "Quotation Item", - "read_only": 0, - "reqd": 0, - "width": "40px" - }, - { - "doctype": "DocField", - "fieldname": "sec_break23", - "fieldtype": "Section Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "net_total_export", - "fieldtype": "Currency", - "label": "Net Total", - "options": "currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_28", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total (Company Currency)", - "no_copy": 0, - "oldfieldname": "net_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "taxes", - "fieldtype": "Section Break", - "label": "Taxes and Charges", - "oldfieldtype": "Section Break", - "options": "icon-money", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "hidden": 0, - "label": "Taxes and Charges", - "oldfieldname": "charge", - "oldfieldtype": "Link", - "options": "Sales Taxes and Charges Master", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_34", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "shipping_rule", - "fieldtype": "Link", - "hidden": 0, - "label": "Shipping Rule", - "oldfieldtype": "Button", - "options": "Shipping Rule", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_36", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "other_charges", - "fieldtype": "Table", - "label": "Sales Taxes and Charges", - "oldfieldname": "other_charges", - "oldfieldtype": "Table", - "options": "Sales Taxes and Charges", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_calculation", - "fieldtype": "HTML", - "label": "Taxes and Charges Calculation", - "oldfieldtype": "HTML", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_39", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_total_export", - "fieldtype": "Currency", - "label": "Taxes and Charges Total", - "options": "currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_42", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_total", - "fieldtype": "Currency", - "label": "Taxes and Charges Total (Company Currency)", - "oldfieldname": "other_charges_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "discount_amount", - "fieldtype": "Currency", - "label": "Discount Amount", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "Totals", - "oldfieldtype": "Section Break", - "options": "icon-money", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "grand_total_export", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Grand Total", - "no_copy": 0, - "oldfieldname": "grand_total_export", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1, - "reqd": 0, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "rounded_total_export", - "fieldtype": "Currency", - "label": "Rounded Total", - "no_copy": 0, - "oldfieldname": "rounded_total_export", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1, - "reqd": 0, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "in_words_export", - "fieldtype": "Data", - "label": "In Words", - "no_copy": 0, - "oldfieldname": "in_words_export", - "oldfieldtype": "Data", - "print_hide": 0, - "read_only": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "no_copy": 0, - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 0, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total (Company Currency)", - "no_copy": 0, - "oldfieldname": "rounded_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "width": "200px" - }, - { - "description": "In Words will be visible once you save the Quotation.", - "doctype": "DocField", - "fieldname": "in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "no_copy": 0, - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "oldfieldtype": "Section Break", - "options": "icon-legal", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Term Details", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "contact_section", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn", - "read_only": 0 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Territory", - "options": "Territory", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "depends_on": "customer", - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "in_filter": 1, - "label": "Customer Group", - "oldfieldname": "customer_group", - "oldfieldtype": "Link", - "options": "Customer Group", - "print_hide": 1, - "read_only": 0, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "shipping_address_name", - "fieldtype": "Link", - "hidden": 0, - "label": "Shipping Address", - "options": "Address", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "shipping_address", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Shipping Address", - "print_hide": 1, - "read_only": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "col_break98", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "customer_address", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Customer Address", - "options": "Address", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "eval:doc.customer", - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Contact Person", - "oldfieldname": "contact_person", - "oldfieldtype": "Link", - "options": "Contact", - "print_hide": 1, - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "campaign", - "fieldtype": "Link", - "hidden": 0, - "label": "Campaign", - "no_copy": 0, - "oldfieldname": "campaign", - "oldfieldtype": "Link", - "options": "Campaign", - "print_hide": 1, - "read_only": 0, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "source", - "fieldtype": "Select", - "hidden": 0, - "label": "Source", - "no_copy": 0, - "oldfieldname": "source", - "oldfieldtype": "Select", - "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", - "print_hide": 1, - "read_only": 0, - "report_hide": 0 - }, - { - "allow_on_submit": 0, - "default": "Draft", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "Draft\nSubmitted\nOrdered\nLost\nCancelled", - "print_hide": 1, - "read_only": 1, - "reqd": 1, - "search_index": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "order_lost_reason", - "fieldtype": "Small Text", - "label": "Quotation Lost Reason", - "no_copy": 1, - "oldfieldname": "order_lost_reason", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "read_only": 0, - "width": "50%" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Select", - "label": "Letter Head", - "oldfieldname": "letter_head", - "oldfieldtype": "Select", - "options": "link:Letter Head", - "print_hide": 1, - "read_only": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "enq_det", - "fieldtype": "Text", - "hidden": 1, - "label": "Opportunity Item", - "no_copy": 0, - "oldfieldname": "enq_det", - "oldfieldtype": "Text", - "print_hide": 1, - "read_only": 1, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "communication_history", - "fieldtype": "Section Break", - "label": "Communication History", - "oldfieldtype": "Section Break", - "options": "icon-comments", - "print_hide": 1, - "read_only": 0 - }, - { - "allow_on_submit": 1, - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "communication_html", - "fieldtype": "HTML", - "label": "Communication HTML", - "oldfieldname": "follow_up", - "oldfieldtype": "Table", - "print_hide": 1, - "read_only": 0, - "width": "40px" - }, - { - "doctype": "DocField", - "fieldname": "communications", - "fieldtype": "Table", - "hidden": 1, - "label": "Communications", - "options": "Communication", - "print_hide": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales User", - "submit": 1, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Customer", - "submit": 0, - "write": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Maintenance Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Maintenance User", - "submit": 1, - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index 9bc75d6ca5e..97d41107a0b 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -10,59 +10,26 @@ test_dependencies = ["Sales BOM"] class TestQuotation(unittest.TestCase): def test_make_sales_order(self): from erpnext.selling.doctype.quotation.quotation import make_sales_order - - quotation = frappe.bean(copy=test_records[0]) + + quotation = frappe.copy_doc(test_records[0]) quotation.insert() - - self.assertRaises(frappe.ValidationError, make_sales_order, quotation.doc.name) - + + self.assertRaises(frappe.ValidationError, make_sales_order, quotation.name) + quotation.submit() - sales_order = make_sales_order(quotation.doc.name) - - self.assertEquals(sales_order[0]["doctype"], "Sales Order") - self.assertEquals(len(sales_order), 2) - self.assertEquals(sales_order[1]["doctype"], "Sales Order Item") - self.assertEquals(sales_order[1]["prevdoc_docname"], quotation.doc.name) - self.assertEquals(sales_order[0]["customer"], "_Test Customer") - - sales_order[0]["delivery_date"] = "2014-01-01" - sales_order[0]["naming_series"] = "_T-Quotation-" - sales_order[0]["transaction_date"] = "2013-05-12" - frappe.bean(sales_order).insert() + sales_order = make_sales_order(quotation.name) + + self.assertEquals(sales_order.doctype, "Sales Order") + self.assertEquals(len(sales_order.get("sales_order_details")), 1) + self.assertEquals(sales_order.get("sales_order_details")[0].doctype, "Sales Order Item") + self.assertEquals(sales_order.get("sales_order_details")[0].prevdoc_docname, quotation.name) + self.assertEquals(sales_order.customer, "_Test Customer") + + sales_order.delivery_date = "2014-01-01" + sales_order.naming_series = "_T-Quotation-" + sales_order.transaction_date = "2013-05-12" + sales_order.insert() -test_records = [ - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "quotation_to": "Customer", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "customer_group": "_Test Customer Group", - "doctype": "Quotation", - "fiscal_year": "_Test Fiscal Year 2013", - "order_type": "Sales", - "plc_conversion_rate": 1.0, - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory", - "transaction_date": "2013-02-21", - "grand_total": 1000.0, - "grand_total_export": 1000.0, - }, - { - "description": "CPU", - "doctype": "Quotation Item", - "item_code": "_Test Item Home Desktop 100", - "item_name": "CPU", - "parentfield": "quotation_details", - "qty": 10.0, - "base_rate": 100.0, - "rate": 100.0, - "base_amount": 1000.0, - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Quotation') diff --git a/erpnext/selling/doctype/quotation/test_records.json b/erpnext/selling/doctype/quotation/test_records.json new file mode 100644 index 00000000000..054144ebf4d --- /dev/null +++ b/erpnext/selling/doctype/quotation/test_records.json @@ -0,0 +1,34 @@ +[ + { + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_group": "_Test Customer Group", + "customer_name": "_Test Customer", + "doctype": "Quotation", + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 1000.0, + "grand_total_export": 1000.0, + "order_type": "Sales", + "plc_conversion_rate": 1.0, + "price_list_currency": "INR", + "quotation_details": [ + { + "base_amount": 1000.0, + "base_rate": 100.0, + "description": "CPU", + "doctype": "Quotation Item", + "item_code": "_Test Item Home Desktop 100", + "item_name": "CPU", + "parentfield": "quotation_details", + "qty": 10.0, + "rate": 100.0 + } + ], + "quotation_to": "Customer", + "selling_price_list": "_Test Price List", + "territory": "_Test Territory", + "transaction_date": "2013-02-21" + } +] \ No newline at end of file diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.json b/erpnext/selling/doctype/quotation_item/quotation_item.json new file mode 100644 index 00000000000..4e19ee79706 --- /dev/null +++ b/erpnext/selling/doctype/quotation_item/quotation_item.json @@ -0,0 +1,361 @@ +{ + "autoname": "QUOD/.#####", + "creation": "2013-03-07 11:42:57.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_hide": 0, + "print_width": "150px", + "read_only": 0, + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "customer_item_code", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Customer's Item Code", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 0, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 0, + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 0, + "print_width": "300px", + "read_only": 0, + "reqd": 1, + "width": "300px" + }, + { + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Quantity and Rate", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_filter": 0, + "in_list_view": 1, + "label": "Quantity", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate", + "oldfieldname": "ref_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "discount_percentage", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Discount (%)", + "oldfieldname": "adj_rate", + "oldfieldtype": "Float", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "width": "100px" + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "base_price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate (Company Currency)", + "oldfieldname": "base_ref_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "width": "100px" + }, + { + "fieldname": "Section_break1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "rate", + "fieldtype": "Currency", + "in_filter": 0, + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "export_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 0, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_filter": 0, + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "export_amount", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "base_rate", + "fieldtype": "Currency", + "in_filter": 0, + "in_list_view": 0, + "label": "Basic Rate (Company Currency)", + "oldfieldname": "basic_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "base_amount", + "fieldtype": "Currency", + "in_filter": 0, + "in_list_view": 0, + "label": "Amount (Company Currency)", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "pricing_rule_for_price", + "fieldtype": "Link", + "label": "Pricing Rule For Price", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "pricing_rule_for_discount", + "fieldtype": "Link", + "label": "Pricing Rule For Discount", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "reference", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Reference", + "permlevel": 0 + }, + { + "fieldname": "prevdoc_doctype", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Against Doctype", + "no_copy": 1, + "oldfieldname": "prevdoc_doctype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "report_hide": 0, + "width": "150px" + }, + { + "fieldname": "prevdoc_docname", + "fieldtype": "Data", + "in_list_view": 0, + "label": "Against Docname", + "no_copy": 1, + "oldfieldname": "prevdoc_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "report_hide": 0, + "width": "150px" + }, + { + "fieldname": "item_tax_rate", + "fieldtype": "Small Text", + "hidden": 1, + "in_list_view": 0, + "label": "Item Tax Rate", + "oldfieldname": "item_tax_rate", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1 + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "hidden": 0, + "in_list_view": 0, + "label": "Page Break", + "no_copy": 1, + "oldfieldname": "page_break", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "brand", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "Brand", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "search_index": 1, + "width": "150px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-28 11:20:34.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Quotation Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.py b/erpnext/selling/doctype/quotation_item/quotation_item.py index 26c87f1c04a..426b199a360 100644 --- a/erpnext/selling/doctype/quotation_item/quotation_item.py +++ b/erpnext/selling/doctype/quotation_item/quotation_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class QuotationItem(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.txt b/erpnext/selling/doctype/quotation_item/quotation_item.txt deleted file mode 100644 index bbf953a0357..00000000000 --- a/erpnext/selling/doctype/quotation_item/quotation_item.txt +++ /dev/null @@ -1,374 +0,0 @@ -[ - { - "creation": "2013-03-07 11:42:57", - "docstatus": 0, - "modified": "2014-02-28 11:20:34", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "QUOD/.#####", - "doctype": "DocType", - "istable": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Quotation Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Quotation Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "print_hide": 0, - "print_width": "150px", - "read_only": 0, - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "customer_item_code", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Customer's Item Code", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 0, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 0, - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "print_hide": 0, - "print_width": "300px", - "read_only": 0, - "reqd": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Quantity and Rate" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_filter": 0, - "in_list_view": 1, - "label": "Quantity", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "print_hide": 0, - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate", - "oldfieldname": "ref_rate", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "discount_percentage", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Discount (%)", - "oldfieldname": "adj_rate", - "oldfieldtype": "Float", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "print_hide": 0, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "base_price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate (Company Currency)", - "oldfieldname": "base_ref_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "Section_break1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Currency", - "in_filter": 0, - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "export_rate", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "print_width": "100px", - "read_only": 0, - "reqd": 0, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "in_filter": 0, - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "export_amount", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "base_rate", - "fieldtype": "Currency", - "in_filter": 0, - "in_list_view": 0, - "label": "Basic Rate (Company Currency)", - "oldfieldname": "basic_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "base_amount", - "fieldtype": "Currency", - "in_filter": 0, - "in_list_view": 0, - "label": "Amount (Company Currency)", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_price", - "fieldtype": "Link", - "label": "Pricing Rule For Price", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_discount", - "fieldtype": "Link", - "label": "Pricing Rule For Discount", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "reference", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Reference" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_doctype", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Against Doctype", - "no_copy": 1, - "oldfieldname": "prevdoc_doctype", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "report_hide": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_docname", - "fieldtype": "Data", - "in_list_view": 0, - "label": "Against Docname", - "no_copy": 1, - "oldfieldname": "prevdoc_docname", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "report_hide": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "item_tax_rate", - "fieldtype": "Small Text", - "hidden": 1, - "in_list_view": 0, - "label": "Item Tax Rate", - "oldfieldname": "item_tax_rate", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break4", - "fieldtype": "Column Break" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "page_break", - "fieldtype": "Check", - "hidden": 0, - "in_list_view": 0, - "label": "Page Break", - "no_copy": 1, - "oldfieldname": "page_break", - "oldfieldtype": "Check", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "Brand", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "search_index": 1, - "width": "150px" - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_bom/sales_bom.json b/erpnext/selling/doctype/sales_bom/sales_bom.json new file mode 100644 index 00000000000..91fac19a271 --- /dev/null +++ b/erpnext/selling/doctype/sales_bom/sales_bom.json @@ -0,0 +1,97 @@ +{ + "allow_import": 1, + "creation": "2013-06-20 11:53:21.000000", + "description": "Aggregate group of **Items** into another **Item**. This is useful if you are bundling a certain **Items** into a package and you maintain stock of the packed **Items** and not the aggregate **Item**. \n\nThe package **Item** will have \"Is Stock Item\" as \"No\" and \"Is Sales Item\" as \"Yes\".\n\nFor Example: If you are selling Laptops and Backpacks separately and have a special price if the customer buys both, then the Laptop + Backpack will be a new Sales BOM Item.\n\nNote: BOM = Bill of Materials", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "basic_section", + "fieldtype": "Section Break", + "label": "Sales BOM Item", + "permlevel": 0 + }, + { + "description": "The Item that represents the Package. This Item must have \"Is Stock Item\" as \"No\" and \"Is Sales Item\" as \"Yes\"", + "fieldname": "new_item_code", + "fieldtype": "Link", + "label": "Parent Item", + "no_copy": 1, + "oldfieldname": "new_item_code", + "oldfieldtype": "Data", + "options": "Item", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "List items that form the package.", + "fieldname": "item_section", + "fieldtype": "Section Break", + "label": "Package Items", + "permlevel": 0 + }, + { + "fieldname": "sales_bom_items", + "fieldtype": "Table", + "label": "Sales BOM Items", + "oldfieldname": "sales_bom_items", + "oldfieldtype": "Table", + "options": "Sales BOM Item", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-sitemap", + "idx": 1, + "is_submittable": 0, + "modified": "2014-01-20 17:49:19.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales BOM", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_bom/sales_bom.py b/erpnext/selling/doctype/sales_bom/sales_bom.py index fb4696199c1..5601d7ff67b 100644 --- a/erpnext/selling/doctype/sales_bom/sales_bom.py +++ b/erpnext/selling/doctype/sales_bom/sales_bom.py @@ -4,23 +4,24 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl +from frappe.model.document import Document + +class SalesBOM(Document): + def autoname(self): - self.doc.name = self.doc.new_item_code + self.name = self.new_item_code def validate(self): self.validate_main_item() from erpnext.utilities.transaction_base import validate_uom_is_integer - validate_uom_is_integer(self.doclist, "uom", "qty") + validate_uom_is_integer(self, "uom", "qty") def validate_main_item(self): """main item must have Is Stock Item as No and Is Sales Item as Yes""" if not frappe.db.sql("""select name from tabItem where name=%s and - ifnull(is_stock_item,'')='No' and ifnull(is_sales_item,'')='Yes'""", self.doc.new_item_code): + ifnull(is_stock_item,'')='No' and ifnull(is_sales_item,'')='Yes'""", self.new_item_code): frappe.msgprint("""Parent Item %s is either a Stock Item or a not a Sales Item""", raise_exception=1) diff --git a/erpnext/selling/doctype/sales_bom/sales_bom.txt b/erpnext/selling/doctype/sales_bom/sales_bom.txt deleted file mode 100644 index ae40e10f80b..00000000000 --- a/erpnext/selling/doctype/sales_bom/sales_bom.txt +++ /dev/null @@ -1,102 +0,0 @@ -[ - { - "creation": "2013-06-20 11:53:21", - "docstatus": 0, - "modified": "2014-01-20 17:49:19", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "description": "Aggregate group of **Items** into another **Item**. This is useful if you are bundling a certain **Items** into a package and you maintain stock of the packed **Items** and not the aggregate **Item**. \n\nThe package **Item** will have \"Is Stock Item\" as \"No\" and \"Is Sales Item\" as \"Yes\".\n\nFor Example: If you are selling Laptops and Backpacks separately and have a special price if the customer buys both, then the Laptop + Backpack will be a new Sales BOM Item.\n\nNote: BOM = Bill of Materials", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-sitemap", - "is_submittable": 0, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales BOM", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Sales BOM", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Sales BOM" - }, - { - "doctype": "DocField", - "fieldname": "basic_section", - "fieldtype": "Section Break", - "label": "Sales BOM Item" - }, - { - "description": "The Item that represents the Package. This Item must have \"Is Stock Item\" as \"No\" and \"Is Sales Item\" as \"Yes\"", - "doctype": "DocField", - "fieldname": "new_item_code", - "fieldtype": "Link", - "label": "Parent Item", - "no_copy": 1, - "oldfieldname": "new_item_code", - "oldfieldtype": "Data", - "options": "Item", - "reqd": 1 - }, - { - "description": "List items that form the package.", - "doctype": "DocField", - "fieldname": "item_section", - "fieldtype": "Section Break", - "label": "Package Items" - }, - { - "doctype": "DocField", - "fieldname": "sales_bom_items", - "fieldtype": "Table", - "label": "Sales BOM Items", - "oldfieldname": "sales_bom_items", - "oldfieldtype": "Table", - "options": "Sales BOM Item", - "reqd": 1 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Material Manager", - "write": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Material User", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales User", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_bom/test_records.json b/erpnext/selling/doctype/sales_bom/test_records.json new file mode 100644 index 00000000000..beb8289f77e --- /dev/null +++ b/erpnext/selling/doctype/sales_bom/test_records.json @@ -0,0 +1,20 @@ +[ + { + "doctype": "Sales BOM", + "new_item_code": "_Test Sales BOM Item", + "sales_bom_items": [ + { + "doctype": "Sales BOM Item", + "item_code": "_Test Item", + "parentfield": "sales_bom_items", + "qty": 5.0 + }, + { + "doctype": "Sales BOM Item", + "item_code": "_Test Item Home Desktop 100", + "parentfield": "sales_bom_items", + "qty": 2.0 + } + ] + } +] \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_bom/test_sales_bom.py b/erpnext/selling/doctype/sales_bom/test_sales_bom.py index 02ca68f0c52..6d39ee2e0f7 100644 --- a/erpnext/selling/doctype/sales_bom/test_sales_bom.py +++ b/erpnext/selling/doctype/sales_bom/test_sales_bom.py @@ -1,23 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [ - { - "doctype": "Sales BOM", - "new_item_code": "_Test Sales BOM Item" - }, - { - "doctype": "Sales BOM Item", - "item_code": "_Test Item", - "parentfield": "sales_bom_items", - "qty": 5.0 - }, - { - "doctype": "Sales BOM Item", - "item_code": "_Test Item Home Desktop 100", - "parentfield": "sales_bom_items", - "qty": 2.0 - } - ], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Sales Bom') \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_bom_item/sales_bom_item.json b/erpnext/selling/doctype/sales_bom_item/sales_bom_item.json new file mode 100644 index 00000000000..c48debdd8c1 --- /dev/null +++ b/erpnext/selling/doctype/sales_bom_item/sales_bom_item.json @@ -0,0 +1,68 @@ +{ + "creation": "2013-05-23 16:55:51.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Item", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Qty", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "300px" + }, + { + "fieldname": "rate", + "fieldtype": "Float", + "hidden": 1, + "in_list_view": 0, + "label": "Rate", + "oldfieldname": "rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "oldfieldname": "uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:21:38.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales BOM Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py b/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py index 26c87f1c04a..9a98c397f8a 100644 --- a/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py +++ b/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesBOMItem(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_bom_item/sales_bom_item.txt b/erpnext/selling/doctype/sales_bom_item/sales_bom_item.txt deleted file mode 100644 index e06d8f8241e..00000000000 --- a/erpnext/selling/doctype/sales_bom_item/sales_bom_item.txt +++ /dev/null @@ -1,81 +0,0 @@ -[ - { - "creation": "2013-05-23 16:55:51", - "docstatus": 0, - "modified": "2013-12-20 19:21:38", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales BOM Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Sales BOM Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Qty", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "print_width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Float", - "hidden": 1, - "in_list_view": 0, - "label": "Rate", - "oldfieldname": "rate", - "oldfieldtype": "Currency", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "oldfieldname": "uom", - "oldfieldtype": "Link", - "options": "UOM", - "read_only": 1, - "search_index": 0 - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 0a3ca99bb03..9d43065dcf6 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -86,7 +86,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( }, warehouse: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); if(item.item_code && item.warehouse) { return this.frm.call({ method: "erpnext.selling.utils.get_available_qty", @@ -162,7 +162,7 @@ cur_frm.cscript['Stop Sales Order'] = function() { if (check) { return $c('runserverobj', { 'method':'stop_sales_order', - 'docs': frappe.model.compress(make_doclist(doc.doctype, doc.name)) + 'docs': doc }, function(r,rt) { cur_frm.refresh(); }); @@ -177,7 +177,7 @@ cur_frm.cscript['Unstop Sales Order'] = function() { if (check) { return $c('runserverobj', { 'method':'unstop_sales_order', - 'docs': frappe.model.compress(make_doclist(doc.doctype, doc.name)) + 'docs': doc }, function(r,rt) { cur_frm.refresh(); }); diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json new file mode 100644 index 00000000000..102abc0eef3 --- /dev/null +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -0,0 +1,932 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-06-18 12:39:59.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "fieldname": "customer_section", + "fieldtype": "Section Break", + "label": "Customer", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "in_filter": 0, + "oldfieldtype": "Column Break", + "permlevel": 0, + "search_index": 0, + "width": "50%" + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "PI/2011/\nSO\nSO/10-11/\nSO1112", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "customer_name", + "fieldtype": "Data", + "hidden": 0, + "label": "Name", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_mobile", + "fieldtype": "Text", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_email", + "fieldtype": "Text", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "default": "Sales", + "fieldname": "order_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Order Type", + "oldfieldname": "order_type", + "oldfieldtype": "Select", + "options": "\nSales\nMaintenance", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "hidden": 1, + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "width": "150px" + }, + { + "description": "Select the relevant company name if you have multiple companies.", + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "default": "Today", + "fieldname": "transaction_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Sales Order Date", + "no_copy": 1, + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 0, + "reqd": 1, + "search_index": 1, + "width": "160px" + }, + { + "depends_on": "eval:doc.order_type == 'Sales'", + "fieldname": "delivery_date", + "fieldtype": "Date", + "hidden": 0, + "in_filter": 1, + "label": "Delivery Date", + "oldfieldname": "delivery_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "reqd": 0, + "search_index": 1, + "width": "160px" + }, + { + "description": "Customer's Purchase Order Number", + "fieldname": "po_no", + "fieldtype": "Data", + "hidden": 0, + "label": "PO No", + "oldfieldname": "po_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "reqd": 0, + "width": "100px" + }, + { + "depends_on": "eval:doc.po_no", + "description": "Customer's Purchase Order Date", + "fieldname": "po_date", + "fieldtype": "Date", + "hidden": 0, + "label": "PO Date", + "oldfieldname": "po_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 0, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "shipping_address_name", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "label": "Shipping Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "shipping_address", + "fieldtype": "Small Text", + "hidden": 1, + "in_filter": 0, + "label": "Shipping Address", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "sec_break45", + "fieldtype": "Section Break", + "label": "Currency and Price List", + "options": "icon-tag", + "permlevel": 0 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "width": "100px" + }, + { + "description": "Rate at which customer's currency is converted to company's base currency", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "label": "Exchange Rate", + "oldfieldname": "conversion_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "selling_price_list", + "fieldtype": "Link", + "label": "Price List", + "oldfieldname": "price_list_name", + "oldfieldtype": "Select", + "options": "Price List", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "price_list_currency", + "fieldtype": "Link", + "label": "Price List Currency", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "description": "Rate at which Price list currency is converted to company's base currency", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "label": "Price List Exchange Rate", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "fieldname": "items", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "sales_order_details", + "fieldtype": "Table", + "label": "Sales Order Items", + "oldfieldname": "sales_order_details", + "oldfieldtype": "Table", + "options": "Sales Order Item", + "permlevel": 0, + "print_hide": 0, + "reqd": 1 + }, + { + "description": "Display all the individual items delivered with the main items", + "fieldname": "packing_list", + "fieldtype": "Section Break", + "hidden": 0, + "label": "Packing List", + "oldfieldtype": "Section Break", + "options": "icon-suitcase", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "packing_details", + "fieldtype": "Table", + "label": "Packing Details", + "oldfieldname": "packing_details", + "oldfieldtype": "Table", + "options": "Packed Item", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "section_break_31", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "net_total_export", + "fieldtype": "Currency", + "label": "Net Total", + "options": "currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break_33", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total (Company Currency)", + "oldfieldname": "net_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0, + "width": "150px" + }, + { + "fieldname": "taxes", + "fieldtype": "Section Break", + "label": "Taxes and Charges", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "print_hide": 0 + }, + { + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "oldfieldname": "charge", + "oldfieldtype": "Link", + "options": "Sales Taxes and Charges Master", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "column_break_38", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "shipping_rule", + "fieldtype": "Link", + "label": "Shipping Rule", + "oldfieldtype": "Button", + "options": "Shipping Rule", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "section_break_40", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "other_charges", + "fieldtype": "Table", + "label": "Sales Taxes and Charges", + "oldfieldname": "other_charges", + "oldfieldtype": "Table", + "options": "Sales Taxes and Charges", + "permlevel": 0 + }, + { + "fieldname": "other_charges_calculation", + "fieldtype": "HTML", + "label": "Taxes and Charges Calculation", + "oldfieldtype": "HTML", + "permlevel": 0, + "print_hide": 0 + }, + { + "fieldname": "section_break_43", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "other_charges_total_export", + "fieldtype": "Currency", + "label": "Taxes and Charges Total", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_46", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "other_charges_total", + "fieldtype": "Currency", + "label": "Taxes and Charges Total (Company Currency)", + "oldfieldname": "other_charges_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "Totals", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "grand_total_export", + "fieldtype": "Currency", + "label": "Grand Total", + "oldfieldname": "grand_total_export", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "reqd": 0, + "width": "150px" + }, + { + "fieldname": "rounded_total_export", + "fieldtype": "Currency", + "label": "Rounded Total", + "oldfieldname": "rounded_total_export", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "in_words_export", + "fieldtype": "Data", + "label": "In Words", + "oldfieldname": "in_words_export", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "width": "200px" + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "width": "50%" + }, + { + "fieldname": "grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0, + "width": "150px" + }, + { + "fieldname": "rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total (Company Currency)", + "oldfieldname": "rounded_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "width": "150px" + }, + { + "description": "In Words will be visible once you save the Sales Order.", + "fieldname": "in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "width": "200px" + }, + { + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "oldfieldtype": "Section Break", + "options": "icon-legal", + "permlevel": 0, + "print_hide": 0 + }, + { + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, + "print_hide": 1, + "search_index": 0 + }, + { + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Terms and Conditions Details", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", + "permlevel": 0, + "print_hide": 0 + }, + { + "depends_on": "customer", + "fieldname": "contact_info", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0 + }, + { + "fieldname": "col_break45", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "in_filter": 1, + "label": "Territory", + "options": "Territory", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "description": "Add / Edit", + "fieldname": "customer_group", + "fieldtype": "Link", + "in_filter": 1, + "label": "Customer Group", + "options": "Customer Group", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "col_break46", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "customer_address", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Customer Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "contact_person", + "fieldtype": "Link", + "in_filter": 1, + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0, + "print_hide": 1 + }, + { + "description": "Track this Sales Order against any Project", + "fieldname": "project_name", + "fieldtype": "Link", + "in_filter": 1, + "label": "Project Name", + "oldfieldname": "project_name", + "oldfieldtype": "Link", + "options": "Project", + "permlevel": 0, + "search_index": 1 + }, + { + "depends_on": "eval:doc.source == 'Campaign'", + "fieldname": "campaign", + "fieldtype": "Link", + "label": "Campaign", + "oldfieldname": "campaign", + "oldfieldtype": "Link", + "options": "Campaign", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "source", + "fieldtype": "Select", + "label": "Source", + "oldfieldname": "source", + "oldfieldtype": "Select", + "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "column_break4", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "width": "50%" + }, + { + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Select", + "label": "Letter Head", + "oldfieldname": "letter_head", + "oldfieldtype": "Select", + "options": "link:Letter Head", + "permlevel": 0, + "print_hide": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "section_break_78", + "fieldtype": "Section Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "width": "50%" + }, + { + "default": "Draft", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nDraft\nSubmitted\nStopped\nCancelled", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1, + "search_index": 1, + "width": "100px" + }, + { + "fieldname": "delivery_status", + "fieldtype": "Select", + "hidden": 1, + "label": "Delivery Status", + "no_copy": 1, + "options": "Delivered\nNot Delivered\nPartly Delivered\nClosed\nNot Applicable", + "permlevel": 0, + "print_hide": 1 + }, + { + "depends_on": "eval:!doc.__islocal", + "description": "% of materials delivered against this Sales Order", + "fieldname": "per_delivered", + "fieldtype": "Percent", + "in_filter": 1, + "in_list_view": 1, + "label": "% Delivered", + "no_copy": 1, + "oldfieldname": "per_delivered", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "width": "100px" + }, + { + "fieldname": "column_break_81", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "description": "% of materials billed against this Sales Order", + "fieldname": "per_billed", + "fieldtype": "Percent", + "in_filter": 1, + "in_list_view": 1, + "label": "% Amount Billed", + "no_copy": 1, + "oldfieldname": "per_billed", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "width": "100px" + }, + { + "fieldname": "billing_status", + "fieldtype": "Select", + "hidden": 1, + "label": "Billing Status", + "no_copy": 1, + "options": "Billed\nNot Billed\nPartly Billed\nClosed", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "sales_team_section_break", + "fieldtype": "Section Break", + "label": "Sales Team", + "oldfieldtype": "Section Break", + "options": "icon-group", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "sales_partner", + "fieldtype": "Link", + "in_filter": 1, + "label": "Sales Partner", + "oldfieldname": "sales_partner", + "oldfieldtype": "Link", + "options": "Sales Partner", + "permlevel": 0, + "print_hide": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "column_break7", + "fieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "width": "50%" + }, + { + "fieldname": "commission_rate", + "fieldtype": "Float", + "label": "Commission Rate", + "oldfieldname": "commission_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "width": "100px" + }, + { + "fieldname": "total_commission", + "fieldtype": "Currency", + "label": "Total Commission", + "oldfieldname": "total_commission", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "section_break1", + "fieldtype": "Section Break", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "sales_team", + "fieldtype": "Table", + "label": "Sales Team1", + "oldfieldname": "sales_team", + "oldfieldtype": "Table", + "options": "Sales Team", + "permlevel": 0, + "print_hide": 1 + } + ], + "icon": "icon-file-text", + "idx": 1, + "is_submittable": 1, + "issingle": 0, + "modified": "2014-01-28 18:47:42.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Order", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Maintenance User", + "submit": 1, + "write": 1 + }, + { + "cancel": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "Accounts User" + }, + { + "cancel": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "Customer" + } + ], + "read_only_onload": 1, + "search_fields": "status,transaction_date,customer,customer_name, territory,order_type,company" +} \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index fd915de7b5a..b302c7c2185 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -6,57 +6,52 @@ import frappe import frappe.utils from frappe.utils import cstr, flt, getdate -from frappe.model.bean import getlist -from frappe.model.code import get_obj + from frappe import msgprint -from frappe.model.mapper import get_mapped_doclist +from frappe.model.mapper import get_mapped_doc from erpnext.controllers.selling_controller import SellingController -class DocType(SellingController): - def __init__(self, doc, doclist=None): - self.doc = doc - if not doclist: doclist = [] - self.doclist = doclist - self.tname = 'Sales Order Item' - self.fname = 'sales_order_details' - self.person_tname = 'Target Detail' - self.partner_tname = 'Partner Target Detail' - self.territory_tname = 'Territory Target Detail' - +class SalesOrder(SellingController): + tname = 'Sales Order Item' + fname = 'sales_order_details' + person_tname = 'Target Detail' + partner_tname = 'Partner Target Detail' + territory_tname = 'Territory Target Detail' + def validate_mandatory(self): # validate transaction date v/s delivery date - if self.doc.delivery_date: - if getdate(self.doc.transaction_date) > getdate(self.doc.delivery_date): + if self.delivery_date: + if getdate(self.transaction_date) > getdate(self.delivery_date): msgprint("Expected Delivery Date cannot be before Sales Order Date") raise Exception - + def validate_po(self): # validate p.o date v/s delivery date - if self.doc.po_date and self.doc.delivery_date and getdate(self.doc.po_date) > getdate(self.doc.delivery_date): + if self.po_date and self.delivery_date and getdate(self.po_date) > getdate(self.delivery_date): msgprint("Expected Delivery Date cannot be before Purchase Order Date") - raise Exception - - if self.doc.po_no and self.doc.customer: + raise Exception + + if self.po_no and self.customer: so = frappe.db.sql("select name from `tabSales Order` \ where ifnull(po_no, '') = %s and name != %s and docstatus < 2\ - and customer = %s", (self.doc.po_no, self.doc.name, self.doc.customer)) + and customer = %s", (self.po_no, self.name, self.customer)) if so and so[0][0]: - msgprint("""Another Sales Order (%s) exists against same PO No and Customer. + msgprint("""Another Sales Order (%s) exists against same PO No and Customer. Please be sure, you are not making duplicate entry.""" % so[0][0]) - + def validate_for_items(self): check_list, flag = [], 0 chk_dupl_itm = [] - for d in getlist(self.doclist, 'sales_order_details'): + for d in self.get('sales_order_details'): e = [d.item_code, d.description, d.warehouse, d.prevdoc_docname or ''] f = [d.item_code, d.description] if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 'Yes': if not d.warehouse: - msgprint("""Please enter Reserved Warehouse for item %s + msgprint("""Please enter Reserved Warehouse for item %s as it is stock Item""" % d.item_code, raise_exception=1) - + if e in check_list: msgprint("Item %s has been entered twice." % d.item_code) else: @@ -68,42 +63,42 @@ class DocType(SellingController): chk_dupl_itm.append(f) # used for production plan - d.transaction_date = self.doc.transaction_date - + d.transaction_date = self.transaction_date + tot_avail_qty = frappe.db.sql("select projected_qty from `tabBin` \ where item_code = %s and warehouse = %s", (d.item_code,d.warehouse)) d.projected_qty = tot_avail_qty and flt(tot_avail_qty[0][0]) or 0 def validate_sales_mntc_quotation(self): - for d in getlist(self.doclist, 'sales_order_details'): + for d in self.get('sales_order_details'): if d.prevdoc_docname: - res = frappe.db.sql("select name from `tabQuotation` where name=%s and order_type = %s", (d.prevdoc_docname, self.doc.order_type)) + res = frappe.db.sql("select name from `tabQuotation` where name=%s and order_type = %s", (d.prevdoc_docname, self.order_type)) if not res: msgprint("""Order Type (%s) should be same in Quotation: %s \ - and current Sales Order""" % (self.doc.order_type, d.prevdoc_docname)) + and current Sales Order""" % (self.order_type, d.prevdoc_docname)) def validate_order_type(self): - super(DocType, self).validate_order_type() - + super(SalesOrder, self).validate_order_type() + def validate_delivery_date(self): - if self.doc.order_type == 'Sales' and not self.doc.delivery_date: + if self.order_type == 'Sales' and not self.delivery_date: msgprint("Please enter 'Expected Delivery Date'") raise Exception - + self.validate_sales_mntc_quotation() def validate_proj_cust(self): - if self.doc.project_name and self.doc.customer_name: - res = frappe.db.sql("""select name from `tabProject` where name = %s - and (customer = %s or ifnull(customer,'')='')""", - (self.doc.project_name, self.doc.customer)) + if self.project_name and self.customer_name: + res = frappe.db.sql("""select name from `tabProject` where name = %s + and (customer = %s or ifnull(customer,'')='')""", + (self.project_name, self.customer)) if not res: - msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in project - %s."%(self.doc.customer,self.doc.project_name,self.doc.project_name)) + msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in project - %s."%(self.customer,self.project_name,self.project_name)) raise Exception - + def validate(self): - super(DocType, self).validate() - + super(SalesOrder, self).validate() + self.validate_order_type() self.validate_delivery_date() self.validate_mandatory() @@ -115,124 +110,125 @@ class DocType(SellingController): from erpnext.stock.doctype.packed_item.packed_item import make_packing_list - self.doclist = make_packing_list(self,'sales_order_details') - + make_packing_list(self,'sales_order_details') + self.validate_with_previous_doc() - - if not self.doc.status: - self.doc.status = "Draft" + + if not self.status: + self.status = "Draft" from erpnext.utilities import validate_status - validate_status(self.doc.status, ["Draft", "Submitted", "Stopped", + validate_status(self.status, ["Draft", "Submitted", "Stopped", "Cancelled"]) - if not self.doc.billing_status: self.doc.billing_status = 'Not Billed' - if not self.doc.delivery_status: self.doc.delivery_status = 'Not Delivered' - + if not self.billing_status: self.billing_status = 'Not Billed' + if not self.delivery_status: self.delivery_status = 'Not Delivered' + def validate_warehouse(self): from erpnext.stock.utils import validate_warehouse_company - - warehouses = list(set([d.warehouse for d in - self.doclist.get({"doctype": self.tname}) if d.warehouse])) - + + warehouses = list(set([d.warehouse for d in + self.get(self.fname) if d.warehouse])) + for w in warehouses: - validate_warehouse_company(w, self.doc.company) - + validate_warehouse_company(w, self.company) + def validate_with_previous_doc(self): - super(DocType, self).validate_with_previous_doc(self.tname, { + super(SalesOrder, self).validate_with_previous_doc(self.tname, { "Quotation": { "ref_dn_field": "prevdoc_docname", "compare_fields": [["company", "="], ["currency", "="]] } }) - + def update_enquiry_status(self, prevdoc, flag): enq = frappe.db.sql("select t2.prevdoc_docname from `tabQuotation` t1, `tabQuotation Item` t2 where t2.parent = t1.name and t1.name=%s", prevdoc) if enq: frappe.db.sql("update `tabOpportunity` set status = %s where name=%s",(flag,enq[0][0])) - def update_prevdoc_status(self, flag): - for quotation in self.doclist.get_distinct_values("prevdoc_docname"): - bean = frappe.bean("Quotation", quotation) - if bean.doc.docstatus==2: - frappe.throw(quotation + ": " + frappe._("Quotation is cancelled.")) - - bean.get_controller().set_status(update=True) + def update_prevdoc_status(self, flag): + for quotation in list(set([d.prevdoc_docname for d in self.get(self.fname)])): + if quotation: + doc = frappe.get_doc("Quotation", quotation) + if doc.docstatus==2: + frappe.throw(quotation + ": " + frappe._("Quotation is cancelled.")) + + doc.set_status(update=True) def on_submit(self): self.update_stock_ledger(update_stock = 1) - self.check_credit(self.doc.grand_total) - - get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.grand_total, self) - + self.check_credit(self.grand_total) + + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.grand_total, self) + self.update_prevdoc_status('submit') - frappe.db.set(self.doc, 'status', 'Submitted') - + frappe.db.set(self, 'status', 'Submitted') + def on_cancel(self): # Cannot cancel stopped SO - if self.doc.status == 'Stopped': - msgprint("Sales Order : '%s' cannot be cancelled as it is Stopped. Unstop it for any further transactions" %(self.doc.name)) + if self.status == 'Stopped': + msgprint("Sales Order : '%s' cannot be cancelled as it is Stopped. Unstop it for any further transactions" %(self.name)) raise Exception self.check_nextdoc_docstatus() self.update_stock_ledger(update_stock = -1) - + self.update_prevdoc_status('cancel') - - frappe.db.set(self.doc, 'status', 'Cancelled') - + + frappe.db.set(self, 'status', 'Cancelled') + def check_nextdoc_docstatus(self): # Checks Delivery Note - submit_dn = frappe.db.sql("select t1.name from `tabDelivery Note` t1,`tabDelivery Note Item` t2 where t1.name = t2.parent and t2.against_sales_order = %s and t1.docstatus = 1", self.doc.name) + submit_dn = frappe.db.sql("select t1.name from `tabDelivery Note` t1,`tabDelivery Note Item` t2 where t1.name = t2.parent and t2.against_sales_order = %s and t1.docstatus = 1", self.name) if submit_dn: - msgprint("Delivery Note : " + cstr(submit_dn[0][0]) + " has been submitted against " + cstr(self.doc.doctype) + ". Please cancel Delivery Note : " + cstr(submit_dn[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1) - + msgprint("Delivery Note : " + cstr(submit_dn[0][0]) + " has been submitted against " + cstr(self.doctype) + ". Please cancel Delivery Note : " + cstr(submit_dn[0][0]) + " first and then cancel "+ cstr(self.doctype), raise_exception = 1) + # Checks Sales Invoice - submit_rv = frappe.db.sql("""select t1.name - from `tabSales Invoice` t1,`tabSales Invoice Item` t2 - where t1.name = t2.parent and t2.sales_order = %s and t1.docstatus = 1""", - self.doc.name) + submit_rv = frappe.db.sql("""select t1.name + from `tabSales Invoice` t1,`tabSales Invoice Item` t2 + where t1.name = t2.parent and t2.sales_order = %s and t1.docstatus = 1""", + self.name) if submit_rv: - msgprint("Sales Invoice : " + cstr(submit_rv[0][0]) + " has already been submitted against " +cstr(self.doc.doctype)+ ". Please cancel Sales Invoice : "+ cstr(submit_rv[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1) - + msgprint("Sales Invoice : " + cstr(submit_rv[0][0]) + " has already been submitted against " +cstr(self.doctype)+ ". Please cancel Sales Invoice : "+ cstr(submit_rv[0][0]) + " first and then cancel "+ cstr(self.doctype), raise_exception = 1) + #check maintenance schedule - submit_ms = frappe.db.sql("select t1.name from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2 where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1",self.doc.name) + submit_ms = frappe.db.sql("select t1.name from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2 where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1",self.name) if submit_ms: - msgprint("Maintenance Schedule : " + cstr(submit_ms[0][0]) + " has already been submitted against " +cstr(self.doc.doctype)+ ". Please cancel Maintenance Schedule : "+ cstr(submit_ms[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1) - + msgprint("Maintenance Schedule : " + cstr(submit_ms[0][0]) + " has already been submitted against " +cstr(self.doctype)+ ". Please cancel Maintenance Schedule : "+ cstr(submit_ms[0][0]) + " first and then cancel "+ cstr(self.doctype), raise_exception = 1) + # check maintenance visit - submit_mv = frappe.db.sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1",self.doc.name) + submit_mv = frappe.db.sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1",self.name) if submit_mv: - msgprint("Maintenance Visit : " + cstr(submit_mv[0][0]) + " has already been submitted against " +cstr(self.doc.doctype)+ ". Please cancel Maintenance Visit : " + cstr(submit_mv[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1) - + msgprint("Maintenance Visit : " + cstr(submit_mv[0][0]) + " has already been submitted against " +cstr(self.doctype)+ ". Please cancel Maintenance Visit : " + cstr(submit_mv[0][0]) + " first and then cancel "+ cstr(self.doctype), raise_exception = 1) + # check production order - pro_order = frappe.db.sql("""select name from `tabProduction Order` where sales_order = %s and docstatus = 1""", self.doc.name) + pro_order = frappe.db.sql("""select name from `tabProduction Order` where sales_order = %s and docstatus = 1""", self.name) if pro_order: - msgprint("""Production Order: %s exists against this sales order. - Please cancel production order first and then cancel this sales order""" % + msgprint("""Production Order: %s exists against this sales order. + Please cancel production order first and then cancel this sales order""" % pro_order[0][0], raise_exception=1) def check_modified_date(self): - mod_db = frappe.db.get_value("Sales Order", self.doc.name, "modified") - date_diff = frappe.db.sql("select TIMEDIFF('%s', '%s')" % - ( mod_db, cstr(self.doc.modified))) + mod_db = frappe.db.get_value("Sales Order", self.name, "modified") + date_diff = frappe.db.sql("select TIMEDIFF('%s', '%s')" % + ( mod_db, cstr(self.modified))) if date_diff and date_diff[0][0]: msgprint("%s: %s has been modified after you have opened. Please Refresh" - % (self.doc.doctype, self.doc.name), raise_exception=1) + % (self.doctype, self.name), raise_exception=1) def stop_sales_order(self): self.check_modified_date() self.update_stock_ledger(-1) - frappe.db.set(self.doc, 'status', 'Stopped') - msgprint("""%s: %s has been Stopped. To make transactions against this Sales Order - you need to Unstop it.""" % (self.doc.doctype, self.doc.name)) + frappe.db.set(self, 'status', 'Stopped') + msgprint("""%s: %s has been Stopped. To make transactions against this Sales Order + you need to Unstop it.""" % (self.doctype, self.name)) def unstop_sales_order(self): self.check_modified_date() self.update_stock_ledger(1) - frappe.db.set(self.doc, 'status', 'Submitted') - msgprint("%s: %s has been Unstopped" % (self.doc.doctype, self.doc.name)) + frappe.db.set(self, 'status', 'Submitted') + msgprint("%s: %s has been Unstopped" % (self.doctype, self.name)) def update_stock_ledger(self, update_stock): @@ -241,182 +237,182 @@ class DocType(SellingController): if frappe.db.get_value("Item", d['item_code'], "is_stock_item") == "Yes": args = { "item_code": d['item_code'], - "warehouse": d['reserved_warehouse'], + "warehouse": d['reserved_warehouse'], "reserved_qty": flt(update_stock) * flt(d['reserved_qty']), - "posting_date": self.doc.transaction_date, - "voucher_type": self.doc.doctype, - "voucher_no": self.doc.name, - "is_amended": self.doc.amended_from and 'Yes' or 'No' + "posting_date": self.transaction_date, + "voucher_type": self.doctype, + "voucher_no": self.name, + "is_amended": self.amended_from and 'Yes' or 'No' } update_bin(args) def on_update(self): pass - + def get_portal_page(self): - return "order" if self.doc.docstatus==1 else None - + return "order" if self.docstatus==1 else None + def set_missing_values(source, target): - bean = frappe.bean(target) - bean.run_method("onload_post_render") - + doc = frappe.get_doc(target) + doc.run_method("onload_post_render") + @frappe.whitelist() -def make_material_request(source_name, target_doclist=None): - def postprocess(source, doclist): - doclist[0].material_request_type = "Purchase" - - doclist = get_mapped_doclist("Sales Order", source_name, { +def make_material_request(source_name, target_doc=None): + def postprocess(source, doc): + doc.material_request_type = "Purchase" + + doc = get_mapped_doc("Sales Order", source_name, { "Sales Order": { - "doctype": "Material Request", + "doctype": "Material Request", "validation": { "docstatus": ["=", 1] } - }, + }, "Sales Order Item": { - "doctype": "Material Request Item", + "doctype": "Material Request Item", "field_map": { - "parent": "sales_order_no", + "parent": "sales_order_no", "stock_uom": "uom" } } - }, target_doclist, postprocess) - - return [(d if isinstance(d, dict) else d.fields) for d in doclist] + }, target_doc, postprocess) + + return doc @frappe.whitelist() -def make_delivery_note(source_name, target_doclist=None): - def update_item(obj, target, source_parent): - target.base_amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.base_rate) - target.amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.rate) - target.qty = flt(obj.qty) - flt(obj.delivered_qty) - - doclist = get_mapped_doclist("Sales Order", source_name, { +def make_delivery_note(source_name, target_doc=None): + def update_item(source, target, source_parent): + target.base_amount = (flt(source.qty) - flt(source.delivered_qty)) * flt(source.base_rate) + target.amount = (flt(source.qty) - flt(source.delivered_qty)) * flt(source.rate) + target.qty = flt(source.qty) - flt(source.delivered_qty) + + doclist = get_mapped_doc("Sales Order", source_name, { "Sales Order": { - "doctype": "Delivery Note", + "doctype": "Delivery Note", "field_map": { - "shipping_address": "address_display", - "shipping_address_name": "customer_address", + "shipping_address": "address_display", + "shipping_address_name": "customer_address", }, "validation": { "docstatus": ["=", 1] } - }, + }, "Sales Order Item": { - "doctype": "Delivery Note Item", + "doctype": "Delivery Note Item", "field_map": { - "rate": "rate", - "name": "prevdoc_detail_docname", - "parent": "against_sales_order", + "rate": "rate", + "name": "prevdoc_detail_docname", + "parent": "against_sales_order", }, "postprocess": update_item, "condition": lambda doc: doc.delivered_qty < doc.qty - }, + }, "Sales Taxes and Charges": { - "doctype": "Sales Taxes and Charges", + "doctype": "Sales Taxes and Charges", "add_if_empty": True - }, + }, "Sales Team": { "doctype": "Sales Team", "add_if_empty": True } - }, target_doclist, set_missing_values) - - return [d.fields for d in doclist] + }, target_doc, set_missing_values) + + return doclist @frappe.whitelist() -def make_sales_invoice(source_name, target_doclist=None): +def make_sales_invoice(source_name, target_doc=None): def set_missing_values(source, target): - bean = frappe.bean(target) - bean.doc.is_pos = 0 - bean.run_method("onload_post_render") - - def update_item(obj, target, source_parent): - target.amount = flt(obj.amount) - flt(obj.billed_amt) + doc = frappe.get_doc(target) + doc.is_pos = 0 + doc.run_method("onload_post_render") + + def update_item(source, target, source_parent): + target.amount = flt(source.amount) - flt(source.billed_amt) target.base_amount = target.amount * flt(source_parent.conversion_rate) - target.qty = obj.rate and target.amount / flt(obj.rate) or obj.qty - - doclist = get_mapped_doclist("Sales Order", source_name, { + target.qty = source.rate and target.amount / flt(source.rate) or obj.qty + + doclist = get_mapped_doc("Sales Order", source_name, { "Sales Order": { - "doctype": "Sales Invoice", + "doctype": "Sales Invoice", "validation": { "docstatus": ["=", 1] } - }, + }, "Sales Order Item": { - "doctype": "Sales Invoice Item", + "doctype": "Sales Invoice Item", "field_map": { - "name": "so_detail", - "parent": "sales_order", + "name": "so_detail", + "parent": "sales_order", }, "postprocess": update_item, "condition": lambda doc: doc.base_amount==0 or doc.billed_amt < doc.amount - }, + }, "Sales Taxes and Charges": { - "doctype": "Sales Taxes and Charges", + "doctype": "Sales Taxes and Charges", "add_if_empty": True - }, + }, "Sales Team": { - "doctype": "Sales Team", + "doctype": "Sales Team", "add_if_empty": True } - }, target_doclist, set_missing_values) - - return [d.fields for d in doclist] - + }, target_doc, set_missing_values) + + return doclist + @frappe.whitelist() -def make_maintenance_schedule(source_name, target_doclist=None): - maint_schedule = frappe.db.sql("""select t1.name - from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2 +def make_maintenance_schedule(source_name, target_doc=None): + maint_schedule = frappe.db.sql("""select t1.name + from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1""", source_name) - + if not maint_schedule: - doclist = get_mapped_doclist("Sales Order", source_name, { + doclist = get_mapped_doc("Sales Order", source_name, { "Sales Order": { - "doctype": "Maintenance Schedule", + "doctype": "Maintenance Schedule", "field_map": { "name": "sales_order_no" - }, + }, "validation": { "docstatus": ["=", 1] } - }, + }, "Sales Order Item": { - "doctype": "Maintenance Schedule Item", + "doctype": "Maintenance Schedule Item", "field_map": { "parent": "prevdoc_docname" }, "add_if_empty": True } - }, target_doclist) - - return [d.fields for d in doclist] - + }, target_doc) + + return doclist + @frappe.whitelist() -def make_maintenance_visit(source_name, target_doclist=None): - visit = frappe.db.sql("""select t1.name - from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 - where t2.parent=t1.name and t2.prevdoc_docname=%s +def make_maintenance_visit(source_name, target_doc=None): + visit = frappe.db.sql("""select t1.name + from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 + where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1 and t1.completion_status='Fully Completed'""", source_name) - + if not visit: - doclist = get_mapped_doclist("Sales Order", source_name, { + doclist = get_mapped_doc("Sales Order", source_name, { "Sales Order": { - "doctype": "Maintenance Visit", + "doctype": "Maintenance Visit", "field_map": { "name": "sales_order_no" }, "validation": { "docstatus": ["=", 1] } - }, + }, "Sales Order Item": { - "doctype": "Maintenance Visit Purpose", + "doctype": "Maintenance Visit Purpose", "field_map": { - "parent": "prevdoc_docname", + "parent": "prevdoc_docname", "parenttype": "prevdoc_doctype" }, "add_if_empty": True } - }, target_doclist) - - return [d.fields for d in doclist] + }, target_doc) + + return doclist diff --git a/erpnext/selling/doctype/sales_order/sales_order.txt b/erpnext/selling/doctype/sales_order/sales_order.txt deleted file mode 100644 index 01c2817306e..00000000000 --- a/erpnext/selling/doctype/sales_order/sales_order.txt +++ /dev/null @@ -1,942 +0,0 @@ -[ - { - "creation": "2013-06-18 12:39:59", - "docstatus": 0, - "modified": "2014-01-28 18:47:42", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-file-text", - "is_submittable": 1, - "issingle": 0, - "module": "Selling", - "name": "__common__", - "read_only_onload": 1, - "search_fields": "status,transaction_date,customer,customer_name, territory,order_type,company" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales Order", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Sales Order", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1 - }, - { - "doctype": "DocType", - "name": "Sales Order" - }, - { - "doctype": "DocField", - "fieldname": "customer_section", - "fieldtype": "Section Break", - "label": "Customer", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "in_filter": 0, - "oldfieldtype": "Column Break", - "search_index": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "PI/2011/\nSO\nSO/10-11/\nSO1112", - "print_hide": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "hidden": 0, - "label": "Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Text", - "hidden": 1, - "label": "Mobile No", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Text", - "hidden": 1, - "label": "Contact Email", - "print_hide": 1, - "read_only": 1 - }, - { - "default": "Sales", - "doctype": "DocField", - "fieldname": "order_type", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Order Type", - "oldfieldname": "order_type", - "oldfieldtype": "Select", - "options": "\nSales\nMaintenance", - "print_hide": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "hidden": 1, - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "width": "150px" - }, - { - "description": "Select the relevant company name if you have multiple companies.", - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "transaction_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Sales Order Date", - "no_copy": 1, - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "print_hide": 0, - "reqd": 1, - "search_index": 1, - "width": "160px" - }, - { - "depends_on": "eval:doc.order_type == 'Sales'", - "doctype": "DocField", - "fieldname": "delivery_date", - "fieldtype": "Date", - "hidden": 0, - "in_filter": 1, - "label": "Delivery Date", - "oldfieldname": "delivery_date", - "oldfieldtype": "Date", - "print_hide": 1, - "reqd": 0, - "search_index": 1, - "width": "160px" - }, - { - "description": "Customer's Purchase Order Number", - "doctype": "DocField", - "fieldname": "po_no", - "fieldtype": "Data", - "hidden": 0, - "label": "PO No", - "oldfieldname": "po_no", - "oldfieldtype": "Data", - "print_hide": 0, - "reqd": 0, - "width": "100px" - }, - { - "depends_on": "eval:doc.po_no", - "description": "Customer's Purchase Order Date", - "doctype": "DocField", - "fieldname": "po_date", - "fieldtype": "Date", - "hidden": 0, - "label": "PO Date", - "oldfieldname": "po_date", - "oldfieldtype": "Date", - "print_hide": 0, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "shipping_address_name", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "label": "Shipping Address", - "options": "Address", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "shipping_address", - "fieldtype": "Small Text", - "hidden": 1, - "in_filter": 0, - "label": "Shipping Address", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "sec_break45", - "fieldtype": "Section Break", - "label": "Currency and Price List", - "options": "icon-tag" - }, - { - "doctype": "DocField", - "fieldname": "currency", - "fieldtype": "Link", - "label": "Currency", - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "print_hide": 1, - "reqd": 1, - "width": "100px" - }, - { - "description": "Rate at which customer's currency is converted to company's base currency", - "doctype": "DocField", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "label": "Exchange Rate", - "oldfieldname": "conversion_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "selling_price_list", - "fieldtype": "Link", - "label": "Price List", - "oldfieldname": "price_list_name", - "oldfieldtype": "Select", - "options": "Price List", - "print_hide": 1, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "price_list_currency", - "fieldtype": "Link", - "label": "Price List Currency", - "options": "Currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "description": "Rate at which Price list currency is converted to company's base currency", - "doctype": "DocField", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "label": "Price List Exchange Rate", - "print_hide": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "items", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "sales_order_details", - "fieldtype": "Table", - "label": "Sales Order Items", - "oldfieldname": "sales_order_details", - "oldfieldtype": "Table", - "options": "Sales Order Item", - "print_hide": 0, - "reqd": 1 - }, - { - "description": "Display all the individual items delivered with the main items", - "doctype": "DocField", - "fieldname": "packing_list", - "fieldtype": "Section Break", - "hidden": 0, - "label": "Packing List", - "oldfieldtype": "Section Break", - "options": "icon-suitcase", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "packing_details", - "fieldtype": "Table", - "label": "Packing Details", - "oldfieldname": "packing_details", - "oldfieldtype": "Table", - "options": "Packed Item", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break_31", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total_export", - "fieldtype": "Currency", - "label": "Net Total", - "options": "currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_33", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total (Company Currency)", - "oldfieldname": "net_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "taxes", - "fieldtype": "Section Break", - "label": "Taxes and Charges", - "oldfieldtype": "Section Break", - "options": "icon-money", - "print_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "oldfieldname": "charge", - "oldfieldtype": "Link", - "options": "Sales Taxes and Charges Master", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_38", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "shipping_rule", - "fieldtype": "Link", - "label": "Shipping Rule", - "oldfieldtype": "Button", - "options": "Shipping Rule", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break_40", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "other_charges", - "fieldtype": "Table", - "label": "Sales Taxes and Charges", - "oldfieldname": "other_charges", - "oldfieldtype": "Table", - "options": "Sales Taxes and Charges" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_calculation", - "fieldtype": "HTML", - "label": "Taxes and Charges Calculation", - "oldfieldtype": "HTML", - "print_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_43", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_total_export", - "fieldtype": "Currency", - "label": "Taxes and Charges Total", - "options": "currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_46", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_total", - "fieldtype": "Currency", - "label": "Taxes and Charges Total (Company Currency)", - "oldfieldname": "other_charges_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "discount_amount", - "fieldtype": "Currency", - "label": "Discount Amount", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "Totals", - "oldfieldtype": "Section Break", - "options": "icon-money", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "grand_total_export", - "fieldtype": "Currency", - "label": "Grand Total", - "oldfieldname": "grand_total_export", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1, - "reqd": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "rounded_total_export", - "fieldtype": "Currency", - "label": "Rounded Total", - "oldfieldname": "rounded_total_export", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "in_words_export", - "fieldtype": "Data", - "label": "In Words", - "oldfieldname": "in_words_export", - "oldfieldtype": "Data", - "print_hide": 0, - "read_only": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "reqd": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total (Company Currency)", - "oldfieldname": "rounded_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1, - "width": "150px" - }, - { - "description": "In Words will be visible once you save the Sales Order.", - "doctype": "DocField", - "fieldname": "in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "oldfieldtype": "Section Break", - "options": "icon-legal", - "print_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "print_hide": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Terms and Conditions Details", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor", - "print_hide": 0 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_info", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn" - }, - { - "doctype": "DocField", - "fieldname": "col_break45", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "in_filter": 1, - "label": "Territory", - "options": "Territory", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "in_filter": 1, - "label": "Customer Group", - "options": "Customer Group", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break46", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "customer_address", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Customer Address", - "options": "Address", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "in_filter": 1, - "label": "Contact Person", - "options": "Contact", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text", - "print_hide": 1 - }, - { - "description": "Track this Sales Order against any Project", - "doctype": "DocField", - "fieldname": "project_name", - "fieldtype": "Link", - "in_filter": 1, - "label": "Project Name", - "oldfieldname": "project_name", - "oldfieldtype": "Link", - "options": "Project", - "search_index": 1 - }, - { - "depends_on": "eval:doc.source == 'Campaign'", - "doctype": "DocField", - "fieldname": "campaign", - "fieldtype": "Link", - "label": "Campaign", - "oldfieldname": "campaign", - "oldfieldtype": "Link", - "options": "Campaign", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "source", - "fieldtype": "Select", - "label": "Source", - "oldfieldname": "source", - "oldfieldtype": "Select", - "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "width": "50%" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Select", - "label": "Letter Head", - "oldfieldname": "letter_head", - "oldfieldtype": "Select", - "options": "link:Letter Head", - "print_hide": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "print_hide": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "section_break_78", - "fieldtype": "Section Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "width": "50%" - }, - { - "default": "Draft", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nDraft\nSubmitted\nStopped\nCancelled", - "print_hide": 1, - "read_only": 1, - "reqd": 1, - "search_index": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "delivery_status", - "fieldtype": "Select", - "hidden": 1, - "label": "Delivery Status", - "no_copy": 1, - "options": "Delivered\nNot Delivered\nPartly Delivered\nClosed\nNot Applicable", - "print_hide": 1 - }, - { - "depends_on": "eval:!doc.__islocal", - "description": "% of materials delivered against this Sales Order", - "doctype": "DocField", - "fieldname": "per_delivered", - "fieldtype": "Percent", - "in_filter": 1, - "in_list_view": 1, - "label": "% Delivered", - "no_copy": 1, - "oldfieldname": "per_delivered", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "column_break_81", - "fieldtype": "Column Break" - }, - { - "depends_on": "eval:!doc.__islocal", - "description": "% of materials billed against this Sales Order", - "doctype": "DocField", - "fieldname": "per_billed", - "fieldtype": "Percent", - "in_filter": 1, - "in_list_view": 1, - "label": "% Amount Billed", - "no_copy": 1, - "oldfieldname": "per_billed", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "billing_status", - "fieldtype": "Select", - "hidden": 1, - "label": "Billing Status", - "no_copy": 1, - "options": "Billed\nNot Billed\nPartly Billed\nClosed", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "sales_team_section_break", - "fieldtype": "Section Break", - "label": "Sales Team", - "oldfieldtype": "Section Break", - "options": "icon-group", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "sales_partner", - "fieldtype": "Link", - "in_filter": 1, - "label": "Sales Partner", - "oldfieldname": "sales_partner", - "oldfieldtype": "Link", - "options": "Sales Partner", - "print_hide": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "column_break7", - "fieldtype": "Column Break", - "print_hide": 1, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "commission_rate", - "fieldtype": "Float", - "label": "Commission Rate", - "oldfieldname": "commission_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "total_commission", - "fieldtype": "Currency", - "label": "Total Commission", - "oldfieldname": "total_commission", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break1", - "fieldtype": "Section Break", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "sales_team", - "fieldtype": "Table", - "label": "Sales Team1", - "oldfieldname": "sales_team", - "oldfieldtype": "Table", - "options": "Sales Team", - "print_hide": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "report": 1, - "role": "Sales User", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "report": 1, - "role": "Maintenance User", - "submit": 1, - "write": 1 - }, - { - "cancel": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Accounts User" - }, - { - "cancel": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Customer" - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order/test_records.json b/erpnext/selling/doctype/sales_order/test_records.json new file mode 100644 index 00000000000..88af30c1f9f --- /dev/null +++ b/erpnext/selling/doctype/sales_order/test_records.json @@ -0,0 +1,36 @@ +[ + { + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_group": "_Test Customer Group", + "customer_name": "_Test Customer", + "delivery_date": "2013-02-23", + "doctype": "Sales Order", + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 1000.0, + "grand_total_export": 1000.0, + "naming_series": "_T-Sales Order-", + "order_type": "Sales", + "plc_conversion_rate": 1.0, + "price_list_currency": "INR", + "sales_order_details": [ + { + "base_amount": 1000.0, + "base_rate": 100.0, + "description": "CPU", + "doctype": "Sales Order Item", + "item_code": "_Test Item Home Desktop 100", + "item_name": "CPU", + "parentfield": "sales_order_details", + "qty": 10.0, + "rate": 100.0, + "warehouse": "_Test Warehouse - _TC" + } + ], + "selling_price_list": "_Test Price List", + "territory": "_Test Territory", + "transaction_date": "2013-02-21" + } +] \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index e325aeb1eaa..52bde1e880a 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -4,339 +4,306 @@ import frappe from frappe.utils import flt import unittest +import copy class TestSalesOrder(unittest.TestCase): def tearDown(self): frappe.set_user("Administrator") - + def test_make_material_request(self): from erpnext.selling.doctype.sales_order.sales_order import make_material_request - - so = frappe.bean(copy=test_records[0]).insert() - - self.assertRaises(frappe.ValidationError, make_material_request, - so.doc.name) - sales_order = frappe.bean("Sales Order", so.doc.name) + so = frappe.copy_doc(test_records[0]).insert() + + self.assertRaises(frappe.ValidationError, make_material_request, + so.name) + + sales_order = frappe.get_doc("Sales Order", so.name) sales_order.submit() - mr = make_material_request(so.doc.name) - - self.assertEquals(mr[0]["material_request_type"], "Purchase") - self.assertEquals(len(mr), len(sales_order.doclist)) + mr = make_material_request(so.name) + + self.assertEquals(mr.material_request_type, "Purchase") + self.assertEquals(len(mr.get("indent_details")), len(sales_order.get("sales_order_details"))) def test_make_delivery_note(self): from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note - so = frappe.bean(copy=test_records[0]).insert() + so = frappe.copy_doc(test_records[0]).insert() - self.assertRaises(frappe.ValidationError, make_delivery_note, - so.doc.name) + self.assertRaises(frappe.ValidationError, make_delivery_note, + so.name) - sales_order = frappe.bean("Sales Order", so.doc.name) + sales_order = frappe.get_doc("Sales Order", so.name) sales_order.submit() - dn = make_delivery_note(so.doc.name) - - self.assertEquals(dn[0]["doctype"], "Delivery Note") - self.assertEquals(len(dn), len(sales_order.doclist)) + dn = make_delivery_note(so.name) + + self.assertEquals(dn.doctype, "Delivery Note") + self.assertEquals(len(dn.get("delivery_note_details")), len(sales_order.get("sales_order_details"))) def test_make_sales_invoice(self): from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice - so = frappe.bean(copy=test_records[0]).insert() + so = frappe.copy_doc(test_records[0]).insert() - self.assertRaises(frappe.ValidationError, make_sales_invoice, - so.doc.name) + self.assertRaises(frappe.ValidationError, make_sales_invoice, + so.name) - sales_order = frappe.bean("Sales Order", so.doc.name) + sales_order = frappe.get_doc("Sales Order", so.name) sales_order.submit() - si = make_sales_invoice(so.doc.name) - - self.assertEquals(si[0]["doctype"], "Sales Invoice") - self.assertEquals(len(si), len(sales_order.doclist)) - self.assertEquals(len([d for d in si if d["doctype"]=="Sales Invoice Item"]), 1) - - si = frappe.bean(si) - si.doc.posting_date = "2013-10-10" + si = make_sales_invoice(so.name) + + self.assertEquals(si.doctype, "Sales Invoice") + self.assertEquals(len(si.get("entries")), len(sales_order.get("sales_order_details"))) + self.assertEquals(len(si.get("entries")), 1) + + si.posting_date = "2013-10-10" si.insert() si.submit() - si1 = make_sales_invoice(so.doc.name) - self.assertEquals(len([d for d in si1 if d["doctype"]=="Sales Invoice Item"]), 0) - + si1 = make_sales_invoice(so.name) + self.assertEquals(len(si1.get("entries")), 0) - def create_so(self, so_doclist = None): - if not so_doclist: - so_doclist = test_records[0] - - w = frappe.bean(copy=so_doclist) + + def create_so(self, so_doc = None): + if not so_doc: + so_doc = test_records[0] + + w = frappe.copy_doc(so_doc) w.insert() w.submit() return w - + def create_dn_against_so(self, so, delivered_qty=0): from erpnext.stock.doctype.delivery_note.test_delivery_note import test_records as dn_test_records from erpnext.stock.doctype.delivery_note.test_delivery_note import _insert_purchase_receipt - _insert_purchase_receipt(so.doclist[1].item_code) - - dn = frappe.bean(frappe.copy_doclist(dn_test_records[0])) - dn.doclist[1].item_code = so.doclist[1].item_code - dn.doclist[1].against_sales_order = so.doc.name - dn.doclist[1].prevdoc_detail_docname = so.doclist[1].name + _insert_purchase_receipt(so.get("sales_order_details")[0].item_code) + + dn = frappe.get_doc(frappe.copy_doc(dn_test_records[0])) + dn.get("delivery_note_details")[0].item_code = so.get("sales_order_details")[0].item_code + dn.get("delivery_note_details")[0].against_sales_order = so.name + dn.get("delivery_note_details")[0].prevdoc_detail_docname = so.get("sales_order_details")[0].name if delivered_qty: - dn.doclist[1].qty = delivered_qty + dn.get("delivery_note_details")[0].qty = delivered_qty dn.insert() dn.submit() return dn - + def get_bin_reserved_qty(self, item_code, warehouse): - return flt(frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse}, + return flt(frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse}, "reserved_qty")) - + def delete_bin(self, item_code, warehouse): - bin = frappe.db.exists({"doctype": "Bin", "item_code": item_code, + bin = frappe.db.exists({"doctype": "Bin", "item_code": item_code, "warehouse": warehouse}) if bin: frappe.delete_doc("Bin", bin[0][0]) - + def check_reserved_qty(self, item_code, warehouse, qty): bin_reserved_qty = self.get_bin_reserved_qty(item_code, warehouse) self.assertEqual(bin_reserved_qty, qty) - + def test_reserved_qty_for_so(self): # reset bin - self.delete_bin(test_records[0][1]["item_code"], test_records[0][1]["warehouse"]) - + so_item = test_records[0]["sales_order_details"][0].copy() + self.delete_bin(so_item["item_code"], so_item["warehouse"]) + # submit so = self.create_so() - self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 10.0) - + self.check_reserved_qty(so.get("sales_order_details")[0].item_code, so.get("sales_order_details")[0].warehouse, 10.0) + # cancel so.cancel() - self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 0.0) - - + self.check_reserved_qty(so.get("sales_order_details")[0].item_code, so.get("sales_order_details")[0].warehouse, 0.0) + + def test_reserved_qty_for_partial_delivery(self): # reset bin - self.delete_bin(test_records[0][1]["item_code"], test_records[0][1]["warehouse"]) - + so_item = test_records[0]["sales_order_details"][0].copy() + self.delete_bin(so_item["item_code"], so_item["warehouse"]) + # submit so so = self.create_so() - + # allow negative stock frappe.db.set_default("allow_negative_stock", 1) - + # submit dn dn = self.create_dn_against_so(so) - - self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 5.0) - + + self.check_reserved_qty(so.get("sales_order_details")[0].item_code, so.get("sales_order_details")[0].warehouse, 5.0) + # stop so so.load_from_db() - so.obj.stop_sales_order() - self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 0.0) - + so.stop_sales_order() + self.check_reserved_qty(so.get("sales_order_details")[0].item_code, so.get("sales_order_details")[0].warehouse, 0.0) + # unstop so so.load_from_db() - so.obj.unstop_sales_order() - self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 5.0) - + so.unstop_sales_order() + self.check_reserved_qty(so.get("sales_order_details")[0].item_code, so.get("sales_order_details")[0].warehouse, 5.0) + # cancel dn dn.cancel() - self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 10.0) - + self.check_reserved_qty(so.get("sales_order_details")[0].item_code, so.get("sales_order_details")[0].warehouse, 10.0) + def test_reserved_qty_for_over_delivery(self): # reset bin - self.delete_bin(test_records[0][1]["item_code"], test_records[0][1]["warehouse"]) - + so_item = test_records[0]["sales_order_details"][0].copy() + self.delete_bin(so_item["item_code"], so_item["warehouse"]) + # submit so so = self.create_so() - + # allow negative stock frappe.db.set_default("allow_negative_stock", 1) - + # set over-delivery tolerance - frappe.db.set_value('Item', so.doclist[1].item_code, 'tolerance', 50) - + frappe.db.set_value('Item', so.get("sales_order_details")[0].item_code, 'tolerance', 50) + # submit dn dn = self.create_dn_against_so(so, 15) - self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 0.0) + self.check_reserved_qty(so.get("sales_order_details")[0].item_code, so.get("sales_order_details")[0].warehouse, 0.0) # cancel dn dn.cancel() - self.check_reserved_qty(so.doclist[1].item_code, so.doclist[1].warehouse, 10.0) - + self.check_reserved_qty(so.get("sales_order_details")[0].item_code, so.get("sales_order_details")[0].warehouse, 10.0) + def test_reserved_qty_for_so_with_packing_list(self): from erpnext.selling.doctype.sales_bom.test_sales_bom import test_records as sbom_test_records - + # change item in test so record - test_record = test_records[0][:] - test_record[1]["item_code"] = "_Test Sales BOM Item" - + test_record = copy.deepcopy(test_records[0]) + test_record["sales_order_details"][0]["item_code"] = "_Test Sales BOM Item" + # reset bin - self.delete_bin(sbom_test_records[0][1]["item_code"], test_record[1]["warehouse"]) - self.delete_bin(sbom_test_records[0][2]["item_code"], test_record[1]["warehouse"]) - + self.delete_bin(sbom_test_records[0]["sales_bom_items"][0]["item_code"], test_record.get("sales_order_details")[0]["warehouse"]) + self.delete_bin(sbom_test_records[0]["sales_bom_items"][1]["item_code"], test_record.get("sales_order_details")[0]["warehouse"]) + # submit so = self.create_so(test_record) - - - self.check_reserved_qty(sbom_test_records[0][1]["item_code"], - so.doclist[1].warehouse, 50.0) - self.check_reserved_qty(sbom_test_records[0][2]["item_code"], - so.doclist[1].warehouse, 20.0) - + + + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][0]["item_code"], + so.get("sales_order_details")[0].warehouse, 50.0) + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][1]["item_code"], + so.get("sales_order_details")[0].warehouse, 20.0) + # cancel so.cancel() - self.check_reserved_qty(sbom_test_records[0][1]["item_code"], - so.doclist[1].warehouse, 0.0) - self.check_reserved_qty(sbom_test_records[0][2]["item_code"], - so.doclist[1].warehouse, 0.0) - + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][0]["item_code"], + so.get("sales_order_details")[0].warehouse, 0.0) + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][1]["item_code"], + so.get("sales_order_details")[0].warehouse, 0.0) + def test_reserved_qty_for_partial_delivery_with_packing_list(self): from erpnext.selling.doctype.sales_bom.test_sales_bom import test_records as sbom_test_records - + # change item in test so record - - test_record = frappe.copy_doclist(test_records[0]) - test_record[1]["item_code"] = "_Test Sales BOM Item" + + test_record = frappe.copy_doc(test_records[0]) + test_record.get("sales_order_details")[0].item_code = "_Test Sales BOM Item" # reset bin - self.delete_bin(sbom_test_records[0][1]["item_code"], test_record[1]["warehouse"]) - self.delete_bin(sbom_test_records[0][2]["item_code"], test_record[1]["warehouse"]) - + self.delete_bin(sbom_test_records[0]["sales_bom_items"][0]["item_code"], test_record.get("sales_order_details")[0].warehouse) + self.delete_bin(sbom_test_records[0]["sales_bom_items"][1]["item_code"], test_record.get("sales_order_details")[0].warehouse) + # submit so = self.create_so(test_record) - + # allow negative stock frappe.db.set_default("allow_negative_stock", 1) - + # submit dn dn = self.create_dn_against_so(so) - - self.check_reserved_qty(sbom_test_records[0][1]["item_code"], - so.doclist[1].warehouse, 25.0) - self.check_reserved_qty(sbom_test_records[0][2]["item_code"], - so.doclist[1].warehouse, 10.0) - + + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][0]["item_code"], + so.get("sales_order_details")[0].warehouse, 25.0) + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][1]["item_code"], + so.get("sales_order_details")[0].warehouse, 10.0) + # stop so so.load_from_db() - so.obj.stop_sales_order() - - self.check_reserved_qty(sbom_test_records[0][1]["item_code"], - so.doclist[1].warehouse, 0.0) - self.check_reserved_qty(sbom_test_records[0][2]["item_code"], - so.doclist[1].warehouse, 0.0) - + so.stop_sales_order() + + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][0]["item_code"], + so.get("sales_order_details")[0].warehouse, 0.0) + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][1]["item_code"], + so.get("sales_order_details")[0].warehouse, 0.0) + # unstop so so.load_from_db() - so.obj.unstop_sales_order() - self.check_reserved_qty(sbom_test_records[0][1]["item_code"], - so.doclist[1].warehouse, 25.0) - self.check_reserved_qty(sbom_test_records[0][2]["item_code"], - so.doclist[1].warehouse, 10.0) - + so.unstop_sales_order() + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][0]["item_code"], + so.get("sales_order_details")[0].warehouse, 25.0) + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][1]["item_code"], + so.get("sales_order_details")[0].warehouse, 10.0) + # cancel dn dn.cancel() - self.check_reserved_qty(sbom_test_records[0][1]["item_code"], - so.doclist[1].warehouse, 50.0) - self.check_reserved_qty(sbom_test_records[0][2]["item_code"], - so.doclist[1].warehouse, 20.0) - + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][0]["item_code"], + so.get("sales_order_details")[0].warehouse, 50.0) + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][1]["item_code"], + so.get("sales_order_details")[0].warehouse, 20.0) + def test_reserved_qty_for_over_delivery_with_packing_list(self): from erpnext.selling.doctype.sales_bom.test_sales_bom import test_records as sbom_test_records - + # change item in test so record - test_record = frappe.copy_doclist(test_records[0]) - test_record[1]["item_code"] = "_Test Sales BOM Item" + test_record = frappe.copy_doc(test_records[0]) + test_record.get("sales_order_details")[0].item_code = "_Test Sales BOM Item" # reset bin - self.delete_bin(sbom_test_records[0][1]["item_code"], test_record[1]["warehouse"]) - self.delete_bin(sbom_test_records[0][2]["item_code"], test_record[1]["warehouse"]) - + self.delete_bin(sbom_test_records[0]["sales_bom_items"][0]["item_code"], test_record.get("sales_order_details")[0].warehouse) + self.delete_bin(sbom_test_records[0]["sales_bom_items"][1]["item_code"], test_record.get("sales_order_details")[0].warehouse) + # submit so = self.create_so(test_record) - + # allow negative stock frappe.db.set_default("allow_negative_stock", 1) - + # set over-delivery tolerance - frappe.db.set_value('Item', so.doclist[1].item_code, 'tolerance', 50) - + frappe.db.set_value('Item', so.get("sales_order_details")[0].item_code, 'tolerance', 50) + # submit dn dn = self.create_dn_against_so(so, 15) - - self.check_reserved_qty(sbom_test_records[0][1]["item_code"], - so.doclist[1].warehouse, 0.0) - self.check_reserved_qty(sbom_test_records[0][2]["item_code"], - so.doclist[1].warehouse, 0.0) + + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][0]["item_code"], + so.get("sales_order_details")[0].warehouse, 0.0) + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][1]["item_code"], + so.get("sales_order_details")[0].warehouse, 0.0) # cancel dn dn.cancel() - self.check_reserved_qty(sbom_test_records[0][1]["item_code"], - so.doclist[1].warehouse, 50.0) - self.check_reserved_qty(sbom_test_records[0][2]["item_code"], - so.doclist[1].warehouse, 20.0) + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][0]["item_code"], + so.get("sales_order_details")[0].warehouse, 50.0) + self.check_reserved_qty(sbom_test_records[0]["sales_bom_items"][1]["item_code"], + so.get("sales_order_details")[0].warehouse, 20.0) def test_warehouse_user(self): frappe.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", "Restriction") - frappe.bean("User", "test@example.com").get_controller()\ + frappe.get_doc("User", "test@example.com")\ .add_roles("Sales User", "Sales Manager", "Material User", "Material Manager") - - frappe.bean("User", "test2@example.com").get_controller()\ + + frappe.get_doc("User", "test2@example.com")\ .add_roles("Sales User", "Sales Manager", "Material User", "Material Manager") - + frappe.set_user("test@example.com") - from frappe.model.bean import BeanPermissionError - so = frappe.bean(copy = test_records[0]) - so.doc.company = "_Test Company 1" - so.doc.conversion_rate = 0.02 - so.doc.plc_conversion_rate = 0.02 - so.doclist[1].warehouse = "_Test Warehouse 2 - _TC1" - self.assertRaises(BeanPermissionError, so.insert) + so = frappe.copy_doc(test_records[0]) + so.company = "_Test Company 1" + so.conversion_rate = 0.02 + so.plc_conversion_rate = 0.02 + so.get("sales_order_details")[0].warehouse = "_Test Warehouse 2 - _TC1" + self.assertRaises(frappe.PermissionError, so.insert) frappe.set_user("test2@example.com") so.insert() - + frappe.defaults.clear_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", parenttype="Restriction") test_dependencies = ["Sales BOM", "Currency Exchange"] - -test_records = [ - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "customer_group": "_Test Customer Group", - "doctype": "Sales Order", - "fiscal_year": "_Test Fiscal Year 2013", - "order_type": "Sales", - "delivery_date": "2013-02-23", - "plc_conversion_rate": 1.0, - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "territory": "_Test Territory", - "transaction_date": "2013-02-21", - "grand_total": 1000.0, - "grand_total_export": 1000.0, - "naming_series": "_T-Sales Order-" - }, - { - "description": "CPU", - "doctype": "Sales Order Item", - "item_code": "_Test Item Home Desktop 100", - "item_name": "CPU", - "parentfield": "sales_order_details", - "qty": 10.0, - "base_rate": 100.0, - "rate": 100.0, - "base_amount": 1000.0, - "warehouse": "_Test Warehouse - _TC", - } - ], -] \ No newline at end of file + +test_records = frappe.get_test_records('Sales Order') diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.json b/erpnext/selling/doctype/sales_order_item/sales_order_item.json new file mode 100644 index 00000000000..9d0ae0e031a --- /dev/null +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json @@ -0,0 +1,447 @@ +{ + "autoname": "SOD/.#####", + "creation": "2013-03-07 11:42:58.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_width": "150px", + "read_only": 0, + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "customer_item_code", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Customer's Item Code", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_list_view": 0, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150", + "read_only": 0, + "reqd": 1, + "width": "150" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_filter": 1, + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 0, + "reqd": 1, + "search_index": 1, + "width": "300px" + }, + { + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Quantity and Rate", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Quantity", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate", + "oldfieldname": "ref_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "70px", + "read_only": 1, + "reqd": 0, + "width": "70px" + }, + { + "fieldname": "discount_percentage", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Discount(%)", + "oldfieldname": "adj_rate", + "oldfieldtype": "Float", + "permlevel": 0, + "print_hide": 1, + "print_width": "70px", + "read_only": 0, + "width": "70px" + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "hidden": 0, + "in_list_view": 0, + "label": "UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "print_width": "70px", + "read_only": 1, + "reqd": 0, + "width": "70px" + }, + { + "fieldname": "base_price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate (Company Currency)", + "oldfieldname": "base_ref_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "width": "100px" + }, + { + "fieldname": "section_break_simple1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "rate", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "export_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "no_copy": 0, + "oldfieldname": "export_amount", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "base_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Basic Rate (Company Currency)", + "oldfieldname": "basic_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "base_amount", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Amount (Company Currency)", + "no_copy": 0, + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "pricing_rule_for_price", + "fieldtype": "Link", + "label": "Pricing Rule For Price", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "pricing_rule_for_discount", + "fieldtype": "Link", + "label": "Pricing Rule For Discount", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "warehouse_and_reference", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Warehouse and Reference", + "permlevel": 0 + }, + { + "fieldname": "warehouse", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Reserved Warehouse", + "no_copy": 0, + "oldfieldname": "reserved_warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 0, + "reqd": 0, + "width": "150px" + }, + { + "fieldname": "prevdoc_docname", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "in_list_view": 0, + "label": "Quotation", + "no_copy": 1, + "oldfieldname": "prevdoc_docname", + "oldfieldtype": "Link", + "options": "Quotation", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "brand", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "Brand Name", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "in_list_view": 0, + "label": "Page Break", + "oldfieldname": "page_break", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "projected_qty", + "fieldtype": "Float", + "hidden": 1, + "in_list_view": 0, + "label": "Projected Qty", + "no_copy": 1, + "oldfieldname": "projected_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "70px", + "read_only": 1, + "width": "70px" + }, + { + "fieldname": "actual_qty", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Actual Qty", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "print_width": "70px", + "read_only": 1, + "width": "70px" + }, + { + "fieldname": "delivered_qty", + "fieldtype": "Float", + "hidden": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Delivered Qty", + "no_copy": 1, + "oldfieldname": "delivered_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "billed_amt", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Billed Amt", + "no_copy": 1, + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "For Production", + "fieldname": "planned_qty", + "fieldtype": "Float", + "hidden": 1, + "in_list_view": 0, + "label": "Planned Quantity", + "no_copy": 1, + "oldfieldname": "planned_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "50px", + "read_only": 1, + "report_hide": 1, + "width": "50px" + }, + { + "description": "For Production", + "fieldname": "produced_qty", + "fieldtype": "Float", + "hidden": 1, + "in_list_view": 0, + "label": "Produced Quantity", + "oldfieldname": "produced_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "50px", + "read_only": 1, + "report_hide": 1, + "width": "50px" + }, + { + "fieldname": "item_tax_rate", + "fieldtype": "Small Text", + "hidden": 1, + "in_list_view": 0, + "label": "Item Tax Rate", + "oldfieldname": "item_tax_rate", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1 + }, + { + "fieldname": "transaction_date", + "fieldtype": "Date", + "hidden": 1, + "in_filter": 0, + "in_list_view": 0, + "label": "Sales Order Date", + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1, + "search_index": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-28 11:20:05.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Order Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.py b/erpnext/selling/doctype/sales_order_item/sales_order_item.py index 26c87f1c04a..ef2ad098eca 100644 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.py +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesOrderItem(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.txt b/erpnext/selling/doctype/sales_order_item/sales_order_item.txt deleted file mode 100644 index 7e471e497c0..00000000000 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.txt +++ /dev/null @@ -1,460 +0,0 @@ -[ - { - "creation": "2013-03-07 11:42:58", - "docstatus": 0, - "modified": "2014-02-28 11:20:05", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "SOD/.#####", - "doctype": "DocType", - "istable": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales Order Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Sales Order Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "print_width": "150px", - "read_only": 0, - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "customer_item_code", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Customer's Item Code", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_list_view": 0, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150", - "read_only": 0, - "reqd": 1, - "width": "150" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_filter": 1, - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "print_width": "300px", - "read_only": 0, - "reqd": 1, - "search_index": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Quantity and Rate" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Quantity", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate", - "oldfieldname": "ref_rate", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "print_width": "70px", - "read_only": 1, - "reqd": 0, - "width": "70px" - }, - { - "doctype": "DocField", - "fieldname": "discount_percentage", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Discount(%)", - "oldfieldname": "adj_rate", - "oldfieldtype": "Float", - "print_hide": 1, - "print_width": "70px", - "read_only": 0, - "width": "70px" - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "hidden": 0, - "in_list_view": 0, - "label": "UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "print_width": "70px", - "read_only": 1, - "reqd": 0, - "width": "70px" - }, - { - "doctype": "DocField", - "fieldname": "base_price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate (Company Currency)", - "oldfieldname": "base_ref_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "section_break_simple1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "export_rate", - "oldfieldtype": "Currency", - "options": "currency", - "print_width": "100px", - "read_only": 0, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "no_copy": 0, - "oldfieldname": "export_amount", - "oldfieldtype": "Currency", - "options": "currency", - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "base_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Basic Rate (Company Currency)", - "oldfieldname": "basic_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "base_amount", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Amount (Company Currency)", - "no_copy": 0, - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_price", - "fieldtype": "Link", - "label": "Pricing Rule For Price", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_discount", - "fieldtype": "Link", - "label": "Pricing Rule For Discount", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "warehouse_and_reference", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Warehouse and Reference" - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Reserved Warehouse", - "no_copy": 0, - "oldfieldname": "reserved_warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "print_width": "150px", - "read_only": 0, - "reqd": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_docname", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "in_list_view": 0, - "label": "Quotation", - "no_copy": 1, - "oldfieldname": "prevdoc_docname", - "oldfieldtype": "Link", - "options": "Quotation", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "Brand Name", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "page_break", - "fieldtype": "Check", - "in_list_view": 0, - "label": "Page Break", - "oldfieldname": "page_break", - "oldfieldtype": "Check", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break4", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "projected_qty", - "fieldtype": "Float", - "hidden": 1, - "in_list_view": 0, - "label": "Projected Qty", - "no_copy": 1, - "oldfieldname": "projected_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "70px", - "read_only": 1, - "width": "70px" - }, - { - "doctype": "DocField", - "fieldname": "actual_qty", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Actual Qty", - "no_copy": 1, - "print_hide": 1, - "print_width": "70px", - "read_only": 1, - "width": "70px" - }, - { - "doctype": "DocField", - "fieldname": "delivered_qty", - "fieldtype": "Float", - "hidden": 0, - "in_filter": 0, - "in_list_view": 0, - "label": "Delivered Qty", - "no_copy": 1, - "oldfieldname": "delivered_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "billed_amt", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Billed Amt", - "no_copy": 1, - "options": "currency", - "print_hide": 1, - "read_only": 1 - }, - { - "description": "For Production", - "doctype": "DocField", - "fieldname": "planned_qty", - "fieldtype": "Float", - "hidden": 1, - "in_list_view": 0, - "label": "Planned Quantity", - "no_copy": 1, - "oldfieldname": "planned_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "50px", - "read_only": 1, - "report_hide": 1, - "width": "50px" - }, - { - "description": "For Production", - "doctype": "DocField", - "fieldname": "produced_qty", - "fieldtype": "Float", - "hidden": 1, - "in_list_view": 0, - "label": "Produced Quantity", - "oldfieldname": "produced_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "50px", - "read_only": 1, - "report_hide": 1, - "width": "50px" - }, - { - "doctype": "DocField", - "fieldname": "item_tax_rate", - "fieldtype": "Small Text", - "hidden": 1, - "in_list_view": 0, - "label": "Item Tax Rate", - "oldfieldname": "item_tax_rate", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "transaction_date", - "fieldtype": "Date", - "hidden": 1, - "in_filter": 0, - "in_list_view": 0, - "label": "Sales Order Date", - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 1, - "report_hide": 1, - "search_index": 0 - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_team/sales_team.json b/erpnext/selling/doctype/sales_team/sales_team.json new file mode 100644 index 00000000000..dda6046e7e9 --- /dev/null +++ b/erpnext/selling/doctype/sales_team/sales_team.json @@ -0,0 +1,107 @@ +{ + "creation": "2013-04-19 13:30:51.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "sales_person", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Sales Person", + "oldfieldname": "sales_person", + "oldfieldtype": "Link", + "options": "Sales Person", + "permlevel": 0, + "print_width": "200px", + "reqd": 1, + "search_index": 1, + "width": "200px" + }, + { + "fieldname": "sales_designation", + "fieldtype": "Data", + "hidden": 0, + "in_list_view": 1, + "label": "Designation", + "oldfieldname": "sales_designation", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "100px", + "width": "100px" + }, + { + "fieldname": "contact_no", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 1, + "label": "Contact No.", + "oldfieldname": "contact_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "100px", + "width": "100px" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "allocated_percentage", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Contribution (%)", + "oldfieldname": "allocated_percentage", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "100px", + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "allocated_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Contribution to Net Total", + "oldfieldname": "allocated_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_width": "120px", + "read_only": 1, + "reqd": 0, + "width": "120px" + }, + { + "fieldname": "incentives", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Incentives", + "oldfieldname": "incentives", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "parenttype", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "in_list_view": 0, + "label": "Parenttype", + "oldfieldname": "parenttype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "search_index": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-31 19:00:14.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Team", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_team/sales_team.py b/erpnext/selling/doctype/sales_team/sales_team.py index 26c87f1c04a..01d38d26142 100644 --- a/erpnext/selling/doctype/sales_team/sales_team.py +++ b/erpnext/selling/doctype/sales_team/sales_team.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SalesTeam(Document): + pass \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_team/sales_team.txt b/erpnext/selling/doctype/sales_team/sales_team.txt deleted file mode 100644 index d012cb41c1f..00000000000 --- a/erpnext/selling/doctype/sales_team/sales_team.txt +++ /dev/null @@ -1,120 +0,0 @@ -[ - { - "creation": "2013-04-19 13:30:51", - "docstatus": 0, - "modified": "2013-12-31 19:00:14", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales Team", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Sales Team" - }, - { - "doctype": "DocField", - "fieldname": "sales_person", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Sales Person", - "oldfieldname": "sales_person", - "oldfieldtype": "Link", - "options": "Sales Person", - "print_width": "200px", - "reqd": 1, - "search_index": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "sales_designation", - "fieldtype": "Data", - "hidden": 0, - "in_list_view": 1, - "label": "Designation", - "oldfieldname": "sales_designation", - "oldfieldtype": "Data", - "print_width": "100px", - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "contact_no", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 1, - "label": "Contact No.", - "oldfieldname": "contact_no", - "oldfieldtype": "Data", - "print_width": "100px", - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "allocated_percentage", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Contribution (%)", - "oldfieldname": "allocated_percentage", - "oldfieldtype": "Currency", - "print_width": "100px", - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "allocated_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Contribution to Net Total", - "oldfieldname": "allocated_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_width": "120px", - "read_only": 1, - "reqd": 0, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "incentives", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Incentives", - "oldfieldname": "incentives", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "parenttype", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "in_list_view": 0, - "label": "Parenttype", - "oldfieldname": "parenttype", - "oldfieldtype": "Data", - "print_hide": 1, - "search_index": 1 - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.json b/erpnext/selling/doctype/selling_settings/selling_settings.json new file mode 100644 index 00000000000..ade8449d4c4 --- /dev/null +++ b/erpnext/selling/doctype/selling_settings/selling_settings.json @@ -0,0 +1,90 @@ +{ + "creation": "2013-06-25 10:25:16.000000", + "description": "Settings for Selling Module", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Other", + "fields": [ + { + "default": "Customer Name", + "fieldname": "cust_master_name", + "fieldtype": "Select", + "label": "Customer Naming By", + "options": "Customer Name\nNaming Series", + "permlevel": 0 + }, + { + "description": "Add / Edit", + "fieldname": "customer_group", + "fieldtype": "Link", + "label": "Default Customer Group", + "options": "Customer Group", + "permlevel": 0 + }, + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "label": "Default Territory", + "options": "Territory", + "permlevel": 0 + }, + { + "fieldname": "selling_price_list", + "fieldtype": "Link", + "label": "Default Price List", + "options": "Price List", + "permlevel": 0 + }, + { + "fieldname": "column_break_5", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "so_required", + "fieldtype": "Select", + "label": "Sales Order Required", + "options": "No\nYes", + "permlevel": 0 + }, + { + "fieldname": "dn_required", + "fieldtype": "Select", + "label": "Delivery Note Required", + "options": "No\nYes", + "permlevel": 0 + }, + { + "fieldname": "maintain_same_sales_rate", + "fieldtype": "Check", + "label": "Maintain Same Rate Throughout Sales Cycle", + "permlevel": 0 + }, + { + "fieldname": "editable_price_list_rate", + "fieldtype": "Check", + "label": "Allow user to edit Price List Rate in transactions", + "permlevel": 0 + } + ], + "icon": "icon-cog", + "idx": 1, + "issingle": 1, + "modified": "2014-02-19 18:35:36.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Selling Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "System Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.py b/erpnext/selling/doctype/selling_settings/selling_settings.py index 5b44c7b6a66..69273e08772 100644 --- a/erpnext/selling/doctype/selling_settings/selling_settings.py +++ b/erpnext/selling/doctype/selling_settings/selling_settings.py @@ -6,15 +6,15 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class SellingSettings(Document): def validate(self): for key in ["cust_master_name", "customer_group", "territory", "maintain_same_sales_rate", "editable_price_list_rate", "selling_price_list"]: - frappe.db.set_default(key, self.doc.fields.get(key, "")) + frappe.db.set_default(key, self.get(key, "")) from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series set_by_naming_series("Customer", "customer_name", - self.doc.get("cust_master_name")=="Naming Series", hide_name_field=False) + self.get("cust_master_name")=="Naming Series", hide_name_field=False) diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.txt b/erpnext/selling/doctype/selling_settings/selling_settings.txt deleted file mode 100644 index 24d5c281063..00000000000 --- a/erpnext/selling/doctype/selling_settings/selling_settings.txt +++ /dev/null @@ -1,109 +0,0 @@ -[ - { - "creation": "2013-06-25 10:25:16", - "docstatus": 0, - "modified": "2014-02-19 18:35:36", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Settings for Selling Module", - "doctype": "DocType", - "document_type": "Other", - "icon": "icon-cog", - "issingle": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Selling Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Selling Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "role": "System Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Selling Settings" - }, - { - "default": "Customer Name", - "doctype": "DocField", - "fieldname": "cust_master_name", - "fieldtype": "Select", - "label": "Customer Naming By", - "options": "Customer Name\nNaming Series" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "label": "Default Customer Group", - "options": "Customer Group" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "label": "Default Territory", - "options": "Territory" - }, - { - "doctype": "DocField", - "fieldname": "selling_price_list", - "fieldtype": "Link", - "label": "Default Price List", - "options": "Price List" - }, - { - "doctype": "DocField", - "fieldname": "column_break_5", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "so_required", - "fieldtype": "Select", - "label": "Sales Order Required", - "options": "No\nYes" - }, - { - "doctype": "DocField", - "fieldname": "dn_required", - "fieldtype": "Select", - "label": "Delivery Note Required", - "options": "No\nYes" - }, - { - "doctype": "DocField", - "fieldname": "maintain_same_sales_rate", - "fieldtype": "Check", - "label": "Maintain Same Rate Throughout Sales Cycle" - }, - { - "doctype": "DocField", - "fieldname": "editable_price_list_rate", - "fieldtype": "Check", - "label": "Allow user to edit Price List Rate in transactions" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/sms_center/sms_center.json b/erpnext/selling/doctype/sms_center/sms_center.json new file mode 100644 index 00000000000..56143c4d8c7 --- /dev/null +++ b/erpnext/selling/doctype/sms_center/sms_center.json @@ -0,0 +1,129 @@ +{ + "allow_attach": 0, + "allow_copy": 1, + "creation": "2013-01-10 16:34:22.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "send_to", + "fieldtype": "Select", + "label": "Send To", + "options": "\nAll Contact\nAll Customer Contact\nAll Supplier Contact\nAll Sales Partner Contact\nAll Lead (Open)\nAll Employee (Active)\nAll Sales Person", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.send_to=='All Customer Contact'", + "fieldname": "customer", + "fieldtype": "Link", + "label": "Customer", + "options": "Customer", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.send_to=='All Supplier Contact'", + "fieldname": "supplier", + "fieldtype": "Link", + "label": "Supplier", + "options": "Supplier", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.send_to=='All Employee (Active)'", + "fieldname": "department", + "fieldtype": "Select", + "label": "Department", + "options": "link:Department", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.send_to=='All Employee (Active)'", + "fieldname": "branch", + "fieldtype": "Select", + "label": "Branch", + "options": "link:Branch", + "permlevel": 0 + }, + { + "fieldname": "create_receiver_list", + "fieldtype": "Button", + "label": "Create Receiver List", + "options": "create_receiver_list", + "permlevel": 0 + }, + { + "fieldname": "receiver_list", + "fieldtype": "Code", + "label": "Receiver List", + "permlevel": 0 + }, + { + "fieldname": "column_break9", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "description": "Messages greater than 160 characters will be split into multiple messages", + "fieldname": "message", + "fieldtype": "Text", + "label": "Message", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "total_words", + "fieldtype": "Int", + "label": "Total Words", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "total_messages", + "fieldtype": "Int", + "label": "Total Message(s)", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "send_sms", + "fieldtype": "Button", + "label": "Send SMS", + "options": "send_sms", + "permlevel": 0 + } + ], + "hide_heading": 0, + "hide_toolbar": 0, + "icon": "icon-mobile-phone", + "idx": 1, + "in_create": 0, + "issingle": 1, + "modified": "2014-01-30 15:29:04.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "SMS Center", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 0, + "export": 0, + "import": 0, + "permlevel": 0, + "read": 1, + "report": 0, + "role": "System Manager", + "submit": 0, + "write": 1 + } + ], + "read_only": 1 +} \ No newline at end of file diff --git a/erpnext/selling/doctype/sms_center/sms_center.py b/erpnext/selling/doctype/sms_center/sms_center.py index 7da6f321029..209d1b4c383 100644 --- a/erpnext/selling/doctype/sms_center/sms_center.py +++ b/erpnext/selling/doctype/sms_center/sms_center.py @@ -5,60 +5,58 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr -from frappe.model.code import get_obj from frappe import msgprint, _ -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class SMSCenter(Document): def create_receiver_list(self): rec, where_clause = '', '' - if self.doc.send_to == 'All Customer Contact': - where_clause = self.doc.customer and " and customer = '%s'" % \ - self.doc.customer.replace("'", "\'") or " and ifnull(customer, '') != ''" - if self.doc.send_to == 'All Supplier Contact': - where_clause = self.doc.supplier and \ + if self.send_to == 'All Customer Contact': + where_clause = self.customer and " and customer = '%s'" % \ + self.customer.replace("'", "\'") or " and ifnull(customer, '') != ''" + if self.send_to == 'All Supplier Contact': + where_clause = self.supplier and \ " and ifnull(is_supplier, 0) = 1 and supplier = '%s'" % \ - self.doc.supplier.replace("'", "\'") or " and ifnull(supplier, '') != ''" - if self.doc.send_to == 'All Sales Partner Contact': - where_clause = self.doc.sales_partner and \ + self.supplier.replace("'", "\'") or " and ifnull(supplier, '') != ''" + if self.send_to == 'All Sales Partner Contact': + where_clause = self.sales_partner and \ " and ifnull(is_sales_partner, 0) = 1 and sales_partner = '%s'" % \ - self.doc.sales_partner.replace("'", "\'") or " and ifnull(sales_partner, '') != ''" + self.sales_partner.replace("'", "\'") or " and ifnull(sales_partner, '') != ''" - if self.doc.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']: + if self.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']: rec = frappe.db.sql("""select CONCAT(ifnull(first_name,''), '', ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s""", where_clause) - elif self.doc.send_to == 'All Lead (Open)': + elif self.send_to == 'All Lead (Open)': rec = frappe.db.sql("""select lead_name, mobile_no from `tabLead` where ifnull(mobile_no,'')!='' and docstatus != 2 and status='Open'""") - elif self.doc.send_to == 'All Employee (Active)': - where_clause = self.doc.department and " and department = '%s'" % \ - self.doc.department.replace("'", "\'") or "" - where_clause += self.doc.branch and " and branch = '%s'" % \ - self.doc.branch.replace("'", "\'") or "" + elif self.send_to == 'All Employee (Active)': + where_clause = self.department and " and department = '%s'" % \ + self.department.replace("'", "\'") or "" + where_clause += self.branch and " and branch = '%s'" % \ + self.branch.replace("'", "\'") or "" rec = frappe.db.sql("""select employee_name, cell_number from `tabEmployee` where status = 'Active' and docstatus < 2 and ifnull(cell_number,'')!='' %s""", where_clause) - elif self.doc.send_to == 'All Sales Person': + elif self.send_to == 'All Sales Person': rec = frappe.db.sql("""select sales_person_name, mobile_no from `tabSales Person` where docstatus!=2 and ifnull(mobile_no,'')!=''""") rec_list = '' for d in rec: rec_list += d[0] + ' - ' + d[1] + '\n' - self.doc.receiver_list = rec_list + self.receiver_list = rec_list def get_receiver_nos(self): receiver_nos = [] - if self.doc.receiver_list: - for d in self.doc.receiver_list.split('\n'): + if self.receiver_list: + for d in self.receiver_list.split('\n'): receiver_no = d if '-' in d: receiver_no = receiver_no.split('-')[1] @@ -70,9 +68,9 @@ class DocType: return receiver_nos def send_sms(self): - if not self.doc.message: + if not self.message: msgprint(_("Please enter message before sending")) else: receiver_list = self.get_receiver_nos() if receiver_list: - msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, cstr(self.doc.message))) \ No newline at end of file + msgprint(frappe.get_doc('SMS Control', 'SMS Control').send_sms(receiver_list, cstr(self.message))) \ No newline at end of file diff --git a/erpnext/selling/doctype/sms_center/sms_center.txt b/erpnext/selling/doctype/sms_center/sms_center.txt deleted file mode 100644 index efa7a455511..00000000000 --- a/erpnext/selling/doctype/sms_center/sms_center.txt +++ /dev/null @@ -1,148 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:22", - "docstatus": 0, - "modified": "2014-01-30 15:29:04", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 0, - "allow_copy": 1, - "doctype": "DocType", - "hide_heading": 0, - "hide_toolbar": 0, - "icon": "icon-mobile-phone", - "in_create": 0, - "issingle": 1, - "module": "Selling", - "name": "__common__", - "read_only": 1 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "SMS Center", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 0, - "doctype": "DocPerm", - "export": 0, - "import": 0, - "name": "__common__", - "parent": "SMS Center", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 0, - "role": "System Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "SMS Center" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "send_to", - "fieldtype": "Select", - "label": "Send To", - "options": "\nAll Contact\nAll Customer Contact\nAll Supplier Contact\nAll Sales Partner Contact\nAll Lead (Open)\nAll Employee (Active)\nAll Sales Person" - }, - { - "depends_on": "eval:doc.send_to=='All Customer Contact'", - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "label": "Customer", - "options": "Customer" - }, - { - "depends_on": "eval:doc.send_to=='All Supplier Contact'", - "doctype": "DocField", - "fieldname": "supplier", - "fieldtype": "Link", - "label": "Supplier", - "options": "Supplier" - }, - { - "depends_on": "eval:doc.send_to=='All Employee (Active)'", - "doctype": "DocField", - "fieldname": "department", - "fieldtype": "Select", - "label": "Department", - "options": "link:Department" - }, - { - "depends_on": "eval:doc.send_to=='All Employee (Active)'", - "doctype": "DocField", - "fieldname": "branch", - "fieldtype": "Select", - "label": "Branch", - "options": "link:Branch" - }, - { - "doctype": "DocField", - "fieldname": "create_receiver_list", - "fieldtype": "Button", - "label": "Create Receiver List", - "options": "create_receiver_list" - }, - { - "doctype": "DocField", - "fieldname": "receiver_list", - "fieldtype": "Code", - "label": "Receiver List" - }, - { - "doctype": "DocField", - "fieldname": "column_break9", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "description": "Messages greater than 160 characters will be split into multiple messages", - "doctype": "DocField", - "fieldname": "message", - "fieldtype": "Text", - "label": "Message", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_words", - "fieldtype": "Int", - "label": "Total Words", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_messages", - "fieldtype": "Int", - "label": "Total Message(s)", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "send_sms", - "fieldtype": "Button", - "label": "Send SMS", - "options": "send_sms" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/selling/page/sales_analytics/sales_analytics.json b/erpnext/selling/page/sales_analytics/sales_analytics.json new file mode 100644 index 00000000000..12bc4874b35 --- /dev/null +++ b/erpnext/selling/page/sales_analytics/sales_analytics.json @@ -0,0 +1,26 @@ +{ + "creation": "2012-09-21 20:15:12.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-bar-chart", + "idx": 1, + "modified": "2013-07-11 14:43:59.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "sales-analytics", + "owner": "Administrator", + "page_name": "sales-analytics", + "roles": [ + { + "role": "Analytics" + }, + { + "role": "Sales Manager" + }, + { + "role": "Maintenance Manager" + } + ], + "standard": "Yes", + "title": "Sales Analytics" +} \ No newline at end of file diff --git a/erpnext/selling/page/sales_analytics/sales_analytics.txt b/erpnext/selling/page/sales_analytics/sales_analytics.txt deleted file mode 100644 index 8753be6b289..00000000000 --- a/erpnext/selling/page/sales_analytics/sales_analytics.txt +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "creation": "2012-09-21 20:15:12", - "docstatus": 0, - "modified": "2013-07-11 14:43:59", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-bar-chart", - "module": "Selling", - "name": "__common__", - "page_name": "sales-analytics", - "standard": "Yes", - "title": "Sales Analytics" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "sales-analytics", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "sales-analytics" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Sales Manager" - }, - { - "doctype": "Page Role", - "role": "Maintenance Manager" - } -] \ No newline at end of file diff --git a/erpnext/selling/page/sales_browser/sales_browser.json b/erpnext/selling/page/sales_browser/sales_browser.json new file mode 100644 index 00000000000..ace9203ef60 --- /dev/null +++ b/erpnext/selling/page/sales_browser/sales_browser.json @@ -0,0 +1,37 @@ +{ + "creation": "2012-06-14 15:07:26.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-sitemap", + "idx": 1, + "modified": "2013-07-11 14:43:56.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Browser", + "owner": "Administrator", + "page_name": "Sales Browser", + "roles": [ + { + "role": "Sales Master Manager" + }, + { + "role": "Material Master Manager" + }, + { + "role": "Accounts Manager" + }, + { + "role": "Sales Master Manager" + }, + { + "role": "Purchase Manager" + }, + { + "role": "Purchase Master Manager" + }, + { + "role": "Material Manager" + } + ], + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/selling/page/sales_browser/sales_browser.py b/erpnext/selling/page/sales_browser/sales_browser.py index e53515c22ec..fcb270e5c5a 100644 --- a/erpnext/selling/page/sales_browser/sales_browser.py +++ b/erpnext/selling/page/sales_browser/sales_browser.py @@ -21,8 +21,7 @@ def get_children(): @frappe.whitelist() def add_node(): - # from frappe.model.doc import Document - ctype = frappe.form_dict.get('ctype') + # ctype = frappe.form_dict.get('ctype') parent_field = 'parent_' + ctype.lower().replace(' ', '_') name_field = ctype.lower().replace(' ', '_') + '_name' @@ -36,4 +35,4 @@ def add_node(): if ctype == "Sales Person": doclist[0]["employee"] = frappe.form_dict.get('employee') - frappe.bean(doclist).save() \ No newline at end of file + frappe.get_doc(doclist).save() \ No newline at end of file diff --git a/erpnext/selling/page/sales_browser/sales_browser.txt b/erpnext/selling/page/sales_browser/sales_browser.txt deleted file mode 100644 index 5a047e27de5..00000000000 --- a/erpnext/selling/page/sales_browser/sales_browser.txt +++ /dev/null @@ -1,56 +0,0 @@ -[ - { - "creation": "2012-06-14 15:07:26", - "docstatus": 0, - "modified": "2013-07-11 14:43:56", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-sitemap", - "module": "Selling", - "name": "__common__", - "page_name": "Sales Browser", - "standard": "Yes" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "Sales Browser", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "Sales Browser" - }, - { - "doctype": "Page Role", - "role": "Sales Master Manager" - }, - { - "doctype": "Page Role", - "role": "Material Master Manager" - }, - { - "doctype": "Page Role", - "role": "Accounts Manager" - }, - { - "doctype": "Page Role", - "role": "Sales Master Manager" - }, - { - "doctype": "Page Role", - "role": "Purchase Manager" - }, - { - "doctype": "Page Role", - "role": "Purchase Master Manager" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - } -] \ No newline at end of file diff --git a/erpnext/selling/page/sales_funnel/sales_funnel.json b/erpnext/selling/page/sales_funnel/sales_funnel.json new file mode 100644 index 00000000000..3a50968f2c7 --- /dev/null +++ b/erpnext/selling/page/sales_funnel/sales_funnel.json @@ -0,0 +1,20 @@ +{ + "creation": "2013-10-04 13:17:18.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-filter", + "idx": 1, + "modified": "2013-10-04 13:17:18.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "sales-funnel", + "owner": "Administrator", + "page_name": "sales-funnel", + "roles": [ + { + "role": "Sales Manager" + } + ], + "standard": "Yes", + "title": "Sales Funnel" +} \ No newline at end of file diff --git a/erpnext/selling/page/sales_funnel/sales_funnel.txt b/erpnext/selling/page/sales_funnel/sales_funnel.txt deleted file mode 100644 index b841f20fdcc..00000000000 --- a/erpnext/selling/page/sales_funnel/sales_funnel.txt +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "creation": "2013-10-04 13:17:18", - "docstatus": 0, - "modified": "2013-10-04 13:17:18", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-filter", - "module": "Selling", - "name": "__common__", - "page_name": "sales-funnel", - "standard": "Yes", - "title": "Sales Funnel" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "sales-funnel", - "parentfield": "roles", - "parenttype": "Page", - "role": "Sales Manager" - }, - { - "doctype": "Page", - "name": "sales-funnel" - }, - { - "doctype": "Page Role" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.json b/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.json new file mode 100644 index 00000000000..29b47c8fbb3 --- /dev/null +++ b/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-21 13:40:05.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Available Stock for Packing Items", + "owner": "Administrator", + "ref_doctype": "Sales BOM", + "report_name": "Available Stock for Packing Items", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt b/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt deleted file mode 100644 index 6655caad591..00000000000 --- a/erpnext/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-21 13:40:05", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "ref_doctype": "Sales BOM", - "report_name": "Available Stock for Packing Items", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Available Stock for Packing Items" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.json b/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.json new file mode 100644 index 00000000000..b04e5dad255 --- /dev/null +++ b/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-11-28 14:58:06.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Customer Acquisition and Loyalty", + "owner": "Administrator", + "ref_doctype": "Customer", + "report_name": "Customer Acquisition and Loyalty", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.txt b/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.txt deleted file mode 100644 index 98ef3a9639c..00000000000 --- a/erpnext/selling/report/customer_acquisition_and_loyalty/customer_acquisition_and_loyalty.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-11-28 14:58:06", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "ref_doctype": "Customer", - "report_name": "Customer Acquisition and Loyalty", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Customer Acquisition and Loyalty" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json b/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json new file mode 100644 index 00000000000..9fe5291cb45 --- /dev/null +++ b/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json @@ -0,0 +1,16 @@ +{ + "creation": "2012-10-04 18:45:27.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Customer Addresses And Contacts", + "owner": "Administrator", + "query": "SELECT\n\t`tabCustomer`.name as customer_id,\n\t`tabCustomer`.customer_name,\n\t`tabCustomer`.customer_group,\n\t`tabAddress`.address_line1,\n\t`tabAddress`.address_line2,\n\t`tabAddress`.city,\n\t`tabAddress`.state,\n\t`tabAddress`.pincode,\n\t`tabAddress`.country,\n\t`tabAddress`.is_primary_address, \n\t`tabContact`.first_name,\n\t`tabContact`.last_name,\n\t`tabContact`.phone,\n\t`tabContact`.mobile_no,\n\t`tabContact`.email_id,\n\t`tabContact`.is_primary_contact\nFROM\n\t`tabCustomer`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.customer=`tabCustomer`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.customer=`tabCustomer`.name\n\t)\nWHERE\n\t`tabCustomer`.docstatus<2\nORDER BY\n\t`tabCustomer`.name asc", + "ref_doctype": "Customer", + "report_name": "Customer Addresses And Contacts", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.txt b/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.txt deleted file mode 100644 index fbe5b770525..00000000000 --- a/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2012-10-04 18:45:27", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "query": "SELECT\n\t`tabCustomer`.name as customer_id,\n\t`tabCustomer`.customer_name,\n\t`tabCustomer`.customer_group,\n\t`tabAddress`.address_line1,\n\t`tabAddress`.address_line2,\n\t`tabAddress`.city,\n\t`tabAddress`.state,\n\t`tabAddress`.pincode,\n\t`tabAddress`.country,\n\t`tabAddress`.is_primary_address, \n\t`tabContact`.first_name,\n\t`tabContact`.last_name,\n\t`tabContact`.phone,\n\t`tabContact`.mobile_no,\n\t`tabContact`.email_id,\n\t`tabContact`.is_primary_contact\nFROM\n\t`tabCustomer`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.customer=`tabCustomer`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.customer=`tabCustomer`.name\n\t)\nWHERE\n\t`tabCustomer`.docstatus<2\nORDER BY\n\t`tabCustomer`.name asc", - "ref_doctype": "Customer", - "report_name": "Customer Addresses And Contacts", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Customer Addresses And Contacts" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.json b/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.json new file mode 100644 index 00000000000..04b662e119a --- /dev/null +++ b/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-07 12:27:07.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Customers Not Buying Since Long Time", + "owner": "Administrator", + "ref_doctype": "Sales Order", + "report_name": "Customers Not Buying Since Long Time ", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.txt b/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.txt deleted file mode 100644 index 54ea37ebcd4..00000000000 --- a/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-07 12:27:07", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "ref_doctype": "Sales Order", - "report_name": "Customers Not Buying Since Long Time ", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Customers Not Buying Since Long Time" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json new file mode 100644 index 00000000000..27bd1538dea --- /dev/null +++ b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.json @@ -0,0 +1,18 @@ +{ + "add_total_row": 1, + "creation": "2013-05-23 17:42:24.000000", + "disabled": 0, + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Item-wise Sales History", + "owner": "Administrator", + "query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Float:100\",\n\tso_item.stock_uom as \"UOM:Link/UOM:80\",\n\tso_item.base_rate as \"Rate:Currency:120\",\n\tso_item.base_amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n so.project_name as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Float:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc", + "ref_doctype": "Sales Order", + "report_name": "Item-wise Sales History", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.txt b/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.txt deleted file mode 100644 index d03ca924c1b..00000000000 --- a/erpnext/selling/report/item_wise_sales_history/item_wise_sales_history.txt +++ /dev/null @@ -1,25 +0,0 @@ -[ - { - "creation": "2013-05-23 17:42:24", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "disabled": 0, - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "query": "select\n so_item.item_code as \"Item Code:Link/Item:120\",\n\tso_item.item_name as \"Item Name::120\",\n\tso_item.description as \"Description::150\",\n\tso_item.qty as \"Qty:Float:100\",\n\tso_item.stock_uom as \"UOM:Link/UOM:80\",\n\tso_item.base_rate as \"Rate:Currency:120\",\n\tso_item.base_amount as \"Amount:Currency:120\",\n\tso.name as \"Sales Order:Link/Sales Order:120\",\n\tso.transaction_date as \"Transaction Date:Date:140\",\n\tso.customer as \"Customer:Link/Customer:130\",\n\tso.territory as \"Territory:Link/Territory:130\",\n so.project_name as \"Project:Link/Project:130\",\n\tifnull(so_item.delivered_qty, 0) as \"Delivered Qty:Float:120\",\n\tifnull(so_item.billed_amt, 0) as \"Billed Amount:Currency:120\"\nfrom\n\t`tabSales Order` so, `tabSales Order Item` so_item\nwhere\n\tso.name = so_item.parent\n\tand so.docstatus = 1\norder by so.name desc", - "ref_doctype": "Sales Order", - "report_name": "Item-wise Sales History", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Item-wise Sales History" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/lead_details/lead_details.json b/erpnext/selling/report/lead_details/lead_details.json new file mode 100644 index 00000000000..20c964b8aee --- /dev/null +++ b/erpnext/selling/report/lead_details/lead_details.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-10-22 11:58:16.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Lead Details", + "owner": "Administrator", + "query": "SELECT\n `tabLead`.name as \"Lead Id:Link/Lead:120\",\n `tabLead`.lead_name as \"Lead Name::120\",\n\t`tabLead`.company_name as \"Company Name::120\",\n\t`tabLead`.status as \"Status::120\",\n\tconcat_ws(', ', \n\t\ttrim(',' from `tabAddress`.address_line1), \n\t\ttrim(',' from tabAddress.address_line2), \n\t\ttabAddress.state, tabAddress.pincode, tabAddress.country\n\t) as 'Address::180',\n\t`tabLead`.phone as \"Phone::100\",\n\t`tabLead`.mobile_no as \"Mobile No::100\",\n\t`tabLead`.email_id as \"Email Id::120\",\n\t`tabLead`.lead_owner as \"Lead Owner::120\",\n\t`tabLead`.source as \"Source::120\",\n\t`tabLead`.territory as \"Territory::120\",\n `tabLead`.owner as \"Owner:Link/User:120\"\nFROM\n\t`tabLead`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.lead=`tabLead`.name\n\t)\nWHERE\n\t`tabLead`.docstatus<2\nORDER BY\n\t`tabLead`.name asc", + "ref_doctype": "Lead", + "report_name": "Lead Details", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/lead_details/lead_details.txt b/erpnext/selling/report/lead_details/lead_details.txt deleted file mode 100644 index 8c9f1701718..00000000000 --- a/erpnext/selling/report/lead_details/lead_details.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-10-22 11:58:16", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "query": "SELECT\n `tabLead`.name as \"Lead Id:Link/Lead:120\",\n `tabLead`.lead_name as \"Lead Name::120\",\n\t`tabLead`.company_name as \"Company Name::120\",\n\t`tabLead`.status as \"Status::120\",\n\tconcat_ws(', ', \n\t\ttrim(',' from `tabAddress`.address_line1), \n\t\ttrim(',' from tabAddress.address_line2), \n\t\ttabAddress.state, tabAddress.pincode, tabAddress.country\n\t) as 'Address::180',\n\t`tabLead`.phone as \"Phone::100\",\n\t`tabLead`.mobile_no as \"Mobile No::100\",\n\t`tabLead`.email_id as \"Email Id::120\",\n\t`tabLead`.lead_owner as \"Lead Owner::120\",\n\t`tabLead`.source as \"Source::120\",\n\t`tabLead`.territory as \"Territory::120\",\n `tabLead`.owner as \"Owner:Link/User:120\"\nFROM\n\t`tabLead`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.lead=`tabLead`.name\n\t)\nWHERE\n\t`tabLead`.docstatus<2\nORDER BY\n\t`tabLead`.name asc", - "ref_doctype": "Lead", - "report_name": "Lead Details", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Lead Details" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.json b/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.json new file mode 100644 index 00000000000..b3282b98a38 --- /dev/null +++ b/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-06-21 16:46:45.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Pending SO Items For Purchase Request", + "owner": "Administrator", + "query": "select \n so_item.item_code as \"Item Code:Link/Item:120\",\n so_item.item_name as \"Item Name::120\",\n so_item.description as \"Description::120\",\n so.`name` as \"S.O. No.:Link/Sales Order:120\",\n so.`transaction_date` as \"Date:Date:120\",\n mr.name as \"Material Request:Link/Material Request:120\",\n so.customer as \"Customer:Link/Customer:120\",\n so.territory as \"Terretory:Link/Territory:120\",\n sum(so_item.qty) as \"SO Qty:Float:100 \",\n sum(mr_item.qty) as \"Requested Qty:Float:100\"\nfrom\n `tabSales Order` so, `tabSales Order Item` so_item, \n `tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n so_item.`parent` = so.`name` and mr_item.sales_order_no = so.name\n and mr_item.parent = mr.name \n and so.docstatus = 1 and so.status != \"Stopped\" \n and mr.docstatus = 1 and mr.status != \"Stopped\"\ngroup by so.name, so_item.item_code\norder by so.name desc, so_item.item_code asc", + "ref_doctype": "Sales Order", + "report_name": "Pending SO Items For Purchase Request", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.txt b/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.txt deleted file mode 100644 index 07b524b4f90..00000000000 --- a/erpnext/selling/report/pending_so_items_for_purchase_request/pending_so_items_for_purchase_request.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-06-21 16:46:45", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "query": "select \n so_item.item_code as \"Item Code:Link/Item:120\",\n so_item.item_name as \"Item Name::120\",\n so_item.description as \"Description::120\",\n so.`name` as \"S.O. No.:Link/Sales Order:120\",\n so.`transaction_date` as \"Date:Date:120\",\n mr.name as \"Material Request:Link/Material Request:120\",\n so.customer as \"Customer:Link/Customer:120\",\n so.territory as \"Terretory:Link/Territory:120\",\n sum(so_item.qty) as \"SO Qty:Float:100 \",\n sum(mr_item.qty) as \"Requested Qty:Float:100\"\nfrom\n `tabSales Order` so, `tabSales Order Item` so_item, \n `tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n so_item.`parent` = so.`name` and mr_item.sales_order_no = so.name\n and mr_item.parent = mr.name \n and so.docstatus = 1 and so.status != \"Stopped\" \n and mr.docstatus = 1 and mr.status != \"Stopped\"\ngroup by so.name, so_item.item_code\norder by so.name desc, so_item.item_code asc", - "ref_doctype": "Sales Order", - "report_name": "Pending SO Items For Purchase Request", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Pending SO Items For Purchase Request" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/quotation_trends/quotation_trends.json b/erpnext/selling/report/quotation_trends/quotation_trends.json new file mode 100644 index 00000000000..6be53acf477 --- /dev/null +++ b/erpnext/selling/report/quotation_trends/quotation_trends.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 0, + "creation": "2013-06-07 16:01:16.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Quotation Trends", + "owner": "Administrator", + "ref_doctype": "Quotation", + "report_name": "Quotation Trends", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/quotation_trends/quotation_trends.txt b/erpnext/selling/report/quotation_trends/quotation_trends.txt deleted file mode 100644 index 5db150f380d..00000000000 --- a/erpnext/selling/report/quotation_trends/quotation_trends.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-06-07 16:01:16", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 0, - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "ref_doctype": "Quotation", - "report_name": "Quotation Trends", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Quotation Trends" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/sales_order_trends/sales_order_trends.json b/erpnext/selling/report/sales_order_trends/sales_order_trends.json new file mode 100644 index 00000000000..cb08af1c124 --- /dev/null +++ b/erpnext/selling/report/sales_order_trends/sales_order_trends.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-13 18:43:30.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Order Trends", + "owner": "Administrator", + "ref_doctype": "Sales Order", + "report_name": "Sales Order Trends", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/sales_order_trends/sales_order_trends.txt b/erpnext/selling/report/sales_order_trends/sales_order_trends.txt deleted file mode 100644 index 6ac7595d0fe..00000000000 --- a/erpnext/selling/report/sales_order_trends/sales_order_trends.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-13 18:43:30", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "ref_doctype": "Sales Order", - "report_name": "Sales Order Trends", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Sales Order Trends" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.json b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.json new file mode 100644 index 00000000000..6c45ba9f8d5 --- /dev/null +++ b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-21 12:14:15.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Person Target Variance Item Group-Wise", + "owner": "Administrator", + "ref_doctype": "Sales Order", + "report_name": "Sales Person Target Variance Item Group-Wise", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt deleted file mode 100644 index 56674e1046c..00000000000 --- a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-21 12:14:15", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "ref_doctype": "Sales Order", - "report_name": "Sales Person Target Variance Item Group-Wise", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Sales Person Target Variance Item Group-Wise" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.json b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.json new file mode 100644 index 00000000000..4ecba96f60c --- /dev/null +++ b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-05-03 11:31:05.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Person-wise Transaction Summary", + "owner": "Administrator", + "ref_doctype": "Sales Order", + "report_name": "Sales Person-wise Transaction Summary", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt deleted file mode 100644 index b1334c68bef..00000000000 --- a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-05-03 11:31:05", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "ref_doctype": "Sales Order", - "report_name": "Sales Person-wise Transaction Summary", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Sales Person-wise Transaction Summary" - } -] \ No newline at end of file diff --git a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.json b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.json new file mode 100644 index 00000000000..b03bb023998 --- /dev/null +++ b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-21 12:15:00.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Selling", + "name": "Territory Target Variance Item Group-Wise", + "owner": "Administrator", + "ref_doctype": "Sales Order", + "report_name": "Territory Target Variance Item Group-Wise", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt deleted file mode 100644 index 5bce0073e45..00000000000 --- a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-21 12:15:00", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Selling", - "name": "__common__", - "ref_doctype": "Sales Order", - "report_name": "Territory Target Variance Item Group-Wise", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Territory Target Variance Item Group-Wise" - } -] \ No newline at end of file diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 1dbbbfe2a1d..ce2a7988f55 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -70,7 +70,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ if(this.frm.fields_dict[this.fname].grid.get_field('batch_no')) { this.frm.set_query("batch_no", this.fname, function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); if(!item.item_code) { frappe.throw(frappe._("Please enter Item Code to get batch no")); } else { @@ -98,7 +98,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ this.frm.toggle_display("customer_name", (this.frm.doc.customer_name && this.frm.doc.customer_name!==this.frm.doc.customer)); if(this.frm.fields_dict.packing_details) { - var packing_list_exists = this.frm.get_doclist({parentfield: "packing_details"}).length; + var packing_list_exists = (this.frm.doc.packing_details || []).length; this.frm.toggle_display("packing_list", packing_list_exists ? true : false); } }, @@ -128,7 +128,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }, price_list_rate: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]); item.rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0), @@ -138,7 +138,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }, discount_percentage: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); if(!item.price_list_rate) { item.discount_percentage = 0.0; } else { @@ -147,7 +147,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }, rate: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["rate", "price_list_rate"]); if(item.price_list_rate) { @@ -188,7 +188,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }, allocated_percentage: function(doc, cdt, cdn) { - var sales_person = frappe.model.get_doc(cdt, cdn); + var sales_person = frappe.get_doc(cdt, cdn); if(sales_person.allocated_percentage) { sales_person.allocated_percentage = flt(sales_person.allocated_percentage, @@ -203,7 +203,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }, warehouse: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); if(item.item_code && item.warehouse) { return this.frm.call({ method: "erpnext.selling.utils.get_available_qty", @@ -434,8 +434,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ calculate_contribution: function() { var me = this; - $.each(frappe.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, - {parentfield: "sales_team"}), function(i, sales_person) { + $.each(this.frm.doc.doctype.sales_team || [], function(i, sales_person) { frappe.model.round_floats_in(sales_person); if(sales_person.allocated_percentage) { sales_person.allocated_amount = flt( @@ -545,8 +544,8 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ // toggle columns var item_grid = this.frm.fields_dict[this.fname].grid; var show = (this.frm.doc.currency != company_currency) || - (frappe.model.get_doclist(cur_frm.doctype, cur_frm.docname, - {parentfield: "other_charges", included_in_print_rate: 1}).length); + (cur_frm.doc.other_charges.filter( + function(d) { return d.included_in_print_rate===1}).length); $.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) { if(frappe.meta.get_docfield(item_grid.doctype, fname)) @@ -566,7 +565,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ // Help for Sales BOM items var set_sales_bom_help = function(doc) { if(!cur_frm.fields_dict.packing_list) return; - if (getchildren('Packed Item', doc.name, 'packing_details').length) { + if ((doc.packing_details || []).length) { $(cur_frm.fields_dict.packing_list.row.wrapper).toggle(true); if (inList(['Delivery Note', 'Sales Invoice'], doc.doctype)) { diff --git a/erpnext/setup/doctype/applicable_territory/applicable_territory.json b/erpnext/setup/doctype/applicable_territory/applicable_territory.json new file mode 100644 index 00000000000..cc41933f23f --- /dev/null +++ b/erpnext/setup/doctype/applicable_territory/applicable_territory.json @@ -0,0 +1,24 @@ +{ + "creation": "2013-06-20 12:48:38.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Territory", + "options": "Territory", + "permlevel": 0, + "reqd": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:22:53.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Applicable Territory", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/applicable_territory/applicable_territory.py b/erpnext/setup/doctype/applicable_territory/applicable_territory.py index cb42e2eea2a..25478d6aadd 100644 --- a/erpnext/setup/doctype/applicable_territory/applicable_territory.py +++ b/erpnext/setup/doctype/applicable_territory/applicable_territory.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ApplicableTerritory(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/applicable_territory/applicable_territory.txt b/erpnext/setup/doctype/applicable_territory/applicable_territory.txt deleted file mode 100644 index 3a5b0f351b5..00000000000 --- a/erpnext/setup/doctype/applicable_territory/applicable_territory.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2013-06-20 12:48:38", - "docstatus": 0, - "modified": "2013-12-20 19:22:53", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Setup", - "name": "__common__" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Territory", - "name": "__common__", - "options": "Territory", - "parent": "Applicable Territory", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocType", - "name": "Applicable Territory" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/authorization_control/authorization_control.json b/erpnext/setup/doctype/authorization_control/authorization_control.json new file mode 100644 index 00000000000..da356342928 --- /dev/null +++ b/erpnext/setup/doctype/authorization_control/authorization_control.json @@ -0,0 +1,12 @@ +{ + "creation": "2012-03-27 14:36:18.000000", + "docstatus": 0, + "doctype": "DocType", + "idx": 1, + "issingle": 1, + "modified": "2013-12-20 19:22:54.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Authorization Control", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/authorization_control/authorization_control.py b/erpnext/setup/doctype/authorization_control/authorization_control.py index b37686a666b..8a401f07be3 100644 --- a/erpnext/setup/doctype/authorization_control/authorization_control.py +++ b/erpnext/setup/doctype/authorization_control/authorization_control.py @@ -5,16 +5,14 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt, has_common, make_esc -from frappe.model.bean import getlist + from frappe import session, msgprint from erpnext.setup.utils import get_company_currency from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +class AuthorizationControl(TransactionBase): # Get Names of all Approving Users and Roles @@ -38,7 +36,7 @@ class DocType(TransactionBase): if not has_common(appr_roles, frappe.user.get_roles()) and not has_common(appr_users, [session['user']]): msg, add_msg = '','' if max_amount: - dcc = get_company_currency(self.doc.company) + dcc = get_company_currency(self.company) if based_on == 'Grand Total': msg = "since Grand Total exceeds %s. %s" % (dcc, flt(max_amount)) elif based_on == 'Itemwise Discount': msg = "since Discount exceeds %s for Item Code : %s" % (cstr(max_amount)+'%', item) elif based_on == 'Average Discount' or based_on == 'Customerwise Discount': msg = "since Discount exceeds %s" % (cstr(max_amount)+'%') @@ -83,12 +81,12 @@ class DocType(TransactionBase): if based_on == 'Grand Total': auth_value = total elif based_on == 'Customerwise Discount': if doc_obj: - if doc_obj.doc.doctype == 'Sales Invoice': customer = doc_obj.doc.customer - else: customer = doc_obj.doc.customer_name + if doc_obj.doctype == 'Sales Invoice': customer = doc_obj.customer + else: customer = doc_obj.customer_name add_cond = " and master_name = '"+make_esc("'")(cstr(customer))+"'" if based_on == 'Itemwise Discount': if doc_obj: - for t in getlist(doc_obj.doclist, doc_obj.fname): + for t in doc_obj.get(doc_obj.fname): self.validate_auth_rule(doctype_name, t.discount_percentage, based_on, add_cond, company,t.item_code ) else: self.validate_auth_rule(doctype_name, auth_value, based_on, add_cond, company) @@ -100,7 +98,7 @@ class DocType(TransactionBase): av_dis = 0 if doc_obj: price_list_rate, base_rate = 0, 0 - for d in getlist(doc_obj.doclist, doc_obj.fname): + for d in doc_obj.get(doc_obj.fname): if d.base_price_list_rate and d.base_rate: price_list_rate += flt(d.base_price_list_rate) base_rate += flt(d.base_rate) @@ -172,11 +170,11 @@ class DocType(TransactionBase): if doc_obj: if doctype_name == 'Expense Claim': - rule = self.get_value_based_rule(doctype_name,doc_obj.doc.employee,doc_obj.doc.total_claimed_amount, doc_obj.doc.company) + rule = self.get_value_based_rule(doctype_name,doc_obj.employee,doc_obj.total_claimed_amount, doc_obj.company) elif doctype_name == 'Appraisal': - rule = frappe.db.sql("select name, to_emp, to_designation, approving_role, approving_user from `tabAuthorization Rule` where transaction=%s and (to_emp=%s or to_designation IN (select designation from `tabEmployee` where name=%s)) and company = %s and docstatus!=2",(doctype_name,doc_obj.doc.employee, doc_obj.doc.employee, doc_obj.doc.company),as_dict=1) + rule = frappe.db.sql("select name, to_emp, to_designation, approving_role, approving_user from `tabAuthorization Rule` where transaction=%s and (to_emp=%s or to_designation IN (select designation from `tabEmployee` where name=%s)) and company = %s and docstatus!=2",(doctype_name,doc_obj.employee, doc_obj.employee, doc_obj.company),as_dict=1) if not rule: - rule = frappe.db.sql("select name, to_emp, to_designation, approving_role, approving_user from `tabAuthorization Rule` where transaction=%s and (to_emp=%s or to_designation IN (select designation from `tabEmployee` where name=%s)) and ifnull(company,'') = '' and docstatus!=2",(doctype_name,doc_obj.doc.employee, doc_obj.doc.employee),as_dict=1) + rule = frappe.db.sql("select name, to_emp, to_designation, approving_role, approving_user from `tabAuthorization Rule` where transaction=%s and (to_emp=%s or to_designation IN (select designation from `tabEmployee` where name=%s)) and ifnull(company,'') = '' and docstatus!=2",(doctype_name,doc_obj.employee, doc_obj.employee),as_dict=1) if rule: for m in rule: diff --git a/erpnext/setup/doctype/authorization_control/authorization_control.txt b/erpnext/setup/doctype/authorization_control/authorization_control.txt deleted file mode 100644 index c5628d23dd4..00000000000 --- a/erpnext/setup/doctype/authorization_control/authorization_control.txt +++ /dev/null @@ -1,19 +0,0 @@ -[ - { - "creation": "2012-03-27 14:36:18", - "docstatus": 0, - "modified": "2013-12-20 19:22:54", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "issingle": 1, - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocType", - "name": "Authorization Control" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/authorization_rule/authorization_rule.json b/erpnext/setup/doctype/authorization_rule/authorization_rule.json new file mode 100644 index 00000000000..23c06005ced --- /dev/null +++ b/erpnext/setup/doctype/authorization_rule/authorization_rule.json @@ -0,0 +1,147 @@ +{ + "allow_import": 1, + "autoname": "AR.####", + "creation": "2013-01-10 16:34:22.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "transaction", + "fieldtype": "Select", + "label": "Transaction", + "oldfieldname": "transaction", + "oldfieldtype": "Select", + "options": "\nDelivery Note\nPurchase Invoice\nPurchase Order\nPurchase Receipt\nQuotation\nSales Invoice\nSales Order\nAppraisal", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "based_on", + "fieldtype": "Select", + "label": "Based On", + "oldfieldname": "based_on", + "oldfieldtype": "Select", + "options": "\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nNot Applicable", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "master_name", + "fieldtype": "Link", + "label": "Customer / Item Name", + "oldfieldname": "master_name", + "oldfieldtype": "Link", + "options": "[Select]", + "permlevel": 0 + }, + { + "fieldname": "system_role", + "fieldtype": "Link", + "label": "Applicable To (Role)", + "oldfieldname": "system_role", + "oldfieldtype": "Link", + "options": "Role", + "permlevel": 0 + }, + { + "fieldname": "system_user", + "fieldtype": "Link", + "label": "Applicable To (User)", + "oldfieldname": "system_user", + "oldfieldtype": "Link", + "options": "User", + "permlevel": 0 + }, + { + "description": "This will be used for setting rule in HR module", + "fieldname": "to_emp", + "fieldtype": "Link", + "label": "Applicable To (Employee)", + "oldfieldname": "to_emp", + "oldfieldtype": "Link", + "options": "Employee", + "permlevel": 0, + "search_index": 0 + }, + { + "description": "This will be used for setting rule in HR module", + "fieldname": "to_designation", + "fieldtype": "Link", + "label": "Applicable To (Designation)", + "oldfieldname": "to_designation", + "oldfieldtype": "Link", + "options": "Designation", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "approving_role", + "fieldtype": "Link", + "label": "Approving Role", + "oldfieldname": "approving_role", + "oldfieldtype": "Link", + "options": "Role", + "permlevel": 0 + }, + { + "fieldname": "approving_user", + "fieldtype": "Link", + "label": "Approving User", + "oldfieldname": "approving_user", + "oldfieldtype": "Link", + "options": "User", + "permlevel": 0 + }, + { + "fieldname": "value", + "fieldtype": "Float", + "label": "Above Value", + "oldfieldname": "value", + "oldfieldtype": "Currency", + "permlevel": 0 + }, + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0 + } + ], + "icon": "icon-shield", + "idx": 1, + "modified": "2014-01-20 17:48:25.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Authorization Rule", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "submit": 0, + "write": 1 + } + ], + "search_fields": "transaction,based_on,system_user,system_role,approving_user,approving_role" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/authorization_rule/authorization_rule.py b/erpnext/setup/doctype/authorization_rule/authorization_rule.py index 71f5caf6d0d..1c6daf26b26 100644 --- a/erpnext/setup/doctype/authorization_rule/authorization_rule.py +++ b/erpnext/setup/doctype/authorization_rule/authorization_rule.py @@ -7,9 +7,9 @@ import frappe from frappe.utils import cint, cstr, flt, has_common from frappe import msgprint -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class AuthorizationRule(Document): def check_duplicate_entry(self): @@ -17,10 +17,10 @@ class DocType: where transaction = %s and based_on = %s and system_user = %s and system_role = %s and approving_user = %s and approving_role = %s and to_emp =%s and to_designation=%s and name != %s""", - (self.doc.transaction, self.doc.based_on, cstr(self.doc.system_user), - cstr(self.doc.system_role), cstr(self.doc.approving_user), - cstr(self.doc.approving_role), cstr(self.doc.to_emp), - cstr(self.doc.to_designation), self.doc.name)) + (self.transaction, self.based_on, cstr(self.system_user), + cstr(self.system_role), cstr(self.approving_user), + cstr(self.approving_role), cstr(self.to_emp), + cstr(self.to_designation), self.name)) auth_exists = exists and exists[0][0] or '' if auth_exists: if cint(exists[0][1]) == 2: @@ -32,49 +32,49 @@ class DocType: def validate_master_name(self): - if self.doc.based_on == 'Customerwise Discount' and \ + if self.based_on == 'Customerwise Discount' and \ not frappe.db.sql("""select name from tabCustomer - where name = %s and docstatus != 2""", (self.doc.master_name)): + where name = %s and docstatus != 2""", (self.master_name)): msgprint("Please select valid Customer Name for Customerwise Discount", raise_exception=1) - elif self.doc.based_on == 'Itemwise Discount' and \ + elif self.based_on == 'Itemwise Discount' and \ not frappe.db.sql("select name from tabItem where name = %s and docstatus != 2", - (self.doc.master_name)): + (self.master_name)): msgprint("Please select valid Item Name for Itemwise Discount", raise_exception=1) - elif (self.doc.based_on == 'Grand Total' or \ - self.doc.based_on == 'Average Discount') and self.doc.master_name: + elif (self.based_on == 'Grand Total' or \ + self.based_on == 'Average Discount') and self.master_name: msgprint("Please remove Customer/Item Name for %s." % - self.doc.based_on, raise_exception=1) + self.based_on, raise_exception=1) def validate_rule(self): - if self.doc.transaction != 'Appraisal': - if not self.doc.approving_role and not self.doc.approving_user: + if self.transaction != 'Appraisal': + if not self.approving_role and not self.approving_user: msgprint("Please enter Approving Role or Approving User", raise_exception=1) - elif self.doc.system_user and self.doc.system_user == self.doc.approving_user: + elif self.system_user and self.system_user == self.approving_user: msgprint("Approving User cannot be same as user the rule is Applicable To (User)", raise_exception=1) - elif self.doc.system_role and self.doc.system_role == self.doc.approving_role: + elif self.system_role and self.system_role == self.approving_role: msgprint("Approving Role cannot be same as user the rule is \ Applicable To (Role).", raise_exception=1) - elif self.doc.system_user and self.doc.approving_role and \ - has_common([self.doc.approving_role], [x[0] for x in \ + elif self.system_user and self.approving_role and \ + has_common([self.approving_role], [x[0] for x in \ frappe.db.sql("select role from `tabUserRole` where parent = %s", \ - (self.doc.system_user))]): + (self.system_user))]): msgprint("System User : %s is assigned role : %s. So rule does not make sense" % - (self.doc.system_user,self.doc.approving_role), raise_exception=1) - elif self.doc.transaction in ['Purchase Order', 'Purchase Receipt', \ - 'Purchase Invoice', 'Stock Entry'] and self.doc.based_on \ + (self.system_user,self.approving_role), raise_exception=1) + elif self.transaction in ['Purchase Order', 'Purchase Receipt', \ + 'Purchase Invoice', 'Stock Entry'] and self.based_on \ in ['Average Discount', 'Customerwise Discount', 'Itemwise Discount']: msgprint("You cannot set authorization on basis of Discount for %s" % - self.doc.transaction, raise_exception=1) - elif self.doc.based_on == 'Average Discount' and flt(self.doc.value) > 100.00: + self.transaction, raise_exception=1) + elif self.based_on == 'Average Discount' and flt(self.value) > 100.00: msgprint("Discount cannot given for more than 100%", raise_exception=1) - elif self.doc.based_on == 'Customerwise Discount' and not self.doc.master_name: + elif self.based_on == 'Customerwise Discount' and not self.master_name: msgprint("Please enter Customer Name for 'Customerwise Discount'", raise_exception=1) else: - if self.doc.transaction == 'Appraisal' and self.doc.based_on != 'Not Applicable': + if self.transaction == 'Appraisal' and self.based_on != 'Not Applicable': msgprint("Based on should be 'Not Applicable' while setting authorization rule\ for 'Appraisal'", raise_exception=1) @@ -84,4 +84,4 @@ class DocType: self.check_duplicate_entry() self.validate_rule() self.validate_master_name() - if not self.doc.value: self.doc.value = 0.0 \ No newline at end of file + if not self.value: self.value = 0.0 \ No newline at end of file diff --git a/erpnext/setup/doctype/authorization_rule/authorization_rule.txt b/erpnext/setup/doctype/authorization_rule/authorization_rule.txt deleted file mode 100644 index bd852d0b8ea..00000000000 --- a/erpnext/setup/doctype/authorization_rule/authorization_rule.txt +++ /dev/null @@ -1,166 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:22", - "docstatus": 0, - "modified": "2014-01-20 17:48:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "AR.####", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-shield", - "module": "Setup", - "name": "__common__", - "search_fields": "transaction,based_on,system_user,system_role,approving_user,approving_role" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Authorization Rule", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Authorization Rule", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Authorization Rule" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "transaction", - "fieldtype": "Select", - "label": "Transaction", - "oldfieldname": "transaction", - "oldfieldtype": "Select", - "options": "\nDelivery Note\nPurchase Invoice\nPurchase Order\nPurchase Receipt\nQuotation\nSales Invoice\nSales Order\nAppraisal", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "based_on", - "fieldtype": "Select", - "label": "Based On", - "oldfieldname": "based_on", - "oldfieldtype": "Select", - "options": "\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nNot Applicable", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "master_name", - "fieldtype": "Link", - "label": "Customer / Item Name", - "oldfieldname": "master_name", - "oldfieldtype": "Link", - "options": "[Select]" - }, - { - "doctype": "DocField", - "fieldname": "system_role", - "fieldtype": "Link", - "label": "Applicable To (Role)", - "oldfieldname": "system_role", - "oldfieldtype": "Link", - "options": "Role" - }, - { - "doctype": "DocField", - "fieldname": "system_user", - "fieldtype": "Link", - "label": "Applicable To (User)", - "oldfieldname": "system_user", - "oldfieldtype": "Link", - "options": "User" - }, - { - "description": "This will be used for setting rule in HR module", - "doctype": "DocField", - "fieldname": "to_emp", - "fieldtype": "Link", - "label": "Applicable To (Employee)", - "oldfieldname": "to_emp", - "oldfieldtype": "Link", - "options": "Employee", - "search_index": 0 - }, - { - "description": "This will be used for setting rule in HR module", - "doctype": "DocField", - "fieldname": "to_designation", - "fieldtype": "Link", - "label": "Applicable To (Designation)", - "oldfieldname": "to_designation", - "oldfieldtype": "Link", - "options": "Designation", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "approving_role", - "fieldtype": "Link", - "label": "Approving Role", - "oldfieldname": "approving_role", - "oldfieldtype": "Link", - "options": "Role" - }, - { - "doctype": "DocField", - "fieldname": "approving_user", - "fieldtype": "Link", - "label": "Approving User", - "oldfieldname": "approving_user", - "oldfieldtype": "Link", - "options": "User" - }, - { - "doctype": "DocField", - "fieldname": "value", - "fieldtype": "Float", - "label": "Above Value", - "oldfieldname": "value", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/backup_manager/backup_manager.json b/erpnext/setup/doctype/backup_manager/backup_manager.json new file mode 100644 index 00000000000..a82ab6515c8 --- /dev/null +++ b/erpnext/setup/doctype/backup_manager/backup_manager.json @@ -0,0 +1,159 @@ +{ + "creation": "2013-04-30 12:58:38.000000", + "description": "System for managing Backups", + "docstatus": 0, + "doctype": "DocType", + "document_type": "System", + "fields": [ + { + "fieldname": "setup", + "fieldtype": "Section Break", + "label": "Setup", + "permlevel": 0 + }, + { + "description": "Email ids separated by commas.", + "fieldname": "send_notifications_to", + "fieldtype": "Data", + "label": "Send Notifications To", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "backup_right_now", + "fieldtype": "Button", + "hidden": 1, + "label": "Backup Right Now", + "permlevel": 0, + "read_only": 1 + }, + { + "description": "Note: Backups and files are not deleted from Dropbox, you will have to delete them manually.", + "fieldname": "sync_with_dropbox", + "fieldtype": "Section Break", + "label": "Sync with Dropbox", + "permlevel": 0 + }, + { + "fieldname": "upload_backups_to_dropbox", + "fieldtype": "Select", + "label": "Upload Backups to Dropbox", + "options": "Never\nWeekly\nDaily", + "permlevel": 0 + }, + { + "fieldname": "dropbox_access_key", + "fieldtype": "Data", + "hidden": 1, + "label": "Dropbox Access Key", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "dropbox_access_secret", + "fieldtype": "Data", + "hidden": 1, + "label": "Dropbox Access Secret", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "dropbox_access_allowed", + "fieldtype": "Check", + "hidden": 1, + "label": "Dropbox Access Allowed", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "allow_dropbox_access", + "fieldtype": "Button", + "label": "Allow Dropbox Access", + "permlevel": 0 + }, + { + "description": "Note: Backups and files are not deleted from Google Drive, you will have to delete them manually.", + "fieldname": "sync_with_gdrive", + "fieldtype": "Section Break", + "hidden": 1, + "label": "Sync with Google Drive", + "permlevel": 0 + }, + { + "fieldname": "upload_backups_to_gdrive", + "fieldtype": "Select", + "label": "Upload Backups to Google Drive", + "options": "Never\nDaily\nWeekly", + "permlevel": 0 + }, + { + "fieldname": "allow_gdrive_access", + "fieldtype": "Button", + "label": "Allow Google Drive Access", + "permlevel": 0 + }, + { + "fieldname": "verification_code", + "fieldtype": "Data", + "label": "Enter Verification Code", + "permlevel": 0 + }, + { + "fieldname": "validate_gdrive", + "fieldtype": "Button", + "label": "Validate", + "permlevel": 0 + }, + { + "fieldname": "gdrive_access_allowed", + "fieldtype": "Check", + "hidden": 1, + "label": "Google Drive Access Allowed", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "gdrive_credentials", + "fieldtype": "Text", + "hidden": 1, + "label": "Credentials", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "database_folder_id", + "fieldtype": "Data", + "hidden": 1, + "label": "Database Folder ID", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "files_folder_id", + "fieldtype": "Data", + "hidden": 1, + "label": "Files Folder ID", + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-cloud-upload", + "idx": 1, + "issingle": 1, + "modified": "2013-12-20 19:22:55.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Backup Manager", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "System Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/backup_manager/backup_manager.py b/erpnext/setup/doctype/backup_manager/backup_manager.py index c3978006c85..ff4e1150771 100644 --- a/erpnext/setup/doctype/backup_manager/backup_manager.py +++ b/erpnext/setup/doctype/backup_manager/backup_manager.py @@ -7,9 +7,10 @@ from __future__ import unicode_literals import frappe from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class BackupManager(Document): + pass def take_backups_daily(): take_backups_if("Daily") diff --git a/erpnext/setup/doctype/backup_manager/backup_manager.txt b/erpnext/setup/doctype/backup_manager/backup_manager.txt deleted file mode 100644 index 259bf378dd6..00000000000 --- a/erpnext/setup/doctype/backup_manager/backup_manager.txt +++ /dev/null @@ -1,178 +0,0 @@ -[ - { - "creation": "2013-04-30 12:58:38", - "docstatus": 0, - "modified": "2013-12-20 19:22:55", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "System for managing Backups", - "doctype": "DocType", - "document_type": "System", - "icon": "icon-cloud-upload", - "issingle": 1, - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Backup Manager", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Backup Manager", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "role": "System Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Backup Manager" - }, - { - "doctype": "DocField", - "fieldname": "setup", - "fieldtype": "Section Break", - "label": "Setup" - }, - { - "description": "Email ids separated by commas.", - "doctype": "DocField", - "fieldname": "send_notifications_to", - "fieldtype": "Data", - "label": "Send Notifications To", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "backup_right_now", - "fieldtype": "Button", - "hidden": 1, - "label": "Backup Right Now", - "read_only": 1 - }, - { - "description": "Note: Backups and files are not deleted from Dropbox, you will have to delete them manually.", - "doctype": "DocField", - "fieldname": "sync_with_dropbox", - "fieldtype": "Section Break", - "label": "Sync with Dropbox" - }, - { - "doctype": "DocField", - "fieldname": "upload_backups_to_dropbox", - "fieldtype": "Select", - "label": "Upload Backups to Dropbox", - "options": "Never\nWeekly\nDaily" - }, - { - "doctype": "DocField", - "fieldname": "dropbox_access_key", - "fieldtype": "Data", - "hidden": 1, - "label": "Dropbox Access Key", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "dropbox_access_secret", - "fieldtype": "Data", - "hidden": 1, - "label": "Dropbox Access Secret", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "dropbox_access_allowed", - "fieldtype": "Check", - "hidden": 1, - "label": "Dropbox Access Allowed", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "allow_dropbox_access", - "fieldtype": "Button", - "label": "Allow Dropbox Access" - }, - { - "description": "Note: Backups and files are not deleted from Google Drive, you will have to delete them manually.", - "doctype": "DocField", - "fieldname": "sync_with_gdrive", - "fieldtype": "Section Break", - "hidden": 1, - "label": "Sync with Google Drive" - }, - { - "doctype": "DocField", - "fieldname": "upload_backups_to_gdrive", - "fieldtype": "Select", - "label": "Upload Backups to Google Drive", - "options": "Never\nDaily\nWeekly" - }, - { - "doctype": "DocField", - "fieldname": "allow_gdrive_access", - "fieldtype": "Button", - "label": "Allow Google Drive Access" - }, - { - "doctype": "DocField", - "fieldname": "verification_code", - "fieldtype": "Data", - "label": "Enter Verification Code" - }, - { - "doctype": "DocField", - "fieldname": "validate_gdrive", - "fieldtype": "Button", - "label": "Validate" - }, - { - "doctype": "DocField", - "fieldname": "gdrive_access_allowed", - "fieldtype": "Check", - "hidden": 1, - "label": "Google Drive Access Allowed", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "gdrive_credentials", - "fieldtype": "Text", - "hidden": 1, - "label": "Credentials", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "database_folder_id", - "fieldtype": "Data", - "hidden": 1, - "label": "Database Folder ID", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "files_folder_id", - "fieldtype": "Data", - "hidden": 1, - "label": "Files Folder ID", - "read_only": 1 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/brand/brand.json b/erpnext/setup/doctype/brand/brand.json new file mode 100644 index 00000000000..493eb5b714b --- /dev/null +++ b/erpnext/setup/doctype/brand/brand.json @@ -0,0 +1,93 @@ +{ + "allow_import": 1, + "autoname": "field:brand", + "creation": "2013-02-22 01:27:54.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "brand", + "fieldtype": "Data", + "label": "Brand Name", + "oldfieldname": "brand", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "read_only": 0, + "width": "300px" + } + ], + "icon": "icon-certificate", + "idx": 1, + "in_dialog": 0, + "modified": "2014-01-20 17:48:27.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Brand", + "owner": "Administrator", + "permissions": [ + { + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Master Manager", + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, + "write": 0 + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User" + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User" + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User" + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/brand/brand.py b/erpnext/setup/doctype/brand/brand.py index d30eab6e92b..5bdc2431941 100644 --- a/erpnext/setup/doctype/brand/brand.py +++ b/erpnext/setup/doctype/brand/brand.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class Brand(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/brand/brand.txt b/erpnext/setup/doctype/brand/brand.txt deleted file mode 100644 index 3e67b9ff624..00000000000 --- a/erpnext/setup/doctype/brand/brand.txt +++ /dev/null @@ -1,95 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:54", - "docstatus": 0, - "modified": "2014-01-20 17:48:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:brand", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-certificate", - "in_dialog": 0, - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Brand", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "read_only": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Brand", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Brand" - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Data", - "label": "Brand Name", - "oldfieldname": "brand", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "width": "300px" - }, - { - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Material Master Manager", - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Material User", - "submit": 0, - "write": 0 - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase User" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Accounts User" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/brand/test_brand.py b/erpnext/setup/doctype/brand/test_brand.py index c66413ffa0f..34dc6de0485 100644 --- a/erpnext/setup/doctype/brand/test_brand.py +++ b/erpnext/setup/doctype/brand/test_brand.py @@ -1,9 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Brand", - "brand": "_Test Brand" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Brand') \ No newline at end of file diff --git a/erpnext/setup/doctype/brand/test_records.json b/erpnext/setup/doctype/brand/test_records.json new file mode 100644 index 00000000000..d2a4ad4e238 --- /dev/null +++ b/erpnext/setup/doctype/brand/test_records.json @@ -0,0 +1,6 @@ +[ + { + "brand": "_Test Brand", + "doctype": "Brand" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json new file mode 100644 index 00000000000..555d0f131fd --- /dev/null +++ b/erpnext/setup/doctype/company/company.json @@ -0,0 +1,377 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:company_name", + "creation": "2013-04-10 08:35:39.000000", + "description": "Legal Entity / Subsidiary with a separate Chart of Accounts belonging to the Organization.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "details", + "fieldtype": "Section Break", + "label": "Company Details", + "oldfieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "company_name", + "fieldtype": "Data", + "label": "Company", + "no_copy": 0, + "oldfieldname": "company_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "description": "Please Enter Abbreviation or Short Name properly as it will be added as Suffix to all Account Heads.", + "fieldname": "abbr", + "fieldtype": "Data", + "label": "Abbr", + "no_copy": 0, + "oldfieldname": "abbr", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "cb0", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "domain", + "fieldtype": "Select", + "label": "Domain", + "options": "Distribution\nManufacturing\nRetail\nServices", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "charts_section", + "fieldtype": "Section Break", + "label": "Chart of Accounts", + "permlevel": 0 + }, + { + "fieldname": "country", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Country", + "options": "Country", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "chart_of_accounts", + "fieldtype": "Link", + "label": "Chart of Accounts", + "options": "Chart of Accounts", + "permlevel": 0 + }, + { + "fieldname": "default_settings", + "fieldtype": "Section Break", + "label": "Default Settings", + "oldfieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "default_bank_account", + "fieldtype": "Link", + "label": "Default Bank Account", + "no_copy": 1, + "oldfieldname": "default_bank_account", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "default_cash_account", + "fieldtype": "Link", + "label": "Default Cash Account", + "no_copy": 1, + "options": "Account", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "receivables_group", + "fieldtype": "Link", + "label": "Receivables Group", + "no_copy": 1, + "oldfieldname": "receivables_group", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "payables_group", + "fieldtype": "Link", + "label": "Payables Group", + "no_copy": 1, + "oldfieldname": "payables_group", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "default_expense_account", + "fieldtype": "Link", + "label": "Default Expense Account", + "no_copy": 1, + "options": "Account", + "permlevel": 0 + }, + { + "fieldname": "default_income_account", + "fieldtype": "Link", + "label": "Default Income Account", + "no_copy": 1, + "options": "Account", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "default_currency", + "fieldtype": "Link", + "label": "Default Currency", + "options": "Currency", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "cost_center", + "fieldtype": "Link", + "label": "Cost Center", + "no_copy": 1, + "options": "Cost Center", + "permlevel": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "credit_days", + "fieldtype": "Int", + "label": "Credit Days", + "oldfieldname": "credit_days", + "oldfieldtype": "Int", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "credit_limit", + "fieldtype": "Currency", + "label": "Credit Limit", + "oldfieldname": "credit_limit", + "oldfieldtype": "Currency", + "options": "default_currency", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "yearly_bgt_flag", + "fieldtype": "Select", + "label": "If Yearly Budget Exceeded", + "oldfieldname": "yearly_bgt_flag", + "oldfieldtype": "Select", + "options": "\nWarn\nIgnore\nStop", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "monthly_bgt_flag", + "fieldtype": "Select", + "label": "If Monthly Budget Exceeded", + "oldfieldname": "monthly_bgt_flag", + "oldfieldtype": "Select", + "options": "\nWarn\nIgnore\nStop", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "auto_accounting_for_stock_settings", + "fieldtype": "Section Break", + "label": "Auto Accounting For Stock Settings", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "stock_received_but_not_billed", + "fieldtype": "Link", + "label": "Stock Received But Not Billed", + "no_copy": 1, + "options": "Account", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "stock_adjustment_account", + "fieldtype": "Link", + "label": "Stock Adjustment Account", + "no_copy": 1, + "options": "Account", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "expenses_included_in_valuation", + "fieldtype": "Link", + "label": "Expenses Included In Valuation", + "no_copy": 1, + "options": "Account", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "For reference only.", + "fieldname": "company_info", + "fieldtype": "Section Break", + "label": "Company Info", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "address", + "fieldtype": "Small Text", + "label": "Address", + "oldfieldname": "address", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "phone_no", + "fieldtype": "Data", + "label": "Phone No", + "oldfieldname": "phone_no", + "oldfieldtype": "Data", + "options": "Phone", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "fax", + "fieldtype": "Data", + "label": "Fax", + "oldfieldname": "fax", + "oldfieldtype": "Data", + "options": "Phone", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "email", + "fieldtype": "Data", + "label": "Email", + "oldfieldname": "email", + "oldfieldtype": "Data", + "options": "Email", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "website", + "fieldtype": "Data", + "label": "Website", + "oldfieldname": "website", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Company registration numbers for your reference. Example: VAT Registration Numbers etc.", + "fieldname": "registration_info", + "fieldtype": "Section Break", + "label": "Registration Info", + "oldfieldtype": "Section Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "description": "Company registration numbers for your reference. Tax numbers etc.", + "fieldname": "registration_details", + "fieldtype": "Code", + "label": "Registration Details", + "oldfieldname": "registration_details", + "oldfieldtype": "Code", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "no_copy": 1, + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-building", + "idx": 1, + "modified": "2014-03-05 14:54:29.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Company", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "submit": 0, + "write": 1 + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "All" + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 5162ffbb14f..7355bd2b28b 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -9,131 +9,130 @@ from frappe.utils import cstr, cint import frappe.defaults -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl +from frappe.model.document import Document + +class Company(Document): + def onload(self): - self.doc.fields["__transactions_exist"] = self.check_if_transactions_exist() + self.set("__transactions_exist", self.check_if_transactions_exist()) def check_if_transactions_exist(self): exists = False for doctype in ["Sales Invoice", "Delivery Note", "Sales Order", "Quotation", "Purchase Invoice", "Purchase Receipt", "Purchase Order", "Supplier Quotation"]: if frappe.db.sql("""select name from `tab%s` where company=%s and docstatus=1 - limit 1""" % (doctype, "%s"), self.doc.name): + limit 1""" % (doctype, "%s"), self.name): exists = True break return exists def validate(self): - if self.doc.fields.get('__islocal') and len(self.doc.abbr) > 5: + if self.get('__islocal') and len(self.abbr) > 5: frappe.msgprint("Abbreviation cannot have more than 5 characters", raise_exception=1) - self.previous_default_currency = frappe.db.get_value("Company", self.doc.name, "default_currency") - if self.doc.default_currency and self.previous_default_currency and \ - self.doc.default_currency != self.previous_default_currency and \ + self.previous_default_currency = frappe.db.get_value("Company", self.name, "default_currency") + if self.default_currency and self.previous_default_currency and \ + self.default_currency != self.previous_default_currency and \ self.check_if_transactions_exist(): msgprint(_("Sorry! You cannot change company's default currency, because there are existing transactions against it. You will need to cancel those transactions if you want to change the default currency."), raise_exception=True) def on_update(self): if not frappe.db.sql("""select name from tabAccount - where company=%s and docstatus<2 limit 1""", self.doc.name): + where company=%s and docstatus<2 limit 1""", self.name): self.create_default_accounts() self.create_default_warehouses() self.create_default_web_page() if not frappe.db.get_value("Cost Center", {"group_or_ledger": "Ledger", - "company": self.doc.name}): + "company": self.name}): self.create_default_cost_center() self.set_default_accounts() - if self.doc.default_currency: - frappe.db.set_value("Currency", self.doc.default_currency, "enabled", 1) + if self.default_currency: + frappe.db.set_value("Currency", self.default_currency, "enabled", 1) def create_default_warehouses(self): for whname in ("Stores", "Work In Progress", "Finished Goods"): - if not frappe.db.exists("Warehouse", whname + " - " + self.doc.abbr): + if not frappe.db.exists("Warehouse", whname + " - " + self.abbr): stock_group = frappe.db.get_value("Account", {"account_type": "Stock", "group_or_ledger": "Group"}) if stock_group: - frappe.bean({ + frappe.get_doc({ "doctype":"Warehouse", "warehouse_name": whname, - "company": self.doc.name, + "company": self.name, "create_account_under": stock_group }).insert() def create_default_web_page(self): if not frappe.db.get_value("Website Settings", None, "home_page") and \ - not frappe.db.sql("select name from tabCompany where name!=%s", self.doc.name): + not frappe.db.sql("select name from tabCompany where name!=%s", self.name): import os with open(os.path.join(os.path.dirname(__file__), "sample_home_page.html"), "r") as webfile: - webpage = frappe.bean({ + webpage = frappe.get_doc({ "doctype": "Web Page", - "title": self.doc.name + " Home", + "title": self.name + " Home", "published": 1, - "description": "Standard Home Page for " + self.doc.name, - "main_section": webfile.read() % self.doc.fields + "description": "Standard Home Page for " + self.name, + "main_section": webfile.read() % self.as_dict() }).insert() # update in home page in settings - website_settings = frappe.bean("Website Settings", "Website Settings") - website_settings.doc.home_page = webpage.doc.name - website_settings.doc.brand_html = self.doc.name - website_settings.doc.copyright = self.doc.name - website_settings.doclist.append({ + website_settings = frappe.get_doc("Website Settings", "Website Settings") + website_settings.home_page = webpage.name + website_settings.brand_html = self.name + website_settings.copyright = self.name + website_settings.append("top_bar_items", { "doctype": "Top Bar Item", - "parentfield": "top_bar_items", "label":"Contact", "url": "contact" }) - website_settings.doclist.append({ + website_settings.append("top_bar_items", { "doctype": "Top Bar Item", - "parentfield": "top_bar_items", "label":"Blog", "url": "blog" }) website_settings.save() - style_settings = frappe.bean("Style Settings", "Style Settings") - style_settings.doc.top_bar_background = "F2F2F2" - style_settings.doc.font_size = "15px" + style_settings = frappe.get_doc("Style Settings", "Style Settings") + style_settings.top_bar_background = "F2F2F2" + style_settings.font_size = "15px" style_settings.save() def create_default_accounts(self): - if self.doc.chart_of_accounts: + if self.chart_of_accounts: self.import_chart_of_account() else: self.create_standard_accounts() - frappe.db.set(self.doc, "receivables_group", "Accounts Receivable - " + self.doc.abbr) - frappe.db.set(self.doc, "payables_group", "Accounts Payable - " + self.doc.abbr) + frappe.db.set(self, "receivables_group", "Accounts Receivable - " + self.abbr) + frappe.db.set(self, "payables_group", "Accounts Payable - " + self.abbr) def import_chart_of_account(self): - chart = frappe.bean("Chart of Accounts", self.doc.chart_of_accounts) - chart.make_controller().create_accounts(self.doc.name) + chart = frappe.get_doc("Chart of Accounts", self.chart_of_accounts) + chart.create_accounts(self.name) def add_acc(self,lst): - account = frappe.bean({ + account = frappe.get_doc({ "doctype": "Account", "freeze_account": "No", "master_type": "", }) for d in self.fld_dict.keys(): - account.doc.fields[d] = (d == 'parent_account' and lst[self.fld_dict[d]]) and lst[self.fld_dict[d]] +' - '+ self.doc.abbr or lst[self.fld_dict[d]] + account.set(d, (d == 'parent_account' and lst[self.fld_dict[d]]) and lst[self.fld_dict[d]] +' - '+ self.abbr or lst[self.fld_dict[d]]) account.insert() def set_default_accounts(self): def _set_default_accounts(accounts): for field, account_type in accounts.items(): account = frappe.db.get_value("Account", {"account_type": account_type, - "group_or_ledger": "Ledger", "company": self.doc.name}) + "group_or_ledger": "Ledger", "company": self.name}) - if account and not self.doc.fields.get(field): - frappe.db.set(self.doc, field, account) + if account and not self.get(field): + frappe.db.set(self, field, account) _set_default_accounts({ "default_cash_account": "Cash", @@ -150,58 +149,58 @@ class DocType: def create_default_cost_center(self): cc_list = [ { - 'cost_center_name': self.doc.name, - 'company':self.doc.name, + 'cost_center_name': self.name, + 'company':self.name, 'group_or_ledger':'Group', 'parent_cost_center':'' }, { 'cost_center_name':'Main', - 'company':self.doc.name, + 'company':self.name, 'group_or_ledger':'Ledger', - 'parent_cost_center':self.doc.name + ' - ' + self.doc.abbr + 'parent_cost_center':self.name + ' - ' + self.abbr }, ] for cc in cc_list: cc.update({"doctype": "Cost Center"}) - cc_bean = frappe.bean(cc) - cc_bean.ignore_permissions = True + cc_doc = frappe.get_doc(cc) + cc_doc.ignore_permissions = True - if cc.get("cost_center_name") == self.doc.name: - cc_bean.ignore_mandatory = True - cc_bean.insert() + if cc.get("cost_center_name") == self.name: + cc_doc.ignore_mandatory = True + cc_doc.insert() - frappe.db.set(self.doc, "cost_center", "Main - " + self.doc.abbr) + frappe.db.set(self, "cost_center", "Main - " + self.abbr) def on_trash(self): """ Trash accounts and cost centers for this company if no gl entry exists """ - rec = frappe.db.sql("SELECT name from `tabGL Entry` where company = %s", self.doc.name) + rec = frappe.db.sql("SELECT name from `tabGL Entry` where company = %s", self.name) if not rec: #delete tabAccount - frappe.db.sql("delete from `tabAccount` where company = %s order by lft desc, rgt desc", self.doc.name) + frappe.db.sql("delete from `tabAccount` where company = %s order by lft desc, rgt desc", self.name) #delete cost center child table - budget detail - frappe.db.sql("delete bd.* from `tabBudget Detail` bd, `tabCost Center` cc where bd.parent = cc.name and cc.company = %s", self.doc.name) + frappe.db.sql("delete bd.* from `tabBudget Detail` bd, `tabCost Center` cc where bd.parent = cc.name and cc.company = %s", self.name) #delete cost center - frappe.db.sql("delete from `tabCost Center` WHERE company = %s order by lft desc, rgt desc", self.doc.name) + frappe.db.sql("delete from `tabCost Center` WHERE company = %s order by lft desc, rgt desc", self.name) - if not frappe.db.get_value("Stock Ledger Entry", {"company": self.doc.name}): - frappe.db.sql("""delete from `tabWarehouse` where company=%s""", self.doc.name) + if not frappe.db.get_value("Stock Ledger Entry", {"company": self.name}): + frappe.db.sql("""delete from `tabWarehouse` where company=%s""", self.name) - frappe.defaults.clear_default("company", value=self.doc.name) + frappe.defaults.clear_default("company", value=self.name) frappe.db.sql("""update `tabSingles` set value="" where doctype='Global Defaults' and field='default_company' - and value=%s""", self.doc.name) + and value=%s""", self.name) def before_rename(self, olddn, newdn, merge=False): if merge: frappe.throw(_("Sorry, companies cannot be merged")) def after_rename(self, olddn, newdn, merge=False): - frappe.db.set(self.doc, "company_name", newdn) + frappe.db.set(self, "company_name", newdn) frappe.db.sql("""update `tabDefaultValue` set defvalue=%s where defkey='Company' and defvalue=%s""", (newdn, olddn)) @@ -220,121 +219,120 @@ class DocType: } acc_list_common = [ - ['Application of Funds (Assets)','','Group','','Balance Sheet',self.doc.name,''], - ['Current Assets','Application of Funds (Assets)','Group','','Balance Sheet',self.doc.name,''], - ['Accounts Receivable','Current Assets','Group','','Balance Sheet',self.doc.name,''], - ['Bank Accounts','Current Assets','Group','Bank','Balance Sheet',self.doc.name,''], - ['Cash In Hand','Current Assets','Group','Cash','Balance Sheet',self.doc.name,''], - ['Cash','Cash In Hand','Ledger','Cash','Balance Sheet',self.doc.name,''], - ['Loans and Advances (Assets)','Current Assets','Group','','Balance Sheet',self.doc.name,''], - ['Securities and Deposits','Current Assets','Group','','Balance Sheet',self.doc.name,''], - ['Earnest Money','Securities and Deposits','Ledger','','Balance Sheet',self.doc.name,''], - ['Stock Assets','Current Assets','Group','Stock','Balance Sheet',self.doc.name,''], - ['Tax Assets','Current Assets','Group','','Balance Sheet',self.doc.name,''], - ['Fixed Assets','Application of Funds (Assets)','Group','','Balance Sheet',self.doc.name,''], - ['Capital Equipments','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.doc.name,''], - ['Computers','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.doc.name,''], - ['Furniture and Fixture','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.doc.name,''], - ['Office Equipments','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.doc.name,''], - ['Plant and Machinery','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.doc.name,''], - ['Investments','Application of Funds (Assets)','Group','','Balance Sheet',self.doc.name,''], - ['Temporary Accounts (Assets)','Application of Funds (Assets)','Group','','Balance Sheet',self.doc.name,''], - ['Temporary Account (Assets)','Temporary Accounts (Assets)','Ledger','','Balance Sheet',self.doc.name,''], - ['Expenses','','Group','Expense Account','Profit and Loss',self.doc.name,''], - ['Direct Expenses','Expenses','Group','Expense Account','Profit and Loss',self.doc.name,''], - ['Stock Expenses','Direct Expenses','Group','Expense Account','Profit and Loss',self.doc.name,''], - ['Cost of Goods Sold','Stock Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Stock Adjustment','Stock Expenses','Ledger','Stock Adjustment','Profit and Loss',self.doc.name,''], - ['Expenses Included In Valuation', "Stock Expenses", 'Ledger', 'Expenses Included In Valuation', 'Profit and Loss', self.doc.name, ''], - ['Indirect Expenses','Expenses','Group','Expense Account','Profit and Loss',self.doc.name,''], - ['Advertising and Publicity','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.doc.name,''], - ['Bad Debts Written Off','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Bank Charges','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Books and Periodicals','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Charity and Donations','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Commission on Sales','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Conveyance Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Customer Entertainment Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Depreciation Account','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Freight and Forwarding Charges','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.doc.name,''], - ['Legal Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Miscellaneous Expenses','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.doc.name,''], - ['Office Maintenance Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Office Rent','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Postal Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Print and Stationary','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Rounded Off','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Salary','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Sales Promotion Expenses','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.doc.name,''], - ['Service Charges Paid','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Staff Welfare Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Telephone Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Travelling Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Water and Electricity Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''], - ['Income','','Group','','Profit and Loss',self.doc.name,''], - ['Direct Income','Income','Group','Income Account','Profit and Loss',self.doc.name,''], - ['Sales','Direct Income','Ledger','Income Account','Profit and Loss',self.doc.name,''], - ['Service','Direct Income','Ledger','Income Account','Profit and Loss',self.doc.name,''], - ['Indirect Income','Income','Group','Income Account','Profit and Loss',self.doc.name,''], - ['Source of Funds (Liabilities)','','Group','','Balance Sheet',self.doc.name,''], - ['Capital Account','Source of Funds (Liabilities)','Group','','Balance Sheet',self.doc.name,''], - ['Reserves and Surplus','Capital Account','Ledger','','Balance Sheet',self.doc.name,''], - ['Shareholders Funds','Capital Account','Ledger','','Balance Sheet',self.doc.name,''], - ['Current Liabilities','Source of Funds (Liabilities)','Group','','Balance Sheet',self.doc.name,''], - ['Accounts Payable','Current Liabilities','Group','','Balance Sheet',self.doc.name,''], - ['Stock Liabilities','Current Liabilities','Group','','Balance Sheet',self.doc.name,''], - ['Stock Received But Not Billed', 'Stock Liabilities', 'Ledger', 'Stock Received But Not Billed', 'Balance Sheet', self.doc.name, ''], - ['Duties and Taxes','Current Liabilities','Group','','Balance Sheet',self.doc.name,''], - ['Loans (Liabilities)','Current Liabilities','Group','','Balance Sheet',self.doc.name,''], - ['Secured Loans','Loans (Liabilities)','Group','','Balance Sheet',self.doc.name,''], - ['Unsecured Loans','Loans (Liabilities)','Group','','Balance Sheet',self.doc.name,''], - ['Bank Overdraft Account','Loans (Liabilities)','Group','','Balance Sheet',self.doc.name,''], - ['Temporary Accounts (Liabilities)','Source of Funds (Liabilities)','Group','','Balance Sheet',self.doc.name,''], - ['Temporary Account (Liabilities)','Temporary Accounts (Liabilities)','Ledger','','Balance Sheet',self.doc.name,''] + ['Application of Funds (Assets)','','Group','','Balance Sheet',self.name,''], + ['Current Assets','Application of Funds (Assets)','Group','','Balance Sheet',self.name,''], + ['Accounts Receivable','Current Assets','Group','','Balance Sheet',self.name,''], + ['Bank Accounts','Current Assets','Group','Bank','Balance Sheet',self.name,''], + ['Cash In Hand','Current Assets','Group','Cash','Balance Sheet',self.name,''], + ['Cash','Cash In Hand','Ledger','Cash','Balance Sheet',self.name,''], + ['Loans and Advances (Assets)','Current Assets','Group','','Balance Sheet',self.name,''], + ['Securities and Deposits','Current Assets','Group','','Balance Sheet',self.name,''], + ['Earnest Money','Securities and Deposits','Ledger','','Balance Sheet',self.name,''], + ['Stock Assets','Current Assets','Group','Stock','Balance Sheet',self.name,''], + ['Tax Assets','Current Assets','Group','','Balance Sheet',self.name,''], + ['Fixed Assets','Application of Funds (Assets)','Group','','Balance Sheet',self.name,''], + ['Capital Equipments','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.name,''], + ['Computers','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.name,''], + ['Furniture and Fixture','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.name,''], + ['Office Equipments','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.name,''], + ['Plant and Machinery','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.name,''], + ['Investments','Application of Funds (Assets)','Group','','Balance Sheet',self.name,''], + ['Temporary Accounts (Assets)','Application of Funds (Assets)','Group','','Balance Sheet',self.name,''], + ['Temporary Account (Assets)','Temporary Accounts (Assets)','Ledger','','Balance Sheet',self.name,''], + ['Expenses','','Group','Expense Account','Profit and Loss',self.name,''], + ['Direct Expenses','Expenses','Group','Expense Account','Profit and Loss',self.name,''], + ['Stock Expenses','Direct Expenses','Group','Expense Account','Profit and Loss',self.name,''], + ['Cost of Goods Sold','Stock Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Stock Adjustment','Stock Expenses','Ledger','Stock Adjustment','Profit and Loss',self.name,''], + ['Expenses Included In Valuation', "Stock Expenses", 'Ledger', 'Expenses Included In Valuation', 'Profit and Loss', self.name, ''], + ['Indirect Expenses','Expenses','Group','Expense Account','Profit and Loss',self.name,''], + ['Advertising and Publicity','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.name,''], + ['Bad Debts Written Off','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Bank Charges','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Books and Periodicals','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Charity and Donations','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Commission on Sales','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Conveyance Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Customer Entertainment Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Depreciation Account','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Freight and Forwarding Charges','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.name,''], + ['Legal Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Miscellaneous Expenses','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.name,''], + ['Office Maintenance Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Office Rent','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Postal Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Print and Stationary','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Rounded Off','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Salary','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Sales Promotion Expenses','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.name,''], + ['Service Charges Paid','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Staff Welfare Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Telephone Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Travelling Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Water and Electricity Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.name,''], + ['Income','','Group','','Profit and Loss',self.name,''], + ['Direct Income','Income','Group','Income Account','Profit and Loss',self.name,''], + ['Sales','Direct Income','Ledger','Income Account','Profit and Loss',self.name,''], + ['Service','Direct Income','Ledger','Income Account','Profit and Loss',self.name,''], + ['Indirect Income','Income','Group','Income Account','Profit and Loss',self.name,''], + ['Source of Funds (Liabilities)','','Group','','Balance Sheet',self.name,''], + ['Capital Account','Source of Funds (Liabilities)','Group','','Balance Sheet',self.name,''], + ['Reserves and Surplus','Capital Account','Ledger','','Balance Sheet',self.name,''], + ['Shareholders Funds','Capital Account','Ledger','','Balance Sheet',self.name,''], + ['Current Liabilities','Source of Funds (Liabilities)','Group','','Balance Sheet',self.name,''], + ['Accounts Payable','Current Liabilities','Group','','Balance Sheet',self.name,''], + ['Stock Liabilities','Current Liabilities','Group','','Balance Sheet',self.name,''], + ['Stock Received But Not Billed', 'Stock Liabilities', 'Ledger', 'Stock Received But Not Billed', 'Balance Sheet', self.name, ''], + ['Duties and Taxes','Current Liabilities','Group','','Balance Sheet',self.name,''], + ['Loans (Liabilities)','Current Liabilities','Group','','Balance Sheet',self.name,''], + ['Secured Loans','Loans (Liabilities)','Group','','Balance Sheet',self.name,''], + ['Unsecured Loans','Loans (Liabilities)','Group','','Balance Sheet',self.name,''], + ['Bank Overdraft Account','Loans (Liabilities)','Group','','Balance Sheet',self.name,''], + ['Temporary Accounts (Liabilities)','Source of Funds (Liabilities)','Group','','Balance Sheet',self.name,''], + ['Temporary Account (Liabilities)','Temporary Accounts (Liabilities)','Ledger','','Balance Sheet',self.name,''] ] acc_list_india = [ - ['CENVAT Capital Goods','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['CENVAT','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['CENVAT Service Tax','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['CENVAT Service Tax Cess 1','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['CENVAT Service Tax Cess 2','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['CENVAT Edu Cess','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['CENVAT SHE Cess','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['Excise Duty 4','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'4.00'], - ['Excise Duty 8','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'8.00'], - ['Excise Duty 10','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'10.00'], - ['Excise Duty 14','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'14.00'], - ['Excise Duty Edu Cess 2','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'2.00'], - ['Excise Duty SHE Cess 1','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'1.00'], - ['P L A','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['P L A - Cess Portion','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['Edu. Cess on Excise','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'2.00'], - ['Edu. Cess on Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'2.00'], - ['Edu. Cess on TDS','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'2.00'], - ['Excise Duty @ 4','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'4.00'], - ['Excise Duty @ 8','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'8.00'], - ['Excise Duty @ 10','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'10.00'], - ['Excise Duty @ 14','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'14.00'], - ['Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'10.3'], - ['SHE Cess on Excise','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'1.00'], - ['SHE Cess on Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'1.00'], - ['SHE Cess on TDS','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'1.00'], - ['Professional Tax','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['VAT','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['TDS (Advertisement)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['TDS (Commission)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['TDS (Contractor)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['TDS (Interest)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['TDS (Rent)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''], - ['TDS (Salary)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''] + ['CENVAT Capital Goods','Tax Assets','Ledger','Chargeable','Balance Sheet',self.name,''], + ['CENVAT','Tax Assets','Ledger','Chargeable','Balance Sheet',self.name,''], + ['CENVAT Service Tax','Tax Assets','Ledger','Chargeable','Balance Sheet',self.name,''], + ['CENVAT Service Tax Cess 1','Tax Assets','Ledger','Chargeable','Balance Sheet',self.name,''], + ['CENVAT Service Tax Cess 2','Tax Assets','Ledger','Chargeable','Balance Sheet',self.name,''], + ['CENVAT Edu Cess','Tax Assets','Ledger','Chargeable','Balance Sheet',self.name,''], + ['CENVAT SHE Cess','Tax Assets','Ledger','Chargeable','Balance Sheet',self.name,''], + ['Excise Duty 4','Tax Assets','Ledger','Tax','Balance Sheet',self.name,'4.00'], + ['Excise Duty 8','Tax Assets','Ledger','Tax','Balance Sheet',self.name,'8.00'], + ['Excise Duty 10','Tax Assets','Ledger','Tax','Balance Sheet',self.name,'10.00'], + ['Excise Duty 14','Tax Assets','Ledger','Tax','Balance Sheet',self.name,'14.00'], + ['Excise Duty Edu Cess 2','Tax Assets','Ledger','Tax','Balance Sheet',self.name,'2.00'], + ['Excise Duty SHE Cess 1','Tax Assets','Ledger','Tax','Balance Sheet',self.name,'1.00'], + ['P L A','Tax Assets','Ledger','Chargeable','Balance Sheet',self.name,''], + ['P L A - Cess Portion','Tax Assets','Ledger','Chargeable','Balance Sheet',self.name,''], + ['Edu. Cess on Excise','Duties and Taxes','Ledger','Tax','Balance Sheet',self.name,'2.00'], + ['Edu. Cess on Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet',self.name,'2.00'], + ['Edu. Cess on TDS','Duties and Taxes','Ledger','Tax','Balance Sheet',self.name,'2.00'], + ['Excise Duty @ 4','Duties and Taxes','Ledger','Tax','Balance Sheet',self.name,'4.00'], + ['Excise Duty @ 8','Duties and Taxes','Ledger','Tax','Balance Sheet',self.name,'8.00'], + ['Excise Duty @ 10','Duties and Taxes','Ledger','Tax','Balance Sheet',self.name,'10.00'], + ['Excise Duty @ 14','Duties and Taxes','Ledger','Tax','Balance Sheet',self.name,'14.00'], + ['Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet',self.name,'10.3'], + ['SHE Cess on Excise','Duties and Taxes','Ledger','Tax','Balance Sheet',self.name,'1.00'], + ['SHE Cess on Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet',self.name,'1.00'], + ['SHE Cess on TDS','Duties and Taxes','Ledger','Tax','Balance Sheet',self.name,'1.00'], + ['Professional Tax','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.name,''], + ['VAT','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.name,''], + ['TDS (Advertisement)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.name,''], + ['TDS (Commission)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.name,''], + ['TDS (Contractor)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.name,''], + ['TDS (Interest)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.name,''], + ['TDS (Rent)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.name,''], + ['TDS (Salary)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.name,''] ] # load common account heads for d in acc_list_common: self.add_acc(d) - country = frappe.db.sql("select value from tabSingles where field = 'country' and doctype = 'Control Panel'") - country = country and cstr(country[0][0]) or '' + country = frappe.db.get_default("country") # load taxes (only for India) if country == 'India': diff --git a/erpnext/setup/doctype/company/company.txt b/erpnext/setup/doctype/company/company.txt deleted file mode 100644 index 3aca5253903..00000000000 --- a/erpnext/setup/doctype/company/company.txt +++ /dev/null @@ -1,393 +0,0 @@ -[ - { - "creation": "2013-04-10 08:35:39", - "docstatus": 0, - "modified": "2014-03-05 14:54:29", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:company_name", - "description": "Legal Entity / Subsidiary with a separate Chart of Accounts belonging to the Organization.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-building", - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Company", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Company", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1 - }, - { - "doctype": "DocType", - "name": "Company" - }, - { - "doctype": "DocField", - "fieldname": "details", - "fieldtype": "Section Break", - "label": "Company Details", - "oldfieldtype": "Section Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "company_name", - "fieldtype": "Data", - "label": "Company", - "no_copy": 0, - "oldfieldname": "company_name", - "oldfieldtype": "Data", - "read_only": 0, - "reqd": 1 - }, - { - "description": "Please Enter Abbreviation or Short Name properly as it will be added as Suffix to all Account Heads.", - "doctype": "DocField", - "fieldname": "abbr", - "fieldtype": "Data", - "label": "Abbr", - "no_copy": 0, - "oldfieldname": "abbr", - "oldfieldtype": "Data", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb0", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "domain", - "fieldtype": "Select", - "label": "Domain", - "options": "Distribution\nManufacturing\nRetail\nServices", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "charts_section", - "fieldtype": "Section Break", - "label": "Chart of Accounts" - }, - { - "doctype": "DocField", - "fieldname": "country", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Country", - "options": "Country", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "chart_of_accounts", - "fieldtype": "Link", - "label": "Chart of Accounts", - "options": "Chart of Accounts" - }, - { - "doctype": "DocField", - "fieldname": "default_settings", - "fieldtype": "Section Break", - "label": "Default Settings", - "oldfieldtype": "Section Break", - "read_only": 0 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "default_bank_account", - "fieldtype": "Link", - "label": "Default Bank Account", - "no_copy": 1, - "oldfieldname": "default_bank_account", - "oldfieldtype": "Link", - "options": "Account", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "default_cash_account", - "fieldtype": "Link", - "label": "Default Cash Account", - "no_copy": 1, - "options": "Account", - "read_only": 0 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "receivables_group", - "fieldtype": "Link", - "label": "Receivables Group", - "no_copy": 1, - "oldfieldname": "receivables_group", - "oldfieldtype": "Link", - "options": "Account", - "read_only": 0 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "payables_group", - "fieldtype": "Link", - "label": "Payables Group", - "no_copy": 1, - "oldfieldname": "payables_group", - "oldfieldtype": "Link", - "options": "Account", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "default_expense_account", - "fieldtype": "Link", - "label": "Default Expense Account", - "no_copy": 1, - "options": "Account" - }, - { - "doctype": "DocField", - "fieldname": "default_income_account", - "fieldtype": "Link", - "label": "Default Income Account", - "no_copy": 1, - "options": "Account" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "default_currency", - "fieldtype": "Link", - "label": "Default Currency", - "options": "Currency", - "read_only": 0, - "reqd": 1 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "label": "Cost Center", - "no_copy": 1, - "options": "Cost Center" - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "credit_days", - "fieldtype": "Int", - "label": "Credit Days", - "oldfieldname": "credit_days", - "oldfieldtype": "Int", - "read_only": 0 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "credit_limit", - "fieldtype": "Currency", - "label": "Credit Limit", - "oldfieldname": "credit_limit", - "oldfieldtype": "Currency", - "options": "default_currency", - "read_only": 0 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "yearly_bgt_flag", - "fieldtype": "Select", - "label": "If Yearly Budget Exceeded", - "oldfieldname": "yearly_bgt_flag", - "oldfieldtype": "Select", - "options": "\nWarn\nIgnore\nStop", - "read_only": 0 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "monthly_bgt_flag", - "fieldtype": "Select", - "label": "If Monthly Budget Exceeded", - "oldfieldname": "monthly_bgt_flag", - "oldfieldtype": "Select", - "options": "\nWarn\nIgnore\nStop", - "read_only": 0 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "auto_accounting_for_stock_settings", - "fieldtype": "Section Break", - "label": "Auto Accounting For Stock Settings", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "stock_received_but_not_billed", - "fieldtype": "Link", - "label": "Stock Received But Not Billed", - "no_copy": 1, - "options": "Account", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "stock_adjustment_account", - "fieldtype": "Link", - "label": "Stock Adjustment Account", - "no_copy": 1, - "options": "Account", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "expenses_included_in_valuation", - "fieldtype": "Link", - "label": "Expenses Included In Valuation", - "no_copy": 1, - "options": "Account", - "read_only": 0 - }, - { - "description": "For reference only.", - "doctype": "DocField", - "fieldname": "company_info", - "fieldtype": "Section Break", - "label": "Company Info", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "address", - "fieldtype": "Small Text", - "label": "Address", - "oldfieldname": "address", - "oldfieldtype": "Small Text", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "phone_no", - "fieldtype": "Data", - "label": "Phone No", - "oldfieldname": "phone_no", - "oldfieldtype": "Data", - "options": "Phone", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "fax", - "fieldtype": "Data", - "label": "Fax", - "oldfieldname": "fax", - "oldfieldtype": "Data", - "options": "Phone", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "email", - "fieldtype": "Data", - "label": "Email", - "oldfieldname": "email", - "oldfieldtype": "Data", - "options": "Email", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "website", - "fieldtype": "Data", - "label": "Website", - "oldfieldname": "website", - "oldfieldtype": "Data", - "read_only": 0 - }, - { - "description": "Company registration numbers for your reference. Example: VAT Registration Numbers etc.", - "doctype": "DocField", - "fieldname": "registration_info", - "fieldtype": "Section Break", - "label": "Registration Info", - "oldfieldtype": "Section Break", - "read_only": 0, - "width": "50%" - }, - { - "description": "Company registration numbers for your reference. Tax numbers etc.", - "doctype": "DocField", - "fieldname": "registration_details", - "fieldtype": "Code", - "label": "Registration Details", - "oldfieldname": "registration_details", - "oldfieldtype": "Code", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "no_copy": 1, - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "report": 1, - "role": "System Manager", - "submit": 0, - "write": 1 - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "All" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/company/test_company.py b/erpnext/setup/doctype/company/test_company.py index 932c45af2ac..06db121531e 100644 --- a/erpnext/setup/doctype/company/test_company.py +++ b/erpnext/setup/doctype/company/test_company.py @@ -13,7 +13,7 @@ class TestCompany(unittest.TestCase): print "Country: ", country print "Chart Name: ", chart_name - company_bean = frappe.bean({ + company_doc = frappe.get_doc({ "doctype": "Company", "company_name": "_Test Company 2", "abbr": "_TC2", @@ -22,26 +22,11 @@ class TestCompany(unittest.TestCase): "chart_of_accounts": chart_name }) - company_bean.insert() + company_doc.insert() self.assertTrue(frappe.db.sql("""select count(*) from tabAccount where company='_Test Company 2'""")[0][0] > 10) frappe.delete_doc("Company", "_Test Company 2") -test_records = [ - [{ - "doctype": "Company", - "company_name": "_Test Company", - "abbr": "_TC", - "default_currency": "INR", - "domain": "Manufacturing" - }], - [{ - "doctype": "Company", - "company_name": "_Test Company 1", - "abbr": "_TC1", - "default_currency": "USD", - "domain": "Retail" - }], -] \ No newline at end of file +test_records = frappe.get_test_records('Company') \ No newline at end of file diff --git a/erpnext/setup/doctype/company/test_records.json b/erpnext/setup/doctype/company/test_records.json new file mode 100644 index 00000000000..ad6558558f6 --- /dev/null +++ b/erpnext/setup/doctype/company/test_records.json @@ -0,0 +1,16 @@ +[ + { + "abbr": "_TC", + "company_name": "_Test Company", + "default_currency": "INR", + "doctype": "Company", + "domain": "Manufacturing" + }, + { + "abbr": "_TC1", + "company_name": "_Test Company 1", + "default_currency": "USD", + "doctype": "Company", + "domain": "Retail" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/contact_control/contact_control.js b/erpnext/setup/doctype/contact_control/contact_control.js index f28e3a09721..743bedd1dcb 100755 --- a/erpnext/setup/doctype/contact_control/contact_control.js +++ b/erpnext/setup/doctype/contact_control/contact_control.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt cur_frm.cscript.get_states=function(doc, dt, dn) { - return $c('runserverobj', args={'method': 'check_state', 'docs':frappe.model.compress(make_doclist(doc.doctype, doc.name))}, + return $c('runserverobj', args={'method': 'check_state', 'docs':doc}, function(r, rt) { if(r.message) set_field_options('state', r.message); diff --git a/erpnext/setup/doctype/contact_control/contact_control.json b/erpnext/setup/doctype/contact_control/contact_control.json new file mode 100644 index 00000000000..560aed5424e --- /dev/null +++ b/erpnext/setup/doctype/contact_control/contact_control.json @@ -0,0 +1,48 @@ +{ + "creation": "2012-03-27 14:36:19.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "header", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Header", + "permlevel": 0 + }, + { + "fieldname": "customer_intro", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Customer Intro", + "permlevel": 0 + }, + { + "fieldname": "supplier_intro", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Supplier Intro", + "permlevel": 0 + } + ], + "idx": 1, + "in_create": 1, + "issingle": 1, + "modified": "2013-12-20 19:23:02.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Contact Control", + "owner": "Administrator", + "permissions": [ + { + "create": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "System Manager", + "write": 1 + } + ], + "read_only": 1 +} \ No newline at end of file diff --git a/erpnext/setup/doctype/contact_control/contact_control.py b/erpnext/setup/doctype/contact_control/contact_control.py index 35bd61c982a..96e9551c3fa 100644 --- a/erpnext/setup/doctype/contact_control/contact_control.py +++ b/erpnext/setup/doctype/contact_control/contact_control.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self,doc,doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class ContactControl(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/contact_control/contact_control.txt b/erpnext/setup/doctype/contact_control/contact_control.txt deleted file mode 100644 index a5a0d01c276..00000000000 --- a/erpnext/setup/doctype/contact_control/contact_control.txt +++ /dev/null @@ -1,63 +0,0 @@ -[ - { - "creation": "2012-03-27 14:36:19", - "docstatus": 0, - "modified": "2013-12-20 19:23:02", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "in_create": 1, - "issingle": 1, - "module": "Setup", - "name": "__common__", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldtype": "Text", - "in_list_view": 1, - "name": "__common__", - "parent": "Contact Control", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Contact Control", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "role": "System Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Contact Control" - }, - { - "doctype": "DocField", - "fieldname": "header", - "label": "Header" - }, - { - "doctype": "DocField", - "fieldname": "customer_intro", - "label": "Customer Intro" - }, - { - "doctype": "DocField", - "fieldname": "supplier_intro", - "label": "Supplier Intro" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/country/country.json b/erpnext/setup/doctype/country/country.json new file mode 100644 index 00000000000..487a160f756 --- /dev/null +++ b/erpnext/setup/doctype/country/country.json @@ -0,0 +1,102 @@ +{ + "allow_import": 1, + "autoname": "field:country_name", + "creation": "2013-01-19 10:23:30.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "country_name", + "fieldtype": "Data", + "label": "Country Name", + "oldfieldname": "country_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "date_format", + "fieldtype": "Data", + "label": "Date Format", + "permlevel": 0 + }, + { + "fieldname": "time_zones", + "fieldtype": "Text", + "label": "Time Zones", + "permlevel": 0 + }, + { + "fieldname": "code", + "fieldtype": "Data", + "label": "Code", + "permlevel": 0 + } + ], + "icon": "icon-globe", + "idx": 1, + "in_create": 0, + "modified": "2014-03-05 14:36:16.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Country", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + }, + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Master Manager", + "submit": 0, + "write": 1 + }, + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR User", + "submit": 0, + "write": 1 + }, + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "HR Manager", + "submit": 0, + "write": 1 + }, + { + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "All" + } + ], + "read_only": 0 +} \ No newline at end of file diff --git a/erpnext/setup/doctype/country/country.py b/erpnext/setup/doctype/country/country.py index d30eab6e92b..5e16f51f8f7 100644 --- a/erpnext/setup/doctype/country/country.py +++ b/erpnext/setup/doctype/country/country.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class Country(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/country/country.txt b/erpnext/setup/doctype/country/country.txt deleted file mode 100644 index 57d20253162..00000000000 --- a/erpnext/setup/doctype/country/country.txt +++ /dev/null @@ -1,105 +0,0 @@ -[ - { - "creation": "2013-01-19 10:23:30", - "docstatus": 0, - "modified": "2014-03-05 14:36:16", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:country_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-globe", - "in_create": 0, - "module": "Setup", - "name": "__common__", - "read_only": 0 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Country", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Country", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Country" - }, - { - "doctype": "DocField", - "fieldname": "country_name", - "fieldtype": "Data", - "label": "Country Name", - "oldfieldname": "country_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "date_format", - "fieldtype": "Data", - "label": "Date Format" - }, - { - "doctype": "DocField", - "fieldname": "time_zones", - "fieldtype": "Text", - "label": "Time Zones" - }, - { - "doctype": "DocField", - "fieldname": "code", - "fieldtype": "Data", - "label": "Code" - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager", - "submit": 0, - "write": 1 - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "Purchase Master Manager", - "submit": 0, - "write": 1 - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "HR User", - "submit": 0, - "write": 1 - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "HR Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocPerm", - "role": "All" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/country/test_country.py b/erpnext/setup/doctype/country/test_country.py index 27174a10242..b2610667af4 100644 --- a/erpnext/setup/doctype/country/test_country.py +++ b/erpnext/setup/doctype/country/test_country.py @@ -1,9 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Country", - "country_name": "_Test Country" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Country') \ No newline at end of file diff --git a/erpnext/setup/doctype/country/test_records.json b/erpnext/setup/doctype/country/test_records.json new file mode 100644 index 00000000000..5a7c8a5568c --- /dev/null +++ b/erpnext/setup/doctype/country/test_records.json @@ -0,0 +1,6 @@ +[ + { + "country_name": "_Test Country", + "doctype": "Country" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/currency/currency.json b/erpnext/setup/doctype/currency/currency.json new file mode 100644 index 00000000000..6c66bca0708 --- /dev/null +++ b/erpnext/setup/doctype/currency/currency.json @@ -0,0 +1,119 @@ +{ + "autoname": "field:currency_name", + "creation": "2013-01-28 10:06:02.000000", + "description": "**Currency** Master", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "currency_name", + "fieldtype": "Data", + "label": "Currency Name", + "oldfieldname": "currency_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "enabled", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Enabled", + "permlevel": 0 + }, + { + "description": "Sub-currency. For e.g. \"Cent\"", + "fieldname": "fraction", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Fraction", + "permlevel": 0 + }, + { + "description": "1 Currency = [?] Fraction\nFor e.g. 1 USD = 100 Cent", + "fieldname": "fraction_units", + "fieldtype": "Int", + "in_list_view": 1, + "label": "Fraction Units", + "permlevel": 0 + }, + { + "description": "A symbol for this currency. For e.g. $", + "fieldname": "symbol", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Symbol", + "permlevel": 0 + }, + { + "description": "How should this currency be formatted? If not set, will use system defaults", + "fieldname": "number_format", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Number Format", + "options": "\n#,###.##\n#.###,##\n# ###.##\n#,###.###\n#,##,###.##\n#.###\n#,###", + "permlevel": 0 + } + ], + "icon": "icon-bitcoin", + "idx": 1, + "in_create": 0, + "modified": "2014-01-20 17:48:31.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Currency", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Master Manager", + "submit": 0, + "write": 1 + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "All" + } + ], + "read_only": 0 +} \ No newline at end of file diff --git a/erpnext/setup/doctype/currency/currency.py b/erpnext/setup/doctype/currency/currency.py index 2f6a62af749..9dc6e3b2290 100644 --- a/erpnext/setup/doctype/currency/currency.py +++ b/erpnext/setup/doctype/currency/currency.py @@ -5,10 +5,11 @@ from __future__ import unicode_literals import frappe from frappe import throw, _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - +from frappe.model.document import Document + +class Currency(Document): + pass + def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company): """common validation for currency and price list currency""" diff --git a/erpnext/setup/doctype/currency/currency.txt b/erpnext/setup/doctype/currency/currency.txt deleted file mode 100644 index 6bd2b1ca35d..00000000000 --- a/erpnext/setup/doctype/currency/currency.txt +++ /dev/null @@ -1,126 +0,0 @@ -[ - { - "creation": "2013-01-28 10:06:02", - "docstatus": 0, - "modified": "2014-01-20 17:48:31", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "field:currency_name", - "description": "**Currency** Master", - "doctype": "DocType", - "icon": "icon-bitcoin", - "in_create": 0, - "module": "Setup", - "name": "__common__", - "read_only": 0 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Currency", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Currency", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "currency_name", - "fieldtype": "Data", - "label": "Currency Name", - "oldfieldname": "currency_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "enabled", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Enabled" - }, - { - "description": "Sub-currency. For e.g. \"Cent\"", - "doctype": "DocField", - "fieldname": "fraction", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Fraction" - }, - { - "description": "1 Currency = [?] Fraction\nFor e.g. 1 USD = 100 Cent", - "doctype": "DocField", - "fieldname": "fraction_units", - "fieldtype": "Int", - "in_list_view": 1, - "label": "Fraction Units" - }, - { - "description": "A symbol for this currency. For e.g. $", - "doctype": "DocField", - "fieldname": "symbol", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Symbol" - }, - { - "description": "How should this currency be formatted? If not set, will use system defaults", - "doctype": "DocField", - "fieldname": "number_format", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Number Format", - "options": "\n#,###.##\n#.###,##\n# ###.##\n#,###.###\n#,##,###.##\n#.###\n#,###" - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Accounts Manager", - "submit": 0, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager", - "submit": 0, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase Master Manager", - "submit": 0, - "write": 1 - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "All" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/currency/test_currency.py b/erpnext/setup/doctype/currency/test_currency.py index 41a2fab2548..f0c6cee2609 100644 --- a/erpnext/setup/doctype/currency/test_currency.py +++ b/erpnext/setup/doctype/currency/test_currency.py @@ -2,4 +2,6 @@ # License: GNU General Public License v3. See license.txt # pre loaded -test_records = [] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Currency') \ No newline at end of file diff --git a/erpnext/setup/doctype/currency/test_records.json b/erpnext/setup/doctype/currency/test_records.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/erpnext/setup/doctype/currency/test_records.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/erpnext/setup/doctype/currency_exchange/currency_exchange.json b/erpnext/setup/doctype/currency_exchange/currency_exchange.json new file mode 100644 index 00000000000..7556968fe24 --- /dev/null +++ b/erpnext/setup/doctype/currency_exchange/currency_exchange.json @@ -0,0 +1,81 @@ +{ + "allow_import": 1, + "creation": "2013-06-20 15:40:29.000000", + "description": "Specify Exchange Rate to convert one currency into another", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "from_currency", + "fieldtype": "Link", + "label": "From Currency", + "options": "Currency", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "to_currency", + "fieldtype": "Link", + "label": "To Currency", + "options": "Currency", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "exchange_rate", + "fieldtype": "Float", + "label": "Exchange Rate", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-exchange", + "idx": 1, + "modified": "2014-01-20 17:48:31.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Currency Exchange", + "owner": "Administrator", + "permissions": [ + { + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "write": 1 + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User" + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User" + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User" + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/currency_exchange/currency_exchange.py b/erpnext/setup/doctype/currency_exchange/currency_exchange.py index 93f44190bac..e22f035b929 100644 --- a/erpnext/setup/doctype/currency_exchange/currency_exchange.py +++ b/erpnext/setup/doctype/currency_exchange/currency_exchange.py @@ -8,15 +8,13 @@ import frappe from frappe import _, msgprint from frappe.model.controller import DocListController -class DocType(DocListController): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +class CurrencyExchange(DocListController): def autoname(self): - self.doc.name = self.doc.from_currency + "-" + self.doc.to_currency + self.name = self.from_currency + "-" + self.to_currency def validate(self): self.validate_value("exchange_rate", ">", 0) - if self.doc.from_currency == self.doc.to_currency: + if self.from_currency == self.to_currency: msgprint(_("From Currency and To Currency cannot be same"), raise_exception=True) \ No newline at end of file diff --git a/erpnext/setup/doctype/currency_exchange/currency_exchange.txt b/erpnext/setup/doctype/currency_exchange/currency_exchange.txt deleted file mode 100644 index adaf12508a0..00000000000 --- a/erpnext/setup/doctype/currency_exchange/currency_exchange.txt +++ /dev/null @@ -1,86 +0,0 @@ -[ - { - "creation": "2013-06-20 15:40:29", - "docstatus": 0, - "modified": "2014-01-20 17:48:31", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "description": "Specify Exchange Rate to convert one currency into another", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-exchange", - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Currency Exchange", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Currency Exchange", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Currency Exchange" - }, - { - "doctype": "DocField", - "fieldname": "from_currency", - "fieldtype": "Link", - "label": "From Currency", - "options": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "to_currency", - "fieldtype": "Link", - "label": "To Currency", - "options": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "exchange_rate", - "fieldtype": "Float", - "label": "Exchange Rate" - }, - { - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Accounts Manager", - "write": 1 - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Accounts User" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase User" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py index f8260be607b..6726dc83188 100644 --- a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py +++ b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py @@ -1,23 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Currency Exchange", - "from_currency": "USD", - "to_currency": "INR", - "exchange_rate": 60.0 - }], - [{ - "doctype": "Currency Exchange", - "from_currency": "USD", - "to_currency": "EUR", - "exchange_rate": 0.773 - }], - [{ - "doctype": "Currency Exchange", - "from_currency": "INR", - "to_currency": "USD", - "exchange_rate": 0.0167 - }], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Currency Exchange') \ No newline at end of file diff --git a/erpnext/setup/doctype/currency_exchange/test_records.json b/erpnext/setup/doctype/currency_exchange/test_records.json new file mode 100644 index 00000000000..784bf262c03 --- /dev/null +++ b/erpnext/setup/doctype/currency_exchange/test_records.json @@ -0,0 +1,20 @@ +[ + { + "doctype": "Currency Exchange", + "exchange_rate": 60.0, + "from_currency": "USD", + "to_currency": "INR" + }, + { + "doctype": "Currency Exchange", + "exchange_rate": 0.773, + "from_currency": "USD", + "to_currency": "EUR" + }, + { + "doctype": "Currency Exchange", + "exchange_rate": 0.0167, + "from_currency": "INR", + "to_currency": "USD" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/customer_group/customer_group.json b/erpnext/setup/doctype/customer_group/customer_group.json new file mode 100644 index 00000000000..e5ade41fbfe --- /dev/null +++ b/erpnext/setup/doctype/customer_group/customer_group.json @@ -0,0 +1,160 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:customer_group_name", + "creation": "2013-01-10 16:34:23.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "customer_group_name", + "fieldtype": "Data", + "label": "Customer Group Name", + "no_copy": 1, + "oldfieldname": "customer_group_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "Add / Edit", + "fieldname": "parent_customer_group", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Parent Customer Group", + "oldfieldname": "parent_customer_group", + "oldfieldtype": "Link", + "options": "Customer Group", + "permlevel": 0, + "reqd": 0 + }, + { + "description": "Only leaf nodes are allowed in transaction", + "fieldname": "is_group", + "fieldtype": "Select", + "label": "Has Child Node", + "oldfieldname": "is_group", + "oldfieldtype": "Select", + "options": "\nYes\nNo", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "cb0", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "default_price_list", + "fieldtype": "Link", + "label": "Default Price List", + "options": "Price List", + "permlevel": 0 + }, + { + "fieldname": "lft", + "fieldtype": "Int", + "hidden": 1, + "label": "lft", + "no_copy": 1, + "oldfieldname": "lft", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1, + "search_index": 1 + }, + { + "fieldname": "rgt", + "fieldtype": "Int", + "hidden": 1, + "label": "rgt", + "no_copy": 1, + "oldfieldname": "rgt", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1, + "search_index": 1 + }, + { + "description": "Add / Edit", + "fieldname": "old_parent", + "fieldtype": "Link", + "hidden": 1, + "ignore_restrictions": 1, + "label": "old_parent", + "no_copy": 1, + "oldfieldname": "old_parent", + "oldfieldtype": "Data", + "options": "Customer Group", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + } + ], + "icon": "icon-sitemap", + "idx": 1, + "in_create": 1, + "modified": "2014-01-20 17:48:33.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Customer Group", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + } + ], + "read_only": 1, + "search_fields": "name,parent_customer_group" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/customer_group/customer_group.py b/erpnext/setup/doctype/customer_group/customer_group.py index 547f19fc39d..11a15faae3d 100644 --- a/erpnext/setup/doctype/customer_group/customer_group.py +++ b/erpnext/setup/doctype/customer_group/customer_group.py @@ -6,45 +6,42 @@ import frappe from frappe import msgprint -from frappe.utils.nestedset import DocTypeNestedSet -class DocType(DocTypeNestedSet): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.nsm_parent_field = 'parent_customer_group'; +from frappe.utils.nestedset import NestedSet +class CustomerGroup(NestedSet): + nsm_parent_field = 'parent_customer_group'; def validate(self): if frappe.db.sql("select name from `tabCustomer Group` where name = %s and docstatus = 2", - (self.doc.customer_group_name)): + (self.customer_group_name)): msgprint("""Another %s record is trashed. To untrash please go to Setup -> Recycle Bin.""" % - (self.doc.customer_group_name), raise_exception = 1) + (self.customer_group_name), raise_exception = 1) def on_update(self): self.validate_name_with_customer() - super(DocType, self).on_update() + super(CustomerGroup, self).on_update() self.validate_one_root() def validate_name_with_customer(self): - if frappe.db.exists("Customer", self.doc.name): + if frappe.db.exists("Customer", self.name): frappe.msgprint("An Customer exists with same name (%s), \ please change the Customer Group name or rename the Customer" % - self.doc.name, raise_exception=1) + self.name, raise_exception=1) def on_trash(self): cust = frappe.db.sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s", - self.doc.name) + self.name) cust = [d[0] for d in cust] if cust: msgprint("""Customer Group: %s can not be trashed/deleted \ because it is used in customer: %s. To trash/delete this, remove/change customer group in customer master""" % - (self.doc.name, cust or ''), raise_exception=1) + (self.name, cust or ''), raise_exception=1) if frappe.db.sql("select name from `tabCustomer Group` where parent_customer_group = %s \ - and docstatus != 2", self.doc.name): + and docstatus != 2", self.name): msgprint("Child customer group exists for this customer group. \ You can not trash/cancel/delete this customer group.", raise_exception=1) # rebuild tree - super(DocType, self).on_trash() + super(CustomerGroup, self).on_trash() diff --git a/erpnext/setup/doctype/customer_group/customer_group.txt b/erpnext/setup/doctype/customer_group/customer_group.txt deleted file mode 100644 index 59f52c6727e..00000000000 --- a/erpnext/setup/doctype/customer_group/customer_group.txt +++ /dev/null @@ -1,165 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:23", - "docstatus": 0, - "modified": "2014-01-20 17:48:33", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:customer_group_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-sitemap", - "in_create": 1, - "module": "Setup", - "name": "__common__", - "read_only": 1, - "search_fields": "name,parent_customer_group" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Customer Group", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Customer Group", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Customer Group" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer_group_name", - "fieldtype": "Data", - "label": "Customer Group Name", - "no_copy": 1, - "oldfieldname": "customer_group_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "parent_customer_group", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Parent Customer Group", - "oldfieldname": "parent_customer_group", - "oldfieldtype": "Link", - "options": "Customer Group", - "reqd": 0 - }, - { - "description": "Only leaf nodes are allowed in transaction", - "doctype": "DocField", - "fieldname": "is_group", - "fieldtype": "Select", - "label": "Has Child Node", - "oldfieldname": "is_group", - "oldfieldtype": "Select", - "options": "\nYes\nNo", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb0", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "default_price_list", - "fieldtype": "Link", - "label": "Default Price List", - "options": "Price List" - }, - { - "doctype": "DocField", - "fieldname": "lft", - "fieldtype": "Int", - "hidden": 1, - "label": "lft", - "no_copy": 1, - "oldfieldname": "lft", - "oldfieldtype": "Int", - "print_hide": 1, - "report_hide": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "rgt", - "fieldtype": "Int", - "hidden": 1, - "label": "rgt", - "no_copy": 1, - "oldfieldname": "rgt", - "oldfieldtype": "Int", - "print_hide": 1, - "report_hide": 1, - "search_index": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "old_parent", - "fieldtype": "Link", - "hidden": 1, - "ignore_restrictions": 1, - "label": "old_parent", - "no_copy": 1, - "oldfieldname": "old_parent", - "oldfieldtype": "Data", - "options": "Customer Group", - "print_hide": 1, - "report_hide": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Sales Manager", - "write": 0 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/customer_group/test_customer_group.py b/erpnext/setup/doctype/customer_group/test_customer_group.py index e08ec23e3f9..68f7aacc3b3 100644 --- a/erpnext/setup/doctype/customer_group/test_customer_group.py +++ b/erpnext/setup/doctype/customer_group/test_customer_group.py @@ -4,11 +4,6 @@ test_ignore = ["Price List"] -test_records = [ - [{ - "doctype": "Customer Group", - "customer_group_name": "_Test Customer Group", - "parent_customer_group": "All Customer Groups", - "is_group": "No" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Customer Group') \ No newline at end of file diff --git a/erpnext/setup/doctype/customer_group/test_records.json b/erpnext/setup/doctype/customer_group/test_records.json new file mode 100644 index 00000000000..a2dfba07d87 --- /dev/null +++ b/erpnext/setup/doctype/customer_group/test_records.json @@ -0,0 +1,8 @@ +[ + { + "customer_group_name": "_Test Customer Group", + "doctype": "Customer Group", + "is_group": "No", + "parent_customer_group": "All Customer Groups" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/email_digest/email_digest.js b/erpnext/setup/doctype/email_digest/email_digest.js index 875061b1b26..51f6231c29b 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.js +++ b/erpnext/setup/doctype/email_digest/email_digest.js @@ -9,7 +9,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.add_custom_button(frappe._('View Now'), function() { doc = locals[dt][dn]; if(doc.__unsaved != 1) { - return $c_obj(make_doclist(dt, dn), 'get_digest_msg', '', function(r, rt) { + return $c_obj(doc, 'get_digest_msg', '', function(r, rt) { if(r.exc) { msgprint(err_msg); console.log(r.exc); @@ -32,7 +32,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.add_custom_button(frappe._('Send Now'), function() { doc = locals[dt][dn]; if(doc.__unsaved != 1) { - return $c_obj(make_doclist(dt, dn), 'send', '', function(r, rt) { + return $c_obj(doc, 'send', '', function(r, rt) { if(r.exc) { msgprint(err_msg); console.log(r.exc); @@ -49,7 +49,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.cscript.addremove_recipients = function(doc, dt, dn) { // Get user list - return $c_obj(make_doclist(dt, dn), 'get_users', '', function(r, rt) { + return $c_obj(doc, 'get_users', '', function(r, rt) { if(r.exc) { msgprint(r.exc); } else { diff --git a/erpnext/setup/doctype/email_digest/email_digest.json b/erpnext/setup/doctype/email_digest/email_digest.json new file mode 100644 index 00000000000..0ffc60d0b02 --- /dev/null +++ b/erpnext/setup/doctype/email_digest/email_digest.json @@ -0,0 +1,352 @@ +{ + "autoname": "Prompt", + "creation": "2013-02-21 14:15:31.000000", + "description": "Send regular summary reports via Email.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "System", + "fields": [ + { + "fieldname": "settings", + "fieldtype": "Section Break", + "label": "Email Digest Settings", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enabled", + "permlevel": 0 + }, + { + "fieldname": "company", + "fieldtype": "Select", + "label": "For Company", + "options": "link:Company", + "permlevel": 0, + "reqd": 1 + }, + { + "allow_on_submit": 0, + "fieldname": "frequency", + "fieldtype": "Select", + "label": "How frequently?", + "options": "Daily\nWeekly\nMonthly", + "permlevel": 0, + "reqd": 1 + }, + { + "depends_on": "eval:doc.enabled", + "fieldname": "next_send", + "fieldtype": "Data", + "label": "Next email will be sent on:", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "Note: Email will not be sent to disabled users", + "fieldname": "recipient_list", + "fieldtype": "Text", + "label": "Recipients", + "permlevel": 0, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "addremove_recipients", + "fieldtype": "Button", + "label": "Add/Remove Recipients", + "permlevel": 0 + }, + { + "fieldname": "accounts", + "fieldtype": "Section Break", + "label": "Accounts", + "permlevel": 0 + }, + { + "fieldname": "accounts_module", + "fieldtype": "Column Break", + "label": "Income / Expense", + "permlevel": 0 + }, + { + "fieldname": "income_year_to_date", + "fieldtype": "Check", + "label": "Income Year to Date", + "permlevel": 0 + }, + { + "description": "Balances of Accounts of type \"Bank\" or \"Cash\"", + "fieldname": "bank_balance", + "fieldtype": "Check", + "label": "Bank/Cash Balance", + "permlevel": 0 + }, + { + "description": "Income booked for the digest period", + "fieldname": "income", + "fieldtype": "Check", + "label": "Income Booked", + "permlevel": 0 + }, + { + "description": "Expenses booked for the digest period", + "fieldname": "expenses_booked", + "fieldtype": "Check", + "label": "Expenses Booked", + "permlevel": 0 + }, + { + "description": "Receivable / Payable account will be identified based on the field Master Type", + "fieldname": "column_break_16", + "fieldtype": "Column Break", + "label": "Receivables / Payables", + "permlevel": 0 + }, + { + "description": "Payments received during the digest period", + "fieldname": "collections", + "fieldtype": "Check", + "label": "Payments Received", + "permlevel": 0 + }, + { + "description": "Payments made during the digest period", + "fieldname": "payments", + "fieldtype": "Check", + "label": "Payments Made", + "permlevel": 0 + }, + { + "description": "Total amount of invoices sent to the customer during the digest period", + "fieldname": "invoiced_amount", + "fieldtype": "Check", + "label": "Receivables", + "permlevel": 0 + }, + { + "description": "Total amount of invoices received from suppliers during the digest period", + "fieldname": "payables", + "fieldtype": "Check", + "label": "Payables", + "permlevel": 0 + }, + { + "fieldname": "section_break_20", + "fieldtype": "Section Break", + "label": "Buying & Selling", + "permlevel": 0 + }, + { + "fieldname": "buying_module", + "fieldtype": "Column Break", + "label": "Buying", + "permlevel": 0 + }, + { + "fieldname": "new_purchase_requests", + "fieldtype": "Check", + "label": "New Material Requests", + "permlevel": 0 + }, + { + "fieldname": "new_supplier_quotations", + "fieldtype": "Check", + "label": "New Supplier Quotations", + "permlevel": 0 + }, + { + "fieldname": "new_purchase_orders", + "fieldtype": "Check", + "label": "New Purchase Orders", + "permlevel": 0 + }, + { + "fieldname": "selling_module", + "fieldtype": "Column Break", + "label": "Selling", + "permlevel": 0 + }, + { + "fieldname": "new_leads", + "fieldtype": "Check", + "label": "New Leads", + "permlevel": 0 + }, + { + "fieldname": "new_enquiries", + "fieldtype": "Check", + "label": "New Enquiries", + "permlevel": 0 + }, + { + "fieldname": "new_quotations", + "fieldtype": "Check", + "label": "New Quotations", + "permlevel": 0 + }, + { + "fieldname": "new_sales_orders", + "fieldtype": "Check", + "label": "New Sales Orders", + "permlevel": 0 + }, + { + "fieldname": "section_break_34", + "fieldtype": "Section Break", + "label": "Inventory & Support", + "permlevel": 0 + }, + { + "fieldname": "stock_module", + "fieldtype": "Column Break", + "label": "Stock", + "permlevel": 0 + }, + { + "fieldname": "new_delivery_notes", + "fieldtype": "Check", + "label": "New Delivery Notes", + "permlevel": 0 + }, + { + "fieldname": "new_purchase_receipts", + "fieldtype": "Check", + "label": "New Purchase Receipts", + "permlevel": 0 + }, + { + "fieldname": "new_stock_entries", + "fieldtype": "Check", + "label": "New Stock Entries", + "permlevel": 0 + }, + { + "fieldname": "support_module", + "fieldtype": "Column Break", + "label": "Support", + "permlevel": 0 + }, + { + "fieldname": "new_support_tickets", + "fieldtype": "Check", + "label": "New Support Tickets", + "permlevel": 0 + }, + { + "fieldname": "open_tickets", + "fieldtype": "Check", + "label": "Open Tickets", + "permlevel": 0 + }, + { + "fieldname": "new_communications", + "fieldtype": "Check", + "label": "New Communications", + "permlevel": 0 + }, + { + "fieldname": "section_break_40", + "fieldtype": "Section Break", + "label": "Projects & System", + "permlevel": 0 + }, + { + "fieldname": "projects_module", + "fieldtype": "Column Break", + "label": "Projects", + "permlevel": 0 + }, + { + "fieldname": "new_projects", + "fieldtype": "Check", + "label": "New Projects", + "permlevel": 0 + }, + { + "fieldname": "core_module", + "fieldtype": "Column Break", + "label": "System", + "permlevel": 0 + }, + { + "fieldname": "scheduler_errors", + "fieldtype": "Check", + "label": "Scheduler Failed Events", + "permlevel": 0 + }, + { + "fieldname": "user_specific", + "fieldtype": "Section Break", + "label": "User Specific", + "permlevel": 0 + }, + { + "fieldname": "general", + "fieldtype": "Column Break", + "label": "General", + "permlevel": 0 + }, + { + "fieldname": "calendar_events", + "fieldtype": "Check", + "label": "Calendar Events", + "permlevel": 0 + }, + { + "fieldname": "todo_list", + "fieldtype": "Check", + "label": "To Do List", + "permlevel": 0 + }, + { + "fieldname": "stub", + "fieldtype": "Column Break", + "label": "Stub", + "permlevel": 0 + } + ], + "icon": "icon-envelope", + "idx": 1, + "modified": "2014-03-19 11:39:27.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Email Digest", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "permlevel": 1, + "read": 1, + "role": "System Manager", + "submit": 0 + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index c46c43e8417..a61955562c9 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -45,12 +45,12 @@ row_template = """

""" from frappe.model.controller import DocListController -class DocType(DocListController): - def __init__(self, doc, doclist=[]): - self.doc, self.doclist = doc, doclist +class EmailDigest(DocListController): + def __init__(self, arg1, arg2=None): + super(EmailDigest, self).__init__(arg1, arg2) self.from_date, self.to_date = self.get_from_to_date() self.future_from_date, self.future_to_date = self.get_future_from_to_date() - self.currency = frappe.db.get_value("Company", self.doc.company, + self.currency = frappe.db.get_value("Company", self.company, "default_currency") def get_users(self): @@ -61,8 +61,8 @@ class DocType(DocListController): and user_type != "Website User" order by enabled desc, name asc""".format(", ".join(["%s"]*len(STANDARD_USERS))), STANDARD_USERS, as_dict=1) - if self.doc.recipient_list: - recipient_list = self.doc.recipient_list.split("\n") + if self.recipient_list: + recipient_list = self.recipient_list.split("\n") else: recipient_list = [] for p in user_list: @@ -75,7 +75,7 @@ class DocType(DocListController): valid_users = [p[0] for p in frappe.db.sql("""select name from `tabUser` where enabled=1""")] recipients = filter(lambda r: r in valid_users, - self.doc.recipient_list.split("\n")) + self.recipient_list.split("\n")) common_msg = self.get_common_content() if recipients: @@ -85,7 +85,7 @@ class DocType(DocListController): if msg_for_this_receipient: sendmail(recipients=user_id, subject="[ERPNext] [{frequency} Digest] {name}".format( - frequency=self.doc.frequency, name=self.doc.name), + frequency=self.frequency, name=self.name), msg=msg_for_this_receipient) def get_digest_msg(self): @@ -97,7 +97,7 @@ class DocType(DocListController): for module, content in content_sequence: module_out = [] for ctype in content: - if self.doc.fields.get(ctype) and hasattr(self, "get_"+ctype): + if self.get(ctype) and hasattr(self, "get_"+ctype): module_out.append(getattr(self, "get_"+ctype)()) if any([m[0] for m in module_out]): out += [[1, "

" + _(module) + "

"]] + module_out + [[1, "
"]] @@ -114,7 +114,7 @@ class DocType(DocListController): out = [] for ctype in user_specific_content: - if self.doc.fields.get(ctype) and hasattr(self, "get_"+ctype): + if self.get(ctype) and hasattr(self, "get_"+ctype): out.append(getattr(self, "get_"+ctype)(user_id)) frappe.session.user = original_session_user @@ -139,16 +139,16 @@ class DocType(DocListController): if no_value: no_value = """

No Updates For:

""" + "\n".join(no_value) - date = self.doc.frequency == "Daily" and formatdate(self.from_date) or \ + date = self.frequency == "Daily" and formatdate(self.from_date) or \ "%s to %s" % (formatdate(self.from_date), formatdate(self.to_date)) msg = digest_template % { - "digest": self.doc.frequency + " Digest", + "digest": self.frequency + " Digest", "date": date, - "company": self.doc.company, + "company": self.company, "with_value": with_value, "no_value": no_value or "", - "name": self.doc.name + "name": self.name } return msg @@ -337,7 +337,7 @@ class DocType(DocListController): def get_new_count(self, doctype, label, docstatus=0, filter_by_company=True): if filter_by_company: - company = """and company="%s" """ % self.doc.company.replace('"', '\"') + company = """and company="%s" """ % self.company.replace('"', '\"') else: company = "" count = frappe.db.sql("""select count(*) from `tab%s` @@ -352,7 +352,7 @@ class DocType(DocListController): count_sum = frappe.db.sql("""select count(*), sum(ifnull(`%s`, 0)) from `tab%s` where docstatus=1 and company = %s and date(creation)>=%s and date(creation)<=%s""" % (sum_field, doctype, "%s", - "%s", "%s"), (self.doc.company, self.from_date, self.to_date)) + "%s", "%s"), (self.company, self.from_date, self.to_date)) count, total = count_sum and count_sum[0] or (0, 0) return count, self.get_html(label, self.currency, @@ -379,7 +379,7 @@ class DocType(DocListController): where company=%s and posting_date <= %s %s""" % ("%s", "%s", from_date and "and posting_date>='%s'" % from_date or ""), - (self.doc.company, to_date or self.to_date), as_dict=1) + (self.company, to_date or self.to_date), as_dict=1) # cache if it is the normal cases if from_date==self.from_date and to_date==self.to_date: @@ -393,17 +393,17 @@ class DocType(DocListController): root_type, account_type, account_name, master_type from `tabAccount` where company=%s and docstatus < 2 and group_or_ledger = "Ledger" order by lft""", - (self.doc.company,), as_dict=1) + (self.company,), as_dict=1) return self.accounts def get_from_to_date(self): today = now_datetime().date() # decide from date based on email digest frequency - if self.doc.frequency == "Daily": + if self.frequency == "Daily": # from date, to_date is yesterday from_date = to_date = today - timedelta(days=1) - elif self.doc.frequency == "Weekly": + elif self.frequency == "Weekly": # from date is the previous week's monday from_date = today - timedelta(days=today.weekday(), weeks=1) # to date is sunday i.e. the previous day @@ -420,10 +420,10 @@ class DocType(DocListController): today = now_datetime().date() # decide from date based on email digest frequency - if self.doc.frequency == "Daily": + if self.frequency == "Daily": # from date, to_date is today from_date = to_date = today - elif self.doc.frequency == "Weekly": + elif self.frequency == "Weekly": # from date is the current week's monday from_date = today - timedelta(days=today.weekday()) # to date is the current week's sunday @@ -441,13 +441,13 @@ class DocType(DocListController): send_date = to_date + timedelta(days=1) - if self.doc.frequency == "Daily": + if self.frequency == "Daily": next_send_date = send_date + timedelta(days=1) - elif self.doc.frequency == "Weekly": + elif self.frequency == "Weekly": next_send_date = send_date + timedelta(weeks=1) else: next_send_date = send_date + relativedelta(months=1) - self.doc.next_send = formatdate(next_send_date) + " at midnight" + self.next_send = formatdate(next_send_date) + " at midnight" return send_date @@ -471,12 +471,10 @@ class DocType(DocListController): self.get_next_sending() def send(): - from frappe.model.code import get_obj - from frappe.utils import getdate now_date = now_datetime().date() for ed in frappe.db.sql("""select name from `tabEmail Digest` where enabled=1 and docstatus<2""", as_list=1): - ed_obj = get_obj('Email Digest', ed[0]) + ed_obj = frappe.get_doc('Email Digest', ed[0]) if (now_date == ed_obj.get_next_sending()): ed_obj.send() diff --git a/erpnext/setup/doctype/email_digest/email_digest.txt b/erpnext/setup/doctype/email_digest/email_digest.txt deleted file mode 100644 index 6660c250feb..00000000000 --- a/erpnext/setup/doctype/email_digest/email_digest.txt +++ /dev/null @@ -1,368 +0,0 @@ -[ - { - "creation": "2013-02-21 14:15:31", - "docstatus": 0, - "modified": "2014-03-19 11:39:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "Prompt", - "description": "Send regular summary reports via Email.", - "doctype": "DocType", - "document_type": "System", - "icon": "icon-envelope", - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Email Digest", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Email Digest", - "parentfield": "permissions", - "parenttype": "DocType", - "read": 1, - "role": "System Manager", - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Email Digest" - }, - { - "doctype": "DocField", - "fieldname": "settings", - "fieldtype": "Section Break", - "label": "Email Digest Settings" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "enabled", - "fieldtype": "Check", - "label": "Enabled" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "label": "For Company", - "options": "link:Company", - "reqd": 1 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "frequency", - "fieldtype": "Select", - "label": "How frequently?", - "options": "Daily\nWeekly\nMonthly", - "reqd": 1 - }, - { - "depends_on": "eval:doc.enabled", - "doctype": "DocField", - "fieldname": "next_send", - "fieldtype": "Data", - "label": "Next email will be sent on:", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break" - }, - { - "description": "Note: Email will not be sent to disabled users", - "doctype": "DocField", - "fieldname": "recipient_list", - "fieldtype": "Text", - "label": "Recipients", - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "addremove_recipients", - "fieldtype": "Button", - "label": "Add/Remove Recipients" - }, - { - "doctype": "DocField", - "fieldname": "accounts", - "fieldtype": "Section Break", - "label": "Accounts" - }, - { - "doctype": "DocField", - "fieldname": "accounts_module", - "fieldtype": "Column Break", - "label": "Income / Expense" - }, - { - "doctype": "DocField", - "fieldname": "income_year_to_date", - "fieldtype": "Check", - "label": "Income Year to Date" - }, - { - "description": "Balances of Accounts of type \"Bank\" or \"Cash\"", - "doctype": "DocField", - "fieldname": "bank_balance", - "fieldtype": "Check", - "label": "Bank/Cash Balance" - }, - { - "description": "Income booked for the digest period", - "doctype": "DocField", - "fieldname": "income", - "fieldtype": "Check", - "label": "Income Booked" - }, - { - "description": "Expenses booked for the digest period", - "doctype": "DocField", - "fieldname": "expenses_booked", - "fieldtype": "Check", - "label": "Expenses Booked" - }, - { - "description": "Receivable / Payable account will be identified based on the field Master Type", - "doctype": "DocField", - "fieldname": "column_break_16", - "fieldtype": "Column Break", - "label": "Receivables / Payables" - }, - { - "description": "Payments received during the digest period", - "doctype": "DocField", - "fieldname": "collections", - "fieldtype": "Check", - "label": "Payments Received" - }, - { - "description": "Payments made during the digest period", - "doctype": "DocField", - "fieldname": "payments", - "fieldtype": "Check", - "label": "Payments Made" - }, - { - "description": "Total amount of invoices sent to the customer during the digest period", - "doctype": "DocField", - "fieldname": "invoiced_amount", - "fieldtype": "Check", - "label": "Receivables" - }, - { - "description": "Total amount of invoices received from suppliers during the digest period", - "doctype": "DocField", - "fieldname": "payables", - "fieldtype": "Check", - "label": "Payables" - }, - { - "doctype": "DocField", - "fieldname": "section_break_20", - "fieldtype": "Section Break", - "label": "Buying & Selling" - }, - { - "doctype": "DocField", - "fieldname": "buying_module", - "fieldtype": "Column Break", - "label": "Buying" - }, - { - "doctype": "DocField", - "fieldname": "new_purchase_requests", - "fieldtype": "Check", - "label": "New Material Requests" - }, - { - "doctype": "DocField", - "fieldname": "new_supplier_quotations", - "fieldtype": "Check", - "label": "New Supplier Quotations" - }, - { - "doctype": "DocField", - "fieldname": "new_purchase_orders", - "fieldtype": "Check", - "label": "New Purchase Orders" - }, - { - "doctype": "DocField", - "fieldname": "selling_module", - "fieldtype": "Column Break", - "label": "Selling" - }, - { - "doctype": "DocField", - "fieldname": "new_leads", - "fieldtype": "Check", - "label": "New Leads" - }, - { - "doctype": "DocField", - "fieldname": "new_enquiries", - "fieldtype": "Check", - "label": "New Enquiries" - }, - { - "doctype": "DocField", - "fieldname": "new_quotations", - "fieldtype": "Check", - "label": "New Quotations" - }, - { - "doctype": "DocField", - "fieldname": "new_sales_orders", - "fieldtype": "Check", - "label": "New Sales Orders" - }, - { - "doctype": "DocField", - "fieldname": "section_break_34", - "fieldtype": "Section Break", - "label": "Inventory & Support" - }, - { - "doctype": "DocField", - "fieldname": "stock_module", - "fieldtype": "Column Break", - "label": "Stock" - }, - { - "doctype": "DocField", - "fieldname": "new_delivery_notes", - "fieldtype": "Check", - "label": "New Delivery Notes" - }, - { - "doctype": "DocField", - "fieldname": "new_purchase_receipts", - "fieldtype": "Check", - "label": "New Purchase Receipts" - }, - { - "doctype": "DocField", - "fieldname": "new_stock_entries", - "fieldtype": "Check", - "label": "New Stock Entries" - }, - { - "doctype": "DocField", - "fieldname": "support_module", - "fieldtype": "Column Break", - "label": "Support" - }, - { - "doctype": "DocField", - "fieldname": "new_support_tickets", - "fieldtype": "Check", - "label": "New Support Tickets" - }, - { - "doctype": "DocField", - "fieldname": "open_tickets", - "fieldtype": "Check", - "label": "Open Tickets" - }, - { - "doctype": "DocField", - "fieldname": "new_communications", - "fieldtype": "Check", - "label": "New Communications" - }, - { - "doctype": "DocField", - "fieldname": "section_break_40", - "fieldtype": "Section Break", - "label": "Projects & System" - }, - { - "doctype": "DocField", - "fieldname": "projects_module", - "fieldtype": "Column Break", - "label": "Projects" - }, - { - "doctype": "DocField", - "fieldname": "new_projects", - "fieldtype": "Check", - "label": "New Projects" - }, - { - "doctype": "DocField", - "fieldname": "core_module", - "fieldtype": "Column Break", - "label": "System" - }, - { - "doctype": "DocField", - "fieldname": "scheduler_errors", - "fieldtype": "Check", - "label": "Scheduler Failed Events" - }, - { - "doctype": "DocField", - "fieldname": "user_specific", - "fieldtype": "Section Break", - "label": "User Specific" - }, - { - "doctype": "DocField", - "fieldname": "general", - "fieldtype": "Column Break", - "label": "General" - }, - { - "doctype": "DocField", - "fieldname": "calendar_events", - "fieldtype": "Check", - "label": "Calendar Events" - }, - { - "doctype": "DocField", - "fieldname": "todo_list", - "fieldtype": "Check", - "label": "To Do List" - }, - { - "doctype": "DocField", - "fieldname": "stub", - "fieldtype": "Column Break", - "label": "Stub" - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "permlevel": 0, - "print": 1, - "report": 1, - "write": 1 - }, - { - "amend": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "permlevel": 1 - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/features_setup/features_setup.json b/erpnext/setup/doctype/features_setup/features_setup.json new file mode 100644 index 00000000000..8122da0c1e6 --- /dev/null +++ b/erpnext/setup/doctype/features_setup/features_setup.json @@ -0,0 +1,241 @@ +{ + "creation": "2012-12-20 12:50:49.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "materials", + "fieldtype": "Section Break", + "label": "Materials", + "permlevel": 0 + }, + { + "description": "To track item in sales and purchase documents based on their serial nos. This is can also used to track warranty details of the product.", + "fieldname": "fs_item_serial_nos", + "fieldtype": "Check", + "label": "Item Serial Nos", + "permlevel": 0 + }, + { + "description": "To track items in sales and purchase documents with batch nos
Preferred Industry: Chemicals etc", + "fieldname": "fs_item_batch_nos", + "fieldtype": "Check", + "label": "Item Batch Nos", + "permlevel": 0 + }, + { + "description": "To track brand name in the following documents
\nDelivery Note, Enuiry, Material Request, Item, Purchase Order, Purchase Voucher, Purchaser Receipt, Quotation, Sales Invoice, Sales BOM, Sales Order, Serial No", + "fieldname": "fs_brands", + "fieldtype": "Check", + "label": "Brands", + "permlevel": 0 + }, + { + "description": "To track items using barcode. You will be able to enter items in Delivery Note and Sales Invoice by scanning barcode of item.", + "fieldname": "fs_item_barcode", + "fieldtype": "Check", + "label": "Item Barcode", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "1. To maintain the customer wise item code and to make them searchable based on their code use this option", + "fieldname": "fs_item_advanced", + "fieldtype": "Check", + "label": "Item Advanced", + "permlevel": 0 + }, + { + "description": "If Sale BOM is defined, the actual BOM of the Pack is displayed as table.\nAvailable in Delivery Note and Sales Order", + "fieldname": "fs_packing_details", + "fieldtype": "Check", + "label": "Packing Details", + "permlevel": 0 + }, + { + "description": "To get Item Group in details table", + "fieldname": "fs_item_group_in_details", + "fieldtype": "Check", + "label": "Item Groups in Details", + "permlevel": 0 + }, + { + "fieldname": "sales_and_purchase", + "fieldtype": "Section Break", + "label": "Sales and Purchase", + "permlevel": 0 + }, + { + "description": "All export related fields like currency, conversion rate, export total, export grand total etc are available in
\nDelivery Note, POS, Quotation, Sales Invoice, Sales Order etc.", + "fieldname": "fs_exports", + "fieldtype": "Check", + "label": "Exports", + "permlevel": 0 + }, + { + "description": "All import related fields like currency, conversion rate, import total, import grand total etc are available in
\nPurchase Receipt, Supplier Quotation, Purchase Invoice, Purchase Order etc.", + "fieldname": "fs_imports", + "fieldtype": "Check", + "label": "Imports", + "permlevel": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "Field available in Delivery Note, Quotation, Sales Invoice, Sales Order", + "fieldname": "fs_discounts", + "fieldtype": "Check", + "label": "Sales Discounts", + "permlevel": 0 + }, + { + "description": "Discount Fields will be available in Purchase Order, Purchase Receipt, Purchase Invoice", + "fieldname": "fs_purchase_discounts", + "fieldtype": "Check", + "label": "Purchase Discounts", + "permlevel": 0 + }, + { + "description": "To track any installation or commissioning related work after sales", + "fieldname": "fs_after_sales_installations", + "fieldtype": "Check", + "label": "After Sale Installations", + "permlevel": 0 + }, + { + "description": "Available in \nBOM, Delivery Note, Purchase Invoice, Production Order, Purchase Order, Purchase Receipt, Sales Invoice, Sales Order, Stock Entry, Timesheet", + "fieldname": "fs_projects", + "fieldtype": "Check", + "label": "Projects", + "permlevel": 0 + }, + { + "description": "If you have Sales Team and Sale Partners (Channel Partners) they can be tagged and maintain their contribution in the sales activity", + "fieldname": "fs_sales_extras", + "fieldtype": "Check", + "label": "Sales Extras", + "permlevel": 0 + }, + { + "fieldname": "accounts", + "fieldtype": "Section Break", + "label": "Accounts", + "permlevel": 0 + }, + { + "description": "Check if you need automatic recurring invoices. After submitting any sales invoice, Recurring section will be visible.", + "fieldname": "fs_recurring_invoice", + "fieldtype": "Check", + "label": "Recurring Invoice", + "permlevel": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "To enable Point of Sale features", + "fieldname": "fs_pos", + "fieldtype": "Check", + "label": "Point of Sale", + "permlevel": 0 + }, + { + "description": "To enable Point of Sale view", + "fieldname": "fs_pos_view", + "fieldtype": "Check", + "label": "POS View", + "permlevel": 0 + }, + { + "fieldname": "production", + "fieldtype": "Section Break", + "label": "Manufacturing", + "permlevel": 0 + }, + { + "description": "If you involve in manufacturing activity
\nEnables item Is Manufactured", + "fieldname": "fs_manufacturing", + "fieldtype": "Check", + "label": "Manufacturing", + "permlevel": 0 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "If you follow Quality Inspection
\nEnables item QA Required and QA No in Purchase Receipt", + "fieldname": "fs_quality", + "fieldtype": "Check", + "label": "Quality", + "permlevel": 0 + }, + { + "fieldname": "miscelleneous", + "fieldtype": "Section Break", + "label": "Miscelleneous", + "permlevel": 0 + }, + { + "description": "If you have long print formats, this feature can be used to split the page to be printed on multiple pages with all headers and footers on each page", + "fieldname": "fs_page_break", + "fieldtype": "Check", + "label": "Page Break", + "permlevel": 0 + }, + { + "fieldname": "column_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "fs_more_info", + "fieldtype": "Check", + "label": "More Info", + "permlevel": 0 + } + ], + "icon": "icon-glass", + "idx": 1, + "issingle": 1, + "modified": "2013-12-24 11:40:19.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Features Setup", + "name_case": "Title Case", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "System Manager", + "submit": 0, + "write": 1 + }, + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "Administrator", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/features_setup/features_setup.py b/erpnext/setup/doctype/features_setup/features_setup.py index 0c9d6e45372..3d3367a4eb1 100644 --- a/erpnext/setup/doctype/features_setup/features_setup.py +++ b/erpnext/setup/doctype/features_setup/features_setup.py @@ -2,9 +2,9 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class FeaturesSetup(Document): def validate(self): """ @@ -12,6 +12,6 @@ class DocType: """ from frappe.model import default_fields from frappe.utils import set_default - for key in self.doc.fields: + for key in self.meta.get_valid_columns(): if key not in default_fields: - set_default(key, self.doc.fields[key]) + set_default(key, self.get(key)) diff --git a/erpnext/setup/doctype/features_setup/features_setup.txt b/erpnext/setup/doctype/features_setup/features_setup.txt deleted file mode 100644 index dd2df028def..00000000000 --- a/erpnext/setup/doctype/features_setup/features_setup.txt +++ /dev/null @@ -1,253 +0,0 @@ -[ - { - "creation": "2012-12-20 12:50:49", - "docstatus": 0, - "modified": "2013-12-24 11:40:19", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "icon": "icon-glass", - "issingle": 1, - "module": "Setup", - "name": "__common__", - "name_case": "Title Case" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Features Setup", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Features Setup", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Features Setup" - }, - { - "doctype": "DocField", - "fieldname": "materials", - "fieldtype": "Section Break", - "label": "Materials" - }, - { - "description": "To track item in sales and purchase documents based on their serial nos. This is can also used to track warranty details of the product.", - "doctype": "DocField", - "fieldname": "fs_item_serial_nos", - "fieldtype": "Check", - "label": "Item Serial Nos" - }, - { - "description": "To track items in sales and purchase documents with batch nos
Preferred Industry: Chemicals etc", - "doctype": "DocField", - "fieldname": "fs_item_batch_nos", - "fieldtype": "Check", - "label": "Item Batch Nos" - }, - { - "description": "To track brand name in the following documents
\nDelivery Note, Enuiry, Material Request, Item, Purchase Order, Purchase Voucher, Purchaser Receipt, Quotation, Sales Invoice, Sales BOM, Sales Order, Serial No", - "doctype": "DocField", - "fieldname": "fs_brands", - "fieldtype": "Check", - "label": "Brands" - }, - { - "description": "To track items using barcode. You will be able to enter items in Delivery Note and Sales Invoice by scanning barcode of item.", - "doctype": "DocField", - "fieldname": "fs_item_barcode", - "fieldtype": "Check", - "label": "Item Barcode" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break" - }, - { - "description": "1. To maintain the customer wise item code and to make them searchable based on their code use this option", - "doctype": "DocField", - "fieldname": "fs_item_advanced", - "fieldtype": "Check", - "label": "Item Advanced" - }, - { - "description": "If Sale BOM is defined, the actual BOM of the Pack is displayed as table.\nAvailable in Delivery Note and Sales Order", - "doctype": "DocField", - "fieldname": "fs_packing_details", - "fieldtype": "Check", - "label": "Packing Details" - }, - { - "description": "To get Item Group in details table", - "doctype": "DocField", - "fieldname": "fs_item_group_in_details", - "fieldtype": "Check", - "label": "Item Groups in Details" - }, - { - "doctype": "DocField", - "fieldname": "sales_and_purchase", - "fieldtype": "Section Break", - "label": "Sales and Purchase" - }, - { - "description": "All export related fields like currency, conversion rate, export total, export grand total etc are available in
\nDelivery Note, POS, Quotation, Sales Invoice, Sales Order etc.", - "doctype": "DocField", - "fieldname": "fs_exports", - "fieldtype": "Check", - "label": "Exports" - }, - { - "description": "All import related fields like currency, conversion rate, import total, import grand total etc are available in
\nPurchase Receipt, Supplier Quotation, Purchase Invoice, Purchase Order etc.", - "doctype": "DocField", - "fieldname": "fs_imports", - "fieldtype": "Check", - "label": "Imports" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break" - }, - { - "description": "Field available in Delivery Note, Quotation, Sales Invoice, Sales Order", - "doctype": "DocField", - "fieldname": "fs_discounts", - "fieldtype": "Check", - "label": "Sales Discounts" - }, - { - "description": "Discount Fields will be available in Purchase Order, Purchase Receipt, Purchase Invoice", - "doctype": "DocField", - "fieldname": "fs_purchase_discounts", - "fieldtype": "Check", - "label": "Purchase Discounts" - }, - { - "description": "To track any installation or commissioning related work after sales", - "doctype": "DocField", - "fieldname": "fs_after_sales_installations", - "fieldtype": "Check", - "label": "After Sale Installations" - }, - { - "description": "Available in \nBOM, Delivery Note, Purchase Invoice, Production Order, Purchase Order, Purchase Receipt, Sales Invoice, Sales Order, Stock Entry, Timesheet", - "doctype": "DocField", - "fieldname": "fs_projects", - "fieldtype": "Check", - "label": "Projects" - }, - { - "description": "If you have Sales Team and Sale Partners (Channel Partners) they can be tagged and maintain their contribution in the sales activity", - "doctype": "DocField", - "fieldname": "fs_sales_extras", - "fieldtype": "Check", - "label": "Sales Extras" - }, - { - "doctype": "DocField", - "fieldname": "accounts", - "fieldtype": "Section Break", - "label": "Accounts" - }, - { - "description": "Check if you need automatic recurring invoices. After submitting any sales invoice, Recurring section will be visible.", - "doctype": "DocField", - "fieldname": "fs_recurring_invoice", - "fieldtype": "Check", - "label": "Recurring Invoice" - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break" - }, - { - "description": "To enable Point of Sale features", - "doctype": "DocField", - "fieldname": "fs_pos", - "fieldtype": "Check", - "label": "Point of Sale" - }, - { - "description": "To enable Point of Sale view", - "doctype": "DocField", - "fieldname": "fs_pos_view", - "fieldtype": "Check", - "label": "POS View" - }, - { - "doctype": "DocField", - "fieldname": "production", - "fieldtype": "Section Break", - "label": "Manufacturing" - }, - { - "description": "If you involve in manufacturing activity
\nEnables item Is Manufactured", - "doctype": "DocField", - "fieldname": "fs_manufacturing", - "fieldtype": "Check", - "label": "Manufacturing" - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break" - }, - { - "description": "If you follow Quality Inspection
\nEnables item QA Required and QA No in Purchase Receipt", - "doctype": "DocField", - "fieldname": "fs_quality", - "fieldtype": "Check", - "label": "Quality" - }, - { - "doctype": "DocField", - "fieldname": "miscelleneous", - "fieldtype": "Section Break", - "label": "Miscelleneous" - }, - { - "description": "If you have long print formats, this feature can be used to split the page to be printed on multiple pages with all headers and footers on each page", - "doctype": "DocField", - "fieldname": "fs_page_break", - "fieldtype": "Check", - "label": "Page Break" - }, - { - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "fs_more_info", - "fieldtype": "Check", - "label": "More Info" - }, - { - "doctype": "DocPerm", - "role": "System Manager" - }, - { - "doctype": "DocPerm", - "role": "Administrator" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.js b/erpnext/setup/doctype/global_defaults/global_defaults.js index 4b378b3d7e2..85d718ae799 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.js +++ b/erpnext/setup/doctype/global_defaults/global_defaults.js @@ -18,7 +18,7 @@ $.extend(cur_frm.cscript, { }, validate: function(doc, cdt, cdn) { - return $c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){ + return $c_obj(doc, 'get_defaults', '', function(r, rt){ sys_defaults = r.message; }); }, diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.json b/erpnext/setup/doctype/global_defaults/global_defaults.json new file mode 100644 index 00000000000..5a5f21e38a6 --- /dev/null +++ b/erpnext/setup/doctype/global_defaults/global_defaults.json @@ -0,0 +1,174 @@ +{ + "allow_copy": 1, + "creation": "2013-05-02 17:53:24.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "date_and_number_settings", + "fieldtype": "Section Break", + "label": "Date and Number Settings", + "permlevel": 0 + }, + { + "default": "dd-mm-yyyy", + "fieldname": "date_format", + "fieldtype": "Select", + "label": "Date Format", + "options": "yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "This is the default number format. For currencies, please set the number format in the currency master.", + "fieldname": "number_format", + "fieldtype": "Select", + "label": "Number Format", + "options": "\n#,###.##\n#.###,##\n# ###.##\n#,###.###\n#,##,###.##\n#.###\n#,###", + "permlevel": 0, + "read_only": 0 + }, + { + "default": "3", + "description": "Precision for Float fields (quantities, discounts, percentages etc). Floats will be rounded up to specified decimals. Default = 3", + "fieldname": "float_precision", + "fieldtype": "Select", + "label": "Float Precision", + "options": "\n2\n3\n4\n5\n6", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "If disable, 'Rounded Total' field will not be visible in any transaction", + "fieldname": "disable_rounded_total", + "fieldtype": "Check", + "label": "Disable Rounded Total", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "currency_settings", + "fieldtype": "Section Break", + "label": "Currency Settings", + "permlevel": 0 + }, + { + "default": "INR", + "fieldname": "default_currency", + "fieldtype": "Link", + "label": "Default Currency", + "options": "Currency", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "description": "Do not show any symbol like $ etc next to currencies.", + "fieldname": "hide_currency_symbol", + "fieldtype": "Select", + "label": "Hide Currency Symbol", + "options": "\nNo\nYes", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "company", + "fieldtype": "Section Break", + "label": "Company Settings", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "default_company", + "fieldtype": "Link", + "label": "Default Company", + "options": "Company", + "permlevel": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "current_fiscal_year", + "fieldtype": "Link", + "label": "Current Fiscal Year", + "options": "Fiscal Year", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "system", + "fieldtype": "Section Break", + "label": "System Settings", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Session Expiry in Hours e.g. 06:00", + "fieldname": "session_expiry", + "fieldtype": "Data", + "label": "Session Expiry", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "country", + "fieldtype": "Select", + "label": "Country", + "options": "link:Country", + "permlevel": 0 + }, + { + "fieldname": "sms_sender_name", + "fieldtype": "Data", + "label": "SMS Sender Name", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "For Server Side Print Formats", + "fieldname": "print_style", + "fieldtype": "Select", + "label": "Print Format Style", + "options": "Standard\nClassic\nModern\nSpartan", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "time_zone", + "fieldtype": "Select", + "label": "Time Zone", + "permlevel": 0 + } + ], + "hide_toolbar": 0, + "icon": "icon-cog", + "idx": 1, + "in_create": 1, + "issingle": 1, + "modified": "2014-02-19 19:11:58.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Global Defaults", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "permlevel": 0, + "read": 1, + "report": 0, + "role": "System Manager", + "submit": 0, + "write": 1 + } + ], + "read_only": 1 +} \ No newline at end of file diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.py b/erpnext/setup/doctype/global_defaults/global_defaults.py index d61ff8a00ef..93d75a1d2e9 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.py +++ b/erpnext/setup/doctype/global_defaults/global_defaults.py @@ -22,21 +22,21 @@ keydict = { 'disable_rounded_total': 'disable_rounded_total', } -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class GlobalDefaults(Document): def on_update(self): """update defaults""" self.validate_session_expiry() - self.update_control_panel() + self.set_country_and_timezone() for key in keydict: - frappe.db.set_default(key, self.doc.fields.get(keydict[key], '')) + frappe.db.set_default(key, self.get(keydict[key], '')) # update year start date and year end date from fiscal_year year_start_end_date = frappe.db.sql("""select year_start_date, year_end_date - from `tabFiscal Year` where name=%s""", self.doc.current_fiscal_year) + from `tabFiscal Year` where name=%s""", self.current_fiscal_year) ysd = year_start_end_date[0][0] or '' yed = year_start_end_date[0][1] or '' @@ -46,27 +46,22 @@ class DocType: frappe.db.set_default('year_end_date', yed.strftime('%Y-%m-%d')) # enable default currency - if self.doc.default_currency: - frappe.db.set_value("Currency", self.doc.default_currency, "enabled", 1) + if self.default_currency: + frappe.db.set_value("Currency", self.default_currency, "enabled", 1) # clear cache frappe.clear_cache() def validate_session_expiry(self): - if self.doc.session_expiry: - parts = self.doc.session_expiry.split(":") + if self.session_expiry: + parts = self.session_expiry.split(":") if len(parts)!=2 or not (cint(parts[0]) or cint(parts[1])): frappe.msgprint("""Session Expiry must be in format hh:mm""", raise_exception=1) - def update_control_panel(self): - cp_bean = frappe.bean("Control Panel") - if self.doc.country: - cp_bean.doc.country = self.doc.country - if self.doc.time_zone: - cp_bean.doc.time_zone = self.doc.time_zone - cp_bean.ignore_permissions = True - cp_bean.save() + def set_country_and_timezone(self): + frappe.db.set_default("country", self.country) + frappe.db.set_default("time_zone", self.time_zone) def get_defaults(self): return frappe.defaults.get_defaults() diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.txt b/erpnext/setup/doctype/global_defaults/global_defaults.txt deleted file mode 100644 index 31ba0df9ce7..00000000000 --- a/erpnext/setup/doctype/global_defaults/global_defaults.txt +++ /dev/null @@ -1,193 +0,0 @@ -[ - { - "creation": "2013-05-02 17:53:24", - "docstatus": 0, - "modified": "2014-02-19 19:11:58", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_copy": 1, - "doctype": "DocType", - "hide_toolbar": 0, - "icon": "icon-cog", - "in_create": 1, - "issingle": 1, - "module": "Setup", - "name": "__common__", - "read_only": 1 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Global Defaults", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Global Defaults", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 0, - "role": "System Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Global Defaults" - }, - { - "doctype": "DocField", - "fieldname": "date_and_number_settings", - "fieldtype": "Section Break", - "label": "Date and Number Settings" - }, - { - "default": "dd-mm-yyyy", - "doctype": "DocField", - "fieldname": "date_format", - "fieldtype": "Select", - "label": "Date Format", - "options": "yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy", - "read_only": 0 - }, - { - "description": "This is the default number format. For currencies, please set the number format in the currency master.", - "doctype": "DocField", - "fieldname": "number_format", - "fieldtype": "Select", - "label": "Number Format", - "options": "\n#,###.##\n#.###,##\n# ###.##\n#,###.###\n#,##,###.##\n#.###\n#,###", - "read_only": 0 - }, - { - "default": "3", - "description": "Precision for Float fields (quantities, discounts, percentages etc). Floats will be rounded up to specified decimals. Default = 3", - "doctype": "DocField", - "fieldname": "float_precision", - "fieldtype": "Select", - "label": "Float Precision", - "options": "\n2\n3\n4\n5\n6", - "read_only": 0 - }, - { - "description": "If disable, 'Rounded Total' field will not be visible in any transaction", - "doctype": "DocField", - "fieldname": "disable_rounded_total", - "fieldtype": "Check", - "label": "Disable Rounded Total", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "currency_settings", - "fieldtype": "Section Break", - "label": "Currency Settings" - }, - { - "default": "INR", - "doctype": "DocField", - "fieldname": "default_currency", - "fieldtype": "Link", - "label": "Default Currency", - "options": "Currency", - "read_only": 0, - "reqd": 1 - }, - { - "description": "Do not show any symbol like $ etc next to currencies.", - "doctype": "DocField", - "fieldname": "hide_currency_symbol", - "fieldtype": "Select", - "label": "Hide Currency Symbol", - "options": "\nNo\nYes", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Section Break", - "label": "Company Settings", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "default_company", - "fieldtype": "Link", - "label": "Default Company", - "options": "Company", - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "current_fiscal_year", - "fieldtype": "Link", - "label": "Current Fiscal Year", - "options": "Fiscal Year", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "system", - "fieldtype": "Section Break", - "label": "System Settings", - "read_only": 0 - }, - { - "description": "Session Expiry in Hours e.g. 06:00", - "doctype": "DocField", - "fieldname": "session_expiry", - "fieldtype": "Data", - "label": "Session Expiry", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "country", - "fieldtype": "Select", - "label": "Country", - "options": "link:Country" - }, - { - "doctype": "DocField", - "fieldname": "sms_sender_name", - "fieldtype": "Data", - "label": "SMS Sender Name", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_3", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "description": "For Server Side Print Formats", - "doctype": "DocField", - "fieldname": "print_style", - "fieldtype": "Select", - "label": "Print Format Style", - "options": "Standard\nClassic\nModern\nSpartan", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "time_zone", - "fieldtype": "Select", - "label": "Time Zone" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/item_group/item_group.json b/erpnext/setup/doctype/item_group/item_group.json new file mode 100644 index 00000000000..592673edcb2 --- /dev/null +++ b/erpnext/setup/doctype/item_group/item_group.json @@ -0,0 +1,239 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:item_group_name", + "creation": "2013-03-28 10:35:29.000000", + "description": "Item Classification", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "item_group_name", + "fieldtype": "Data", + "label": "Item Group Name", + "no_copy": 0, + "oldfieldname": "item_group_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "page_name", + "fieldtype": "Data", + "label": "Page Name", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "cb0", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "Add / Edit", + "fieldname": "parent_item_group", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Parent Item Group", + "no_copy": 0, + "oldfieldname": "parent_item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "reqd": 0, + "search_index": 0 + }, + { + "description": "Only leaf nodes are allowed in transaction", + "fieldname": "is_group", + "fieldtype": "Select", + "label": "Has Child Node", + "no_copy": 0, + "oldfieldname": "is_group", + "oldfieldtype": "Select", + "options": "\nYes\nNo", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "sb9", + "fieldtype": "Section Break", + "label": "Website Settings", + "permlevel": 0 + }, + { + "description": "Check this if you want to show in website", + "fieldname": "show_in_website", + "fieldtype": "Check", + "label": "Show in Website", + "no_copy": 0, + "permlevel": 0, + "search_index": 0 + }, + { + "depends_on": "show_in_website", + "fieldname": "parent_website_route", + "fieldtype": "Link", + "label": "Parent Website Page", + "options": "Website Route", + "permlevel": 0 + }, + { + "depends_on": "show_in_website", + "description": "Show this slideshow at the top of the page", + "fieldname": "slideshow", + "fieldtype": "Link", + "label": "Slideshow", + "options": "Website Slideshow", + "permlevel": 0 + }, + { + "depends_on": "show_in_website", + "description": "HTML / Banner that will show on the top of product list.", + "fieldname": "description", + "fieldtype": "Text Editor", + "label": "Description", + "permlevel": 0 + }, + { + "depends_on": "show_in_website", + "fieldname": "item_website_specifications", + "fieldtype": "Table", + "label": "Item Website Specifications", + "options": "Item Website Specification", + "permlevel": 0 + }, + { + "fieldname": "lft", + "fieldtype": "Int", + "hidden": 1, + "in_filter": 1, + "label": "lft", + "no_copy": 1, + "oldfieldname": "lft", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1, + "report_hide": 0, + "search_index": 1 + }, + { + "fieldname": "rgt", + "fieldtype": "Int", + "hidden": 1, + "in_filter": 1, + "label": "rgt", + "no_copy": 1, + "oldfieldname": "rgt", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1, + "report_hide": 0, + "search_index": 1 + }, + { + "description": "Add / Edit", + "fieldname": "old_parent", + "fieldtype": "Link", + "hidden": 1, + "ignore_restrictions": 1, + "label": "old_parent", + "no_copy": 1, + "oldfieldname": "old_parent", + "oldfieldtype": "Data", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1, + "search_index": 0 + } + ], + "icon": "icon-sitemap", + "idx": 1, + "in_create": 1, + "issingle": 0, + "max_attachments": 3, + "modified": "2014-02-20 18:29:57.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Item Group", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Manager", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, + "write": 0 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Master Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User" + }, + { + "cancel": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User" + }, + { + "cancel": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User" + } + ], + "search_fields": "parent_item_group" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index aa1002e66f6..4b0dc117c86 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -4,27 +4,35 @@ from __future__ import unicode_literals import frappe -from frappe.utils.nestedset import DocTypeNestedSet +from frappe.utils.nestedset import NestedSet +from frappe.website.website_generator import WebsiteGenerator + +class ItemGroup(NestedSet, WebsiteGenerator): + nsm_parent_field = 'parent_item_group' + + def autoname(self): + self.name = self.item_group_name -class DocType(DocTypeNestedSet): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.nsm_parent_field = 'parent_item_group' - def validate(self): - if not self.doc.parent_website_route: - self.doc.parent_website_route = frappe.get_website_route("Item Group", - self.doc.parent_item_group) - + if not self.parent_website_route: + self.parent_website_route = frappe.get_website_route("Item Group", + self.parent_item_group) + def on_update(self): - DocTypeNestedSet.on_update(self) - + NestedSet.on_update(self) + WebsiteGenerator.on_update(self) self.validate_name_with_item() - self.validate_one_root() - + + def after_rename(self, olddn, newdn, merge=False): + NestedSet.after_rename(self, olddn, newdn, merge) + WebsiteGenerator.after_rename(self, olddn, newdn, merge) + + def on_trash(self): + NestedSet.on_trash(self) + WebsiteGenerator.on_trash(self) + def validate_name_with_item(self): - if frappe.db.exists("Item", self.doc.name): + if frappe.db.exists("Item", self.name): frappe.msgprint("An item exists with same name (%s), please change the \ - item group name or rename the item" % self.doc.name, raise_exception=1) + item group name or rename the item" % self.name, raise_exception=1) diff --git a/erpnext/setup/doctype/item_group/item_group.txt b/erpnext/setup/doctype/item_group/item_group.txt deleted file mode 100644 index 8bd9e7f237e..00000000000 --- a/erpnext/setup/doctype/item_group/item_group.txt +++ /dev/null @@ -1,228 +0,0 @@ -[ - { - "creation": "2013-03-28 10:35:29", - "docstatus": 0, - "modified": "2014-02-20 18:29:57", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:item_group_name", - "description": "Item Classification", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-sitemap", - "in_create": 1, - "issingle": 0, - "max_attachments": 3, - "module": "Setup", - "name": "__common__", - "search_fields": "parent_item_group" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Item Group", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "delete": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Item Group", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Item Group" - }, - { - "doctype": "DocField", - "fieldname": "item_group_name", - "fieldtype": "Data", - "label": "Item Group Name", - "no_copy": 0, - "oldfieldname": "item_group_name", - "oldfieldtype": "Data", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "page_name", - "fieldtype": "Data", - "label": "Page Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb0", - "fieldtype": "Column Break" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "parent_item_group", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Parent Item Group", - "no_copy": 0, - "oldfieldname": "parent_item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "reqd": 0, - "search_index": 0 - }, - { - "description": "Only leaf nodes are allowed in transaction", - "doctype": "DocField", - "fieldname": "is_group", - "fieldtype": "Select", - "label": "Has Child Node", - "no_copy": 0, - "oldfieldname": "is_group", - "oldfieldtype": "Select", - "options": "\nYes\nNo", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "sb9", - "fieldtype": "Section Break", - "label": "Website Settings" - }, - { - "description": "Check this if you want to show in website", - "doctype": "DocField", - "fieldname": "show_in_website", - "fieldtype": "Check", - "label": "Show in Website", - "no_copy": 0, - "search_index": 0 - }, - { - "depends_on": "show_in_website", - "doctype": "DocField", - "fieldname": "parent_website_route", - "fieldtype": "Link", - "label": "Parent Website Page", - "options": "Website Route" - }, - { - "depends_on": "show_in_website", - "description": "Show this slideshow at the top of the page", - "doctype": "DocField", - "fieldname": "slideshow", - "fieldtype": "Link", - "label": "Slideshow", - "options": "Website Slideshow" - }, - { - "depends_on": "show_in_website", - "description": "HTML / Banner that will show on the top of product list.", - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text Editor", - "label": "Description" - }, - { - "depends_on": "show_in_website", - "doctype": "DocField", - "fieldname": "item_website_specifications", - "fieldtype": "Table", - "label": "Item Website Specifications", - "options": "Item Website Specification" - }, - { - "doctype": "DocField", - "fieldname": "lft", - "fieldtype": "Int", - "hidden": 1, - "in_filter": 1, - "label": "lft", - "no_copy": 1, - "oldfieldname": "lft", - "oldfieldtype": "Int", - "print_hide": 1, - "report_hide": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "rgt", - "fieldtype": "Int", - "hidden": 1, - "in_filter": 1, - "label": "rgt", - "no_copy": 1, - "oldfieldname": "rgt", - "oldfieldtype": "Int", - "print_hide": 1, - "report_hide": 0, - "search_index": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "old_parent", - "fieldtype": "Link", - "hidden": 1, - "ignore_restrictions": 1, - "label": "old_parent", - "no_copy": 1, - "oldfieldname": "old_parent", - "oldfieldtype": "Data", - "options": "Item Group", - "print_hide": 1, - "report_hide": 1, - "search_index": 0 - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "role": "Material Manager", - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "role": "Material User", - "submit": 0, - "write": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "Material Master Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "doctype": "DocPerm", - "role": "Purchase User" - }, - { - "doctype": "DocPerm", - "role": "Accounts User" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/item_group/test_item_group.py b/erpnext/setup/doctype/item_group/test_item_group.py index 0f174ed5991..3eac0aae6e7 100644 --- a/erpnext/setup/doctype/item_group/test_item_group.py +++ b/erpnext/setup/doctype/item_group/test_item_group.py @@ -7,88 +7,20 @@ import frappe from frappe.utils.nestedset import NestedSetRecursionError, NestedSetMultipleRootsError, \ NestedSetChildExistsError, NestedSetInvalidMergeError, rebuild_tree, get_ancestors_of -test_records = [ - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group", - "parent_item_group": "All Item Groups", - "is_group": "No" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group Desktops", - "parent_item_group": "All Item Groups", - "is_group": "No" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group A", - "parent_item_group": "All Item Groups", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group B", - "parent_item_group": "All Item Groups", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group B - 1", - "parent_item_group": "_Test Item Group B", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group B - 2", - "parent_item_group": "_Test Item Group B", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group B - 3", - "parent_item_group": "_Test Item Group B", - "is_group": "No" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group C", - "parent_item_group": "All Item Groups", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group C - 1", - "parent_item_group": "_Test Item Group C", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group C - 2", - "parent_item_group": "_Test Item Group C", - "is_group": "Yes" - }], - [{ - "doctype": "Item Group", - "item_group_name": "_Test Item Group D", - "parent_item_group": "All Item Groups", - "is_group": "Yes" - }], -] +test_records = frappe.get_test_records('Item Group') class TestItem(unittest.TestCase): def test_basic_tree(self, records=None): min_lft = 1 max_rgt = frappe.db.sql("select max(rgt) from `tabItem Group`")[0][0] - + if not records: records = test_records[2:] - + for item_group in records: - item_group = item_group[0] - lft, rgt, parent_item_group = frappe.db.get_value("Item Group", item_group["item_group_name"], + lft, rgt, parent_item_group = frappe.db.get_value("Item Group", item_group["item_group_name"], ["lft", "rgt", "parent_item_group"]) - + if parent_item_group: parent_lft, parent_rgt = frappe.db.get_value("Item Group", parent_item_group, ["lft", "rgt"]) @@ -96,7 +28,7 @@ class TestItem(unittest.TestCase): # root parent_lft = min_lft - 1 parent_rgt = max_rgt + 1 - + self.assertTrue(lft) self.assertTrue(rgt) self.assertTrue(lft < rgt) @@ -105,171 +37,171 @@ class TestItem(unittest.TestCase): self.assertTrue(rgt < parent_rgt) self.assertTrue(lft >= min_lft) self.assertTrue(rgt <= max_rgt) - + no_of_children = self.get_no_of_children(item_group["item_group_name"]) self.assertTrue(rgt == (lft + 1 + (2 * no_of_children))) - + no_of_children = self.get_no_of_children(parent_item_group) self.assertTrue(parent_rgt == (parent_lft + 1 + (2 * no_of_children))) - + def get_no_of_children(self, item_group): def get_no_of_children(item_groups, no_of_children): children = [] for ig in item_groups: children += frappe.db.sql_list("""select name from `tabItem Group` where ifnull(parent_item_group, '')=%s""", ig or '') - + if len(children): return get_no_of_children(children, no_of_children + len(children)) else: return no_of_children - + return get_no_of_children([item_group], 0) - + def test_recursion(self): - group_b = frappe.bean("Item Group", "_Test Item Group B") - group_b.doc.parent_item_group = "_Test Item Group B - 3" + group_b = frappe.get_doc("Item Group", "_Test Item Group B") + group_b.parent_item_group = "_Test Item Group B - 3" self.assertRaises(NestedSetRecursionError, group_b.save) - + # cleanup - group_b.doc.parent_item_group = "All Item Groups" + group_b.parent_item_group = "All Item Groups" group_b.save() - + def test_rebuild_tree(self): rebuild_tree("Item Group", "parent_item_group") self.test_basic_tree() - + def move_it_back(self): - group_b = frappe.bean("Item Group", "_Test Item Group B") - group_b.doc.parent_item_group = "All Item Groups" + group_b = frappe.get_doc("Item Group", "_Test Item Group B") + group_b.parent_item_group = "All Item Groups" group_b.save() self.test_basic_tree() - + def test_move_group_into_another(self): # before move old_lft, old_rgt = frappe.db.get_value("Item Group", "_Test Item Group C", ["lft", "rgt"]) - + # put B under C - group_b = frappe.bean("Item Group", "_Test Item Group B") - lft, rgt = group_b.doc.lft, group_b.doc.rgt - - group_b.doc.parent_item_group = "_Test Item Group C" + group_b = frappe.get_doc("Item Group", "_Test Item Group B") + lft, rgt = group_b.lft, group_b.rgt + + group_b.parent_item_group = "_Test Item Group C" group_b.save() self.test_basic_tree() - + # after move new_lft, new_rgt = frappe.db.get_value("Item Group", "_Test Item Group C", ["lft", "rgt"]) - + # lft should reduce self.assertEquals(old_lft - new_lft, rgt - lft + 1) - + # adjacent siblings, hence rgt diff will be 0 self.assertEquals(new_rgt - old_rgt, 0) - + self.move_it_back() - + def test_move_group_into_root(self): - group_b = frappe.bean("Item Group", "_Test Item Group B") - group_b.doc.parent_item_group = "" + group_b = frappe.get_doc("Item Group", "_Test Item Group B") + group_b.parent_item_group = "" self.assertRaises(NestedSetMultipleRootsError, group_b.save) # trick! works because it hasn't been rolled back :D self.test_basic_tree() - + self.move_it_back() - + def print_tree(self): import json print json.dumps(frappe.db.sql("select name, lft, rgt from `tabItem Group` order by lft"), indent=1) - + def test_move_leaf_into_another_group(self): # before move old_lft, old_rgt = frappe.db.get_value("Item Group", "_Test Item Group C", ["lft", "rgt"]) - - group_b_3 = frappe.bean("Item Group", "_Test Item Group B - 3") - lft, rgt = group_b_3.doc.lft, group_b_3.doc.rgt - + + group_b_3 = frappe.get_doc("Item Group", "_Test Item Group B - 3") + lft, rgt = group_b_3.lft, group_b_3.rgt + # child of right sibling is moved into it - group_b_3.doc.parent_item_group = "_Test Item Group C" + group_b_3.parent_item_group = "_Test Item Group C" group_b_3.save() self.test_basic_tree() - + new_lft, new_rgt = frappe.db.get_value("Item Group", "_Test Item Group C", ["lft", "rgt"]) - + # lft should remain the same self.assertEquals(old_lft - new_lft, 0) - + # rgt should increase self.assertEquals(new_rgt - old_rgt, rgt - lft + 1) - + # move it back - group_b_3 = frappe.bean("Item Group", "_Test Item Group B - 3") - group_b_3.doc.parent_item_group = "_Test Item Group B" + group_b_3 = frappe.get_doc("Item Group", "_Test Item Group B - 3") + group_b_3.parent_item_group = "_Test Item Group B" group_b_3.save() self.test_basic_tree() - + def test_delete_leaf(self): # for checking later parent_item_group = frappe.db.get_value("Item Group", "_Test Item Group B - 3", "parent_item_group") rgt = frappe.db.get_value("Item Group", parent_item_group, "rgt") - + ancestors = get_ancestors_of("Item Group", "_Test Item Group B - 3") ancestors = frappe.db.sql("""select name, rgt from `tabItem Group` where name in ({})""".format(", ".join(["%s"]*len(ancestors))), tuple(ancestors), as_dict=True) - + frappe.delete_doc("Item Group", "_Test Item Group B - 3") records_to_test = test_records[2:] del records_to_test[4] self.test_basic_tree(records=records_to_test) - + # rgt of each ancestor would reduce by 2 for item_group in ancestors: new_lft, new_rgt = frappe.db.get_value("Item Group", item_group.name, ["lft", "rgt"]) self.assertEquals(new_rgt, item_group.rgt - 2) - + # insert it back - frappe.bean(copy=test_records[6]).insert() - + frappe.copy_doc(test_records[6]).insert() + self.test_basic_tree() - + def test_delete_group(self): # cannot delete group with child, but can delete leaf self.assertRaises(NestedSetChildExistsError, frappe.delete_doc, "Item Group", "_Test Item Group B") - + def test_merge_groups(self): frappe.rename_doc("Item Group", "_Test Item Group B", "_Test Item Group C", merge=True) records_to_test = test_records[2:] del records_to_test[1] self.test_basic_tree(records=records_to_test) - + # insert Group B back - frappe.bean(copy=test_records[3]).insert() + frappe.copy_doc(test_records[3]).insert() self.test_basic_tree() - + # move its children back for name in frappe.db.sql_list("""select name from `tabItem Group` where parent_item_group='_Test Item Group C'"""): - - bean = frappe.bean("Item Group", name) - bean.doc.parent_item_group = "_Test Item Group B" - bean.save() + + doc = frappe.get_doc("Item Group", name) + doc.parent_item_group = "_Test Item Group B" + doc.save() self.test_basic_tree() - + def test_merge_leaves(self): frappe.rename_doc("Item Group", "_Test Item Group B - 2", "_Test Item Group B - 1", merge=True) records_to_test = test_records[2:] del records_to_test[3] self.test_basic_tree(records=records_to_test) - + # insert Group B - 2back - frappe.bean(copy=test_records[5]).insert() + frappe.copy_doc(test_records[5]).insert() self.test_basic_tree() - + def test_merge_leaf_into_group(self): - self.assertRaises(NestedSetInvalidMergeError, frappe.rename_doc, "Item Group", "_Test Item Group B - 3", + self.assertRaises(NestedSetInvalidMergeError, frappe.rename_doc, "Item Group", "_Test Item Group B - 3", "_Test Item Group B", merge=True) - + def test_merge_group_into_leaf(self): - self.assertRaises(NestedSetInvalidMergeError, frappe.rename_doc, "Item Group", "_Test Item Group B", - "_Test Item Group B - 3", merge=True) \ No newline at end of file + self.assertRaises(NestedSetInvalidMergeError, frappe.rename_doc, "Item Group", "_Test Item Group B", + "_Test Item Group B - 3", merge=True) diff --git a/erpnext/setup/doctype/item_group/test_records.json b/erpnext/setup/doctype/item_group/test_records.json new file mode 100644 index 00000000000..d85fa2266bd --- /dev/null +++ b/erpnext/setup/doctype/item_group/test_records.json @@ -0,0 +1,68 @@ +[ + { + "doctype": "Item Group", + "is_group": "No", + "item_group_name": "_Test Item Group", + "parent_item_group": "All Item Groups" + }, + { + "doctype": "Item Group", + "is_group": "No", + "item_group_name": "_Test Item Group Desktops", + "parent_item_group": "All Item Groups" + }, + { + "doctype": "Item Group", + "is_group": "Yes", + "item_group_name": "_Test Item Group A", + "parent_item_group": "All Item Groups" + }, + { + "doctype": "Item Group", + "is_group": "Yes", + "item_group_name": "_Test Item Group B", + "parent_item_group": "All Item Groups" + }, + { + "doctype": "Item Group", + "is_group": "Yes", + "item_group_name": "_Test Item Group B - 1", + "parent_item_group": "_Test Item Group B" + }, + { + "doctype": "Item Group", + "is_group": "Yes", + "item_group_name": "_Test Item Group B - 2", + "parent_item_group": "_Test Item Group B" + }, + { + "doctype": "Item Group", + "is_group": "No", + "item_group_name": "_Test Item Group B - 3", + "parent_item_group": "_Test Item Group B" + }, + { + "doctype": "Item Group", + "is_group": "Yes", + "item_group_name": "_Test Item Group C", + "parent_item_group": "All Item Groups" + }, + { + "doctype": "Item Group", + "is_group": "Yes", + "item_group_name": "_Test Item Group C - 1", + "parent_item_group": "_Test Item Group C" + }, + { + "doctype": "Item Group", + "is_group": "Yes", + "item_group_name": "_Test Item Group C - 2", + "parent_item_group": "_Test Item Group C" + }, + { + "doctype": "Item Group", + "is_group": "Yes", + "item_group_name": "_Test Item Group D", + "parent_item_group": "All Item Groups" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.json b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.json new file mode 100644 index 00000000000..e6fec9d61c5 --- /dev/null +++ b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.json @@ -0,0 +1,73 @@ +{ + "creation": "2013-01-15 16:50:01.000000", + "description": "Email settings for jobs email id \"jobs@example.com\"", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Settings to extract Job Applicants from a mailbox e.g. \"jobs@example.com\"", + "fieldname": "pop3_mail_settings", + "fieldtype": "Section Break", + "label": "POP3 Mail Settings", + "permlevel": 0 + }, + { + "description": "Check to activate", + "fieldname": "extract_emails", + "fieldtype": "Check", + "label": "Extract Emails", + "permlevel": 0 + }, + { + "description": "Email Id where a job applicant will email e.g. \"jobs@example.com\"", + "fieldname": "email_id", + "fieldtype": "Data", + "label": "Email Id", + "permlevel": 0 + }, + { + "description": "POP3 server e.g. (pop.gmail.com)", + "fieldname": "host", + "fieldtype": "Data", + "label": "Host", + "permlevel": 0 + }, + { + "fieldname": "use_ssl", + "fieldtype": "Check", + "label": "Use SSL", + "permlevel": 0 + }, + { + "fieldname": "username", + "fieldtype": "Data", + "label": "Username", + "permlevel": 0 + }, + { + "fieldname": "password", + "fieldtype": "Password", + "label": "Password", + "permlevel": 0 + } + ], + "icon": "icon-cog", + "idx": 1, + "issingle": 1, + "modified": "2013-12-20 19:23:16.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Jobs Email Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "System Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py index 4d2d1ea7fa6..94874f22331 100644 --- a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py +++ b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py @@ -8,13 +8,13 @@ import frappe from frappe import _ from frappe.utils import cint -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class JobsEmailSettings(Document): def validate(self): - if cint(self.doc.extract_emails) and not (self.doc.email_id and self.doc.host and \ - self.doc.username and self.doc.password): + if cint(self.extract_emails) and not (self.email_id and self.host and \ + self.username and self.password): frappe.msgprint(_("""Host, Email and Password required if emails are to be pulled"""), raise_exception=True) \ No newline at end of file diff --git a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.txt b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.txt deleted file mode 100644 index 24a424054cb..00000000000 --- a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.txt +++ /dev/null @@ -1,92 +0,0 @@ -[ - { - "creation": "2013-01-15 16:50:01", - "docstatus": 0, - "modified": "2013-12-20 19:23:16", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Email settings for jobs email id \"jobs@example.com\"", - "doctype": "DocType", - "icon": "icon-cog", - "issingle": 1, - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Jobs Email Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Jobs Email Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "role": "System Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Jobs Email Settings" - }, - { - "description": "Settings to extract Job Applicants from a mailbox e.g. \"jobs@example.com\"", - "doctype": "DocField", - "fieldname": "pop3_mail_settings", - "fieldtype": "Section Break", - "label": "POP3 Mail Settings" - }, - { - "description": "Check to activate", - "doctype": "DocField", - "fieldname": "extract_emails", - "fieldtype": "Check", - "label": "Extract Emails" - }, - { - "description": "Email Id where a job applicant will email e.g. \"jobs@example.com\"", - "doctype": "DocField", - "fieldname": "email_id", - "fieldtype": "Data", - "label": "Email Id" - }, - { - "description": "POP3 server e.g. (pop.gmail.com)", - "doctype": "DocField", - "fieldname": "host", - "fieldtype": "Data", - "label": "Host" - }, - { - "doctype": "DocField", - "fieldname": "use_ssl", - "fieldtype": "Check", - "label": "Use SSL" - }, - { - "doctype": "DocField", - "fieldname": "username", - "fieldtype": "Data", - "label": "Username" - }, - { - "doctype": "DocField", - "fieldname": "password", - "fieldtype": "Password", - "label": "Password" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/naming_series/naming_series.js b/erpnext/setup/doctype/naming_series/naming_series.js index 4f6a4c92c04..b9b94ca8234 100644 --- a/erpnext/setup/doctype/naming_series/naming_series.js +++ b/erpnext/setup/doctype/naming_series/naming_series.js @@ -29,7 +29,7 @@ cur_frm.cscript.select_doc_for_series = function(doc, cdt, cdn) { } if(doc.select_doc_for_series) - return $c_obj(make_doclist(doc.doctype, doc.name),'get_options','',callback); + return $c_obj(doc,'get_options','',callback); } cur_frm.cscript.update = function() { diff --git a/erpnext/setup/doctype/naming_series/naming_series.json b/erpnext/setup/doctype/naming_series/naming_series.json new file mode 100644 index 00000000000..95faa487450 --- /dev/null +++ b/erpnext/setup/doctype/naming_series/naming_series.json @@ -0,0 +1,98 @@ +{ + "creation": "2013-01-25 11:35:08.000000", + "description": "Set prefix for numbering series on your transactions", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Set prefix for numbering series on your transactions", + "fieldname": "setup_series", + "fieldtype": "Section Break", + "label": "Setup Series", + "permlevel": 0 + }, + { + "fieldname": "select_doc_for_series", + "fieldtype": "Select", + "label": "Select Transaction", + "permlevel": 0 + }, + { + "fieldname": "help_html", + "fieldtype": "HTML", + "label": "Help HTML", + "options": "
\nEdit list of Series in the box below. Rules:\n\nExamples:
\nINV-
\nINV-10-
\nINVK-
\nINV-.####
\n
", + "permlevel": 0 + }, + { + "fieldname": "set_options", + "fieldtype": "Text", + "label": "Series List for this Transaction", + "permlevel": 0 + }, + { + "description": "Check this if you want to force the user to select a series before saving. There will be no default if you check this.", + "fieldname": "user_must_always_select", + "fieldtype": "Check", + "label": "User must always select", + "permlevel": 0 + }, + { + "fieldname": "update", + "fieldtype": "Button", + "label": "Update", + "permlevel": 0 + }, + { + "description": "Change the starting / current sequence number of an existing series.", + "fieldname": "update_series", + "fieldtype": "Section Break", + "label": "Update Series", + "permlevel": 0 + }, + { + "fieldname": "prefix", + "fieldtype": "Select", + "label": "Prefix", + "permlevel": 0 + }, + { + "description": "This is the number of the last created transaction with this prefix", + "fieldname": "current_value", + "fieldtype": "Int", + "label": "Current Value", + "permlevel": 0 + }, + { + "fieldname": "update_series_start", + "fieldtype": "Button", + "label": "Update Series Number", + "options": "update_series_start", + "permlevel": 0 + } + ], + "hide_heading": 0, + "hide_toolbar": 1, + "icon": "icon-sort-by-order", + "idx": 1, + "issingle": 1, + "modified": "2013-12-20 19:23:21.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Naming Series", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "System Manager", + "submit": 0, + "write": 1 + } + ], + "read_only": 1 +} \ No newline at end of file diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py index 5b0c9e25e66..e93af3c387e 100644 --- a/erpnext/setup/doctype/naming_series/naming_series.py +++ b/erpnext/setup/doctype/naming_series/naming_series.py @@ -6,11 +6,10 @@ import frappe from frappe.utils import cstr from frappe import msgprint, throw, _ -import frappe.model.doctype -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class NamingSeries(Document): def get_transactions(self, arg=None): return { @@ -31,10 +30,10 @@ class DocType: def update_series(self, arg=None): """update series list""" self.check_duplicate() - series_list = self.doc.set_options.split("\n") + series_list = self.set_options.split("\n") # set in doctype - self.set_series_for(self.doc.select_doc_for_series, series_list) + self.set_series_for(self.select_doc_for_series, series_list) # create series map(self.insert_series, [d.split('.')[0] for d in series_list]) @@ -49,35 +48,36 @@ class DocType: # validate names for i in options: self.validate_series_name(i) - if self.doc.user_must_always_select: + if self.user_must_always_select: options = [''] + options default = '' else: default = options[0] # update in property setter - from frappe.model.doc import Document prop_dict = {'options': "\n".join(options), 'default': default} for prop in prop_dict: ps_exists = frappe.db.sql("""SELECT name FROM `tabProperty Setter` WHERE doc_type = %s AND field_name = 'naming_series' AND property = %s""", (doctype, prop)) if ps_exists: - ps = Document('Property Setter', ps_exists[0][0]) + ps = frappe.get_doc('Property Setter', ps_exists[0][0]) ps.value = prop_dict[prop] ps.save() else: - ps = Document('Property Setter', fielddata = { + ps = frappe.get_doc({ + 'doctype': 'Property Setter', 'doctype_or_field': 'DocField', 'doc_type': doctype, 'field_name': 'naming_series', 'property': prop, 'value': prop_dict[prop], 'property_type': 'Select', + '__islocal': 1 }) - ps.save(1) + ps.save() - self.doc.set_options = "\n".join(options) + self.set_options = "\n".join(options) frappe.clear_cache(doctype=doctype) @@ -89,17 +89,17 @@ class DocType: frappe.db.sql_list("""select dt.name from `tabDocField` df, `tabDocType` dt where dt.name = df.parent and df.fieldname='naming_series' and dt.name != %s""", - self.doc.select_doc_for_series) + self.select_doc_for_series) + frappe.db.sql_list("""select dt.name from `tabCustom Field` df, `tabDocType` dt where dt.name = df.dt and df.fieldname='naming_series' and dt.name != %s""", - self.doc.select_doc_for_series) + self.select_doc_for_series) )) - sr = [[frappe.model.doctype.get_property(p, 'options', 'naming_series'), p] + sr = [[frappe.get_meta(p).get_field("naming_series").options, p] for p in parent] - options = self.scrub_options_list(self.doc.set_options.split("\n")) + options = self.scrub_options_list(self.set_options.split("\n")) for series in options: - dt.validate_series(series, self.doc.select_doc_for_series) + dt.validate_series(series, self.select_doc_for_series) for i in sr: if i[0]: existing_series = [d.split('.')[0] for d in i[0].split("\n")] @@ -119,15 +119,13 @@ class DocType: throw('Special Characters except "-" and "/" not allowed in naming series') def get_options(self, arg=''): - sr = frappe.model.doctype.get_property(self.doc.select_doc_for_series, - 'options', 'naming_series') - return sr + return frappe.get_meta(self.select_doc_for_series).get_field("naming_series").options def get_current(self, arg=None): """get series current""" - if self.doc.prefix: - self.doc.current_value = frappe.db.get_value("Series", - self.doc.prefix.split('.')[0], "current") + if self.prefix: + self.current_value = frappe.db.get_value("Series", + self.prefix.split('.')[0], "current") def insert_series(self, series): """insert series if missing""" @@ -135,11 +133,11 @@ class DocType: frappe.db.sql("insert into tabSeries (name, current) values (%s, 0)", (series)) def update_series_start(self): - if self.doc.prefix: - prefix = self.doc.prefix.split('.')[0] + if self.prefix: + prefix = self.prefix.split('.')[0] self.insert_series(prefix) frappe.db.sql("update `tabSeries` set current = %s where name = %s", - (self.doc.current_value, prefix)) + (self.current_value, prefix)) msgprint(_("Series Updated Successfully")) else: msgprint(_("Please select prefix first")) @@ -171,7 +169,6 @@ def set_by_naming_series(doctype, fieldname, naming_series, hide_name_field=True ifnull({fieldname}, '')=''""".format(doctype=doctype, fieldname=fieldname)) def get_default_naming_series(doctype): - from frappe.model.doctype import get_property - naming_series = get_property(doctype, "options", "naming_series") + naming_series = frappe.get_meta(doctype).get_field("naming_series").options or "" naming_series = naming_series.split("\n") return naming_series[0] or naming_series[1] \ No newline at end of file diff --git a/erpnext/setup/doctype/naming_series/naming_series.txt b/erpnext/setup/doctype/naming_series/naming_series.txt deleted file mode 100644 index dd28eac340d..00000000000 --- a/erpnext/setup/doctype/naming_series/naming_series.txt +++ /dev/null @@ -1,117 +0,0 @@ -[ - { - "creation": "2013-01-25 11:35:08", - "docstatus": 0, - "modified": "2013-12-20 19:23:21", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Set prefix for numbering series on your transactions", - "doctype": "DocType", - "hide_heading": 0, - "hide_toolbar": 1, - "icon": "icon-sort-by-order", - "issingle": 1, - "module": "Setup", - "name": "__common__", - "read_only": 1 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Naming Series", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Naming Series", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "role": "System Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Naming Series" - }, - { - "description": "Set prefix for numbering series on your transactions", - "doctype": "DocField", - "fieldname": "setup_series", - "fieldtype": "Section Break", - "label": "Setup Series" - }, - { - "doctype": "DocField", - "fieldname": "select_doc_for_series", - "fieldtype": "Select", - "label": "Select Transaction" - }, - { - "doctype": "DocField", - "fieldname": "help_html", - "fieldtype": "HTML", - "label": "Help HTML", - "options": "
\nEdit list of Series in the box below. Rules:\n\nExamples:
\nINV-
\nINV-10-
\nINVK-
\nINV-.####
\n
" - }, - { - "doctype": "DocField", - "fieldname": "set_options", - "fieldtype": "Text", - "label": "Series List for this Transaction" - }, - { - "description": "Check this if you want to force the user to select a series before saving. There will be no default if you check this.", - "doctype": "DocField", - "fieldname": "user_must_always_select", - "fieldtype": "Check", - "label": "User must always select" - }, - { - "doctype": "DocField", - "fieldname": "update", - "fieldtype": "Button", - "label": "Update" - }, - { - "description": "Change the starting / current sequence number of an existing series.", - "doctype": "DocField", - "fieldname": "update_series", - "fieldtype": "Section Break", - "label": "Update Series" - }, - { - "doctype": "DocField", - "fieldname": "prefix", - "fieldtype": "Select", - "label": "Prefix" - }, - { - "description": "This is the number of the last created transaction with this prefix", - "doctype": "DocField", - "fieldname": "current_value", - "fieldtype": "Int", - "label": "Current Value" - }, - { - "doctype": "DocField", - "fieldname": "update_series_start", - "fieldtype": "Button", - "label": "Update Series Number", - "options": "update_series_start" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/notification_control/notification_control.js b/erpnext/setup/doctype/notification_control/notification_control.js index 9d26496d87e..19660b8f7fc 100644 --- a/erpnext/setup/doctype/notification_control/notification_control.js +++ b/erpnext/setup/doctype/notification_control/notification_control.js @@ -8,6 +8,6 @@ cur_frm.cscript.select_transaction = function(doc, cdt, cdn) { doc.custom_message = r.message; refresh_field('custom_message'); } - return $c_obj(make_doclist(cdt, cdn),'get_message',doc.select_transaction, callback) + return $c_obj(doc,'get_message',doc.select_transaction, callback) } } diff --git a/erpnext/setup/doctype/notification_control/notification_control.json b/erpnext/setup/doctype/notification_control/notification_control.json new file mode 100644 index 00000000000..e6a6a7f36ed --- /dev/null +++ b/erpnext/setup/doctype/notification_control/notification_control.json @@ -0,0 +1,200 @@ +{ + "allow_copy": 1, + "allow_email": 1, + "allow_print": 1, + "creation": "2012-07-12 23:29:45.000000", + "description": "Send automatic emails to Contacts on Submitting transactions.", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "When any of the checked transactions are \"Submitted\", an email pop-up automatically opened to send an email to the associated \"Contact\" in that transaction, with the transaction as an attachment. The user may or may not send the email.", + "fieldname": "send_autonotification_for", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Prompt for Email on Submission of", + "permlevel": 0 + }, + { + "fieldname": "sales", + "fieldtype": "Column Break", + "in_list_view": 0, + "label": "Sales", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "quotation", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Quotation", + "permlevel": 0 + }, + { + "fieldname": "sales_order", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Sales Order", + "permlevel": 0 + }, + { + "fieldname": "delivery_note", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Delivery Note", + "permlevel": 0 + }, + { + "fieldname": "sales_invoice", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Sales Invoice", + "permlevel": 0 + }, + { + "fieldname": "purchase", + "fieldtype": "Column Break", + "in_list_view": 0, + "label": "Purchase", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "purchase_order", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Purchase Order", + "permlevel": 0 + }, + { + "fieldname": "purchase_receipt", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Purchase Receipt", + "permlevel": 0 + }, + { + "fieldname": "expense_claim", + "fieldtype": "Check", + "label": "Expense Claim", + "permlevel": 0 + }, + { + "description": "Customize the introductory text that goes as a part of that email. Each transaction has a separate introductory text.", + "fieldname": "customize_the_notification", + "fieldtype": "Section Break", + "label": "Customize the Notification", + "permlevel": 0 + }, + { + "fieldname": "select_transaction", + "fieldtype": "Select", + "label": "Select Transaction", + "options": "\nQuotation\nSales Order\nDelivery Note\nSales Invoice\nPurchase Order\nPurchase Receipt\nExpense Claim\nExpense Claim Approved\nExpense Claim Rejected", + "permlevel": 0 + }, + { + "fieldname": "custom_message", + "fieldtype": "Text Editor", + "label": "Custom Message", + "permlevel": 0 + }, + { + "fieldname": "update", + "fieldtype": "Button", + "label": "Update", + "options": "set_message", + "permlevel": 0 + }, + { + "fieldname": "quotation_message", + "fieldtype": "Text", + "hidden": 1, + "label": "Quotation Message", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "sales_order_message", + "fieldtype": "Text", + "hidden": 1, + "label": "Sales Order Message", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "delivery_note_message", + "fieldtype": "Text", + "hidden": 1, + "label": "Delivery Note Message", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "sales_invoice_message", + "fieldtype": "Text", + "hidden": 1, + "label": "Sales Invoice Message", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "purchase_order_message", + "fieldtype": "Text", + "hidden": 1, + "label": "Purchase Order Message", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "purchase_receipt_message", + "fieldtype": "Text", + "hidden": 1, + "label": "Purchase Receipt Message", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "expense_claim_approved_message", + "fieldtype": "Text", + "hidden": 1, + "label": "Expense Claim Approved Message", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "expense_claim_rejected_message", + "fieldtype": "Text", + "hidden": 1, + "label": "Expense Claim Rejected Message", + "permlevel": 0, + "print_hide": 1 + } + ], + "icon": "icon-envelope", + "idx": 1, + "issingle": 1, + "modified": "2013-07-10 19:24:07.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Notification Control", + "owner": "Administrator", + "permissions": [ + { + "create": 0, + "permlevel": 0, + "read": 1, + "role": "Guest", + "write": 0 + }, + { + "create": 1, + "permlevel": 0, + "read": 1, + "role": "System Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/notification_control/notification_control.py b/erpnext/setup/doctype/notification_control/notification_control.py index c5137461c60..87674ecd119 100644 --- a/erpnext/setup/doctype/notification_control/notification_control.py +++ b/erpnext/setup/doctype/notification_control/notification_control.py @@ -7,17 +7,16 @@ import frappe from frappe import msgprint -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl +from frappe.model.document import Document +class NotificationControl(Document): def get_message(self, arg): fn = arg.lower().replace(' ', '_') + '_message' v = frappe.db.sql("select value from tabSingles where field=%s and doctype=%s", (fn, 'Notification Control')) return v and v[0][0] or '' def set_message(self, arg = ''): - fn = self.doc.select_transaction.lower().replace(' ', '_') + '_message' - frappe.db.set(self.doc, fn, self.doc.custom_message) - msgprint("Custom Message for %s updated!" % self.doc.select_transaction) + fn = self.select_transaction.lower().replace(' ', '_') + '_message' + frappe.db.set(self, fn, self.custom_message) + msgprint("Custom Message for %s updated!" % self.select_transaction) diff --git a/erpnext/setup/doctype/notification_control/notification_control.txt b/erpnext/setup/doctype/notification_control/notification_control.txt deleted file mode 100644 index 81e08a552e7..00000000000 --- a/erpnext/setup/doctype/notification_control/notification_control.txt +++ /dev/null @@ -1,218 +0,0 @@ -[ - { - "creation": "2012-07-12 23:29:45", - "docstatus": 0, - "modified": "2013-07-10 19:24:07", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_copy": 1, - "allow_email": 1, - "allow_print": 1, - "description": "Send automatic emails to Contacts on Submitting transactions.", - "doctype": "DocType", - "icon": "icon-envelope", - "issingle": 1, - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Notification Control", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "Notification Control", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1 - }, - { - "doctype": "DocType", - "name": "Notification Control" - }, - { - "description": "When any of the checked transactions are \"Submitted\", an email pop-up automatically opened to send an email to the associated \"Contact\" in that transaction, with the transaction as an attachment. The user may or may not send the email.", - "doctype": "DocField", - "fieldname": "send_autonotification_for", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Prompt for Email on Submission of" - }, - { - "doctype": "DocField", - "fieldname": "sales", - "fieldtype": "Column Break", - "in_list_view": 0, - "label": "Sales", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "quotation", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Quotation" - }, - { - "doctype": "DocField", - "fieldname": "sales_order", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Sales Order" - }, - { - "doctype": "DocField", - "fieldname": "delivery_note", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Delivery Note" - }, - { - "doctype": "DocField", - "fieldname": "sales_invoice", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Sales Invoice" - }, - { - "doctype": "DocField", - "fieldname": "purchase", - "fieldtype": "Column Break", - "in_list_view": 0, - "label": "Purchase", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "purchase_order", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Purchase Order" - }, - { - "doctype": "DocField", - "fieldname": "purchase_receipt", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Purchase Receipt" - }, - { - "doctype": "DocField", - "fieldname": "expense_claim", - "fieldtype": "Check", - "label": "Expense Claim" - }, - { - "description": "Customize the introductory text that goes as a part of that email. Each transaction has a separate introductory text.", - "doctype": "DocField", - "fieldname": "customize_the_notification", - "fieldtype": "Section Break", - "label": "Customize the Notification" - }, - { - "doctype": "DocField", - "fieldname": "select_transaction", - "fieldtype": "Select", - "label": "Select Transaction", - "options": "\nQuotation\nSales Order\nDelivery Note\nSales Invoice\nPurchase Order\nPurchase Receipt\nExpense Claim\nExpense Claim Approved\nExpense Claim Rejected" - }, - { - "doctype": "DocField", - "fieldname": "custom_message", - "fieldtype": "Text Editor", - "label": "Custom Message" - }, - { - "doctype": "DocField", - "fieldname": "update", - "fieldtype": "Button", - "label": "Update", - "options": "set_message" - }, - { - "doctype": "DocField", - "fieldname": "quotation_message", - "fieldtype": "Text", - "hidden": 1, - "label": "Quotation Message", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "sales_order_message", - "fieldtype": "Text", - "hidden": 1, - "label": "Sales Order Message", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "delivery_note_message", - "fieldtype": "Text", - "hidden": 1, - "label": "Delivery Note Message", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "sales_invoice_message", - "fieldtype": "Text", - "hidden": 1, - "label": "Sales Invoice Message", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "purchase_order_message", - "fieldtype": "Text", - "hidden": 1, - "label": "Purchase Order Message", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "purchase_receipt_message", - "fieldtype": "Text", - "hidden": 1, - "label": "Purchase Receipt Message", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "expense_claim_approved_message", - "fieldtype": "Text", - "hidden": 1, - "label": "Expense Claim Approved Message", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "expense_claim_rejected_message", - "fieldtype": "Text", - "hidden": 1, - "label": "Expense Claim Rejected Message", - "print_hide": 1 - }, - { - "create": 0, - "doctype": "DocPerm", - "role": "Guest", - "write": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "System Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/print_heading/print_heading.json b/erpnext/setup/doctype/print_heading/print_heading.json new file mode 100644 index 00000000000..fc558f2b7d5 --- /dev/null +++ b/erpnext/setup/doctype/print_heading/print_heading.json @@ -0,0 +1,61 @@ +{ + "allow_import": 1, + "autoname": "field:print_heading", + "creation": "2013-01-10 16:34:24.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "print_heading", + "fieldtype": "Data", + "in_filter": 1, + "label": "Print Heading", + "oldfieldname": "print_heading", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "width": "300px" + } + ], + "icon": "icon-font", + "idx": 1, + "modified": "2014-01-20 17:49:01.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Print Heading", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "All", + "submit": 0, + "write": 1 + } + ], + "search_fields": "print_heading" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/print_heading/print_heading.py b/erpnext/setup/doctype/print_heading/print_heading.py index 263c31e327d..eb6d9780ff0 100644 --- a/erpnext/setup/doctype/print_heading/print_heading.py +++ b/erpnext/setup/doctype/print_heading/print_heading.py @@ -4,12 +4,7 @@ from __future__ import unicode_literals import frappe -from frappe.model import db_exists -from frappe.model.bean import copy_doclist +from frappe.model.document import Document - - - -class DocType: - def __init__(self,doc,doclist=[]): - self.doc, self.doclist = doc,doclist \ No newline at end of file +class PrintHeading(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/print_heading/print_heading.txt b/erpnext/setup/doctype/print_heading/print_heading.txt deleted file mode 100644 index d566f8dee28..00000000000 --- a/erpnext/setup/doctype/print_heading/print_heading.txt +++ /dev/null @@ -1,80 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:24", - "docstatus": 0, - "modified": "2014-01-20 17:49:01", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:print_heading", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-font", - "module": "Setup", - "name": "__common__", - "search_fields": "print_heading" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Print Heading", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Print Heading", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "All", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Print Heading" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "print_heading", - "fieldtype": "Data", - "in_filter": 1, - "label": "Print Heading", - "oldfieldname": "print_heading", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "width": "300px" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/print_heading/test_print_heading.py b/erpnext/setup/doctype/print_heading/test_print_heading.py index e9f61c4b485..6ccb4d677ad 100644 --- a/erpnext/setup/doctype/print_heading/test_print_heading.py +++ b/erpnext/setup/doctype/print_heading/test_print_heading.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{"print_heading": "_Test Print Heading"}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Print Heading') \ No newline at end of file diff --git a/erpnext/setup/doctype/print_heading/test_records.json b/erpnext/setup/doctype/print_heading/test_records.json new file mode 100644 index 00000000000..479c38ad984 --- /dev/null +++ b/erpnext/setup/doctype/print_heading/test_records.json @@ -0,0 +1,5 @@ +[ + { + "print_heading": "_Test Print Heading" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.json b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.json new file mode 100644 index 00000000000..0d58279f12f --- /dev/null +++ b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.json @@ -0,0 +1,51 @@ +{ + "allow_import": 1, + "autoname": "field:order_lost_reason", + "creation": "2013-01-10 16:34:24.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "order_lost_reason", + "fieldtype": "Data", + "label": "Quotation Lost Reason", + "oldfieldname": "order_lost_reason", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-flag", + "idx": 1, + "modified": "2014-01-20 17:49:17.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Quotation Lost Reason", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py index d30eab6e92b..ea9f927856d 100644 --- a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py +++ b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class QuotationLostReason(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.txt b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.txt deleted file mode 100644 index 00e9c6ea4e8..00000000000 --- a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.txt +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:24", - "docstatus": 0, - "modified": "2014-01-20 17:49:17", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:order_lost_reason", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-flag", - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Quotation Lost Reason", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Quotation Lost Reason", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Sales Master Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Quotation Lost Reason" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "order_lost_reason", - "fieldtype": "Data", - "label": "Quotation Lost Reason", - "oldfieldname": "order_lost_reason", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/quotation_lost_reason/test_quotation_lost_reason.py b/erpnext/setup/doctype/quotation_lost_reason/test_quotation_lost_reason.py index 486dd86e366..0c96d451426 100644 --- a/erpnext/setup/doctype/quotation_lost_reason/test_quotation_lost_reason.py +++ b/erpnext/setup/doctype/quotation_lost_reason/test_quotation_lost_reason.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{"doctype":"Quotation Lost Reason", "order_lost_reason": "_Test Quotation Lost Reason"}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Quotation Lost Reason') \ No newline at end of file diff --git a/erpnext/setup/doctype/quotation_lost_reason/test_records.json b/erpnext/setup/doctype/quotation_lost_reason/test_records.json new file mode 100644 index 00000000000..29f04de0081 --- /dev/null +++ b/erpnext/setup/doctype/quotation_lost_reason/test_records.json @@ -0,0 +1,6 @@ +[ + { + "doctype": "Quotation Lost Reason", + "order_lost_reason": "_Test Quotation Lost Reason" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.json b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.json new file mode 100644 index 00000000000..c19f2e2e228 --- /dev/null +++ b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.json @@ -0,0 +1,73 @@ +{ + "creation": "2013-01-16 10:25:26.000000", + "description": "Email settings to extract Leads from sales email id e.g. \"sales@example.com\"", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Email settings to extract Leads from sales email id e.g. \"sales@example.com\"", + "fieldname": "pop3_mail_settings", + "fieldtype": "Section Break", + "label": "POP3 Mail Settings", + "permlevel": 0 + }, + { + "description": "Check to activate", + "fieldname": "extract_emails", + "fieldtype": "Check", + "label": "Extract Emails", + "permlevel": 0 + }, + { + "description": "Email Id where a job applicant will email e.g. \"jobs@example.com\"", + "fieldname": "email_id", + "fieldtype": "Data", + "label": "Email Id", + "permlevel": 0 + }, + { + "description": "POP3 server e.g. (pop.gmail.com)", + "fieldname": "host", + "fieldtype": "Data", + "label": "Host", + "permlevel": 0 + }, + { + "fieldname": "use_ssl", + "fieldtype": "Check", + "label": "Use SSL", + "permlevel": 0 + }, + { + "fieldname": "username", + "fieldtype": "Data", + "label": "Username", + "permlevel": 0 + }, + { + "fieldname": "password", + "fieldtype": "Password", + "label": "Password", + "permlevel": 0 + } + ], + "icon": "icon-cog", + "idx": 1, + "issingle": 1, + "modified": "2013-12-20 19:21:38.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Sales Email Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "System Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py index 4d2d1ea7fa6..88dc411a7ca 100644 --- a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py +++ b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py @@ -8,13 +8,13 @@ import frappe from frappe import _ from frappe.utils import cint -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class SalesEmailSettings(Document): def validate(self): - if cint(self.doc.extract_emails) and not (self.doc.email_id and self.doc.host and \ - self.doc.username and self.doc.password): + if cint(self.extract_emails) and not (self.email_id and self.host and \ + self.username and self.password): frappe.msgprint(_("""Host, Email and Password required if emails are to be pulled"""), raise_exception=True) \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.txt b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.txt deleted file mode 100644 index f5f8a97fa13..00000000000 --- a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.txt +++ /dev/null @@ -1,92 +0,0 @@ -[ - { - "creation": "2013-01-16 10:25:26", - "docstatus": 0, - "modified": "2013-12-20 19:21:38", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Email settings to extract Leads from sales email id e.g. \"sales@example.com\"", - "doctype": "DocType", - "icon": "icon-cog", - "issingle": 1, - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales Email Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Sales Email Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "role": "System Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Sales Email Settings" - }, - { - "description": "Email settings to extract Leads from sales email id e.g. \"sales@example.com\"", - "doctype": "DocField", - "fieldname": "pop3_mail_settings", - "fieldtype": "Section Break", - "label": "POP3 Mail Settings" - }, - { - "description": "Check to activate", - "doctype": "DocField", - "fieldname": "extract_emails", - "fieldtype": "Check", - "label": "Extract Emails" - }, - { - "description": "Email Id where a job applicant will email e.g. \"jobs@example.com\"", - "doctype": "DocField", - "fieldname": "email_id", - "fieldtype": "Data", - "label": "Email Id" - }, - { - "description": "POP3 server e.g. (pop.gmail.com)", - "doctype": "DocField", - "fieldname": "host", - "fieldtype": "Data", - "label": "Host" - }, - { - "doctype": "DocField", - "fieldname": "use_ssl", - "fieldtype": "Check", - "label": "Use SSL" - }, - { - "doctype": "DocField", - "fieldname": "username", - "fieldtype": "Data", - "label": "Username" - }, - { - "doctype": "DocField", - "fieldname": "password", - "fieldtype": "Password", - "label": "Password" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.json b/erpnext/setup/doctype/sales_partner/sales_partner.json new file mode 100644 index 00000000000..7bc0edd6794 --- /dev/null +++ b/erpnext/setup/doctype/sales_partner/sales_partner.json @@ -0,0 +1,247 @@ +{ + "allow_import": 1, + "autoname": "field:partner_name", + "creation": "2013-04-12 15:34:06.000000", + "description": "A third party distributor / dealer / commission agent / affiliate / reseller who sells the companies products for a commission.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "partner_name", + "fieldtype": "Data", + "in_filter": 1, + "label": "Sales Partner Name", + "oldfieldname": "partner_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "partner_type", + "fieldtype": "Select", + "in_filter": 1, + "label": "Partner Type", + "oldfieldname": "partner_type", + "oldfieldtype": "Select", + "options": "\nChannel Partner\nDistributor\nDealer\nAgent\nRetailer\nImplementation Partner\nReseller", + "permlevel": 0, + "search_index": 0 + }, + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "label": "Territory", + "options": "Territory", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "commission_rate", + "fieldtype": "Float", + "label": "Commission Rate", + "oldfieldname": "commission_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "address_contacts", + "fieldtype": "Section Break", + "label": "Address & Contacts", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.__islocal", + "fieldname": "address_desc", + "fieldtype": "HTML", + "label": "Address Desc", + "options": "Addresses will appear only when you save the customer", + "permlevel": 0 + }, + { + "fieldname": "address_html", + "fieldtype": "HTML", + "label": "Address HTML", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.__islocal", + "fieldname": "contact_desc", + "fieldtype": "HTML", + "label": "Contact Desc", + "options": "Contact Details will appear only when you save the customer", + "permlevel": 0 + }, + { + "fieldname": "contact_html", + "fieldtype": "HTML", + "label": "Contact HTML", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "partner_target_details_section_break", + "fieldtype": "Section Break", + "label": "Sales Partner Target", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "partner_target_details", + "fieldtype": "Table", + "label": "Partner Target Detail", + "oldfieldname": "partner_target_details", + "oldfieldtype": "Table", + "options": "Target Detail", + "permlevel": 0, + "reqd": 0 + }, + { + "description": "Select Budget Distribution to unevenly distribute targets across months.", + "fieldname": "distribution_id", + "fieldtype": "Link", + "label": "Target Distribution", + "oldfieldname": "distribution_id", + "oldfieldtype": "Link", + "options": "Budget Distribution", + "permlevel": 0 + }, + { + "fieldname": "website", + "fieldtype": "Section Break", + "label": "Website", + "permlevel": 0 + }, + { + "fieldname": "show_in_website", + "fieldtype": "Check", + "label": "Show In Website", + "permlevel": 0 + }, + { + "depends_on": "eval:cint(doc.show_in_website)", + "fieldname": "section_break_17", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "logo", + "fieldtype": "Select", + "label": "Logo", + "options": "attach_files:", + "permlevel": 0 + }, + { + "fieldname": "partner_website", + "fieldtype": "Data", + "label": "Partner's Website", + "permlevel": 0 + }, + { + "fieldname": "column_break_20", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "page_name", + "fieldtype": "Data", + "label": "Page Name", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "eval:cint(doc.show_in_website)", + "fieldname": "section_break_22", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "introduction", + "fieldtype": "Text", + "label": "Introduction", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Text Editor", + "label": "Description", + "permlevel": 0 + }, + { + "fieldname": "parent_website_route", + "fieldtype": "Link", + "label": "Parent Website Route", + "options": "Website Route", + "permlevel": 0 + } + ], + "icon": "icon-user", + "idx": 1, + "in_create": 0, + "modified": "2014-02-20 18:30:32.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Sales Partner", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + } + ], + "read_only": 0 +} \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.py b/erpnext/setup/doctype/sales_partner/sales_partner.py index eefabf6784b..b90b65e8683 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.py +++ b/erpnext/setup/doctype/sales_partner/sales_partner.py @@ -4,24 +4,24 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, cstr, filter_strip_join +from frappe.website.website_generator import WebsiteGenerator -class DocType(): - def __init__(self, doc, doclist=None): - self.doc = doc - self.doclist = doclist +class SalesPartner(WebsiteGenerator): + def autoname(self): + self.name = self.partner_name def validate(self): - if self.doc.partner_website and not self.doc.partner_website.startswith("http"): - self.doc.partner_website = "http://" + self.doc.partner_website + if self.partner_website and not self.partner_website.startswith("http"): + self.partner_website = "http://" + self.partner_website def get_contacts(self, nm): if nm: return frappe.db.convert_to_lists(frappe.db.sql(""" - select name, CONCAT(IFNULL(first_name,''), - ' ',IFNULL(last_name,'')),contact_no,email_id + select name, CONCAT(IFNULL(first_name,''), + ' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where sales_partner = %s""", nm)) else: return '' def get_page_title(self): - return self.doc.partner_name + return self.partner_name diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.txt b/erpnext/setup/doctype/sales_partner/sales_partner.txt deleted file mode 100644 index 25ae9a06713..00000000000 --- a/erpnext/setup/doctype/sales_partner/sales_partner.txt +++ /dev/null @@ -1,250 +0,0 @@ -[ - { - "creation": "2013-04-12 15:34:06", - "docstatus": 0, - "modified": "2014-02-20 18:30:32", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:partner_name", - "description": "A third party distributor / dealer / commission agent / affiliate / reseller who sells the companies products for a commission.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-user", - "in_create": 0, - "module": "Setup", - "name": "__common__", - "read_only": 0 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales Partner", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "delete": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Sales Partner", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Sales Partner" - }, - { - "doctype": "DocField", - "fieldname": "partner_name", - "fieldtype": "Data", - "in_filter": 1, - "label": "Sales Partner Name", - "oldfieldname": "partner_name", - "oldfieldtype": "Data", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "partner_type", - "fieldtype": "Select", - "in_filter": 1, - "label": "Partner Type", - "oldfieldname": "partner_type", - "oldfieldtype": "Select", - "options": "\nChannel Partner\nDistributor\nDealer\nAgent\nRetailer\nImplementation Partner\nReseller", - "search_index": 0 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "label": "Territory", - "options": "Territory", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "commission_rate", - "fieldtype": "Float", - "label": "Commission Rate", - "oldfieldname": "commission_rate", - "oldfieldtype": "Currency", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_contacts", - "fieldtype": "Section Break", - "label": "Address & Contacts" - }, - { - "depends_on": "eval:doc.__islocal", - "doctype": "DocField", - "fieldname": "address_desc", - "fieldtype": "HTML", - "label": "Address Desc", - "options": "Addresses will appear only when you save the customer" - }, - { - "doctype": "DocField", - "fieldname": "address_html", - "fieldtype": "HTML", - "label": "Address HTML", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break" - }, - { - "depends_on": "eval:doc.__islocal", - "doctype": "DocField", - "fieldname": "contact_desc", - "fieldtype": "HTML", - "label": "Contact Desc", - "options": "Contact Details will appear only when you save the customer" - }, - { - "doctype": "DocField", - "fieldname": "contact_html", - "fieldtype": "HTML", - "label": "Contact HTML", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "partner_target_details_section_break", - "fieldtype": "Section Break", - "label": "Sales Partner Target", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "partner_target_details", - "fieldtype": "Table", - "label": "Partner Target Detail", - "oldfieldname": "partner_target_details", - "oldfieldtype": "Table", - "options": "Target Detail", - "reqd": 0 - }, - { - "description": "Select Budget Distribution to unevenly distribute targets across months.", - "doctype": "DocField", - "fieldname": "distribution_id", - "fieldtype": "Link", - "label": "Target Distribution", - "oldfieldname": "distribution_id", - "oldfieldtype": "Link", - "options": "Budget Distribution" - }, - { - "doctype": "DocField", - "fieldname": "website", - "fieldtype": "Section Break", - "label": "Website" - }, - { - "doctype": "DocField", - "fieldname": "show_in_website", - "fieldtype": "Check", - "label": "Show In Website" - }, - { - "depends_on": "eval:cint(doc.show_in_website)", - "doctype": "DocField", - "fieldname": "section_break_17", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "logo", - "fieldtype": "Select", - "label": "Logo", - "options": "attach_files:" - }, - { - "doctype": "DocField", - "fieldname": "partner_website", - "fieldtype": "Data", - "label": "Partner's Website" - }, - { - "doctype": "DocField", - "fieldname": "column_break_20", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "page_name", - "fieldtype": "Data", - "label": "Page Name", - "read_only": 1 - }, - { - "depends_on": "eval:cint(doc.show_in_website)", - "doctype": "DocField", - "fieldname": "section_break_22", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "introduction", - "fieldtype": "Text", - "label": "Introduction" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text Editor", - "label": "Description" - }, - { - "doctype": "DocField", - "fieldname": "parent_website_route", - "fieldtype": "Link", - "label": "Parent Website Route", - "options": "Website Route" - }, - { - "create": 0, - "doctype": "DocPerm", - "role": "Sales Manager", - "write": 0 - }, - { - "create": 0, - "doctype": "DocPerm", - "role": "Sales User", - "write": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_partner/test_records.json b/erpnext/setup/doctype/sales_partner/test_records.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/erpnext/setup/doctype/sales_partner/test_records.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_partner/test_sales_partner.py b/erpnext/setup/doctype/sales_partner/test_sales_partner.py index 2dc000680ae..e14f5ec6e7b 100644 --- a/erpnext/setup/doctype/sales_partner/test_sales_partner.py +++ b/erpnext/setup/doctype/sales_partner/test_sales_partner.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Sales Partner') \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_person/sales_person.json b/erpnext/setup/doctype/sales_person/sales_person.json new file mode 100644 index 00000000000..55b32a283bf --- /dev/null +++ b/erpnext/setup/doctype/sales_person/sales_person.json @@ -0,0 +1,193 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:sales_person_name", + "creation": "2013-01-10 16:34:24.000000", + "description": "All Sales Transactions can be tagged against multiple **Sales Persons** so that you can set and monitor targets.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "name_and_employee_id", + "fieldtype": "Section Break", + "label": "Name and Employee ID", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "sales_person_name", + "fieldtype": "Data", + "in_filter": 1, + "label": "Sales Person Name", + "oldfieldname": "sales_person_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "description": "Select company name first.", + "fieldname": "parent_sales_person", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Parent Sales Person", + "oldfieldname": "parent_sales_person", + "oldfieldtype": "Link", + "options": "Sales Person", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "is_group", + "fieldtype": "Select", + "label": "Has Child Node", + "oldfieldname": "is_group", + "oldfieldtype": "Select", + "options": "\nYes\nNo", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "cb0", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "employee", + "fieldtype": "Link", + "label": "Employee", + "options": "Employee", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "lft", + "fieldtype": "Int", + "hidden": 1, + "in_filter": 1, + "label": "lft", + "no_copy": 1, + "oldfieldname": "lft", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1, + "search_index": 1 + }, + { + "fieldname": "rgt", + "fieldtype": "Int", + "hidden": 1, + "in_filter": 1, + "label": "rgt", + "no_copy": 1, + "oldfieldname": "rgt", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1, + "search_index": 1 + }, + { + "fieldname": "old_parent", + "fieldtype": "Data", + "hidden": 1, + "label": "old_parent", + "no_copy": 1, + "oldfieldname": "old_parent", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1 + }, + { + "description": "Set targets Item Group-wise for this Sales Person.", + "fieldname": "target_details_section_break", + "fieldtype": "Section Break", + "label": "Sales Person Targets", + "oldfieldtype": "Section Break", + "options": "icon-bullseye", + "permlevel": 0 + }, + { + "fieldname": "target_details", + "fieldtype": "Table", + "label": "Target Details1", + "oldfieldname": "target_details", + "oldfieldtype": "Table", + "options": "Target Detail", + "permlevel": 0 + }, + { + "description": "Select Budget Distribution to unevenly distribute targets across months.", + "fieldname": "distribution_id", + "fieldtype": "Link", + "label": "Target Distribution", + "oldfieldname": "distribution_id", + "oldfieldtype": "Link", + "options": "Budget Distribution", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "communications", + "fieldtype": "Table", + "hidden": 1, + "label": "Communications", + "options": "Communication", + "permlevel": 0, + "print_hide": 1 + } + ], + "icon": "icon-user", + "idx": 1, + "in_create": 1, + "modified": "2014-01-20 17:49:25.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Sales Person", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + } + ], + "search_fields": "name,parent_sales_person" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_person/sales_person.py b/erpnext/setup/doctype/sales_person/sales_person.py index 58ddd13c6c9..63897223497 100644 --- a/erpnext/setup/doctype/sales_person/sales_person.py +++ b/erpnext/setup/doctype/sales_person/sales_person.py @@ -3,29 +3,26 @@ from __future__ import unicode_literals import frappe -from frappe.model.bean import getlist -from frappe.utils import flt -from frappe.utils.nestedset import DocTypeNestedSet -class DocType(DocTypeNestedSet): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.nsm_parent_field = 'parent_sales_person'; +from frappe.utils import flt +from frappe.utils.nestedset import NestedSet + +class SalesPerson(NestedSet): + nsm_parent_field = 'parent_sales_person'; def validate(self): - for d in getlist(self.doclist, 'target_details'): + for d in self.get('target_details'): if not flt(d.target_qty) and not flt(d.target_amount): frappe.throw(_("Either target qty or target amount is mandatory.")) def on_update(self): - super(DocType, self).on_update() + super(SalesPerson, self).on_update() self.validate_one_root() def get_email_id(self): - if self.doc.employee: - user = frappe.db.get_value("Employee", self.doc.employee, "user_id") + if self.employee: + user = frappe.db.get_value("Employee", self.employee, "user_id") if not user: - frappe.throw("User ID not set for Employee %s" % self.doc.employee) + frappe.throw("User ID not set for Employee %s" % self.employee) else: return frappe.db.get_value("User", user, "email") or user \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_person/sales_person.txt b/erpnext/setup/doctype/sales_person/sales_person.txt deleted file mode 100644 index 724dc4cd0eb..00000000000 --- a/erpnext/setup/doctype/sales_person/sales_person.txt +++ /dev/null @@ -1,198 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:24", - "docstatus": 0, - "modified": "2014-01-20 17:49:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:sales_person_name", - "description": "All Sales Transactions can be tagged against multiple **Sales Persons** so that you can set and monitor targets.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-user", - "in_create": 1, - "module": "Setup", - "name": "__common__", - "search_fields": "name,parent_sales_person" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Sales Person", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Sales Person", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Sales Person" - }, - { - "doctype": "DocField", - "fieldname": "name_and_employee_id", - "fieldtype": "Section Break", - "label": "Name and Employee ID", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "sales_person_name", - "fieldtype": "Data", - "in_filter": 1, - "label": "Sales Person Name", - "oldfieldname": "sales_person_name", - "oldfieldtype": "Data", - "reqd": 1, - "search_index": 0 - }, - { - "description": "Select company name first.", - "doctype": "DocField", - "fieldname": "parent_sales_person", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Parent Sales Person", - "oldfieldname": "parent_sales_person", - "oldfieldtype": "Link", - "options": "Sales Person", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "is_group", - "fieldtype": "Select", - "label": "Has Child Node", - "oldfieldname": "is_group", - "oldfieldtype": "Select", - "options": "\nYes\nNo", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb0", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "employee", - "fieldtype": "Link", - "label": "Employee", - "options": "Employee", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "lft", - "fieldtype": "Int", - "hidden": 1, - "in_filter": 1, - "label": "lft", - "no_copy": 1, - "oldfieldname": "lft", - "oldfieldtype": "Int", - "print_hide": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "rgt", - "fieldtype": "Int", - "hidden": 1, - "in_filter": 1, - "label": "rgt", - "no_copy": 1, - "oldfieldname": "rgt", - "oldfieldtype": "Int", - "print_hide": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "old_parent", - "fieldtype": "Data", - "hidden": 1, - "label": "old_parent", - "no_copy": 1, - "oldfieldname": "old_parent", - "oldfieldtype": "Data", - "print_hide": 1 - }, - { - "description": "Set targets Item Group-wise for this Sales Person.", - "doctype": "DocField", - "fieldname": "target_details_section_break", - "fieldtype": "Section Break", - "label": "Sales Person Targets", - "oldfieldtype": "Section Break", - "options": "icon-bullseye" - }, - { - "doctype": "DocField", - "fieldname": "target_details", - "fieldtype": "Table", - "label": "Target Details1", - "oldfieldname": "target_details", - "oldfieldtype": "Table", - "options": "Target Detail" - }, - { - "description": "Select Budget Distribution to unevenly distribute targets across months.", - "doctype": "DocField", - "fieldname": "distribution_id", - "fieldtype": "Link", - "label": "Target Distribution", - "oldfieldname": "distribution_id", - "oldfieldtype": "Link", - "options": "Budget Distribution", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "communications", - "fieldtype": "Table", - "hidden": 1, - "label": "Communications", - "options": "Communication", - "print_hide": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Sales Manager", - "write": 0 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_person/test_records.json b/erpnext/setup/doctype/sales_person/test_records.json new file mode 100644 index 00000000000..cd29d40b1ae --- /dev/null +++ b/erpnext/setup/doctype/sales_person/test_records.json @@ -0,0 +1,23 @@ +[ + { + "doctype": "Sales Person", + "employee": "_T-Employee-0001", + "is_group": "No", + "parent_sales_person": "Sales Team", + "sales_person_name": "_Test Sales Person" + }, + { + "doctype": "Sales Person", + "employee": "_T-Employee-0002", + "is_group": "No", + "parent_sales_person": "Sales Team", + "sales_person_name": "_Test Sales Person 1" + }, + { + "doctype": "Sales Person", + "employee": "_T-Employee-0003", + "is_group": "No", + "parent_sales_person": "Sales Team", + "sales_person_name": "_Test Sales Person 2" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_person/test_sales_person.py b/erpnext/setup/doctype/sales_person/test_sales_person.py index ebbc25ed9bb..8db97d387f9 100644 --- a/erpnext/setup/doctype/sales_person/test_sales_person.py +++ b/erpnext/setup/doctype/sales_person/test_sales_person.py @@ -2,28 +2,6 @@ # License: GNU General Public License v3. See license.txt test_dependencies = ["Employee"] -test_records = [ - [{ - "doctype": "Sales Person", - "sales_person_name": "_Test Sales Person", - "parent_sales_person": "Sales Team", - "is_group": "No", - "employee": "_T-Employee-0001", - }], - [{ - "doctype": "Sales Person", - "sales_person_name": "_Test Sales Person 1", - "parent_sales_person": "Sales Team", - "is_group": "No", - "employee": "_T-Employee-0002", - }], - [{ - "doctype": "Sales Person", - "sales_person_name": "_Test Sales Person 2", - "parent_sales_person": "Sales Team", - "is_group": "No", - "employee": "_T-Employee-0003", - }] - - -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Sales Person') \ No newline at end of file diff --git a/erpnext/setup/doctype/sms_parameter/sms_parameter.json b/erpnext/setup/doctype/sms_parameter/sms_parameter.json new file mode 100755 index 00000000000..cfa3d98498d --- /dev/null +++ b/erpnext/setup/doctype/sms_parameter/sms_parameter.json @@ -0,0 +1,34 @@ +{ + "creation": "2013-02-22 01:27:58.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "parameter", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Parameter", + "permlevel": 0, + "print_width": "150px", + "reqd": 1, + "width": "150px" + }, + { + "fieldname": "value", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Value", + "permlevel": 0, + "print_width": "150px", + "reqd": 1, + "width": "150px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:21:47.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "SMS Parameter", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/sms_parameter/sms_parameter.py b/erpnext/setup/doctype/sms_parameter/sms_parameter.py index 26c87f1c04a..a62da69f697 100644 --- a/erpnext/setup/doctype/sms_parameter/sms_parameter.py +++ b/erpnext/setup/doctype/sms_parameter/sms_parameter.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SMSParameter(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/sms_parameter/sms_parameter.txt b/erpnext/setup/doctype/sms_parameter/sms_parameter.txt deleted file mode 100755 index c4ebb8f84f1..00000000000 --- a/erpnext/setup/doctype/sms_parameter/sms_parameter.txt +++ /dev/null @@ -1,42 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:58", - "docstatus": 0, - "modified": "2013-12-20 19:21:47", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldtype": "Data", - "in_list_view": 1, - "name": "__common__", - "parent": "SMS Parameter", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "print_width": "150px", - "reqd": 1, - "width": "150px" - }, - { - "doctype": "DocType", - "name": "SMS Parameter" - }, - { - "doctype": "DocField", - "fieldname": "parameter", - "label": "Parameter" - }, - { - "doctype": "DocField", - "fieldname": "value", - "label": "Value" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.json b/erpnext/setup/doctype/sms_settings/sms_settings.json new file mode 100755 index 00000000000..a966ddbd4c5 --- /dev/null +++ b/erpnext/setup/doctype/sms_settings/sms_settings.json @@ -0,0 +1,75 @@ +{ + "allow_copy": 1, + "allow_email": 1, + "allow_print": 1, + "creation": "2013-01-10 16:34:24.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "description": "Eg. smsgateway.com/api/send_sms.cgi", + "fieldname": "sms_gateway_url", + "fieldtype": "Data", + "label": "SMS Gateway URL", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "Enter url parameter for message", + "fieldname": "message_parameter", + "fieldtype": "Data", + "label": "Message Parameter", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "Enter url parameter for receiver nos", + "fieldname": "receiver_parameter", + "fieldtype": "Data", + "label": "Receiver Parameter", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "static_parameters", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "description": "Enter static url parameters here (Eg. sender=ERPNext, username=ERPNext, password=1234 etc.)", + "fieldname": "static_parameter_details", + "fieldtype": "Table", + "label": "Static Parameters", + "options": "SMS Parameter", + "permlevel": 0 + } + ], + "icon": "icon-cog", + "idx": 1, + "in_create": 0, + "issingle": 1, + "modified": "2013-09-10 17:20:25.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "SMS Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "permlevel": 0, + "read": 1, + "report": 0, + "role": "System Manager", + "submit": 0, + "write": 1 + } + ], + "read_only": 0 +} \ No newline at end of file diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.py b/erpnext/setup/doctype/sms_settings/sms_settings.py index 26c87f1c04a..281ae7672c6 100644 --- a/erpnext/setup/doctype/sms_settings/sms_settings.py +++ b/erpnext/setup/doctype/sms_settings/sms_settings.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SMSSettings(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.txt b/erpnext/setup/doctype/sms_settings/sms_settings.txt deleted file mode 100755 index 20c0a62439d..00000000000 --- a/erpnext/setup/doctype/sms_settings/sms_settings.txt +++ /dev/null @@ -1,94 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:24", - "docstatus": 0, - "modified": "2013-09-10 17:20:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_copy": 1, - "allow_email": 1, - "allow_print": 1, - "doctype": "DocType", - "icon": "icon-cog", - "in_create": 0, - "issingle": 1, - "module": "Setup", - "name": "__common__", - "read_only": 0 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "SMS Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "SMS Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 0, - "role": "System Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "SMS Settings" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "description": "Eg. smsgateway.com/api/send_sms.cgi", - "doctype": "DocField", - "fieldname": "sms_gateway_url", - "fieldtype": "Data", - "label": "SMS Gateway URL", - "reqd": 1 - }, - { - "description": "Enter url parameter for message", - "doctype": "DocField", - "fieldname": "message_parameter", - "fieldtype": "Data", - "label": "Message Parameter", - "reqd": 1 - }, - { - "description": "Enter url parameter for receiver nos", - "doctype": "DocField", - "fieldname": "receiver_parameter", - "fieldtype": "Data", - "label": "Receiver Parameter", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "static_parameters", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "description": "Enter static url parameters here (Eg. sender=ERPNext, username=ERPNext, password=1234 etc.)", - "doctype": "DocField", - "fieldname": "static_parameter_details", - "fieldtype": "Table", - "label": "Static Parameters", - "options": "SMS Parameter" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/supplier_type/supplier_type.json b/erpnext/setup/doctype/supplier_type/supplier_type.json new file mode 100644 index 00000000000..03c8ece9e09 --- /dev/null +++ b/erpnext/setup/doctype/supplier_type/supplier_type.json @@ -0,0 +1,80 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:supplier_type", + "creation": "2013-01-10 16:34:24.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "supplier_type", + "fieldtype": "Data", + "label": "Supplier Type", + "oldfieldname": "supplier_type", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-flag", + "idx": 1, + "modified": "2014-01-20 17:49:31.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Supplier Type", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Manager", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Master Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/supplier_type/supplier_type.py b/erpnext/setup/doctype/supplier_type/supplier_type.py index d30eab6e92b..70369569ce9 100644 --- a/erpnext/setup/doctype/supplier_type/supplier_type.py +++ b/erpnext/setup/doctype/supplier_type/supplier_type.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class SupplierType(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/supplier_type/supplier_type.txt b/erpnext/setup/doctype/supplier_type/supplier_type.txt deleted file mode 100644 index 5154f15a987..00000000000 --- a/erpnext/setup/doctype/supplier_type/supplier_type.txt +++ /dev/null @@ -1,85 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:24", - "docstatus": 0, - "modified": "2014-01-20 17:49:31", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:supplier_type", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-flag", - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Supplier Type", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Supplier Type", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Supplier Type" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "supplier_type", - "fieldtype": "Data", - "label": "Supplier Type", - "oldfieldname": "supplier_type", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase Manager", - "write": 0 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase User", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Purchase Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/supplier_type/test_records.json b/erpnext/setup/doctype/supplier_type/test_records.json new file mode 100644 index 00000000000..a74c564551f --- /dev/null +++ b/erpnext/setup/doctype/supplier_type/test_records.json @@ -0,0 +1,6 @@ +[ + { + "doctype": "Supplier Type", + "supplier_type": "_Test Supplier Type" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/supplier_type/test_supplier_type.py b/erpnext/setup/doctype/supplier_type/test_supplier_type.py index eb49ef4ceb4..b365a05a854 100644 --- a/erpnext/setup/doctype/supplier_type/test_supplier_type.py +++ b/erpnext/setup/doctype/supplier_type/test_supplier_type.py @@ -1,9 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Supplier Type", - "supplier_type": "_Test Supplier Type", - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Supplier Type') \ No newline at end of file diff --git a/erpnext/setup/doctype/target_detail/target_detail.json b/erpnext/setup/doctype/target_detail/target_detail.json new file mode 100644 index 00000000000..a3df0e56907 --- /dev/null +++ b/erpnext/setup/doctype/target_detail/target_detail.json @@ -0,0 +1,62 @@ +{ + "creation": "2013-02-22 01:27:58.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "target_qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Target Qty", + "oldfieldname": "target_qty", + "oldfieldtype": "Currency", + "permlevel": 0 + }, + { + "fieldname": "target_amount", + "fieldtype": "Float", + "in_filter": 1, + "in_list_view": 1, + "label": "Target Amount", + "oldfieldname": "target_amount", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 0, + "search_index": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:21:51.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Target Detail", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/target_detail/target_detail.py b/erpnext/setup/doctype/target_detail/target_detail.py index 26c87f1c04a..2332560b65c 100644 --- a/erpnext/setup/doctype/target_detail/target_detail.py +++ b/erpnext/setup/doctype/target_detail/target_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class TargetDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/target_detail/target_detail.txt b/erpnext/setup/doctype/target_detail/target_detail.txt deleted file mode 100644 index 3ae395fc227..00000000000 --- a/erpnext/setup/doctype/target_detail/target_detail.txt +++ /dev/null @@ -1,72 +0,0 @@ -[ - { - "creation": "2013-02-22 01:27:58", - "docstatus": 0, - "modified": "2013-12-20 19:21:51", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Target Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Target Detail" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "in_filter": 1, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "target_qty", - "fieldtype": "Float", - "label": "Target Qty", - "oldfieldname": "target_qty", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "target_amount", - "fieldtype": "Float", - "in_filter": 1, - "label": "Target Amount", - "oldfieldname": "target_amount", - "oldfieldtype": "Currency", - "reqd": 0, - "search_index": 1 - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.json b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.json new file mode 100644 index 00000000000..b43790bbeef --- /dev/null +++ b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.json @@ -0,0 +1,103 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:title", + "creation": "2013-01-10 16:34:24.000000", + "description": "Standard Terms and Conditions that can be added to Sales and Purchases.\n\nExamples:\n\n1. Validity of the offer.\n1. Payment Terms (In Advance, On Credit, part advance etc).\n1. What is extra (or payable by the Customer).\n1. Safety / usage warning.\n1. Warranty if any.\n1. Returns Policy.\n1. Terms of shipping, if applicable.\n1. Ways of addressing disputes, indemnity, liability, etc.\n1. Address and Contact of your Company.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "title", + "fieldtype": "Data", + "in_filter": 1, + "label": "Title", + "oldfieldname": "title", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Terms and Conditions", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", + "permlevel": 0 + } + ], + "icon": "icon-legal", + "idx": 1, + "modified": "2014-01-20 17:49:33.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Terms and Conditions", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 0 + }, + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py index 26c87f1c04a..be538a7ea9a 100644 --- a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py +++ b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class TermsandConditions(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.txt b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.txt deleted file mode 100644 index 16493799ca3..00000000000 --- a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.txt +++ /dev/null @@ -1,104 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:24", - "docstatus": 0, - "modified": "2014-01-20 17:49:33", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:title", - "description": "Standard Terms and Conditions that can be added to Sales and Purchases.\n\nExamples:\n\n1. Validity of the offer.\n1. Payment Terms (In Advance, On Credit, part advance etc).\n1. What is extra (or payable by the Customer).\n1. Safety / usage warning.\n1. Warranty if any.\n1. Returns Policy.\n1. Terms of shipping, if applicable.\n1. Ways of addressing disputes, indemnity, liability, etc.\n1. Address and Contact of your Company.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-legal", - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Terms and Conditions", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Terms and Conditions", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Terms and Conditions" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "title", - "fieldtype": "Data", - "in_filter": 1, - "label": "Title", - "oldfieldname": "title", - "oldfieldtype": "Data", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Terms and Conditions", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor" - }, - { - "amend": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager", - "write": 1 - }, - { - "amend": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "System Manager", - "write": 1 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Accounts User", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/terms_and_conditions/test_records.json b/erpnext/setup/doctype/terms_and_conditions/test_records.json new file mode 100644 index 00000000000..9ba107706ca --- /dev/null +++ b/erpnext/setup/doctype/terms_and_conditions/test_records.json @@ -0,0 +1,6 @@ +[ + { + "terms": "_Test Terms", + "title": "_Test Terms and Conditions" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/terms_and_conditions/test_terms_and_conditions.py b/erpnext/setup/doctype/terms_and_conditions/test_terms_and_conditions.py index acebf7982cd..146930f373b 100644 --- a/erpnext/setup/doctype/terms_and_conditions/test_terms_and_conditions.py +++ b/erpnext/setup/doctype/terms_and_conditions/test_terms_and_conditions.py @@ -1,4 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [[{"title": "_Test Terms and Conditions", "terms": "_Test Terms"}]] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Terms And Conditions') \ No newline at end of file diff --git a/erpnext/setup/doctype/territory/territory.json b/erpnext/setup/doctype/territory/territory.json new file mode 100644 index 00000000000..e3456e93223 --- /dev/null +++ b/erpnext/setup/doctype/territory/territory.json @@ -0,0 +1,196 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:territory_name", + "creation": "2013-01-10 16:34:24.000000", + "description": "Classification of Customers by region", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "territory_name", + "fieldtype": "Data", + "label": "Territory Name", + "no_copy": 1, + "oldfieldname": "territory_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "Add / Edit", + "fieldname": "parent_territory", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Parent Territory", + "oldfieldname": "parent_territory", + "oldfieldtype": "Link", + "options": "Territory", + "permlevel": 0, + "reqd": 0 + }, + { + "description": "Only leaf nodes are allowed in transaction", + "fieldname": "is_group", + "fieldtype": "Select", + "label": "Has Child Node", + "oldfieldname": "is_group", + "oldfieldtype": "Select", + "options": "\nYes\nNo", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "cb0", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "For reference", + "fieldname": "territory_manager", + "fieldtype": "Link", + "in_filter": 1, + "label": "Territory Manager", + "oldfieldname": "territory_manager", + "oldfieldtype": "Link", + "options": "Sales Person", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "lft", + "fieldtype": "Int", + "hidden": 1, + "in_filter": 1, + "label": "lft", + "no_copy": 1, + "oldfieldname": "lft", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1, + "report_hide": 0, + "search_index": 1 + }, + { + "fieldname": "rgt", + "fieldtype": "Int", + "hidden": 1, + "in_filter": 1, + "label": "rgt", + "no_copy": 1, + "oldfieldname": "rgt", + "oldfieldtype": "Int", + "permlevel": 0, + "print_hide": 1, + "report_hide": 0, + "search_index": 1 + }, + { + "description": "Add / Edit", + "fieldname": "old_parent", + "fieldtype": "Link", + "hidden": 1, + "ignore_restrictions": 1, + "label": "old_parent", + "no_copy": 1, + "oldfieldname": "old_parent", + "oldfieldtype": "Data", + "options": "Territory", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + }, + { + "description": "Set Item Group-wise budgets on this Territory. You can also include seasonality by setting the Distribution.", + "fieldname": "target_details_section_break", + "fieldtype": "Section Break", + "label": "Territory Targets", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "target_details", + "fieldtype": "Table", + "label": "Target Details", + "oldfieldname": "target_details", + "oldfieldtype": "Table", + "options": "Target Detail", + "permlevel": 0 + }, + { + "description": "Select Budget Distribution to unevenly distribute targets across months.", + "fieldname": "distribution_id", + "fieldtype": "Link", + "label": "Target Distribution", + "oldfieldname": "distribution_id", + "oldfieldtype": "Link", + "options": "Budget Distribution", + "permlevel": 0 + } + ], + "icon": "icon-map-marker", + "idx": 1, + "in_create": 1, + "modified": "2014-01-20 17:49:33.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Territory", + "name_case": "Title Case", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + } + ], + "read_only": 1, + "search_fields": "name,parent_territory,territory_manager" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/territory/territory.py b/erpnext/setup/doctype/territory/territory.py index 5dfe458908f..83eae91c37e 100644 --- a/erpnext/setup/doctype/territory/territory.py +++ b/erpnext/setup/doctype/territory/territory.py @@ -4,23 +4,20 @@ from __future__ import unicode_literals import frappe -from frappe.model.bean import getlist + from frappe.utils import flt -from frappe.utils.nestedset import DocTypeNestedSet +from frappe.utils.nestedset import NestedSet -class DocType(DocTypeNestedSet): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.nsm_parent_field = 'parent_territory' +class Territory(NestedSet): + nsm_parent_field = 'parent_territory' def validate(self): - for d in getlist(self.doclist, 'target_details'): + for d in self.get('target_details'): if not flt(d.target_qty) and not flt(d.target_amount): msgprint("Either target qty or target amount is mandatory.") raise Exception def on_update(self): - super(DocType, self).on_update() + super(Territory, self).on_update() self.validate_one_root() diff --git a/erpnext/setup/doctype/territory/territory.txt b/erpnext/setup/doctype/territory/territory.txt deleted file mode 100644 index 3eb766d4e04..00000000000 --- a/erpnext/setup/doctype/territory/territory.txt +++ /dev/null @@ -1,201 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:24", - "docstatus": 0, - "modified": "2014-01-20 17:49:33", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:territory_name", - "description": "Classification of Customers by region", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-map-marker", - "in_create": 1, - "module": "Setup", - "name": "__common__", - "name_case": "Title Case", - "read_only": 1, - "search_fields": "name,parent_territory,territory_manager" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Territory", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Territory", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Territory" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "territory_name", - "fieldtype": "Data", - "label": "Territory Name", - "no_copy": 1, - "oldfieldname": "territory_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "parent_territory", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Parent Territory", - "oldfieldname": "parent_territory", - "oldfieldtype": "Link", - "options": "Territory", - "reqd": 0 - }, - { - "description": "Only leaf nodes are allowed in transaction", - "doctype": "DocField", - "fieldname": "is_group", - "fieldtype": "Select", - "label": "Has Child Node", - "oldfieldname": "is_group", - "oldfieldtype": "Select", - "options": "\nYes\nNo", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb0", - "fieldtype": "Column Break" - }, - { - "description": "For reference", - "doctype": "DocField", - "fieldname": "territory_manager", - "fieldtype": "Link", - "in_filter": 1, - "label": "Territory Manager", - "oldfieldname": "territory_manager", - "oldfieldtype": "Link", - "options": "Sales Person", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "lft", - "fieldtype": "Int", - "hidden": 1, - "in_filter": 1, - "label": "lft", - "no_copy": 1, - "oldfieldname": "lft", - "oldfieldtype": "Int", - "print_hide": 1, - "report_hide": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "rgt", - "fieldtype": "Int", - "hidden": 1, - "in_filter": 1, - "label": "rgt", - "no_copy": 1, - "oldfieldname": "rgt", - "oldfieldtype": "Int", - "print_hide": 1, - "report_hide": 0, - "search_index": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "old_parent", - "fieldtype": "Link", - "hidden": 1, - "ignore_restrictions": 1, - "label": "old_parent", - "no_copy": 1, - "oldfieldname": "old_parent", - "oldfieldtype": "Data", - "options": "Territory", - "print_hide": 1, - "report_hide": 1 - }, - { - "description": "Set Item Group-wise budgets on this Territory. You can also include seasonality by setting the Distribution.", - "doctype": "DocField", - "fieldname": "target_details_section_break", - "fieldtype": "Section Break", - "label": "Territory Targets", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "target_details", - "fieldtype": "Table", - "label": "Target Details", - "oldfieldname": "target_details", - "oldfieldtype": "Table", - "options": "Target Detail" - }, - { - "description": "Select Budget Distribution to unevenly distribute targets across months.", - "doctype": "DocField", - "fieldname": "distribution_id", - "fieldtype": "Link", - "label": "Target Distribution", - "oldfieldname": "distribution_id", - "oldfieldtype": "Link", - "options": "Budget Distribution" - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Sales Manager", - "write": 0 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User", - "write": 0 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/territory/test_records.json b/erpnext/setup/doctype/territory/test_records.json new file mode 100644 index 00000000000..251861942bf --- /dev/null +++ b/erpnext/setup/doctype/territory/test_records.json @@ -0,0 +1,32 @@ +[ + { + "doctype": "Territory", + "is_group": "No", + "parent_territory": "All Territories", + "territory_name": "_Test Territory" + }, + { + "doctype": "Territory", + "is_group": "Yes", + "parent_territory": "All Territories", + "territory_name": "_Test Territory India" + }, + { + "doctype": "Territory", + "is_group": "No", + "parent_territory": "_Test Territory India", + "territory_name": "_Test Territory Maharashtra" + }, + { + "doctype": "Territory", + "is_group": "No", + "parent_territory": "All Territories", + "territory_name": "_Test Territory Rest Of The World" + }, + { + "doctype": "Territory", + "is_group": "No", + "parent_territory": "All Territories", + "territory_name": "_Test Territory United States" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/territory/test_territory.py b/erpnext/setup/doctype/territory/test_territory.py index 3068b5f969c..22fad29f6a7 100644 --- a/erpnext/setup/doctype/territory/test_territory.py +++ b/erpnext/setup/doctype/territory/test_territory.py @@ -1,35 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Territory", - "territory_name": "_Test Territory", - "parent_territory": "All Territories", - "is_group": "No", - }], - [{ - "doctype": "Territory", - "territory_name": "_Test Territory India", - "parent_territory": "All Territories", - "is_group": "Yes", - }], - [{ - "doctype": "Territory", - "territory_name": "_Test Territory Maharashtra", - "parent_territory": "_Test Territory India", - "is_group": "No", - }], - [{ - "doctype": "Territory", - "territory_name": "_Test Territory Rest Of The World", - "parent_territory": "All Territories", - "is_group": "No", - }], - [{ - "doctype": "Territory", - "territory_name": "_Test Territory United States", - "parent_territory": "All Territories", - "is_group": "No", - }], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Territory') \ No newline at end of file diff --git a/erpnext/setup/doctype/uom/test_records.json b/erpnext/setup/doctype/uom/test_records.json new file mode 100644 index 00000000000..ddca542315d --- /dev/null +++ b/erpnext/setup/doctype/uom/test_records.json @@ -0,0 +1,11 @@ +[ + { + "doctype": "UOM", + "must_be_whole_number": 1, + "uom_name": "_Test UOM" + }, + { + "doctype": "UOM", + "uom_name": "_Test UOM 1" + } +] \ No newline at end of file diff --git a/erpnext/setup/doctype/uom/test_uom.py b/erpnext/setup/doctype/uom/test_uom.py index 2a7f2eea311..3511874e6fa 100644 --- a/erpnext/setup/doctype/uom/test_uom.py +++ b/erpnext/setup/doctype/uom/test_uom.py @@ -1,14 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "UOM", - "uom_name": "_Test UOM", - "must_be_whole_number": 1 - }], - [{ - "doctype": "UOM", - "uom_name": "_Test UOM 1" - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Uom') \ No newline at end of file diff --git a/erpnext/setup/doctype/uom/uom.json b/erpnext/setup/doctype/uom/uom.json new file mode 100644 index 00000000000..42e31eb1f14 --- /dev/null +++ b/erpnext/setup/doctype/uom/uom.json @@ -0,0 +1,77 @@ +{ + "allow_import": 1, + "autoname": "field:uom_name", + "creation": "2013-01-10 16:34:24.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "uom_name", + "fieldtype": "Data", + "label": "UOM Name", + "oldfieldname": "uom_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "Check this to disallow fractions. (for Nos)", + "fieldname": "must_be_whole_number", + "fieldtype": "Check", + "label": "Must be Whole Number", + "permlevel": 0 + } + ], + "icon": "icon-compass", + "idx": 1, + "modified": "2014-01-20 17:49:34.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "UOM", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Master Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Manager", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, + "write": 0 + } + ] +} \ No newline at end of file diff --git a/erpnext/setup/doctype/uom/uom.py b/erpnext/setup/doctype/uom/uom.py index d30eab6e92b..882226348a2 100644 --- a/erpnext/setup/doctype/uom/uom.py +++ b/erpnext/setup/doctype/uom/uom.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class UOM(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/uom/uom.txt b/erpnext/setup/doctype/uom/uom.txt deleted file mode 100644 index edff5b1d7b1..00000000000 --- a/erpnext/setup/doctype/uom/uom.txt +++ /dev/null @@ -1,82 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:24", - "docstatus": 0, - "modified": "2014-01-20 17:49:34", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "field:uom_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-compass", - "module": "Setup", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "UOM", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "UOM", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "UOM" - }, - { - "doctype": "DocField", - "fieldname": "uom_name", - "fieldtype": "Data", - "label": "UOM Name", - "oldfieldname": "uom_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "description": "Check this to disallow fractions. (for Nos)", - "doctype": "DocField", - "fieldname": "must_be_whole_number", - "fieldtype": "Check", - "label": "Must be Whole Number" - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Material Master Manager", - "write": 1 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Material Manager", - "write": 0 - }, - { - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Material User", - "write": 0 - } -] \ No newline at end of file diff --git a/erpnext/setup/doctype/website_item_group/website_item_group.json b/erpnext/setup/doctype/website_item_group/website_item_group.json new file mode 100644 index 00000000000..2f68e0a387d --- /dev/null +++ b/erpnext/setup/doctype/website_item_group/website_item_group.json @@ -0,0 +1,26 @@ +{ + "creation": "2013-02-22 01:28:09.000000", + "description": "Cross Listing of Item in multiple groups", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Other", + "fields": [ + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Item Group", + "options": "Item Group", + "permlevel": 0, + "reqd": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-28 13:00:07.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "Website Item Group", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/setup/doctype/website_item_group/website_item_group.py b/erpnext/setup/doctype/website_item_group/website_item_group.py index cb42e2eea2a..4665cabef23 100644 --- a/erpnext/setup/doctype/website_item_group/website_item_group.py +++ b/erpnext/setup/doctype/website_item_group/website_item_group.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class WebsiteItemGroup(Document): + pass \ No newline at end of file diff --git a/erpnext/setup/doctype/website_item_group/website_item_group.txt b/erpnext/setup/doctype/website_item_group/website_item_group.txt deleted file mode 100644 index ff731a1e48c..00000000000 --- a/erpnext/setup/doctype/website_item_group/website_item_group.txt +++ /dev/null @@ -1,39 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:09", - "docstatus": 0, - "modified": "2014-02-28 13:00:07", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Cross Listing of Item in multiple groups", - "doctype": "DocType", - "document_type": "Other", - "istable": 1, - "module": "Setup", - "name": "__common__" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item Group", - "name": "__common__", - "options": "Item Group", - "parent": "Website Item Group", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocType", - "name": "Website Item Group" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index ae81fbd3e4d..5128e36e8c0 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -10,7 +10,7 @@ def after_install(): import_country_and_currency() from erpnext.accounts.doctype.chart_of_accounts.import_charts import import_charts import_charts() - frappe.db.set_value('Control Panel', None, 'home_page', 'setup-wizard') + frappe.db.set_default('desktop:home_page', 'setup-wizard') feature_setup() from erpnext.setup.page.setup_wizard.setup_wizard import add_all_roles_to add_all_roles_to("Administrator") @@ -24,7 +24,7 @@ def import_country_and_currency(): for name in data: country = frappe._dict(data[name]) if not frappe.db.exists("Country", name): - frappe.doc({ + frappe.get_doc({ "doctype": "Country", "country_name": name, "code": country.code, @@ -33,7 +33,7 @@ def import_country_and_currency(): }).insert() if country.currency and not frappe.db.exists("Currency", country.currency): - frappe.doc({ + frappe.get_doc({ "doctype": "Currency", "currency_name": country.currency, "fraction": country.currency_fraction, @@ -111,19 +111,19 @@ def import_defaults(): from frappe.modules import scrub for r in records: - bean = frappe.bean(r) + doc = frappe.get_doc(r) # ignore mandatory for root - parent_link_field = ("parent_" + scrub(bean.doc.doctype)) - if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field): - bean.ignore_mandatory = True + parent_link_field = ("parent_" + scrub(doc.doctype)) + if doc.meta.get_field(parent_link_field) and not doc.get(parent_link_field): + doc.ignore_mandatory = True - bean.insert() + doc.insert() def feature_setup(): """save global defaults and features setup""" - bean = frappe.bean("Features Setup", "Features Setup") - bean.ignore_permissions = True + doc = frappe.get_doc("Features Setup", "Features Setup") + doc.ignore_permissions = True # store value as 1 for all these fields flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode', @@ -133,18 +133,18 @@ def feature_setup(): 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality', 'fs_page_break', 'fs_more_info', 'fs_pos_view' ] - bean.doc.fields.update(dict(zip(flds, [1]*len(flds)))) - bean.save() + doc.update(dict(zip(flds, [1]*len(flds)))) + doc.save() def set_single_defaults(): for dt in frappe.db.sql_list("""select name from `tabDocType` where issingle=1"""): default_values = frappe.db.sql("""select fieldname, `default` from `tabDocField` - where parent=%s""", dt, as_dict=True) + where parent=%s""", dt) if default_values: try: - b = frappe.bean(dt, dt) + b = frappe.get_doc(dt, dt) for fieldname, value in default_values: - b.doc.fields[fieldname] = value + b.set(fieldname, value) b.save() except frappe.MandatoryError: pass diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.js b/erpnext/setup/page/setup_wizard/setup_wizard.js index a8e63802762..fe2ceb88d38 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.js +++ b/erpnext/setup/page/setup_wizard/setup_wizard.js @@ -40,7 +40,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) { title: frappe._("ERPNext Setup Guide"), welcome_html: '

\

'+frappe._('ERPNext Setup')+'

\ -

' + +

' + frappe._('Welcome to ERPNext. Over the next few minutes we will help you setup your ERPNext account. Try and fill in as much information as you have even if it takes a bit longer. It will save you a lot of time later. Good Luck!') + '

', working_html: '

\ @@ -106,7 +106,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) { var parts = slide.get_input("company_name").val().split(" "); var abbr = $.map(parts, function(p) { return p ? p.substr(0,1) : null }).join(""); slide.get_input("company_abbr").val(abbr.toUpperCase()); - }).val(frappe.boot.control_panel.company_name || "").trigger("change"); + }).val(frappe.boot.sysdefaults.company_name || "").trigger("change"); slide.get_input("fy_start_date").on("change", function() { var year_end_date = diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.json b/erpnext/setup/page/setup_wizard/setup_wizard.json new file mode 100644 index 00000000000..e90c87c77c0 --- /dev/null +++ b/erpnext/setup/page/setup_wizard/setup_wizard.json @@ -0,0 +1,19 @@ +{ + "creation": "2013-10-04 13:49:33.000000", + "docstatus": 0, + "doctype": "Page", + "idx": 1, + "modified": "2013-10-04 13:49:33.000000", + "modified_by": "Administrator", + "module": "Setup", + "name": "setup-wizard", + "owner": "Administrator", + "page_name": "setup-wizard", + "roles": [ + { + "role": "System Manager" + } + ], + "standard": "Yes", + "title": "Setup Wizard" +} \ No newline at end of file diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py index eba79d84326..2bd906f1c23 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.py +++ b/erpnext/setup/page/setup_wizard/setup_wizard.py @@ -12,13 +12,13 @@ from frappe.utils.file_manager import save_file def setup_account(args=None): # if frappe.db.sql("select name from tabCompany"): # frappe.throw(_("Setup Already Complete!!")) - + if not args: args = frappe.local.form_dict if isinstance(args, basestring): args = json.loads(args) args = frappe._dict(args) - + update_user_name(args) create_fiscal_year_and_company(args) set_defaults(args) @@ -31,21 +31,21 @@ def setup_account(args=None): create_items(args) create_customers(args) create_suppliers(args) - frappe.db.set_value('Control Panel', None, 'home_page', 'desktop') + frappe.db.set_default('desktop:home_page', 'desktop') frappe.clear_cache() frappe.db.commit() - + # suppress msgprints frappe.local.message_log = [] return "okay" - + def update_user_name(args): if args.get("email"): args['name'] = args.get("email") frappe.flags.mute_emails = True - frappe.bean({ + frappe.get_doc({ "doctype":"User", "email": args.get("email"), "first_name": args.get("first_name"), @@ -59,30 +59,30 @@ def update_user_name(args): args['name'] = frappe.session.user # Update User - if not args.get('last_name') or args.get('last_name')=='None': + if not args.get('last_name') or args.get('last_name')=='None': args['last_name'] = None frappe.db.sql("""update `tabUser` SET first_name=%(first_name)s, last_name=%(last_name)s WHERE name=%(name)s""", args) - + if args.get("attach_user"): filename, filetype, content = args.get("attach_user").split(",") fileurl = save_file(filename, content, "User", args.get("name"), decode=True).file_name frappe.db.set_value("User", args.get("name"), "user_image", fileurl) - + add_all_roles_to(args.get("name")) - + def create_fiscal_year_and_company(args): curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date')) - frappe.bean([{ + frappe.get_doc({ "doctype":"Fiscal Year", 'year': curr_fiscal_year, 'year_start_date': args.get('fy_start_date'), 'year_end_date': args.get('fy_end_date'), - }]).insert() + }).insert() print args # Company - frappe.bean([{ + frappe.get_doc({ "doctype":"Company", 'domain': args.get("industry"), 'company_name':args.get('company_name'), @@ -90,34 +90,30 @@ def create_fiscal_year_and_company(args): 'default_currency':args.get('currency'), 'country': args.get('country'), 'chart_of_accounts': args.get(('chart_of_accounts')), - }]).insert() - + }).insert() + args["curr_fiscal_year"] = curr_fiscal_year - + def create_price_lists(args): for pl_type in ["Selling", "Buying"]: - frappe.bean([ - { + frappe.get_doc({ "doctype": "Price List", "price_list_name": "Standard " + pl_type, "enabled": 1, "buying": 1 if pl_type == "Buying" else 0, "selling": 1 if pl_type == "Selling" else 0, - "currency": args["currency"] - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "All Territories" - } - ]).insert() - + "currency": args["currency"], + "valid_for_territories": { + "territory": "All Territories" + } + }).insert() + def set_defaults(args): # enable default currency frappe.db.set_value("Currency", args.get("currency"), "enabled", 1) - - global_defaults = frappe.bean("Global Defaults", "Global Defaults") - global_defaults.doc.fields.update({ + + global_defaults = frappe.get_doc("Global Defaults", "Global Defaults") + global_defaults.update({ 'current_fiscal_year': args.curr_fiscal_year, 'default_currency': args.get('currency'), 'default_company':args.get('company_name'), @@ -127,50 +123,48 @@ def set_defaults(args): "time_zone": args.get("time_zone") }) global_defaults.save() - - accounts_settings = frappe.bean("Accounts Settings") - accounts_settings.doc.auto_accounting_for_stock = 1 + + accounts_settings = frappe.get_doc("Accounts Settings") + accounts_settings.auto_accounting_for_stock = 1 accounts_settings.save() - stock_settings = frappe.bean("Stock Settings") - stock_settings.doc.item_naming_by = "Item Code" - stock_settings.doc.valuation_method = "FIFO" - stock_settings.doc.stock_uom = "Nos" - stock_settings.doc.auto_indent = 1 + stock_settings = frappe.get_doc("Stock Settings") + stock_settings.item_naming_by = "Item Code" + stock_settings.valuation_method = "FIFO" + stock_settings.stock_uom = "Nos" + stock_settings.auto_indent = 1 stock_settings.save() - - selling_settings = frappe.bean("Selling Settings") - selling_settings.doc.cust_master_name = "Customer Name" - selling_settings.doc.so_required = "No" - selling_settings.doc.dn_required = "No" + + selling_settings = frappe.get_doc("Selling Settings") + selling_settings.cust_master_name = "Customer Name" + selling_settings.so_required = "No" + selling_settings.dn_required = "No" selling_settings.save() - buying_settings = frappe.bean("Buying Settings") - buying_settings.doc.supp_master_name = "Supplier Name" - buying_settings.doc.po_required = "No" - buying_settings.doc.pr_required = "No" - buying_settings.doc.maintain_same_rate = 1 + buying_settings = frappe.get_doc("Buying Settings") + buying_settings.supp_master_name = "Supplier Name" + buying_settings.po_required = "No" + buying_settings.pr_required = "No" + buying_settings.maintain_same_rate = 1 buying_settings.save() - notification_control = frappe.bean("Notification Control") - notification_control.doc.quotation = 1 - notification_control.doc.sales_invoice = 1 - notification_control.doc.purchase_order = 1 + notification_control = frappe.get_doc("Notification Control") + notification_control.quotation = 1 + notification_control.sales_invoice = 1 + notification_control.purchase_order = 1 notification_control.save() - hr_settings = frappe.bean("HR Settings") - hr_settings.doc.emp_created_by = "Naming Series" + hr_settings = frappe.get_doc("HR Settings") + hr_settings.emp_created_by = "Naming Series" hr_settings.save() - email_settings = frappe.bean("Outgoing Email Settings") - email_settings.doc.send_print_in_body_and_attachment = 1 + email_settings = frappe.get_doc("Outgoing Email Settings") + email_settings.send_print_in_body_and_attachment = 1 email_settings.save() - # control panel - cp = frappe.doc("Control Panel", "Control Panel") - cp.company_name = args["company_name"] - cp.save() - + # default + frappe.db.set_default("company_name", args["company_name"]) + def create_feed_and_todo(): """update activty feed and create todo for creation of item, customer, vendor""" from erpnext.home import make_feed @@ -180,13 +174,13 @@ def create_feed_and_todo(): def create_email_digest(): from frappe.utils.user import get_system_managers system_managers = get_system_managers(only_name=True) - if not system_managers: + if not system_managers: return - + companies = frappe.db.sql_list("select name FROM `tabCompany`") for company in companies: if not frappe.db.exists("Email Digest", "Default Weekly Digest - " + company): - edigest = frappe.bean({ + edigest = frappe.get_doc({ "doctype": "Email Digest", "name": "Default Weekly Digest - " + company, "company": company, @@ -194,16 +188,16 @@ def create_email_digest(): "recipient_list": "\n".join(system_managers) }) - for fieldname in edigest.meta.get_fieldnames({"fieldtype": "Check"}): + for fieldname in edigest.meta.get("fields", {"fieldtype": "Check"}): if fieldname != "scheduler_errors": - edigest.doc.fields[fieldname] = 1 - + edigest.set(fieldname, 1) + edigest.insert() - + # scheduler errors digest if companies: - edigest = frappe.new_bean("Email Digest") - edigest.doc.fields.update({ + edigest = frappe.new_doc("Email Digest") + edigest.update({ "name": "Scheduler Errors", "company": companies[0], "frequency": "Daily", @@ -212,7 +206,7 @@ def create_email_digest(): "enabled": 1 }) edigest.insert() - + def get_fy_details(fy_start_date, fy_end_date): start_year = getdate(fy_start_date).year if start_year == getdate(fy_end_date).year: @@ -224,7 +218,7 @@ def get_fy_details(fy_start_date, fy_end_date): def create_taxes(args): for i in xrange(1,6): if args.get("tax_" + str(i)): - frappe.bean({ + frappe.get_doc({ "doctype":"Account", "company": args.get("company_name"), "parent_account": "Duties and Taxes - " + args.get("company_abbr"), @@ -240,7 +234,7 @@ def create_items(args): item = args.get("item_" + str(i)) if item: item_group = args.get("item_group_" + str(i)) - frappe.bean({ + frappe.get_doc({ "doctype":"Item", "item_code": item, "item_name": item, @@ -251,17 +245,17 @@ def create_items(args): "stock_uom": args.get("item_uom_" + str(i)), "default_warehouse": item_group!="Service" and ("Finished Goods - " + args.get("company_abbr")) or "" }).insert() - + if args.get("item_img_" + str(i)): filename, filetype, content = args.get("item_img_" + str(i)).split(",") fileurl = save_file(filename, content, "Item", item, decode=True).file_name frappe.db.set_value("Item", item, "image", fileurl) - + for i in xrange(1,6): item = args.get("item_buy_" + str(i)) if item: item_group = args.get("item_buy_group_" + str(i)) - frappe.bean({ + frappe.get_doc({ "doctype":"Item", "item_code": item, "item_name": item, @@ -272,7 +266,7 @@ def create_items(args): "stock_uom": args.get("item_buy_uom_" + str(i)), "default_warehouse": item_group!="Service" and ("Stores - " + args.get("company_abbr")) or "" }).insert() - + if args.get("item_img_" + str(i)): filename, filetype, content = args.get("item_img_" + str(i)).split(",") fileurl = save_file(filename, content, "Item", item, decode=True).file_name @@ -283,7 +277,7 @@ def create_customers(args): for i in xrange(1,6): customer = args.get("customer_" + str(i)) if customer: - frappe.bean({ + frappe.get_doc({ "doctype":"Customer", "customer_name": customer, "customer_type": "Company", @@ -291,21 +285,21 @@ def create_customers(args): "territory": args.get("country"), "company": args.get("company_name") }).insert() - + if args.get("customer_contact_" + str(i)): contact = args.get("customer_contact_" + str(i)).split(" ") - frappe.bean({ + frappe.get_doc({ "doctype":"Contact", "customer": customer, "first_name":contact[0], "last_name": len(contact) > 1 and contact[1] or "" }).insert() - + def create_suppliers(args): for i in xrange(1,6): supplier = args.get("supplier_" + str(i)) if supplier: - frappe.bean({ + frappe.get_doc({ "doctype":"Supplier", "supplier_name": supplier, "supplier_type": "Local", @@ -314,7 +308,7 @@ def create_suppliers(args): if args.get("supplier_contact_" + str(i)): contact = args.get("supplier_contact_" + str(i)).split(" ") - frappe.bean({ + frappe.get_doc({ "doctype":"Contact", "supplier": supplier, "first_name":contact[0], @@ -324,36 +318,34 @@ def create_suppliers(args): def create_letter_head(args): if args.get("attach_letterhead"): - lh = frappe.bean({ + lh = frappe.get_doc({ "doctype":"Letter Head", "letter_head_name": "Standard", "is_default": 1 }).insert() - + filename, filetype, content = args.get("attach_letterhead").split(",") fileurl = save_file(filename, content, "Letter Head", "Standard", decode=True).file_name frappe.db.set_value("Letter Head", "Standard", "content", "" % fileurl) - - - + def add_all_roles_to(name): - user = frappe.doc("User", name) + user = frappe.get_doc("User", name) for role in frappe.db.sql("""select name from tabRole"""): if role[0] not in ["Administrator", "Guest", "All", "Customer", "Supplier", "Partner"]: - d = user.addchild("user_roles", "UserRole") + d = user.append("user_roles") d.role = role[0] - d.insert() - + user.save() + def create_territories(): """create two default territories, one for home country and one named Rest of the World""" from frappe.utils.nestedset import get_root_of - country = frappe.db.get_value("Control Panel", None, "country") + country = frappe.db.get_default("country") root_territory = get_root_of("Territory") for name in (country, "Rest Of The World"): if name and not frappe.db.exists("Territory", name): - frappe.bean({ + frappe.get_doc({ "doctype": "Territory", "territory_name": name.replace("'", ""), "parent_territory": root_territory, "is_group": "No" - }).insert() \ No newline at end of file + }).insert() diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.txt b/erpnext/setup/page/setup_wizard/setup_wizard.txt deleted file mode 100644 index 996fd1a0591..00000000000 --- a/erpnext/setup/page/setup_wizard/setup_wizard.txt +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "creation": "2013-10-04 13:49:33", - "docstatus": 0, - "modified": "2013-10-04 13:49:33", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "module": "Setup", - "name": "__common__", - "page_name": "setup-wizard", - "standard": "Yes", - "title": "Setup Wizard" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "setup-wizard", - "parentfield": "roles", - "parenttype": "Page", - "role": "System Manager" - }, - { - "doctype": "Page", - "name": "setup-wizard" - }, - { - "doctype": "Page Role" - } -] \ No newline at end of file diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py index 4b47398fb54..1d5a6d207ba 100644 --- a/erpnext/startup/boot.py +++ b/erpnext/startup/boot.py @@ -8,19 +8,17 @@ import frappe def boot_session(bootinfo): """boot session - send website info if guest""" import frappe - import frappe.model.doc bootinfo['custom_css'] = frappe.db.get_value('Style Settings', None, 'custom_css') or '' - bootinfo['website_settings'] = frappe.model.doc.getsingle('Website Settings') + bootinfo['website_settings'] = frappe.get_doc('Website Settings') if frappe.session['user']!='Guest': bootinfo['letter_heads'] = get_letter_heads() load_country_and_currency(bootinfo) - import frappe.model.doctype - bootinfo['notification_settings'] = frappe.doc("Notification Control", - "Notification Control").get_values() + bootinfo['notification_settings'] = frappe.get_doc("Notification Control", + "Notification Control") # if no company, show a dialog box to create a new company bootinfo["customer_count"] = frappe.db.sql("""select count(*) from tabCustomer""")[0][0] @@ -33,9 +31,9 @@ def boot_session(bootinfo): from `tabCompany`""", as_dict=1, update={"doctype":":Company"}) def load_country_and_currency(bootinfo): - if bootinfo.control_panel.country and \ - frappe.db.exists("Country", bootinfo.control_panel.country): - bootinfo["docs"] += [frappe.doc("Country", bootinfo.control_panel.country)] + country = frappe.db.get_default("country") + if country and frappe.db.exists("Country", country): + bootinfo["docs"] += [frappe.get_doc("Country", country)] bootinfo["docs"] += frappe.db.sql("""select * from tabCurrency where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"}) diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index 448cbf0de3b..0fea0ea55b1 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -4,14 +4,14 @@ from __future__ import unicode_literals import frappe +from frappe.utils import nowtime +from frappe.utils.user import get_user_fullname from erpnext.home import make_feed def on_session_creation(login_manager): """make feed""" if frappe.session['user'] not in ('Guest'): # create feed - from frappe.utils import nowtime - from frappe.utils.user import get_user_fullname make_feed('Login', 'User', login_manager.user, login_manager.user, '%s logged in at %s' % (get_user_fullname(login_manager.user), nowtime()), login_manager.user=='Administrator' and '#8CA2B3' or '#1B750D') diff --git a/erpnext/stock/Print Format/Delivery Note Classic/Delivery Note Classic.json b/erpnext/stock/Print Format/Delivery Note Classic/Delivery Note Classic.json new file mode 100644 index 00000000000..c0a198fa71f --- /dev/null +++ b/erpnext/stock/Print Format/Delivery Note Classic/Delivery Note Classic.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:31:11.000000", + "doc_type": "Delivery Note", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:36:51.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Delivery Note Classic", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt b/erpnext/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt deleted file mode 100644 index 3f29d611277..00000000000 --- a/erpnext/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:31:11", - "docstatus": 0, - "modified": "2014-02-11 17:36:51", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Delivery Note", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Stock", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Delivery Note Classic" - } -] \ No newline at end of file diff --git a/erpnext/stock/Print Format/Delivery Note Modern/Delivery Note Modern.json b/erpnext/stock/Print Format/Delivery Note Modern/Delivery Note Modern.json new file mode 100644 index 00000000000..9a4999db863 --- /dev/null +++ b/erpnext/stock/Print Format/Delivery Note Modern/Delivery Note Modern.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:31:11.000000", + "doc_type": "Delivery Note", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:36:26.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Delivery Note Modern", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/stock/Print Format/Delivery Note Modern/Delivery Note Modern.txt b/erpnext/stock/Print Format/Delivery Note Modern/Delivery Note Modern.txt deleted file mode 100644 index 2c668670f81..00000000000 --- a/erpnext/stock/Print Format/Delivery Note Modern/Delivery Note Modern.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:31:11", - "docstatus": 0, - "modified": "2014-02-11 17:36:26", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Delivery Note", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Stock", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Delivery Note Modern" - } -] \ No newline at end of file diff --git a/erpnext/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.json b/erpnext/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.json new file mode 100644 index 00000000000..eb420341ea2 --- /dev/null +++ b/erpnext/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.json @@ -0,0 +1,13 @@ +{ + "creation": "2011-08-23 16:49:40.000000", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n", + "idx": 1, + "modified": "2011-10-19 14:12:11.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Delivery Note Packing List Wise", + "owner": "Administrator", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.txt b/erpnext/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.txt deleted file mode 100644 index 1d338332277..00000000000 --- a/erpnext/stock/Print Format/Delivery Note Packing List Wise/Delivery Note Packing List Wise.txt +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2011-08-23 16:49:40", - "modified_by": "Administrator", - "modified": "2011-10-19 14:12:11" - }, - { - "name": "__common__", - "module": "Stock", - "standard": "Yes", - "html": "\n\n\n\n\n\n\n\n\n\n", - "doctype": "Print Format" - }, - { - "name": "Delivery Note Packing List Wise", - "doctype": "Print Format" - } -] \ No newline at end of file diff --git a/erpnext/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.json b/erpnext/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.json new file mode 100644 index 00000000000..626dcda0bcb --- /dev/null +++ b/erpnext/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-04-19 13:31:11.000000", + "doc_type": "Delivery Note", + "docstatus": 0, + "doctype": "Print Format", + "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", + "idx": 1, + "modified": "2014-02-11 17:37:14.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Delivery Note Spartan", + "owner": "Administrator", + "print_format_type": "Client", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.txt b/erpnext/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.txt deleted file mode 100644 index 4b62d70f1c1..00000000000 --- a/erpnext/stock/Print Format/Delivery Note Spartan/Delivery Note Spartan.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-04-19 13:31:11", - "docstatus": 0, - "modified": "2014-02-11 17:37:14", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doc_type": "Delivery Note", - "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n", - "module": "Stock", - "name": "__common__", - "print_format_type": "Client", - "standard": "Yes" - }, - { - "doctype": "Print Format", - "name": "Delivery Note Spartan" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/batch/batch.json b/erpnext/stock/doctype/batch/batch.json new file mode 100644 index 00000000000..df9c8c5d47e --- /dev/null +++ b/erpnext/stock/doctype/batch/batch.json @@ -0,0 +1,90 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "autoname": "field:batch_id", + "creation": "2013-03-05 14:50:38.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "batch_id", + "fieldtype": "Data", + "label": "Batch ID", + "no_copy": 1, + "oldfieldname": "batch_id", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "item", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Item", + "oldfieldname": "item", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "width": "300px" + }, + { + "fieldname": "expiry_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Expiry Date", + "oldfieldname": "expiry_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "start_date", + "fieldtype": "Date", + "label": "Batch Started Date", + "oldfieldname": "start_date", + "oldfieldtype": "Date", + "permlevel": 0 + }, + { + "fieldname": "finished_date", + "fieldtype": "Date", + "label": "Batch Finished Date", + "oldfieldname": "finished_date", + "oldfieldtype": "Date", + "permlevel": 0 + } + ], + "icon": "icon-archive", + "idx": 1, + "max_attachments": 5, + "modified": "2014-01-20 17:48:24.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Batch", + "owner": "harshada@webnotestech.com", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Master Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index 26c87f1c04a..365cb38b60a 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class Batch(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/batch/batch.txt b/erpnext/stock/doctype/batch/batch.txt deleted file mode 100644 index c08573b5077..00000000000 --- a/erpnext/stock/doctype/batch/batch.txt +++ /dev/null @@ -1,109 +0,0 @@ -[ - { - "creation": "2013-03-05 14:50:38", - "docstatus": 0, - "modified": "2014-01-20 17:48:24", - "modified_by": "Administrator", - "owner": "harshada@webnotestech.com" - }, - { - "allow_attach": 1, - "allow_import": 1, - "autoname": "field:batch_id", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-archive", - "max_attachments": 5, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Batch", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Batch", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Material Master Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Batch" - }, - { - "doctype": "DocField", - "fieldname": "batch_id", - "fieldtype": "Data", - "label": "Batch ID", - "no_copy": 1, - "oldfieldname": "batch_id", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "item", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item", - "oldfieldname": "item", - "oldfieldtype": "Link", - "options": "Item", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "expiry_date", - "fieldtype": "Date", - "in_list_view": 1, - "label": "Expiry Date", - "oldfieldname": "expiry_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "start_date", - "fieldtype": "Date", - "label": "Batch Started Date", - "oldfieldname": "start_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocField", - "fieldname": "finished_date", - "fieldtype": "Date", - "label": "Batch Finished Date", - "oldfieldname": "finished_date", - "oldfieldtype": "Date" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/bin/bin.json b/erpnext/stock/doctype/bin/bin.json new file mode 100644 index 00000000000..03fa4bfe1b0 --- /dev/null +++ b/erpnext/stock/doctype/bin/bin.json @@ -0,0 +1,205 @@ +{ + "autoname": "BIN/.#######", + "creation": "2013-01-10 16:34:25.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "warehouse", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Warehouse", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "read_only": 1, + "search_index": 1 + }, + { + "default": "0.00", + "fieldname": "reserved_qty", + "fieldtype": "Float", + "in_filter": 0, + "in_list_view": 1, + "label": "Reserved Quantity", + "oldfieldname": "reserved_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "default": "0.00", + "fieldname": "actual_qty", + "fieldtype": "Float", + "in_filter": 1, + "in_list_view": 1, + "label": "Actual Quantity", + "oldfieldname": "actual_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "default": "0.00", + "fieldname": "ordered_qty", + "fieldtype": "Float", + "in_filter": 0, + "in_list_view": 1, + "label": "Ordered Quantity", + "oldfieldname": "ordered_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "default": "0.00", + "fieldname": "indented_qty", + "fieldtype": "Float", + "in_filter": 0, + "label": "Quantity Requested for Purchase", + "oldfieldname": "indented_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "planned_qty", + "fieldtype": "Float", + "in_filter": 0, + "label": "Planned Qty", + "oldfieldname": "planned_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "projected_qty", + "fieldtype": "Float", + "in_filter": 0, + "label": "Projected Qty", + "oldfieldname": "projected_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "ma_rate", + "fieldtype": "Float", + "hidden": 1, + "in_filter": 0, + "label": "Moving Average Rate", + "oldfieldname": "ma_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1, + "search_index": 0 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "in_filter": 1, + "label": "UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "fcfs_rate", + "fieldtype": "Float", + "hidden": 1, + "label": "FCFS Rate", + "oldfieldname": "fcfs_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1 + }, + { + "fieldname": "valuation_rate", + "fieldtype": "Float", + "label": "Valuation Rate", + "oldfieldname": "valuation_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "stock_value", + "fieldtype": "Float", + "label": "Stock Value", + "oldfieldname": "stock_value", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + } + ], + "hide_toolbar": 1, + "idx": 1, + "in_create": 1, + "modified": "2013-12-20 19:23:56.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Bin", + "owner": "Administrator", + "permissions": [ + { + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0 + }, + { + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "submit": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, + "write": 0 + } + ], + "read_only": 0, + "search_fields": "item_code,warehouse" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py index 1b5e243731c..3f74c5c7d35 100644 --- a/erpnext/stock/doctype/bin/bin.py +++ b/erpnext/stock/doctype/bin/bin.py @@ -3,31 +3,25 @@ from __future__ import unicode_literals import frappe -from frappe.utils import add_days, cint,flt, nowdate, get_url_to_form, formatdate -from frappe import msgprint, _ - +from frappe.utils import flt, nowdate import frappe.defaults +from frappe.model.document import Document - -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - +class Bin(Document): def validate(self): - if self.doc.fields.get("__islocal") or not self.doc.stock_uom: - self.doc.stock_uom = frappe.db.get_value('Item', self.doc.item_code, 'stock_uom') + if self.get("__islocal") or not self.stock_uom: + self.stock_uom = frappe.db.get_value('Item', self.item_code, 'stock_uom') self.validate_mandatory() - self.doc.projected_qty = flt(self.doc.actual_qty) + flt(self.doc.ordered_qty) + \ - flt(self.doc.indented_qty) + flt(self.doc.planned_qty) - flt(self.doc.reserved_qty) + self.projected_qty = flt(self.actual_qty) + flt(self.ordered_qty) + \ + flt(self.indented_qty) + flt(self.planned_qty) - flt(self.reserved_qty) def validate_mandatory(self): qf = ['actual_qty', 'reserved_qty', 'ordered_qty', 'indented_qty'] for f in qf: - if (not self.doc.fields.has_key(f)) or (not self.doc.fields[f]): - self.doc.fields[f] = 0.0 + if (not getattr(self, f, None)) or (not self.get(f)): + self.set(f, 0.0) def update_stock(self, args): self.update_qty(args) @@ -40,24 +34,25 @@ class DocType: # update valuation and qty after transaction for post dated entry update_entries_after({ - "item_code": self.doc.item_code, - "warehouse": self.doc.warehouse, + "item_code": self.item_code, + "warehouse": self.warehouse, "posting_date": args.get("posting_date"), "posting_time": args.get("posting_time") }) def update_qty(self, args): # update the stock values (for current quantities) - self.doc.actual_qty = flt(self.doc.actual_qty) + flt(args.get("actual_qty")) - self.doc.ordered_qty = flt(self.doc.ordered_qty) + flt(args.get("ordered_qty")) - self.doc.reserved_qty = flt(self.doc.reserved_qty) + flt(args.get("reserved_qty")) - self.doc.indented_qty = flt(self.doc.indented_qty) + flt(args.get("indented_qty")) - self.doc.planned_qty = flt(self.doc.planned_qty) + flt(args.get("planned_qty")) - self.doc.projected_qty = flt(self.doc.actual_qty) + flt(self.doc.ordered_qty) + \ - flt(self.doc.indented_qty) + flt(self.doc.planned_qty) - flt(self.doc.reserved_qty) + self.actual_qty = flt(self.actual_qty) + flt(args.get("actual_qty")) + self.ordered_qty = flt(self.ordered_qty) + flt(args.get("ordered_qty")) + self.reserved_qty = flt(self.reserved_qty) + flt(args.get("reserved_qty")) + self.indented_qty = flt(self.indented_qty) + flt(args.get("indented_qty")) + self.planned_qty = flt(self.planned_qty) + flt(args.get("planned_qty")) - self.doc.save() + self.projected_qty = flt(self.actual_qty) + flt(self.ordered_qty) + \ + flt(self.indented_qty) + flt(self.planned_qty) - flt(self.reserved_qty) + + self.save() def get_first_sle(self): sle = frappe.db.sql(""" @@ -66,5 +61,5 @@ class DocType: and warehouse = %s order by timestamp(posting_date, posting_time) asc, name asc limit 1 - """, (self.doc.item_code, self.doc.warehouse), as_dict=1) + """, (self.item_code, self.warehouse), as_dict=1) return sle and sle[0] or None \ No newline at end of file diff --git a/erpnext/stock/doctype/bin/bin.txt b/erpnext/stock/doctype/bin/bin.txt deleted file mode 100644 index 27751910704..00000000000 --- a/erpnext/stock/doctype/bin/bin.txt +++ /dev/null @@ -1,202 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:25", - "docstatus": 0, - "modified": "2013-12-20 19:23:56", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "BIN/.#######", - "doctype": "DocType", - "hide_toolbar": 1, - "in_create": 1, - "module": "Stock", - "name": "__common__", - "read_only": 0, - "search_fields": "item_code,warehouse" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Bin", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "read_only": 1 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Bin", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Bin" - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Warehouse", - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "search_index": 1 - }, - { - "default": "0.00", - "doctype": "DocField", - "fieldname": "reserved_qty", - "fieldtype": "Float", - "in_filter": 0, - "in_list_view": 1, - "label": "Reserved Quantity", - "oldfieldname": "reserved_qty", - "oldfieldtype": "Currency", - "search_index": 0 - }, - { - "default": "0.00", - "doctype": "DocField", - "fieldname": "actual_qty", - "fieldtype": "Float", - "in_filter": 1, - "in_list_view": 1, - "label": "Actual Quantity", - "oldfieldname": "actual_qty", - "oldfieldtype": "Currency", - "search_index": 0 - }, - { - "default": "0.00", - "doctype": "DocField", - "fieldname": "ordered_qty", - "fieldtype": "Float", - "in_filter": 0, - "in_list_view": 1, - "label": "Ordered Quantity", - "oldfieldname": "ordered_qty", - "oldfieldtype": "Currency", - "search_index": 0 - }, - { - "default": "0.00", - "doctype": "DocField", - "fieldname": "indented_qty", - "fieldtype": "Float", - "in_filter": 0, - "label": "Quantity Requested for Purchase", - "oldfieldname": "indented_qty", - "oldfieldtype": "Currency", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "planned_qty", - "fieldtype": "Float", - "in_filter": 0, - "label": "Planned Qty", - "oldfieldname": "planned_qty", - "oldfieldtype": "Currency", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "projected_qty", - "fieldtype": "Float", - "in_filter": 0, - "label": "Projected Qty", - "oldfieldname": "projected_qty", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "ma_rate", - "fieldtype": "Float", - "hidden": 1, - "in_filter": 0, - "label": "Moving Average Rate", - "oldfieldname": "ma_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "report_hide": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "in_filter": 1, - "label": "UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "fcfs_rate", - "fieldtype": "Float", - "hidden": 1, - "label": "FCFS Rate", - "oldfieldname": "fcfs_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "valuation_rate", - "fieldtype": "Float", - "label": "Valuation Rate", - "oldfieldname": "valuation_rate", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocField", - "fieldname": "stock_value", - "fieldtype": "Float", - "label": "Stock Value", - "oldfieldname": "stock_value", - "oldfieldtype": "Currency" - }, - { - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "doctype": "DocPerm", - "role": "Purchase User" - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "role": "Material User", - "write": 0 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 371c093a2a6..f94a118ff63 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -20,8 +20,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( if(!doc.__billing_complete && doc.docstatus==1) { // show Make Invoice button only if Delivery Note is not created from Sales Invoice var from_sales_invoice = false; - from_sales_invoice = cur_frm.get_doclist({parentfield: "delivery_note_details"}) - .some(function(item) { + from_sales_invoice = cur_frm.doc.delivery_note_details.some(function(item) { return item.against_sales_invoice ? true : false; }); @@ -167,7 +166,7 @@ cur_frm.pformat.sales_order_no= function(doc, cdt, cdn){ out =''; - var cl = getchildren('Delivery Note Item',doc.name,'delivery_note_details'); + var cl = doc.delivery_note_details || []; // outer table var out='
'; @@ -205,7 +204,7 @@ if (sys_defaults.auto_accounting_for_stock) { cur_frm.cscript.expense_account = function(doc, cdt, cdn){ var d = locals[cdt][cdn]; if(d.expense_account) { - var cl = getchildren('Delivery Note Item', doc.name, cur_frm.cscript.fname, doc.doctype); + var cl = doc[cur_frm.cscript.fname] || []; for(var i = 0; i < cl.length; i++){ if(!cl[i].expense_account) cl[i].expense_account = d.expense_account; } @@ -228,7 +227,7 @@ if (sys_defaults.auto_accounting_for_stock) { cur_frm.cscript.cost_center = function(doc, cdt, cdn){ var d = locals[cdt][cdn]; if(d.cost_center) { - var cl = getchildren('Delivery Note Item', doc.name, cur_frm.cscript.fname, doc.doctype); + var cl = doc[cur_frm.cscript.fname] || []; for(var i = 0; i < cl.length; i++){ if(!cl[i].cost_center) cl[i].cost_center = d.cost_center; } diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json new file mode 100644 index 00000000000..2300f9a11bd --- /dev/null +++ b/erpnext/stock/doctype/delivery_note/delivery_note.json @@ -0,0 +1,1076 @@ +{ + "allow_attach": 1, + "autoname": "naming_series:", + "creation": "2013-05-24 19:29:09.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "fieldname": "delivery_to_section", + "fieldtype": "Section Break", + "label": "Delivery To", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "DN", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "in_filter": 1, + "label": "Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "depends_on": "customer", + "fieldname": "customer_name", + "fieldtype": "Data", + "hidden": 0, + "in_list_view": 1, + "label": "Customer Name", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "customer", + "fieldname": "customer_address", + "fieldtype": "Link", + "in_filter": 1, + "label": "Billing Address Name", + "options": "Address", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Billing Address", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "shipping_address_name", + "fieldtype": "Link", + "label": "Shipping Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "shipping_address", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Shipping Address", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_mobile", + "fieldtype": "Text", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_email", + "fieldtype": "Text", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 0, + "fieldname": "amended_from", + "fieldtype": "Data", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "description": "Select the relevant company name if you have multiple companies", + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 0, + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "default": "Today", + "fieldname": "posting_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Posting Date", + "no_copy": 1, + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "search_index": 1, + "width": "100px" + }, + { + "fieldname": "po_no", + "fieldtype": "Data", + "hidden": 1, + "label": "Customer's Purchase Order No", + "no_copy": 0, + "oldfieldname": "po_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "width": "100px" + }, + { + "depends_on": "eval:doc.po_no", + "fieldname": "po_date", + "fieldtype": "Date", + "hidden": 0, + "label": "Customer's Purchase Order Date", + "no_copy": 0, + "oldfieldname": "po_date", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "width": "100px" + }, + { + "fieldname": "sec_break25", + "fieldtype": "Section Break", + "label": "Currency and Price List", + "options": "icon-tag", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "description": "Rate at which customer's currency is converted to company's base currency", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "label": "Exchange Rate", + "no_copy": 0, + "oldfieldname": "conversion_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "col_break23", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "selling_price_list", + "fieldtype": "Link", + "label": "Price List", + "oldfieldname": "price_list_name", + "oldfieldtype": "Select", + "options": "Price List", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "price_list_currency", + "fieldtype": "Link", + "label": "Price List Currency", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "description": "Rate at which Price list currency is converted to company's base currency", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "label": "Price List Exchange Rate", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "items", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "delivery_note_details", + "fieldtype": "Table", + "label": "Delivery Note Items", + "no_copy": 0, + "oldfieldname": "delivery_note_details", + "oldfieldtype": "Table", + "options": "Delivery Note Item", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "packing_list", + "fieldtype": "Section Break", + "label": "Packing List", + "oldfieldtype": "Section Break", + "options": "icon-suitcase", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "packing_details", + "fieldtype": "Table", + "label": "Packing Details", + "oldfieldname": "packing_details", + "oldfieldtype": "Table", + "options": "Packed Item", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "sales_bom_help", + "fieldtype": "HTML", + "label": "Sales BOM Help", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break_31", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "net_total_export", + "fieldtype": "Currency", + "label": "Net Total", + "options": "currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break_33", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total (Company Currency)", + "no_copy": 0, + "oldfieldname": "net_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "reqd": 0, + "width": "150px" + }, + { + "fieldname": "taxes", + "fieldtype": "Section Break", + "label": "Taxes and Charges", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "If you have created a standard template in Sales Taxes and Charges Master, select one and click on the button below.", + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "oldfieldname": "charge", + "oldfieldtype": "Link", + "options": "Sales Taxes and Charges Master", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break_39", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "shipping_rule", + "fieldtype": "Link", + "label": "Shipping Rule", + "oldfieldtype": "Button", + "options": "Shipping Rule", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break_41", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "other_charges", + "fieldtype": "Table", + "label": "Sales Taxes and Charges", + "no_copy": 0, + "oldfieldname": "other_charges", + "oldfieldtype": "Table", + "options": "Sales Taxes and Charges", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "other_charges_calculation", + "fieldtype": "HTML", + "label": "Taxes and Charges Calculation", + "oldfieldtype": "HTML", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "section_break_44", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "other_charges_total_export", + "fieldtype": "Currency", + "label": "Taxes and Charges Total", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break_47", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "other_charges_total", + "fieldtype": "Currency", + "label": "Taxes and Charges Total (Company Currency)", + "oldfieldname": "other_charges_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "discount_amount", + "fieldtype": "Currency", + "label": "Discount Amount", + "options": "Company:company:default_currency", + "permlevel": 0 + }, + { + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "Totals", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "print_hide": 0, + "read_only": 0 + }, + { + "fieldname": "grand_total_export", + "fieldtype": "Currency", + "label": "Grand Total", + "no_copy": 0, + "oldfieldname": "grand_total_export", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "print_width": "150px", + "read_only": 1, + "reqd": 0, + "width": "150px" + }, + { + "fieldname": "rounded_total_export", + "fieldtype": "Currency", + "label": "Rounded Total", + "no_copy": 0, + "oldfieldname": "rounded_total_export", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "description": "In Words (Export) will be visible once you save the Delivery Note.", + "fieldname": "in_words_export", + "fieldtype": "Data", + "label": "In Words", + "no_copy": 0, + "oldfieldname": "in_words_export", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "no_copy": 0, + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "reqd": 0, + "width": "150px" + }, + { + "fieldname": "rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total (Company Currency)", + "no_copy": 0, + "oldfieldname": "rounded_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "description": "In Words will be visible once you save the Delivery Note.", + "fieldname": "in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "no_copy": 0, + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "200px", + "read_only": 1, + "width": "200px" + }, + { + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "oldfieldtype": "Section Break", + "options": "icon-legal", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Terms and Conditions Details", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "transporter_info", + "fieldtype": "Section Break", + "label": "Transporter Info", + "options": "icon-truck", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "transporter_name", + "fieldtype": "Data", + "label": "Transporter Name", + "no_copy": 0, + "oldfieldname": "transporter_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 0, + "reqd": 0, + "width": "150px" + }, + { + "fieldname": "col_break34", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, + { + "description": "Transporter lorry number", + "fieldname": "lr_no", + "fieldtype": "Data", + "label": "Vehicle No", + "no_copy": 0, + "oldfieldname": "lr_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "reqd": 0, + "width": "100px" + }, + { + "default": "Today", + "description": "Date on which lorry started from your warehouse", + "fieldname": "lr_date", + "fieldtype": "Date", + "label": "Vehicle Dispatch Date", + "no_copy": 0, + "oldfieldname": "lr_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "width": "100px" + }, + { + "depends_on": "customer", + "fieldname": "contact_info", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Territory", + "options": "Territory", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "description": "Add / Edit", + "fieldname": "customer_group", + "fieldtype": "Link", + "in_filter": 1, + "label": "Customer Group", + "options": "Customer Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "search_index": 1 + }, + { + "fieldname": "col_break21", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "contact_person", + "fieldtype": "Link", + "in_filter": 1, + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "description": "Track this Delivery Note against any Project", + "fieldname": "project_name", + "fieldtype": "Link", + "in_filter": 1, + "label": "Project Name", + "oldfieldname": "project_name", + "oldfieldtype": "Link", + "options": "Project", + "permlevel": 0, + "read_only": 0, + "search_index": 1 + }, + { + "depends_on": "eval:doc.source == 'Campaign'", + "fieldname": "campaign", + "fieldtype": "Link", + "label": "Campaign", + "oldfieldname": "campaign", + "oldfieldtype": "Link", + "options": "Campaign", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "source", + "fieldtype": "Select", + "label": "Source", + "oldfieldname": "source", + "oldfieldtype": "Select", + "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break5", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, + { + "description": "Time at which items were delivered from warehouse", + "fieldname": "posting_time", + "fieldtype": "Time", + "in_filter": 0, + "label": "Posting Time", + "oldfieldname": "posting_time", + "oldfieldtype": "Time", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 0, + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Select", + "label": "Letter Head", + "oldfieldname": "letter_head", + "oldfieldtype": "Link", + "options": "link:Letter Head", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "print_without_amount", + "fieldtype": "Check", + "label": "Print Without Amount", + "oldfieldname": "print_without_amount", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break_83", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "default": "Draft", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nDraft\nSubmitted\nCancelled", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "depends_on": "eval:!doc.__islocal", + "description": "% of materials delivered against this Delivery Note", + "fieldname": "per_installed", + "fieldtype": "Percent", + "in_filter": 1, + "in_list_view": 1, + "label": "% Installed", + "no_copy": 1, + "oldfieldname": "per_installed", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "installation_status", + "fieldtype": "Select", + "hidden": 1, + "label": "Installation Status", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "column_break_89", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "Required only for sample item.", + "fieldname": "to_warehouse", + "fieldtype": "Link", + "hidden": 0, + "label": "To Warehouse", + "no_copy": 1, + "oldfieldname": "to_warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "excise_page", + "fieldtype": "Data", + "hidden": 1, + "label": "Excise Page Number", + "oldfieldname": "excise_page", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "instructions", + "fieldtype": "Text", + "label": "Instructions", + "oldfieldname": "instructions", + "oldfieldtype": "Text", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "sales_team_section_break", + "fieldtype": "Section Break", + "label": "Sales Team", + "oldfieldtype": "Section Break", + "options": "icon-group", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "sales_partner", + "fieldtype": "Link", + "label": "Sales Partner", + "no_copy": 0, + "oldfieldname": "sales_partner", + "oldfieldtype": "Link", + "options": "Sales Partner", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 0, + "width": "150px" + }, + { + "fieldname": "column_break7", + "fieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "commission_rate", + "fieldtype": "Float", + "label": "Commission Rate (%)", + "no_copy": 0, + "oldfieldname": "commission_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "width": "100px" + }, + { + "fieldname": "total_commission", + "fieldtype": "Currency", + "label": "Total Commission", + "no_copy": 0, + "oldfieldname": "total_commission", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "section_break1", + "fieldtype": "Section Break", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "sales_team", + "fieldtype": "Table", + "label": "Sales Team1", + "oldfieldname": "sales_team", + "oldfieldtype": "Table", + "options": "Sales Team", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + } + ], + "hide_toolbar": 0, + "icon": "icon-truck", + "idx": 1, + "in_create": 0, + "is_submittable": 1, + "modified": "2014-01-28 18:51:42.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Delivery Note", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 1, + "write": 1 + }, + { + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 0, + "write": 0 + }, + { + "cancel": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Customer" + } + ], + "read_only_onload": 1, + "search_fields": "status,customer,customer_name, territory,grand_total" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index a7c49231252..e91c36dd74e 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -5,20 +5,19 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt, cint -from frappe.model.bean import getlist -from frappe.model.code import get_obj + from frappe import msgprint, _ import frappe.defaults -from frappe.model.mapper import get_mapped_doclist +from frappe.model.mapper import get_mapped_doc from erpnext.stock.utils import update_bin from erpnext.controllers.selling_controller import SellingController -class DocType(SellingController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.tname = 'Delivery Note Item' - self.fname = 'delivery_note_details' +class DeliveryNote(SellingController): + tname = 'Delivery Note Item' + fname = 'delivery_note_details' + + def __init__(self, arg1, arg2=None): + super(DeliveryNote, self).__init__(arg1, arg2) self.status_updater = [{ 'source_dt': 'Delivery Note Item', 'target_dt': 'Sales Order Item', @@ -32,38 +31,38 @@ class DocType(SellingController): 'status_field': 'delivery_status', 'keyword': 'Delivered' }] - + def onload(self): billed_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabSales Invoice Item` - where docstatus=1 and delivery_note=%s""", self.doc.name) + where docstatus=1 and delivery_note=%s""", self.name) if billed_qty: - total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "delivery_note_details"}))) - self.doc.fields["__billing_complete"] = billed_qty[0][0] == total_qty - + total_qty = sum((item.qty for item in self.get("delivery_note_details"))) + self.set("__billing_complete", billed_qty[0][0] == total_qty) + def get_portal_page(self): - return "shipment" if self.doc.docstatus==1 else None + return "shipment" if self.docstatus==1 else None def set_actual_qty(self): - for d in getlist(self.doclist, 'delivery_note_details'): + for d in self.get('delivery_note_details'): if d.item_code and d.warehouse: - actual_qty = frappe.db.sql("""select actual_qty from `tabBin` + actual_qty = frappe.db.sql("""select actual_qty from `tabBin` where item_code = %s and warehouse = %s""", (d.item_code, d.warehouse)) d.actual_qty = actual_qty and flt(actual_qty[0][0]) or 0 def so_required(self): """check in manage account if sales order required or not""" if frappe.db.get_value("Selling Settings", None, 'so_required') == 'Yes': - for d in getlist(self.doclist,'delivery_note_details'): + for d in self.get('delivery_note_details'): if not d.against_sales_order: msgprint("Sales Order No. required against item %s"%d.item_code) raise Exception def validate(self): - super(DocType, self).validate() - + super(DeliveryNote, self).validate() + from erpnext.utilities import validate_status - validate_status(self.doc.status, ["Draft", "Submitted", "Cancelled"]) + validate_status(self.status, ["Draft", "Submitted", "Cancelled"]) self.so_required() self.validate_proj_cust() @@ -71,21 +70,21 @@ class DocType(SellingController): self.validate_for_items() self.validate_warehouse() self.validate_uom_is_integer("stock_uom", "qty") - self.update_current_stock() + self.update_current_stock() self.validate_with_previous_doc() - + from erpnext.stock.doctype.packed_item.packed_item import make_packing_list - self.doclist = make_packing_list(self, 'delivery_note_details') - - self.doc.status = 'Draft' - if not self.doc.installation_status: self.doc.installation_status = 'Not Installed' - + make_packing_list(self, 'delivery_note_details') + + self.status = 'Draft' + if not self.installation_status: self.installation_status = 'Not Installed' + def validate_with_previous_doc(self): - items = self.doclist.get({"parentfield": "delivery_note_details"}) - + items = self.get("delivery_note_details") + for fn in (("Sales Order", "against_sales_order"), ("Sales Invoice", "against_sales_invoice")): - if items.get_distinct_values(fn[1]): - super(DocType, self).validate_with_previous_doc(self.tname, { + if filter(None, [getattr(d, fn[1], None) for d in items]): + super(DeliveryNote, self).validate_with_previous_doc(self.tname, { fn[0]: { "ref_dn_field": fn[1], "compare_fields": [["customer", "="], ["company", "="], ["project_name", "="], @@ -94,39 +93,39 @@ class DocType(SellingController): }) if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')): - super(DocType, self).validate_with_previous_doc(self.tname, { + super(DeliveryNote, self).validate_with_previous_doc(self.tname, { fn[0] + " Item": { "ref_dn_field": "prevdoc_detail_docname", "compare_fields": [["rate", "="]], "is_child_table": True } }) - + def validate_proj_cust(self): """check for does customer belong to same project as entered..""" - if self.doc.project_name and self.doc.customer: - res = frappe.db.sql("""select name from `tabProject` - where name = %s and (customer = %s or - ifnull(customer,'')='')""", (self.doc.project_name, self.doc.customer)) + if self.project_name and self.customer: + res = frappe.db.sql("""select name from `tabProject` + where name = %s and (customer = %s or + ifnull(customer,'')='')""", (self.project_name, self.customer)) if not res: - msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in project - %s."%(self.doc.customer,self.doc.project_name,self.doc.project_name)) + msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in project - %s."%(self.customer,self.project_name,self.project_name)) raise Exception def validate_for_items(self): check_list, chk_dupl_itm = [], [] - for d in getlist(self.doclist,'delivery_note_details'): + for d in self.get('delivery_note_details'): e = [d.item_code, d.description, d.warehouse, d.against_sales_order or d.against_sales_invoice, d.batch_no or ''] f = [d.item_code, d.description, d.against_sales_order or d.against_sales_invoice] if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 'Yes': if e in check_list: - msgprint("Please check whether item %s has been entered twice wrongly." + msgprint("Please check whether item %s has been entered twice wrongly." % d.item_code) else: check_list.append(e) else: if f in chk_dupl_itm: - msgprint("Please check whether item %s has been entered twice wrongly." + msgprint("Please check whether item %s has been entered twice wrongly." % d.item_code) else: chk_dupl_itm.append(f) @@ -137,14 +136,14 @@ class DocType(SellingController): if not d['warehouse']: msgprint("Please enter Warehouse for item %s as it is stock item" % d['item_code'], raise_exception=1) - + def update_current_stock(self): - for d in getlist(self.doclist, 'delivery_note_details'): + for d in self.get('delivery_note_details'): bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1) d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0 - for d in getlist(self.doclist, 'packing_details'): + for d in self.get('packing_details'): bin = frappe.db.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1) d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0 d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0 @@ -153,50 +152,48 @@ class DocType(SellingController): self.validate_packed_qty() # Check for Approving Authority - get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total, self) - - # update delivered qty in sales order + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total, self) + + # update delivered qty in sales order self.update_prevdoc_status() - + # create stock ledger entry self.update_stock_ledger() self.credit_limit() - + self.make_gl_entries() # set DN status - frappe.db.set(self.doc, 'status', 'Submitted') + frappe.db.set(self, 'status', 'Submitted') def on_cancel(self): self.check_stop_sales_order("against_sales_order") self.check_next_docstatus() - + self.update_prevdoc_status() - + self.update_stock_ledger() - frappe.db.set(self.doc, 'status', 'Cancelled') + frappe.db.set(self, 'status', 'Cancelled') self.cancel_packing_slips() - + self.make_cancel_gl_entries() def validate_packed_qty(self): """ Validate that if packed qty exists, it should be equal to qty """ - if not any([flt(d.fields.get('packed_qty')) for d in self.doclist if - d.doctype=='Delivery Note Item']): + if not any([flt(d.get('packed_qty')) for d in self.get(self.fname)]): return packing_error_list = [] - for d in self.doclist: - if d.doctype != 'Delivery Note Item': continue - if flt(d.fields.get('qty')) != flt(d.fields.get('packed_qty')): + for d in self.get(self.fname): + if flt(d.get('qty')) != flt(d.get('packed_qty')): packing_error_list.append([ - d.fields.get('item_code', ''), - d.fields.get('qty', 0), - d.fields.get('packed_qty', 0) + d.get('item_code', ''), + d.get('qty', 0), + d.get('packed_qty', 0) ]) if packing_error_list: err_msg = "\n".join([("Item: " + d[0] + ", Qty: " + cstr(d[1]) \ @@ -204,18 +201,18 @@ class DocType(SellingController): frappe.msgprint("Packing Error:\n" + err_msg, raise_exception=1) def check_next_docstatus(self): - submit_rv = frappe.db.sql("""select t1.name - from `tabSales Invoice` t1,`tabSales Invoice Item` t2 - where t1.name = t2.parent and t2.delivery_note = %s and t1.docstatus = 1""", - (self.doc.name)) + submit_rv = frappe.db.sql("""select t1.name + from `tabSales Invoice` t1,`tabSales Invoice Item` t2 + where t1.name = t2.parent and t2.delivery_note = %s and t1.docstatus = 1""", + (self.name)) if submit_rv: msgprint("Sales Invoice : " + cstr(submit_rv[0][0]) + " has already been submitted !") raise Exception , "Validation Error." - submit_in = frappe.db.sql("""select t1.name - from `tabInstallation Note` t1, `tabInstallation Note Item` t2 - where t1.name = t2.parent and t2.prevdoc_docname = %s and t1.docstatus = 1""", - (self.doc.name)) + submit_in = frappe.db.sql("""select t1.name + from `tabInstallation Note` t1, `tabInstallation Note Item` t2 + where t1.name = t2.parent and t2.prevdoc_docname = %s and t1.docstatus = 1""", + (self.name)) if submit_in: msgprint("Installation Note : "+cstr(submit_in[0][0]) +" has already been submitted !") raise Exception , "Validation Error." @@ -224,13 +221,12 @@ class DocType(SellingController): """ Cancel submitted packing slips related to this delivery note """ - res = frappe.db.sql("""SELECT name FROM `tabPacking Slip` WHERE delivery_note = %s - AND docstatus = 1""", self.doc.name) + res = frappe.db.sql("""SELECT name FROM `tabPacking Slip` WHERE delivery_note = %s + AND docstatus = 1""", self.name) if res: - from frappe.model.bean import Bean for r in res: - ps = Bean(dt='Packing Slip', dn=r[0]) + ps = frappe.get_doc('Packing Slip', r[0]) ps.cancel() frappe.msgprint(_("Packing Slip(s) Cancelled")) @@ -241,129 +237,125 @@ class DocType(SellingController): if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes" \ and d.warehouse: self.update_reserved_qty(d) - + sl_entries.append(self.get_sl_entries(d, { "actual_qty": -1*flt(d['qty']), })) - + self.make_sl_entries(sl_entries) - + def update_reserved_qty(self, d): if d['reserved_qty'] < 0 : # Reduce reserved qty from reserved warehouse mentioned in so if not d["reserved_warehouse"]: frappe.throw(_("Reserved Warehouse is missing in Sales Order")) - + args = { "item_code": d['item_code'], "warehouse": d["reserved_warehouse"], - "voucher_type": self.doc.doctype, - "voucher_no": self.doc.name, - "reserved_qty": (self.doc.docstatus==1 and 1 or -1)*flt(d['reserved_qty']), - "posting_date": self.doc.posting_date, - "is_amended": self.doc.amended_from and 'Yes' or 'No' + "voucher_type": self.doctype, + "voucher_no": self.name, + "reserved_qty": (self.docstatus==1 and 1 or -1)*flt(d['reserved_qty']), + "posting_date": self.posting_date, + "is_amended": self.amended_from and 'Yes' or 'No' } update_bin(args) def credit_limit(self): """check credit limit of items in DN Detail which are not fetched from sales order""" amount, total = 0, 0 - for d in getlist(self.doclist, 'delivery_note_details'): + for d in self.get('delivery_note_details'): if not (d.against_sales_order or d.against_sales_invoice): amount += d.base_amount if amount != 0: - total = (amount/self.doc.net_total)*self.doc.grand_total + total = (amount/self.net_total)*self.grand_total self.check_credit(total) def get_invoiced_qty_map(delivery_note): """returns a map: {dn_detail: invoiced_qty}""" invoiced_qty_map = {} - + for dn_detail, qty in frappe.db.sql("""select dn_detail, qty from `tabSales Invoice Item` where delivery_note=%s and docstatus=1""", delivery_note): if not invoiced_qty_map.get(dn_detail): invoiced_qty_map[dn_detail] = 0 invoiced_qty_map[dn_detail] += qty - + return invoiced_qty_map @frappe.whitelist() -def make_sales_invoice(source_name, target_doclist=None): +def make_sales_invoice(source_name, target_doc=None): invoiced_qty_map = get_invoiced_qty_map(source_name) - + def update_accounts(source, target): - si = frappe.bean(target) - si.doc.is_pos = 0 + si = frappe.get_doc(target) + si.is_pos = 0 si.run_method("onload_post_render") - - si.set_doclist(si.doclist.get({"parentfield": ["!=", "entries"]}) + - si.doclist.get({"parentfield": "entries", "qty": [">", 0]})) - - if len(si.doclist.get({"parentfield": "entries"})) == 0: - frappe.msgprint(_("Hey! All these items have already been invoiced."), + + if len(si.get("entries")) == 0: + frappe.msgprint(_("All these items have already been invoiced."), raise_exception=True) - - return si.doclist - + def update_item(source_doc, target_doc, source_parent): target_doc.qty = source_doc.qty - invoiced_qty_map.get(source_doc.name, 0) - - doclist = get_mapped_doclist("Delivery Note", source_name, { + + doc = get_mapped_doc("Delivery Note", source_name, { "Delivery Note": { - "doctype": "Sales Invoice", + "doctype": "Sales Invoice", "validation": { "docstatus": ["=", 1] } - }, + }, "Delivery Note Item": { - "doctype": "Sales Invoice Item", + "doctype": "Sales Invoice Item", "field_map": { - "name": "dn_detail", - "parent": "delivery_note", - "prevdoc_detail_docname": "so_detail", - "against_sales_order": "sales_order", + "name": "dn_detail", + "parent": "delivery_note", + "prevdoc_detail_docname": "so_detail", + "against_sales_order": "sales_order", "serial_no": "serial_no" }, - "postprocess": update_item - }, + "postprocess": update_item, + "filter": lambda d: d.qty - invoiced_qty_map.get(d.name, 0)<=0 + }, "Sales Taxes and Charges": { - "doctype": "Sales Taxes and Charges", + "doctype": "Sales Taxes and Charges", "add_if_empty": True - }, + }, "Sales Team": { - "doctype": "Sales Team", + "doctype": "Sales Team", "field_map": { "incentives": "incentives" }, "add_if_empty": True } - }, target_doclist, update_accounts) - - return [d.fields for d in doclist] - + }, target_doc, update_accounts) + + return doc + @frappe.whitelist() -def make_installation_note(source_name, target_doclist=None): +def make_installation_note(source_name, target_doc=None): def update_item(obj, target, source_parent): target.qty = flt(obj.qty) - flt(obj.installed_qty) target.serial_no = obj.serial_no - - doclist = get_mapped_doclist("Delivery Note", source_name, { + + doclist = get_mapped_doc("Delivery Note", source_name, { "Delivery Note": { - "doctype": "Installation Note", + "doctype": "Installation Note", "validation": { "docstatus": ["=", 1] } - }, + }, "Delivery Note Item": { - "doctype": "Installation Note Item", + "doctype": "Installation Note Item", "field_map": { - "name": "prevdoc_detail_docname", - "parent": "prevdoc_docname", - "parenttype": "prevdoc_doctype", + "name": "prevdoc_detail_docname", + "parent": "prevdoc_docname", + "parenttype": "prevdoc_doctype", }, "postprocess": update_item, "condition": lambda doc: doc.installed_qty < doc.qty } - }, target_doclist) + }, target_doc) - return [d.fields for d in doclist] \ No newline at end of file + return doclist diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.txt b/erpnext/stock/doctype/delivery_note/delivery_note.txt deleted file mode 100644 index a20723de337..00000000000 --- a/erpnext/stock/doctype/delivery_note/delivery_note.txt +++ /dev/null @@ -1,1079 +0,0 @@ -[ - { - "creation": "2013-05-24 19:29:09", - "docstatus": 0, - "modified": "2014-01-28 18:51:42", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "document_type": "Transaction", - "hide_toolbar": 0, - "icon": "icon-truck", - "in_create": 0, - "is_submittable": 1, - "module": "Stock", - "name": "__common__", - "read_only_onload": 1, - "search_fields": "status,customer,customer_name, territory,grand_total" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Delivery Note", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Delivery Note", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Delivery Note" - }, - { - "doctype": "DocField", - "fieldname": "delivery_to_section", - "fieldtype": "Section Break", - "label": "Delivery To", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "DN", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "in_filter": 1, - "label": "Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "hidden": 0, - "in_list_view": 1, - "label": "Customer Name", - "read_only": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "customer_address", - "fieldtype": "Link", - "in_filter": 1, - "label": "Billing Address Name", - "options": "Address", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Billing Address", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "shipping_address_name", - "fieldtype": "Link", - "label": "Shipping Address", - "options": "Address", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "shipping_address", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Shipping Address", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Text", - "hidden": 1, - "label": "Mobile No", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Text", - "hidden": 1, - "label": "Contact Email", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "description": "Select the relevant company name if you have multiple companies", - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "print_width": "150px", - "read_only": 0, - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Posting Date", - "no_copy": 1, - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "print_hide": 0, - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "search_index": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "po_no", - "fieldtype": "Data", - "hidden": 1, - "label": "Customer's Purchase Order No", - "no_copy": 0, - "oldfieldname": "po_no", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "width": "100px" - }, - { - "depends_on": "eval:doc.po_no", - "doctype": "DocField", - "fieldname": "po_date", - "fieldtype": "Date", - "hidden": 0, - "label": "Customer's Purchase Order Date", - "no_copy": 0, - "oldfieldname": "po_date", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "sec_break25", - "fieldtype": "Section Break", - "label": "Currency and Price List", - "options": "icon-tag", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "currency", - "fieldtype": "Link", - "label": "Currency", - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "description": "Rate at which customer's currency is converted to company's base currency", - "doctype": "DocField", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "label": "Exchange Rate", - "no_copy": 0, - "oldfieldname": "conversion_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break23", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "selling_price_list", - "fieldtype": "Link", - "label": "Price List", - "oldfieldname": "price_list_name", - "oldfieldtype": "Select", - "options": "Price List", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "price_list_currency", - "fieldtype": "Link", - "label": "Price List Currency", - "options": "Currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "description": "Rate at which Price list currency is converted to company's base currency", - "doctype": "DocField", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "label": "Price List Exchange Rate", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "items", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart", - "read_only": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "delivery_note_details", - "fieldtype": "Table", - "label": "Delivery Note Items", - "no_copy": 0, - "oldfieldname": "delivery_note_details", - "oldfieldtype": "Table", - "options": "Delivery Note Item", - "print_hide": 0, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "packing_list", - "fieldtype": "Section Break", - "label": "Packing List", - "oldfieldtype": "Section Break", - "options": "icon-suitcase", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "packing_details", - "fieldtype": "Table", - "label": "Packing Details", - "oldfieldname": "packing_details", - "oldfieldtype": "Table", - "options": "Packed Item", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "sales_bom_help", - "fieldtype": "HTML", - "label": "Sales BOM Help", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_31", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total_export", - "fieldtype": "Currency", - "label": "Net Total", - "options": "currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_33", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total (Company Currency)", - "no_copy": 0, - "oldfieldname": "net_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "reqd": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "taxes", - "fieldtype": "Section Break", - "label": "Taxes and Charges", - "oldfieldtype": "Section Break", - "options": "icon-money", - "read_only": 0 - }, - { - "description": "If you have created a standard template in Sales Taxes and Charges Master, select one and click on the button below.", - "doctype": "DocField", - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "oldfieldname": "charge", - "oldfieldtype": "Link", - "options": "Sales Taxes and Charges Master", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_39", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "shipping_rule", - "fieldtype": "Link", - "label": "Shipping Rule", - "oldfieldtype": "Button", - "options": "Shipping Rule", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_41", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "other_charges", - "fieldtype": "Table", - "label": "Sales Taxes and Charges", - "no_copy": 0, - "oldfieldname": "other_charges", - "oldfieldtype": "Table", - "options": "Sales Taxes and Charges", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_calculation", - "fieldtype": "HTML", - "label": "Taxes and Charges Calculation", - "oldfieldtype": "HTML", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_44", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_total_export", - "fieldtype": "Currency", - "label": "Taxes and Charges Total", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_47", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_total", - "fieldtype": "Currency", - "label": "Taxes and Charges Total (Company Currency)", - "oldfieldname": "other_charges_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "discount_amount", - "fieldtype": "Currency", - "label": "Discount Amount", - "options": "Company:company:default_currency" - }, - { - "doctype": "DocField", - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "Totals", - "oldfieldtype": "Section Break", - "options": "icon-money", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "grand_total_export", - "fieldtype": "Currency", - "label": "Grand Total", - "no_copy": 0, - "oldfieldname": "grand_total_export", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "print_width": "150px", - "read_only": 1, - "reqd": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "rounded_total_export", - "fieldtype": "Currency", - "label": "Rounded Total", - "no_copy": 0, - "oldfieldname": "rounded_total_export", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "description": "In Words (Export) will be visible once you save the Delivery Note.", - "doctype": "DocField", - "fieldname": "in_words_export", - "fieldtype": "Data", - "label": "In Words", - "no_copy": 0, - "oldfieldname": "in_words_export", - "oldfieldtype": "Data", - "print_hide": 0, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "no_copy": 0, - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "reqd": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total (Company Currency)", - "no_copy": 0, - "oldfieldname": "rounded_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "description": "In Words will be visible once you save the Delivery Note.", - "doctype": "DocField", - "fieldname": "in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "no_copy": 0, - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "200px", - "read_only": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "oldfieldtype": "Section Break", - "options": "icon-legal", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Terms and Conditions Details", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "transporter_info", - "fieldtype": "Section Break", - "label": "Transporter Info", - "options": "icon-truck", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "transporter_name", - "fieldtype": "Data", - "label": "Transporter Name", - "no_copy": 0, - "oldfieldname": "transporter_name", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 0, - "reqd": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "col_break34", - "fieldtype": "Column Break", - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, - { - "description": "Transporter lorry number", - "doctype": "DocField", - "fieldname": "lr_no", - "fieldtype": "Data", - "label": "Vehicle No", - "no_copy": 0, - "oldfieldname": "lr_no", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "reqd": 0, - "width": "100px" - }, - { - "default": "Today", - "description": "Date on which lorry started from your warehouse", - "doctype": "DocField", - "fieldname": "lr_date", - "fieldtype": "Date", - "label": "Vehicle Dispatch Date", - "no_copy": 0, - "oldfieldname": "lr_date", - "oldfieldtype": "Date", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "width": "100px" - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_info", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn", - "read_only": 0 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Territory", - "options": "Territory", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "in_filter": 1, - "label": "Customer Group", - "options": "Customer Group", - "print_hide": 1, - "read_only": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break21", - "fieldtype": "Column Break", - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "in_filter": 1, - "label": "Contact Person", - "options": "Contact", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text", - "print_hide": 1, - "read_only": 0 - }, - { - "description": "Track this Delivery Note against any Project", - "doctype": "DocField", - "fieldname": "project_name", - "fieldtype": "Link", - "in_filter": 1, - "label": "Project Name", - "oldfieldname": "project_name", - "oldfieldtype": "Link", - "options": "Project", - "read_only": 0, - "search_index": 1 - }, - { - "depends_on": "eval:doc.source == 'Campaign'", - "doctype": "DocField", - "fieldname": "campaign", - "fieldtype": "Link", - "label": "Campaign", - "oldfieldname": "campaign", - "oldfieldtype": "Link", - "options": "Campaign", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "source", - "fieldtype": "Select", - "label": "Source", - "oldfieldname": "source", - "oldfieldtype": "Select", - "options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break5", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, - { - "description": "Time at which items were delivered from warehouse", - "doctype": "DocField", - "fieldname": "posting_time", - "fieldtype": "Time", - "in_filter": 0, - "label": "Posting Time", - "oldfieldname": "posting_time", - "oldfieldtype": "Time", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "print_width": "150px", - "read_only": 0, - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Select", - "label": "Letter Head", - "oldfieldname": "letter_head", - "oldfieldtype": "Link", - "options": "link:Letter Head", - "print_hide": 1, - "read_only": 0 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "print_without_amount", - "fieldtype": "Check", - "label": "Print Without Amount", - "oldfieldname": "print_without_amount", - "oldfieldtype": "Check", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_83", - "fieldtype": "Section Break" - }, - { - "default": "Draft", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nDraft\nSubmitted\nCancelled", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "depends_on": "eval:!doc.__islocal", - "description": "% of materials delivered against this Delivery Note", - "doctype": "DocField", - "fieldname": "per_installed", - "fieldtype": "Percent", - "in_filter": 1, - "in_list_view": 1, - "label": "% Installed", - "no_copy": 1, - "oldfieldname": "per_installed", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "installation_status", - "fieldtype": "Select", - "hidden": 1, - "label": "Installation Status", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_89", - "fieldtype": "Column Break" - }, - { - "description": "Required only for sample item.", - "doctype": "DocField", - "fieldname": "to_warehouse", - "fieldtype": "Link", - "hidden": 0, - "label": "To Warehouse", - "no_copy": 1, - "oldfieldname": "to_warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "excise_page", - "fieldtype": "Data", - "hidden": 1, - "label": "Excise Page Number", - "oldfieldname": "excise_page", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "instructions", - "fieldtype": "Text", - "label": "Instructions", - "oldfieldname": "instructions", - "oldfieldtype": "Text", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "sales_team_section_break", - "fieldtype": "Section Break", - "label": "Sales Team", - "oldfieldtype": "Section Break", - "options": "icon-group", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "sales_partner", - "fieldtype": "Link", - "label": "Sales Partner", - "no_copy": 0, - "oldfieldname": "sales_partner", - "oldfieldtype": "Link", - "options": "Sales Partner", - "print_hide": 1, - "print_width": "150px", - "read_only": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "column_break7", - "fieldtype": "Column Break", - "print_hide": 1, - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "commission_rate", - "fieldtype": "Float", - "label": "Commission Rate (%)", - "no_copy": 0, - "oldfieldname": "commission_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "total_commission", - "fieldtype": "Currency", - "label": "Total Commission", - "no_copy": 0, - "oldfieldname": "total_commission", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break1", - "fieldtype": "Section Break", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "sales_team", - "fieldtype": "Table", - "label": "Sales Team1", - "oldfieldname": "sales_team", - "oldfieldtype": "Table", - "options": "Sales Team", - "print_hide": 1, - "read_only": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Material User", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Material Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales User", - "submit": 1, - "write": 1 - }, - { - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Accounts User", - "submit": 0, - "write": 0 - }, - { - "cancel": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Customer" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py index 1ad65070a80..6e82ae92cc0 100644 --- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py @@ -11,77 +11,77 @@ from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import get_gl_ def _insert_purchase_receipt(item_code=None): if not item_code: - item_code = pr_test_records[0][1]["item_code"] - - pr = frappe.bean(copy=pr_test_records[0]) - pr.doclist[1].item_code = item_code + item_code = pr_test_records[0]["purchase_receipt_details"][0]["item_code"] + + pr = frappe.copy_doc(pr_test_records[0]) + pr.get("purchase_receipt_details")[0].item_code = item_code pr.insert() pr.submit() - + class TestDeliveryNote(unittest.TestCase): def test_over_billing_against_dn(self): self.clear_stock_account_balance() _insert_purchase_receipt() - + from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice _insert_purchase_receipt() - dn = frappe.bean(copy=test_records[0]).insert() - - self.assertRaises(frappe.ValidationError, make_sales_invoice, - dn.doc.name) + dn = frappe.copy_doc(test_records[0]).insert() - dn = frappe.bean("Delivery Note", dn.doc.name) + self.assertRaises(frappe.ValidationError, make_sales_invoice, + dn.name) + + dn = frappe.get_doc("Delivery Note", dn.name) dn.submit() - si = make_sales_invoice(dn.doc.name) - - self.assertEquals(len(si), len(dn.doclist)) - + si = make_sales_invoice(dn.name) + + self.assertEquals(len(si.get("entries")), len(dn.get("delivery_note_details"))) + # modify amount - si[1]["rate"] = 200 - self.assertRaises(frappe.ValidationError, frappe.bean(si).insert) - - + si.get("entries")[0].rate = 200 + self.assertRaises(frappe.ValidationError, frappe.get_doc(si).insert) + + def test_delivery_note_no_gl_entry(self): self.clear_stock_account_balance() set_perpetual_inventory(0) self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 0) - + _insert_purchase_receipt() - - dn = frappe.bean(copy=test_records[0]) + + dn = frappe.copy_doc(test_records[0]) dn.insert() dn.submit() - - stock_value, stock_value_difference = frappe.db.get_value("Stock Ledger Entry", - {"voucher_type": "Delivery Note", "voucher_no": dn.doc.name, + + stock_value, stock_value_difference = frappe.db.get_value("Stock Ledger Entry", + {"voucher_type": "Delivery Note", "voucher_no": dn.name, "item_code": "_Test Item"}, ["stock_value", "stock_value_difference"]) self.assertEqual(stock_value, 0) self.assertEqual(stock_value_difference, -375) - - self.assertFalse(get_gl_entries("Delivery Note", dn.doc.name)) - + + self.assertFalse(get_gl_entries("Delivery Note", dn.name)) + def test_delivery_note_gl_entry(self): self.clear_stock_account_balance() set_perpetual_inventory() self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1) frappe.db.set_value("Item", "_Test Item", "valuation_method", "FIFO") - - _insert_purchase_receipt() - - dn = frappe.bean(copy=test_records[0]) - dn.doclist[1].expense_account = "Cost of Goods Sold - _TC" - dn.doclist[1].cost_center = "Main - _TC" - stock_in_hand_account = frappe.db.get_value("Account", - {"master_name": dn.doclist[1].warehouse}) - + _insert_purchase_receipt() + + dn = frappe.copy_doc(test_records[0]) + dn.get("delivery_note_details")[0].expense_account = "Cost of Goods Sold - _TC" + dn.get("delivery_note_details")[0].cost_center = "Main - _TC" + + stock_in_hand_account = frappe.db.get_value("Account", + {"master_name": dn.get("delivery_note_details")[0].warehouse}) + from erpnext.accounts.utils import get_balance_on - prev_bal = get_balance_on(stock_in_hand_account, dn.doc.posting_date) + prev_bal = get_balance_on(stock_in_hand_account, dn.posting_date) dn.insert() dn.submit() - - gl_entries = get_gl_entries("Delivery Note", dn.doc.name) + + gl_entries = get_gl_entries("Delivery Note", dn.name) self.assertTrue(gl_entries) expected_values = { stock_in_hand_account: [0.0, 375.0], @@ -89,21 +89,21 @@ class TestDeliveryNote(unittest.TestCase): } for i, gle in enumerate(gl_entries): self.assertEquals([gle.debit, gle.credit], expected_values.get(gle.account)) - + # check stock in hand balance - bal = get_balance_on(stock_in_hand_account, dn.doc.posting_date) + bal = get_balance_on(stock_in_hand_account, dn.posting_date) self.assertEquals(bal, prev_bal - 375.0) - + # back dated purchase receipt - pr = frappe.bean(copy=pr_test_records[0]) - pr.doc.posting_date = "2013-01-01" - pr.doclist[1].rate = 100 - pr.doclist[1].base_amount = 100 - + pr = frappe.copy_doc(pr_test_records[0]) + pr.posting_date = "2013-01-01" + pr.get("purchase_receipt_details")[0].rate = 100 + pr.get("purchase_receipt_details")[0].base_amount = 100 + pr.insert() pr.submit() - - gl_entries = get_gl_entries("Delivery Note", dn.doc.name) + + gl_entries = get_gl_entries("Delivery Note", dn.name) self.assertTrue(gl_entries) expected_values = { stock_in_hand_account: [0.0, 666.67], @@ -111,102 +111,102 @@ class TestDeliveryNote(unittest.TestCase): } for i, gle in enumerate(gl_entries): self.assertEquals([gle.debit, gle.credit], expected_values.get(gle.account)) - + dn.cancel() - self.assertFalse(get_gl_entries("Delivery Note", dn.doc.name)) + self.assertFalse(get_gl_entries("Delivery Note", dn.name)) set_perpetual_inventory(0) - + def test_delivery_note_gl_entry_packing_item(self): self.clear_stock_account_balance() set_perpetual_inventory() - + _insert_purchase_receipt() _insert_purchase_receipt("_Test Item Home Desktop 100") - - dn = frappe.bean(copy=test_records[0]) - dn.doclist[1].item_code = "_Test Sales BOM Item" - dn.doclist[1].qty = 1 - - stock_in_hand_account = frappe.db.get_value("Account", - {"master_name": dn.doclist[1].warehouse}) - + + dn = frappe.copy_doc(test_records[0]) + dn.get("delivery_note_details")[0].item_code = "_Test Sales BOM Item" + dn.get("delivery_note_details")[0].qty = 1 + + stock_in_hand_account = frappe.db.get_value("Account", + {"master_name": dn.get("delivery_note_details")[0].warehouse}) + from erpnext.accounts.utils import get_balance_on - prev_bal = get_balance_on(stock_in_hand_account, dn.doc.posting_date) - + prev_bal = get_balance_on(stock_in_hand_account, dn.posting_date) + dn.insert() dn.submit() - - gl_entries = get_gl_entries("Delivery Note", dn.doc.name) + + gl_entries = get_gl_entries("Delivery Note", dn.name) self.assertTrue(gl_entries) - + expected_values = { stock_in_hand_account: [0.0, 525], "Cost of Goods Sold - _TC": [525.0, 0.0] } for i, gle in enumerate(gl_entries): self.assertEquals([gle.debit, gle.credit], expected_values.get(gle.account)) - + # check stock in hand balance - bal = get_balance_on(stock_in_hand_account, dn.doc.posting_date) + bal = get_balance_on(stock_in_hand_account, dn.posting_date) self.assertEquals(bal, prev_bal - 525.0) - + dn.cancel() - self.assertFalse(get_gl_entries("Delivery Note", dn.doc.name)) - + self.assertFalse(get_gl_entries("Delivery Note", dn.name)) + set_perpetual_inventory(0) - + def test_serialized(self): from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos - + se = make_serialized_item() - serial_nos = get_serial_nos(se.doclist[1].serial_no) - - dn = frappe.bean(copy=test_records[0]) - dn.doclist[1].item_code = "_Test Serialized Item With Series" - dn.doclist[1].qty = 1 - dn.doclist[1].serial_no = serial_nos[0] + serial_nos = get_serial_nos(se.get("mtn_details")[0].serial_no) + + dn = frappe.copy_doc(test_records[0]) + dn.get("delivery_note_details")[0].item_code = "_Test Serialized Item With Series" + dn.get("delivery_note_details")[0].qty = 1 + dn.get("delivery_note_details")[0].serial_no = serial_nos[0] dn.insert() dn.submit() - + self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], "status"), "Delivered") self.assertFalse(frappe.db.get_value("Serial No", serial_nos[0], "warehouse")) - self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], - "delivery_document_no"), dn.doc.name) - + self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], + "delivery_document_no"), dn.name) + return dn - + def test_serialized_cancel(self): from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos dn = self.test_serialized() dn.cancel() - serial_nos = get_serial_nos(dn.doclist[1].serial_no) + serial_nos = get_serial_nos(dn.get("delivery_note_details")[0].serial_no) self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], "status"), "Available") self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], "warehouse"), "_Test Warehouse - _TC") - self.assertFalse(frappe.db.get_value("Serial No", serial_nos[0], + self.assertFalse(frappe.db.get_value("Serial No", serial_nos[0], "delivery_document_no")) def test_serialize_status(self): from erpnext.stock.doctype.serial_no.serial_no import SerialNoStatusError, get_serial_nos from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item - + se = make_serialized_item() - serial_nos = get_serial_nos(se.doclist[1].serial_no) - - sr = frappe.bean("Serial No", serial_nos[0]) - sr.doc.status = "Not Available" + serial_nos = get_serial_nos(se.get("mtn_details")[0].serial_no) + + sr = frappe.get_doc("Serial No", serial_nos[0]) + sr.status = "Not Available" sr.save() - - dn = frappe.bean(copy=test_records[0]) - dn.doclist[1].item_code = "_Test Serialized Item With Series" - dn.doclist[1].qty = 1 - dn.doclist[1].serial_no = serial_nos[0] + + dn = frappe.copy_doc(test_records[0]) + dn.get("delivery_note_details")[0].item_code = "_Test Serialized Item With Series" + dn.get("delivery_note_details")[0].qty = 1 + dn.get("delivery_note_details")[0].serial_no = serial_nos[0] dn.insert() self.assertRaises(SerialNoStatusError, dn.submit) - + def clear_stock_account_balance(self): frappe.db.sql("""delete from `tabBin`""") frappe.db.sql("delete from `tabStock Ledger Entry`") @@ -214,43 +214,4 @@ class TestDeliveryNote(unittest.TestCase): test_dependencies = ["Sales BOM"] -test_records = [ - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "doctype": "Delivery Note", - "fiscal_year": "_Test Fiscal Year 2013", - "plc_conversion_rate": 1.0, - "posting_date": "2013-02-21", - "posting_time": "9:00:00", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", - "status": "Draft", - "territory": "_Test Territory", - "net_total": 500.0, - "grand_total": 500.0, - "grand_total_export": 500.0, - "naming_series": "_T-Delivery Note-" - }, - { - "description": "CPU", - "doctype": "Delivery Note Item", - "item_code": "_Test Item", - "item_name": "_Test Item", - "parentfield": "delivery_note_details", - "qty": 5.0, - "base_rate": 100.0, - "rate": 100.0, - "base_amount": 500.0, - "warehouse": "_Test Warehouse - _TC", - "stock_uom": "_Test UOM", - "expense_account": "Cost of Goods Sold - _TC", - "cost_center": "Main - _TC" - } - ] - -] +test_records = frappe.get_test_records('Delivery Note') diff --git a/erpnext/stock/doctype/delivery_note/test_records.json b/erpnext/stock/doctype/delivery_note/test_records.json new file mode 100644 index 00000000000..3127a080086 --- /dev/null +++ b/erpnext/stock/doctype/delivery_note/test_records.json @@ -0,0 +1,39 @@ +[ + { + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "delivery_note_details": [ + { + "base_amount": 500.0, + "base_rate": 100.0, + "cost_center": "Main - _TC", + "description": "CPU", + "doctype": "Delivery Note Item", + "expense_account": "Cost of Goods Sold - _TC", + "item_code": "_Test Item", + "item_name": "_Test Item", + "parentfield": "delivery_note_details", + "qty": 5.0, + "rate": 100.0, + "stock_uom": "_Test UOM", + "warehouse": "_Test Warehouse - _TC" + } + ], + "doctype": "Delivery Note", + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 500.0, + "grand_total_export": 500.0, + "naming_series": "_T-Delivery Note-", + "net_total": 500.0, + "plc_conversion_rate": 1.0, + "posting_date": "2013-02-21", + "posting_time": "9:00:00", + "price_list_currency": "INR", + "selling_price_list": "_Test Price List", + "status": "Draft", + "territory": "_Test Territory" + } +] \ No newline at end of file diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json new file mode 100644 index 00000000000..e093def8869 --- /dev/null +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json @@ -0,0 +1,445 @@ +{ + "autoname": "DND/.#######", + "creation": "2013-04-22 13:15:44.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "barcode", + "fieldtype": "Data", + "in_list_view": 0, + "label": "Barcode", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_width": "150px", + "read_only": 0, + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_list_view": 0, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 0, + "reqd": 1, + "width": "150px" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "customer_item_code", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Customer's Item Code", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 0, + "reqd": 1, + "width": "300px" + }, + { + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Quantity and Rate", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Quantity", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate", + "no_copy": 0, + "oldfieldname": "ref_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "discount_percentage", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Discount (%)", + "oldfieldname": "adj_rate", + "oldfieldtype": "Float", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "width": "100px" + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "print_hide": 0, + "print_width": "50px", + "read_only": 1, + "reqd": 1, + "width": "50px" + }, + { + "fieldname": "base_price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate (Company Currency)", + "oldfieldname": "base_ref_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "width": "100px" + }, + { + "fieldname": "section_break_1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "rate", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "export_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "print_width": "150px", + "read_only": 0, + "reqd": 0, + "width": "150px" + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "export_amount", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "base_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Rate (Company Currency)", + "oldfieldname": "basic_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "reqd": 0, + "width": "150px" + }, + { + "fieldname": "base_amount", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Amount (Company Currency)", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "pricing_rule_for_price", + "fieldtype": "Link", + "label": "Pricing Rule For Price", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "pricing_rule_for_discount", + "fieldtype": "Link", + "label": "Pricing Rule For Discount", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "warehouse_and_reference", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Warehouse and Reference", + "permlevel": 0 + }, + { + "fieldname": "warehouse", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Warehouse", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "width": "100px" + }, + { + "fieldname": "serial_no", + "fieldtype": "Text", + "in_filter": 1, + "in_list_view": 1, + "label": "Serial No", + "no_copy": 1, + "oldfieldname": "serial_no", + "oldfieldtype": "Text", + "permlevel": 0, + "print_hide": 0, + "read_only": 0 + }, + { + "fieldname": "batch_no", + "fieldtype": "Link", + "hidden": 0, + "label": "Batch No", + "oldfieldname": "batch_no", + "oldfieldtype": "Link", + "options": "Batch", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "hidden": 1, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "brand", + "fieldtype": "Link", + "hidden": 1, + "label": "Brand Name", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "item_tax_rate", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Item Tax Rate", + "oldfieldname": "item_tax_rate", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "actual_qty", + "fieldtype": "Float", + "label": "Available Qty at Warehouse", + "no_copy": 1, + "oldfieldname": "actual_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "expense_account", + "fieldtype": "Link", + "hidden": 0, + "label": "Expense Account", + "no_copy": 1, + "options": "Account", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "120px" + }, + { + "default": ":Company", + "fieldname": "cost_center", + "fieldtype": "Link", + "hidden": 0, + "label": "Cost Center", + "no_copy": 1, + "options": "Cost Center", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "width": "120px" + }, + { + "fieldname": "against_sales_order", + "fieldtype": "Link", + "label": "Against Sales Order", + "options": "Sales Order", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "against_sales_invoice", + "fieldtype": "Link", + "label": "Against Sales Invoice", + "options": "Sales Invoice", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "prevdoc_detail_docname", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "label": "Against Document Detail No", + "no_copy": 1, + "oldfieldname": "prevdoc_detail_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "search_index": 0, + "width": "150px" + }, + { + "fieldname": "installed_qty", + "fieldtype": "Float", + "label": "Installed Qty", + "no_copy": 1, + "oldfieldname": "installed_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "buying_amount", + "fieldtype": "Currency", + "hidden": 1, + "label": "Buying Amount", + "no_copy": 1, + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "label": "Page Break", + "oldfieldname": "page_break", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-28 11:20:58.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Delivery Note Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py index 26c87f1c04a..3789cdaffa6 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class DeliveryNoteItem(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.txt b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.txt deleted file mode 100644 index f5f77125f1b..00000000000 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.txt +++ /dev/null @@ -1,458 +0,0 @@ -[ - { - "creation": "2013-04-22 13:15:44", - "docstatus": 0, - "modified": "2014-02-28 11:20:58", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "DND/.#######", - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Delivery Note Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Delivery Note Item" - }, - { - "doctype": "DocField", - "fieldname": "barcode", - "fieldtype": "Data", - "in_list_view": 0, - "label": "Barcode", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "print_width": "150px", - "read_only": 0, - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_list_view": 0, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 0, - "reqd": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "customer_item_code", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Customer's Item Code", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "print_width": "300px", - "read_only": 0, - "reqd": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Quantity and Rate" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Quantity", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate", - "no_copy": 0, - "oldfieldname": "ref_rate", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "discount_percentage", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Discount (%)", - "oldfieldname": "adj_rate", - "oldfieldtype": "Float", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "print_hide": 0, - "print_width": "50px", - "read_only": 1, - "reqd": 1, - "width": "50px" - }, - { - "doctype": "DocField", - "fieldname": "base_price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate (Company Currency)", - "oldfieldname": "base_ref_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "section_break_1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "export_rate", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "print_width": "150px", - "read_only": 0, - "reqd": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "export_amount", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "base_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Rate (Company Currency)", - "oldfieldname": "basic_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "reqd": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "base_amount", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Amount (Company Currency)", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_price", - "fieldtype": "Link", - "label": "Pricing Rule For Price", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_discount", - "fieldtype": "Link", - "label": "Pricing Rule For Discount", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "warehouse_and_reference", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Warehouse and Reference" - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Warehouse", - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Text", - "in_filter": 1, - "in_list_view": 1, - "label": "Serial No", - "no_copy": 1, - "oldfieldname": "serial_no", - "oldfieldtype": "Text", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "batch_no", - "fieldtype": "Link", - "hidden": 0, - "label": "Batch No", - "oldfieldname": "batch_no", - "oldfieldtype": "Link", - "options": "Batch", - "print_hide": 1, - "read_only": 0 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 1, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Link", - "hidden": 1, - "label": "Brand Name", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "item_tax_rate", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Item Tax Rate", - "oldfieldname": "item_tax_rate", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break4", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "actual_qty", - "fieldtype": "Float", - "label": "Available Qty at Warehouse", - "no_copy": 1, - "oldfieldname": "actual_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "expense_account", - "fieldtype": "Link", - "hidden": 0, - "label": "Expense Account", - "no_copy": 1, - "options": "Account", - "print_hide": 1, - "read_only": 0, - "width": "120px" - }, - { - "default": ":Company", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "hidden": 0, - "label": "Cost Center", - "no_copy": 1, - "options": "Cost Center", - "print_hide": 1, - "read_only": 0, - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "against_sales_order", - "fieldtype": "Link", - "label": "Against Sales Order", - "options": "Sales Order", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "against_sales_invoice", - "fieldtype": "Link", - "label": "Against Sales Invoice", - "options": "Sales Invoice", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_detail_docname", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "label": "Against Document Detail No", - "no_copy": 1, - "oldfieldname": "prevdoc_detail_docname", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "search_index": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "installed_qty", - "fieldtype": "Float", - "label": "Installed Qty", - "no_copy": 1, - "oldfieldname": "installed_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "buying_amount", - "fieldtype": "Currency", - "hidden": 1, - "label": "Buying Amount", - "no_copy": 1, - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "page_break", - "fieldtype": "Check", - "label": "Page Break", - "oldfieldname": "page_break", - "oldfieldtype": "Check", - "print_hide": 1, - "read_only": 0 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 3cae5992552..b797420bdb5 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -151,8 +151,7 @@ cur_frm.fields_dict.item_supplier_details.grid.get_field("supplier").get_query = cur_frm.cscript.copy_from_item_group = function(doc) { frappe.model.with_doc("Item Group", doc.item_group, function() { - $.each(frappe.model.get("Item Website Specification", {parent:doc.item_group}), - function(i, d) { + $.each((doc.item_website_specifications || []), function(i, d) { var n = frappe.model.add_child(doc, "Item Website Specification", "item_website_specifications"); n.label = d.label; diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json new file mode 100644 index 00000000000..77c992a61f8 --- /dev/null +++ b/erpnext/stock/doctype/item/item.json @@ -0,0 +1,885 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:item_code", + "creation": "2013-05-03 10:45:46.000000", + "default_print_format": "Standard", + "description": "A Product or a Service that is bought, sold or kept in stock.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "name_and_description_section", + "fieldtype": "Section Break", + "label": "Name and Description", + "no_copy": 0, + "oldfieldtype": "Section Break", + "options": "icon-flag", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "options": "\nITEM", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Item will be saved by this name in the data base.", + "fieldname": "item_code", + "fieldtype": "Data", + "in_filter": 0, + "label": "Item Code", + "no_copy": 1, + "oldfieldname": "item_code", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "in_filter": 1, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "description": "Unit of measurement of this item (e.g. Kg, Unit, No, Pair).", + "fieldname": "stock_uom", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Default Unit of Measure", + "oldfieldname": "stock_uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "brand", + "fieldtype": "Link", + "hidden": 0, + "label": "Brand", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "barcode", + "fieldtype": "Data", + "label": "Barcode", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "image", + "fieldtype": "Select", + "label": "Image", + "options": "attach_files:", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "image_view", + "fieldtype": "Image", + "in_list_view": 1, + "label": "Image View", + "options": "image", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_filter": 0, + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "description_html", + "fieldtype": "Small Text", + "label": "Description HTML", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Generates HTML to include selected image in the description", + "fieldname": "add_image", + "fieldtype": "Button", + "label": "Generate Description HTML", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "inventory", + "fieldtype": "Section Break", + "label": "Inventory", + "oldfieldtype": "Section Break", + "options": "icon-truck", + "permlevel": 0, + "read_only": 0 + }, + { + "default": "Yes", + "description": "Select \"Yes\" if you are maintaining stock of this item in your Inventory.", + "fieldname": "is_stock_item", + "fieldtype": "Select", + "label": "Is Stock Item", + "oldfieldname": "is_stock_item", + "oldfieldtype": "Select", + "options": "Yes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "description": "Mandatory if Stock Item is \"Yes\". Also the default warehouse where reserved quantity is set from Sales Order.", + "fieldname": "default_warehouse", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Default Warehouse", + "oldfieldname": "default_warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "description": "Percentage variation in quantity to be allowed while receiving or delivering this item.", + "fieldname": "tolerance", + "fieldtype": "Float", + "label": "Allowance Percent", + "oldfieldname": "tolerance", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "fieldname": "valuation_method", + "fieldtype": "Select", + "label": "Valuation Method", + "options": "\nFIFO\nMoving Average", + "permlevel": 0, + "read_only": 0 + }, + { + "default": "0.00", + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "description": "You can enter the minimum quantity of this item to be ordered.", + "fieldname": "min_order_qty", + "fieldtype": "Float", + "hidden": 0, + "label": "Minimum Order Qty", + "oldfieldname": "min_order_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "default": "No", + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "description": "Select \"Yes\" if this item is used for some internal purpose in your company.", + "fieldname": "is_asset_item", + "fieldtype": "Select", + "label": "Is Fixed Asset Item", + "oldfieldname": "is_asset_item", + "oldfieldtype": "Select", + "options": "Yes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "default": "No", + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "fieldname": "has_batch_no", + "fieldtype": "Select", + "label": "Has Batch No", + "oldfieldname": "has_batch_no", + "oldfieldtype": "Select", + "options": "Yes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "default": "No", + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "description": "Selecting \"Yes\" will give a unique identity to each entity of this item which can be viewed in the Serial No master.", + "fieldname": "has_serial_no", + "fieldtype": "Select", + "in_filter": 1, + "label": "Has Serial No", + "oldfieldname": "has_serial_no", + "oldfieldtype": "Select", + "options": "Yes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "depends_on": "eval: doc.has_serial_no===\"Yes\"", + "description": "Example: ABCD.#####\nIf series is set and Serial No is not mentioned in transactions, then automatic serial number will be created based on this series. If you always want to explicitly mention Serial Nos for this item. leave this blank.", + "fieldname": "serial_no_series", + "fieldtype": "Data", + "label": "Serial Number Series", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "fieldname": "warranty_period", + "fieldtype": "Data", + "label": "Warranty Period (in days)", + "oldfieldname": "warranty_period", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "fieldname": "end_of_life", + "fieldtype": "Date", + "label": "End of Life", + "oldfieldname": "end_of_life", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "description": "Net Weight of each Item", + "fieldname": "net_weight", + "fieldtype": "Float", + "label": "Net Weight", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "fieldname": "weight_uom", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Weight UOM", + "options": "UOM", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Auto-raise Material Request if quantity goes below re-order level in a warehouse", + "fieldname": "reorder_section", + "fieldtype": "Section Break", + "label": "Re-order", + "options": "icon-rss", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "fieldname": "re_order_level", + "fieldtype": "Float", + "label": "Re-Order Level", + "oldfieldname": "re_order_level", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_stock_item==\"Yes\"", + "fieldname": "re_order_qty", + "fieldtype": "Float", + "label": "Re-Order Qty", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "section_break_31", + "fieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "item_reorder", + "fieldtype": "Table", + "label": "Warehouse-wise Item Reorder", + "options": "Item Reorder", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "purchase_details", + "fieldtype": "Section Break", + "label": "Purchase Details", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0, + "read_only": 0 + }, + { + "default": "Yes", + "description": "Selecting \"Yes\" will allow this item to appear in Purchase Order , Purchase Receipt.", + "fieldname": "is_purchase_item", + "fieldtype": "Select", + "label": "Is Purchase Item", + "oldfieldname": "is_purchase_item", + "oldfieldtype": "Select", + "options": "Yes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "default_supplier", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Default Supplier", + "options": "Supplier", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.is_purchase_item==\"Yes\"", + "description": "Lead Time days is number of days by which this item is expected in your warehouse. This days is fetched in Material Request when you select this item.", + "fieldname": "lead_time_days", + "fieldtype": "Int", + "label": "Lead Time Days", + "no_copy": 1, + "oldfieldname": "lead_time_days", + "oldfieldtype": "Int", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_purchase_item==\"Yes\"", + "description": "Default Purchase Account in which cost of the item will be debited.", + "fieldname": "expense_account", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Default Expense Account", + "oldfieldname": "purchase_account", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_purchase_item==\"Yes\"", + "description": "Default Cost Center for tracking expense for this item.", + "fieldname": "buying_cost_center", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Default Buying Cost Center", + "oldfieldname": "cost_center", + "oldfieldtype": "Link", + "options": "Cost Center", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_purchase_item==\"Yes\"", + "fieldname": "last_purchase_rate", + "fieldtype": "Float", + "label": "Last Purchase Rate", + "no_copy": 1, + "oldfieldname": "last_purchase_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "eval:doc.is_purchase_item==\"Yes\"", + "fieldname": "standard_rate", + "fieldtype": "Float", + "label": "Standard Rate", + "oldfieldname": "standard_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_purchase_item==\"Yes\"", + "fieldname": "column_break2", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "depends_on": "eval:doc.is_purchase_item==\"Yes\"", + "fieldname": "uom_conversion_details", + "fieldtype": "Table", + "label": "UOM Conversion Details", + "no_copy": 1, + "oldfieldname": "uom_conversion_details", + "oldfieldtype": "Table", + "options": "UOM Conversion Detail", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_purchase_item==\"Yes\"", + "fieldname": "manufacturer", + "fieldtype": "Data", + "label": "Manufacturer", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_purchase_item==\"Yes\"", + "fieldname": "manufacturer_part_no", + "fieldtype": "Data", + "label": "Manufacturer Part Number", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_purchase_item==\"Yes\"", + "fieldname": "item_supplier_details", + "fieldtype": "Table", + "label": "Item Supplier Details", + "options": "Item Supplier", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "sales_details", + "fieldtype": "Section Break", + "label": "Sales Details", + "oldfieldtype": "Section Break", + "options": "icon-tag", + "permlevel": 0, + "read_only": 0 + }, + { + "default": "Yes", + "description": "Selecting \"Yes\" will allow this item to figure in Sales Order, Delivery Note", + "fieldname": "is_sales_item", + "fieldtype": "Select", + "in_filter": 1, + "label": "Is Sales Item", + "oldfieldname": "is_sales_item", + "oldfieldtype": "Select", + "options": "Yes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "default": "No", + "depends_on": "eval:doc.is_sales_item==\"Yes\"", + "description": "Select \"Yes\" if this item represents some work like training, designing, consulting etc.", + "fieldname": "is_service_item", + "fieldtype": "Select", + "in_filter": 1, + "label": "Is Service Item", + "oldfieldname": "is_service_item", + "oldfieldtype": "Select", + "options": "Yes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "depends_on": "eval:doc.is_sales_item==\"Yes\"", + "fieldname": "max_discount", + "fieldtype": "Float", + "label": "Max Discount (%)", + "oldfieldname": "max_discount", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_sales_item==\"Yes\"", + "fieldname": "income_account", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Default Income Account", + "options": "Account", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_sales_item==\"Yes\"", + "fieldname": "selling_cost_center", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Default Selling Cost Center", + "options": "Cost Center", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "eval:doc.is_sales_item==\"Yes\"", + "fieldname": "column_break3", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "depends_on": "eval:doc.is_sales_item==\"Yes\"", + "description": "For the convenience of customers, these codes can be used in print formats like Invoices and Delivery Notes", + "fieldname": "item_customer_details", + "fieldtype": "Table", + "label": "Customer Codes", + "options": "Item Customer Detail", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "item_tax_section_break", + "fieldtype": "Section Break", + "label": "Item Tax", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "item_tax", + "fieldtype": "Table", + "label": "Item Tax1", + "oldfieldname": "item_tax", + "oldfieldtype": "Table", + "options": "Item Tax", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "inspection_criteria", + "fieldtype": "Section Break", + "label": "Inspection Criteria", + "oldfieldtype": "Section Break", + "options": "icon-search", + "permlevel": 0, + "read_only": 0 + }, + { + "default": "No", + "fieldname": "inspection_required", + "fieldtype": "Select", + "label": "Inspection Required", + "no_copy": 0, + "oldfieldname": "inspection_required", + "oldfieldtype": "Select", + "options": "\nYes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "depends_on": "eval:doc.inspection_required==\"Yes\"", + "description": "Quality Inspection Parameters", + "fieldname": "item_specification_details", + "fieldtype": "Table", + "label": "Item Quality Inspection Parameter", + "oldfieldname": "item_specification_details", + "oldfieldtype": "Table", + "options": "Item Quality Inspection Parameter", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "manufacturing", + "fieldtype": "Section Break", + "label": "Manufacturing", + "oldfieldtype": "Section Break", + "options": "icon-cogs", + "permlevel": 0, + "read_only": 0 + }, + { + "default": "No", + "description": "Selecting \"Yes\" will allow you to create Bill of Material showing raw material and operational costs incurred to manufacture this item.", + "fieldname": "is_manufactured_item", + "fieldtype": "Select", + "label": "Allow Bill of Materials", + "oldfieldname": "is_manufactured_item", + "oldfieldtype": "Select", + "options": "Yes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "depends_on": "eval:doc.is_manufactured_item==\"Yes\"", + "fieldname": "default_bom", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Default BOM", + "no_copy": 1, + "oldfieldname": "default_bom", + "oldfieldtype": "Link", + "options": "BOM", + "permlevel": 0, + "read_only": 1 + }, + { + "default": "No", + "depends_on": "eval:doc.is_manufactured_item==\"Yes\"", + "description": "Selecting \"Yes\" will allow you to make a Production Order for this item.", + "fieldname": "is_pro_applicable", + "fieldtype": "Select", + "label": "Allow Production Order", + "oldfieldname": "is_pro_applicable", + "oldfieldtype": "Select", + "options": "Yes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "default": "No", + "description": "Select \"Yes\" if you supply raw materials to your supplier to manufacture this item.", + "fieldname": "is_sub_contracted_item", + "fieldtype": "Select", + "label": "Is Sub Contracted Item", + "oldfieldname": "is_sub_contracted_item", + "oldfieldtype": "Select", + "options": "Yes\nNo", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "customer_code", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "label": "Customer Code", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "website_section", + "fieldtype": "Section Break", + "label": "Website", + "options": "icon-globe", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "show_in_website", + "fieldtype": "Check", + "label": "Show in Website", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "show_in_website", + "description": "website page link", + "fieldname": "page_name", + "fieldtype": "Data", + "label": "Page Name", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "show_in_website", + "description": "Products will be sorted by weight-age in default searches. More the weight-age, higher the product will appear in the list.", + "fieldname": "weightage", + "fieldtype": "Int", + "label": "Weightage", + "permlevel": 0, + "read_only": 0, + "search_index": 1 + }, + { + "depends_on": "show_in_website", + "description": "Show a slideshow at the top of the page", + "fieldname": "slideshow", + "fieldtype": "Link", + "label": "Slideshow", + "options": "Website Slideshow", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "show_in_website", + "description": "Item Image (if not slideshow)", + "fieldname": "website_image", + "fieldtype": "Select", + "label": "Image", + "options": "attach_files:", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "cb72", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "show_in_website", + "description": "Show \"In Stock\" or \"Not in Stock\" based on stock available in this warehouse.", + "fieldname": "website_warehouse", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Website Warehouse", + "options": "Warehouse", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "show_in_website", + "description": "List this Item in multiple groups on the website.", + "fieldname": "website_item_groups", + "fieldtype": "Table", + "label": "Website Item Groups", + "options": "Website Item Group", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "show_in_website", + "fieldname": "sb72", + "fieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "show_in_website", + "fieldname": "copy_from_item_group", + "fieldtype": "Button", + "label": "Copy From Item Group", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "show_in_website", + "fieldname": "item_website_specifications", + "fieldtype": "Table", + "label": "Item Website Specifications", + "options": "Item Website Specification", + "permlevel": 0, + "read_only": 0 + }, + { + "depends_on": "show_in_website", + "fieldname": "web_long_description", + "fieldtype": "Text Editor", + "label": "Website Description", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "parent_website_route", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Parent Website Route", + "options": "Website Route", + "permlevel": 0 + } + ], + "icon": "icon-tag", + "idx": 1, + "max_attachments": 1, + "modified": "2014-03-13 15:54:09.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "import": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Master Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Manager", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, + "write": 0 + } + ], + "search_fields": "item_name,description,item_group,customer_code" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 58d151a5217..dd364ff5185 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -3,33 +3,29 @@ from __future__ import unicode_literals import frappe - -from frappe.utils import cstr, flt, getdate, now_datetime, formatdate -from frappe.model.doc import addchild -from frappe.model.bean import getlist from frappe import msgprint, _ - -from frappe.model.controller import DocListController +from frappe.utils import cstr, flt, getdate, now_datetime, formatdate +from frappe.website.website_generator import WebsiteGenerator class WarehouseNotSet(Exception): pass -class DocType(DocListController): +class Item(WebsiteGenerator): def onload(self): - self.doc.fields["__sle_exists"] = self.check_if_sle_exists() - + self.set("__sle_exists", self.check_if_sle_exists()) + def autoname(self): if frappe.db.get_default("item_naming_by")=="Naming Series": - from frappe.model.doc import make_autoname - self.doc.item_code = make_autoname(self.doc.naming_series+'.#####') - elif not self.doc.item_code: + from frappe.model.naming import make_autoname + self.item_code = make_autoname(self.naming_series+'.#####') + elif not self.item_code: msgprint(_("Item Code (item_code) is mandatory because Item naming is not sequential."), raise_exception=1) - - self.doc.name = self.doc.item_code - + + self.name = self.item_code + def validate(self): - if not self.doc.stock_uom: + if not self.stock_uom: msgprint(_("Please enter Default Unit of Measure"), raise_exception=1) - + self.check_warehouse_is_set_for_stock_item() self.check_stock_uom_with_bin() self.add_default_uom_in_conversion_factor_table() @@ -41,117 +37,121 @@ class DocType(DocListController): self.validate_barcode() self.cant_change() self.validate_item_type_for_reorder() - - if not self.doc.parent_website_route: - self.doc.parent_website_route = frappe.get_website_route("Item Group", self.doc.item_group) - if self.doc.name: - self.old_page_name = frappe.db.get_value('Item', self.doc.name, 'page_name') - + if not self.parent_website_route: + self.parent_website_route = frappe.get_website_route("Item Group", self.item_group) + + if self.name: + self.old_page_name = frappe.db.get_value('Item', self.name, 'page_name') + def on_update(self): + super(Item, self).on_update() self.validate_name_with_item_group() self.update_item_price() def check_warehouse_is_set_for_stock_item(self): - if self.doc.is_stock_item=="Yes" and not self.doc.default_warehouse: + if self.is_stock_item=="Yes" and not self.default_warehouse: frappe.msgprint(_("Default Warehouse is mandatory for Stock Item."), raise_exception=WarehouseNotSet) - + def add_default_uom_in_conversion_factor_table(self): - uom_conv_list = [d.uom for d in self.doclist.get({"parentfield": "uom_conversion_details"})] - if self.doc.stock_uom not in uom_conv_list: - ch = addchild(self.doc, 'uom_conversion_details', 'UOM Conversion Detail', self.doclist) - ch.uom = self.doc.stock_uom + uom_conv_list = [d.uom for d in self.get("uom_conversion_details")] + if self.stock_uom not in uom_conv_list: + ch = self.append('uom_conversion_details', {}) + ch.uom = self.stock_uom ch.conversion_factor = 1 - - for d in self.doclist.get({"parentfield": "uom_conversion_details"}): - if d.conversion_factor == 1 and d.uom != self.doc.stock_uom: - self.doclist.remove(d) - + + to_remove = [] + for d in self.get("uom_conversion_details"): + if d.conversion_factor == 1 and d.uom != self.stock_uom: + to_remove.append(d) + + [self.remove(d) for d in to_remove] + def check_stock_uom_with_bin(self): - if not self.doc.fields.get("__islocal"): + if not self.get("__islocal"): matched=True - ref_uom = frappe.db.get_value("Stock Ledger Entry", - {"item_code": self.doc.name}, "stock_uom") + ref_uom = frappe.db.get_value("Stock Ledger Entry", + {"item_code": self.name}, "stock_uom") if ref_uom: - if cstr(ref_uom) != cstr(self.doc.stock_uom): + if cstr(ref_uom) != cstr(self.stock_uom): matched = False else: - bin_list = frappe.db.sql("select * from tabBin where item_code=%s", - self.doc.item_code, as_dict=1) + bin_list = frappe.db.sql("select * from tabBin where item_code=%s", + self.item_code, as_dict=1) for bin in bin_list: if (bin.reserved_qty > 0 or bin.ordered_qty > 0 or bin.indented_qty > 0 \ - or bin.planned_qty > 0) and cstr(bin.stock_uom) != cstr(self.doc.stock_uom): + or bin.planned_qty > 0) and cstr(bin.stock_uom) != cstr(self.stock_uom): matched = False break - + if matched and bin_list: frappe.db.sql("""update tabBin set stock_uom=%s where item_code=%s""", - (self.doc.stock_uom, self.doc.name)) - + (self.stock_uom, self.name)) + if not matched: frappe.throw(_("Default Unit of Measure can not be changed directly because you have already made some transaction(s) with another UOM. To change default UOM, use 'UOM Replace Utility' tool under Stock module.")) - + def validate_conversion_factor(self): check_list = [] - for d in getlist(self.doclist,'uom_conversion_details'): + for d in self.get('uom_conversion_details'): if cstr(d.uom) in check_list: msgprint(_("UOM %s has been entered more than once in Conversion Factor Table." % cstr(d.uom)), raise_exception=1) else: check_list.append(cstr(d.uom)) - if d.uom and cstr(d.uom) == cstr(self.doc.stock_uom) and flt(d.conversion_factor) != 1: - msgprint(_("""Conversion Factor of UOM: %s should be equal to 1. As UOM: %s is Stock UOM of Item: %s.""" % - (d.uom, d.uom, self.doc.name)), raise_exception=1) - elif d.uom and cstr(d.uom)!= self.doc.stock_uom and flt(d.conversion_factor) == 1: - msgprint(_("""Conversion Factor of UOM: %s should not be equal to 1. As UOM: %s is not Stock UOM of Item: %s""" % - (d.uom, d.uom, self.doc.name)), raise_exception=1) - - def validate_item_type(self): - if cstr(self.doc.is_manufactured_item) == "No": - self.doc.is_pro_applicable = "No" + if d.uom and cstr(d.uom) == cstr(self.stock_uom) and flt(d.conversion_factor) != 1: + msgprint(_("""Conversion Factor of UOM: %s should be equal to 1. As UOM: %s is Stock UOM of Item: %s.""" % + (d.uom, d.uom, self.name)), raise_exception=1) + elif d.uom and cstr(d.uom)!= self.stock_uom and flt(d.conversion_factor) == 1: + msgprint(_("""Conversion Factor of UOM: %s should not be equal to 1. As UOM: %s is not Stock UOM of Item: %s""" % + (d.uom, d.uom, self.name)), raise_exception=1) - if self.doc.is_pro_applicable == 'Yes' and self.doc.is_stock_item == 'No': + def validate_item_type(self): + if cstr(self.is_manufactured_item) == "No": + self.is_pro_applicable = "No" + + if self.is_pro_applicable == 'Yes' and self.is_stock_item == 'No': frappe.throw(_("As Production Order can be made for this item, \ it must be a stock item.")) - if self.doc.has_serial_no == 'Yes' and self.doc.is_stock_item == 'No': + if self.has_serial_no == 'Yes' and self.is_stock_item == 'No': msgprint("'Has Serial No' can not be 'Yes' for non-stock item", raise_exception=1) - + def check_for_active_boms(self): - if self.doc.is_purchase_item != "Yes": - bom_mat = frappe.db.sql("""select distinct t1.parent - from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent - and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1 - and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name) - + if self.is_purchase_item != "Yes": + bom_mat = frappe.db.sql("""select distinct t1.parent + from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent + and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1 + and t2.docstatus = 1 and t1.docstatus =1 """, self.name) + if bom_mat and bom_mat[0][0]: frappe.throw(_("Item must be a purchase item, \ as it is present in one or many Active BOMs")) - - if self.doc.is_manufactured_item != "Yes": - bom = frappe.db.sql("""select name from `tabBOM` where item = %s - and is_active = 1""", (self.doc.name,)) + + if self.is_manufactured_item != "Yes": + bom = frappe.db.sql("""select name from `tabBOM` where item = %s + and is_active = 1""", (self.name,)) if bom and bom[0][0]: frappe.throw(_("""Allow Bill of Materials should be 'Yes'. Because one or many \ active BOMs present for this item""")) - + def fill_customer_code(self): """ Append all the customer codes and insert into "customer_code" field of item table """ cust_code=[] - for d in getlist(self.doclist,'item_customer_details'): + for d in self.get('item_customer_details'): cust_code.append(d.ref_code) - self.doc.customer_code=','.join(cust_code) + self.customer_code=','.join(cust_code) def check_item_tax(self): """Check whether Tax Rate is not entered twice for same Tax Type""" check_list=[] - for d in getlist(self.doclist,'item_tax'): + for d in self.get('item_tax'): if d.tax_type: account_type = frappe.db.get_value("Account", d.tax_type, "account_type") - + if account_type not in ['Tax', 'Chargeable', 'Income Account', 'Expense Account']: msgprint("'%s' is not Tax / Chargeable / Income / Expense Account" % d.tax_type, raise_exception=1) else: @@ -159,58 +159,57 @@ class DocType(DocListController): msgprint("Rate is entered twice for: '%s'" % d.tax_type, raise_exception=1) else: check_list.append(d.tax_type) - + def validate_barcode(self): - if self.doc.barcode: - duplicate = frappe.db.sql("""select name from tabItem where barcode = %s - and name != %s""", (self.doc.barcode, self.doc.name)) + if self.barcode: + duplicate = frappe.db.sql("""select name from tabItem where barcode = %s + and name != %s""", (self.barcode, self.name)) if duplicate: - msgprint("Barcode: %s already used in item: %s" % - (self.doc.barcode, cstr(duplicate[0][0])), raise_exception = 1) + msgprint("Barcode: %s already used in item: %s" % + (self.barcode, cstr(duplicate[0][0])), raise_exception = 1) def cant_change(self): - if not self.doc.fields.get("__islocal"): - vals = frappe.db.get_value("Item", self.doc.name, + if not self.get("__islocal"): + vals = frappe.db.get_value("Item", self.name, ["has_serial_no", "is_stock_item", "valuation_method"], as_dict=True) - - if vals and ((self.doc.is_stock_item == "No" and vals.is_stock_item == "Yes") or - vals.has_serial_no != self.doc.has_serial_no or - cstr(vals.valuation_method) != cstr(self.doc.valuation_method)): + + if vals and ((self.is_stock_item == "No" and vals.is_stock_item == "Yes") or + vals.has_serial_no != self.has_serial_no or + cstr(vals.valuation_method) != cstr(self.valuation_method)): if self.check_if_sle_exists() == "exists": frappe.throw(_("As there are existing stock transactions for this item, you can not change the values of 'Has Serial No', 'Is Stock Item' and 'Valuation Method'")) - + def validate_item_type_for_reorder(self): - if self.doc.re_order_level or len(self.doclist.get({"parentfield": "item_reorder", - "material_request_type": "Purchase"})): - if not self.doc.is_purchase_item: - frappe.msgprint(_("""To set reorder level, item must be Purchase Item"""), + if self.re_order_level or len(self.get("item_reorder", {"material_request_type": "Purchase"})): + if not self.is_purchase_item: + frappe.msgprint(_("""To set reorder level, item must be Purchase Item"""), raise_exception=1) - + def check_if_sle_exists(self): - sle = frappe.db.sql("""select name from `tabStock Ledger Entry` - where item_code = %s""", self.doc.name) + sle = frappe.db.sql("""select name from `tabStock Ledger Entry` + where item_code = %s""", self.name) return sle and 'exists' or 'not exists' def validate_name_with_item_group(self): # causes problem with tree build - if frappe.db.exists("Item Group", self.doc.name): + if frappe.db.exists("Item Group", self.name): frappe.msgprint("An item group exists with same name (%s), \ - please change the item name or rename the item group" % - self.doc.name, raise_exception=1) + please change the item name or rename the item group" % + self.name, raise_exception=1) def update_item_price(self): - frappe.db.sql("""update `tabItem Price` set item_name=%s, + frappe.db.sql("""update `tabItem Price` set item_name=%s, item_description=%s, modified=NOW() where item_code=%s""", - (self.doc.item_name, self.doc.description, self.doc.name)) + (self.item_name, self.description, self.name)) def get_page_title(self): - if self.doc.name==self.doc.item_name: - page_name_from = self.doc.name + if self.name==self.item_name: + page_name_from = self.name else: - page_name_from = self.doc.name + " " + self.doc.item_name - + page_name_from = self.name + " " + self.item_name + return page_name_from - + def get_tax_rate(self, tax_type): return { "tax_rate": frappe.db.get_value("Account", tax_type, "tax_rate") } @@ -222,82 +221,84 @@ class DocType(DocListController): 'description' : file and file[0]['description'] or '' } return ret - + def on_trash(self): - frappe.db.sql("""delete from tabBin where item_code=%s""", self.doc.item_code) + super(Item, self).on_trash() + frappe.db.sql("""delete from tabBin where item_code=%s""", self.item_code) def before_rename(self, olddn, newdn, merge=False): if merge: # Validate properties before merging if not frappe.db.exists("Item", newdn): frappe.throw(_("Item ") + newdn +_(" does not exists")) - + field_list = ["stock_uom", "is_stock_item", "has_serial_no", "has_batch_no"] new_properties = [cstr(d) for d in frappe.db.get_value("Item", newdn, field_list)] - if new_properties != [cstr(self.doc.fields[fld]) for fld in field_list]: + if new_properties != [cstr(self.get(fld)) for fld in field_list]: frappe.throw(_("To merge, following properties must be same for both items") + ": \n" + ", ".join([self.meta.get_label(fld) for fld in field_list])) frappe.db.sql("delete from `tabBin` where item_code=%s", olddn) def after_rename(self, olddn, newdn, merge): + super(Item, self).after_rename(olddn, newdn, merge) + frappe.db.set_value("Item", newdn, "item_code", newdn) - if merge: self.set_last_purchase_rate(newdn) self.recalculate_bin_qty(newdn) - + def set_last_purchase_rate(self, newdn): last_purchase_rate = get_last_purchase_details(newdn).get("base_rate", 0) frappe.db.set_value("Item", newdn, "last_purchase_rate", last_purchase_rate) - + def recalculate_bin_qty(self, newdn): from erpnext.utilities.repost_stock import repost_stock frappe.db.auto_commit_on_many_writes = 1 frappe.db.set_default("allow_negative_stock", 1) - + for warehouse in frappe.db.sql("select name from `tabWarehouse`"): repost_stock(newdn, warehouse[0]) - - frappe.db.set_default("allow_negative_stock", + + frappe.db.set_default("allow_negative_stock", frappe.db.get_value("Stock Settings", None, "allow_negative_stock")) frappe.db.auto_commit_on_many_writes = 0 def validate_end_of_life(item_code, end_of_life=None, verbose=1): if not end_of_life: end_of_life = frappe.db.get_value("Item", item_code, "end_of_life") - + if end_of_life and getdate(end_of_life) <= now_datetime().date(): msg = (_("Item") + " %(item_code)s: " + _("reached its end of life on") + \ " %(date)s. " + _("Please check") + ": %(end_of_life_label)s " + \ "in Item master") % { "item_code": item_code, "date": formatdate(end_of_life), - "end_of_life_label": frappe.get_doctype("Item").get_label("end_of_life") + "end_of_life_label": frappe.get_meta("Item").get_label("end_of_life") } - + _msgprint(msg, verbose) - + def validate_is_stock_item(item_code, is_stock_item=None, verbose=1): if not is_stock_item: is_stock_item = frappe.db.get_value("Item", item_code, "is_stock_item") - + if is_stock_item != "Yes": msg = (_("Item") + " %(item_code)s: " + _("is not a Stock Item")) % { "item_code": item_code, } - + _msgprint(msg, verbose) - + def validate_cancelled_item(item_code, docstatus=None, verbose=1): if docstatus is None: docstatus = frappe.db.get_value("Item", item_code, "docstatus") - + if docstatus == 2: msg = (_("Item") + " %(item_code)s: " + _("is a cancelled Item")) % { "item_code": item_code, } - + _msgprint(msg, verbose) def _msgprint(msg, verbose): @@ -305,22 +306,22 @@ def _msgprint(msg, verbose): msgprint(msg, raise_exception=True) else: raise frappe.ValidationError, msg - - + + def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0): """returns last purchase details in stock uom""" # get last purchase order item details last_purchase_order = frappe.db.sql("""\ select po.name, po.transaction_date, po.conversion_rate, - po_item.conversion_factor, po_item.base_price_list_rate, + po_item.conversion_factor, po_item.base_price_list_rate, po_item.discount_percentage, po_item.base_rate from `tabPurchase Order` po, `tabPurchase Order Item` po_item - where po.docstatus = 1 and po_item.item_code = %s and po.name != %s and + where po.docstatus = 1 and po_item.item_code = %s and po.name != %s and po.name = po_item.parent order by po.transaction_date desc, po.name desc limit 1""", (item_code, cstr(doc_name)), as_dict=1) - # get last purchase receipt item details + # get last purchase receipt item details last_purchase_receipt = frappe.db.sql("""\ select pr.name, pr.posting_date, pr.posting_time, pr.conversion_rate, pr_item.conversion_factor, pr_item.base_price_list_rate, pr_item.discount_percentage, @@ -341,16 +342,16 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0): # use purchase order last_purchase = last_purchase_order[0] purchase_date = purchase_order_date - + elif (purchase_receipt_date > purchase_order_date) or \ (last_purchase_receipt and not last_purchase_order): # use purchase receipt last_purchase = last_purchase_receipt[0] purchase_date = purchase_receipt_date - + else: return frappe._dict() - + conversion_factor = flt(last_purchase.conversion_factor) out = frappe._dict({ "base_price_list_rate": flt(last_purchase.base_price_list_rate) / conversion_factor, @@ -365,5 +366,5 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0): "rate": out.base_rate / conversion_rate, "base_rate": out.base_rate }) - - return out \ No newline at end of file + + return out diff --git a/erpnext/stock/doctype/item/item.txt b/erpnext/stock/doctype/item/item.txt deleted file mode 100644 index 229fa9718b9..00000000000 --- a/erpnext/stock/doctype/item/item.txt +++ /dev/null @@ -1,892 +0,0 @@ -[ - { - "creation": "2013-05-03 10:45:46", - "docstatus": 0, - "modified": "2014-03-13 15:54:09", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:item_code", - "default_print_format": "Standard", - "description": "A Product or a Service that is bought, sold or kept in stock.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-tag", - "max_attachments": 1, - "module": "Stock", - "name": "__common__", - "search_fields": "item_name,description,item_group,customer_code" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Item", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Item" - }, - { - "doctype": "DocField", - "fieldname": "name_and_description_section", - "fieldtype": "Section Break", - "label": "Name and Description", - "no_copy": 0, - "oldfieldtype": "Section Break", - "options": "icon-flag", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "options": "\nITEM", - "read_only": 0 - }, - { - "description": "Item will be saved by this name in the data base.", - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Data", - "in_filter": 0, - "label": "Item Code", - "no_copy": 1, - "oldfieldname": "item_code", - "oldfieldtype": "Data", - "read_only": 0, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "in_filter": 1, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "read_only": 0, - "reqd": 1 - }, - { - "description": "Unit of measurement of this item (e.g. Kg, Unit, No, Pair).", - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Default Unit of Measure", - "oldfieldname": "stock_uom", - "oldfieldtype": "Link", - "options": "UOM", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Link", - "hidden": 0, - "label": "Brand", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "print_hide": 1, - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "barcode", - "fieldtype": "Data", - "label": "Barcode", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "image", - "fieldtype": "Select", - "label": "Image", - "options": "attach_files:", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "image_view", - "fieldtype": "Image", - "in_list_view": 1, - "label": "Image View", - "options": "image", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_filter": 0, - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "description_html", - "fieldtype": "Small Text", - "label": "Description HTML", - "read_only": 0 - }, - { - "description": "Generates HTML to include selected image in the description", - "doctype": "DocField", - "fieldname": "add_image", - "fieldtype": "Button", - "label": "Generate Description HTML", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "inventory", - "fieldtype": "Section Break", - "label": "Inventory", - "oldfieldtype": "Section Break", - "options": "icon-truck", - "read_only": 0 - }, - { - "default": "Yes", - "description": "Select \"Yes\" if you are maintaining stock of this item in your Inventory.", - "doctype": "DocField", - "fieldname": "is_stock_item", - "fieldtype": "Select", - "label": "Is Stock Item", - "oldfieldname": "is_stock_item", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "description": "Mandatory if Stock Item is \"Yes\". Also the default warehouse where reserved quantity is set from Sales Order.", - "doctype": "DocField", - "fieldname": "default_warehouse", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Default Warehouse", - "oldfieldname": "default_warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "description": "Percentage variation in quantity to be allowed while receiving or delivering this item.", - "doctype": "DocField", - "fieldname": "tolerance", - "fieldtype": "Float", - "label": "Allowance Percent", - "oldfieldname": "tolerance", - "oldfieldtype": "Currency", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "valuation_method", - "fieldtype": "Select", - "label": "Valuation Method", - "options": "\nFIFO\nMoving Average", - "read_only": 0 - }, - { - "default": "0.00", - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "description": "You can enter the minimum quantity of this item to be ordered.", - "doctype": "DocField", - "fieldname": "min_order_qty", - "fieldtype": "Float", - "hidden": 0, - "label": "Minimum Order Qty", - "oldfieldname": "min_order_qty", - "oldfieldtype": "Currency", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "default": "No", - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "description": "Select \"Yes\" if this item is used for some internal purpose in your company.", - "doctype": "DocField", - "fieldname": "is_asset_item", - "fieldtype": "Select", - "label": "Is Fixed Asset Item", - "oldfieldname": "is_asset_item", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "default": "No", - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "has_batch_no", - "fieldtype": "Select", - "label": "Has Batch No", - "oldfieldname": "has_batch_no", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "default": "No", - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "description": "Selecting \"Yes\" will give a unique identity to each entity of this item which can be viewed in the Serial No master.", - "doctype": "DocField", - "fieldname": "has_serial_no", - "fieldtype": "Select", - "in_filter": 1, - "label": "Has Serial No", - "oldfieldname": "has_serial_no", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "depends_on": "eval: doc.has_serial_no===\"Yes\"", - "description": "Example: ABCD.#####\nIf series is set and Serial No is not mentioned in transactions, then automatic serial number will be created based on this series. If you always want to explicitly mention Serial Nos for this item. leave this blank.", - "doctype": "DocField", - "fieldname": "serial_no_series", - "fieldtype": "Data", - "label": "Serial Number Series" - }, - { - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "warranty_period", - "fieldtype": "Data", - "label": "Warranty Period (in days)", - "oldfieldname": "warranty_period", - "oldfieldtype": "Data", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "end_of_life", - "fieldtype": "Date", - "label": "End of Life", - "oldfieldname": "end_of_life", - "oldfieldtype": "Date", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "description": "Net Weight of each Item", - "doctype": "DocField", - "fieldname": "net_weight", - "fieldtype": "Float", - "label": "Net Weight", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "weight_uom", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Weight UOM", - "options": "UOM", - "read_only": 0 - }, - { - "description": "Auto-raise Material Request if quantity goes below re-order level in a warehouse", - "doctype": "DocField", - "fieldname": "reorder_section", - "fieldtype": "Section Break", - "label": "Re-order", - "options": "icon-rss", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "re_order_level", - "fieldtype": "Float", - "label": "Re-Order Level", - "oldfieldname": "re_order_level", - "oldfieldtype": "Currency", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_stock_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "re_order_qty", - "fieldtype": "Float", - "label": "Re-Order Qty", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_31", - "fieldtype": "Section Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "item_reorder", - "fieldtype": "Table", - "label": "Warehouse-wise Item Reorder", - "options": "Item Reorder", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "purchase_details", - "fieldtype": "Section Break", - "label": "Purchase Details", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart", - "read_only": 0 - }, - { - "default": "Yes", - "description": "Selecting \"Yes\" will allow this item to appear in Purchase Order , Purchase Receipt.", - "doctype": "DocField", - "fieldname": "is_purchase_item", - "fieldtype": "Select", - "label": "Is Purchase Item", - "oldfieldname": "is_purchase_item", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "default_supplier", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Default Supplier", - "options": "Supplier" - }, - { - "depends_on": "eval:doc.is_purchase_item==\"Yes\"", - "description": "Lead Time days is number of days by which this item is expected in your warehouse. This days is fetched in Material Request when you select this item.", - "doctype": "DocField", - "fieldname": "lead_time_days", - "fieldtype": "Int", - "label": "Lead Time Days", - "no_copy": 1, - "oldfieldname": "lead_time_days", - "oldfieldtype": "Int", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_purchase_item==\"Yes\"", - "description": "Default Purchase Account in which cost of the item will be debited.", - "doctype": "DocField", - "fieldname": "expense_account", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Default Expense Account", - "oldfieldname": "purchase_account", - "oldfieldtype": "Link", - "options": "Account", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_purchase_item==\"Yes\"", - "description": "Default Cost Center for tracking expense for this item.", - "doctype": "DocField", - "fieldname": "buying_cost_center", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Default Buying Cost Center", - "oldfieldname": "cost_center", - "oldfieldtype": "Link", - "options": "Cost Center", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_purchase_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "last_purchase_rate", - "fieldtype": "Float", - "label": "Last Purchase Rate", - "no_copy": 1, - "oldfieldname": "last_purchase_rate", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "depends_on": "eval:doc.is_purchase_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "standard_rate", - "fieldtype": "Float", - "label": "Standard Rate", - "oldfieldname": "standard_rate", - "oldfieldtype": "Currency", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_purchase_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "depends_on": "eval:doc.is_purchase_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "uom_conversion_details", - "fieldtype": "Table", - "label": "UOM Conversion Details", - "no_copy": 1, - "oldfieldname": "uom_conversion_details", - "oldfieldtype": "Table", - "options": "UOM Conversion Detail", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_purchase_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "manufacturer", - "fieldtype": "Data", - "label": "Manufacturer", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_purchase_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "manufacturer_part_no", - "fieldtype": "Data", - "label": "Manufacturer Part Number", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_purchase_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "item_supplier_details", - "fieldtype": "Table", - "label": "Item Supplier Details", - "options": "Item Supplier", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "sales_details", - "fieldtype": "Section Break", - "label": "Sales Details", - "oldfieldtype": "Section Break", - "options": "icon-tag", - "read_only": 0 - }, - { - "default": "Yes", - "description": "Selecting \"Yes\" will allow this item to figure in Sales Order, Delivery Note", - "doctype": "DocField", - "fieldname": "is_sales_item", - "fieldtype": "Select", - "in_filter": 1, - "label": "Is Sales Item", - "oldfieldname": "is_sales_item", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "default": "No", - "depends_on": "eval:doc.is_sales_item==\"Yes\"", - "description": "Select \"Yes\" if this item represents some work like training, designing, consulting etc.", - "doctype": "DocField", - "fieldname": "is_service_item", - "fieldtype": "Select", - "in_filter": 1, - "label": "Is Service Item", - "oldfieldname": "is_service_item", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "depends_on": "eval:doc.is_sales_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "max_discount", - "fieldtype": "Float", - "label": "Max Discount (%)", - "oldfieldname": "max_discount", - "oldfieldtype": "Currency", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_sales_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "income_account", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Default Income Account", - "options": "Account", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_sales_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "selling_cost_center", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Default Selling Cost Center", - "options": "Cost Center", - "read_only": 0 - }, - { - "depends_on": "eval:doc.is_sales_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "depends_on": "eval:doc.is_sales_item==\"Yes\"", - "description": "For the convenience of customers, these codes can be used in print formats like Invoices and Delivery Notes", - "doctype": "DocField", - "fieldname": "item_customer_details", - "fieldtype": "Table", - "label": "Customer Codes", - "options": "Item Customer Detail", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "item_tax_section_break", - "fieldtype": "Section Break", - "label": "Item Tax", - "oldfieldtype": "Section Break", - "options": "icon-money", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "item_tax", - "fieldtype": "Table", - "label": "Item Tax1", - "oldfieldname": "item_tax", - "oldfieldtype": "Table", - "options": "Item Tax", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "inspection_criteria", - "fieldtype": "Section Break", - "label": "Inspection Criteria", - "oldfieldtype": "Section Break", - "options": "icon-search", - "read_only": 0 - }, - { - "default": "No", - "doctype": "DocField", - "fieldname": "inspection_required", - "fieldtype": "Select", - "label": "Inspection Required", - "no_copy": 0, - "oldfieldname": "inspection_required", - "oldfieldtype": "Select", - "options": "\nYes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "depends_on": "eval:doc.inspection_required==\"Yes\"", - "description": "Quality Inspection Parameters", - "doctype": "DocField", - "fieldname": "item_specification_details", - "fieldtype": "Table", - "label": "Item Quality Inspection Parameter", - "oldfieldname": "item_specification_details", - "oldfieldtype": "Table", - "options": "Item Quality Inspection Parameter", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "manufacturing", - "fieldtype": "Section Break", - "label": "Manufacturing", - "oldfieldtype": "Section Break", - "options": "icon-cogs", - "read_only": 0 - }, - { - "default": "No", - "description": "Selecting \"Yes\" will allow you to create Bill of Material showing raw material and operational costs incurred to manufacture this item.", - "doctype": "DocField", - "fieldname": "is_manufactured_item", - "fieldtype": "Select", - "label": "Allow Bill of Materials", - "oldfieldname": "is_manufactured_item", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "depends_on": "eval:doc.is_manufactured_item==\"Yes\"", - "doctype": "DocField", - "fieldname": "default_bom", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Default BOM", - "no_copy": 1, - "oldfieldname": "default_bom", - "oldfieldtype": "Link", - "options": "BOM", - "read_only": 1 - }, - { - "default": "No", - "depends_on": "eval:doc.is_manufactured_item==\"Yes\"", - "description": "Selecting \"Yes\" will allow you to make a Production Order for this item.", - "doctype": "DocField", - "fieldname": "is_pro_applicable", - "fieldtype": "Select", - "label": "Allow Production Order", - "oldfieldname": "is_pro_applicable", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "default": "No", - "description": "Select \"Yes\" if you supply raw materials to your supplier to manufacture this item.", - "doctype": "DocField", - "fieldname": "is_sub_contracted_item", - "fieldtype": "Select", - "label": "Is Sub Contracted Item", - "oldfieldname": "is_sub_contracted_item", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer_code", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "label": "Customer Code", - "no_copy": 1, - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "website_section", - "fieldtype": "Section Break", - "label": "Website", - "options": "icon-globe", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "show_in_website", - "fieldtype": "Check", - "label": "Show in Website", - "read_only": 0 - }, - { - "depends_on": "show_in_website", - "description": "website page link", - "doctype": "DocField", - "fieldname": "page_name", - "fieldtype": "Data", - "label": "Page Name", - "read_only": 1 - }, - { - "depends_on": "show_in_website", - "description": "Products will be sorted by weight-age in default searches. More the weight-age, higher the product will appear in the list.", - "doctype": "DocField", - "fieldname": "weightage", - "fieldtype": "Int", - "label": "Weightage", - "read_only": 0, - "search_index": 1 - }, - { - "depends_on": "show_in_website", - "description": "Show a slideshow at the top of the page", - "doctype": "DocField", - "fieldname": "slideshow", - "fieldtype": "Link", - "label": "Slideshow", - "options": "Website Slideshow", - "read_only": 0 - }, - { - "depends_on": "show_in_website", - "description": "Item Image (if not slideshow)", - "doctype": "DocField", - "fieldname": "website_image", - "fieldtype": "Select", - "label": "Image", - "options": "attach_files:", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "cb72", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "depends_on": "show_in_website", - "description": "Show \"In Stock\" or \"Not in Stock\" based on stock available in this warehouse.", - "doctype": "DocField", - "fieldname": "website_warehouse", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Website Warehouse", - "options": "Warehouse", - "read_only": 0 - }, - { - "depends_on": "show_in_website", - "description": "List this Item in multiple groups on the website.", - "doctype": "DocField", - "fieldname": "website_item_groups", - "fieldtype": "Table", - "label": "Website Item Groups", - "options": "Website Item Group", - "read_only": 0 - }, - { - "depends_on": "show_in_website", - "doctype": "DocField", - "fieldname": "sb72", - "fieldtype": "Section Break", - "read_only": 0 - }, - { - "depends_on": "show_in_website", - "doctype": "DocField", - "fieldname": "copy_from_item_group", - "fieldtype": "Button", - "label": "Copy From Item Group", - "read_only": 0 - }, - { - "depends_on": "show_in_website", - "doctype": "DocField", - "fieldname": "item_website_specifications", - "fieldtype": "Table", - "label": "Item Website Specifications", - "options": "Item Website Specification", - "read_only": 0 - }, - { - "depends_on": "show_in_website", - "doctype": "DocField", - "fieldname": "web_long_description", - "fieldtype": "Text Editor", - "label": "Website Description", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "parent_website_route", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Parent Website Route", - "options": "Website Route" - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "import": 1, - "role": "Material Master Manager", - "write": 1 - }, - { - "amend": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Material Manager", - "write": 0 - }, - { - "amend": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Material User", - "write": 0 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index e86b113212f..506e5d016c3 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -13,9 +13,9 @@ test_dependencies = ["Warehouse"] class TestItem(unittest.TestCase): def test_default_warehouse(self): from erpnext.stock.doctype.item.item import WarehouseNotSet - item = frappe.bean(copy=test_records[0]) - item.doc.is_stock_item = "Yes" - item.doc.default_warehouse = None + item = frappe.copy_doc(test_records[0]) + item.is_stock_item = "Yes" + item.default_warehouse = None self.assertRaises(WarehouseNotSet, item.insert) def test_get_item_details(self): @@ -60,246 +60,4 @@ class TestItem(unittest.TestCase): for key, value in to_check.iteritems(): self.assertEquals(value, details.get(key)) -test_records = [ - [{ - "doctype": "Item", - "item_code": "_Test Item", - "item_name": "_Test Item", - "description": "_Test Item", - "item_group": "_Test Item Group", - "is_stock_item": "Yes", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM", - "income_account": "Sales - _TC", - "default_warehouse": "_Test Warehouse - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "selling_cost_center": "_Test Cost Center - _TC", - }, { - "doctype": "Item Reorder", - "parentfield": "item_reorder", - "warehouse": "_Test Warehouse - _TC", - "warehouse_reorder_level": 20, - "warehouse_reorder_qty": 20, - "material_request_type": "Purchase" - }, - ], - [{ - "doctype": "Item", - "item_code": "_Test Item 2", - "item_name": "_Test Item 2", - "description": "_Test Item 2", - "item_group": "_Test Item Group", - "is_stock_item": "Yes", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM", - "income_account": "Sales - _TC", - "default_warehouse": "_Test Warehouse - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC" - }], - [{ - "doctype": "Item", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "description": "_Test Item Home Desktop 100", - "item_group": "_Test Item Group Desktops", - "default_warehouse": "_Test Warehouse - _TC", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_stock_item": "Yes", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "No", - "is_sub_contracted_item": "No", - "is_manufactured_item": "No", - "stock_uom": "_Test UOM" - }, - { - "doctype": "Item Tax", - "tax_type": "_Test Account Excise Duty - _TC", - "tax_rate": 10 - }], - [{ - "doctype": "Item", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "description": "_Test Item Home Desktop 200", - "item_group": "_Test Item Group Desktops", - "default_warehouse": "_Test Warehouse - _TC", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_stock_item": "Yes", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "No", - "is_sub_contracted_item": "No", - "is_manufactured_item": "No", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test Sales BOM Item", - "item_name": "_Test Sales BOM Item", - "description": "_Test Sales BOM Item", - "item_group": "_Test Item Group Desktops", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_stock_item": "No", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "No", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test FG Item", - "item_name": "_Test FG Item", - "description": "_Test FG Item", - "item_group": "_Test Item Group Desktops", - "is_stock_item": "Yes", - "default_warehouse": "_Test Warehouse - _TC", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "Yes", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test Non Stock Item", - "item_name": "_Test Non Stock Item", - "description": "_Test Non Stock Item", - "item_group": "_Test Item Group Desktops", - "is_stock_item": "No", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "No", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test Serialized Item", - "item_name": "_Test Serialized Item", - "description": "_Test Serialized Item", - "item_group": "_Test Item Group Desktops", - "is_stock_item": "Yes", - "default_warehouse": "_Test Warehouse - _TC", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "Yes", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "No", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test Serialized Item With Series", - "item_name": "_Test Serialized Item With Series", - "description": "_Test Serialized Item", - "item_group": "_Test Item Group Desktops", - "is_stock_item": "Yes", - "default_warehouse": "_Test Warehouse - _TC", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "Yes", - "serial_no_series": "ABCD.#####", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "No", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test Item Home Desktop Manufactured", - "item_name": "_Test Item Home Desktop Manufactured", - "description": "_Test Item Home Desktop Manufactured", - "item_group": "_Test Item Group Desktops", - "default_warehouse": "_Test Warehouse - _TC", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_stock_item": "Yes", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "No", - "is_manufactured_item": "Yes", - "stock_uom": "_Test UOM" - }], - [{ - "doctype": "Item", - "item_code": "_Test FG Item 2", - "item_name": "_Test FG Item 2", - "description": "_Test FG Item 2", - "item_group": "_Test Item Group Desktops", - "is_stock_item": "Yes", - "default_warehouse": "_Test Warehouse - _TC", - "income_account": "Sales - _TC", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "is_asset_item": "No", - "has_batch_no": "No", - "has_serial_no": "No", - "is_purchase_item": "Yes", - "is_sales_item": "Yes", - "is_service_item": "No", - "inspection_required": "No", - "is_pro_applicable": "Yes", - "is_sub_contracted_item": "Yes", - "stock_uom": "_Test UOM" - }], -] \ No newline at end of file +test_records = frappe.get_test_records('Item') \ No newline at end of file diff --git a/erpnext/stock/doctype/item/test_records.json b/erpnext/stock/doctype/item/test_records.json new file mode 100644 index 00000000000..bc407e0c594 --- /dev/null +++ b/erpnext/stock/doctype/item/test_records.json @@ -0,0 +1,248 @@ +[ + { + "default_warehouse": "_Test Warehouse - _TC", + "description": "_Test Item", + "doctype": "Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "has_batch_no": "No", + "has_serial_no": "No", + "income_account": "Sales - _TC", + "inspection_required": "No", + "is_asset_item": "No", + "is_pro_applicable": "Yes", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_stock_item": "Yes", + "is_sub_contracted_item": "No", + "item_code": "_Test Item", + "item_group": "_Test Item Group", + "item_name": "_Test Item", + "item_reorder": [ + { + "doctype": "Item Reorder", + "material_request_type": "Purchase", + "parentfield": "item_reorder", + "warehouse": "_Test Warehouse - _TC", + "warehouse_reorder_level": 20, + "warehouse_reorder_qty": 20 + } + ], + "selling_cost_center": "_Test Cost Center - _TC", + "stock_uom": "_Test UOM" + }, + { + "default_warehouse": "_Test Warehouse - _TC", + "description": "_Test Item 2", + "doctype": "Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "has_batch_no": "No", + "has_serial_no": "No", + "income_account": "Sales - _TC", + "inspection_required": "No", + "is_asset_item": "No", + "is_pro_applicable": "Yes", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_stock_item": "Yes", + "is_sub_contracted_item": "No", + "item_code": "_Test Item 2", + "item_group": "_Test Item Group", + "item_name": "_Test Item 2", + "stock_uom": "_Test UOM" + }, + { + "default_warehouse": "_Test Warehouse - _TC", + "description": "_Test Item Home Desktop 100", + "doctype": "Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "has_batch_no": "No", + "has_serial_no": "No", + "income_account": "Sales - _TC", + "inspection_required": "No", + "is_asset_item": "No", + "is_manufactured_item": "No", + "is_pro_applicable": "No", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_stock_item": "Yes", + "is_sub_contracted_item": "No", + "item_code": "_Test Item Home Desktop 100", + "item_group": "_Test Item Group Desktops", + "item_name": "_Test Item Home Desktop 100", + "item_tax": [ + { + "doctype": "Item Tax", + "parentfield": "item_tax", + "tax_rate": 10, + "tax_type": "_Test Account Excise Duty - _TC" + } + ], + "stock_uom": "_Test UOM" + }, + { + "default_warehouse": "_Test Warehouse - _TC", + "description": "_Test Item Home Desktop 200", + "doctype": "Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "has_batch_no": "No", + "has_serial_no": "No", + "income_account": "Sales - _TC", + "inspection_required": "No", + "is_asset_item": "No", + "is_manufactured_item": "No", + "is_pro_applicable": "No", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_stock_item": "Yes", + "is_sub_contracted_item": "No", + "item_code": "_Test Item Home Desktop 200", + "item_group": "_Test Item Group Desktops", + "item_name": "_Test Item Home Desktop 200", + "stock_uom": "_Test UOM" + }, + { + "description": "_Test Sales BOM Item", + "doctype": "Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "has_batch_no": "No", + "has_serial_no": "No", + "income_account": "Sales - _TC", + "inspection_required": "No", + "is_asset_item": "No", + "is_pro_applicable": "No", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_stock_item": "No", + "is_sub_contracted_item": "No", + "item_code": "_Test Sales BOM Item", + "item_group": "_Test Item Group Desktops", + "item_name": "_Test Sales BOM Item", + "stock_uom": "_Test UOM" + }, + { + "default_warehouse": "_Test Warehouse - _TC", + "description": "_Test FG Item", + "doctype": "Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "has_batch_no": "No", + "has_serial_no": "No", + "income_account": "Sales - _TC", + "inspection_required": "No", + "is_asset_item": "No", + "is_pro_applicable": "Yes", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_stock_item": "Yes", + "is_sub_contracted_item": "Yes", + "item_code": "_Test FG Item", + "item_group": "_Test Item Group Desktops", + "item_name": "_Test FG Item", + "stock_uom": "_Test UOM" + }, + { + "description": "_Test Non Stock Item", + "doctype": "Item", + "has_batch_no": "No", + "has_serial_no": "No", + "inspection_required": "No", + "is_asset_item": "No", + "is_pro_applicable": "No", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_stock_item": "No", + "is_sub_contracted_item": "No", + "item_code": "_Test Non Stock Item", + "item_group": "_Test Item Group Desktops", + "item_name": "_Test Non Stock Item", + "stock_uom": "_Test UOM" + }, + { + "default_warehouse": "_Test Warehouse - _TC", + "description": "_Test Serialized Item", + "doctype": "Item", + "has_batch_no": "No", + "has_serial_no": "Yes", + "inspection_required": "No", + "is_asset_item": "No", + "is_pro_applicable": "No", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_stock_item": "Yes", + "is_sub_contracted_item": "No", + "item_code": "_Test Serialized Item", + "item_group": "_Test Item Group Desktops", + "item_name": "_Test Serialized Item", + "stock_uom": "_Test UOM" + }, + { + "default_warehouse": "_Test Warehouse - _TC", + "description": "_Test Serialized Item", + "doctype": "Item", + "has_batch_no": "No", + "has_serial_no": "Yes", + "inspection_required": "No", + "is_asset_item": "No", + "is_pro_applicable": "Yes", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_stock_item": "Yes", + "is_sub_contracted_item": "No", + "item_code": "_Test Serialized Item With Series", + "item_group": "_Test Item Group Desktops", + "item_name": "_Test Serialized Item With Series", + "serial_no_series": "ABCD.#####", + "stock_uom": "_Test UOM" + }, + { + "default_warehouse": "_Test Warehouse - _TC", + "description": "_Test Item Home Desktop Manufactured", + "doctype": "Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "has_batch_no": "No", + "has_serial_no": "No", + "income_account": "Sales - _TC", + "inspection_required": "No", + "is_asset_item": "No", + "is_manufactured_item": "Yes", + "is_pro_applicable": "Yes", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_stock_item": "Yes", + "is_sub_contracted_item": "No", + "item_code": "_Test Item Home Desktop Manufactured", + "item_group": "_Test Item Group Desktops", + "item_name": "_Test Item Home Desktop Manufactured", + "stock_uom": "_Test UOM" + }, + { + "default_warehouse": "_Test Warehouse - _TC", + "description": "_Test FG Item 2", + "doctype": "Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "has_batch_no": "No", + "has_serial_no": "No", + "income_account": "Sales - _TC", + "inspection_required": "No", + "is_asset_item": "No", + "is_pro_applicable": "Yes", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_stock_item": "Yes", + "is_sub_contracted_item": "Yes", + "item_code": "_Test FG Item 2", + "item_group": "_Test Item Group Desktops", + "item_name": "_Test FG Item 2", + "stock_uom": "_Test UOM" + } +] \ No newline at end of file diff --git a/erpnext/stock/doctype/item_customer_detail/item_customer_detail.json b/erpnext/stock/doctype/item_customer_detail/item_customer_detail.json new file mode 100644 index 00000000000..42b917bce7b --- /dev/null +++ b/erpnext/stock/doctype/item_customer_detail/item_customer_detail.json @@ -0,0 +1,47 @@ +{ + "autoname": "ITEMCUST/.#####", + "creation": "2013-03-08 15:37:16.000000", + "description": "For the convenience of customers, these codes can be used in print formats like Invoices and Delivery Notes", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "customer_name", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Customer Name", + "oldfieldname": "price_list_name", + "oldfieldtype": "Select", + "options": "Customer", + "permlevel": 0, + "print_width": "180px", + "reqd": 1, + "search_index": 1, + "width": "180px" + }, + { + "fieldname": "ref_code", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Ref Code", + "oldfieldname": "ref_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "120px", + "reqd": 1, + "search_index": 1, + "width": "120px" + } + ], + "idx": 1, + "in_create": 0, + "istable": 1, + "modified": "2013-12-20 19:23:16.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item Customer Detail", + "owner": "Administrator", + "read_only": 0 +} \ No newline at end of file diff --git a/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py b/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py index 26c87f1c04a..b0bd280c7e3 100644 --- a/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py +++ b/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemCustomerDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item_customer_detail/item_customer_detail.txt b/erpnext/stock/doctype/item_customer_detail/item_customer_detail.txt deleted file mode 100644 index 9d9b6ca0789..00000000000 --- a/erpnext/stock/doctype/item_customer_detail/item_customer_detail.txt +++ /dev/null @@ -1,56 +0,0 @@ -[ - { - "creation": "2013-03-08 15:37:16", - "docstatus": 0, - "modified": "2013-12-20 19:23:16", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "ITEMCUST/.#####", - "description": "For the convenience of customers, these codes can be used in print formats like Invoices and Delivery Notes", - "doctype": "DocType", - "in_create": 0, - "istable": 1, - "module": "Stock", - "name": "__common__", - "read_only": 0 - }, - { - "doctype": "DocField", - "in_filter": 1, - "in_list_view": 1, - "name": "__common__", - "parent": "Item Customer Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocType", - "name": "Item Customer Detail" - }, - { - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Link", - "label": "Customer Name", - "oldfieldname": "price_list_name", - "oldfieldtype": "Select", - "options": "Customer", - "print_width": "180px", - "width": "180px" - }, - { - "doctype": "DocField", - "fieldname": "ref_code", - "fieldtype": "Data", - "label": "Ref Code", - "oldfieldname": "ref_rate", - "oldfieldtype": "Currency", - "print_width": "120px", - "width": "120px" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/item_price/item_price.json b/erpnext/stock/doctype/item_price/item_price.json new file mode 100644 index 00000000000..6b50349dc2e --- /dev/null +++ b/erpnext/stock/doctype/item_price/item_price.json @@ -0,0 +1,140 @@ +{ + "allow_import": 1, + "autoname": "RFD/.#####", + "creation": "2013-05-02 16:29:48.000000", + "description": "Multiple Item prices.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "price_list_details", + "fieldtype": "Section Break", + "label": "Price List", + "options": "icon-tags", + "permlevel": 0 + }, + { + "fieldname": "price_list", + "fieldtype": "Link", + "in_filter": 1, + "label": "Price List", + "options": "Price List", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "buying", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Buying", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "selling", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Selling", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "item_details", + "fieldtype": "Section Break", + "label": "Item", + "options": "icon-tag", + "permlevel": 0 + }, + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "price_list_name", + "oldfieldtype": "Select", + "options": "Item", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "price_list_rate", + "fieldtype": "Currency", + "in_filter": 1, + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "ref_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "col_br_1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "label": "Item Name", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "item_description", + "fieldtype": "Text", + "label": "Item Description", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "hidden": 1, + "label": "Currency", + "options": "Currency", + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-flag", + "idx": 1, + "in_create": 0, + "istable": 0, + "modified": "2014-02-10 17:27:32.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item Price", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Master Manager", + "write": 1 + } + ], + "read_only": 0 +} \ No newline at end of file diff --git a/erpnext/stock/doctype/item_price/item_price.py b/erpnext/stock/doctype/item_price/item_price.py index 879fcae4d11..89166288557 100644 --- a/erpnext/stock/doctype/item_price/item_price.py +++ b/erpnext/stock/doctype/item_price/item_price.py @@ -7,9 +7,9 @@ from frappe import throw, _ class ItemPriceDuplicateItem(frappe.ValidationError): pass -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class ItemPrice(Document): def validate(self): self.validate_item() @@ -19,39 +19,39 @@ class DocType: self.update_item_details() def validate_item(self): - if not frappe.db.exists("Item", self.doc.item_code): + if not frappe.db.exists("Item", self.item_code): throw("{doctype}: {item} {not_found}".format(**{ "doctype": _("Item"), - "item": self.doc.item_code, + "item": self.item_code, "not_found": _(" not found") })) def validate_price_list(self): - enabled = frappe.db.get_value("Price List", self.doc.price_list, "enabled") + enabled = frappe.db.get_value("Price List", self.price_list, "enabled") if not enabled: throw("{message}: {price_list} {disabled}".format(**{ "message": _("Price List"), - "price_list": self.doc.price_list, + "price_list": self.price_list, "disabled": _("is disabled.") })) def check_duplicate_item(self): if frappe.db.sql("""select name from `tabItem Price` where item_code=%s and price_list=%s and name!=%s""", - (self.doc.item_code, self.doc.price_list, self.doc.name)): + (self.item_code, self.price_list, self.name)): throw("{duplicate_item}: {item_code}, {already}: {price_list}".format(**{ "duplicate_item": _("Duplicate Item"), - "item_code": self.doc.item_code, + "item_code": self.item_code, "already": _("already available in Price List"), - "price_list": self.doc.price_list + "price_list": self.price_list }), ItemPriceDuplicateItem) def update_price_list_details(self): - self.doc.buying, self.doc.selling, self.doc.currency = \ - frappe.db.get_value("Price List", {"name": self.doc.price_list, "enabled": 1}, + self.buying, self.selling, self.currency = \ + frappe.db.get_value("Price List", {"name": self.price_list, "enabled": 1}, ["buying", "selling", "currency"]) def update_item_details(self): - self.doc.item_name, self.doc.item_description = frappe.db.get_value("Item", - self.doc.item_code, ["item_name", "description"]) + self.item_name, self.item_description = frappe.db.get_value("Item", + self.item_code, ["item_name", "description"]) \ No newline at end of file diff --git a/erpnext/stock/doctype/item_price/item_price.txt b/erpnext/stock/doctype/item_price/item_price.txt deleted file mode 100644 index 8b188762e17..00000000000 --- a/erpnext/stock/doctype/item_price/item_price.txt +++ /dev/null @@ -1,151 +0,0 @@ -[ - { - "creation": "2013-05-02 16:29:48", - "docstatus": 0, - "modified": "2014-02-10 17:27:32", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "autoname": "RFD/.#####", - "description": "Multiple Item prices.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-flag", - "in_create": 0, - "istable": 0, - "module": "Stock", - "name": "__common__", - "read_only": 0 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Item Price", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Item Price", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Item Price" - }, - { - "doctype": "DocField", - "fieldname": "price_list_details", - "fieldtype": "Section Break", - "label": "Price List", - "options": "icon-tags" - }, - { - "doctype": "DocField", - "fieldname": "price_list", - "fieldtype": "Link", - "in_filter": 1, - "label": "Price List", - "options": "Price List", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "buying", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Buying", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "selling", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Selling", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_details", - "fieldtype": "Section Break", - "label": "Item", - "options": "icon-tag" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "price_list_name", - "oldfieldtype": "Select", - "options": "Item", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "price_list_rate", - "fieldtype": "Currency", - "in_filter": 1, - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "ref_rate", - "oldfieldtype": "Currency", - "options": "currency", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_br_1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "label": "Item Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_description", - "fieldtype": "Text", - "label": "Item Description", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "currency", - "fieldtype": "Link", - "hidden": 1, - "label": "Currency", - "options": "Currency", - "read_only": 1 - }, - { - "doctype": "DocPerm", - "role": "Sales Master Manager" - }, - { - "doctype": "DocPerm", - "role": "Purchase Master Manager" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/item_price/test_item_price.py b/erpnext/stock/doctype/item_price/test_item_price.py index 4585e38b032..1a430bf9f05 100644 --- a/erpnext/stock/doctype/item_price/test_item_price.py +++ b/erpnext/stock/doctype/item_price/test_item_price.py @@ -8,16 +8,7 @@ import frappe class TestItem(unittest.TestCase): def test_duplicate_item(self): from erpnext.stock.doctype.item_price.item_price import ItemPriceDuplicateItem - bean = frappe.bean(copy=test_records[0]) - self.assertRaises(ItemPriceDuplicateItem, bean.insert) + doc = frappe.copy_doc(test_records[0]) + self.assertRaises(ItemPriceDuplicateItem, doc.insert) -test_records = [ - [ - { - "doctype": "Item Price", - "price_list": "_Test Price List", - "item_code": "_Test Item", - "price_list_rate": 100 - } - ] -] \ No newline at end of file +test_records = frappe.get_test_records('Item Price') \ No newline at end of file diff --git a/erpnext/stock/doctype/item_price/test_records.json b/erpnext/stock/doctype/item_price/test_records.json new file mode 100644 index 00000000000..72d5582c653 --- /dev/null +++ b/erpnext/stock/doctype/item_price/test_records.json @@ -0,0 +1,8 @@ +[ + { + "doctype": "Item Price", + "item_code": "_Test Item", + "price_list": "_Test Price List", + "price_list_rate": 100 + } +] \ No newline at end of file diff --git a/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.json b/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.json new file mode 100644 index 00000000000..f7c35f21029 --- /dev/null +++ b/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.json @@ -0,0 +1,38 @@ +{ + "autoname": "IISD/.#####", + "creation": "2013-02-22 01:28:01.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "specification", + "fieldtype": "Data", + "in_filter": 0, + "in_list_view": 1, + "label": "Parameter", + "oldfieldname": "specification", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "200px", + "reqd": 1, + "search_index": 0, + "width": "200px" + }, + { + "fieldname": "value", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Acceptance Criteria", + "oldfieldname": "value", + "oldfieldtype": "Data", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:16.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item Quality Inspection Parameter", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py b/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py index 26c87f1c04a..b659bb0746f 100644 --- a/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py +++ b/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemQualityInspectionParameter(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.txt b/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.txt deleted file mode 100644 index 8ec87d7cc13..00000000000 --- a/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.txt +++ /dev/null @@ -1,48 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:01", - "docstatus": 0, - "modified": "2013-12-20 19:23:16", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "IISD/.#####", - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldtype": "Data", - "in_list_view": 1, - "name": "__common__", - "oldfieldtype": "Data", - "parent": "Item Quality Inspection Parameter", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Item Quality Inspection Parameter" - }, - { - "doctype": "DocField", - "fieldname": "specification", - "in_filter": 0, - "label": "Parameter", - "oldfieldname": "specification", - "print_width": "200px", - "reqd": 1, - "search_index": 0, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "value", - "label": "Acceptance Criteria", - "oldfieldname": "value" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/item_reorder/item_reorder.json b/erpnext/stock/doctype/item_reorder/item_reorder.json new file mode 100644 index 00000000000..bc96b4a923f --- /dev/null +++ b/erpnext/stock/doctype/item_reorder/item_reorder.json @@ -0,0 +1,53 @@ +{ + "autoname": "REORD-.#####", + "creation": "2013-03-07 11:42:59.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "warehouse", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Warehouse", + "options": "Warehouse", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "warehouse_reorder_level", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Re-order Level", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "warehouse_reorder_qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Re-order Qty", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "material_request_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Material Request Type", + "options": "Purchase\nTransfer", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + } + ], + "idx": 1, + "in_create": 1, + "istable": 1, + "modified": "2013-12-20 19:23:16.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item Reorder", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/item_reorder/item_reorder.py b/erpnext/stock/doctype/item_reorder/item_reorder.py index 968a25b6134..7dcefb0e083 100644 --- a/erpnext/stock/doctype/item_reorder/item_reorder.py +++ b/erpnext/stock/doctype/item_reorder/item_reorder.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemReorder(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item_reorder/item_reorder.txt b/erpnext/stock/doctype/item_reorder/item_reorder.txt deleted file mode 100644 index 74df09a0ae8..00000000000 --- a/erpnext/stock/doctype/item_reorder/item_reorder.txt +++ /dev/null @@ -1,60 +0,0 @@ -[ - { - "creation": "2013-03-07 11:42:59", - "docstatus": 0, - "modified": "2013-12-20 19:23:16", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "REORD-.#####", - "doctype": "DocType", - "in_create": 1, - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Item Reorder", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "read_only": 0 - }, - { - "doctype": "DocType", - "name": "Item Reorder" - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "label": "Warehouse", - "options": "Warehouse", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "warehouse_reorder_level", - "fieldtype": "Float", - "label": "Re-order Level", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "warehouse_reorder_qty", - "fieldtype": "Float", - "label": "Re-order Qty" - }, - { - "doctype": "DocField", - "fieldname": "material_request_type", - "fieldtype": "Select", - "label": "Material Request Type", - "options": "Purchase\nTransfer", - "reqd": 1 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/item_supplier/item_supplier.json b/erpnext/stock/doctype/item_supplier/item_supplier.json new file mode 100644 index 00000000000..e56f29e7047 --- /dev/null +++ b/erpnext/stock/doctype/item_supplier/item_supplier.json @@ -0,0 +1,31 @@ +{ + "creation": "2013-02-22 01:28:01.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "supplier", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Supplier", + "options": "Supplier", + "permlevel": 0 + }, + { + "fieldname": "supplier_part_no", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Supplier Part Number", + "permlevel": 0, + "print_width": "200px", + "width": "200px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:16.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item Supplier", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/item_supplier/item_supplier.py b/erpnext/stock/doctype/item_supplier/item_supplier.py index 26c87f1c04a..68f481602f8 100644 --- a/erpnext/stock/doctype/item_supplier/item_supplier.py +++ b/erpnext/stock/doctype/item_supplier/item_supplier.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemSupplier(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item_supplier/item_supplier.txt b/erpnext/stock/doctype/item_supplier/item_supplier.txt deleted file mode 100644 index 02e0bd7cac1..00000000000 --- a/erpnext/stock/doctype/item_supplier/item_supplier.txt +++ /dev/null @@ -1,43 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:01", - "docstatus": 0, - "modified": "2013-12-20 19:23:16", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Item Supplier", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Item Supplier" - }, - { - "doctype": "DocField", - "fieldname": "supplier", - "fieldtype": "Link", - "label": "Supplier", - "options": "Supplier" - }, - { - "doctype": "DocField", - "fieldname": "supplier_part_no", - "fieldtype": "Data", - "label": "Supplier Part Number", - "print_width": "200px", - "width": "200px" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/item_tax/item_tax.json b/erpnext/stock/doctype/item_tax/item_tax.json new file mode 100644 index 00000000000..b2b92564228 --- /dev/null +++ b/erpnext/stock/doctype/item_tax/item_tax.json @@ -0,0 +1,35 @@ +{ + "creation": "2013-02-22 01:28:01.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "tax_type", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Tax", + "oldfieldname": "tax_type", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "tax_rate", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Tax Rate", + "oldfieldname": "tax_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "reqd": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:16.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item Tax", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/item_tax/item_tax.py b/erpnext/stock/doctype/item_tax/item_tax.py index 26c87f1c04a..96363e81159 100644 --- a/erpnext/stock/doctype/item_tax/item_tax.py +++ b/erpnext/stock/doctype/item_tax/item_tax.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemTax(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item_tax/item_tax.txt b/erpnext/stock/doctype/item_tax/item_tax.txt deleted file mode 100644 index 243ee1f31bf..00000000000 --- a/erpnext/stock/doctype/item_tax/item_tax.txt +++ /dev/null @@ -1,47 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:01", - "docstatus": 0, - "modified": "2013-12-20 19:23:16", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Item Tax", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Item Tax" - }, - { - "doctype": "DocField", - "fieldname": "tax_type", - "fieldtype": "Link", - "label": "Tax", - "oldfieldname": "tax_type", - "oldfieldtype": "Link", - "options": "Account", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "tax_rate", - "fieldtype": "Float", - "label": "Tax Rate", - "oldfieldname": "tax_rate", - "oldfieldtype": "Currency", - "reqd": 0 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/item_website_specification/item_website_specification.json b/erpnext/stock/doctype/item_website_specification/item_website_specification.json new file mode 100644 index 00000000000..1cf2189dbdc --- /dev/null +++ b/erpnext/stock/doctype/item_website_specification/item_website_specification.json @@ -0,0 +1,33 @@ +{ + "creation": "2013-02-22 01:28:01.000000", + "description": "Table for Item that will be shown in Web Site", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "label", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Label", + "permlevel": 0, + "print_width": "150px", + "width": "150px" + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "permlevel": 0, + "print_width": "300px", + "width": "300px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:16.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item Website Specification", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/item_website_specification/item_website_specification.py b/erpnext/stock/doctype/item_website_specification/item_website_specification.py index 968a25b6134..ceb07275f9f 100644 --- a/erpnext/stock/doctype/item_website_specification/item_website_specification.py +++ b/erpnext/stock/doctype/item_website_specification/item_website_specification.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class ItemWebsiteSpecification(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/item_website_specification/item_website_specification.txt b/erpnext/stock/doctype/item_website_specification/item_website_specification.txt deleted file mode 100644 index 164da81ca78..00000000000 --- a/erpnext/stock/doctype/item_website_specification/item_website_specification.txt +++ /dev/null @@ -1,45 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:01", - "docstatus": 0, - "modified": "2013-12-20 19:23:16", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Table for Item that will be shown in Web Site", - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Item Website Specification", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Item Website Specification" - }, - { - "doctype": "DocField", - "fieldname": "label", - "fieldtype": "Data", - "label": "Label", - "print_width": "150px", - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "label": "Description", - "print_width": "300px", - "width": "300px" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.json b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.json new file mode 100644 index 00000000000..f761ebabb12 --- /dev/null +++ b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.json @@ -0,0 +1,57 @@ +{ + "creation": "2013-02-22 01:28:02.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "account_head", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Account Head", + "oldfieldname": "account_head", + "oldfieldtype": "Link", + "options": "Account", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "cost_center", + "fieldtype": "Link", + "label": "Cost Center", + "options": "Cost Center", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "300px", + "reqd": 1, + "width": "300px" + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "reqd": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:18.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Landed Cost Item", + "owner": "wasim@webnotestech.com" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py index 26c87f1c04a..4681361d9d5 100644 --- a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py +++ b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class LandedCostItem(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.txt b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.txt deleted file mode 100644 index bf8af3a37b5..00000000000 --- a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.txt +++ /dev/null @@ -1,67 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:02", - "docstatus": 0, - "modified": "2013-12-20 19:23:18", - "modified_by": "Administrator", - "owner": "wasim@webnotestech.com" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Landed Cost Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocType", - "name": "Landed Cost Item" - }, - { - "doctype": "DocField", - "fieldname": "account_head", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Account Head", - "oldfieldname": "account_head", - "oldfieldtype": "Link", - "options": "Account", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "label": "Cost Center", - "options": "Cost Center" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Data", - "print_width": "300px", - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "currency" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.json b/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.json new file mode 100644 index 00000000000..b50c148292e --- /dev/null +++ b/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.json @@ -0,0 +1,26 @@ +{ + "creation": "2013-02-22 01:28:02.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "purchase_receipt", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Purchase Receipt", + "oldfieldname": "purchase_receipt_no", + "oldfieldtype": "Link", + "options": "Purchase Receipt", + "permlevel": 0, + "print_width": "220px", + "width": "220px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:18.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Landed Cost Purchase Receipt", + "owner": "wasim@webnotestech.com" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py b/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py index 26c87f1c04a..090f8337118 100644 --- a/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py +++ b/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class LandedCostPurchaseReceipt(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.txt b/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.txt deleted file mode 100644 index 8d02e3a10cc..00000000000 --- a/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.txt +++ /dev/null @@ -1,39 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:02", - "docstatus": 0, - "modified": "2013-12-20 19:23:18", - "modified_by": "Administrator", - "owner": "wasim@webnotestech.com" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "purchase_receipt", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Purchase Receipt", - "name": "__common__", - "oldfieldname": "purchase_receipt_no", - "oldfieldtype": "Link", - "options": "Purchase Receipt", - "parent": "Landed Cost Purchase Receipt", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "print_width": "220px", - "width": "220px" - }, - { - "doctype": "DocType", - "name": "Landed Cost Purchase Receipt" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.json b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.json new file mode 100644 index 00000000000..59c94781254 --- /dev/null +++ b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.json @@ -0,0 +1,83 @@ +{ + "creation": "2013-01-22 16:50:39.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "section_break0", + "fieldtype": "Section Break", + "label": "Select Purchase Receipts", + "options": "Simple", + "permlevel": 0 + }, + { + "fieldname": "lc_pr_details", + "fieldtype": "Table", + "label": "Landed Cost Purchase Receipts", + "options": "Landed Cost Purchase Receipt", + "permlevel": 0 + }, + { + "fieldname": "section_break1", + "fieldtype": "Section Break", + "label": "Add Taxes and Charges", + "permlevel": 0 + }, + { + "fieldname": "landed_cost_details", + "fieldtype": "Table", + "label": "Landed Cost Items", + "options": "Landed Cost Item", + "permlevel": 0 + }, + { + "fieldname": "update_landed_cost", + "fieldtype": "Button", + "label": "Update Landed Cost", + "options": "update_landed_cost", + "permlevel": 0 + } + ], + "icon": "icon-magic", + "idx": 1, + "issingle": 1, + "modified": "2013-12-20 19:23:18.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Landed Cost Wizard", + "owner": "wasim@webnotestech.com", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "Purchase Manager", + "submit": 0, + "write": 1 + }, + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "Purchase User", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py index c52c820be96..e7cb41035bf 100644 --- a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py +++ b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py @@ -4,13 +4,11 @@ from __future__ import unicode_literals import frappe from frappe.utils import flt -from frappe.model.doc import addchild from frappe import msgprint, _ -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class LandedCostWizard(Document): def update_landed_cost(self): """ @@ -18,7 +16,7 @@ class DocType: Recalculate valuation rate in all sle after pr posting date """ purchase_receipts = [row.purchase_receipt for row in - self.doclist.get({"parentfield": "lc_pr_details"})] + self.get("lc_pr_details")] self.validate_purchase_receipts(purchase_receipts) self.cancel_pr(purchase_receipts) @@ -36,15 +34,13 @@ class DocType: total_amt = self.get_total_pr_amt(purchase_receipts) for pr in purchase_receipts: - pr_bean = frappe.bean('Purchase Receipt', pr) - pr_items = pr_bean.doclist.get({"parentfield": "purchase_tax_details"}) - idx = max([d.idx for d in pr_items]) if pr_items else 0 + pr_doc = frappe.get_doc('Purchase Receipt', pr) + pr_items = pr_doc.get("purchase_tax_details") - for lc in self.doclist.get({"parentfield": "landed_cost_details"}): - amt = flt(lc.amount) * flt(pr_bean.doc.net_total)/ flt(total_amt) + for lc in self.get("landed_cost_details"): + amt = flt(lc.amount) * flt(pr_doc.net_total)/ flt(total_amt) - matched_row = pr_bean.doclist.get({ - "parentfield": "other_charges", + matched_row = pr_doc.get("other_charges", { "category": "Valuation", "add_deduct_tax": "Add", "charge_type": "Actual", @@ -52,7 +48,7 @@ class DocType: }) if not matched_row: # add if not exists - ch = addchild(pr_bean.doc, 'other_charges', 'Purchase Taxes and Charges') + ch = pr_doc.append("other_charges") ch.category = 'Valuation' ch.add_deduct_tax = 'Add' ch.charge_type = 'Actual' @@ -62,17 +58,15 @@ class DocType: ch.rate = amt ch.tax_amount = amt ch.docstatus = 1 - ch.idx = idx + 1 ch.save(1) - idx += 1 else: # overwrite if exists matched_row[0].rate = amt matched_row[0].tax_amount = amt matched_row[0].cost_center = lc.cost_center - pr_bean.run_method("validate") - for d in pr_bean.doclist: - d.save() + pr_doc.run_method("validate") + for d in pr_doc.get_all_children(): + d.db_update() def get_total_pr_amt(self, purchase_receipts): return frappe.db.sql("""SELECT SUM(net_total) FROM `tabPurchase Receipt` @@ -81,9 +75,9 @@ class DocType: def cancel_pr(self, purchase_receipts): for pr in purchase_receipts: - pr_bean = frappe.bean("Purchase Receipt", pr) + pr_doc = frappe.get_doc("Purchase Receipt", pr) - pr_bean.run_method("update_ordered_qty") + pr_doc.run_method("update_ordered_qty") frappe.db.sql("""delete from `tabStock Ledger Entry` where voucher_type='Purchase Receipt' and voucher_no=%s""", pr) @@ -92,7 +86,7 @@ class DocType: def submit_pr(self, purchase_receipts): for pr in purchase_receipts: - pr_bean = frappe.bean("Purchase Receipt", pr) - pr_bean.run_method("update_ordered_qty") - pr_bean.run_method("update_stock") - pr_bean.run_method("make_gl_entries") \ No newline at end of file + pr_doc = frappe.get_doc("Purchase Receipt", pr) + pr_doc.run_method("update_ordered_qty") + pr_doc.run_method("update_stock") + pr_doc.run_method("make_gl_entries") \ No newline at end of file diff --git a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt deleted file mode 100644 index 587d0e313c0..00000000000 --- a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.txt +++ /dev/null @@ -1,95 +0,0 @@ -[ - { - "creation": "2013-01-22 16:50:39", - "docstatus": 0, - "modified": "2013-12-20 19:23:18", - "modified_by": "Administrator", - "owner": "wasim@webnotestech.com" - }, - { - "doctype": "DocType", - "icon": "icon-magic", - "issingle": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Landed Cost Wizard", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Landed Cost Wizard", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Landed Cost Wizard" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "label": "Select Purchase Receipts", - "options": "Simple" - }, - { - "doctype": "DocField", - "fieldname": "lc_pr_details", - "fieldtype": "Table", - "label": "Landed Cost Purchase Receipts", - "options": "Landed Cost Purchase Receipt" - }, - { - "doctype": "DocField", - "fieldname": "section_break1", - "fieldtype": "Section Break", - "label": "Add Taxes and Charges" - }, - { - "doctype": "DocField", - "fieldname": "landed_cost_details", - "fieldtype": "Table", - "label": "Landed Cost Items", - "options": "Landed Cost Item" - }, - { - "doctype": "DocField", - "fieldname": "update_landed_cost", - "fieldtype": "Button", - "label": "Update Landed Cost", - "options": "update_landed_cost" - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm", - "role": "Purchase Manager" - }, - { - "doctype": "DocPerm", - "role": "Purchase User" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index c83077530c3..081469b1038 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -80,7 +80,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten schedule_date: function(doc, cdt, cdn) { var val = locals[cdt][cdn].schedule_date; if(val) { - $.each(frappe.model.get("Material Request Item", { parent: cur_frm.doc.name }), function(i, d) { + $.each((doc.indent_details || []), function(i, d) { if(!d.schedule_date) { d.schedule_date = val; } @@ -172,7 +172,7 @@ cur_frm.cscript['Stop Material Request'] = function() { var check = confirm(frappe._("Do you really want to STOP this Material Request?")); if (check) { - return $c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': frappe.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) { + return $c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': doc}, function(r,rt) { cur_frm.refresh(); }); } @@ -183,7 +183,7 @@ cur_frm.cscript['Unstop Material Request'] = function(){ var check = confirm(frappe._("Do you really want to UNSTOP this Material Request?")); if (check) { - return $c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': frappe.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) { + return $c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': doc}, function(r,rt) { cur_frm.refresh(); }); } diff --git a/erpnext/stock/doctype/material_request/material_request.json b/erpnext/stock/doctype/material_request/material_request.json new file mode 100644 index 00000000000..7db60dd21c1 --- /dev/null +++ b/erpnext/stock/doctype/material_request/material_request.json @@ -0,0 +1,297 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-03-07 14:48:38.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "type_section", + "fieldtype": "Section Break", + "label": "Basic Info", + "options": "icon-pushpin", + "permlevel": 0 + }, + { + "fieldname": "material_request_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Type", + "options": "Purchase\nTransfer", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "column_break_2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "MREQ-\nIDT", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "description": "Select the relevant company name if you have multiple companies", + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "items", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0 + }, + { + "allow_on_submit": 0, + "fieldname": "indent_details", + "fieldtype": "Table", + "label": "Material Request Items", + "no_copy": 0, + "oldfieldname": "indent_details", + "oldfieldtype": "Table", + "options": "Material Request Item", + "permlevel": 0 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "requested_by", + "fieldtype": "Data", + "label": "Requested For", + "permlevel": 0 + }, + { + "fieldname": "transaction_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Transaction Date", + "no_copy": 1, + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_width": "100px", + "reqd": 1, + "search_index": 1, + "width": "100px" + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nDraft\nSubmitted\nStopped\nCancelled", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "search_index": 1, + "width": "100px" + }, + { + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Select", + "label": "Letter Head", + "oldfieldname": "letter_head", + "oldfieldtype": "Select", + "options": "link:Letter Head", + "permlevel": 0, + "print_hide": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1 + }, + { + "description": "% of materials ordered against this Material Request", + "fieldname": "per_ordered", + "fieldtype": "Percent", + "in_list_view": 1, + "label": "% Completed", + "no_copy": 1, + "oldfieldname": "per_ordered", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "oldfieldtype": "Section Break", + "options": "icon-legal", + "permlevel": 0 + }, + { + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + }, + { + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Terms and Conditions Content", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", + "permlevel": 0 + } + ], + "icon": "icon-ticket", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:48:57.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Material Request", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "submit": 1, + "write": 1 + } + ], + "read_only_onload": 1, + "search_fields": "status,transaction_date" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py index 2fca85bbb73..156751e89c1 100644 --- a/erpnext/stock/doctype/material_request/material_request.py +++ b/erpnext/stock/doctype/material_request/material_request.py @@ -8,24 +8,19 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt -from frappe.model.utils import getlist -from frappe.model.code import get_obj from frappe import msgprint, _ from erpnext.controllers.buying_controller import BuyingController -class DocType(BuyingController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.tname = 'Material Request Item' - self.fname = 'indent_details' +class MaterialRequest(BuyingController): + tname = 'Material Request Item' + fname = 'indent_details' def check_if_already_pulled(self): - pass#if self.[d.sales_order_no for d in getlist(self.doclist, 'indent_details')] + pass#if self.[d.sales_order_no for d in self.get('indent_details')] def validate_qty_against_so(self): so_items = {} # Format --> {'SO/00001': {'Item/001': 120, 'Item/002': 24}} - for d in getlist(self.doclist, 'indent_details'): + for d in self.get('indent_details'): if d.sales_order_no: if not so_items.has_key(d.sales_order_no): so_items[d.sales_order_no] = {d.item_code: flt(d.qty)} @@ -34,273 +29,269 @@ class DocType(BuyingController): so_items[d.sales_order_no][d.item_code] = flt(d.qty) else: so_items[d.sales_order_no][d.item_code] += flt(d.qty) - + for so_no in so_items.keys(): for item in so_items[so_no].keys(): - already_indented = frappe.db.sql("""select sum(ifnull(qty, 0)) - from `tabMaterial Request Item` - where item_code = %s and sales_order_no = %s and - docstatus = 1 and parent != %s""", (item, so_no, self.doc.name)) + already_indented = frappe.db.sql("""select sum(ifnull(qty, 0)) + from `tabMaterial Request Item` + where item_code = %s and sales_order_no = %s and + docstatus = 1 and parent != %s""", (item, so_no, self.name)) already_indented = already_indented and flt(already_indented[0][0]) or 0 - - actual_so_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabSales Order Item` + + actual_so_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabSales Order Item` where parent = %s and item_code = %s and docstatus = 1""", (so_no, item)) actual_so_qty = actual_so_qty and flt(actual_so_qty[0][0]) or 0 - + if actual_so_qty and (flt(so_items[so_no][item]) + already_indented > actual_so_qty): frappe.throw("You can raise indent of maximum qty: %s for item: %s against sales order: %s\ \n Anyway, you can add more qty in new row for the same item." % (actual_so_qty - already_indented, item, so_no)) - + def validate_schedule_date(self): - for d in getlist(self.doclist, 'indent_details'): - if d.schedule_date < self.doc.transaction_date: + for d in self.get('indent_details'): + if d.schedule_date < self.transaction_date: frappe.throw(_("Expected Date cannot be before Material Request Date")) - + # Validate # --------------------- def validate(self): - super(DocType, self).validate() - + super(MaterialRequest, self).validate() + self.validate_schedule_date() self.validate_uom_is_integer("uom", "qty") - - if not self.doc.status: - self.doc.status = "Draft" + + if not self.status: + self.status = "Draft" from erpnext.utilities import validate_status - validate_status(self.doc.status, ["Draft", "Submitted", "Stopped", "Cancelled"]) - + validate_status(self.status, ["Draft", "Submitted", "Stopped", "Cancelled"]) + self.validate_value("material_request_type", "in", ["Purchase", "Transfer"]) - pc_obj = get_obj(dt='Purchase Common') + pc_obj = frappe.get_doc('Purchase Common') pc_obj.validate_for_items(self) - + # self.validate_qty_against_so() # NOTE: Since Item BOM and FG quantities are combined, using current data, it cannot be validated # Though the creation of Material Request from a Production Plan can be rethought to fix this - + def update_bin(self, is_submit, is_stopped): """ Update Quantity Requested for Purchase in Bin for Material Request of type 'Purchase'""" - + from erpnext.stock.utils import update_bin - for d in getlist(self.doclist, 'indent_details'): + for d in self.get('indent_details'): if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes": if not d.warehouse: - frappe.throw("Please Enter Warehouse for Item %s as it is stock item" + frappe.throw("Please Enter Warehouse for Item %s as it is stock item" % cstr(d.item_code)) - + qty =flt(d.qty) if is_stopped: qty = (d.qty > d.ordered_qty) and flt(flt(d.qty) - flt(d.ordered_qty)) or 0 - + args = { "item_code": d.item_code, "warehouse": d.warehouse, "indented_qty": (is_submit and 1 or -1) * flt(qty), - "posting_date": self.doc.transaction_date + "posting_date": self.transaction_date } - update_bin(args) - + update_bin(args) + def on_submit(self): - frappe.db.set(self.doc, 'status', 'Submitted') + frappe.db.set(self, 'status', 'Submitted') self.update_bin(is_submit = 1, is_stopped = 0) - + def check_modified_date(self): - mod_db = frappe.db.sql("""select modified from `tabMaterial Request` where name = %s""", - self.doc.name) + mod_db = frappe.db.sql("""select modified from `tabMaterial Request` where name = %s""", + self.name) date_diff = frappe.db.sql("""select TIMEDIFF('%s', '%s')""" - % (mod_db[0][0], cstr(self.doc.modified))) - + % (mod_db[0][0], cstr(self.modified))) + if date_diff and date_diff[0][0]: - frappe.throw(cstr(self.doc.doctype) + " => " + cstr(self.doc.name) + " has been modified. Please Refresh.") + frappe.throw(cstr(self.doctype) + " => " + cstr(self.name) + " has been modified. Please Refresh.") def update_status(self, status): self.check_modified_date() - # Step 1:=> Update Bin self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1) - - # Step 2:=> Set status - frappe.db.set(self.doc, 'status', cstr(status)) - - # Step 3:=> Acknowledge User - msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status))) - + frappe.db.set(self, 'status', cstr(status)) + msgprint(self.doctype + ": " + self.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status))) def on_cancel(self): # Step 1:=> Get Purchase Common Obj - pc_obj = get_obj(dt='Purchase Common') - + pc_obj = frappe.get_doc('Purchase Common') + # Step 2:=> Check for stopped status - pc_obj.check_for_stopped_status(self.doc.doctype, self.doc.name) - + pc_obj.check_for_stopped_status(self.doctype, self.name) + # Step 3:=> Check if Purchase Order has been submitted against current Material Request - pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Order', docname = self.doc.name, detail_doctype = 'Purchase Order Item') + pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Order', docname = self.name, detail_doctype = 'Purchase Order Item') # Step 4:=> Update Bin - self.update_bin(is_submit = 0, is_stopped = (cstr(self.doc.status) == 'Stopped') and 1 or 0) - + self.update_bin(is_submit = 0, is_stopped = (cstr(self.status) == 'Stopped') and 1 or 0) + # Step 5:=> Set Status - frappe.db.set(self.doc,'status','Cancelled') - + frappe.db.set(self,'status','Cancelled') + def update_completed_qty(self, mr_items=None): - if self.doc.material_request_type != "Transfer": + if self.material_request_type != "Transfer": return - - item_doclist = self.doclist.get({"parentfield": "indent_details"}) - + + item_doclist = self.get("indent_details") + if not mr_items: mr_items = [d.name for d in item_doclist] - + per_ordered = 0.0 for d in item_doclist: if d.name in mr_items: - d.ordered_qty = flt(frappe.db.sql("""select sum(transfer_qty) - from `tabStock Entry Detail` where material_request = %s - and material_request_item = %s and docstatus = 1""", - (self.doc.name, d.name))[0][0]) + d.ordered_qty = flt(frappe.db.sql("""select sum(transfer_qty) + from `tabStock Entry Detail` where material_request = %s + and material_request_item = %s and docstatus = 1""", + (self.name, d.name))[0][0]) frappe.db.set_value(d.doctype, d.name, "ordered_qty", d.ordered_qty) - + # note: if qty is 0, its row is still counted in len(item_doclist) # hence adding 1 to per_ordered if (d.ordered_qty > d.qty) or not d.qty: per_ordered += 1.0 elif d.qty > 0: per_ordered += flt(d.ordered_qty / flt(d.qty)) - - self.doc.per_ordered = flt((per_ordered / flt(len(item_doclist))) * 100.0, 2) - frappe.db.set_value(self.doc.doctype, self.doc.name, "per_ordered", self.doc.per_ordered) - -def update_completed_qty(bean, method): - if bean.doc.doctype == "Stock Entry": + + self.per_ordered = flt((per_ordered / flt(len(item_doclist))) * 100.0, 2) + frappe.db.set_value(self.doctype, self.name, "per_ordered", self.per_ordered) + +def update_completed_qty(doc, method): + if doc.doctype == "Stock Entry": material_request_map = {} - - for d in bean.doclist.get({"parentfield": "mtn_details"}): + + for d in doc.get("mtn_details"): if d.material_request: material_request_map.setdefault(d.material_request, []).append(d.material_request_item) - + for mr_name, mr_items in material_request_map.items(): - mr_obj = frappe.get_obj("Material Request", mr_name, with_children=1) - mr_doctype = frappe.get_doctype("Material Request") - - if mr_obj.doc.status in ["Stopped", "Cancelled"]: - frappe.throw(_("Material Request") + ": %s, " % mr_obj.doc.name - + _(mr_doctype.get_label("status")) + " = %s. " % _(mr_obj.doc.status) + mr_obj = frappe.get_doc("Material Request", mr_name) + + if mr_obj.status in ["Stopped", "Cancelled"]: + frappe.throw(_("Material Request") + ": %s, " % mr_obj.name + + _(mr_obj.meta.get_label("status")) + " = %s. " % _(mr_obj.status) + _("Cannot continue."), exc=frappe.InvalidStatusError) - - _update_requested_qty(bean, mr_obj, mr_items) - + + _update_requested_qty(doc, mr_obj, mr_items) + # update ordered percentage and qty mr_obj.update_completed_qty(mr_items) - -def _update_requested_qty(bean, mr_obj, mr_items): + +def _update_requested_qty(doc, mr_obj, mr_items): """update requested qty (before ordered_qty is updated)""" from erpnext.stock.utils import update_bin for mr_item_name in mr_items: - mr_item = mr_obj.doclist.getone({"parentfield": "indent_details", "name": mr_item_name}) - se_detail = bean.doclist.getone({"parentfield": "mtn_details", - "material_request": mr_obj.doc.name, "material_request_item": mr_item_name}) - - mr_item.ordered_qty = flt(mr_item.ordered_qty) - mr_item.qty = flt(mr_item.qty) - se_detail.transfer_qty = flt(se_detail.transfer_qty) - - if se_detail.docstatus == 2 and mr_item.ordered_qty > mr_item.qty \ - and se_detail.transfer_qty == mr_item.ordered_qty: - add_indented_qty = mr_item.qty - elif se_detail.docstatus == 1 and \ - mr_item.ordered_qty + se_detail.transfer_qty > mr_item.qty: - add_indented_qty = mr_item.qty - mr_item.ordered_qty - else: - add_indented_qty = se_detail.transfer_qty - - update_bin({ - "item_code": se_detail.item_code, - "warehouse": se_detail.t_warehouse, - "indented_qty": (se_detail.docstatus==2 and 1 or -1) * add_indented_qty, - "posting_date": bean.doc.posting_date, - }) + mr_item = mr_obj.get("indent_details", {"name": mr_item_name}) + se_detail = doc.get("mtn_details", {"material_request": mr_obj.name, + "material_request_item": mr_item_name}) -def set_missing_values(source, target_doclist): - po = frappe.bean(target_doclist) + if mr_item and se_detail: + mr_item = mr_item[0] + se_detail = se_detail[0] + mr_item.ordered_qty = flt(mr_item.ordered_qty) + mr_item.qty = flt(mr_item.qty) + se_detail.transfer_qty = flt(se_detail.transfer_qty) + + if se_detail.docstatus == 2 and mr_item.ordered_qty > mr_item.qty \ + and se_detail.transfer_qty == mr_item.ordered_qty: + add_indented_qty = mr_item.qty + elif se_detail.docstatus == 1 and \ + mr_item.ordered_qty + se_detail.transfer_qty > mr_item.qty: + add_indented_qty = mr_item.qty - mr_item.ordered_qty + else: + add_indented_qty = se_detail.transfer_qty + + update_bin({ + "item_code": se_detail.item_code, + "warehouse": se_detail.t_warehouse, + "indented_qty": (se_detail.docstatus==2 and 1 or -1) * add_indented_qty, + "posting_date": doc.posting_date, + }) + +def set_missing_values(source, target_doc): + po = frappe.get_doc(target_doc) po.run_method("set_missing_values") - + def update_item(obj, target, source_parent): target.conversion_factor = 1 target.qty = flt(obj.qty) - flt(obj.ordered_qty) @frappe.whitelist() -def make_purchase_order(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist +def make_purchase_order(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc - doclist = get_mapped_doclist("Material Request", source_name, { + doclist = get_mapped_doc("Material Request", source_name, { "Material Request": { - "doctype": "Purchase Order", + "doctype": "Purchase Order", "validation": { "docstatus": ["=", 1], "material_request_type": ["=", "Purchase"] } - }, + }, "Material Request Item": { - "doctype": "Purchase Order Item", + "doctype": "Purchase Order Item", "field_map": [ - ["name", "prevdoc_detail_docname"], - ["parent", "prevdoc_docname"], - ["parenttype", "prevdoc_doctype"], + ["name", "prevdoc_detail_docname"], + ["parent", "prevdoc_docname"], + ["parenttype", "prevdoc_doctype"], ["uom", "stock_uom"], ["uom", "uom"] ], "postprocess": update_item } - }, target_doclist, set_missing_values) + }, target_doc, set_missing_values) + + return doclist - return [d.fields for d in doclist] - @frappe.whitelist() -def make_purchase_order_based_on_supplier(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist - if target_doclist: - if isinstance(target_doclist, basestring): +def make_purchase_order_based_on_supplier(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc + if target_doc: + if isinstance(target_doc, basestring): import json - target_doclist = frappe.doclist(json.loads(target_doclist)) - target_doclist = target_doclist.get({"parentfield": ["!=", "po_details"]}) - + target_doc = frappe.get_doc(json.loads(target_doc)) + target_doc = target_doc.get({"parentfield": ["!=", "po_details"]}) + material_requests, supplier_items = get_material_requests_based_on_supplier(source_name) - - def postprocess(source, target_doclist): - target_doclist[0].supplier = source_name - set_missing_values(source, target_doclist) - - po_items = target_doclist.get({"parentfield": "po_details"}) - target_doclist = target_doclist.get({"parentfield": ["!=", "po_details"]}) + \ - [d for d in po_items - if d.fields.get("item_code") in supplier_items and d.fields.get("qty") > 0] - - return target_doclist - + + def postprocess(source, target_doc): + target_doc[0].supplier = source_name + set_missing_values(source, target_doc) + + po_items = target_doc.get({"parentfield": "po_details"}) + target_doc = target_doc.get({"parentfield": ["!=", "po_details"]}) + \ + [d for d in po_items + if d.get("item_code") in supplier_items and d.get("qty") > 0] + + return target_doc + for mr in material_requests: - target_doclist = get_mapped_doclist("Material Request", mr, { + target_doc = get_mapped_doc("Material Request", mr, { "Material Request": { - "doctype": "Purchase Order", - }, + "doctype": "Purchase Order", + }, "Material Request Item": { - "doctype": "Purchase Order Item", + "doctype": "Purchase Order Item", "field_map": [ - ["name", "prevdoc_detail_docname"], - ["parent", "prevdoc_docname"], - ["parenttype", "prevdoc_doctype"], + ["name", "prevdoc_detail_docname"], + ["parent", "prevdoc_docname"], + ["parenttype", "prevdoc_doctype"], ["uom", "stock_uom"], ["uom", "uom"] ], "postprocess": update_item } - }, target_doclist, postprocess) - - return [d.fields for d in target_doclist] - + }, target_doc, postprocess) + + return target_doc.as_dict() + def get_material_requests_based_on_supplier(supplier): - supplier_items = [d[0] for d in frappe.db.get_values("Item", + supplier_items = [d[0] for d in frappe.db.get_values("Item", {"default_supplier": supplier})] - material_requests = frappe.db.sql_list("""select distinct mr.name + material_requests = frappe.db.sql_list("""select distinct mr.name from `tabMaterial Request` mr, `tabMaterial Request Item` mr_item where mr.name = mr_item.parent and mr_item.item_code in (%s) @@ -310,63 +301,63 @@ def get_material_requests_based_on_supplier(supplier): and mr.status != 'Stopped'""" % ', '.join(['%s']*len(supplier_items)), tuple(supplier_items)) return material_requests, supplier_items - -@frappe.whitelist() -def make_supplier_quotation(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist - doclist = get_mapped_doclist("Material Request", source_name, { +@frappe.whitelist() +def make_supplier_quotation(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc + + doclist = get_mapped_doc("Material Request", source_name, { "Material Request": { - "doctype": "Supplier Quotation", + "doctype": "Supplier Quotation", "validation": { "docstatus": ["=", 1], "material_request_type": ["=", "Purchase"] } - }, + }, "Material Request Item": { - "doctype": "Supplier Quotation Item", + "doctype": "Supplier Quotation Item", "field_map": { - "name": "prevdoc_detail_docname", - "parent": "prevdoc_docname", + "name": "prevdoc_detail_docname", + "parent": "prevdoc_docname", "parenttype": "prevdoc_doctype" } } - }, target_doclist, set_missing_values) + }, target_doc, set_missing_values) + + return doclist - return [d.fields for d in doclist] - @frappe.whitelist() -def make_stock_entry(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist - +def make_stock_entry(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc + def update_item(obj, target, source_parent): target.conversion_factor = 1 target.qty = flt(obj.qty) - flt(obj.ordered_qty) target.transfer_qty = flt(obj.qty) - flt(obj.ordered_qty) - + def set_missing_values(source, target): - target[0].purpose = "Material Transfer" - se = frappe.bean(target) + target.purpose = "Material Transfer" + se = frappe.get_doc(target) se.run_method("get_stock_and_rate") - doclist = get_mapped_doclist("Material Request", source_name, { + doclist = get_mapped_doc("Material Request", source_name, { "Material Request": { - "doctype": "Stock Entry", + "doctype": "Stock Entry", "validation": { "docstatus": ["=", 1], "material_request_type": ["=", "Transfer"] } - }, + }, "Material Request Item": { - "doctype": "Stock Entry Detail", + "doctype": "Stock Entry Detail", "field_map": { - "name": "material_request_item", - "parent": "material_request", - "uom": "stock_uom", + "name": "material_request_item", + "parent": "material_request", + "uom": "stock_uom", "warehouse": "t_warehouse" }, "postprocess": update_item } - }, target_doclist, set_missing_values) + }, target_doc, set_missing_values) - return [d.fields for d in doclist] + return doclist diff --git a/erpnext/stock/doctype/material_request/material_request.txt b/erpnext/stock/doctype/material_request/material_request.txt deleted file mode 100644 index cb027918bd4..00000000000 --- a/erpnext/stock/doctype/material_request/material_request.txt +++ /dev/null @@ -1,286 +0,0 @@ -[ - { - "creation": "2013-03-07 14:48:38", - "docstatus": 0, - "modified": "2014-01-20 17:48:57", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "icon": "icon-ticket", - "is_submittable": 1, - "module": "Stock", - "name": "__common__", - "read_only_onload": 1, - "search_fields": "status,transaction_date" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Material Request", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Material Request", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Material Request" - }, - { - "doctype": "DocField", - "fieldname": "type_section", - "fieldtype": "Section Break", - "label": "Basic Info", - "options": "icon-pushpin" - }, - { - "doctype": "DocField", - "fieldname": "material_request_type", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Type", - "options": "Purchase\nTransfer", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "MREQ-\nIDT", - "print_hide": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "description": "Select the relevant company name if you have multiple companies", - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "print_width": "150px", - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "items", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart" - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "indent_details", - "fieldtype": "Table", - "label": "Material Request Items", - "no_copy": 0, - "oldfieldname": "indent_details", - "oldfieldtype": "Table", - "options": "Material Request Item" - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "requested_by", - "fieldtype": "Data", - "label": "Requested For" - }, - { - "doctype": "DocField", - "fieldname": "transaction_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Transaction Date", - "no_copy": 1, - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "print_width": "100px", - "reqd": 1, - "search_index": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "print_width": "150px", - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nDraft\nSubmitted\nStopped\nCancelled", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "search_index": 1, - "width": "100px" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Select", - "label": "Letter Head", - "oldfieldname": "letter_head", - "oldfieldtype": "Select", - "options": "link:Letter Head", - "print_hide": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "options": "Print Heading", - "print_hide": 1 - }, - { - "description": "% of materials ordered against this Material Request", - "doctype": "DocField", - "fieldname": "per_ordered", - "fieldtype": "Percent", - "in_list_view": 1, - "label": "% Completed", - "no_copy": 1, - "oldfieldname": "per_ordered", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "oldfieldtype": "Section Break", - "options": "icon-legal" - }, - { - "doctype": "DocField", - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "print_hide": 1, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Terms and Conditions Content", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor" - }, - { - "doctype": "DocPerm", - "role": "Purchase Manager" - }, - { - "doctype": "DocPerm", - "role": "Material Manager" - }, - { - "doctype": "DocPerm", - "role": "Material User" - }, - { - "doctype": "DocPerm", - "role": "Purchase User" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/material_request/test_material_request.py b/erpnext/stock/doctype/material_request/test_material_request.py index a41425bf85f..7719dfd90af 100644 --- a/erpnext/stock/doctype/material_request/test_material_request.py +++ b/erpnext/stock/doctype/material_request/test_material_request.py @@ -15,240 +15,259 @@ class TestMaterialRequest(unittest.TestCase): def test_make_purchase_order(self): from erpnext.stock.doctype.material_request.material_request import make_purchase_order - mr = frappe.bean(copy=test_records[0]).insert() + mr = frappe.copy_doc(test_records[0]).insert() - self.assertRaises(frappe.ValidationError, make_purchase_order, - mr.doc.name) + self.assertRaises(frappe.ValidationError, make_purchase_order, + mr.name) - mr = frappe.bean("Material Request", mr.doc.name) + mr = frappe.get_doc("Material Request", mr.name) mr.submit() - po = make_purchase_order(mr.doc.name) - - self.assertEquals(po[0]["doctype"], "Purchase Order") - self.assertEquals(len(po), len(mr.doclist)) - + po = make_purchase_order(mr.name) + + self.assertEquals(po.doctype, "Purchase Order") + self.assertEquals(len(po.get("po_details")), len(mr.get("indent_details"))) + def test_make_supplier_quotation(self): from erpnext.stock.doctype.material_request.material_request import make_supplier_quotation - mr = frappe.bean(copy=test_records[0]).insert() + mr = frappe.copy_doc(test_records[0]).insert() - self.assertRaises(frappe.ValidationError, make_supplier_quotation, - mr.doc.name) + self.assertRaises(frappe.ValidationError, make_supplier_quotation, mr.name) - mr = frappe.bean("Material Request", mr.doc.name) + mr = frappe.get_doc("Material Request", mr.name) mr.submit() - sq = make_supplier_quotation(mr.doc.name) - - self.assertEquals(sq[0]["doctype"], "Supplier Quotation") - self.assertEquals(len(sq), len(mr.doclist)) - - + sq = make_supplier_quotation(mr.name) + + self.assertEquals(sq.doctype, "Supplier Quotation") + self.assertEquals(len(sq.get("quotation_items")), len(mr.get("indent_details"))) + + def test_make_stock_entry(self): from erpnext.stock.doctype.material_request.material_request import make_stock_entry - mr = frappe.bean(copy=test_records[0]).insert() + mr = frappe.copy_doc(test_records[0]).insert() - self.assertRaises(frappe.ValidationError, make_stock_entry, - mr.doc.name) + self.assertRaises(frappe.ValidationError, make_stock_entry, + mr.name) - mr = frappe.bean("Material Request", mr.doc.name) - mr.doc.material_request_type = "Transfer" + mr = frappe.get_doc("Material Request", mr.name) + mr.material_request_type = "Transfer" mr.submit() - se = make_stock_entry(mr.doc.name) - - self.assertEquals(se[0]["doctype"], "Stock Entry") - self.assertEquals(len(se), len(mr.doclist)) - - def _test_expected(self, doclist, expected_values): - for i, expected in enumerate(expected_values): - for fieldname, val in expected.items(): - self.assertEquals(val, doclist[i].fields.get(fieldname)) - + se = make_stock_entry(mr.name) + + self.assertEquals(se.doctype, "Stock Entry") + self.assertEquals(len(se.get("mtn_details")), len(mr.get("indent_details"))) + def _test_requested_qty(self, qty1, qty2): self.assertEqual(flt(frappe.db.get_value("Bin", {"item_code": "_Test Item Home Desktop 100", "warehouse": "_Test Warehouse - _TC"}, "indented_qty")), qty1) self.assertEqual(flt(frappe.db.get_value("Bin", {"item_code": "_Test Item Home Desktop 200", "warehouse": "_Test Warehouse - _TC"}, "indented_qty")), qty2) - + def _insert_stock_entry(self, qty1, qty2): - se = frappe.bean([ - { - "company": "_Test Company", - "doctype": "Stock Entry", - "posting_date": "2013-03-01", - "posting_time": "00:00:00", + se = frappe.get_doc({ + "company": "_Test Company", + "doctype": "Stock Entry", + "posting_date": "2013-03-01", + "posting_time": "00:00:00", "purpose": "Material Receipt", "fiscal_year": "_Test Fiscal Year 2013", - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item Home Desktop 100", - "parentfield": "mtn_details", - "incoming_rate": 100, - "qty": qty1, - "stock_uom": "_Test UOM 1", - "transfer_qty": qty1, - "uom": "_Test UOM 1", - "t_warehouse": "_Test Warehouse 1 - _TC", - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item Home Desktop 200", - "parentfield": "mtn_details", - "incoming_rate": 100, - "qty": qty2, - "stock_uom": "_Test UOM 1", - "transfer_qty": qty2, - "uom": "_Test UOM 1", - "t_warehouse": "_Test Warehouse 1 - _TC", - }, - ]) + "mtn_details": [ + { + "conversion_factor": 1.0, + "doctype": "Stock Entry Detail", + "item_code": "_Test Item Home Desktop 100", + "parentfield": "mtn_details", + "incoming_rate": 100, + "qty": qty1, + "stock_uom": "_Test UOM 1", + "transfer_qty": qty1, + "uom": "_Test UOM 1", + "t_warehouse": "_Test Warehouse 1 - _TC", + }, + { + "conversion_factor": 1.0, + "doctype": "Stock Entry Detail", + "item_code": "_Test Item Home Desktop 200", + "parentfield": "mtn_details", + "incoming_rate": 100, + "qty": qty2, + "stock_uom": "_Test UOM 1", + "transfer_qty": qty2, + "uom": "_Test UOM 1", + "t_warehouse": "_Test Warehouse 1 - _TC", + } + ] + }) se.insert() se.submit() - + def test_completed_qty_for_purchase(self): frappe.db.sql("""delete from `tabBin`""") - + # submit material request of type Purchase - mr = frappe.bean(copy=test_records[0]) + mr = frappe.copy_doc(test_records[0]) mr.insert() mr.submit() - + # check if per complete is None - self._test_expected(mr.doclist, [{"per_ordered": None}, {"ordered_qty": None}, {"ordered_qty": None}]) - + self.assertEquals(mr.per_ordered, None) + self.assertEquals(mr.get("indent_details")[0].ordered_qty, 0) + self.assertEquals(mr.get("indent_details")[1].ordered_qty, 0) + self._test_requested_qty(54.0, 3.0) - + # map a purchase order from erpnext.stock.doctype.material_request.material_request import make_purchase_order - po_doclist = make_purchase_order(mr.doc.name) - po_doclist[0]["supplier"] = "_Test Supplier" - po_doclist[0]["transaction_date"] = "2013-07-07" - po_doclist[1]["qty"] = 27.0 - po_doclist[2]["qty"] = 1.5 - po_doclist[1]["schedule_date"] = "2013-07-09" - po_doclist[2]["schedule_date"] = "2013-07-09" + po_doc = make_purchase_order(mr.name) + po_doc.supplier = "_Test Supplier" + po_doc.transaction_date = "2013-07-07" + po_doc.get("po_details")[0].qty = 27.0 + po_doc.get("po_details")[1].qty = 1.5 + po_doc.get("po_details")[0].schedule_date = "2013-07-09" + po_doc.get("po_details")[1].schedule_date = "2013-07-09" + - # check for stopped status of Material Request - po = frappe.bean(copy=po_doclist) + po = frappe.copy_doc(po_doc) po.insert() - mr.obj.update_status('Stopped') - self.assertRaises(frappe.ValidationError, po.submit) - self.assertRaises(frappe.ValidationError, po.cancel) + po.load_from_db() + mr.update_status('Stopped') + self.assertRaises(frappe.InvalidStatusError, po.submit) + frappe.db.set(po, "docstatus", 1) + self.assertRaises(frappe.InvalidStatusError, po.cancel) - mr.obj.update_status('Submitted') - po = frappe.bean(copy=po_doclist) + # resubmit and check for per complete + mr.load_from_db() + mr.update_status('Submitted') + po = frappe.copy_doc(po_doc) po.insert() po.submit() - + # check if per complete is as expected mr.load_from_db() - self._test_expected(mr.doclist, [{"per_ordered": 50}, {"ordered_qty": 27.0}, {"ordered_qty": 1.5}]) + self.assertEquals(mr.per_ordered, 50) + self.assertEquals(mr.get("indent_details")[0].ordered_qty, 27.0) + self.assertEquals(mr.get("indent_details")[1].ordered_qty, 1.5) self._test_requested_qty(27.0, 1.5) - + po.cancel() # check if per complete is as expected mr.load_from_db() - self._test_expected(mr.doclist, [{"per_ordered": None}, {"ordered_qty": None}, {"ordered_qty": None}]) + self.assertEquals(mr.per_ordered, None) + self.assertEquals(mr.get("indent_details")[0].ordered_qty, None) + self.assertEquals(mr.get("indent_details")[1].ordered_qty, None) + self._test_requested_qty(54.0, 3.0) - + def test_completed_qty_for_transfer(self): frappe.db.sql("""delete from `tabBin`""") frappe.db.sql("""delete from `tabStock Ledger Entry`""") - + # submit material request of type Purchase - mr = frappe.bean(copy=test_records[0]) - mr.doc.material_request_type = "Transfer" + mr = frappe.copy_doc(test_records[0]) + mr.material_request_type = "Transfer" mr.insert() mr.submit() # check if per complete is None - self._test_expected(mr.doclist, [{"per_ordered": None}, {"ordered_qty": None}, {"ordered_qty": None}]) - + self.assertEquals(mr.per_ordered, None) + self.assertEquals(mr.get("indent_details")[0].ordered_qty, 0) + self.assertEquals(mr.get("indent_details")[1].ordered_qty, 0) + self._test_requested_qty(54.0, 3.0) from erpnext.stock.doctype.material_request.material_request import make_stock_entry - + # map a stock entry - se_doclist = make_stock_entry(mr.doc.name) - se_doclist[0].update({ + se_doc = make_stock_entry(mr.name) + se_doc.update({ "posting_date": "2013-03-01", "posting_time": "01:00", "fiscal_year": "_Test Fiscal Year 2013", }) - se_doclist[1].update({ + se_doc.get("mtn_details")[0].update({ "qty": 27.0, "transfer_qty": 27.0, "s_warehouse": "_Test Warehouse 1 - _TC", "incoming_rate": 1.0 }) - se_doclist[2].update({ + se_doc.get("mtn_details")[1].update({ "qty": 1.5, "transfer_qty": 1.5, "s_warehouse": "_Test Warehouse 1 - _TC", "incoming_rate": 1.0 }) - + # make available the qty in _Test Warehouse 1 before transfer self._insert_stock_entry(27.0, 1.5) - + # check for stopped status of Material Request - se = frappe.bean(copy=se_doclist) + se = frappe.copy_doc(se_doc) se.insert() - mr.obj.update_status('Stopped') - self.assertRaises(frappe.ValidationError, se.submit) - self.assertRaises(frappe.ValidationError, se.cancel) - - mr.obj.update_status('Submitted') - se = frappe.bean(copy=se_doclist) + mr.update_status('Stopped') + self.assertRaises(frappe.InvalidStatusError, se.submit) + + mr.update_status('Submitted') + se.submit() + mr.update_status('Stopped') + self.assertRaises(frappe.InvalidStatusError, se.cancel) + + mr.update_status('Submitted') + se = frappe.copy_doc(se_doc) se.insert() se.submit() - + # check if per complete is as expected mr.load_from_db() - self._test_expected(mr.doclist, [{"per_ordered": 50}, {"ordered_qty": 27.0}, {"ordered_qty": 1.5}]) + self.assertEquals(mr.per_ordered, 50) + self.assertEquals(mr.get("indent_details")[0].ordered_qty, 27.0) + self.assertEquals(mr.get("indent_details")[1].ordered_qty, 1.5) + self._test_requested_qty(27.0, 1.5) - + # check if per complete is as expected for Stock Entry cancelled se.cancel() mr.load_from_db() - self._test_expected(mr.doclist, [{"per_ordered": 0}, {"ordered_qty": 0}, {"ordered_qty": 0}]) + self.assertEquals(mr.per_ordered, 0) + self.assertEquals(mr.get("indent_details")[0].ordered_qty, 0) + self.assertEquals(mr.get("indent_details")[1].ordered_qty, 0) + self._test_requested_qty(54.0, 3.0) - + def test_completed_qty_for_over_transfer(self): frappe.db.sql("""delete from `tabBin`""") frappe.db.sql("""delete from `tabStock Ledger Entry`""") - + # submit material request of type Purchase - mr = frappe.bean(copy=test_records[0]) - mr.doc.material_request_type = "Transfer" + mr = frappe.copy_doc(test_records[0]) + mr.material_request_type = "Transfer" mr.insert() mr.submit() # check if per complete is None - self._test_expected(mr.doclist, [{"per_ordered": None}, {"ordered_qty": None}, {"ordered_qty": None}]) - + self.assertEquals(mr.per_ordered, None) + self.assertEquals(mr.get("indent_details")[0].ordered_qty, 0) + self.assertEquals(mr.get("indent_details")[1].ordered_qty, 0) + self._test_requested_qty(54.0, 3.0) - + # map a stock entry from erpnext.stock.doctype.material_request.material_request import make_stock_entry - se_doclist = make_stock_entry(mr.doc.name) - se_doclist[0].update({ + se_doc = make_stock_entry(mr.name) + se_doc.update({ "posting_date": "2013-03-01", "posting_time": "00:00", "fiscal_year": "_Test Fiscal Year 2013", }) - se_doclist[1].update({ + se_doc.get("mtn_details")[0].update({ "qty": 60.0, "transfer_qty": 60.0, "s_warehouse": "_Test Warehouse 1 - _TC", "incoming_rate": 1.0 }) - se_doclist[2].update({ + se_doc.get("mtn_details")[1].update({ "qty": 3.0, "transfer_qty": 3.0, "s_warehouse": "_Test Warehouse 1 - _TC", @@ -257,102 +276,75 @@ class TestMaterialRequest(unittest.TestCase): # make available the qty in _Test Warehouse 1 before transfer self._insert_stock_entry(60.0, 3.0) - + # check for stopped status of Material Request - se = frappe.bean(copy=se_doclist) + se = frappe.copy_doc(se_doc) se.insert() - mr.obj.update_status('Stopped') - self.assertRaises(frappe.ValidationError, se.submit) - self.assertRaises(frappe.ValidationError, se.cancel) - - mr.obj.update_status('Submitted') - se = frappe.bean(copy=se_doclist) + mr.update_status('Stopped') + self.assertRaises(frappe.InvalidStatusError, se.submit) + self.assertRaises(frappe.InvalidStatusError, se.cancel) + + mr.update_status('Submitted') + se = frappe.copy_doc(se_doc) se.insert() se.submit() - + # check if per complete is as expected mr.load_from_db() - self._test_expected(mr.doclist, [{"per_ordered": 100}, {"ordered_qty": 60.0}, {"ordered_qty": 3.0}]) + + self.assertEquals(mr.per_ordered, 100) + self.assertEquals(mr.get("indent_details")[0].ordered_qty, 60.0) + self.assertEquals(mr.get("indent_details")[1].ordered_qty, 3.0) self._test_requested_qty(0.0, 0.0) - + # check if per complete is as expected for Stock Entry cancelled se.cancel() mr.load_from_db() - self._test_expected(mr.doclist, [{"per_ordered": 0}, {"ordered_qty": 0}, {"ordered_qty": 0}]) + self.assertEquals(mr.per_ordered, 0) + self.assertEquals(mr.get("indent_details")[0].ordered_qty, 0) + self.assertEquals(mr.get("indent_details")[1].ordered_qty, 0) + self._test_requested_qty(54.0, 3.0) - + def test_incorrect_mapping_of_stock_entry(self): # submit material request of type Purchase - mr = frappe.bean(copy=test_records[0]) - mr.doc.material_request_type = "Transfer" + mr = frappe.copy_doc(test_records[0]) + mr.material_request_type = "Transfer" mr.insert() mr.submit() # map a stock entry from erpnext.stock.doctype.material_request.material_request import make_stock_entry - - se_doclist = make_stock_entry(mr.doc.name) - se_doclist[0].update({ + + se_doc = make_stock_entry(mr.name) + se_doc.update({ "posting_date": "2013-03-01", "posting_time": "00:00", "fiscal_year": "_Test Fiscal Year 2013", }) - se_doclist[1].update({ + se_doc.get("mtn_details")[0].update({ "qty": 60.0, "transfer_qty": 60.0, "s_warehouse": "_Test Warehouse - _TC", "t_warehouse": "_Test Warehouse 1 - _TC", "incoming_rate": 1.0 }) - se_doclist[2].update({ + se_doc.get("mtn_details")[1].update({ "qty": 3.0, "transfer_qty": 3.0, "s_warehouse": "_Test Warehouse 1 - _TC", "incoming_rate": 1.0 }) - + # check for stopped status of Material Request - se = frappe.bean(copy=se_doclist) + se = frappe.copy_doc(se_doc) self.assertRaises(frappe.MappingMismatchError, se.insert) - + def test_warehouse_company_validation(self): from erpnext.stock.utils import InvalidWarehouseCompany - mr = frappe.bean(copy=test_records[0]) - mr.doc.company = "_Test Company 1" + mr = frappe.copy_doc(test_records[0]) + mr.company = "_Test Company 1" self.assertRaises(InvalidWarehouseCompany, mr.insert) test_dependencies = ["Currency Exchange"] -test_records = [ - [ - { - "company": "_Test Company", - "doctype": "Material Request", - "fiscal_year": "_Test Fiscal Year 2013", - "transaction_date": "2013-02-18", - "material_request_type": "Purchase", - "naming_series": "_T-Material Request-" - }, - { - "description": "_Test Item Home Desktop 100", - "doctype": "Material Request Item", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "parentfield": "indent_details", - "qty": 54.0, - "schedule_date": "2013-02-18", - "uom": "_Test UOM 1", - "warehouse": "_Test Warehouse - _TC" - }, - { - "description": "_Test Item Home Desktop 200", - "doctype": "Material Request Item", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "parentfield": "indent_details", - "qty": 3.0, - "schedule_date": "2013-02-19", - "uom": "_Test UOM 1", - "warehouse": "_Test Warehouse - _TC" - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Material Request') diff --git a/erpnext/stock/doctype/material_request/test_records.json b/erpnext/stock/doctype/material_request/test_records.json new file mode 100644 index 00000000000..0337ac273d5 --- /dev/null +++ b/erpnext/stock/doctype/material_request/test_records.json @@ -0,0 +1,34 @@ +[ + { + "company": "_Test Company", + "doctype": "Material Request", + "fiscal_year": "_Test Fiscal Year 2013", + "indent_details": [ + { + "description": "_Test Item Home Desktop 100", + "doctype": "Material Request Item", + "item_code": "_Test Item Home Desktop 100", + "item_name": "_Test Item Home Desktop 100", + "parentfield": "indent_details", + "qty": 54.0, + "schedule_date": "2013-02-18", + "uom": "_Test UOM 1", + "warehouse": "_Test Warehouse - _TC" + }, + { + "description": "_Test Item Home Desktop 200", + "doctype": "Material Request Item", + "item_code": "_Test Item Home Desktop 200", + "item_name": "_Test Item Home Desktop 200", + "parentfield": "indent_details", + "qty": 3.0, + "schedule_date": "2013-02-19", + "uom": "_Test UOM 1", + "warehouse": "_Test Warehouse - _TC" + } + ], + "material_request_type": "Purchase", + "naming_series": "_T-Material Request-", + "transaction_date": "2013-02-18" + } +] \ No newline at end of file diff --git a/erpnext/stock/doctype/material_request_item/material_request_item.json b/erpnext/stock/doctype/material_request_item/material_request_item.json new file mode 100644 index 00000000000..bff669f5f7a --- /dev/null +++ b/erpnext/stock/doctype/material_request_item/material_request_item.json @@ -0,0 +1,240 @@ +{ + "autoname": "MREQD-.#####", + "creation": "2013-02-22 01:28:02.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_width": "100px", + "reqd": 1, + "search_index": 1, + "width": "100px" + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 0, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "100px", + "reqd": 0, + "search_index": 1, + "width": "100px" + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "250px", + "reqd": 1, + "width": "250px" + }, + { + "fieldname": "quantity_and_warehouse", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Quantity and Warehouse", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Quantity", + "no_copy": 0, + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "80px", + "reqd": 1, + "width": "80px" + }, + { + "fieldname": "warehouse", + "fieldtype": "Link", + "in_list_view": 1, + "label": "For Warehouse", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "uom", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Stock UOM", + "no_copy": 0, + "oldfieldname": "uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0, + "print_width": "70px", + "read_only": 1, + "reqd": 1, + "width": "70px" + }, + { + "allow_on_submit": 0, + "fieldname": "schedule_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Required Date", + "no_copy": 0, + "oldfieldname": "schedule_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "permlevel": 0 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "in_filter": 1, + "label": "Item Group", + "no_copy": 0, + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "brand", + "fieldtype": "Link", + "label": "Brand", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "width": "100px" + }, + { + "fieldname": "lead_time_date", + "fieldtype": "Date", + "in_list_view": 0, + "label": "Lead Time Date", + "no_copy": 1, + "oldfieldname": "lead_time_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "sales_order_no", + "fieldtype": "Link", + "label": "Sales Order No", + "no_copy": 0, + "options": "Sales Order", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "min_order_qty", + "fieldtype": "Float", + "label": "Min Order Qty", + "no_copy": 1, + "oldfieldname": "min_order_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "70px", + "read_only": 1, + "reqd": 0, + "width": "70px" + }, + { + "fieldname": "projected_qty", + "fieldtype": "Float", + "label": "Projected Qty", + "no_copy": 1, + "oldfieldname": "projected_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "70px", + "read_only": 1, + "width": "70px" + }, + { + "fieldname": "ordered_qty", + "fieldtype": "Float", + "label": "Completed Qty", + "no_copy": 1, + "oldfieldname": "ordered_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "label": "Page Break", + "no_copy": 1, + "oldfieldname": "page_break", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-03 11:35:26.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Material Request Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/material_request_item/material_request_item.py b/erpnext/stock/doctype/material_request_item/material_request_item.py index 968a25b6134..30101f3a88e 100644 --- a/erpnext/stock/doctype/material_request_item/material_request_item.py +++ b/erpnext/stock/doctype/material_request_item/material_request_item.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class MaterialRequestItem(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/material_request_item/material_request_item.txt b/erpnext/stock/doctype/material_request_item/material_request_item.txt deleted file mode 100644 index 56a4976bcac..00000000000 --- a/erpnext/stock/doctype/material_request_item/material_request_item.txt +++ /dev/null @@ -1,253 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:02", - "docstatus": 0, - "modified": "2014-02-03 11:35:26", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "MREQD-.#####", - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Material Request Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Material Request Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "print_width": "100px", - "reqd": 1, - "search_index": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 0, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "print_width": "100px", - "reqd": 0, - "search_index": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "print_width": "250px", - "reqd": 1, - "width": "250px" - }, - { - "doctype": "DocField", - "fieldname": "quantity_and_warehouse", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Quantity and Warehouse" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Quantity", - "no_copy": 0, - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "print_width": "80px", - "reqd": 1, - "width": "80px" - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "in_list_view": 1, - "label": "For Warehouse", - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 0, - "print_width": "100px", - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "uom", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Stock UOM", - "no_copy": 0, - "oldfieldname": "uom", - "oldfieldtype": "Link", - "options": "UOM", - "print_width": "70px", - "read_only": 1, - "reqd": 1, - "width": "70px" - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "schedule_date", - "fieldtype": "Date", - "in_list_view": 1, - "label": "Required Date", - "no_copy": 0, - "oldfieldname": "schedule_date", - "oldfieldtype": "Date", - "print_hide": 0, - "print_width": "100px", - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "in_filter": 1, - "label": "Item Group", - "no_copy": 0, - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "print_hide": 1, - "read_only": 1, - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Link", - "label": "Brand", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "lead_time_date", - "fieldtype": "Date", - "in_list_view": 0, - "label": "Lead Time Date", - "no_copy": 1, - "oldfieldname": "lead_time_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "sales_order_no", - "fieldtype": "Link", - "label": "Sales Order No", - "no_copy": 0, - "options": "Sales Order", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "min_order_qty", - "fieldtype": "Float", - "label": "Min Order Qty", - "no_copy": 1, - "oldfieldname": "min_order_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "70px", - "read_only": 1, - "reqd": 0, - "width": "70px" - }, - { - "doctype": "DocField", - "fieldname": "projected_qty", - "fieldtype": "Float", - "label": "Projected Qty", - "no_copy": 1, - "oldfieldname": "projected_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "70px", - "read_only": 1, - "width": "70px" - }, - { - "doctype": "DocField", - "fieldname": "ordered_qty", - "fieldtype": "Float", - "label": "Completed Qty", - "no_copy": 1, - "oldfieldname": "ordered_qty", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "page_break", - "fieldtype": "Check", - "label": "Page Break", - "no_copy": 1, - "oldfieldname": "page_break", - "oldfieldtype": "Check", - "print_hide": 1 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/packed_item/packed_item.json b/erpnext/stock/doctype/packed_item/packed_item.json new file mode 100644 index 00000000000..6558efbafc7 --- /dev/null +++ b/erpnext/stock/doctype/packed_item/packed_item.json @@ -0,0 +1,157 @@ +{ + "creation": "2013-02-22 01:28:00.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "parent_item", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Parent Item", + "oldfieldname": "parent_item", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "parent_detail_docname", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Parent Detail docname", + "no_copy": 1, + "oldfieldname": "parent_detail_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 1, + "width": "300px" + }, + { + "fieldname": "warehouse", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Warehouse", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Qty", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "serial_no", + "fieldtype": "Text", + "label": "Serial No", + "permlevel": 0 + }, + { + "fieldname": "batch_no", + "fieldtype": "Data", + "label": "Batch No", + "permlevel": 0 + }, + { + "fieldname": "actual_qty", + "fieldtype": "Float", + "label": "Actual Qty", + "no_copy": 1, + "oldfieldname": "actual_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "projected_qty", + "fieldtype": "Float", + "label": "Projected Qty", + "no_copy": 1, + "oldfieldname": "projected_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "uom", + "fieldtype": "Link", + "label": "UOM", + "oldfieldname": "uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "prevdoc_doctype", + "fieldtype": "Data", + "hidden": 1, + "label": "Prevdoc DocType", + "oldfieldname": "prevdoc_doctype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "label": "Page Break", + "oldfieldname": "page_break", + "oldfieldtype": "Check", + "permlevel": 0, + "read_only": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:23.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Packed Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py index b01307d7a28..cf208ee87d0 100644 --- a/erpnext/stock/doctype/packed_item/packed_item.py +++ b/erpnext/stock/doctype/packed_item/packed_item.py @@ -6,12 +6,12 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt -from frappe.model.doc import addchild -from frappe.model.bean import getlist -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl + +from frappe.model.document import Document + +class PackedItem(Document): + pass def get_sales_bom_items(item_code): return frappe.db.sql("""select t1.item_code, t1.qty, t1.uom @@ -33,13 +33,13 @@ def update_packing_list_item(obj, packing_item_code, qty, warehouse, line, packi # check if exists exists = 0 - for d in getlist(obj.doclist, 'packing_details'): + for d in obj.get("packing_details"): if d.parent_item == line.item_code and d.item_code == packing_item_code and d.parent_detail_docname == line.name: pi, exists = d, 1 break if not exists: - pi = addchild(obj.doc, 'packing_details', 'Packed Item', obj.doclist) + pi = obj.append('packing_details', {}) pi.parent_item = line.item_code pi.item_code = packing_item_code @@ -53,7 +53,7 @@ def update_packing_list_item(obj, packing_item_code, qty, warehouse, line, packi if not pi.warehouse: pi.warehouse = warehouse if not pi.batch_no: - pi.batch_no = cstr(line.batch_no) + pi.batch_no = cstr(line.get("batch_no")) pi.idx = packing_list_idx packing_list_idx += 1 @@ -63,7 +63,7 @@ def make_packing_list(obj, item_table_fieldname): """make packing list for sales bom item""" packing_list_idx = 0 parent_items = [] - for d in obj.doclist.get({"parentfield": item_table_fieldname}): + for d in obj.get(item_table_fieldname): warehouse = (item_table_fieldname == "sales_order_details") \ and d.warehouse or d.warehouse if frappe.db.get_value("Sales BOM", {"new_item_code": d.item_code}): @@ -74,23 +74,22 @@ def make_packing_list(obj, item_table_fieldname): if [d.item_code, d.name] not in parent_items: parent_items.append([d.item_code, d.name]) - obj.doclist = cleanup_packing_list(obj, parent_items) - - return obj.doclist - + cleanup_packing_list(obj, parent_items) + def cleanup_packing_list(obj, parent_items): """Remove all those child items which are no longer present in main item table""" delete_list = [] - for d in obj.doclist.get({"parentfield": "packing_details"}): + for d in obj.get("packing_details"): if [d.parent_item, d.parent_detail_docname] not in parent_items: # mark for deletion from doclist - delete_list.append([d.parent_item, d.parent_detail_docname]) + delete_list.append(d) if not delete_list: - return obj.doclist + return obj - # delete from doclist - obj.doclist = frappe.doclist(filter(lambda d: [d.parent_item, d.parent_detail_docname] - not in delete_list, obj.doclist)) - - return obj.doclist \ No newline at end of file + packing_details = obj.get("packing_details") + obj.set("packing_details", []) + for d in packing_details: + if d not in delete_list: + obj.append("packing_details", d) + \ No newline at end of file diff --git a/erpnext/stock/doctype/packed_item/packed_item.txt b/erpnext/stock/doctype/packed_item/packed_item.txt deleted file mode 100644 index 45a1d4d9b21..00000000000 --- a/erpnext/stock/doctype/packed_item/packed_item.txt +++ /dev/null @@ -1,170 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:00", - "docstatus": 0, - "modified": "2013-12-20 19:23:23", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Packed Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Packed Item" - }, - { - "doctype": "DocField", - "fieldname": "parent_item", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Parent Item", - "oldfieldname": "parent_item", - "oldfieldtype": "Link", - "options": "Item", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "parent_detail_docname", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Parent Detail docname", - "no_copy": 1, - "oldfieldname": "parent_detail_docname", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "print_width": "300px", - "read_only": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Warehouse", - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Qty", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Text", - "label": "Serial No" - }, - { - "doctype": "DocField", - "fieldname": "batch_no", - "fieldtype": "Data", - "label": "Batch No" - }, - { - "doctype": "DocField", - "fieldname": "actual_qty", - "fieldtype": "Float", - "label": "Actual Qty", - "no_copy": 1, - "oldfieldname": "actual_qty", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "projected_qty", - "fieldtype": "Float", - "label": "Projected Qty", - "no_copy": 1, - "oldfieldname": "projected_qty", - "oldfieldtype": "Currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "uom", - "fieldtype": "Link", - "label": "UOM", - "oldfieldname": "uom", - "oldfieldtype": "Link", - "options": "UOM", - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_doctype", - "fieldtype": "Data", - "hidden": 1, - "label": "Prevdoc DocType", - "oldfieldname": "prevdoc_doctype", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "page_break", - "fieldtype": "Check", - "label": "Page Break", - "oldfieldname": "page_break", - "oldfieldtype": "Check", - "read_only": 1 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.js b/erpnext/stock/doctype/packing_slip/packing_slip.js index f00fa775fae..ff1e1f036e8 100644 --- a/erpnext/stock/doctype/packing_slip/packing_slip.js +++ b/erpnext/stock/doctype/packing_slip/packing_slip.js @@ -59,7 +59,7 @@ cur_frm.cscript.validate_case_nos = function(doc) { cur_frm.cscript.validate_calculate_item_details = function(doc) { doc = locals[doc.doctype][doc.name]; - var ps_detail = getchildren('Packing Slip Item', doc.name, 'item_details'); + var ps_detail = doc.item_details || []; cur_frm.cscript.validate_duplicate_items(doc, ps_detail); cur_frm.cscript.calc_net_total_pkg(doc, ps_detail); diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.json b/erpnext/stock/doctype/packing_slip/packing_slip.json new file mode 100644 index 00000000000..634f11f99a0 --- /dev/null +++ b/erpnext/stock/doctype/packing_slip/packing_slip.json @@ -0,0 +1,259 @@ +{ + "autoname": "PS.#######", + "creation": "2013-04-11 15:32:24.000000", + "description": "Generate packing slips for packages to be delivered. Used to notify package number, package contents and its weight.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "fieldname": "packing_slip_details", + "fieldtype": "Section Break", + "label": "Packing Slip Items", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Indicates that the package is a part of this delivery", + "fieldname": "delivery_note", + "fieldtype": "Link", + "label": "Delivery Note", + "options": "Delivery Note", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 0, + "options": "PS", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "section_break0", + "fieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "Identification of the package for the delivery (for print)", + "fieldname": "from_case_no", + "fieldtype": "Data", + "label": "From Package No.", + "no_copy": 1, + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "width": "50px" + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "If more than one package of the same type (for print)", + "fieldname": "to_case_no", + "fieldtype": "Data", + "label": "To Package No.", + "no_copy": 1, + "permlevel": 0, + "read_only": 0, + "width": "50px" + }, + { + "fieldname": "package_item_details", + "fieldtype": "Section Break", + "label": "Package Item Details", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "get_items", + "fieldtype": "Button", + "label": "Get Items", + "permlevel": 0 + }, + { + "fieldname": "item_details", + "fieldtype": "Table", + "label": "Items", + "options": "Packing Slip Item", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "package_weight_details", + "fieldtype": "Section Break", + "label": "Package Weight Details", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "The net weight of this package. (calculated automatically as sum of net weight of items)", + "fieldname": "net_weight_pkg", + "fieldtype": "Float", + "label": "Net Weight", + "no_copy": 1, + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "net_weight_uom", + "fieldtype": "Link", + "label": "Net Weight UOM", + "no_copy": 1, + "options": "UOM", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break4", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "description": "The gross weight of the package. Usually net weight + packaging material weight. (for print)", + "fieldname": "gross_weight_pkg", + "fieldtype": "Float", + "label": "Gross Weight", + "no_copy": 1, + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "gross_weight_uom", + "fieldtype": "Link", + "label": "Gross Weight UOM", + "no_copy": 1, + "options": "UOM", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "misc_details", + "fieldtype": "Section Break", + "label": "Misc Details", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "options": "Packing Slip", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "icon": "icon-suitcase", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:48:59.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Packing Slip", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Master Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "submit": 1, + "write": 1 + } + ], + "read_only_onload": 1, + "search_fields": "delivery_note" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.py b/erpnext/stock/doctype/packing_slip/packing_slip.py index b7b64732033..b4b64cd648a 100644 --- a/erpnext/stock/doctype/packing_slip/packing_slip.py +++ b/erpnext/stock/doctype/packing_slip/packing_slip.py @@ -5,11 +5,10 @@ from __future__ import unicode_literals import frappe from frappe.utils import flt, cint from frappe import msgprint, _ -from frappe.model.doc import addchild -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class PackingSlip(Document): def validate(self): """ @@ -25,18 +24,18 @@ class DocType: self.validate_qty() from erpnext.utilities.transaction_base import validate_uom_is_integer - validate_uom_is_integer(self.doclist, "stock_uom", "qty") - validate_uom_is_integer(self.doclist, "weight_uom", "net_weight") + validate_uom_is_integer(self, "stock_uom", "qty") + validate_uom_is_integer(self, "weight_uom", "net_weight") def validate_delivery_note(self): """ Validates if delivery note has status as draft """ - if cint(frappe.db.get_value("Delivery Note", self.doc.delivery_note, "docstatus")) != 0: + if cint(frappe.db.get_value("Delivery Note", self.delivery_note, "docstatus")) != 0: msgprint(_("""Invalid Delivery Note. Delivery Note should exist and should be in draft state. Please rectify and try again."""), raise_exception=1) def validate_items_mandatory(self): - rows = [d.item_code for d in self.doclist.get({"parentfield": "item_details"})] + rows = [d.item_code for d in self.get("item_details")] if not rows: frappe.msgprint(_("No Items to Pack"), raise_exception=1) @@ -44,11 +43,11 @@ class DocType: """ Validate if case nos overlap. If they do, recommend next case no. """ - if not cint(self.doc.from_case_no): + if not cint(self.from_case_no): frappe.msgprint(_("Please specify a valid 'From Case No.'"), raise_exception=1) - elif not self.doc.to_case_no: - self.doc.to_case_no = self.doc.from_case_no - elif self.doc.from_case_no > self.doc.to_case_no: + elif not self.to_case_no: + self.to_case_no = self.from_case_no + elif self.from_case_no > self.to_case_no: frappe.msgprint(_("'To Case No.' cannot be less than 'From Case No.'"), raise_exception=1) @@ -58,7 +57,7 @@ class DocType: (from_case_no BETWEEN %(from_case_no)s AND %(to_case_no)s OR to_case_no BETWEEN %(from_case_no)s AND %(to_case_no)s OR %(from_case_no)s BETWEEN from_case_no AND to_case_no) - """, self.doc.fields) + """, self.as_dict()) if res: frappe.msgprint(_("""Case No(s) already in use. Please rectify and try again. @@ -87,7 +86,7 @@ class DocType: * No. of Cases of this packing slip """ - rows = [d.item_code for d in self.doclist.get({"parentfield": "item_details"})] + rows = [d.item_code for d in self.get("item_details")] condition = "" if rows: @@ -103,10 +102,10 @@ class DocType: from `tabDelivery Note Item` dni where parent=%s %s group by item_code""" % ("%s", condition), - tuple([self.doc.delivery_note] + rows), as_dict=1) + tuple([self.delivery_note] + rows), as_dict=1) - ps_item_qty = dict([[d.item_code, d.qty] for d in self.doclist]) - no_of_cases = cint(self.doc.to_case_no) - cint(self.doc.from_case_no) + 1 + ps_item_qty = dict([[d.item_code, d.qty] for d in self.get("item_details")]) + no_of_cases = cint(self.to_case_no) - cint(self.from_case_no) + 1 return res, ps_item_qty, no_of_cases @@ -129,10 +128,10 @@ class DocType: """ Fill empty columns in Packing Slip Item """ - if not self.doc.from_case_no: - self.doc.from_case_no = self.get_recommended_case_no() + if not self.from_case_no: + self.from_case_no = self.get_recommended_case_no() - for d in self.doclist.get({"parentfield": "item_details"}): + for d in self.get("item_details"): res = frappe.db.get_value("Item", d.item_code, ["net_weight", "weight_uom"], as_dict=True) @@ -146,17 +145,17 @@ class DocType: note """ recommended_case_no = frappe.db.sql("""SELECT MAX(to_case_no) FROM `tabPacking Slip` - WHERE delivery_note = %(delivery_note)s AND docstatus=1""", self.doc.fields) + WHERE delivery_note = %(delivery_note)s AND docstatus=1""", self.as_dict()) return cint(recommended_case_no[0][0]) + 1 def get_items(self): - self.doclist = self.doc.clear_table(self.doclist, "item_details", 1) + self.set("item_details", []) dn_details = self.get_details_for_packing()[0] for item in dn_details: if flt(item.qty) > flt(item.packed_qty): - ch = addchild(self.doc, 'item_details', 'Packing Slip Item', self.doclist) + ch = self.append('item_details', {}) ch.item_code = item.item_code ch.item_name = item.item_name ch.stock_uom = item.stock_uom diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.txt b/erpnext/stock/doctype/packing_slip/packing_slip.txt deleted file mode 100644 index 2f8ccc3fc70..00000000000 --- a/erpnext/stock/doctype/packing_slip/packing_slip.txt +++ /dev/null @@ -1,238 +0,0 @@ -[ - { - "creation": "2013-04-11 15:32:24", - "docstatus": 0, - "modified": "2014-01-20 17:48:59", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "PS.#######", - "description": "Generate packing slips for packages to be delivered. Used to notify package number, package contents and its weight.", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-suitcase", - "is_submittable": 1, - "module": "Stock", - "name": "__common__", - "read_only_onload": 1, - "search_fields": "delivery_note" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Packing Slip", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Packing Slip", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Packing Slip" - }, - { - "doctype": "DocField", - "fieldname": "packing_slip_details", - "fieldtype": "Section Break", - "label": "Packing Slip Items", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "description": "Indicates that the package is a part of this delivery", - "doctype": "DocField", - "fieldname": "delivery_note", - "fieldtype": "Link", - "label": "Delivery Note", - "options": "Delivery Note", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 0, - "options": "PS", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "description": "Identification of the package for the delivery (for print)", - "doctype": "DocField", - "fieldname": "from_case_no", - "fieldtype": "Data", - "label": "From Package No.", - "no_copy": 1, - "read_only": 0, - "reqd": 1, - "width": "50px" - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "description": "If more than one package of the same type (for print)", - "doctype": "DocField", - "fieldname": "to_case_no", - "fieldtype": "Data", - "label": "To Package No.", - "no_copy": 1, - "read_only": 0, - "width": "50px" - }, - { - "doctype": "DocField", - "fieldname": "package_item_details", - "fieldtype": "Section Break", - "label": "Package Item Details", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "get_items", - "fieldtype": "Button", - "label": "Get Items" - }, - { - "doctype": "DocField", - "fieldname": "item_details", - "fieldtype": "Table", - "label": "Items", - "options": "Packing Slip Item", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "package_weight_details", - "fieldtype": "Section Break", - "label": "Package Weight Details", - "read_only": 0 - }, - { - "description": "The net weight of this package. (calculated automatically as sum of net weight of items)", - "doctype": "DocField", - "fieldname": "net_weight_pkg", - "fieldtype": "Float", - "label": "Net Weight", - "no_copy": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "net_weight_uom", - "fieldtype": "Link", - "label": "Net Weight UOM", - "no_copy": 1, - "options": "UOM", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "description": "The gross weight of the package. Usually net weight + packaging material weight. (for print)", - "doctype": "DocField", - "fieldname": "gross_weight_pkg", - "fieldtype": "Float", - "label": "Gross Weight", - "no_copy": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "gross_weight_uom", - "fieldtype": "Link", - "label": "Gross Weight UOM", - "no_copy": 1, - "options": "UOM", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "misc_details", - "fieldtype": "Section Break", - "label": "Misc Details", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "options": "Packing Slip", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocPerm", - "role": "Material User" - }, - { - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "doctype": "DocPerm", - "role": "Material Master Manager" - }, - { - "doctype": "DocPerm", - "role": "Material Manager" - }, - { - "doctype": "DocPerm", - "role": "Sales Manager" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/packing_slip_item/packing_slip_item.json b/erpnext/stock/doctype/packing_slip_item/packing_slip_item.json new file mode 100644 index 00000000000..9d5c1bb8096 --- /dev/null +++ b/erpnext/stock/doctype/packing_slip_item/packing_slip_item.json @@ -0,0 +1,97 @@ +{ + "autoname": "PSD/.#######", + "creation": "2013-04-08 13:10:16.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Item Code", + "options": "Item", + "permlevel": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Item Name", + "permlevel": 0, + "print_width": "200px", + "read_only": 1, + "width": "200px" + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Quantity", + "permlevel": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "options": "UOM", + "permlevel": 0, + "print_width": "100px", + "read_only": 1, + "width": "100px" + }, + { + "fieldname": "net_weight", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Net Weight", + "permlevel": 0, + "print_width": "100px", + "read_only": 0, + "width": "100px" + }, + { + "fieldname": "weight_uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Weight UOM", + "options": "UOM", + "permlevel": 0, + "print_width": "100px", + "read_only": 0, + "width": "100px" + }, + { + "fieldname": "page_break", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Page Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "dn_detail", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 1, + "label": "DN Detail", + "permlevel": 0, + "read_only": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:23.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Packing Slip Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py b/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py index 968a25b6134..033e44b13c1 100644 --- a/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py +++ b/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PackingSlipItem(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/packing_slip_item/packing_slip_item.txt b/erpnext/stock/doctype/packing_slip_item/packing_slip_item.txt deleted file mode 100644 index 54e69914d01..00000000000 --- a/erpnext/stock/doctype/packing_slip_item/packing_slip_item.txt +++ /dev/null @@ -1,110 +0,0 @@ -[ - { - "creation": "2013-04-08 13:10:16", - "docstatus": 0, - "modified": "2013-12-20 19:23:23", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "PSD/.#######", - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Packing Slip Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Packing Slip Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item Code", - "options": "Item", - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Item Name", - "print_width": "200px", - "read_only": 1, - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Quantity", - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "options": "UOM", - "print_width": "100px", - "read_only": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "net_weight", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Net Weight", - "print_width": "100px", - "read_only": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "weight_uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Weight UOM", - "options": "UOM", - "print_width": "100px", - "read_only": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "page_break", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Page Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "dn_detail", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 1, - "label": "DN Detail", - "read_only": 0 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/price_list/price_list.json b/erpnext/stock/doctype/price_list/price_list.json new file mode 100644 index 00000000000..da69ff60c02 --- /dev/null +++ b/erpnext/stock/doctype/price_list/price_list.json @@ -0,0 +1,126 @@ +{ + "allow_attach": 0, + "allow_copy": 0, + "allow_email": 1, + "allow_import": 1, + "allow_print": 1, + "allow_rename": 1, + "autoname": "field:price_list_name", + "creation": "2013-01-25 11:35:09.000000", + "description": "Price List Master", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "default": "1", + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enabled", + "permlevel": 0 + }, + { + "fieldname": "sb_1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "price_list_name", + "fieldtype": "Data", + "label": "Price List Name", + "oldfieldname": "price_list_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Currency", + "options": "Currency", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "buying", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Buying", + "permlevel": 0 + }, + { + "fieldname": "selling", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Selling", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "Specify a list of Territories, for which, this Price List is valid", + "fieldname": "valid_for_territories", + "fieldtype": "Table", + "label": "Valid for Territories", + "options": "Applicable Territory", + "permlevel": 0, + "reqd": 1 + } + ], + "icon": "icon-tags", + "idx": 1, + "max_attachments": 1, + "modified": "2014-01-27 11:11:08.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Price List", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "permlevel": 0, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "permlevel": 0, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + }, + { + "delete": 0, + "permlevel": 0, + "read": 1, + "report": 1, + "role": "Purchase User" + }, + { + "cancel": 1, + "create": 1, + "delete": 1, + "permlevel": 0, + "read": 1, + "report": 1, + "role": "Purchase Master Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py index 37b956763ea..fa53aba3422 100644 --- a/erpnext/stock/doctype/price_list/price_list.py +++ b/erpnext/stock/doctype/price_list/price_list.py @@ -8,17 +8,16 @@ from frappe.utils import cint from frappe.model.controller import DocListController import frappe.defaults -class DocType(DocListController): +class PriceList(DocListController): def validate(self): - if not cint(self.doc.buying) and not cint(self.doc.selling): + if not cint(self.buying) and not cint(self.selling): throw(_("Price List must be applicable for Buying or Selling")) - if not self.doclist.get({"parentfield": "valid_for_territories"}): + if not self.get("valid_for_territories"): # if no territory, set default territory if frappe.defaults.get_user_default("territory"): - self.doclist.append({ + self.append("valid_for_territories", { "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", "territory": frappe.defaults.get_user_default("territory") }) else: @@ -30,26 +29,26 @@ class DocType(DocListController): self.update_item_price() def set_default_if_missing(self): - if cint(self.doc.selling): + if cint(self.selling): if not frappe.db.get_value("Selling Settings", None, "selling_price_list"): - frappe.set_value("Selling Settings", "Selling Settings", "selling_price_list", self.doc.name) + frappe.set_value("Selling Settings", "Selling Settings", "selling_price_list", self.name) - elif cint(self.doc.buying): + elif cint(self.buying): if not frappe.db.get_value("Buying Settings", None, "buying_price_list"): - frappe.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.doc.name) + frappe.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.name) def update_item_price(self): frappe.db.sql("""update `tabItem Price` set currency=%s, buying=%s, selling=%s, modified=NOW() where price_list=%s""", - (self.doc.currency, cint(self.doc.buying), cint(self.doc.selling), self.doc.name)) + (self.currency, cint(self.buying), cint(self.selling), self.name)) def on_trash(self): def _update_default_price_list(module): - b = frappe.bean(module + " Settings") + b = frappe.get_doc(module + " Settings") price_list_fieldname = module.lower() + "_price_list" - if self.doc.name == b.doc.fields[price_list_fieldname]: - b.doc.fields[price_list_fieldname] = None + if self.name == b.get(price_list_fieldname): + b.set(price_list_fieldname, None) b.save() for module in ["Selling", "Buying"]: diff --git a/erpnext/stock/doctype/price_list/price_list.txt b/erpnext/stock/doctype/price_list/price_list.txt deleted file mode 100644 index 253dce72c5e..00000000000 --- a/erpnext/stock/doctype/price_list/price_list.txt +++ /dev/null @@ -1,139 +0,0 @@ -[ - { - "creation": "2013-01-25 11:35:09", - "docstatus": 0, - "modified": "2014-01-27 11:11:08", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 0, - "allow_copy": 0, - "allow_import": 1, - "allow_email": 1, - "allow_print": 1, - "allow_rename": 1, - "autoname": "field:price_list_name", - "description": "Price List Master", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-tags", - "max_attachments": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Price List", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "Price List", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Price List" - }, - { - "default": "1", - "doctype": "DocField", - "fieldname": "enabled", - "fieldtype": "Check", - "label": "Enabled" - }, - { - "doctype": "DocField", - "fieldname": "sb_1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "price_list_name", - "fieldtype": "Data", - "label": "Price List Name", - "oldfieldname": "price_list_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "currency", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Currency", - "options": "Currency", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "buying", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Buying" - }, - { - "doctype": "DocField", - "fieldname": "selling", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Selling", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_3", - "fieldtype": "Column Break" - }, - { - "description": "Specify a list of Territories, for which, this Price List is valid", - "doctype": "DocField", - "fieldname": "valid_for_territories", - "fieldtype": "Table", - "label": "Valid for Territories", - "options": "Applicable Territory", - "reqd": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User", - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager", - "submit": 0, - "write": 1 - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase User" - }, - { - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Purchase Master Manager", - "write": 1 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/price_list/test_price_list.py b/erpnext/stock/doctype/price_list/test_price_list.py index 8ec53cbfc76..ca7f47d5799 100644 --- a/erpnext/stock/doctype/price_list/test_price_list.py +++ b/erpnext/stock/doctype/price_list/test_price_list.py @@ -6,70 +6,4 @@ import frappe # test_ignore = ["Item"] -test_records = [ - [ - { - "doctype": "Price List", - "price_list_name": "_Test Price List", - "enabled": 1, - "currency": "INR", - "selling": 1, - "buying": 1 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "All Territories" - }, - ], - [ - { - "doctype": "Price List", - "price_list_name": "_Test Price List 2", - "enabled": 1, - "currency": "INR", - "selling": 1, - "buying": 1 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory Rest Of The World" - } - ], - [ - { - "doctype": "Price List", - "price_list_name": "_Test Price List India", - "enabled": 1, - "currency": "INR", - "selling": 1, - "buying": 1 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory India" - } - ], - [ - { - "doctype": "Price List", - "price_list_name": "_Test Price List Rest of the World", - "enabled": 1, - "currency": "USD", - "selling": 1, - "buying": 1 - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory Rest Of The World" - }, - { - "doctype": "Applicable Territory", - "parentfield": "valid_for_territories", - "territory": "_Test Territory United States" - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Price List') \ No newline at end of file diff --git a/erpnext/stock/doctype/price_list/test_records.json b/erpnext/stock/doctype/price_list/test_records.json new file mode 100644 index 00000000000..86d650cb2a8 --- /dev/null +++ b/erpnext/stock/doctype/price_list/test_records.json @@ -0,0 +1,67 @@ +[ + { + "buying": 1, + "currency": "INR", + "doctype": "Price List", + "enabled": 1, + "price_list_name": "_Test Price List", + "selling": 1, + "valid_for_territories": [ + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "All Territories" + } + ] + }, + { + "buying": 1, + "currency": "INR", + "doctype": "Price List", + "enabled": 1, + "price_list_name": "_Test Price List 2", + "selling": 1, + "valid_for_territories": [ + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "_Test Territory Rest Of The World" + } + ] + }, + { + "buying": 1, + "currency": "INR", + "doctype": "Price List", + "enabled": 1, + "price_list_name": "_Test Price List India", + "selling": 1, + "valid_for_territories": [ + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "_Test Territory India" + } + ] + }, + { + "buying": 1, + "currency": "USD", + "doctype": "Price List", + "enabled": 1, + "price_list_name": "_Test Price List Rest of the World", + "selling": 1, + "valid_for_territories": [ + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "_Test Territory Rest Of The World" + }, + { + "doctype": "Applicable Territory", + "parentfield": "valid_for_territories", + "territory": "_Test Territory United States" + } + ] + } +] \ No newline at end of file diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index f067d9c2aa6..2359700809b 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -41,13 +41,13 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend }); } - if(frappe.boot.control_panel.country == 'India') { + if(frappe.boot.sysdefaults.country == 'India') { unhide_field(['challan_no', 'challan_date']); } }, received_qty: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["qty", "received_qty"]); item.qty = (item.qty < item.received_qty) ? item.qty : item.received_qty; @@ -55,7 +55,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend }, qty: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["qty", "received_qty"]); if(!(item.received_qty || item.rejected_qty) && item.qty) { @@ -74,7 +74,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend }, rejected_qty: function(doc, cdt, cdn) { - var item = frappe.model.get_doc(cdt, cdn); + var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["received_qty", "rejected_qty"]); if(item.rejected_qty > item.received_qty) { diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json new file mode 100755 index 00000000000..0d9e9e1d491 --- /dev/null +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json @@ -0,0 +1,846 @@ +{ + "allow_attach": 1, + "autoname": "naming_series:", + "creation": "2013-05-21 16:16:39.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "fieldname": "supplier_section", + "fieldtype": "Section Break", + "label": "Supplier", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "\nGRN", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "allow_on_submit": 0, + "fieldname": "supplier", + "fieldtype": "Link", + "in_filter": 1, + "label": "Supplier", + "oldfieldname": "supplier", + "oldfieldtype": "Link", + "options": "Supplier", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "depends_on": "supplier", + "fieldname": "supplier_name", + "fieldtype": "Data", + "hidden": 0, + "in_list_view": 1, + "label": "Supplier Name", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_mobile", + "fieldtype": "Text", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_email", + "fieldtype": "Text", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "posting_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Posting Date", + "no_copy": 1, + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "reqd": 1, + "search_index": 1, + "width": "100px" + }, + { + "description": "Time at which materials were received", + "fieldname": "posting_time", + "fieldtype": "Time", + "in_filter": 0, + "label": "Posting Time", + "no_copy": 1, + "oldfieldname": "posting_time", + "oldfieldtype": "Time", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "reqd": 1, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "challan_no", + "fieldtype": "Data", + "hidden": 1, + "label": "Supplier Shipment No", + "no_copy": 1, + "oldfieldname": "challan_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "challan_date", + "fieldtype": "Date", + "hidden": 1, + "label": "Supplier Shipment Date", + "no_copy": 1, + "oldfieldname": "challan_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "currency_price_list", + "fieldtype": "Section Break", + "label": "Currency and Price List", + "options": "icon-tag", + "permlevel": 0 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "description": "Rate at which supplier's currency is converted to company's base currency", + "fieldname": "conversion_rate", + "fieldtype": "Float", + "label": "Exchange Rate", + "oldfieldname": "conversion_rate", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "buying_price_list", + "fieldtype": "Link", + "label": "Price List", + "options": "Price List", + "permlevel": 0, + "print_hide": 1 + }, + { + "depends_on": "buying_price_list", + "fieldname": "price_list_currency", + "fieldtype": "Link", + "hidden": 0, + "label": "Price List Currency", + "options": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "depends_on": "buying_price_list", + "fieldname": "plc_conversion_rate", + "fieldtype": "Float", + "label": "Price List Exchange Rate", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "items", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0 + }, + { + "allow_on_submit": 1, + "fieldname": "purchase_receipt_details", + "fieldtype": "Table", + "label": "Purchase Receipt Items", + "oldfieldname": "purchase_receipt_details", + "oldfieldtype": "Table", + "options": "Purchase Receipt Item", + "permlevel": 0, + "print_hide": 0, + "reqd": 0 + }, + { + "fieldname": "section_break0", + "fieldtype": "Section Break", + "oldfieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "net_total_import", + "fieldtype": "Currency", + "label": "Net Total", + "oldfieldname": "net_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "get_current_stock", + "fieldtype": "Button", + "label": "Get Current Stock", + "oldfieldtype": "Button", + "options": "get_current_stock", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "column_break_27", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "net_total", + "fieldtype": "Currency", + "label": "Net Total (Company Currency)", + "oldfieldname": "net_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "reqd": 1, + "width": "150px" + }, + { + "description": "Add / Edit Taxes and Charges", + "fieldname": "taxes", + "fieldtype": "Section Break", + "label": "Taxes and Charges", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0 + }, + { + "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.", + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "label": "Taxes and Charges", + "oldfieldname": "purchase_other_charges", + "oldfieldtype": "Link", + "options": "Purchase Taxes and Charges Master", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "other_charges", + "fieldtype": "Table", + "label": "Purchase Taxes and Charges", + "oldfieldname": "purchase_tax_details", + "oldfieldtype": "Table", + "options": "Purchase Taxes and Charges", + "permlevel": 0 + }, + { + "fieldname": "other_charges_calculation", + "fieldtype": "HTML", + "label": "Taxes and Charges Calculation", + "oldfieldtype": "HTML", + "permlevel": 0, + "print_hide": 1 + }, + { + "description": "Detailed Breakup of the totals", + "fieldname": "totals", + "fieldtype": "Section Break", + "label": "Totals", + "oldfieldtype": "Section Break", + "options": "icon-money", + "permlevel": 0 + }, + { + "fieldname": "other_charges_added_import", + "fieldtype": "Currency", + "label": "Taxes and Charges Added", + "oldfieldname": "other_charges_added_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "other_charges_deducted_import", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted", + "oldfieldname": "other_charges_deducted_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "grand_total_import", + "fieldtype": "Currency", + "label": "Grand Total", + "oldfieldname": "grand_total_import", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "in_words_import", + "fieldtype": "Data", + "label": "In Words", + "oldfieldname": "in_words_import", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "other_charges_added", + "fieldtype": "Currency", + "label": "Taxes and Charges Added (Company Currency)", + "oldfieldname": "other_charges_added", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "other_charges_deducted", + "fieldtype": "Currency", + "label": "Taxes and Charges Deducted (Company Currency)", + "oldfieldname": "other_charges_deducted", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "total_tax", + "fieldtype": "Currency", + "label": "Total Tax (Company Currency)", + "oldfieldname": "total_tax", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "grand_total", + "fieldtype": "Currency", + "label": "Grand Total (Company Currency)", + "oldfieldname": "grand_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "rounded_total", + "fieldtype": "Currency", + "label": "Rounded Total (Company Currency)", + "oldfieldname": "rounded_total", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "In Words will be visible once you save the Purchase Receipt.", + "fieldname": "in_words", + "fieldtype": "Data", + "label": "In Words (Company Currency)", + "oldfieldname": "in_words", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "terms_section_break", + "fieldtype": "Section Break", + "label": "Terms and Conditions", + "oldfieldtype": "Section Break", + "options": "icon-legal", + "permlevel": 0 + }, + { + "fieldname": "tc_name", + "fieldtype": "Link", + "label": "Terms", + "oldfieldname": "tc_name", + "oldfieldtype": "Link", + "options": "Terms and Conditions", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "terms", + "fieldtype": "Text Editor", + "label": "Terms and Conditions1", + "oldfieldname": "terms", + "oldfieldtype": "Text Editor", + "permlevel": 0 + }, + { + "depends_on": "supplier", + "fieldname": "contact_section", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0 + }, + { + "fieldname": "supplier_address", + "fieldtype": "Link", + "label": "Supplier Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "column_break_57", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "contact_person", + "fieldtype": "Link", + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0 + }, + { + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nDraft\nSubmitted\nCancelled", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "default": "No", + "description": "Select \"Yes\" for sub - contracting items", + "fieldname": "is_subcontracted", + "fieldtype": "Select", + "label": "Is Subcontracted", + "oldfieldname": "is_subcontracted", + "oldfieldtype": "Select", + "options": "\nYes\nNo", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "hidden": 1, + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "options": "Purchase Receipt", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "range", + "fieldtype": "Data", + "hidden": 1, + "label": "Range", + "oldfieldname": "range", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "bill_no", + "fieldtype": "Data", + "hidden": 1, + "label": "Bill No", + "oldfieldname": "bill_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "bill_date", + "fieldtype": "Date", + "hidden": 1, + "label": "Bill Date", + "oldfieldname": "bill_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "letter_head", + "fieldtype": "Select", + "label": "Letter Head", + "options": "link:Letter Head", + "permlevel": 0, + "print_hide": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "label": "Print Heading", + "no_copy": 1, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 1, + "report_hide": 1 + }, + { + "description": "Select the relevant company name if you have multiple companies", + "fieldname": "company", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Company", + "no_copy": 0, + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "reqd": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "column_break4", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_hide": 1, + "print_width": "50%", + "width": "50%" + }, + { + "fieldname": "other_details", + "fieldtype": "HTML", + "hidden": 1, + "label": "Other Details", + "oldfieldtype": "HTML", + "options": "
Other Details
", + "permlevel": 0, + "print_hide": 1, + "print_width": "30%", + "reqd": 0, + "width": "30%" + }, + { + "description": "Warehouse where you are maintaining stock of rejected items", + "fieldname": "rejected_warehouse", + "fieldtype": "Link", + "label": "Rejected Warehouse", + "no_copy": 1, + "oldfieldname": "rejected_warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "reqd": 0 + }, + { + "description": "Supplier warehouse where you have issued raw materials for sub - contracting", + "fieldname": "supplier_warehouse", + "fieldtype": "Link", + "label": "Supplier Warehouse", + "no_copy": 1, + "oldfieldname": "supplier_warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "print_width": "50px", + "width": "50px" + }, + { + "fieldname": "instructions", + "fieldtype": "Small Text", + "label": "Instructions", + "oldfieldname": "instructions", + "oldfieldtype": "Text", + "permlevel": 0 + }, + { + "fieldname": "remarks", + "fieldtype": "Small Text", + "label": "Remarks", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "transporter_info", + "fieldtype": "Section Break", + "label": "Transporter Info", + "options": "icon-truck", + "permlevel": 0 + }, + { + "fieldname": "transporter_name", + "fieldtype": "Data", + "label": "Transporter Name", + "oldfieldname": "transporter_name", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "description": "Transporter lorry number", + "fieldname": "lr_no", + "fieldtype": "Data", + "label": "LR No", + "no_copy": 1, + "oldfieldname": "lr_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "width": "100px" + }, + { + "description": "Date on which lorry started from supplier warehouse", + "fieldname": "lr_date", + "fieldtype": "Date", + "label": "LR Date", + "no_copy": 1, + "oldfieldname": "lr_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "width": "100px" + }, + { + "fieldname": "column_break5", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "width": "50%" + }, + { + "description": "Following table will show values if items are sub - contracted. These values will be fetched from the master of \"Bill of Materials\" of sub - contracted items.", + "fieldname": "raw_material_details", + "fieldtype": "Section Break", + "label": "Raw Materials Supplied", + "oldfieldtype": "Section Break", + "options": "icon-table", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "pr_raw_material_details", + "fieldtype": "Table", + "label": "Purchase Receipt Item Supplieds", + "no_copy": 1, + "oldfieldname": "pr_raw_material_details", + "oldfieldtype": "Table", + "options": "Purchase Receipt Item Supplied", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "icon": "icon-truck", + "idx": 1, + "is_submittable": 1, + "modified": "2014-02-17 12:01:00.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Purchase Receipt", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "submit": 1, + "write": 1 + }, + { + "cancel": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Supplier" + } + ], + "read_only_onload": 1, + "search_fields": "status, posting_date, supplier" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index d1e86a85211..7626112f524 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -5,20 +5,18 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt, cint -from frappe.model.bean import getlist -from frappe.model.code import get_obj + from frappe import msgprint, _ import frappe.defaults from erpnext.stock.utils import update_bin from erpnext.controllers.buying_controller import BuyingController -class DocType(BuyingController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist - self.tname = 'Purchase Receipt Item' - self.fname = 'purchase_receipt_details' - self.count = 0 +class PurchaseReceipt(BuyingController): + tname = 'Purchase Receipt Item' + fname = 'purchase_receipt_details' + + def __init__(self, arg1, arg2=None): + super(PurchaseReceipt, self).__init__(arg1, arg2) self.status_updater = [{ 'source_dt': 'Purchase Receipt Item', 'target_dt': 'Purchase Order Item', @@ -30,24 +28,24 @@ class DocType(BuyingController): 'source_field': 'qty', 'percent_join_field': 'prevdoc_docname', }] - + def onload(self): billed_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabPurchase Invoice Item` - where purchase_receipt=%s""", self.doc.name) + where purchase_receipt=%s""", self.name) if billed_qty: - total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "purchase_receipt_details"}))) - self.doc.fields["__billing_complete"] = billed_qty[0][0] == total_qty + total_qty = sum((item.qty for item in self.get("purchase_receipt_details"))) + self.set("__billing_complete", billed_qty[0][0] == total_qty) def validate(self): - super(DocType, self).validate() - + super(PurchaseReceipt, self).validate() + self.po_required() - if not self.doc.status: - self.doc.status = "Draft" + if not self.status: + self.status = "Draft" from erpnext.utilities import validate_status - validate_status(self.doc.status, ["Draft", "Submitted", "Cancelled"]) + validate_status(self.status, ["Draft", "Submitted", "Cancelled"]) self.validate_with_previous_doc() self.validate_rejected_warehouse() @@ -57,26 +55,26 @@ class DocType(BuyingController): self.validate_uom_is_integer("stock_uom", "stock_qty") self.validate_challan_no() - pc_obj = get_obj(dt='Purchase Common') + pc_obj = frappe.get_doc('Purchase Common') pc_obj.validate_for_items(self) self.check_for_stopped_status(pc_obj) # sub-contracting self.validate_for_subcontracting() self.update_raw_materials_supplied("pr_raw_material_details") - + self.update_valuation_rate("purchase_receipt_details") def validate_rejected_warehouse(self): - for d in self.doclist.get({"parentfield": "purchase_receipt_details"}): + for d in self.get("purchase_receipt_details"): if flt(d.rejected_qty) and not d.rejected_warehouse: - d.rejected_warehouse = self.doc.rejected_warehouse + d.rejected_warehouse = self.rejected_warehouse if not d.rejected_warehouse: - frappe.throw(_("Rejected Warehouse is mandatory against regected item")) + frappe.throw(_("Rejected Warehouse is mandatory against regected item")) # validate accepted and rejected qty def validate_accepted_rejected_qty(self): - for d in getlist(self.doclist, "purchase_receipt_details"): + for d in self.get("purchase_receipt_details"): if not flt(d.received_qty) and flt(d.qty): d.received_qty = flt(d.qty) - flt(d.rejected_qty) @@ -95,17 +93,17 @@ class DocType(BuyingController): def validate_challan_no(self): "Validate if same challan no exists for same supplier in a submitted purchase receipt" - if self.doc.challan_no: + if self.challan_no: exists = frappe.db.sql(""" SELECT name FROM `tabPurchase Receipt` WHERE name!=%s AND supplier=%s AND challan_no=%s - AND docstatus=1""", (self.doc.name, self.doc.supplier, self.doc.challan_no)) + AND docstatus=1""", (self.name, self.supplier, self.challan_no)) if exists: frappe.msgprint("Another Purchase Receipt using the same Challan No. already exists.\ Please enter a valid Challan No.", raise_exception=1) - + def validate_with_previous_doc(self): - super(DocType, self).validate_with_previous_doc(self.tname, { + super(PurchaseReceipt, self).validate_with_previous_doc(self.tname, { "Purchase Order": { "ref_dn_field": "prevdoc_docname", "compare_fields": [["supplier", "="], ["company", "="], ["currency", "="]], @@ -116,20 +114,20 @@ class DocType(BuyingController): "is_child_table": True } }) - + if cint(frappe.defaults.get_global_default('maintain_same_rate')): - super(DocType, self).validate_with_previous_doc(self.tname, { + super(PurchaseReceipt, self).validate_with_previous_doc(self.tname, { "Purchase Order Item": { "ref_dn_field": "prevdoc_detail_docname", "compare_fields": [["rate", "="]], "is_child_table": True } }) - + def po_required(self): if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes': - for d in getlist(self.doclist,'purchase_receipt_details'): + for d in self.get('purchase_receipt_details'): if not d.prevdoc_docname: msgprint("Purchse Order No. required against item %s"%d.item_code) raise Exception @@ -137,18 +135,18 @@ class DocType(BuyingController): def update_stock(self): sl_entries = [] stock_items = self.get_stock_items() - - for d in getlist(self.doclist, 'purchase_receipt_details'): + + for d in self.get('purchase_receipt_details'): if d.item_code in stock_items and d.warehouse: pr_qty = flt(d.qty) * flt(d.conversion_factor) - + if pr_qty: sl_entries.append(self.get_sl_entries(d, { "actual_qty": flt(pr_qty), "serial_no": cstr(d.serial_no).strip(), "incoming_rate": d.valuation_rate })) - + if flt(d.rejected_qty) > 0: sl_entries.append(self.get_sl_entries(d, { "warehouse": d.rejected_warehouse, @@ -156,60 +154,60 @@ class DocType(BuyingController): "serial_no": cstr(d.rejected_serial_no).strip(), "incoming_rate": d.valuation_rate })) - + self.bk_flush_supp_wh(sl_entries) self.make_sl_entries(sl_entries) - + def update_ordered_qty(self): stock_items = self.get_stock_items() - for d in self.doclist.get({"parentfield": "purchase_receipt_details"}): + for d in self.get("purchase_receipt_details"): if d.item_code in stock_items and d.warehouse \ and cstr(d.prevdoc_doctype) == 'Purchase Order': - - already_received_qty = self.get_already_received_qty(d.prevdoc_docname, + + already_received_qty = self.get_already_received_qty(d.prevdoc_docname, d.prevdoc_detail_docname) po_qty, ordered_warehouse = self.get_po_qty_and_warehouse(d.prevdoc_detail_docname) - + if not ordered_warehouse: frappe.throw(_("Warehouse is missing in Purchase Order")) - + if already_received_qty + d.qty > po_qty: ordered_qty = - (po_qty - already_received_qty) * flt(d.conversion_factor) else: ordered_qty = - flt(d.qty) * flt(d.conversion_factor) - + update_bin({ "item_code": d.item_code, "warehouse": ordered_warehouse, - "posting_date": self.doc.posting_date, - "ordered_qty": flt(ordered_qty) if self.doc.docstatus==1 else -flt(ordered_qty) + "posting_date": self.posting_date, + "ordered_qty": flt(ordered_qty) if self.docstatus==1 else -flt(ordered_qty) }) def get_already_received_qty(self, po, po_detail): - qty = frappe.db.sql("""select sum(qty) from `tabPurchase Receipt Item` - where prevdoc_detail_docname = %s and docstatus = 1 - and prevdoc_doctype='Purchase Order' and prevdoc_docname=%s - and parent != %s""", (po_detail, po, self.doc.name)) + qty = frappe.db.sql("""select sum(qty) from `tabPurchase Receipt Item` + where prevdoc_detail_docname = %s and docstatus = 1 + and prevdoc_doctype='Purchase Order' and prevdoc_docname=%s + and parent != %s""", (po_detail, po, self.name)) return qty and flt(qty[0][0]) or 0.0 - + def get_po_qty_and_warehouse(self, po_detail): - po_qty, po_warehouse = frappe.db.get_value("Purchase Order Item", po_detail, + po_qty, po_warehouse = frappe.db.get_value("Purchase Order Item", po_detail, ["qty", "warehouse"]) return po_qty, po_warehouse - + def bk_flush_supp_wh(self, sl_entries): - for d in getlist(self.doclist, 'pr_raw_material_details'): - # negative quantity is passed as raw material qty has to be decreased + for d in self.get('pr_raw_material_details'): + # negative quantity is passed as raw material qty has to be decreased # when PR is submitted and it has to be increased when PR is cancelled sl_entries.append(self.get_sl_entries(d, { "item_code": d.rm_item_code, - "warehouse": self.doc.supplier_warehouse, + "warehouse": self.supplier_warehouse, "actual_qty": -1*flt(d.consumed_qty), "incoming_rate": 0 })) def validate_inspection(self): - for d in getlist(self.doclist, 'purchase_receipt_details'): #Enter inspection date for all items that require inspection + for d in self.get('purchase_receipt_details'): #Enter inspection date for all items that require inspection ins_reqd = frappe.db.sql("select inspection_required from `tabItem` where name = %s", (d.item_code,), as_dict = 1) ins_reqd = ins_reqd and ins_reqd[0]['inspection_required'] or 'No' @@ -219,112 +217,112 @@ class DocType(BuyingController): # Check for Stopped status def check_for_stopped_status(self, pc_obj): check_list =[] - for d in getlist(self.doclist, 'purchase_receipt_details'): - if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list: + for d in self.get('purchase_receipt_details'): + if d.meta.get_field('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list: check_list.append(d.prevdoc_docname) pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname) # on submit def on_submit(self): - purchase_controller = frappe.get_obj("Purchase Common") + purchase_controller = frappe.get_doc("Purchase Common") # Check for Approving Authority - get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total) + frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.grand_total) # Set status as Submitted - frappe.db.set(self.doc, 'status', 'Submitted') + frappe.db.set(self, 'status', 'Submitted') self.update_prevdoc_status() - + self.update_ordered_qty() - + self.update_stock() from erpnext.stock.doctype.serial_no.serial_no import update_serial_nos_after_submit update_serial_nos_after_submit(self, "purchase_receipt_details") purchase_controller.update_last_purchase_rate(self, 1) - + self.make_gl_entries() def check_next_docstatus(self): - submit_rv = frappe.db.sql("""select t1.name - from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 - where t1.name = t2.parent and t2.purchase_receipt = %s and t1.docstatus = 1""", - (self.doc.name)) + submit_rv = frappe.db.sql("""select t1.name + from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 + where t1.name = t2.parent and t2.purchase_receipt = %s and t1.docstatus = 1""", + (self.name)) if submit_rv: msgprint("Purchase Invoice : " + cstr(self.submit_rv[0][0]) + " has already been submitted !") raise Exception , "Validation Error." def on_cancel(self): - pc_obj = get_obj('Purchase Common') + pc_obj = frappe.get_doc('Purchase Common') self.check_for_stopped_status(pc_obj) # Check if Purchase Invoice has been submitted against current Purchase Order - submitted = frappe.db.sql("""select t1.name - from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 - where t1.name = t2.parent and t2.purchase_receipt = %s and t1.docstatus = 1""", - self.doc.name) + submitted = frappe.db.sql("""select t1.name + from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 + where t1.name = t2.parent and t2.purchase_receipt = %s and t1.docstatus = 1""", + self.name) if submitted: - frappe.throw("Purchase Invoice : " + cstr(submitted[0][0]) + + frappe.throw("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !") - - frappe.db.set(self.doc,'status','Cancelled') + + frappe.db.set(self,'status','Cancelled') self.update_ordered_qty() - + self.update_stock() self.update_prevdoc_status() pc_obj.update_last_purchase_rate(self, 0) - + self.make_cancel_gl_entries() - + def get_current_stock(self): - for d in getlist(self.doclist, 'pr_raw_material_details'): - if self.doc.supplier_warehouse: - bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.rm_item_code, self.doc.supplier_warehouse), as_dict = 1) + for d in self.get('pr_raw_material_details'): + if self.supplier_warehouse: + bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.rm_item_code, self.supplier_warehouse), as_dict = 1) d.current_stock = bin and flt(bin[0]['actual_qty']) or 0 def get_rate(self,arg): - return get_obj('Purchase Common').get_rate(arg,self) - + return frappe.get_doc('Purchase Common').get_rate(arg,self) + def get_gl_entries(self, warehouse_account=None): against_stock_account = self.get_company_default("stock_received_but_not_billed") - - gl_entries = super(DocType, self).get_gl_entries(warehouse_account, against_stock_account) - return gl_entries - - -@frappe.whitelist() -def make_purchase_invoice(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist - - def set_missing_values(source, target): - bean = frappe.bean(target) - bean.run_method("set_missing_values") - doclist = get_mapped_doclist("Purchase Receipt", source_name, { + gl_entries = super(PurchaseReceipt, self).get_gl_entries(warehouse_account, against_stock_account) + return gl_entries + + +@frappe.whitelist() +def make_purchase_invoice(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc + + def set_missing_values(source, target): + doc = frappe.get_doc(target) + doc.run_method("set_missing_values") + + doclist = get_mapped_doc("Purchase Receipt", source_name, { "Purchase Receipt": { - "doctype": "Purchase Invoice", + "doctype": "Purchase Invoice", "validation": { "docstatus": ["=", 1], } - }, + }, "Purchase Receipt Item": { - "doctype": "Purchase Invoice Item", + "doctype": "Purchase Invoice Item", "field_map": { - "name": "pr_detail", - "parent": "purchase_receipt", - "prevdoc_detail_docname": "po_detail", - "prevdoc_docname": "purchase_order", + "name": "pr_detail", + "parent": "purchase_receipt", + "prevdoc_detail_docname": "po_detail", + "prevdoc_docname": "purchase_order", }, - }, + }, "Purchase Taxes and Charges": { - "doctype": "Purchase Taxes and Charges", + "doctype": "Purchase Taxes and Charges", "add_if_empty": True } - }, target_doclist, set_missing_values) + }, target_doc, set_missing_values) - return [d.fields for d in doclist] \ No newline at end of file + return doclist diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.txt b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.txt deleted file mode 100755 index 5b83710c767..00000000000 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.txt +++ /dev/null @@ -1,853 +0,0 @@ -[ - { - "creation": "2013-05-21 16:16:39", - "docstatus": 0, - "modified": "2014-02-17 12:01:00", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-truck", - "is_submittable": 1, - "module": "Stock", - "name": "__common__", - "read_only_onload": 1, - "search_fields": "status, posting_date, supplier" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Purchase Receipt", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Purchase Receipt", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Purchase Receipt" - }, - { - "doctype": "DocField", - "fieldname": "supplier_section", - "fieldtype": "Section Break", - "label": "Supplier", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "\nGRN", - "print_hide": 1, - "reqd": 1 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "supplier", - "fieldtype": "Link", - "in_filter": 1, - "label": "Supplier", - "oldfieldname": "supplier", - "oldfieldtype": "Link", - "options": "Supplier", - "print_hide": 1, - "print_width": "150px", - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "depends_on": "supplier", - "doctype": "DocField", - "fieldname": "supplier_name", - "fieldtype": "Data", - "hidden": 0, - "in_list_view": 1, - "label": "Supplier Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Text", - "hidden": 1, - "label": "Mobile No", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Text", - "hidden": 1, - "label": "Contact Email", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Posting Date", - "no_copy": 1, - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "print_hide": 1, - "print_width": "100px", - "reqd": 1, - "search_index": 1, - "width": "100px" - }, - { - "description": "Time at which materials were received", - "doctype": "DocField", - "fieldname": "posting_time", - "fieldtype": "Time", - "in_filter": 0, - "label": "Posting Time", - "no_copy": 1, - "oldfieldname": "posting_time", - "oldfieldtype": "Time", - "print_hide": 1, - "print_width": "100px", - "reqd": 1, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "challan_no", - "fieldtype": "Data", - "hidden": 1, - "label": "Supplier Shipment No", - "no_copy": 1, - "oldfieldname": "challan_no", - "oldfieldtype": "Data", - "print_hide": 0, - "print_width": "100px", - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "challan_date", - "fieldtype": "Date", - "hidden": 1, - "label": "Supplier Shipment Date", - "no_copy": 1, - "oldfieldname": "challan_date", - "oldfieldtype": "Date", - "print_hide": 0, - "print_width": "100px", - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "currency_price_list", - "fieldtype": "Section Break", - "label": "Currency and Price List", - "options": "icon-tag" - }, - { - "doctype": "DocField", - "fieldname": "currency", - "fieldtype": "Link", - "label": "Currency", - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", - "print_hide": 1, - "reqd": 1 - }, - { - "description": "Rate at which supplier's currency is converted to company's base currency", - "doctype": "DocField", - "fieldname": "conversion_rate", - "fieldtype": "Float", - "label": "Exchange Rate", - "oldfieldname": "conversion_rate", - "oldfieldtype": "Currency", - "print_hide": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "buying_price_list", - "fieldtype": "Link", - "label": "Price List", - "options": "Price List", - "print_hide": 1 - }, - { - "depends_on": "buying_price_list", - "doctype": "DocField", - "fieldname": "price_list_currency", - "fieldtype": "Link", - "hidden": 0, - "label": "Price List Currency", - "options": "Currency", - "print_hide": 1, - "read_only": 1 - }, - { - "depends_on": "buying_price_list", - "doctype": "DocField", - "fieldname": "plc_conversion_rate", - "fieldtype": "Float", - "label": "Price List Exchange Rate", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "items", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart" - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "purchase_receipt_details", - "fieldtype": "Table", - "label": "Purchase Receipt Items", - "oldfieldname": "purchase_receipt_details", - "oldfieldtype": "Table", - "options": "Purchase Receipt Item", - "print_hide": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "oldfieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total_import", - "fieldtype": "Currency", - "label": "Net Total", - "oldfieldname": "net_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "get_current_stock", - "fieldtype": "Button", - "label": "Get Current Stock", - "oldfieldtype": "Button", - "options": "get_current_stock", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_27", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "net_total", - "fieldtype": "Currency", - "label": "Net Total (Company Currency)", - "oldfieldname": "net_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "reqd": 1, - "width": "150px" - }, - { - "description": "Add / Edit Taxes and Charges", - "doctype": "DocField", - "fieldname": "taxes", - "fieldtype": "Section Break", - "label": "Taxes and Charges", - "oldfieldtype": "Section Break", - "options": "icon-money" - }, - { - "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.", - "doctype": "DocField", - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "label": "Taxes and Charges", - "oldfieldname": "purchase_other_charges", - "oldfieldtype": "Link", - "options": "Purchase Taxes and Charges Master", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "other_charges", - "fieldtype": "Table", - "label": "Purchase Taxes and Charges", - "oldfieldname": "purchase_tax_details", - "oldfieldtype": "Table", - "options": "Purchase Taxes and Charges" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_calculation", - "fieldtype": "HTML", - "label": "Taxes and Charges Calculation", - "oldfieldtype": "HTML", - "print_hide": 1 - }, - { - "description": "Detailed Breakup of the totals", - "doctype": "DocField", - "fieldname": "totals", - "fieldtype": "Section Break", - "label": "Totals", - "oldfieldtype": "Section Break", - "options": "icon-money" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_added_import", - "fieldtype": "Currency", - "label": "Taxes and Charges Added", - "oldfieldname": "other_charges_added_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_deducted_import", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted", - "oldfieldname": "other_charges_deducted_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "grand_total_import", - "fieldtype": "Currency", - "label": "Grand Total", - "oldfieldname": "grand_total_import", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "in_words_import", - "fieldtype": "Data", - "label": "In Words", - "oldfieldname": "in_words_import", - "oldfieldtype": "Data", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "other_charges_added", - "fieldtype": "Currency", - "label": "Taxes and Charges Added (Company Currency)", - "oldfieldname": "other_charges_added", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "other_charges_deducted", - "fieldtype": "Currency", - "label": "Taxes and Charges Deducted (Company Currency)", - "oldfieldname": "other_charges_deducted", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "total_tax", - "fieldtype": "Currency", - "label": "Total Tax (Company Currency)", - "oldfieldname": "total_tax", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "grand_total", - "fieldtype": "Currency", - "label": "Grand Total (Company Currency)", - "oldfieldname": "grand_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "rounded_total", - "fieldtype": "Currency", - "label": "Rounded Total (Company Currency)", - "oldfieldname": "rounded_total", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "description": "In Words will be visible once you save the Purchase Receipt.", - "doctype": "DocField", - "fieldname": "in_words", - "fieldtype": "Data", - "label": "In Words (Company Currency)", - "oldfieldname": "in_words", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "terms_section_break", - "fieldtype": "Section Break", - "label": "Terms and Conditions", - "oldfieldtype": "Section Break", - "options": "icon-legal" - }, - { - "doctype": "DocField", - "fieldname": "tc_name", - "fieldtype": "Link", - "label": "Terms", - "oldfieldname": "tc_name", - "oldfieldtype": "Link", - "options": "Terms and Conditions", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "terms", - "fieldtype": "Text Editor", - "label": "Terms and Conditions1", - "oldfieldname": "terms", - "oldfieldtype": "Text Editor" - }, - { - "depends_on": "supplier", - "doctype": "DocField", - "fieldname": "contact_section", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn" - }, - { - "doctype": "DocField", - "fieldname": "supplier_address", - "fieldtype": "Link", - "label": "Supplier Address", - "options": "Address", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_57", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "label": "Contact Person", - "options": "Contact", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text" - }, - { - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nDraft\nSubmitted\nCancelled", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "default": "No", - "description": "Select \"Yes\" for sub - contracting items", - "doctype": "DocField", - "fieldname": "is_subcontracted", - "fieldtype": "Select", - "label": "Is Subcontracted", - "oldfieldname": "is_subcontracted", - "oldfieldtype": "Select", - "options": "\nYes\nNo", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "hidden": 1, - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "options": "Purchase Receipt", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "range", - "fieldtype": "Data", - "hidden": 1, - "label": "Range", - "oldfieldname": "range", - "oldfieldtype": "Data", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "bill_no", - "fieldtype": "Data", - "hidden": 1, - "label": "Bill No", - "oldfieldname": "bill_no", - "oldfieldtype": "Data", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "bill_date", - "fieldtype": "Date", - "hidden": 1, - "label": "Bill Date", - "oldfieldname": "bill_date", - "oldfieldtype": "Date", - "print_hide": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "letter_head", - "fieldtype": "Select", - "label": "Letter Head", - "options": "link:Letter Head", - "print_hide": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "label": "Print Heading", - "no_copy": 1, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "print_hide": 1, - "report_hide": 1 - }, - { - "description": "Select the relevant company name if you have multiple companies", - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Company", - "no_copy": 0, - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "print_width": "150px", - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "print_width": "150px", - "reqd": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_hide": 1, - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "other_details", - "fieldtype": "HTML", - "hidden": 1, - "label": "Other Details", - "oldfieldtype": "HTML", - "options": "
Other Details
", - "print_hide": 1, - "print_width": "30%", - "reqd": 0, - "width": "30%" - }, - { - "description": "Warehouse where you are maintaining stock of rejected items", - "doctype": "DocField", - "fieldname": "rejected_warehouse", - "fieldtype": "Link", - "label": "Rejected Warehouse", - "no_copy": 1, - "oldfieldname": "rejected_warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "reqd": 0 - }, - { - "description": "Supplier warehouse where you have issued raw materials for sub - contracting", - "doctype": "DocField", - "fieldname": "supplier_warehouse", - "fieldtype": "Link", - "label": "Supplier Warehouse", - "no_copy": 1, - "oldfieldname": "supplier_warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "print_width": "50px", - "width": "50px" - }, - { - "doctype": "DocField", - "fieldname": "instructions", - "fieldtype": "Small Text", - "label": "Instructions", - "oldfieldname": "instructions", - "oldfieldtype": "Text" - }, - { - "doctype": "DocField", - "fieldname": "remarks", - "fieldtype": "Small Text", - "label": "Remarks", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "transporter_info", - "fieldtype": "Section Break", - "label": "Transporter Info", - "options": "icon-truck" - }, - { - "doctype": "DocField", - "fieldname": "transporter_name", - "fieldtype": "Data", - "label": "Transporter Name", - "oldfieldname": "transporter_name", - "oldfieldtype": "Data" - }, - { - "description": "Transporter lorry number", - "doctype": "DocField", - "fieldname": "lr_no", - "fieldtype": "Data", - "label": "LR No", - "no_copy": 1, - "oldfieldname": "lr_no", - "oldfieldtype": "Data", - "print_hide": 0, - "print_width": "100px", - "width": "100px" - }, - { - "description": "Date on which lorry started from supplier warehouse", - "doctype": "DocField", - "fieldname": "lr_date", - "fieldtype": "Date", - "label": "LR Date", - "no_copy": 1, - "oldfieldname": "lr_date", - "oldfieldtype": "Date", - "print_hide": 0, - "print_width": "100px", - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "column_break5", - "fieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "description": "Following table will show values if items are sub - contracted. These values will be fetched from the master of \"Bill of Materials\" of sub - contracted items.", - "doctype": "DocField", - "fieldname": "raw_material_details", - "fieldtype": "Section Break", - "label": "Raw Materials Supplied", - "oldfieldtype": "Section Break", - "options": "icon-table", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "pr_raw_material_details", - "fieldtype": "Table", - "label": "Purchase Receipt Item Supplieds", - "no_copy": 1, - "oldfieldname": "pr_raw_material_details", - "oldfieldtype": "Table", - "options": "Purchase Receipt Item Supplied", - "print_hide": 1, - "read_only": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Material Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Material User", - "submit": 1, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Purchase User", - "submit": 1, - "write": 1 - }, - { - "cancel": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Supplier" - } -] diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 862bd846f87..0aa3accd4ad 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -14,235 +14,120 @@ class TestPurchaseReceipt(unittest.TestCase): set_perpetual_inventory(0) from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice - pr = frappe.bean(copy=test_records[0]).insert() - - self.assertRaises(frappe.ValidationError, make_purchase_invoice, - pr.doc.name) + pr = frappe.copy_doc(test_records[0]).insert() - pr = frappe.bean("Purchase Receipt", pr.doc.name) + self.assertRaises(frappe.ValidationError, make_purchase_invoice, + pr.name) + + pr = frappe.get_doc("Purchase Receipt", pr.name) pr.submit() - pi = make_purchase_invoice(pr.doc.name) - - self.assertEquals(pi[0]["doctype"], "Purchase Invoice") - self.assertEquals(len(pi), len(pr.doclist)) - + pi = make_purchase_invoice(pr.name) + + self.assertEquals(pi.doctype, "Purchase Invoice") + self.assertEquals(len(pi.get("entries")), len(pr.get("purchase_receipt_details"))) + # modify rate - pi[1]["rate"] = 200 - self.assertRaises(frappe.ValidationError, frappe.bean(pi).submit) - + pi.get("entries")[0].rate = 200 + self.assertRaises(frappe.ValidationError, frappe.get_doc(pi).submit) + def test_purchase_receipt_no_gl_entry(self): self._clear_stock_account_balance() set_perpetual_inventory(0) - pr = frappe.bean(copy=test_records[0]) + pr = frappe.copy_doc(test_records[0]) pr.insert() pr.submit() - - stock_value, stock_value_difference = frappe.db.get_value("Stock Ledger Entry", - {"voucher_type": "Purchase Receipt", "voucher_no": pr.doc.name, - "item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"}, + + stock_value, stock_value_difference = frappe.db.get_value("Stock Ledger Entry", + {"voucher_type": "Purchase Receipt", "voucher_no": pr.name, + "item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"}, ["stock_value", "stock_value_difference"]) self.assertEqual(stock_value, 375) self.assertEqual(stock_value_difference, 375) - - bin_stock_value = frappe.db.get_value("Bin", {"item_code": "_Test Item", + + bin_stock_value = frappe.db.get_value("Bin", {"item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"}, "stock_value") self.assertEqual(bin_stock_value, 375) - - self.assertFalse(get_gl_entries("Purchase Receipt", pr.doc.name)) - + + self.assertFalse(get_gl_entries("Purchase Receipt", pr.name)) + def test_purchase_receipt_gl_entry(self): self._clear_stock_account_balance() - + set_perpetual_inventory() self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1) - - pr = frappe.bean(copy=test_records[0]) + + pr = frappe.copy_doc(test_records[0]) pr.insert() pr.submit() - - gl_entries = get_gl_entries("Purchase Receipt", pr.doc.name) - + + gl_entries = get_gl_entries("Purchase Receipt", pr.name) + self.assertTrue(gl_entries) - - stock_in_hand_account = frappe.db.get_value("Account", - {"master_name": pr.doclist[1].warehouse}) - fixed_asset_account = frappe.db.get_value("Account", - {"master_name": pr.doclist[2].warehouse}) - + + stock_in_hand_account = frappe.db.get_value("Account", + {"master_name": pr.get("purchase_receipt_details")[0].warehouse}) + fixed_asset_account = frappe.db.get_value("Account", + {"master_name": pr.get("purchase_receipt_details")[1].warehouse}) + expected_values = { stock_in_hand_account: [375.0, 0.0], fixed_asset_account: [375.0, 0.0], "Stock Received But Not Billed - _TC": [0.0, 750.0] } - + for gle in gl_entries: self.assertEquals(expected_values[gle.account][0], gle.debit) self.assertEquals(expected_values[gle.account][1], gle.credit) - + pr.cancel() - self.assertFalse(get_gl_entries("Purchase Receipt", pr.doc.name)) - + self.assertFalse(get_gl_entries("Purchase Receipt", pr.name)) + set_perpetual_inventory(0) - + def _clear_stock_account_balance(self): frappe.db.sql("delete from `tabStock Ledger Entry`") frappe.db.sql("""delete from `tabBin`""") frappe.db.sql("""delete from `tabGL Entry`""") - + def test_subcontracting(self): - pr = frappe.bean(copy=test_records[1]) + pr = frappe.copy_doc(test_records[1]) pr.run_method("calculate_taxes_and_totals") pr.insert() - - self.assertEquals(pr.doclist[1].rm_supp_cost, 70000.0) - self.assertEquals(len(pr.doclist.get({"parentfield": "pr_raw_material_details"})), 2) - + + self.assertEquals(pr.get("purchase_receipt_details")[0].rm_supp_cost, 70000.0) + self.assertEquals(len(pr.get("pr_raw_material_details")), 2) + def test_serial_no_supplier(self): - pr = frappe.bean(copy=test_records[0]) - pr.doclist[1].item_code = "_Test Serialized Item With Series" - pr.doclist[1].qty = 1 - pr.doclist[1].received_qty = 1 + pr = frappe.copy_doc(test_records[0]) + pr.get("purchase_receipt_details")[0].item_code = "_Test Serialized Item With Series" + pr.get("purchase_receipt_details")[0].qty = 1 + pr.get("purchase_receipt_details")[0].received_qty = 1 pr.insert() pr.submit() - - self.assertEquals(frappe.db.get_value("Serial No", pr.doclist[1].serial_no, - "supplier"), pr.doc.supplier) - + + self.assertEquals(frappe.db.get_value("Serial No", pr.get("purchase_receipt_details")[0].serial_no, + "supplier"), pr.supplier) + return pr - + def test_serial_no_cancel(self): pr = self.test_serial_no_supplier() pr.cancel() - - self.assertFalse(frappe.db.get_value("Serial No", pr.doclist[1].serial_no, + + self.assertFalse(frappe.db.get_value("Serial No", pr.get("purchase_receipt_details")[0].serial_no, "warehouse")) - + def get_gl_entries(voucher_type, voucher_no): return frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type=%s and voucher_no=%s order by account desc""", (voucher_type, voucher_no), as_dict=1) - + def set_perpetual_inventory(enable=1): - accounts_settings = frappe.bean("Accounts Settings") - accounts_settings.doc.auto_accounting_for_stock = enable + accounts_settings = frappe.get_doc("Accounts Settings") + accounts_settings.auto_accounting_for_stock = enable accounts_settings.save() - - + + test_dependencies = ["BOM"] -test_records = [ - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "doctype": "Purchase Receipt", - "fiscal_year": "_Test Fiscal Year 2013", - "posting_date": "2013-02-12", - "posting_time": "15:33:30", - "supplier": "_Test Supplier", - "net_total": 500.0, - "grand_total": 720.0, - "naming_series": "_T-Purchase Receipt-", - "buying_price_list": "_Test Price List" - }, - { - "conversion_factor": 1.0, - "description": "_Test Item", - "doctype": "Purchase Receipt Item", - "item_code": "_Test Item", - "item_name": "_Test Item", - "parentfield": "purchase_receipt_details", - "received_qty": 5.0, - "qty": 5.0, - "rejected_qty": 0.0, - "rate": 50.0, - "base_amount": 250.0, - "warehouse": "_Test Warehouse - _TC", - "stock_uom": "Nos", - "uom": "_Test UOM", - }, - { - "conversion_factor": 1.0, - "description": "_Test Item", - "doctype": "Purchase Receipt Item", - "item_code": "_Test Item", - "item_name": "_Test Item", - "parentfield": "purchase_receipt_details", - "received_qty": 5.0, - "qty": 5.0, - "rejected_qty": 0.0, - "rate": 50.0, - "base_amount": 250.0, - "warehouse": "_Test Warehouse 1 - _TC", - "stock_uom": "Nos", - "uom": "_Test UOM", - }, - { - "account_head": "_Test Account Shipping Charges - _TC", - "add_deduct_tax": "Add", - "category": "Valuation and Total", - "charge_type": "Actual", - "description": "Shipping Charges", - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "rate": 100.0, - "tax_amount": 100.0, - }, - { - "account_head": "_Test Account VAT - _TC", - "add_deduct_tax": "Add", - "category": "Total", - "charge_type": "Actual", - "description": "VAT", - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "rate": 120.0, - "tax_amount": 120.0, - }, - { - "account_head": "_Test Account Customs Duty - _TC", - "add_deduct_tax": "Add", - "category": "Valuation", - "charge_type": "Actual", - "description": "Customs Duty", - "doctype": "Purchase Taxes and Charges", - "parentfield": "other_charges", - "rate": 150.0, - "tax_amount": 150.0, - }, - ], - [ - { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "doctype": "Purchase Receipt", - "fiscal_year": "_Test Fiscal Year 2013", - "posting_date": "2013-02-12", - "posting_time": "15:33:30", - "is_subcontracted": "Yes", - "supplier_warehouse": "_Test Warehouse - _TC", - "supplier": "_Test Supplier", - "net_total": 5000.0, - "grand_total": 5000.0, - "buying_price_list": "_Test Price List" - }, - { - "conversion_factor": 1.0, - "description": "_Test FG Item", - "doctype": "Purchase Receipt Item", - "item_code": "_Test FG Item", - "item_name": "_Test FG Item", - "parentfield": "purchase_receipt_details", - "received_qty": 10.0, - "qty": 10.0, - "rejected_qty": 0.0, - "rate": 500.0, - "base_amount": 5000.0, - "warehouse": "_Test Warehouse - _TC", - "stock_uom": "Nos", - "uom": "_Test UOM", - } - ], -] \ No newline at end of file +test_records = frappe.get_test_records('Purchase Receipt') diff --git a/erpnext/stock/doctype/purchase_receipt/test_records.json b/erpnext/stock/doctype/purchase_receipt/test_records.json new file mode 100644 index 00000000000..7dd4f7f739a --- /dev/null +++ b/erpnext/stock/doctype/purchase_receipt/test_records.json @@ -0,0 +1,118 @@ +[ + { + "buying_price_list": "_Test Price List", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "doctype": "Purchase Receipt", + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 720.0, + "naming_series": "_T-Purchase Receipt-", + "net_total": 500.0, + "other_charges": [ + { + "account_head": "_Test Account Shipping Charges - _TC", + "add_deduct_tax": "Add", + "category": "Valuation and Total", + "charge_type": "Actual", + "description": "Shipping Charges", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 100.0, + "tax_amount": 100.0 + }, + { + "account_head": "_Test Account VAT - _TC", + "add_deduct_tax": "Add", + "category": "Total", + "charge_type": "Actual", + "description": "VAT", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 120.0, + "tax_amount": 120.0 + }, + { + "account_head": "_Test Account Customs Duty - _TC", + "add_deduct_tax": "Add", + "category": "Valuation", + "charge_type": "Actual", + "description": "Customs Duty", + "doctype": "Purchase Taxes and Charges", + "parentfield": "other_charges", + "rate": 150.0, + "tax_amount": 150.0 + } + ], + "posting_date": "2013-02-12", + "posting_time": "15:33:30", + "purchase_receipt_details": [ + { + "base_amount": 250.0, + "conversion_factor": 1.0, + "description": "_Test Item", + "doctype": "Purchase Receipt Item", + "item_code": "_Test Item", + "item_name": "_Test Item", + "parentfield": "purchase_receipt_details", + "qty": 5.0, + "rate": 50.0, + "received_qty": 5.0, + "rejected_qty": 0.0, + "stock_uom": "Nos", + "uom": "_Test UOM", + "warehouse": "_Test Warehouse - _TC" + }, + { + "base_amount": 250.0, + "conversion_factor": 1.0, + "description": "_Test Item", + "doctype": "Purchase Receipt Item", + "item_code": "_Test Item", + "item_name": "_Test Item", + "parentfield": "purchase_receipt_details", + "qty": 5.0, + "rate": 50.0, + "received_qty": 5.0, + "rejected_qty": 0.0, + "stock_uom": "Nos", + "uom": "_Test UOM", + "warehouse": "_Test Warehouse 1 - _TC" + } + ], + "supplier": "_Test Supplier" + }, + { + "buying_price_list": "_Test Price List", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "doctype": "Purchase Receipt", + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 5000.0, + "is_subcontracted": "Yes", + "net_total": 5000.0, + "posting_date": "2013-02-12", + "posting_time": "15:33:30", + "purchase_receipt_details": [ + { + "base_amount": 5000.0, + "conversion_factor": 1.0, + "description": "_Test FG Item", + "doctype": "Purchase Receipt Item", + "item_code": "_Test FG Item", + "item_name": "_Test FG Item", + "parentfield": "purchase_receipt_details", + "qty": 10.0, + "rate": 500.0, + "received_qty": 10.0, + "rejected_qty": 0.0, + "stock_uom": "Nos", + "uom": "_Test UOM", + "warehouse": "_Test Warehouse - _TC" + } + ], + "supplier": "_Test Supplier", + "supplier_warehouse": "_Test Warehouse - _TC" + } +] \ No newline at end of file diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json new file mode 100755 index 00000000000..0c8100ce7db --- /dev/null +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -0,0 +1,561 @@ +{ + "autoname": "GRND/.#######", + "creation": "2013-05-24 19:29:10.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "search_index": 1, + "width": "100px" + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_filter": 0, + "in_list_view": 0, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 0, + "reqd": 1, + "width": "300px" + }, + { + "fieldname": "received_and_accepted", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Received and Accepted", + "permlevel": 0 + }, + { + "fieldname": "received_qty", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Recd Quantity", + "oldfieldname": "received_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Accepted Quantity", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "100px", + "read_only": 0, + "width": "100px" + }, + { + "fieldname": "rejected_qty", + "fieldtype": "Float", + "in_filter": 0, + "in_list_view": 0, + "label": "Rejected Quantity", + "oldfieldname": "rejected_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "oldfieldname": "uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Stock UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "conversion_factor", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Conversion Factor", + "oldfieldname": "conversion_factor", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "rate_and_amount", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Rate and Amount", + "permlevel": 0 + }, + { + "fieldname": "price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate", + "options": "currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "discount_percentage", + "fieldtype": "Float", + "in_list_view": 0, + "label": "Discount %", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "base_price_list_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Price List Rate (Company Currency)", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "sec_break1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "rate", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Rate", + "oldfieldname": "import_rate", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "print_hide": 0, + "print_width": "100px", + "read_only": 0, + "width": "100px" + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "oldfieldname": "import_amount", + "oldfieldtype": "Currency", + "options": "currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "base_rate", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Rate (Company Currency)", + "oldfieldname": "purchase_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 1, + "width": "100px" + }, + { + "fieldname": "base_amount", + "fieldtype": "Currency", + "in_list_view": 0, + "label": "Amount (Company Currency)", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "width": "100px" + }, + { + "fieldname": "pricing_rule_for_price", + "fieldtype": "Link", + "label": "Pricing Rule For Price", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "pricing_rule_for_discount", + "fieldtype": "Link", + "label": "Pricing Rule For Discount", + "options": "Pricing Rule", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "warehouse_and_reference", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Warehouse and Reference", + "permlevel": 0 + }, + { + "fieldname": "warehouse", + "fieldtype": "Link", + "hidden": 0, + "in_list_view": 0, + "label": "Accepted Warehouse", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "width": "100px" + }, + { + "fieldname": "rejected_warehouse", + "fieldtype": "Link", + "hidden": 0, + "label": "Rejected Warehouse", + "no_copy": 1, + "oldfieldname": "rejected_warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 0, + "width": "100px" + }, + { + "default": ":Company", + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", + "fieldname": "cost_center", + "fieldtype": "Link", + "label": "Cost Center", + "options": "Cost Center", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "project_name", + "fieldtype": "Link", + "in_filter": 1, + "label": "Project Name", + "options": "Project", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "qa_no", + "fieldtype": "Link", + "label": "Quality Inspection", + "no_copy": 1, + "oldfieldname": "qa_no", + "oldfieldtype": "Link", + "options": "Quality Inspection", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "schedule_date", + "fieldtype": "Date", + "label": "Required By", + "no_copy": 0, + "oldfieldname": "schedule_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0, + "reqd": 0 + }, + { + "fieldname": "stock_qty", + "fieldtype": "Float", + "label": "Qty as per Stock UOM", + "oldfieldname": "stock_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "100px", + "read_only": 1, + "width": "100px" + }, + { + "fieldname": "prevdoc_doctype", + "fieldtype": "Data", + "hidden": 1, + "label": "Prevdoc Doctype", + "no_copy": 1, + "oldfieldname": "prevdoc_doctype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "prevdoc_docname", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Purchase Order", + "no_copy": 1, + "oldfieldname": "prevdoc_docname", + "oldfieldtype": "Link", + "options": "Purchase Order", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "reqd": 0, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "prevdoc_detail_docname", + "fieldtype": "Data", + "hidden": 1, + "in_filter": 1, + "label": "Purchase Order Item No", + "no_copy": 1, + "oldfieldname": "prevdoc_detail_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "col_break5", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "serial_no", + "fieldtype": "Text", + "in_filter": 1, + "in_list_view": 1, + "label": "Serial No", + "no_copy": 1, + "oldfieldname": "serial_no", + "oldfieldtype": "Text", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "report_hide": 0 + }, + { + "fieldname": "rejected_serial_no", + "fieldtype": "Text", + "label": "Rejected Serial No", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "batch_no", + "fieldtype": "Link", + "label": "Batch No", + "oldfieldname": "batch_no", + "oldfieldtype": "Link", + "options": "Batch", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "brand", + "fieldtype": "Link", + "hidden": 1, + "label": "Brand", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "hidden": 1, + "in_filter": 1, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "rm_supp_cost", + "fieldtype": "Currency", + "hidden": 1, + "in_filter": 0, + "label": "Raw Materials Supplied Cost", + "no_copy": 1, + "oldfieldname": "rm_supp_cost", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "item_tax_amount", + "fieldtype": "Currency", + "hidden": 1, + "label": "Item Tax Amount", + "no_copy": 1, + "oldfieldname": "item_tax_amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "reqd": 0, + "search_index": 0, + "width": "150px" + }, + { + "fieldname": "valuation_rate", + "fieldtype": "Currency", + "hidden": 1, + "in_filter": 0, + "label": "Valuation Rate", + "no_copy": 1, + "oldfieldname": "valuation_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_hide": 1, + "print_width": "80px", + "read_only": 1, + "width": "80px" + }, + { + "description": "Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges", + "fieldname": "item_tax_rate", + "fieldtype": "Small Text", + "hidden": 1, + "in_filter": 0, + "label": "Item Tax Rate", + "oldfieldname": "item_tax_rate", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1 + }, + { + "allow_on_submit": 1, + "fieldname": "page_break", + "fieldtype": "Check", + "label": "Page Break", + "oldfieldname": "page_break", + "oldfieldtype": "Check", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-28 11:27:09.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Purchase Receipt Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py index 26c87f1c04a..35fca0d6c53 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class PurchaseReceiptItem(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt deleted file mode 100755 index cde791178fd..00000000000 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt +++ /dev/null @@ -1,574 +0,0 @@ -[ - { - "creation": "2013-05-24 19:29:10", - "docstatus": 0, - "modified": "2014-02-28 11:27:09", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "GRND/.#######", - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Purchase Receipt Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Purchase Receipt Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "search_index": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_filter": 0, - "in_list_view": 0, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "print_width": "300px", - "read_only": 0, - "reqd": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "received_and_accepted", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Received and Accepted" - }, - { - "doctype": "DocField", - "fieldname": "received_qty", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Recd Quantity", - "oldfieldname": "received_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Accepted Quantity", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "print_width": "100px", - "read_only": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "rejected_qty", - "fieldtype": "Float", - "in_filter": 0, - "in_list_view": 0, - "label": "Rejected Quantity", - "oldfieldname": "rejected_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "oldfieldname": "uom", - "oldfieldtype": "Link", - "options": "UOM", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Stock UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "conversion_factor", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Conversion Factor", - "oldfieldname": "conversion_factor", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "rate_and_amount", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Rate and Amount" - }, - { - "doctype": "DocField", - "fieldname": "price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate", - "options": "currency", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "discount_percentage", - "fieldtype": "Float", - "in_list_view": 0, - "label": "Discount %", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "base_price_list_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Price List Rate (Company Currency)", - "options": "Company:company:default_currency", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "sec_break1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "rate", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Rate", - "oldfieldname": "import_rate", - "oldfieldtype": "Currency", - "options": "currency", - "print_hide": 0, - "print_width": "100px", - "read_only": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Amount", - "oldfieldname": "import_amount", - "oldfieldtype": "Currency", - "options": "currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break4", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "base_rate", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Rate (Company Currency)", - "oldfieldname": "purchase_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "base_amount", - "fieldtype": "Currency", - "in_list_view": 0, - "label": "Amount (Company Currency)", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_price", - "fieldtype": "Link", - "label": "Pricing Rule For Price", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "pricing_rule_for_discount", - "fieldtype": "Link", - "label": "Pricing Rule For Discount", - "options": "Pricing Rule", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "warehouse_and_reference", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Warehouse and Reference" - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "hidden": 0, - "in_list_view": 0, - "label": "Accepted Warehouse", - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "rejected_warehouse", - "fieldtype": "Link", - "hidden": 0, - "label": "Rejected Warehouse", - "no_copy": 1, - "oldfieldname": "rejected_warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "print_width": "100px", - "read_only": 0, - "width": "100px" - }, - { - "default": ":Company", - "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "label": "Cost Center", - "options": "Cost Center", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "project_name", - "fieldtype": "Link", - "in_filter": 1, - "label": "Project Name", - "options": "Project", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "qa_no", - "fieldtype": "Link", - "label": "Quality Inspection", - "no_copy": 1, - "oldfieldname": "qa_no", - "oldfieldtype": "Link", - "options": "Quality Inspection", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "schedule_date", - "fieldtype": "Date", - "label": "Required By", - "no_copy": 0, - "oldfieldname": "schedule_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 1, - "report_hide": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "stock_qty", - "fieldtype": "Float", - "label": "Qty as per Stock UOM", - "oldfieldname": "stock_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_doctype", - "fieldtype": "Data", - "hidden": 1, - "label": "Prevdoc Doctype", - "no_copy": 1, - "oldfieldname": "prevdoc_doctype", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_docname", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Purchase Order", - "no_copy": 1, - "oldfieldname": "prevdoc_docname", - "oldfieldtype": "Link", - "options": "Purchase Order", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "reqd": 0, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_detail_docname", - "fieldtype": "Data", - "hidden": 1, - "in_filter": 1, - "label": "Purchase Order Item No", - "no_copy": 1, - "oldfieldname": "prevdoc_detail_docname", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "col_break5", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Text", - "in_filter": 1, - "in_list_view": 1, - "label": "Serial No", - "no_copy": 1, - "oldfieldname": "serial_no", - "oldfieldtype": "Text", - "print_hide": 0, - "read_only": 0, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "rejected_serial_no", - "fieldtype": "Text", - "label": "Rejected Serial No", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "batch_no", - "fieldtype": "Link", - "label": "Batch No", - "oldfieldname": "batch_no", - "oldfieldtype": "Link", - "options": "Batch", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Link", - "hidden": 1, - "label": "Brand", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "print_hide": 1, - "read_only": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 1, - "in_filter": 1, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "rm_supp_cost", - "fieldtype": "Currency", - "hidden": 1, - "in_filter": 0, - "label": "Raw Materials Supplied Cost", - "no_copy": 1, - "oldfieldname": "rm_supp_cost", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "item_tax_amount", - "fieldtype": "Currency", - "hidden": 1, - "label": "Item Tax Amount", - "no_copy": 1, - "oldfieldname": "item_tax_amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "reqd": 0, - "search_index": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "valuation_rate", - "fieldtype": "Currency", - "hidden": 1, - "in_filter": 0, - "label": "Valuation Rate", - "no_copy": 1, - "oldfieldname": "valuation_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_hide": 1, - "print_width": "80px", - "read_only": 1, - "width": "80px" - }, - { - "description": "Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges", - "doctype": "DocField", - "fieldname": "item_tax_rate", - "fieldtype": "Small Text", - "hidden": 1, - "in_filter": 0, - "label": "Item Tax Rate", - "oldfieldname": "item_tax_rate", - "oldfieldtype": "Small Text", - "print_hide": 1, - "read_only": 1, - "report_hide": 1 - }, - { - "allow_on_submit": 1, - "doctype": "DocField", - "fieldname": "page_break", - "fieldtype": "Check", - "label": "Page Break", - "oldfieldname": "page_break", - "oldfieldtype": "Check", - "print_hide": 1, - "read_only": 0 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/serial_no/serial_no.json b/erpnext/stock/doctype/serial_no/serial_no.json new file mode 100644 index 00000000000..76955780c7e --- /dev/null +++ b/erpnext/stock/doctype/serial_no/serial_no.json @@ -0,0 +1,470 @@ +{ + "allow_attach": 1, + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:serial_no", + "creation": "2013-05-16 10:59:15.000000", + "description": "Distinct unit of an Item", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "details", + "fieldtype": "Section Break", + "label": "Details", + "oldfieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "default": "In Store", + "description": "Only Serial Nos with status \"Available\" can be delivered.", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nAvailable\nNot Available\nDelivered\nPurchase Returned\nSales Returned", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "serial_no", + "fieldtype": "Data", + "in_filter": 0, + "label": "Serial No", + "no_copy": 1, + "oldfieldname": "serial_no", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 0 + }, + { + "description": "Warehouse can only be changed via Stock Entry / Delivery Note / Purchase Receipt", + "fieldname": "warehouse", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Warehouse", + "no_copy": 1, + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "read_only": 1, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Item Name", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_filter": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "read_only": 1, + "search_index": 0, + "width": "300px" + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "in_filter": 0, + "label": "Item Group", + "oldfieldname": "item_group", + "oldfieldtype": "Link", + "options": "Item Group", + "permlevel": 0, + "read_only": 1, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "brand", + "fieldtype": "Link", + "in_filter": 0, + "label": "Brand", + "oldfieldname": "brand", + "oldfieldtype": "Link", + "options": "Brand", + "permlevel": 0, + "read_only": 1, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "purchase_details", + "fieldtype": "Section Break", + "label": "Purchase / Manufacture Details", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "purchase_document_type", + "fieldtype": "Select", + "label": "Creation Document Type", + "no_copy": 1, + "options": "\nPurchase Receipt\nStock Entry", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "purchase_document_no", + "fieldtype": "Data", + "hidden": 0, + "label": "Creation Document No", + "no_copy": 1, + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "purchase_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Creation Date", + "no_copy": 1, + "oldfieldname": "purchase_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 1, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "purchase_time", + "fieldtype": "Time", + "label": "Creation Time", + "no_copy": 1, + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "purchase_rate", + "fieldtype": "Currency", + "in_filter": 0, + "label": "Incoming Rate", + "no_copy": 1, + "oldfieldname": "purchase_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "supplier", + "fieldtype": "Link", + "in_filter": 1, + "label": "Supplier", + "no_copy": 1, + "options": "Supplier", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "supplier_name", + "fieldtype": "Data", + "in_filter": 1, + "label": "Supplier Name", + "no_copy": 1, + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "delivery_details", + "fieldtype": "Section Break", + "label": "Delivery Details", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "delivery_document_type", + "fieldtype": "Select", + "in_filter": 1, + "label": "Delivery Document Type", + "no_copy": 1, + "options": "\nDelivery Note\nSales Invoice\nStock Entry", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "delivery_document_no", + "fieldtype": "Data", + "in_filter": 1, + "label": "Delivery Document No", + "no_copy": 1, + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "delivery_date", + "fieldtype": "Date", + "label": "Delivery Date", + "no_copy": 1, + "oldfieldname": "delivery_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "delivery_time", + "fieldtype": "Time", + "label": "Delivery Time", + "no_copy": 1, + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "is_cancelled", + "fieldtype": "Select", + "hidden": 1, + "label": "Is Cancelled", + "oldfieldname": "is_cancelled", + "oldfieldtype": "Select", + "options": "\nYes\nNo", + "permlevel": 0, + "read_only": 0, + "report_hide": 1 + }, + { + "fieldname": "column_break5", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "in_filter": 1, + "label": "Customer", + "no_copy": 1, + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "search_index": 0 + }, + { + "fieldname": "customer_name", + "fieldtype": "Data", + "in_filter": 1, + "label": "Customer Name", + "no_copy": 1, + "oldfieldname": "customer_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "warranty_amc_details", + "fieldtype": "Section Break", + "label": "Warranty / AMC Details", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break6", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "maintenance_status", + "fieldtype": "Select", + "in_filter": 1, + "label": "Maintenance Status", + "no_copy": 0, + "oldfieldname": "maintenance_status", + "oldfieldtype": "Select", + "options": "\nUnder Warranty\nOut of Warranty\nUnder AMC\nOut of AMC", + "permlevel": 0, + "read_only": 0, + "search_index": 1, + "width": "150px" + }, + { + "fieldname": "warranty_period", + "fieldtype": "Int", + "label": "Warranty Period (Days)", + "oldfieldname": "warranty_period", + "oldfieldtype": "Int", + "permlevel": 0, + "read_only": 0, + "width": "150px" + }, + { + "fieldname": "column_break7", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "warranty_expiry_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Warranty Expiry Date", + "oldfieldname": "warranty_expiry_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0, + "width": "150px" + }, + { + "fieldname": "amc_expiry_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "AMC Expiry Date", + "oldfieldname": "amc_expiry_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0, + "search_index": 0, + "width": "150px" + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "serial_no_details", + "fieldtype": "Text Editor", + "label": "Serial No Details", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "company", + "fieldtype": "Select", + "in_filter": 1, + "label": "Company", + "options": "link:Company", + "permlevel": 0, + "read_only": 1, + "reqd": 1, + "search_index": 1 + } + ], + "icon": "icon-barcode", + "idx": 1, + "in_create": 0, + "modified": "2014-01-20 17:49:26.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Serial No", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Master Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Manager", + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, + "write": 0 + } + ], + "search_fields": "item_code,status" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index d52d48dd8d6..90786550a44 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -20,14 +20,13 @@ class SerialNoStatusError(ValidationError): pass class SerialNoNotExistsError(ValidationError): pass class SerialNoDuplicateError(ValidationError): pass -class DocType(StockController): - def __init__(self, doc, doclist=None): - self.doc = doc - self.doclist = doclist or [] +class SerialNo(StockController): + def __init__(self, arg1, arg2=None): + super(SerialNo, self).__init__(arg1, arg2) self.via_stock_ledger = False def validate(self): - if self.doc.fields.get("__islocal") and self.doc.warehouse: + if self.get("__islocal") and self.warehouse: frappe.throw(_("New Serial No cannot have Warehouse. Warehouse must be \ set by Stock Entry or Purchase Receipt"), SerialNoCannotCreateDirectError) @@ -37,29 +36,29 @@ class DocType(StockController): self.on_stock_ledger_entry() def set_maintenance_status(self): - if not self.doc.warranty_expiry_date and not self.doc.amc_expiry_date: - self.doc.maintenance_status = None + if not self.warranty_expiry_date and not self.amc_expiry_date: + self.maintenance_status = None - if self.doc.warranty_expiry_date and self.doc.warranty_expiry_date < nowdate(): - self.doc.maintenance_status = "Out of Warranty" + if self.warranty_expiry_date and self.warranty_expiry_date < nowdate(): + self.maintenance_status = "Out of Warranty" - if self.doc.amc_expiry_date and self.doc.amc_expiry_date < nowdate(): - self.doc.maintenance_status = "Out of AMC" + if self.amc_expiry_date and self.amc_expiry_date < nowdate(): + self.maintenance_status = "Out of AMC" - if self.doc.amc_expiry_date and self.doc.amc_expiry_date >= nowdate(): - self.doc.maintenance_status = "Under AMC" + if self.amc_expiry_date and self.amc_expiry_date >= nowdate(): + self.maintenance_status = "Under AMC" - if self.doc.warranty_expiry_date and self.doc.warranty_expiry_date >= nowdate(): - self.doc.maintenance_status = "Under Warranty" + if self.warranty_expiry_date and self.warranty_expiry_date >= nowdate(): + self.maintenance_status = "Under Warranty" def validate_warehouse(self): - if not self.doc.fields.get("__islocal"): + if not self.get("__islocal"): item_code, warehouse = frappe.db.get_value("Serial No", - self.doc.name, ["item_code", "warehouse"]) - if item_code != self.doc.item_code: + self.name, ["item_code", "warehouse"]) + if item_code != self.item_code: frappe.throw(_("Item Code cannot be changed for Serial No."), SerialNoCannotCannotChangeError) - if not self.via_stock_ledger and warehouse != self.doc.warehouse: + if not self.via_stock_ledger and warehouse != self.warehouse: frappe.throw(_("Warehouse cannot be changed for Serial No."), SerialNoCannotCannotChangeError) @@ -67,15 +66,15 @@ class DocType(StockController): """ Validate whether serial no is required for this item """ - item = frappe.doc("Item", self.doc.item_code) + item = frappe.get_doc("Item", self.item_code) if item.has_serial_no!="Yes": - frappe.throw(_("Item must have 'Has Serial No' as 'Yes'") + ": " + self.doc.item_code) + frappe.throw(_("Item must have 'Has Serial No' as 'Yes'") + ": " + self.item_code) - self.doc.item_group = item.item_group - self.doc.description = item.description - self.doc.item_name = item.item_name - self.doc.brand = item.brand - self.doc.warranty_period = item.warranty_period + self.item_group = item.item_group + self.description = item.description + self.item_name = item.item_name + self.brand = item.brand + self.warranty_period = item.warranty_period def set_status(self, last_sle): if last_sle: @@ -87,52 +86,52 @@ class DocType(StockController): if last_sle.actual_qty > 0: if document_type == "Sales Return": - self.doc.status = "Sales Returned" + self.status = "Sales Returned" else: - self.doc.status = "Available" + self.status = "Available" else: if document_type == "Purchase Return": - self.doc.status = "Purchase Returned" + self.status = "Purchase Returned" elif last_sle.voucher_type in ("Delivery Note", "Sales Invoice"): - self.doc.status = "Delivered" + self.status = "Delivered" else: - self.doc.status = "Not Available" + self.status = "Not Available" else: - self.doc.status = "Not Available" + self.status = "Not Available" def set_purchase_details(self, purchase_sle): if purchase_sle: - self.doc.purchase_document_type = purchase_sle.voucher_type - self.doc.purchase_document_no = purchase_sle.voucher_no - self.doc.purchase_date = purchase_sle.posting_date - self.doc.purchase_time = purchase_sle.posting_time - self.doc.purchase_rate = purchase_sle.incoming_rate + self.purchase_document_type = purchase_sle.voucher_type + self.purchase_document_no = purchase_sle.voucher_no + self.purchase_date = purchase_sle.posting_date + self.purchase_time = purchase_sle.posting_time + self.purchase_rate = purchase_sle.incoming_rate if purchase_sle.voucher_type == "Purchase Receipt": - self.doc.supplier, self.doc.supplier_name = \ + self.supplier, self.supplier_name = \ frappe.db.get_value("Purchase Receipt", purchase_sle.voucher_no, ["supplier", "supplier_name"]) else: for fieldname in ("purchase_document_type", "purchase_document_no", "purchase_date", "purchase_time", "purchase_rate", "supplier", "supplier_name"): - self.doc.fields[fieldname] = None + self.set(fieldname, None) def set_sales_details(self, delivery_sle): if delivery_sle: - self.doc.delivery_document_type = delivery_sle.voucher_type - self.doc.delivery_document_no = delivery_sle.voucher_no - self.doc.delivery_date = delivery_sle.posting_date - self.doc.delivery_time = delivery_sle.posting_time - self.doc.customer, self.doc.customer_name = \ + self.delivery_document_type = delivery_sle.voucher_type + self.delivery_document_no = delivery_sle.voucher_no + self.delivery_date = delivery_sle.posting_date + self.delivery_time = delivery_sle.posting_time + self.customer, self.customer_name = \ frappe.db.get_value(delivery_sle.voucher_type, delivery_sle.voucher_no, ["customer", "customer_name"]) - if self.doc.warranty_period: - self.doc.warranty_expiry_date = add_days(cstr(delivery_sle.posting_date), - cint(self.doc.warranty_period)) + if self.warranty_period: + self.warranty_expiry_date = add_days(cstr(delivery_sle.posting_date), + cint(self.warranty_period)) else: for fieldname in ("delivery_document_type", "delivery_document_no", "delivery_date", "delivery_time", "customer", "customer_name", "warranty_expiry_date"): - self.doc.fields[fieldname] = None + self.set(fieldname, None) def get_last_sle(self): entries = {} @@ -154,8 +153,8 @@ class DocType(StockController): for sle in frappe.db.sql("""select * from `tabStock Ledger Entry` where serial_no like %s and item_code=%s and ifnull(is_cancelled, 'No')='No' order by posting_date desc, posting_time desc, name desc""", - ("%%%s%%" % self.doc.name, self.doc.item_code), as_dict=1): - if self.doc.name.upper() in get_serial_nos(sle.serial_no): + ("%%%s%%" % self.name, self.item_code), as_dict=1): + if self.name.upper() in get_serial_nos(sle.serial_no): if sle.actual_qty > 0: sle_dict.setdefault("incoming", []).append(sle) else: @@ -164,11 +163,11 @@ class DocType(StockController): return sle_dict def on_trash(self): - if self.doc.status == 'Delivered': - frappe.throw(_("Delivered Serial No ") + self.doc.name + _(" can not be deleted")) - if self.doc.warehouse: + if self.status == 'Delivered': + frappe.throw(_("Delivered Serial No ") + self.name + _(" can not be deleted")) + if self.warehouse: frappe.throw(_("Cannot delete Serial No in warehouse. \ - First remove from warehouse, then delete.") + ": " + self.doc.name) + First remove from warehouse, then delete.") + ": " + self.name) def before_rename(self, old, new, merge=False): if merge: @@ -188,7 +187,7 @@ class DocType(StockController): ('\n'.join(serial_nos), item[0])) def on_stock_ledger_entry(self): - if self.via_stock_ledger and not self.doc.fields.get("__islocal"): + if self.via_stock_ledger and not self.get("__islocal"): last_sle = self.get_last_sle() self.set_status(last_sle.get("last_sle")) self.set_purchase_details(last_sle.get("purchase_sle")) @@ -224,24 +223,24 @@ def validate_serial_no(sle, item_det): for serial_no in serial_nos: if frappe.db.exists("Serial No", serial_no): - sr = frappe.bean("Serial No", serial_no) + sr = frappe.get_doc("Serial No", serial_no) - if sr.doc.item_code!=sle.item_code: + if sr.item_code!=sle.item_code: frappe.throw(_("Serial No does not belong to Item") + (": %s (%s)" % (sle.item_code, serial_no)), SerialNoItemError) - if sr.doc.warehouse and sle.actual_qty > 0: - frappe.throw(_("Same Serial No") + ": " + sr.doc.name + + if sr.warehouse and sle.actual_qty > 0: + frappe.throw(_("Same Serial No") + ": " + sr.name + _(" can not be received twice"), SerialNoDuplicateError) if sle.actual_qty < 0: - if sr.doc.warehouse!=sle.warehouse: + if sr.warehouse!=sle.warehouse: frappe.throw(_("Serial No") + ": " + serial_no + _(" does not belong to Warehouse") + ": " + sle.warehouse, SerialNoWarehouseError) if sle.voucher_type in ("Delivery Note", "Sales Invoice") \ - and sr.doc.status != "Available": + and sr.status != "Available": frappe.throw(_("Serial No status must be 'Available' to Deliver") + ": " + serial_no, SerialNoStatusError) elif sle.actual_qty < 0: @@ -254,7 +253,7 @@ def validate_serial_no(sle, item_det): def update_serial_nos(sle, item_det): if sle.is_cancelled == "No" and not sle.serial_no and sle.actual_qty > 0 and item_det.serial_no_series: - from frappe.model.doc import make_autoname + from frappe.model.naming import make_autoname serial_nos = [] for i in xrange(cint(sle.actual_qty)): serial_nos.append(make_autoname(item_det.serial_no_series)) @@ -264,9 +263,9 @@ def update_serial_nos(sle, item_det): serial_nos = get_serial_nos(sle.serial_no) for serial_no in serial_nos: if frappe.db.exists("Serial No", serial_no): - sr = frappe.bean("Serial No", serial_no) - sr.make_controller().via_stock_ledger = True - sr.doc.warehouse = sle.warehouse if sle.actual_qty > 0 else None + sr = frappe.get_doc("Serial No", serial_no) + sr.via_stock_ledger = True + sr.warehouse = sle.warehouse if sle.actual_qty > 0 else None sr.save() elif sle.actual_qty > 0: make_serial_no(serial_no, sle) @@ -281,26 +280,27 @@ def get_serial_nos(serial_no): if s.strip()] def make_serial_no(serial_no, sle): - sr = frappe.new_bean("Serial No") - sr.doc.serial_no = serial_no - sr.doc.item_code = sle.item_code - sr.doc.warehouse = None - sr.make_controller().via_stock_ledger = True + sr = frappe.new_doc("Serial No") + sr.serial_no = serial_no + sr.item_code = sle.item_code + sr.warehouse = None + sr.company = sle.company + sr.via_stock_ledger = True sr.insert() - sr.doc.warehouse = sle.warehouse - sr.doc.status = "Available" + sr.warehouse = sle.warehouse + sr.status = "Available" sr.save() - frappe.msgprint(_("Serial No created") + ": " + sr.doc.name) - return sr.doc.name + frappe.msgprint(_("Serial No created") + ": " + sr.name) + return sr.name def update_serial_nos_after_submit(controller, parentfield): stock_ledger_entries = frappe.db.sql("""select voucher_detail_no, serial_no from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""", - (controller.doc.doctype, controller.doc.name), as_dict=True) + (controller.doctype, controller.name), as_dict=True) if not stock_ledger_entries: return - for d in controller.doclist.get({"parentfield": parentfield}): + for d in controller.get(parentfield): serial_no = None for sle in stock_ledger_entries: if sle.voucher_detail_no==d.name: diff --git a/erpnext/stock/doctype/serial_no/serial_no.txt b/erpnext/stock/doctype/serial_no/serial_no.txt deleted file mode 100644 index 3588493a209..00000000000 --- a/erpnext/stock/doctype/serial_no/serial_no.txt +++ /dev/null @@ -1,477 +0,0 @@ -[ - { - "creation": "2013-05-16 10:59:15", - "docstatus": 0, - "modified": "2014-01-20 17:49:26", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:serial_no", - "description": "Distinct unit of an Item", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-barcode", - "in_create": 0, - "module": "Stock", - "name": "__common__", - "search_fields": "item_code,status" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Serial No", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Serial No", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Serial No" - }, - { - "doctype": "DocField", - "fieldname": "details", - "fieldtype": "Section Break", - "label": "Details", - "oldfieldtype": "Section Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "default": "In Store", - "description": "Only Serial Nos with status \"Available\" can be delivered.", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nAvailable\nNot Available\nDelivered\nPurchase Returned\nSales Returned", - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Data", - "in_filter": 0, - "label": "Serial No", - "no_copy": 1, - "oldfieldname": "serial_no", - "oldfieldtype": "Data", - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "read_only": 0, - "reqd": 1, - "search_index": 0 - }, - { - "description": "Warehouse can only be changed via Stock Entry / Delivery Note / Purchase Receipt", - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Warehouse", - "no_copy": 1, - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "read_only": 1, - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Item Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_filter": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "read_only": 1, - "search_index": 0, - "width": "300px" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "in_filter": 0, - "label": "Item Group", - "oldfieldname": "item_group", - "oldfieldtype": "Link", - "options": "Item Group", - "read_only": 1, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "brand", - "fieldtype": "Link", - "in_filter": 0, - "label": "Brand", - "oldfieldname": "brand", - "oldfieldtype": "Link", - "options": "Brand", - "read_only": 1, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "purchase_details", - "fieldtype": "Section Break", - "label": "Purchase / Manufacture Details", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "purchase_document_type", - "fieldtype": "Select", - "label": "Creation Document Type", - "no_copy": 1, - "options": "\nPurchase Receipt\nStock Entry", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "purchase_document_no", - "fieldtype": "Data", - "hidden": 0, - "label": "Creation Document No", - "no_copy": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "purchase_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Creation Date", - "no_copy": 1, - "oldfieldname": "purchase_date", - "oldfieldtype": "Date", - "read_only": 1, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "purchase_time", - "fieldtype": "Time", - "label": "Creation Time", - "no_copy": 1, - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "purchase_rate", - "fieldtype": "Currency", - "in_filter": 0, - "label": "Incoming Rate", - "no_copy": 1, - "oldfieldname": "purchase_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "supplier", - "fieldtype": "Link", - "in_filter": 1, - "label": "Supplier", - "no_copy": 1, - "options": "Supplier", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "supplier_name", - "fieldtype": "Data", - "in_filter": 1, - "label": "Supplier Name", - "no_copy": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "delivery_details", - "fieldtype": "Section Break", - "label": "Delivery Details", - "oldfieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "delivery_document_type", - "fieldtype": "Select", - "in_filter": 1, - "label": "Delivery Document Type", - "no_copy": 1, - "options": "\nDelivery Note\nSales Invoice\nStock Entry", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "delivery_document_no", - "fieldtype": "Data", - "in_filter": 1, - "label": "Delivery Document No", - "no_copy": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "delivery_date", - "fieldtype": "Date", - "label": "Delivery Date", - "no_copy": 1, - "oldfieldname": "delivery_date", - "oldfieldtype": "Date", - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "delivery_time", - "fieldtype": "Time", - "label": "Delivery Time", - "no_copy": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "is_cancelled", - "fieldtype": "Select", - "hidden": 1, - "label": "Is Cancelled", - "oldfieldname": "is_cancelled", - "oldfieldtype": "Select", - "options": "\nYes\nNo", - "read_only": 0, - "report_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break5", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "in_filter": 1, - "label": "Customer", - "no_copy": 1, - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "read_only": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "in_filter": 1, - "label": "Customer Name", - "no_copy": 1, - "oldfieldname": "customer_name", - "oldfieldtype": "Data", - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "warranty_amc_details", - "fieldtype": "Section Break", - "label": "Warranty / AMC Details", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break6", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "maintenance_status", - "fieldtype": "Select", - "in_filter": 1, - "label": "Maintenance Status", - "no_copy": 0, - "oldfieldname": "maintenance_status", - "oldfieldtype": "Select", - "options": "\nUnder Warranty\nOut of Warranty\nUnder AMC\nOut of AMC", - "read_only": 0, - "search_index": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "warranty_period", - "fieldtype": "Int", - "label": "Warranty Period (Days)", - "oldfieldname": "warranty_period", - "oldfieldtype": "Int", - "read_only": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "column_break7", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "warranty_expiry_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Warranty Expiry Date", - "oldfieldname": "warranty_expiry_date", - "oldfieldtype": "Date", - "read_only": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "amc_expiry_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "AMC Expiry Date", - "oldfieldname": "amc_expiry_date", - "oldfieldtype": "Date", - "read_only": 0, - "search_index": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "serial_no_details", - "fieldtype": "Text Editor", - "label": "Serial No Details", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "in_filter": 1, - "label": "Company", - "options": "link:Company", - "read_only": 1, - "reqd": 1, - "search_index": 1 - }, - { - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Material Master Manager", - "write": 1 - }, - { - "amend": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Material Manager", - "write": 0 - }, - { - "amend": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Material User", - "write": 0 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/serial_no/test_records.json b/erpnext/stock/doctype/serial_no/test_records.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/erpnext/stock/doctype/serial_no/test_records.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/erpnext/stock/doctype/serial_no/test_serial_no.py b/erpnext/stock/doctype/serial_no/test_serial_no.py index 8b295b4ef65..9518e78c866 100644 --- a/erpnext/stock/doctype/serial_no/test_serial_no.py +++ b/erpnext/stock/doctype/serial_no/test_serial_no.py @@ -8,22 +8,22 @@ from __future__ import unicode_literals import frappe, unittest test_dependencies = ["Item"] -test_records = [] +test_records = frappe.get_test_records('Serial No') from erpnext.stock.doctype.serial_no.serial_no import * class TestSerialNo(unittest.TestCase): def test_cannot_create_direct(self): - sr = frappe.new_bean("Serial No") - sr.doc.item_code = "_Test Serialized Item" - sr.doc.warehouse = "_Test Warehouse - _TC" - sr.doc.serial_no = "_TCSER0001" - sr.doc.purchase_rate = 10 + sr = frappe.new_doc("Serial No") + sr.item_code = "_Test Serialized Item" + sr.warehouse = "_Test Warehouse - _TC" + sr.serial_no = "_TCSER0001" + sr.purchase_rate = 10 self.assertRaises(SerialNoCannotCreateDirectError, sr.insert) - sr.doc.warehouse = None + sr.warehouse = None sr.insert() - self.assertTrue(sr.doc.name) + self.assertTrue(sr.name) - sr.doc.warehouse = "_Test Warehouse - _TC" - self.assertTrue(SerialNoCannotCannotChangeError, sr.doc.save) \ No newline at end of file + sr.warehouse = "_Test Warehouse - _TC" + self.assertTrue(SerialNoCannotCannotChangeError, sr.save) \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 535fcb735b8..07456debf77 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -105,9 +105,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }, callback: function(r) { if (!r.exc) { - for(d in getchildren('Stock Entry Detail', me.frm.doc.name, 'mtn_details')) { + $.each(doc.mtn_details || [], function(i, d) { if(!d.expense_account) d.expense_account = r.message; - } + }); } } }); @@ -192,7 +192,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }, add_excise_button: function() { - if(frappe.boot.control_panel.country === "India") + if(frappe.boot.sysdefaults.country === "India") this.frm.add_custom_button(frappe._("Make Excise Invoice"), function() { var excise = frappe.model.make_new_doc_and_get_name('Journal Voucher'); excise = locals['Journal Voucher'][excise]; @@ -225,7 +225,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }, mtn_details_add: function(doc, cdt, cdn) { - var row = frappe.model.get_doc(cdt, cdn); + var row = frappe.get_doc(cdt, cdn); this.frm.script_manager.copy_from_first_row("mtn_details", row, ["expense_account", "cost_center"]); @@ -350,7 +350,7 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) { 'cost_center' : d.cost_center, 'company' : cur_frm.doc.company }; - return get_server_fields('get_item_details', JSON.stringify(args), + return get_server_fields('get_item_details', {arg: JSON.stringify(args)}, 'mtn_details', doc, cdt, cdn, 1); } @@ -388,7 +388,7 @@ cur_frm.cscript.validate = function(doc, cdt, cdn) { } cur_frm.cscript.validate_items = function(doc) { - cl = getchildren('Stock Entry Detail', doc.name, 'mtn_details'); + cl = doc.mtn_details || []; if (!cl.length) { msgprint(frappe._("Item table can not be blank")); validated = false; diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.json b/erpnext/stock/doctype/stock_entry/stock_entry.json new file mode 100644 index 00000000000..f4a52de5499 --- /dev/null +++ b/erpnext/stock/doctype/stock_entry/stock_entry.json @@ -0,0 +1,649 @@ +{ + "allow_attach": 0, + "allow_copy": 0, + "allow_import": 1, + "allow_rename": 0, + "autoname": "naming_series:", + "creation": "2013-04-09 11:43:55.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "col1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, + { + "allow_on_submit": 0, + "fieldname": "naming_series", + "fieldtype": "Select", + "hidden": 0, + "in_filter": 0, + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "\nSTE", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0 + }, + { + "allow_on_submit": 0, + "default": "Material Issue", + "fieldname": "purpose", + "fieldtype": "Select", + "hidden": 0, + "in_filter": 1, + "in_list_view": 1, + "label": "Purpose", + "no_copy": 0, + "oldfieldname": "purpose", + "oldfieldtype": "Select", + "options": "Material Issue\nMaterial Receipt\nMaterial Transfer\nManufacture/Repack\nSubcontract\nSales Return\nPurchase Return", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:doc.purpose==\"Sales Return\"", + "fieldname": "delivery_note_no", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 0, + "label": "Delivery Note No", + "no_copy": 1, + "oldfieldname": "delivery_note_no", + "oldfieldtype": "Link", + "options": "Delivery Note", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 1 + }, + { + "depends_on": "eval:doc.purpose==\"Sales Return\"", + "fieldname": "sales_invoice_no", + "fieldtype": "Link", + "hidden": 0, + "label": "Sales Invoice No", + "no_copy": 1, + "options": "Sales Invoice", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:doc.purpose==\"Purchase Return\"", + "fieldname": "purchase_receipt_no", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 0, + "label": "Purchase Receipt No", + "no_copy": 1, + "oldfieldname": "purchase_receipt_no", + "oldfieldtype": "Link", + "options": "Purchase Receipt", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "col2", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, + { + "allow_on_submit": 0, + "default": "Today", + "fieldname": "posting_date", + "fieldtype": "Date", + "hidden": 0, + "in_filter": 1, + "in_list_view": 0, + "label": "Posting Date", + "no_copy": 1, + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 1 + }, + { + "allow_on_submit": 0, + "fieldname": "posting_time", + "fieldtype": "Time", + "hidden": 0, + "in_filter": 0, + "label": "Posting Time", + "no_copy": 1, + "oldfieldname": "posting_time", + "oldfieldtype": "Time", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "items_section", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 0, + "fieldname": "from_warehouse", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 0, + "in_list_view": 1, + "label": "Default Source Warehouse", + "no_copy": 1, + "oldfieldname": "from_warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "cb0", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 0, + "fieldname": "to_warehouse", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 0, + "in_list_view": 1, + "label": "Default Target Warehouse", + "no_copy": 1, + "oldfieldname": "to_warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "sb0", + "fieldtype": "Section Break", + "options": "Simple", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 0, + "fieldname": "mtn_details", + "fieldtype": "Table", + "hidden": 0, + "in_filter": 0, + "label": "MTN Details", + "no_copy": 0, + "oldfieldname": "mtn_details", + "oldfieldtype": "Table", + "options": "Stock Entry Detail", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "description": "Get valuation rate and available stock at source/target warehouse on mentioned posting date-time. If serialized item, please press this button after entering serial nos.", + "fieldname": "get_stock_and_rate", + "fieldtype": "Button", + "label": "Get Stock and Rate", + "oldfieldtype": "Button", + "options": "get_stock_and_rate", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "depends_on": "eval:(doc.purpose!==\"Sales Return\" && doc.purpose!==\"Purchase Return\")", + "fieldname": "sb1", + "fieldtype": "Section Break", + "label": "From Bill of Materials", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:inList([\"Material Transfer\", \"Manufacture/Repack\"], doc.purpose)", + "fieldname": "production_order", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Production Order", + "no_copy": 0, + "oldfieldname": "production_order", + "oldfieldtype": "Link", + "options": "Production Order", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 1 + }, + { + "depends_on": "eval:!inList([\"Sales Return\", \"Purchase Return\"], doc.purpose)", + "fieldname": "bom_no", + "fieldtype": "Link", + "label": "BOM No", + "options": "BOM", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:!inList([\"Sales Return\", \"Purchase Return\"], doc.purpose)", + "description": "As per Stock UOM", + "fieldname": "fg_completed_qty", + "fieldtype": "Float", + "hidden": 0, + "in_filter": 0, + "label": "Manufacturing Quantity", + "no_copy": 0, + "oldfieldname": "fg_completed_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "cb1", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "default": "1", + "depends_on": "eval:!inList([\"Sales Return\", \"Purchase Return\"], doc.purpose)", + "description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.", + "fieldname": "use_multi_level_bom", + "fieldtype": "Check", + "label": "Use Multi-Level BOM", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:!inList([\"Sales Return\", \"Purchase Return\"], doc.purpose)", + "fieldname": "get_items", + "fieldtype": "Button", + "hidden": 0, + "in_filter": 0, + "label": "Get Items", + "no_copy": 0, + "oldfieldtype": "Button", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "depends_on": "eval:(doc.purpose==\"Sales Return\" || doc.purpose==\"Purchase Return\")", + "fieldname": "contact_section", + "fieldtype": "Section Break", + "label": "Contact Info", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:doc.purpose==\"Purchase Return\"", + "fieldname": "supplier", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 0, + "label": "Supplier", + "no_copy": 1, + "oldfieldname": "supplier", + "oldfieldtype": "Link", + "options": "Supplier", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:doc.purpose==\"Purchase Return\"", + "fieldname": "supplier_name", + "fieldtype": "Data", + "hidden": 0, + "in_filter": 0, + "label": "Supplier Name", + "no_copy": 1, + "oldfieldname": "supplier_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:doc.purpose==\"Purchase Return\"", + "fieldname": "supplier_address", + "fieldtype": "Small Text", + "hidden": 0, + "in_filter": 0, + "label": "Supplier Address", + "no_copy": 1, + "oldfieldname": "supplier_address", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:doc.purpose==\"Sales Return\"", + "fieldname": "customer", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 0, + "label": "Customer", + "no_copy": 1, + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:doc.purpose==\"Sales Return\"", + "fieldname": "customer_name", + "fieldtype": "Data", + "hidden": 0, + "in_filter": 0, + "label": "Customer Name", + "no_copy": 1, + "oldfieldname": "customer_name", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 1, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:doc.purpose==\"Sales Return\"", + "fieldname": "customer_address", + "fieldtype": "Small Text", + "hidden": 0, + "in_filter": 0, + "label": "Customer Address", + "no_copy": 1, + "oldfieldname": "customer_address", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "col4", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, + { + "fieldname": "total_amount", + "fieldtype": "Currency", + "label": "Total Amount", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "project_name", + "fieldtype": "Link", + "in_filter": 1, + "label": "Project Name", + "oldfieldname": "project_name", + "oldfieldtype": "Link", + "options": "Project", + "permlevel": 0, + "read_only": 0 + }, + { + "allow_on_submit": 0, + "fieldname": "select_print_heading", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 0, + "label": "Print Heading", + "no_copy": 0, + "oldfieldname": "select_print_heading", + "oldfieldtype": "Link", + "options": "Print Heading", + "permlevel": 0, + "print_hide": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 0, + "label": "Fiscal Year", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "col5", + "fieldtype": "Column Break", + "permlevel": 0, + "print_width": "50%", + "read_only": 0, + "width": "50%" + }, + { + "allow_on_submit": 0, + "fieldname": "company", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Company", + "no_copy": 0, + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0 + }, + { + "allow_on_submit": 0, + "fieldname": "amended_from", + "fieldtype": "Link", + "hidden": 0, + "ignore_restrictions": 1, + "in_filter": 0, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Link", + "options": "Stock Entry", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + }, + { + "allow_on_submit": 0, + "fieldname": "remarks", + "fieldtype": "Text", + "hidden": 0, + "in_filter": 0, + "label": "Remarks", + "no_copy": 1, + "oldfieldname": "remarks", + "oldfieldtype": "Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0 + } + ], + "hide_heading": 0, + "hide_toolbar": 0, + "icon": "icon-file-text", + "idx": 1, + "in_create": 0, + "in_dialog": 0, + "is_submittable": 1, + "issingle": 0, + "max_attachments": 0, + "modified": "2014-02-26 10:59:19.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Stock Entry", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Manufacturing User", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Manufacturing Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Manager", + "submit": 1, + "write": 1 + } + ], + "read_only": 0, + "read_only_onload": 0, + "search_fields": "transfer_date, from_warehouse, to_warehouse, purpose, remarks" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 3aeb507873d..b6ffb832274 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -6,9 +6,7 @@ import frappe import frappe.defaults from frappe.utils import cstr, cint, flt, comma_or, nowdate -from frappe.model.doc import addchild -from frappe.model.bean import getlist -from frappe.model.code import get_obj + from frappe import msgprint, _ from erpnext.stock.utils import get_incoming_rate from erpnext.stock.stock_ledger import get_previous_sle @@ -21,20 +19,17 @@ class StockOverReturnError(frappe.ValidationError): pass class IncorrectValuationRateError(frappe.ValidationError): pass class DuplicateEntryForProductionOrderError(frappe.ValidationError): pass class StockOverProductionError(frappe.ValidationError): pass - + from erpnext.controllers.stock_controller import StockController -class DocType(StockController): - def __init__(self, doc, doclist=None): - self.doc = doc - self.doclist = doclist - self.fname = 'mtn_details' - +class StockEntry(StockController): + fname = 'mtn_details' + def validate(self): self.validate_posting_time() self.validate_purpose() - pro_obj = self.doc.production_order and \ - get_obj('Production Order', self.doc.production_order) or None + pro_obj = self.production_order and \ + frappe.get_doc('Production Order', self.production_order) or None self.validate_item() self.validate_uom_is_integer("uom", "qty") @@ -49,7 +44,7 @@ class DocType(StockController): self.validate_with_material_request() self.validate_fiscal_year() self.set_total_amount() - + def on_submit(self): self.update_stock_ledger() @@ -62,153 +57,152 @@ class DocType(StockController): self.update_stock_ledger() self.update_production_order() self.make_cancel_gl_entries() - + def validate_fiscal_year(self): from erpnext.accounts.utils import validate_fiscal_year - validate_fiscal_year(self.doc.posting_date, self.doc.fiscal_year, + validate_fiscal_year(self.posting_date, self.fiscal_year, self.meta.get_label("posting_date")) - + def validate_purpose(self): - valid_purposes = ["Material Issue", "Material Receipt", "Material Transfer", + valid_purposes = ["Material Issue", "Material Receipt", "Material Transfer", "Manufacture/Repack", "Subcontract", "Sales Return", "Purchase Return"] - if self.doc.purpose not in valid_purposes: + if self.purpose not in valid_purposes: msgprint(_("Purpose must be one of ") + comma_or(valid_purposes), raise_exception=True) - + def validate_item(self): stock_items = self.get_stock_items() - for item in self.doclist.get({"parentfield": "mtn_details"}): + for item in self.get("mtn_details"): if item.item_code not in stock_items: msgprint(_("""Only Stock Items are allowed for Stock Entry"""), raise_exception=True) - + def validate_warehouse(self, pro_obj): """perform various (sometimes conditional) validations on warehouse""" - + source_mandatory = ["Material Issue", "Material Transfer", "Purchase Return"] target_mandatory = ["Material Receipt", "Material Transfer", "Sales Return"] - - validate_for_manufacture_repack = any([d.bom_no for d in self.doclist.get( - {"parentfield": "mtn_details"})]) - if self.doc.purpose in source_mandatory and self.doc.purpose not in target_mandatory: - self.doc.to_warehouse = None - for d in getlist(self.doclist, 'mtn_details'): + validate_for_manufacture_repack = any([d.bom_no for d in self.get("mtn_details")]) + + if self.purpose in source_mandatory and self.purpose not in target_mandatory: + self.to_warehouse = None + for d in self.get('mtn_details'): d.t_warehouse = None - elif self.doc.purpose in target_mandatory and self.doc.purpose not in source_mandatory: - self.doc.from_warehouse = None - for d in getlist(self.doclist, 'mtn_details'): + elif self.purpose in target_mandatory and self.purpose not in source_mandatory: + self.from_warehouse = None + for d in self.get('mtn_details'): d.s_warehouse = None - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): if not d.s_warehouse and not d.t_warehouse: - d.s_warehouse = self.doc.from_warehouse - d.t_warehouse = self.doc.to_warehouse + d.s_warehouse = self.from_warehouse + d.t_warehouse = self.to_warehouse if not (d.s_warehouse or d.t_warehouse): msgprint(_("Atleast one warehouse is mandatory"), raise_exception=1) - - if self.doc.purpose in source_mandatory and not d.s_warehouse: + + if self.purpose in source_mandatory and not d.s_warehouse: msgprint(_("Row # ") + "%s: " % cint(d.idx) + _("Source Warehouse") + _(" is mandatory"), raise_exception=1) - - if self.doc.purpose in target_mandatory and not d.t_warehouse: + + if self.purpose in target_mandatory and not d.t_warehouse: msgprint(_("Row # ") + "%s: " % cint(d.idx) + _("Target Warehouse") + _(" is mandatory"), raise_exception=1) - if self.doc.purpose == "Manufacture/Repack": + if self.purpose == "Manufacture/Repack": if validate_for_manufacture_repack: if d.bom_no: d.s_warehouse = None - + if not d.t_warehouse: msgprint(_("Row # ") + "%s: " % cint(d.idx) + _("Target Warehouse") + _(" is mandatory"), raise_exception=1) - - elif pro_obj and cstr(d.t_warehouse) != pro_obj.doc.fg_warehouse: + + elif pro_obj and cstr(d.t_warehouse) != pro_obj.fg_warehouse: msgprint(_("Row # ") + "%s: " % cint(d.idx) + _("Target Warehouse") + _(" should be same as that in ") + _("Production Order"), raise_exception=1) - + else: d.t_warehouse = None if not d.s_warehouse: msgprint(_("Row # ") + "%s: " % cint(d.idx) + _("Source Warehouse") + _(" is mandatory"), raise_exception=1) - + if cstr(d.s_warehouse) == cstr(d.t_warehouse): - msgprint(_("Source and Target Warehouse cannot be same"), + msgprint(_("Source and Target Warehouse cannot be same"), raise_exception=1) - + def validate_production_order(self, pro_obj=None): if not pro_obj: - if self.doc.production_order: - pro_obj = get_obj('Production Order', self.doc.production_order) + if self.production_order: + pro_obj = frappe.get_doc('Production Order', self.production_order) else: return - - if self.doc.purpose == "Manufacture/Repack": + + if self.purpose == "Manufacture/Repack": # check for double entry self.check_duplicate_entry_for_production_order() - elif self.doc.purpose != "Material Transfer": - self.doc.production_order = None - + elif self.purpose != "Material Transfer": + self.production_order = None + def check_duplicate_entry_for_production_order(self): other_ste = [t[0] for t in frappe.db.get_values("Stock Entry", { - "production_order": self.doc.production_order, - "purpose": self.doc.purpose, + "production_order": self.production_order, + "purpose": self.purpose, "docstatus": ["!=", 2], - "name": ["!=", self.doc.name] + "name": ["!=", self.name] }, "name")] - + if other_ste: - production_item, qty = frappe.db.get_value("Production Order", - self.doc.production_order, ["production_item", "qty"]) + production_item, qty = frappe.db.get_value("Production Order", + self.production_order, ["production_item", "qty"]) args = other_ste + [production_item] fg_qty_already_entered = frappe.db.sql("""select sum(actual_qty) - from `tabStock Entry Detail` - where parent in (%s) - and item_code = %s + from `tabStock Entry Detail` + where parent in (%s) + and item_code = %s and ifnull(s_warehouse,'')='' """ % (", ".join(["%s" * len(other_ste)]), "%s"), args)[0][0] - + if fg_qty_already_entered >= qty: - frappe.throw(_("Stock Entries already created for Production Order ") - + self.doc.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError) + frappe.throw(_("Stock Entries already created for Production Order ") + + self.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError) def set_total_amount(self): - self.doc.total_amount = sum([flt(item.amount) for item in self.doclist.get({"parentfield": "mtn_details"})]) - + self.total_amount = sum([flt(item.amount) for item in self.get("mtn_details")]) + def get_stock_and_rate(self): """get stock and incoming rate on posting date""" - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): args = frappe._dict({ "item_code": d.item_code, "warehouse": d.s_warehouse or d.t_warehouse, - "posting_date": self.doc.posting_date, - "posting_time": self.doc.posting_time, + "posting_date": self.posting_date, + "posting_time": self.posting_time, "qty": d.s_warehouse and -1*d.transfer_qty or d.transfer_qty, "serial_no": d.serial_no, "bom_no": d.bom_no, }) # get actual stock at source warehouse d.actual_qty = get_previous_sle(args).get("qty_after_transaction") or 0 - + # get incoming rate if not flt(d.incoming_rate): d.incoming_rate = self.get_incoming_rate(args) - + d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) - + def get_incoming_rate(self, args): incoming_rate = 0 - if self.doc.purpose == "Sales Return" and \ - (self.doc.delivery_note_no or self.doc.sales_invoice_no): - sle = frappe.db.sql("""select name, posting_date, posting_time, - actual_qty, stock_value, warehouse from `tabStock Ledger Entry` - where voucher_type = %s and voucher_no = %s and - item_code = %s limit 1""", - ((self.doc.delivery_note_no and "Delivery Note" or "Sales Invoice"), - self.doc.delivery_note_no or self.doc.sales_invoice_no, args.item_code), as_dict=1) + if self.purpose == "Sales Return" and \ + (self.delivery_note_no or self.sales_invoice_no): + sle = frappe.db.sql("""select name, posting_date, posting_time, + actual_qty, stock_value, warehouse from `tabStock Ledger Entry` + where voucher_type = %s and voucher_no = %s and + item_code = %s limit 1""", + ((self.delivery_note_no and "Delivery Note" or "Sales Invoice"), + self.delivery_note_no or self.sales_invoice_no, args.item_code), as_dict=1) if sle: args.update({ "posting_date": sle[0].posting_date, @@ -221,164 +215,165 @@ class DocType(StockController): flt(sle[0].actual_qty) else: incoming_rate = get_incoming_rate(args) - + return incoming_rate - + def validate_incoming_rate(self): - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): if d.t_warehouse: self.validate_value("incoming_rate", ">", 0, d, raise_exception=IncorrectValuationRateError) - + def validate_bom(self): - for d in getlist(self.doclist, 'mtn_details'): + for d in self.get('mtn_details'): if d.bom_no and not frappe.db.sql("""select name from `tabBOM` where item = %s and name = %s and docstatus = 1 and is_active = 1""", (d.item_code, d.bom_no)): msgprint(_("Item") + " %s: " % cstr(d.item_code) + _("does not belong to BOM: ") + cstr(d.bom_no) + _(" or the BOM is cancelled or inactive"), raise_exception=1) - + def validate_finished_goods(self): """validation: finished good quantity should be same as manufacturing quantity""" - for d in getlist(self.doclist, 'mtn_details'): - if d.bom_no and flt(d.transfer_qty) != flt(self.doc.fg_completed_qty): - msgprint(_("Row #") + " %s: " % d.idx + import json + for d in self.get('mtn_details'): + if d.bom_no and flt(d.transfer_qty) != flt(self.fg_completed_qty): + msgprint(_("Row #") + " %s: " % d.idx + _("Quantity should be equal to Manufacturing Quantity. To fetch items again, click on 'Get Items' button or update the Quantity manually."), raise_exception=1) - + def validate_return_reference_doc(self): """validate item with reference doc""" - ref = get_return_doclist_and_details(self.doc.fields) - - if ref.doclist: + ref = get_return_doc_and_details(self) + + if ref.doc: # validate docstatus - if ref.doclist[0].docstatus != 1: - frappe.msgprint(_(ref.doclist[0].doctype) + ' "' + ref.doclist[0].name + '": ' + if ref.doc.docstatus != 1: + frappe.msgprint(_(ref.doc.doctype) + ' "' + ref.doc.name + '": ' + _("Status should be Submitted"), raise_exception=frappe.InvalidStatusError) - + # update stock check - if ref.doclist[0].doctype == "Sales Invoice" and cint(ref.doclist[0].update_stock) != 1: - frappe.msgprint(_(ref.doclist[0].doctype) + ' "' + ref.doclist[0].name + '": ' - + _("Update Stock should be checked."), + if ref.doc.doctype == "Sales Invoice" and cint(ref.doc.update_stock) != 1: + frappe.msgprint(_(ref.doc.doctype) + ' "' + ref.doc.name + '": ' + + _("Update Stock should be checked."), raise_exception=NotUpdateStockError) - + # posting date check - ref_posting_datetime = "%s %s" % (cstr(ref.doclist[0].posting_date), - cstr(ref.doclist[0].posting_time) or "00:00:00") - this_posting_datetime = "%s %s" % (cstr(self.doc.posting_date), - cstr(self.doc.posting_time)) + ref_posting_datetime = "%s %s" % (cstr(ref.doc.posting_date), + cstr(ref.doc.posting_time) or "00:00:00") + this_posting_datetime = "%s %s" % (cstr(self.posting_date), + cstr(self.posting_time)) if this_posting_datetime < ref_posting_datetime: from frappe.utils.dateutils import datetime_in_user_format frappe.msgprint(_("Posting Date Time cannot be before") + ": " + datetime_in_user_format(ref_posting_datetime), raise_exception=True) - - stock_items = get_stock_items_for_return(ref.doclist, ref.parentfields) + + stock_items = get_stock_items_for_return(ref.doc, ref.parentfields) already_returned_item_qty = self.get_already_returned_item_qty(ref.fieldname) - - for item in self.doclist.get({"parentfield": "mtn_details"}): - # validate if item exists in the ref doclist and that it is a stock item + + for item in self.get("mtn_details"): + # validate if item exists in the ref doc and that it is a stock item if item.item_code not in stock_items: msgprint(_("Item") + ': "' + item.item_code + _("\" does not exist in ") + - ref.doclist[0].doctype + ": " + ref.doclist[0].name, + ref.doc.doctype + ": " + ref.doc.name, raise_exception=frappe.DoesNotExistError) - + # validate quantity <= ref item's qty - qty already returned - ref_item = ref.doclist.getone({"item_code": item.item_code}) + ref_item = ref.doc.getone({"item_code": item.item_code}) returnable_qty = ref_item.qty - flt(already_returned_item_qty.get(item.item_code)) if not returnable_qty: frappe.throw("{item}: {item_code} {returned}".format( - item=_("Item"), item_code=item.item_code, - returned=_("already returned though some other documents")), + item=_("Item"), item_code=item.item_code, + returned=_("already returned though some other documents")), StockOverReturnError) elif item.transfer_qty > returnable_qty: frappe.throw("{item}: {item_code}, {returned}: {qty}".format( item=_("Item"), item_code=item.item_code, returned=_("Max Returnable Qty"), qty=returnable_qty), StockOverReturnError) - + def get_already_returned_item_qty(self, ref_fieldname): return dict(frappe.db.sql("""select item_code, sum(transfer_qty) as qty from `tabStock Entry Detail` where parent in ( select name from `tabStock Entry` where `%s`=%s and docstatus=1) - group by item_code""" % (ref_fieldname, "%s"), (self.doc.fields.get(ref_fieldname),))) - + group by item_code""" % (ref_fieldname, "%s"), (self.get(ref_fieldname),))) + def update_stock_ledger(self): - sl_entries = [] - for d in getlist(self.doclist, 'mtn_details'): - if cstr(d.s_warehouse) and self.doc.docstatus == 1: + sl_entries = [] + for d in self.get('mtn_details'): + if cstr(d.s_warehouse) and self.docstatus == 1: sl_entries.append(self.get_sl_entries(d, { "warehouse": cstr(d.s_warehouse), "actual_qty": -flt(d.transfer_qty), "incoming_rate": 0 })) - + if cstr(d.t_warehouse): sl_entries.append(self.get_sl_entries(d, { "warehouse": cstr(d.t_warehouse), "actual_qty": flt(d.transfer_qty), "incoming_rate": flt(d.incoming_rate) })) - - # On cancellation, make stock ledger entry for + + # On cancellation, make stock ledger entry for # target warehouse first, to update serial no values properly - - if cstr(d.s_warehouse) and self.doc.docstatus == 2: + + if cstr(d.s_warehouse) and self.docstatus == 2: sl_entries.append(self.get_sl_entries(d, { "warehouse": cstr(d.s_warehouse), "actual_qty": -flt(d.transfer_qty), "incoming_rate": 0 })) - - self.make_sl_entries(sl_entries, self.doc.amended_from and 'Yes' or 'No') + + self.make_sl_entries(sl_entries, self.amended_from and 'Yes' or 'No') def update_production_order(self): - def _validate_production_order(pro_bean): - if flt(pro_bean.doc.docstatus) != 1: - frappe.throw(_("Production Order must be submitted") + ": " + - self.doc.production_order) - - if pro_bean.doc.status == 'Stopped': - msgprint(_("Transaction not allowed against stopped Production Order") + ": " + - self.doc.production_order) - - if self.doc.production_order: - pro_bean = frappe.bean("Production Order", self.doc.production_order) - _validate_production_order(pro_bean) - self.update_produced_qty(pro_bean) - if self.doc.purpose == "Manufacture/Repack": - self.update_planned_qty(pro_bean) - - def update_produced_qty(self, pro_bean): - if self.doc.purpose == "Manufacture/Repack": - produced_qty = flt(pro_bean.doc.produced_qty) + \ - (self.doc.docstatus==1 and 1 or -1 ) * flt(self.doc.fg_completed_qty) - - if produced_qty > flt(pro_bean.doc.qty): - frappe.throw(_("Production Order") + ": " + self.doc.production_order + "\n" + - _("Total Manufactured Qty can not be greater than Planned qty to manufacture") - + "(%s/%s)" % (produced_qty, flt(pro_bean.doc.qty)), StockOverProductionError) - - status = 'Completed' if flt(produced_qty) >= flt(pro_bean.doc.qty) else 'In Process' - frappe.db.sql("""update `tabProduction Order` set status=%s, produced_qty=%s - where name=%s""", (status, produced_qty, self.doc.production_order)) - - def update_planned_qty(self, pro_bean): + def _validate_production_order(pro_doc): + if flt(pro_doc.docstatus) != 1: + frappe.throw(_("Production Order must be submitted") + ": " + + self.production_order) + + if pro_doc.status == 'Stopped': + msgprint(_("Transaction not allowed against stopped Production Order") + ": " + + self.production_order) + + if self.production_order: + pro_doc = frappe.get_doc("Production Order", self.production_order) + _validate_production_order(pro_doc) + self.update_produced_qty(pro_doc) + if self.purpose == "Manufacture/Repack": + self.update_planned_qty(pro_doc) + + def update_produced_qty(self, pro_doc): + if self.purpose == "Manufacture/Repack": + produced_qty = flt(pro_doc.produced_qty) + \ + (self.docstatus==1 and 1 or -1 ) * flt(self.fg_completed_qty) + + if produced_qty > flt(pro_doc.qty): + frappe.throw(_("Production Order") + ": " + self.production_order + "\n" + + _("Total Manufactured Qty can not be greater than Planned qty to manufacture") + + "(%s/%s)" % (produced_qty, flt(pro_doc.qty)), StockOverProductionError) + + status = 'Completed' if flt(produced_qty) >= flt(pro_doc.qty) else 'In Process' + frappe.db.sql("""update `tabProduction Order` set status=%s, produced_qty=%s + where name=%s""", (status, produced_qty, self.production_order)) + + def update_planned_qty(self, pro_doc): from erpnext.stock.utils import update_bin update_bin({ - "item_code": pro_bean.doc.production_item, - "warehouse": pro_bean.doc.fg_warehouse, - "posting_date": self.doc.posting_date, - "planned_qty": (self.doc.docstatus==1 and -1 or 1 ) * flt(self.doc.fg_completed_qty) + "item_code": pro_doc.production_item, + "warehouse": pro_doc.fg_warehouse, + "posting_date": self.posting_date, + "planned_qty": (self.docstatus==1 and -1 or 1 ) * flt(self.fg_completed_qty) }) - + def get_item_details(self, arg): arg = json.loads(arg) - item = frappe.db.sql("""select stock_uom, description, item_name, - expense_account, buying_cost_center from `tabItem` - where name = %s and (ifnull(end_of_life,'')='' or end_of_life ='0000-00-00' + item = frappe.db.sql("""select stock_uom, description, item_name, + expense_account, buying_cost_center from `tabItem` + where name = %s and (ifnull(end_of_life,'')='' or end_of_life ='0000-00-00' or end_of_life > now())""", (arg.get('item_code')), as_dict = 1) - if not item: + if not item: msgprint("Item is not active", raise_exception=1) - + ret = { 'uom' : item and item[0]['stock_uom'] or '', 'stock_uom' : item and item[0]['stock_uom'] or '', @@ -400,7 +395,7 @@ class DocType(StockController): def get_uom_details(self, arg = ''): arg, ret = eval(arg), {} - uom = frappe.db.sql("""select conversion_factor from `tabUOM Conversion Detail` + uom = frappe.db.sql("""select conversion_factor from `tabUOM Conversion Detail` where parent = %s and uom = %s""", (arg['item_code'], arg['uom']), as_dict = 1) if not uom or not flt(uom[0].conversion_factor): msgprint("There is no Conversion Factor for UOM '%s' in Item '%s'" % (arg['uom'], @@ -412,83 +407,80 @@ class DocType(StockController): 'transfer_qty' : flt(arg['qty']) * flt(uom[0]['conversion_factor']), } return ret - + def get_warehouse_details(self, args): args = json.loads(args) ret = {} if args.get('warehouse') and args.get('item_code'): args.update({ - "posting_date": self.doc.posting_date, - "posting_time": self.doc.posting_time, + "posting_date": self.posting_date, + "posting_time": self.posting_time, }) args = frappe._dict(args) - + ret = { "actual_qty" : get_previous_sle(args).get("qty_after_transaction") or 0, "incoming_rate" : self.get_incoming_rate(args) } return ret - + def get_items(self): - self.doclist = filter(lambda d: d.parentfield!="mtn_details", self.doclist) - # self.doclist = self.doc.clear_table(self.doclist, 'mtn_details') - pro_obj = None - if self.doc.production_order: + if self.production_order: # common validations - pro_obj = get_obj('Production Order', self.doc.production_order) + pro_obj = frappe.get_doc('Production Order', self.production_order) if pro_obj: self.validate_production_order(pro_obj) - self.doc.bom_no = pro_obj.doc.bom_no + self.bom_no = pro_obj.bom_no else: # invalid production order - self.doc.production_order = None - - if self.doc.bom_no: - if self.doc.purpose in ["Material Issue", "Material Transfer", "Manufacture/Repack", + self.production_order = None + + if self.bom_no: + if self.purpose in ["Material Issue", "Material Transfer", "Manufacture/Repack", "Subcontract"]: - if self.doc.production_order and self.doc.purpose == "Material Transfer": + if self.production_order and self.purpose == "Material Transfer": item_dict = self.get_pending_raw_materials(pro_obj) else: - if not self.doc.fg_completed_qty: + if not self.fg_completed_qty: frappe.throw(_("Manufacturing Quantity is mandatory")) - item_dict = self.get_bom_raw_materials(self.doc.fg_completed_qty) + item_dict = self.get_bom_raw_materials(self.fg_completed_qty) for item in item_dict.values(): if pro_obj: - item["from_warehouse"] = pro_obj.doc.wip_warehouse + item["from_warehouse"] = pro_obj.wip_warehouse item["to_warehouse"] = "" # add raw materials to Stock Entry Detail table idx = self.add_to_stock_entry_detail(item_dict) - + # add finished good item to Stock Entry Detail table -- along with bom_no - if self.doc.production_order and self.doc.purpose == "Manufacture/Repack": - item = frappe.db.get_value("Item", pro_obj.doc.production_item, ["item_name", + if self.production_order and self.purpose == "Manufacture/Repack": + item = frappe.db.get_value("Item", pro_obj.production_item, ["item_name", "description", "stock_uom", "expense_account", "buying_cost_center"], as_dict=1) self.add_to_stock_entry_detail({ - cstr(pro_obj.doc.production_item): { - "to_warehouse": pro_obj.doc.fg_warehouse, + cstr(pro_obj.production_item): { + "to_warehouse": pro_obj.fg_warehouse, "from_warehouse": "", - "qty": self.doc.fg_completed_qty, + "qty": self.fg_completed_qty, "item_name": item.item_name, "description": item.description, "stock_uom": item.stock_uom, "expense_account": item.expense_account, "cost_center": item.buying_cost_center, } - }, bom_no=pro_obj.doc.bom_no, idx=idx) - - elif self.doc.purpose in ["Material Receipt", "Manufacture/Repack"]: - if self.doc.purpose=="Material Receipt": - self.doc.from_warehouse = "" - - item = frappe.db.sql("""select name, item_name, description, - stock_uom, expense_account, buying_cost_center from `tabItem` - where name=(select item from tabBOM where name=%s)""", - self.doc.bom_no, as_dict=1) + }, bom_no=pro_obj.bom_no, idx=idx) + + elif self.purpose in ["Material Receipt", "Manufacture/Repack"]: + if self.purpose=="Material Receipt": + self.from_warehouse = "" + + item = frappe.db.sql("""select name, item_name, description, + stock_uom, expense_account, buying_cost_center from `tabItem` + where name=(select item from tabBOM where name=%s)""", + self.bom_no, as_dict=1) self.add_to_stock_entry_detail({ item[0]["name"] : { - "qty": self.doc.fg_completed_qty, + "qty": self.fg_completed_qty, "item_name": item[0].item_name, "description": item[0]["description"], "stock_uom": item[0]["stock_uom"], @@ -496,21 +488,21 @@ class DocType(StockController): "expense_account": item[0].expense_account, "cost_center": item[0].buying_cost_center, } - }, bom_no=self.doc.bom_no, idx=idx) - + }, bom_no=self.bom_no, idx=idx) + self.get_stock_and_rate() - + def get_bom_raw_materials(self, qty): from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict - + # item dict = { item_code: {qty, description, stock_uom} } - item_dict = get_bom_items_as_dict(self.doc.bom_no, qty=qty, fetch_exploded = self.doc.use_multi_level_bom) - + item_dict = get_bom_items_as_dict(self.bom_no, qty=qty, fetch_exploded = self.use_multi_level_bom) + for item in item_dict.values(): item.from_warehouse = item.default_warehouse - + return item_dict - + def get_pending_raw_materials(self, pro_obj): """ issue (item quantity) that is pending to issue or desire to transfer, @@ -518,30 +510,30 @@ class DocType(StockController): """ item_dict = self.get_bom_raw_materials(1) issued_item_qty = self.get_issued_qty() - - max_qty = flt(pro_obj.doc.qty) + + max_qty = flt(pro_obj.qty) only_pending_fetched = [] - + for item in item_dict: pending_to_issue = (max_qty * item_dict[item]["qty"]) - issued_item_qty.get(item, 0) - desire_to_transfer = flt(self.doc.fg_completed_qty) * item_dict[item]["qty"] + desire_to_transfer = flt(self.fg_completed_qty) * item_dict[item]["qty"] if desire_to_transfer <= pending_to_issue: item_dict[item]["qty"] = desire_to_transfer else: item_dict[item]["qty"] = pending_to_issue if pending_to_issue: only_pending_fetched.append(item) - + # delete items with 0 qty for item in item_dict.keys(): if not item_dict[item]["qty"]: del item_dict[item] - + # show some message if not len(item_dict): frappe.msgprint(_("""All items have already been transferred \ for this Production Order.""")) - + elif only_pending_fetched: frappe.msgprint(_("""Only quantities pending to be transferred \ were fetched for the following items:\n""" + "\n".join(only_pending_fetched))) @@ -554,23 +546,22 @@ class DocType(StockController): from `tabStock Entry Detail` t1, `tabStock Entry` t2 where t1.parent = t2.name and t2.production_order = %s and t2.docstatus = 1 and t2.purpose = 'Material Transfer' - group by t1.item_code""", self.doc.production_order) + group by t1.item_code""", self.production_order) for t in result: issued_item_qty[t[0]] = flt(t[1]) - + return issued_item_qty def add_to_stock_entry_detail(self, item_dict, bom_no=None, idx=None): if not idx: idx = 1 - expense_account, cost_center = frappe.db.get_values("Company", self.doc.company, \ + expense_account, cost_center = frappe.db.get_values("Company", self.company, \ ["default_expense_account", "cost_center"])[0] for d in item_dict: - se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', - self.doclist) + se_child = self.append('mtn_details', {}) se_child.idx = idx - se_child.s_warehouse = item_dict[d].get("from_warehouse", self.doc.from_warehouse) - se_child.t_warehouse = item_dict[d].get("to_warehouse", self.doc.to_warehouse) + se_child.s_warehouse = item_dict[d].get("from_warehouse", self.from_warehouse) + se_child.t_warehouse = item_dict[d].get("to_warehouse", self.to_warehouse) se_child.item_code = cstr(d) se_child.item_name = item_dict[d]["item_name"] se_child.description = item_dict[d]["description"] @@ -579,88 +570,88 @@ class DocType(StockController): se_child.qty = flt(item_dict[d]["qty"]) se_child.expense_account = item_dict[d]["expense_account"] or expense_account se_child.cost_center = item_dict[d]["cost_center"] or cost_center - + # in stock uom se_child.transfer_qty = flt(item_dict[d]["qty"]) se_child.conversion_factor = 1.00 - + # to be assigned for finished item se_child.bom_no = bom_no # increment idx by 1 idx += 1 return idx - + def validate_with_material_request(self): - for item in self.doclist.get({"parentfield": "mtn_details"}): + for item in self.get("mtn_details"): if item.material_request: - mreq_item = frappe.db.get_value("Material Request Item", + mreq_item = frappe.db.get_value("Material Request Item", {"name": item.material_request_item, "parent": item.material_request}, ["item_code", "warehouse", "idx"], as_dict=True) if mreq_item.item_code != item.item_code or mreq_item.warehouse != item.t_warehouse: msgprint(_("Row #") + (" %d: " % item.idx) + _("does not match") + " " + _("Row #") + (" %d %s " % (mreq_item.idx, _("of"))) - + _("Material Request") + (" - %s" % item.material_request), + + _("Material Request") + (" - %s" % item.material_request), raise_exception=frappe.MappingMismatchError) - -@frappe.whitelist() + +@frappe.whitelist() def get_party_details(ref_dt, ref_dn): if ref_dt in ["Delivery Note", "Sales Invoice"]: - res = frappe.db.get_value(ref_dt, ref_dn, + res = frappe.db.get_value(ref_dt, ref_dn, ["customer", "customer_name", "address_display as customer_address"], as_dict=1) else: - res = frappe.db.get_value(ref_dt, ref_dn, + res = frappe.db.get_value(ref_dt, ref_dn, ["supplier", "supplier_name", "address_display as supplier_address"], as_dict=1) return res or {} - + @frappe.whitelist() def get_production_order_details(production_order): - result = frappe.db.sql("""select bom_no, - ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty, use_multi_level_bom, + result = frappe.db.sql("""select bom_no, + ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty, use_multi_level_bom, wip_warehouse from `tabProduction Order` where name = %s""", production_order, as_dict=1) return result and result[0] or {} - + def query_sales_return_doc(doctype, txt, searchfield, start, page_len, filters): conditions = "" if doctype == "Sales Invoice": conditions = "and update_stock=1" - + return frappe.db.sql("""select name, customer, customer_name from `tab%s` where docstatus = 1 - and (`%s` like %%(txt)s + and (`%s` like %%(txt)s or `customer` like %%(txt)s) %s %s order by name, customer, customer_name - limit %s""" % (doctype, searchfield, conditions, - get_match_cond(doctype), "%(start)s, %(page_len)s"), - {"txt": "%%%s%%" % txt, "start": start, "page_len": page_len}, + limit %s""" % (doctype, searchfield, conditions, + get_match_cond(doctype), "%(start)s, %(page_len)s"), + {"txt": "%%%s%%" % txt, "start": start, "page_len": page_len}, as_list=True) - + def query_purchase_return_doc(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select name, supplier, supplier_name from `tab%s` where docstatus = 1 - and (`%s` like %%(txt)s + and (`%s` like %%(txt)s or `supplier` like %%(txt)s) %s order by name, supplier, supplier_name - limit %s""" % (doctype, searchfield, get_match_cond(doctype), - "%(start)s, %(page_len)s"), {"txt": "%%%s%%" % txt, "start": + limit %s""" % (doctype, searchfield, get_match_cond(doctype), + "%(start)s, %(page_len)s"), {"txt": "%%%s%%" % txt, "start": start, "page_len": page_len}, as_list=True) - + def query_return_item(doctype, txt, searchfield, start, page_len, filters): txt = txt.replace("%", "") - ref = get_return_doclist_and_details(filters) - - stock_items = get_stock_items_for_return(ref.doclist, ref.parentfields) - + ref = get_return_doc_and_details(filters) + + stock_items = get_stock_items_for_return(ref.doc, ref.parentfields) + result = [] - for item in ref.doclist.get({"parentfield": ["in", ref.parentfields]}): - if item.item_code in stock_items: + for item in ref.doc.get_all_children(): + if getattr(item, "item_code", None) in stock_items: item.item_name = cstr(item.item_name) item.description = cstr(item.description) if (txt in item.item_code) or (txt in item.item_name) or (txt in item.description): val = [ - item.item_code, - (len(item.item_name) > 40) and (item.item_name[:40] + "...") or item.item_name, + item.item_code, + (len(item.item_name) > 40) and (item.item_name[:40] + "...") or item.item_name, (len(item.description) > 40) and (item.description[:40] + "...") or \ item.description ] @@ -672,75 +663,75 @@ def query_return_item(doctype, txt, searchfield, start, page_len, filters): def get_batch_no(doctype, txt, searchfield, start, page_len, filters): if not filters.get("posting_date"): filters["posting_date"] = nowdate() - + batch_nos = None args = { - 'item_code': filters['item_code'], - 's_warehouse': filters['s_warehouse'], - 'posting_date': filters['posting_date'], - 'txt': "%%%s%%" % txt, - 'mcond':get_match_cond(doctype), - "start": start, + 'item_code': filters['item_code'], + 's_warehouse': filters['s_warehouse'], + 'posting_date': filters['posting_date'], + 'txt': "%%%s%%" % txt, + 'mcond':get_match_cond(doctype), + "start": start, "page_len": page_len } - + if filters.get("s_warehouse"): - batch_nos = frappe.db.sql("""select batch_no - from `tabStock Ledger Entry` sle - where item_code = '%(item_code)s' + batch_nos = frappe.db.sql("""select batch_no + from `tabStock Ledger Entry` sle + where item_code = '%(item_code)s' and warehouse = '%(s_warehouse)s' - and batch_no like '%(txt)s' - and exists(select * from `tabBatch` - where name = sle.batch_no - and (ifnull(expiry_date, '2099-12-31') >= %(posting_date)s + and batch_no like '%(txt)s' + and exists(select * from `tabBatch` + where name = sle.batch_no + and (ifnull(expiry_date, '2099-12-31') >= %(posting_date)s or expiry_date = '') - and docstatus != 2) + and docstatus != 2) %(mcond)s - group by batch_no having sum(actual_qty) > 0 - order by batch_no desc - limit %(start)s, %(page_len)s """ + group by batch_no having sum(actual_qty) > 0 + order by batch_no desc + limit %(start)s, %(page_len)s """ % args) - + if batch_nos: return batch_nos else: - return frappe.db.sql("""select name from `tabBatch` + return frappe.db.sql("""select name from `tabBatch` where item = '%(item_code)s' and docstatus < 2 - and (ifnull(expiry_date, '2099-12-31') >= %(posting_date)s + and (ifnull(expiry_date, '2099-12-31') >= %(posting_date)s or expiry_date = '' or expiry_date = "0000-00-00") %(mcond)s - order by name desc + order by name desc limit %(start)s, %(page_len)s """ % args) -def get_stock_items_for_return(ref_doclist, parentfields): - """return item codes filtered from doclist, which are stock items""" +def get_stock_items_for_return(ref_doc, parentfields): + """return item codes filtered from doc, which are stock items""" if isinstance(parentfields, basestring): parentfields = [parentfields] - - all_items = list(set([d.item_code for d in - ref_doclist.get({"parentfield": ["in", parentfields]})])) + + all_items = list(set([d.item_code for d in + ref_doc.get_all_children() if d.get("item_code")])) stock_items = frappe.db.sql_list("""select name from `tabItem` where is_stock_item='Yes' and name in (%s)""" % (", ".join(["%s"] * len(all_items))), tuple(all_items)) return stock_items - -def get_return_doclist_and_details(args): + +def get_return_doc_and_details(args): ref = frappe._dict() - - # get ref_doclist - if args["purpose"] in return_map: - for fieldname, val in return_map[args["purpose"]].items(): + + # get ref_doc + if args.get("purpose") in return_map: + for fieldname, val in return_map[args.get("purpose")].items(): if args.get(fieldname): ref.fieldname = fieldname - ref.doclist = frappe.get_doclist(val[0], args[fieldname]) + ref.doc = frappe.get_doc(val[0], args.get(fieldname)) ref.parentfields = val[1] break - + return ref - + return_map = { "Sales Return": { # [Ref DocType, [Item tables' parentfields]] @@ -754,175 +745,174 @@ return_map = { @frappe.whitelist() def make_return_jv(stock_entry): - se = frappe.bean("Stock Entry", stock_entry) - if not se.doc.purpose in ["Sales Return", "Purchase Return"]: + se = frappe.get_doc("Stock Entry", stock_entry) + if not se.purpose in ["Sales Return", "Purchase Return"]: return - - ref = get_return_doclist_and_details(se.doc.fields) - - if ref.doclist[0].doctype == "Delivery Note": + + ref = get_return_doc_and_details(se) + + if ref.doc.doctype == "Delivery Note": result = make_return_jv_from_delivery_note(se, ref) - elif ref.doclist[0].doctype == "Sales Invoice": + elif ref.doc.doctype == "Sales Invoice": result = make_return_jv_from_sales_invoice(se, ref) - elif ref.doclist[0].doctype == "Purchase Receipt": + elif ref.doc.doctype == "Purchase Receipt": result = make_return_jv_from_purchase_receipt(se, ref) - - # create jv doclist and fetch balance for each unique row item - jv_list = [{ - "__islocal": 1, - "doctype": "Journal Voucher", - "posting_date": se.doc.posting_date, - "voucher_type": se.doc.purpose == "Sales Return" and "Credit Note" or "Debit Note", - "fiscal_year": se.doc.fiscal_year, - "company": se.doc.company - }] - + + # create jv doc and fetch balance for each unique row item + jv = frappe.new_doc("Journal Voucher") + jv.update({ + "posting_date": se.posting_date, + "voucher_type": se.purpose == "Sales Return" and "Credit Note" or "Debit Note", + "fiscal_year": se.fiscal_year, + "company": se.company + }) + from erpnext.accounts.utils import get_balance_on for r in result: - jv_list.append({ + jv.append("entries", { "__islocal": 1, "doctype": "Journal Voucher Detail", "parentfield": "entries", "account": r.get("account"), "against_invoice": r.get("against_invoice"), "against_voucher": r.get("against_voucher"), - "balance": get_balance_on(r.get("account"), se.doc.posting_date) \ + "balance": get_balance_on(r.get("account"), se.posting_date) \ if r.get("account") else 0 }) - - return jv_list - + + return jv + def make_return_jv_from_sales_invoice(se, ref): # customer account entry parent = { - "account": ref.doclist[0].debit_to, - "against_invoice": ref.doclist[0].name, + "account": ref.doc.debit_to, + "against_invoice": ref.doc.name, } - + # income account entries children = [] - for se_item in se.doclist.get({"parentfield": "mtn_details"}): - # find item in ref.doclist - ref_item = ref.doclist.getone({"item_code": se_item.item_code}) - - account = get_sales_account_from_item(ref.doclist, ref_item) - + for se_item in se.get("mtn_details"): + # find item in ref.doc + ref_item = ref.doc.get({"item_code": se_item.item_code})[0] + + account = get_sales_account_from_item(ref.doc, ref_item) + if account not in children: children.append(account) - + return [parent] + [{"account": account} for account in children] - -def get_sales_account_from_item(doclist, ref_item): + +def get_sales_account_from_item(doc, ref_item): account = None - if not ref_item.income_account: + if not getattr(ref_item, "income_account", None): if ref_item.parent_item: - parent_item = doclist.getone({"item_code": ref_item.parent_item}) + parent_item = doc.get(doc.fname, {"item_code": ref_item.parent_item})[0] account = parent_item.income_account else: account = ref_item.income_account - + return account - + def make_return_jv_from_delivery_note(se, ref): invoices_against_delivery = get_invoice_list("Sales Invoice Item", "delivery_note", - ref.doclist[0].name) - + ref.doc.name) + if not invoices_against_delivery: - sales_orders_against_delivery = [d.against_sales_order for d in ref.doclist if d.against_sales_order] - + sales_orders_against_delivery = [d.against_sales_order for d in ref.doc.get_all_children() if getattr(d, "against_sales_order", None)] + if sales_orders_against_delivery: invoices_against_delivery = get_invoice_list("Sales Invoice Item", "sales_order", sales_orders_against_delivery) - + if not invoices_against_delivery: return [] - - packing_item_parent_map = dict([[d.item_code, d.parent_item] for d in ref.doclist.get( - {"parentfield": ref.parentfields[1]})]) - + + packing_item_parent_map = dict([[d.item_code, d.parent_item] for d in ref.doc.get(ref.parentfields[1])]) + parent = {} children = [] - - for se_item in se.doclist.get({"parentfield": "mtn_details"}): + + for se_item in se.get("mtn_details"): for sales_invoice in invoices_against_delivery: - si = frappe.bean("Sales Invoice", sales_invoice) - + si = frappe.get_doc("Sales Invoice", sales_invoice) + if se_item.item_code in packing_item_parent_map: - ref_item = si.doclist.get({"item_code": packing_item_parent_map[se_item.item_code]}) + ref_item = si.get({"item_code": packing_item_parent_map[se_item.item_code]}) else: - ref_item = si.doclist.get({"item_code": se_item.item_code}) - + ref_item = si.get({"item_code": se_item.item_code}) + if not ref_item: continue - + ref_item = ref_item[0] - - account = get_sales_account_from_item(si.doclist, ref_item) - + + account = get_sales_account_from_item(si, ref_item) + if account not in children: children.append(account) - + if not parent: - parent = {"account": si.doc.debit_to} + parent = {"account": si.debit_to} break - + if len(invoices_against_delivery) == 1: parent["against_invoice"] = invoices_against_delivery[0] - + result = [parent] + [{"account": account} for account in children] - + return result - + def get_invoice_list(doctype, link_field, value): if isinstance(value, basestring): value = [value] - + return frappe.db.sql_list("""select distinct parent from `tab%s` where docstatus = 1 and `%s` in (%s)""" % (doctype, link_field, ", ".join(["%s"]*len(value))), tuple(value)) - + def make_return_jv_from_purchase_receipt(se, ref): invoice_against_receipt = get_invoice_list("Purchase Invoice Item", "purchase_receipt", - ref.doclist[0].name) - + ref.doc.name) + if not invoice_against_receipt: - purchase_orders_against_receipt = [d.prevdoc_docname for d in - ref.doclist.get({"prevdoc_doctype": "Purchase Order"}) if d.prevdoc_docname] - + purchase_orders_against_receipt = [d.prevdoc_docname for d in + ref.doc.get(ref.doc.fname, {"prevdoc_doctype": "Purchase Order"}) + if getattr(d, "prevdoc_docname", None)] + if purchase_orders_against_receipt: invoice_against_receipt = get_invoice_list("Purchase Invoice Item", "purchase_order", purchase_orders_against_receipt) - + if not invoice_against_receipt: return [] - + parent = {} children = [] - - for se_item in se.doclist.get({"parentfield": "mtn_details"}): + + for se_item in se.get("mtn_details"): for purchase_invoice in invoice_against_receipt: - pi = frappe.bean("Purchase Invoice", purchase_invoice) - ref_item = pi.doclist.get({"item_code": se_item.item_code}) - + pi = frappe.get_doc("Purchase Invoice", purchase_invoice) + ref_item = pi.get({"item_code": se_item.item_code}) + if not ref_item: continue - + ref_item = ref_item[0] - + account = ref_item.expense_account - + if account not in children: children.append(account) - + if not parent: - parent = {"account": pi.doc.credit_to} + parent = {"account": pi.credit_to} break - + if len(invoice_against_receipt) == 1: parent["against_voucher"] = invoice_against_receipt[0] - + result = [parent] + [{"account": account} for account in children] - - return result \ No newline at end of file + + return result diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.txt b/erpnext/stock/doctype/stock_entry/stock_entry.txt deleted file mode 100644 index a8cf16b078d..00000000000 --- a/erpnext/stock/doctype/stock_entry/stock_entry.txt +++ /dev/null @@ -1,638 +0,0 @@ -[ - { - "creation": "2013-04-09 11:43:55", - "docstatus": 0, - "modified": "2014-02-26 10:59:19", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 0, - "allow_copy": 0, - "allow_import": 1, - "allow_rename": 0, - "autoname": "naming_series:", - "doctype": "DocType", - "hide_heading": 0, - "hide_toolbar": 0, - "icon": "icon-file-text", - "in_create": 0, - "in_dialog": 0, - "is_submittable": 1, - "issingle": 0, - "max_attachments": 0, - "module": "Stock", - "name": "__common__", - "read_only": 0, - "read_only_onload": 0, - "search_fields": "transfer_date, from_warehouse, to_warehouse, purpose, remarks" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Stock Entry", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Stock Entry", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Stock Entry" - }, - { - "doctype": "DocField", - "fieldname": "col1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "hidden": 0, - "in_filter": 0, - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "\nSTE", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0 - }, - { - "allow_on_submit": 0, - "default": "Material Issue", - "doctype": "DocField", - "fieldname": "purpose", - "fieldtype": "Select", - "hidden": 0, - "in_filter": 1, - "in_list_view": 1, - "label": "Purpose", - "no_copy": 0, - "oldfieldname": "purpose", - "oldfieldtype": "Select", - "options": "Material Issue\nMaterial Receipt\nMaterial Transfer\nManufacture/Repack\nSubcontract\nSales Return\nPurchase Return", - "print_hide": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0 - }, - { - "allow_on_submit": 0, - "depends_on": "eval:doc.purpose==\"Sales Return\"", - "doctype": "DocField", - "fieldname": "delivery_note_no", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 0, - "label": "Delivery Note No", - "no_copy": 1, - "oldfieldname": "delivery_note_no", - "oldfieldtype": "Link", - "options": "Delivery Note", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 1 - }, - { - "depends_on": "eval:doc.purpose==\"Sales Return\"", - "doctype": "DocField", - "fieldname": "sales_invoice_no", - "fieldtype": "Link", - "hidden": 0, - "label": "Sales Invoice No", - "no_copy": 1, - "options": "Sales Invoice", - "print_hide": 1, - "read_only": 0 - }, - { - "allow_on_submit": 0, - "depends_on": "eval:doc.purpose==\"Purchase Return\"", - "doctype": "DocField", - "fieldname": "purchase_receipt_no", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 0, - "label": "Purchase Receipt No", - "no_copy": 1, - "oldfieldname": "purchase_receipt_no", - "oldfieldtype": "Link", - "options": "Purchase Receipt", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "col2", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, - { - "allow_on_submit": 0, - "default": "Today", - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "hidden": 0, - "in_filter": 1, - "in_list_view": 0, - "label": "Posting Date", - "no_copy": 1, - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 1 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "posting_time", - "fieldtype": "Time", - "hidden": 0, - "in_filter": 0, - "label": "Posting Time", - "no_copy": 1, - "oldfieldname": "posting_time", - "oldfieldtype": "Time", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "items_section", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "read_only": 0 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "from_warehouse", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 0, - "in_list_view": 1, - "label": "Default Source Warehouse", - "no_copy": 1, - "oldfieldname": "from_warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "cb0", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "to_warehouse", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 0, - "in_list_view": 1, - "label": "Default Target Warehouse", - "no_copy": 1, - "oldfieldname": "to_warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "sb0", - "fieldtype": "Section Break", - "options": "Simple", - "read_only": 0 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "mtn_details", - "fieldtype": "Table", - "hidden": 0, - "in_filter": 0, - "label": "MTN Details", - "no_copy": 0, - "oldfieldname": "mtn_details", - "oldfieldtype": "Table", - "options": "Stock Entry Detail", - "print_hide": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "description": "Get valuation rate and available stock at source/target warehouse on mentioned posting date-time. If serialized item, please press this button after entering serial nos.", - "doctype": "DocField", - "fieldname": "get_stock_and_rate", - "fieldtype": "Button", - "label": "Get Stock and Rate", - "oldfieldtype": "Button", - "options": "get_stock_and_rate", - "print_hide": 1, - "read_only": 0 - }, - { - "depends_on": "eval:(doc.purpose!==\"Sales Return\" && doc.purpose!==\"Purchase Return\")", - "doctype": "DocField", - "fieldname": "sb1", - "fieldtype": "Section Break", - "label": "From Bill of Materials", - "read_only": 0 - }, - { - "allow_on_submit": 0, - "depends_on": "eval:inList([\"Material Transfer\", \"Manufacture/Repack\"], doc.purpose)", - "doctype": "DocField", - "fieldname": "production_order", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Production Order", - "no_copy": 0, - "oldfieldname": "production_order", - "oldfieldtype": "Link", - "options": "Production Order", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 1 - }, - { - "depends_on": "eval:!inList([\"Sales Return\", \"Purchase Return\"], doc.purpose)", - "doctype": "DocField", - "fieldname": "bom_no", - "fieldtype": "Link", - "label": "BOM No", - "options": "BOM", - "read_only": 0 - }, - { - "allow_on_submit": 0, - "depends_on": "eval:!inList([\"Sales Return\", \"Purchase Return\"], doc.purpose)", - "description": "As per Stock UOM", - "doctype": "DocField", - "fieldname": "fg_completed_qty", - "fieldtype": "Float", - "hidden": 0, - "in_filter": 0, - "label": "Manufacturing Quantity", - "no_copy": 0, - "oldfieldname": "fg_completed_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "cb1", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "default": "1", - "depends_on": "eval:!inList([\"Sales Return\", \"Purchase Return\"], doc.purpose)", - "description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.", - "doctype": "DocField", - "fieldname": "use_multi_level_bom", - "fieldtype": "Check", - "label": "Use Multi-Level BOM", - "read_only": 0 - }, - { - "allow_on_submit": 0, - "depends_on": "eval:!inList([\"Sales Return\", \"Purchase Return\"], doc.purpose)", - "doctype": "DocField", - "fieldname": "get_items", - "fieldtype": "Button", - "hidden": 0, - "in_filter": 0, - "label": "Get Items", - "no_copy": 0, - "oldfieldtype": "Button", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "depends_on": "eval:(doc.purpose==\"Sales Return\" || doc.purpose==\"Purchase Return\")", - "doctype": "DocField", - "fieldname": "contact_section", - "fieldtype": "Section Break", - "label": "Contact Info", - "read_only": 0 - }, - { - "allow_on_submit": 0, - "depends_on": "eval:doc.purpose==\"Purchase Return\"", - "doctype": "DocField", - "fieldname": "supplier", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 0, - "label": "Supplier", - "no_copy": 1, - "oldfieldname": "supplier", - "oldfieldtype": "Link", - "options": "Supplier", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "allow_on_submit": 0, - "depends_on": "eval:doc.purpose==\"Purchase Return\"", - "doctype": "DocField", - "fieldname": "supplier_name", - "fieldtype": "Data", - "hidden": 0, - "in_filter": 0, - "label": "Supplier Name", - "no_copy": 1, - "oldfieldname": "supplier_name", - "oldfieldtype": "Data", - "print_hide": 0, - "read_only": 1, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "allow_on_submit": 0, - "depends_on": "eval:doc.purpose==\"Purchase Return\"", - "doctype": "DocField", - "fieldname": "supplier_address", - "fieldtype": "Small Text", - "hidden": 0, - "in_filter": 0, - "label": "Supplier Address", - "no_copy": 1, - "oldfieldname": "supplier_address", - "oldfieldtype": "Small Text", - "print_hide": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "allow_on_submit": 0, - "depends_on": "eval:doc.purpose==\"Sales Return\"", - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 0, - "label": "Customer", - "no_copy": 1, - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "allow_on_submit": 0, - "depends_on": "eval:doc.purpose==\"Sales Return\"", - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "hidden": 0, - "in_filter": 0, - "label": "Customer Name", - "no_copy": 1, - "oldfieldname": "customer_name", - "oldfieldtype": "Data", - "print_hide": 0, - "read_only": 1, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "allow_on_submit": 0, - "depends_on": "eval:doc.purpose==\"Sales Return\"", - "doctype": "DocField", - "fieldname": "customer_address", - "fieldtype": "Small Text", - "hidden": 0, - "in_filter": 0, - "label": "Customer Address", - "no_copy": 1, - "oldfieldname": "customer_address", - "oldfieldtype": "Small Text", - "print_hide": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "col4", - "fieldtype": "Column Break", - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "total_amount", - "fieldtype": "Currency", - "label": "Total Amount", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "project_name", - "fieldtype": "Link", - "in_filter": 1, - "label": "Project Name", - "oldfieldname": "project_name", - "oldfieldtype": "Link", - "options": "Project", - "read_only": 0 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "select_print_heading", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 0, - "label": "Print Heading", - "no_copy": 0, - "oldfieldname": "select_print_heading", - "oldfieldtype": "Link", - "options": "Print Heading", - "print_hide": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 0, - "label": "Fiscal Year", - "options": "link:Fiscal Year", - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "col5", - "fieldtype": "Column Break", - "print_width": "50%", - "read_only": 0, - "width": "50%" - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Company", - "no_copy": 0, - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "hidden": 0, - "ignore_restrictions": 1, - "in_filter": 0, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Link", - "options": "Stock Entry", - "print_hide": 1, - "read_only": 1, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "remarks", - "fieldtype": "Text", - "hidden": 0, - "in_filter": 0, - "label": "Remarks", - "no_copy": 1, - "oldfieldname": "remarks", - "oldfieldtype": "Text", - "print_hide": 1, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocPerm", - "role": "Material User" - }, - { - "doctype": "DocPerm", - "role": "Manufacturing User" - }, - { - "doctype": "DocPerm", - "role": "Manufacturing Manager" - }, - { - "doctype": "DocPerm", - "role": "Material Manager" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry/test_records.json b/erpnext/stock/doctype/stock_entry/test_records.json new file mode 100644 index 00000000000..a87b635bd78 --- /dev/null +++ b/erpnext/stock/doctype/stock_entry/test_records.json @@ -0,0 +1,113 @@ +[ + { + "company": "_Test Company", + "doctype": "Stock Entry", + "fiscal_year": "_Test Fiscal Year 2013", + "mtn_details": [ + { + "conversion_factor": 1.0, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Stock Entry Detail", + "expense_account": "Stock Adjustment - _TC", + "incoming_rate": 100, + "item_code": "_Test Item", + "parentfield": "mtn_details", + "qty": 50.0, + "stock_uom": "_Test UOM", + "t_warehouse": "_Test Warehouse - _TC", + "transfer_qty": 50.0, + "uom": "_Test UOM" + } + ], + "posting_date": "2013-01-01", + "posting_time": "17:14:24", + "purpose": "Material Receipt" + }, + { + "company": "_Test Company", + "doctype": "Stock Entry", + "fiscal_year": "_Test Fiscal Year 2013", + "mtn_details": [ + { + "conversion_factor": 1.0, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Stock Entry Detail", + "expense_account": "Stock Adjustment - _TC", + "incoming_rate": 100, + "item_code": "_Test Item", + "parentfield": "mtn_details", + "qty": 40.0, + "s_warehouse": "_Test Warehouse - _TC", + "stock_uom": "_Test UOM", + "transfer_qty": 40.0, + "uom": "_Test UOM" + } + ], + "posting_date": "2013-01-25", + "posting_time": "17:15", + "purpose": "Material Issue" + }, + { + "company": "_Test Company", + "doctype": "Stock Entry", + "fiscal_year": "_Test Fiscal Year 2013", + "mtn_details": [ + { + "conversion_factor": 1.0, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Stock Entry Detail", + "expense_account": "Stock Adjustment - _TC", + "incoming_rate": 100, + "item_code": "_Test Item", + "parentfield": "mtn_details", + "qty": 45.0, + "s_warehouse": "_Test Warehouse - _TC", + "stock_uom": "_Test UOM", + "t_warehouse": "_Test Warehouse 1 - _TC", + "transfer_qty": 45.0, + "uom": "_Test UOM" + } + ], + "posting_date": "2013-01-25", + "posting_time": "17:14:24", + "purpose": "Material Transfer" + }, + { + "company": "_Test Company", + "doctype": "Stock Entry", + "fiscal_year": "_Test Fiscal Year 2013", + "mtn_details": [ + { + "conversion_factor": 1.0, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Stock Entry Detail", + "expense_account": "Stock Adjustment - _TC", + "incoming_rate": 100, + "item_code": "_Test Item", + "parentfield": "mtn_details", + "qty": 50.0, + "s_warehouse": "_Test Warehouse - _TC", + "stock_uom": "_Test UOM", + "transfer_qty": 50.0, + "uom": "_Test UOM" + }, + { + "conversion_factor": 1.0, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Stock Entry Detail", + "expense_account": "Stock Adjustment - _TC", + "incoming_rate": 5000, + "item_code": "_Test Item Home Desktop 100", + "parentfield": "mtn_details", + "qty": 1, + "stock_uom": "_Test UOM", + "t_warehouse": "_Test Warehouse - _TC", + "transfer_qty": 1, + "uom": "_Test UOM" + } + ], + "posting_date": "2013-01-25", + "posting_time": "17:14:24", + "purpose": "Manufacture/Repack" + } +] \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index d14e896fb06..f5fd08cfb4d 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -3,7 +3,8 @@ from __future__ import unicode_literals import frappe, unittest -from frappe.utils import flt +import frappe.defaults +from frappe.utils import flt, getdate from erpnext.stock.doctype.serial_no.serial_no import * from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory from erpnext.stock.doctype.stock_ledger_entry.stock_ledger_entry import StockFreezeError @@ -22,16 +23,15 @@ class TestStockEntry(unittest.TestCase): frappe.db.set_value("Stock Settings", None, "auto_indent", True) - st1 = frappe.bean(copy=test_records[0]) + st1 = frappe.copy_doc(test_records[0]) st1.insert() st1.submit() - st2 = frappe.bean(copy=test_records[1]) + st2 = frappe.copy_doc(test_records[1]) st2.insert() st2.submit() - - from erpnext.stock.utils import reorder_item + from erpnext.stock.utils import reorder_item reorder_item() mr_name = frappe.db.sql("""select parent from `tabMaterial Request Item` @@ -39,23 +39,21 @@ class TestStockEntry(unittest.TestCase): self.assertTrue(mr_name) - frappe.db.set_default("company", self.old_default_company) - def test_material_receipt_gl_entry(self): self._clear_stock_account_balance() set_perpetual_inventory() - mr = frappe.bean(copy=test_records[0]) + mr = frappe.copy_doc(test_records[0]) mr.insert() mr.submit() stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Warehouse", - "master_name": mr.doclist[1].t_warehouse}) + "master_name": mr.get("mtn_details")[0].t_warehouse}) - self.check_stock_ledger_entries("Stock Entry", mr.doc.name, + self.check_stock_ledger_entries("Stock Entry", mr.name, [["_Test Item", "_Test Warehouse - _TC", 50.0]]) - self.check_gl_entries("Stock Entry", mr.doc.name, + self.check_gl_entries("Stock Entry", mr.name, sorted([ [stock_in_hand_account, 5000.0, 0.0], ["Stock Adjustment - _TC", 0.0, 5000.0] @@ -65,10 +63,10 @@ class TestStockEntry(unittest.TestCase): mr.cancel() self.assertFalse(frappe.db.sql("""select * from `tabStock Ledger Entry` - where voucher_type='Stock Entry' and voucher_no=%s""", mr.doc.name)) + where voucher_type='Stock Entry' and voucher_no=%s""", mr.name)) self.assertFalse(frappe.db.sql("""select * from `tabGL Entry` - where voucher_type='Stock Entry' and voucher_no=%s""", mr.doc.name)) + where voucher_type='Stock Entry' and voucher_no=%s""", mr.name)) def test_material_issue_gl_entry(self): @@ -77,17 +75,17 @@ class TestStockEntry(unittest.TestCase): self._insert_material_receipt() - mi = frappe.bean(copy=test_records[1]) + mi = frappe.copy_doc(test_records[1]) mi.insert() mi.submit() - self.check_stock_ledger_entries("Stock Entry", mi.doc.name, + self.check_stock_ledger_entries("Stock Entry", mi.name, [["_Test Item", "_Test Warehouse - _TC", -40.0]]) stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Warehouse", - "master_name": mi.doclist[1].s_warehouse}) + "master_name": mi.get("mtn_details")[0].s_warehouse}) - self.check_gl_entries("Stock Entry", mi.doc.name, + self.check_gl_entries("Stock Entry", mi.name, sorted([ [stock_in_hand_account, 0.0, 4000.0], ["Stock Adjustment - _TC", 4000.0, 0.0] @@ -96,16 +94,16 @@ class TestStockEntry(unittest.TestCase): mi.cancel() self.assertFalse(frappe.db.sql("""select * from `tabStock Ledger Entry` - where voucher_type='Stock Entry' and voucher_no=%s""", mi.doc.name)) + where voucher_type='Stock Entry' and voucher_no=%s""", mi.name)) self.assertFalse(frappe.db.sql("""select * from `tabGL Entry` - where voucher_type='Stock Entry' and voucher_no=%s""", mi.doc.name)) + where voucher_type='Stock Entry' and voucher_no=%s""", mi.name)) - self.assertEquals(frappe.db.get_value("Bin", {"warehouse": mi.doclist[1].s_warehouse, - "item_code": mi.doclist[1].item_code}, "actual_qty"), 50) + self.assertEquals(frappe.db.get_value("Bin", {"warehouse": mi.get("mtn_details")[0].s_warehouse, + "item_code": mi.get("mtn_details")[0].item_code}, "actual_qty"), 50) - self.assertEquals(frappe.db.get_value("Bin", {"warehouse": mi.doclist[1].s_warehouse, - "item_code": mi.doclist[1].item_code}, "stock_value"), 5000) + self.assertEquals(frappe.db.get_value("Bin", {"warehouse": mi.get("mtn_details")[0].s_warehouse, + "item_code": mi.get("mtn_details")[0].item_code}, "stock_value"), 5000) def test_material_transfer_gl_entry(self): self._clear_stock_account_balance() @@ -113,21 +111,21 @@ class TestStockEntry(unittest.TestCase): self._insert_material_receipt() - mtn = frappe.bean(copy=test_records[2]) + mtn = frappe.copy_doc(test_records[2]) mtn.insert() mtn.submit() - self.check_stock_ledger_entries("Stock Entry", mtn.doc.name, + self.check_stock_ledger_entries("Stock Entry", mtn.name, [["_Test Item", "_Test Warehouse - _TC", -45.0], ["_Test Item", "_Test Warehouse 1 - _TC", 45.0]]) stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Warehouse", - "master_name": mtn.doclist[1].s_warehouse}) + "master_name": mtn.get("mtn_details")[0].s_warehouse}) fixed_asset_account = frappe.db.get_value("Account", {"account_type": "Warehouse", - "master_name": mtn.doclist[1].t_warehouse}) + "master_name": mtn.get("mtn_details")[0].t_warehouse}) - self.check_gl_entries("Stock Entry", mtn.doc.name, + self.check_gl_entries("Stock Entry", mtn.name, sorted([ [stock_in_hand_account, 0.0, 4500.0], [fixed_asset_account, 4500.0, 0.0], @@ -137,10 +135,10 @@ class TestStockEntry(unittest.TestCase): mtn.cancel() self.assertFalse(frappe.db.sql("""select * from `tabStock Ledger Entry` - where voucher_type='Stock Entry' and voucher_no=%s""", mtn.doc.name)) + where voucher_type='Stock Entry' and voucher_no=%s""", mtn.name)) self.assertFalse(frappe.db.sql("""select * from `tabGL Entry` - where voucher_type='Stock Entry' and voucher_no=%s""", mtn.doc.name)) + where voucher_type='Stock Entry' and voucher_no=%s""", mtn.name)) def test_repack_no_change_in_valuation(self): @@ -149,17 +147,17 @@ class TestStockEntry(unittest.TestCase): self._insert_material_receipt() - repack = frappe.bean(copy=test_records[3]) + repack = frappe.copy_doc(test_records[3]) repack.insert() repack.submit() - self.check_stock_ledger_entries("Stock Entry", repack.doc.name, + self.check_stock_ledger_entries("Stock Entry", repack.name, [["_Test Item", "_Test Warehouse - _TC", -50.0], ["_Test Item Home Desktop 100", "_Test Warehouse - _TC", 1]]) gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Stock Entry' and voucher_no=%s - order by account desc""", repack.doc.name, as_dict=1) + order by account desc""", repack.name, as_dict=1) self.assertFalse(gl_entries) set_perpetual_inventory(0) @@ -170,15 +168,15 @@ class TestStockEntry(unittest.TestCase): self._insert_material_receipt() - repack = frappe.bean(copy=test_records[3]) - repack.doclist[2].incoming_rate = 6000 + repack = frappe.copy_doc(test_records[3]) + repack.get("mtn_details")[1].incoming_rate = 6000 repack.insert() repack.submit() stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Warehouse", - "master_name": repack.doclist[2].t_warehouse}) + "master_name": repack.get("mtn_details")[1].t_warehouse}) - self.check_gl_entries("Stock Entry", repack.doc.name, + self.check_gl_entries("Stock Entry", repack.name, sorted([ [stock_in_hand_account, 1000.0, 0.0], ["Stock Adjustment - _TC", 0.0, 1000.0], @@ -218,12 +216,12 @@ class TestStockEntry(unittest.TestCase): def _insert_material_receipt(self): self._clear_stock_account_balance() - se1 = frappe.bean(copy=test_records[0]) + se1 = frappe.copy_doc(test_records[0]) se1.insert() se1.submit() - se2 = frappe.bean(copy=test_records[0]) - se2.doclist[1].item_code = "_Test Item Home Desktop 100" + se2 = frappe.copy_doc(test_records[0]) + se2.get("mtn_details")[0].item_code = "_Test Item Home Desktop 100" se2.insert() se2.submit() @@ -235,20 +233,20 @@ class TestStockEntry(unittest.TestCase): def _test_sales_invoice_return(self, item_code, delivered_qty, returned_qty): from erpnext.stock.doctype.stock_entry.stock_entry import NotUpdateStockError - + from erpnext.accounts.doctype.sales_invoice.test_sales_invoice \ import test_records as sales_invoice_test_records # invalid sales invoice as update stock not checked - si = frappe.bean(copy=sales_invoice_test_records[1]) + si = frappe.copy_doc(sales_invoice_test_records[1]) si.insert() si.submit() - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Sales Return" - se.doc.sales_invoice_no = si.doc.name - se.doclist[1].qty = returned_qty - se.doclist[1].transfer_qty = returned_qty + se = frappe.copy_doc(test_records[0]) + se.purpose = "Sales Return" + se.sales_invoice_no = si.name + se.get("mtn_details")[0].qty = returned_qty + se.get("mtn_details")[0].transfer_qty = returned_qty self.assertRaises(NotUpdateStockError, se.insert) self._insert_material_receipt() @@ -257,11 +255,11 @@ class TestStockEntry(unittest.TestCase): actual_qty_0 = self._get_actual_qty() # insert a pos invoice with update stock - si = frappe.bean(copy=sales_invoice_test_records[1]) - si.doc.is_pos = si.doc.update_stock = 1 - si.doclist[1].warehouse = "_Test Warehouse - _TC" - si.doclist[1].item_code = item_code - si.doclist[1].qty = 5.0 + si = frappe.copy_doc(sales_invoice_test_records[1]) + si.is_pos = si.update_stock = 1 + si.get("entries")[0].warehouse = "_Test Warehouse - _TC" + si.get("entries")[0].item_code = item_code + si.get("entries")[0].qty = 5.0 si.insert() si.submit() @@ -271,26 +269,26 @@ class TestStockEntry(unittest.TestCase): self.assertEquals(actual_qty_0 - delivered_qty, actual_qty_1) # check if item is validated - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Sales Return" - se.doc.sales_invoice_no = si.doc.name - se.doc.posting_date = "2013-03-10" - se.doc.fiscal_year = "_Test Fiscal Year 2013" - se.doclist[1].item_code = "_Test Item Home Desktop 200" - se.doclist[1].qty = returned_qty - se.doclist[1].transfer_qty = returned_qty + se = frappe.copy_doc(test_records[0]) + se.purpose = "Sales Return" + se.sales_invoice_no = si.name + se.posting_date = "2013-03-10" + se.fiscal_year = "_Test Fiscal Year 2013" + se.get("mtn_details")[0].item_code = "_Test Item Home Desktop 200" + se.get("mtn_details")[0].qty = returned_qty + se.get("mtn_details")[0].transfer_qty = returned_qty # check if stock entry gets submitted self.assertRaises(frappe.DoesNotExistError, se.insert) # try again - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Sales Return" - se.doc.posting_date = "2013-03-10" - se.doc.fiscal_year = "_Test Fiscal Year 2013" - se.doc.sales_invoice_no = si.doc.name - se.doclist[1].qty = returned_qty - se.doclist[1].transfer_qty = returned_qty + se = frappe.copy_doc(test_records[0]) + se.purpose = "Sales Return" + se.posting_date = "2013-03-10" + se.fiscal_year = "_Test Fiscal Year 2013" + se.sales_invoice_no = si.name + se.get("mtn_details")[0].qty = returned_qty + se.get("mtn_details")[0].transfer_qty = returned_qty # in both cases item code remains _Test Item when returning se.insert() @@ -321,8 +319,8 @@ class TestStockEntry(unittest.TestCase): actual_qty_0 = self._get_actual_qty() # make a delivery note based on this invoice - dn = frappe.bean(copy=delivery_note_test_records[0]) - dn.doclist[1].item_code = item_code + dn = frappe.copy_doc(delivery_note_test_records[0]) + dn.get("delivery_note_details")[0].item_code = item_code dn.insert() dn.submit() @@ -330,24 +328,24 @@ class TestStockEntry(unittest.TestCase): self.assertEquals(actual_qty_0 - delivered_qty, actual_qty_1) - si_doclist = make_sales_invoice(dn.doc.name) + si_doc = make_sales_invoice(dn.name) - si = frappe.bean(si_doclist) - si.doc.posting_date = dn.doc.posting_date - si.doc.debit_to = "_Test Customer - _TC" - for d in si.doclist.get({"parentfield": "entries"}): + si = frappe.get_doc(si_doc) + si.posting_date = dn.posting_date + si.debit_to = "_Test Customer - _TC" + for d in si.get("entries"): d.income_account = "Sales - _TC" d.cost_center = "_Test Cost Center - _TC" si.insert() si.submit() # insert and submit stock entry for sales return - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Sales Return" - se.doc.delivery_note_no = dn.doc.name - se.doc.posting_date = "2013-03-10" - se.doc.fiscal_year = "_Test Fiscal Year 2013" - se.doclist[1].qty = se.doclist[1].transfer_qty = returned_qty + se = frappe.copy_doc(test_records[0]) + se.purpose = "Sales Return" + se.delivery_note_no = dn.name + se.posting_date = "2013-03-10" + se.fiscal_year = "_Test Fiscal Year 2013" + se.get("mtn_details")[0].qty = se.get("mtn_details")[0].transfer_qty = returned_qty se.insert() se.submit() @@ -367,14 +365,14 @@ class TestStockEntry(unittest.TestCase): def _test_sales_return_jv(self, se): from erpnext.stock.doctype.stock_entry.stock_entry import make_return_jv - jv_list = make_return_jv(se.doc.name) + jv = make_return_jv(se.name) - self.assertEqual(len(jv_list), 3) - self.assertEqual(jv_list[0].get("voucher_type"), "Credit Note") - self.assertEqual(jv_list[0].get("posting_date"), se.doc.posting_date) - self.assertEqual(jv_list[1].get("account"), "_Test Customer - _TC") - self.assertEqual(jv_list[2].get("account"), "Sales - _TC") - self.assertTrue(jv_list[1].get("against_invoice")) + self.assertEqual(len(jv.get("entries")), 2) + self.assertEqual(jv.get("voucher_type"), "Credit Note") + self.assertEqual(jv.get("posting_date"), se.posting_date) + self.assertEqual(jv.get("entries")[0].get("account"), "_Test Customer - _TC") + self.assertEqual(jv.get("entries")[1].get("account"), "Sales - _TC") + self.assertTrue(jv.get("entries")[0].get("against_invoice")) def test_make_return_jv_for_sales_invoice_non_packing_item(self): self._clear_stock_account_balance() @@ -410,42 +408,37 @@ class TestStockEntry(unittest.TestCase): actual_qty_0 = self._get_actual_qty() - so = frappe.bean(copy=sales_order_test_records[0]) - so.doclist[1].item_code = item_code - so.doclist[1].qty = 5.0 + so = frappe.copy_doc(sales_order_test_records[0]) + so.get("sales_order_details")[0].item_code = item_code + so.get("sales_order_details")[0].qty = 5.0 so.insert() so.submit() - dn_doclist = make_delivery_note(so.doc.name) - - dn = frappe.bean(dn_doclist) - dn.doc.status = "Draft" - dn.doc.posting_date = so.doc.delivery_date + dn = make_delivery_note(so.name) + dn.status = "Draft" + dn.posting_date = so.delivery_date dn.insert() dn.submit() actual_qty_1 = self._get_actual_qty() - self.assertEquals(actual_qty_0 - delivered_qty, actual_qty_1) - si_doclist = make_sales_invoice(so.doc.name) - - si = frappe.bean(si_doclist) - si.doc.posting_date = dn.doc.posting_date - si.doc.debit_to = "_Test Customer - _TC" - for d in si.doclist.get({"parentfield": "entries"}): + si = make_sales_invoice(so.name) + si.posting_date = dn.posting_date + si.debit_to = "_Test Customer - _TC" + for d in si.get("entries"): d.income_account = "Sales - _TC" d.cost_center = "_Test Cost Center - _TC" si.insert() si.submit() # insert and submit stock entry for sales return - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Sales Return" - se.doc.delivery_note_no = dn.doc.name - se.doc.posting_date = "2013-03-10" - se.doc.fiscal_year = "_Test Fiscal Year 2013" - se.doclist[1].qty = se.doclist[1].transfer_qty = returned_qty + se = frappe.copy_doc(test_records[0]) + se.purpose = "Sales Return" + se.delivery_note_no = dn.name + se.posting_date = "2013-03-10" + se.fiscal_year = "_Test Fiscal Year 2013" + se.get("mtn_details")[0].qty = se.get("mtn_details")[0].transfer_qty = returned_qty se.insert() se.submit() @@ -464,9 +457,9 @@ class TestStockEntry(unittest.TestCase): import test_records as purchase_receipt_test_records from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice - + # submit purchase receipt - pr = frappe.bean(copy=purchase_receipt_test_records[0]) + pr = frappe.copy_doc(purchase_receipt_test_records[0]) pr.insert() pr.submit() @@ -474,31 +467,31 @@ class TestStockEntry(unittest.TestCase): self.assertEquals(actual_qty_0 + 5, actual_qty_1) - pi_doclist = make_purchase_invoice(pr.doc.name) + pi_doc = make_purchase_invoice(pr.name) - pi = frappe.bean(pi_doclist) - pi.doc.posting_date = pr.doc.posting_date - pi.doc.credit_to = "_Test Supplier - _TC" - for d in pi.doclist.get({"parentfield": "entries"}): + pi = frappe.get_doc(pi_doc) + pi.posting_date = pr.posting_date + pi.credit_to = "_Test Supplier - _TC" + for d in pi.get("entries"): d.expense_account = "_Test Account Cost for Goods Sold - _TC" d.cost_center = "_Test Cost Center - _TC" - for d in pi.doclist.get({"parentfield": "other_charges"}): + for d in pi.get("other_charges"): d.cost_center = "_Test Cost Center - _TC" pi.run_method("calculate_taxes_and_totals") - pi.doc.bill_no = "NA" + pi.bill_no = "NA" pi.insert() pi.submit() # submit purchase return - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Purchase Return" - se.doc.purchase_receipt_no = pr.doc.name - se.doc.posting_date = "2013-03-01" - se.doc.fiscal_year = "_Test Fiscal Year 2013" - se.doclist[1].qty = se.doclist[1].transfer_qty = 5 - se.doclist[1].s_warehouse = "_Test Warehouse - _TC" + se = frappe.copy_doc(test_records[0]) + se.purpose = "Purchase Return" + se.purchase_receipt_no = pr.name + se.posting_date = "2013-03-01" + se.fiscal_year = "_Test Fiscal Year 2013" + se.get("mtn_details")[0].qty = se.get("mtn_details")[0].transfer_qty = 5 + se.get("mtn_details")[0].s_warehouse = "_Test Warehouse - _TC" se.insert() se.submit() @@ -508,7 +501,7 @@ class TestStockEntry(unittest.TestCase): frappe.db.set_default("company", self.old_default_company) - return se, pr.doc.name + return se, pr.name def test_over_stock_return(self): from erpnext.stock.doctype.stock_entry.stock_entry import StockOverReturnError @@ -518,26 +511,26 @@ class TestStockEntry(unittest.TestCase): prev_se, pr_docname = self.test_purchase_receipt_return() # submit purchase return - return another 6 qtys so that exception is raised - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Purchase Return" - se.doc.purchase_receipt_no = pr_docname - se.doc.posting_date = "2013-03-01" - se.doc.fiscal_year = "_Test Fiscal Year 2013" - se.doclist[1].qty = se.doclist[1].transfer_qty = 6 - se.doclist[1].s_warehouse = "_Test Warehouse - _TC" + se = frappe.copy_doc(test_records[0]) + se.purpose = "Purchase Return" + se.purchase_receipt_no = pr_docname + se.posting_date = "2013-03-01" + se.fiscal_year = "_Test Fiscal Year 2013" + se.get("mtn_details")[0].qty = se.get("mtn_details")[0].transfer_qty = 6 + se.get("mtn_details")[0].s_warehouse = "_Test Warehouse - _TC" self.assertRaises(StockOverReturnError, se.insert) def _test_purchase_return_jv(self, se): from erpnext.stock.doctype.stock_entry.stock_entry import make_return_jv - jv_list = make_return_jv(se.doc.name) + jv = make_return_jv(se.name) - self.assertEqual(len(jv_list), 3) - self.assertEqual(jv_list[0].get("voucher_type"), "Debit Note") - self.assertEqual(jv_list[0].get("posting_date"), se.doc.posting_date) - self.assertEqual(jv_list[1].get("account"), "_Test Supplier - _TC") - self.assertEqual(jv_list[2].get("account"), "_Test Account Cost for Goods Sold - _TC") - self.assertTrue(jv_list[1].get("against_voucher")) + self.assertEqual(len(jv.get("entries")), 2) + self.assertEqual(jv.get("voucher_type"), "Debit Note") + self.assertEqual(jv.get("posting_date"), se.posting_date) + self.assertEqual(jv.get("entries")[0].get("account"), "_Test Supplier - _TC") + self.assertEqual(jv.get("entries")[1].get("account"), "_Test Account Cost for Goods Sold - _TC") + self.assertTrue(jv.get("entries")[0].get("against_voucher")) def test_make_return_jv_for_purchase_receipt(self): self._clear_stock_account_balance() @@ -551,25 +544,25 @@ class TestStockEntry(unittest.TestCase): self._clear_stock_account_balance() actual_qty_0 = self._get_actual_qty() - + from erpnext.buying.doctype.purchase_order.test_purchase_order \ import test_records as purchase_order_test_records - + from erpnext.buying.doctype.purchase_order.purchase_order import \ make_purchase_receipt, make_purchase_invoice # submit purchase receipt - po = frappe.bean(copy=purchase_order_test_records[0]) - po.doc.is_subcontracted = None - po.doclist[1].item_code = "_Test Item" - po.doclist[1].rate = 50 + po = frappe.copy_doc(purchase_order_test_records[0]) + po.is_subcontracted = None + po.get("po_details")[0].item_code = "_Test Item" + po.get("po_details")[0].rate = 50 po.insert() po.submit() - pr_doclist = make_purchase_receipt(po.doc.name) + pr_doc = make_purchase_receipt(po.name) - pr = frappe.bean(pr_doclist) - pr.doc.posting_date = po.doc.transaction_date + pr = frappe.get_doc(pr_doc) + pr.posting_date = po.transaction_date pr.insert() pr.submit() @@ -577,30 +570,30 @@ class TestStockEntry(unittest.TestCase): self.assertEquals(actual_qty_0 + 10, actual_qty_1) - pi_doclist = make_purchase_invoice(po.doc.name) + pi_doc = make_purchase_invoice(po.name) - pi = frappe.bean(pi_doclist) - pi.doc.posting_date = pr.doc.posting_date - pi.doc.credit_to = "_Test Supplier - _TC" - for d in pi.doclist.get({"parentfield": "entries"}): + pi = frappe.get_doc(pi_doc) + pi.posting_date = pr.posting_date + pi.credit_to = "_Test Supplier - _TC" + for d in pi.get("entries"): d.expense_account = "_Test Account Cost for Goods Sold - _TC" d.cost_center = "_Test Cost Center - _TC" - for d in pi.doclist.get({"parentfield": "other_charges"}): + for d in pi.get("other_charges"): d.cost_center = "_Test Cost Center - _TC" pi.run_method("calculate_taxes_and_totals") - pi.doc.bill_no = "NA" + pi.bill_no = "NA" pi.insert() pi.submit() # submit purchase return - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Purchase Return" - se.doc.purchase_receipt_no = pr.doc.name - se.doc.posting_date = "2013-03-01" - se.doc.fiscal_year = "_Test Fiscal Year 2013" - se.doclist[1].qty = se.doclist[1].transfer_qty = 5 - se.doclist[1].s_warehouse = "_Test Warehouse - _TC" + se = frappe.copy_doc(test_records[0]) + se.purpose = "Purchase Return" + se.purchase_receipt_no = pr.name + se.posting_date = "2013-03-01" + se.fiscal_year = "_Test Fiscal Year 2013" + se.get("mtn_details")[0].qty = se.get("mtn_details")[0].transfer_qty = 5 + se.get("mtn_details")[0].s_warehouse = "_Test Warehouse - _TC" se.insert() se.submit() @@ -610,7 +603,7 @@ class TestStockEntry(unittest.TestCase): frappe.db.set_default("company", self.old_default_company) - return se, pr.doc.name + return se, pr.name def _clear_stock_account_balance(self): frappe.db.sql("delete from `tabStock Ledger Entry`") @@ -621,44 +614,44 @@ class TestStockEntry(unittest.TestCase): frappe.db.set_default("company", "_Test Company") def test_serial_no_not_reqd(self): - se = frappe.bean(copy=test_records[0]) - se.doclist[1].serial_no = "ABCD" + se = frappe.copy_doc(test_records[0]) + se.get("mtn_details")[0].serial_no = "ABCD" se.insert() self.assertRaises(SerialNoNotRequiredError, se.submit) def test_serial_no_reqd(self): - se = frappe.bean(copy=test_records[0]) - se.doclist[1].item_code = "_Test Serialized Item" - se.doclist[1].qty = 2 - se.doclist[1].transfer_qty = 2 + se = frappe.copy_doc(test_records[0]) + se.get("mtn_details")[0].item_code = "_Test Serialized Item" + se.get("mtn_details")[0].qty = 2 + se.get("mtn_details")[0].transfer_qty = 2 se.insert() self.assertRaises(SerialNoRequiredError, se.submit) def test_serial_no_qty_more(self): - se = frappe.bean(copy=test_records[0]) - se.doclist[1].item_code = "_Test Serialized Item" - se.doclist[1].qty = 2 - se.doclist[1].serial_no = "ABCD\nEFGH\nXYZ" - se.doclist[1].transfer_qty = 2 + se = frappe.copy_doc(test_records[0]) + se.get("mtn_details")[0].item_code = "_Test Serialized Item" + se.get("mtn_details")[0].qty = 2 + se.get("mtn_details")[0].serial_no = "ABCD\nEFGH\nXYZ" + se.get("mtn_details")[0].transfer_qty = 2 se.insert() self.assertRaises(SerialNoQtyError, se.submit) def test_serial_no_qty_less(self): - se = frappe.bean(copy=test_records[0]) - se.doclist[1].item_code = "_Test Serialized Item" - se.doclist[1].qty = 2 - se.doclist[1].serial_no = "ABCD" - se.doclist[1].transfer_qty = 2 + se = frappe.copy_doc(test_records[0]) + se.get("mtn_details")[0].item_code = "_Test Serialized Item" + se.get("mtn_details")[0].qty = 2 + se.get("mtn_details")[0].serial_no = "ABCD" + se.get("mtn_details")[0].transfer_qty = 2 se.insert() self.assertRaises(SerialNoQtyError, se.submit) def test_serial_no_transfer_in(self): self._clear_stock_account_balance() - se = frappe.bean(copy=test_records[0]) - se.doclist[1].item_code = "_Test Serialized Item" - se.doclist[1].qty = 2 - se.doclist[1].serial_no = "ABCD\nEFGH" - se.doclist[1].transfer_qty = 2 + se = frappe.copy_doc(test_records[0]) + se.get("mtn_details")[0].item_code = "_Test Serialized Item" + se.get("mtn_details")[0].qty = 2 + se.get("mtn_details")[0].serial_no = "ABCD\nEFGH" + se.get("mtn_details")[0].transfer_qty = 2 se.insert() se.submit() @@ -670,14 +663,14 @@ class TestStockEntry(unittest.TestCase): def test_serial_no_not_exists(self): self._clear_stock_account_balance() - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Material Issue" - se.doclist[1].item_code = "_Test Serialized Item" - se.doclist[1].qty = 2 - se.doclist[1].s_warehouse = "_Test Warehouse 1 - _TC" - se.doclist[1].t_warehouse = None - se.doclist[1].serial_no = "ABCD\nEFGH" - se.doclist[1].transfer_qty = 2 + se = frappe.copy_doc(test_records[0]) + se.purpose = "Material Issue" + se.get("mtn_details")[0].item_code = "_Test Serialized Item" + se.get("mtn_details")[0].qty = 2 + se.get("mtn_details")[0].s_warehouse = "_Test Warehouse 1 - _TC" + se.get("mtn_details")[0].t_warehouse = None + se.get("mtn_details")[0].serial_no = "ABCD\nEFGH" + se.get("mtn_details")[0].transfer_qty = 2 se.insert() self.assertRaises(SerialNoNotExistsError, se.submit) @@ -685,11 +678,11 @@ class TestStockEntry(unittest.TestCase): self._clear_stock_account_balance() self.test_serial_by_series() - se = frappe.bean(copy=test_records[0]) - se.doclist[1].item_code = "_Test Serialized Item With Series" - se.doclist[1].qty = 1 - se.doclist[1].serial_no = "ABCD00001" - se.doclist[1].transfer_qty = 1 + se = frappe.copy_doc(test_records[0]) + se.get("mtn_details")[0].item_code = "_Test Serialized Item With Series" + se.get("mtn_details")[0].qty = 1 + se.get("mtn_details")[0].serial_no = "ABCD00001" + se.get("mtn_details")[0].transfer_qty = 1 se.insert() self.assertRaises(SerialNoDuplicateError, se.submit) @@ -697,7 +690,7 @@ class TestStockEntry(unittest.TestCase): self._clear_stock_account_balance() se = make_serialized_item() - serial_nos = get_serial_nos(se.doclist[1].serial_no) + serial_nos = get_serial_nos(se.get("mtn_details")[0].serial_no) self.assertTrue(frappe.db.exists("Serial No", serial_nos[0])) self.assertTrue(frappe.db.exists("Serial No", serial_nos[1])) @@ -708,30 +701,30 @@ class TestStockEntry(unittest.TestCase): self._clear_stock_account_balance() self.test_serial_by_series() - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Material Transfer" - se.doclist[1].item_code = "_Test Serialized Item" - se.doclist[1].qty = 1 - se.doclist[1].transfer_qty = 1 - se.doclist[1].serial_no = "ABCD00001" - se.doclist[1].s_warehouse = "_Test Warehouse - _TC" - se.doclist[1].t_warehouse = "_Test Warehouse 1 - _TC" + se = frappe.copy_doc(test_records[0]) + se.purpose = "Material Transfer" + se.get("mtn_details")[0].item_code = "_Test Serialized Item" + se.get("mtn_details")[0].qty = 1 + se.get("mtn_details")[0].transfer_qty = 1 + se.get("mtn_details")[0].serial_no = "ABCD00001" + se.get("mtn_details")[0].s_warehouse = "_Test Warehouse - _TC" + se.get("mtn_details")[0].t_warehouse = "_Test Warehouse 1 - _TC" se.insert() self.assertRaises(SerialNoItemError, se.submit) def test_serial_move(self): self._clear_stock_account_balance() se = make_serialized_item() - serial_no = get_serial_nos(se.doclist[1].serial_no)[0] + serial_no = get_serial_nos(se.get("mtn_details")[0].serial_no)[0] - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Material Transfer" - se.doclist[1].item_code = "_Test Serialized Item With Series" - se.doclist[1].qty = 1 - se.doclist[1].transfer_qty = 1 - se.doclist[1].serial_no = serial_no - se.doclist[1].s_warehouse = "_Test Warehouse - _TC" - se.doclist[1].t_warehouse = "_Test Warehouse 1 - _TC" + se = frappe.copy_doc(test_records[0]) + se.purpose = "Material Transfer" + se.get("mtn_details")[0].item_code = "_Test Serialized Item With Series" + se.get("mtn_details")[0].qty = 1 + se.get("mtn_details")[0].transfer_qty = 1 + se.get("mtn_details")[0].serial_no = serial_no + se.get("mtn_details")[0].s_warehouse = "_Test Warehouse - _TC" + se.get("mtn_details")[0].t_warehouse = "_Test Warehouse 1 - _TC" se.insert() se.submit() self.assertTrue(frappe.db.get_value("Serial No", serial_no, "warehouse"), "_Test Warehouse 1 - _TC") @@ -743,14 +736,14 @@ class TestStockEntry(unittest.TestCase): self._clear_stock_account_balance() make_serialized_item() - se = frappe.bean(copy=test_records[0]) - se.doc.purpose = "Material Transfer" - se.doclist[1].item_code = "_Test Serialized Item With Series" - se.doclist[1].qty = 1 - se.doclist[1].transfer_qty = 1 - se.doclist[1].serial_no = "ABCD00001" - se.doclist[1].s_warehouse = "_Test Warehouse 1 - _TC" - se.doclist[1].t_warehouse = "_Test Warehouse - _TC" + se = frappe.copy_doc(test_records[0]) + se.purpose = "Material Transfer" + se.get("mtn_details")[0].item_code = "_Test Serialized Item With Series" + se.get("mtn_details")[0].qty = 1 + se.get("mtn_details")[0].transfer_qty = 1 + se.get("mtn_details")[0].serial_no = "ABCD00001" + se.get("mtn_details")[0].s_warehouse = "_Test Warehouse 1 - _TC" + se.get("mtn_details")[0].t_warehouse = "_Test Warehouse - _TC" se.insert() self.assertRaises(SerialNoWarehouseError, se.submit) @@ -759,187 +752,75 @@ class TestStockEntry(unittest.TestCase): se = self.test_serial_by_series() se.cancel() - serial_no = get_serial_nos(se.doclist[1].serial_no)[0] + serial_no = get_serial_nos(se.get("mtn_details")[0].serial_no)[0] self.assertFalse(frappe.db.get_value("Serial No", serial_no, "warehouse")) - + def test_warehouse_company_validation(self): set_perpetual_inventory(0) self._clear_stock_account_balance() - frappe.bean("User", "test2@example.com").get_controller()\ + frappe.get_doc("User", "test2@example.com")\ .add_roles("Sales User", "Sales Manager", "Material User", "Material Manager") frappe.set_user("test2@example.com") from erpnext.stock.utils import InvalidWarehouseCompany - st1 = frappe.bean(copy=test_records[0]) - st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1" + st1 = frappe.copy_doc(test_records[0]) + st1.get("mtn_details")[0].t_warehouse="_Test Warehouse 2 - _TC1" st1.insert() self.assertRaises(InvalidWarehouseCompany, st1.submit) - + # permission tests def test_warehouse_user(self): - import frappe.defaults - from frappe.model.bean import BeanPermissionError set_perpetual_inventory(0) - - frappe.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", "Restriction") + + frappe.defaults.add_default("Warehouse", "_Test Warehouse 1 - _TC", "test@example.com", "Restriction") frappe.defaults.add_default("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com", "Restriction") - frappe.bean("User", "test@example.com").get_controller()\ + frappe.get_doc("User", "test@example.com")\ .add_roles("Sales User", "Sales Manager", "Material User", "Material Manager") - frappe.bean("User", "test2@example.com").get_controller()\ + frappe.get_doc("User", "test2@example.com")\ .add_roles("Sales User", "Sales Manager", "Material User", "Material Manager") frappe.set_user("test@example.com") - st1 = frappe.bean(copy=test_records[0]) - st1.doc.company = "_Test Company 1" - st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1" - self.assertRaises(BeanPermissionError, st1.insert) + st1 = frappe.copy_doc(test_records[0]) + st1.company = "_Test Company 1" + st1.get("mtn_details")[0].t_warehouse="_Test Warehouse 2 - _TC1" + self.assertRaises(frappe.PermissionError, st1.insert) frappe.set_user("test2@example.com") - st1 = frappe.bean(copy=test_records[0]) - st1.doc.company = "_Test Company 1" - st1.doclist[1].t_warehouse="_Test Warehouse 2 - _TC1" + st1 = frappe.copy_doc(test_records[0]) + st1.company = "_Test Company 1" + st1.get("mtn_details")[0].t_warehouse="_Test Warehouse 2 - _TC1" st1.insert() st1.submit() - - frappe.defaults.clear_default("Warehouse", "_Test Warehouse 1 - _TC1", "test@example.com", parenttype="Restriction") - frappe.defaults.clear_default("Warehouse", "_Test Warehouse 2 - _TC1", "test2@example.com", parenttype="Restriction") - + + frappe.defaults.clear_default("Warehouse", "_Test Warehouse 1 - _TC", + "test@example.com", parenttype="Restriction") + frappe.defaults.clear_default("Warehouse", "_Test Warehouse 2 - _TC1", + "test2@example.com", parenttype="Restriction") + def test_freeze_stocks (self): self._clear_stock_account_balance() frappe.db.set_value('Stock Settings', None,'stock_auth_role', '') # test freeze_stocks_upto - date_newer_than_test_records = add_days(getdate(test_records[0][0]['posting_date']), 5) + date_newer_than_test_records = add_days(getdate(test_records[0]['posting_date']), 5) frappe.db.set_value("Stock Settings", None, "stock_frozen_upto", date_newer_than_test_records) - se = frappe.bean(copy=test_records[0]).insert() + se = frappe.copy_doc(test_records[0]).insert() self.assertRaises (StockFreezeError, se.submit) frappe.db.set_value("Stock Settings", None, "stock_frozen_upto", '') # test freeze_stocks_upto_days frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 7) - se = frappe.bean(copy=test_records[0]).insert() + se = frappe.copy_doc(test_records[0]).insert() self.assertRaises (StockFreezeError, se.submit) frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 0) def make_serialized_item(): - se = frappe.bean(copy=test_records[0]) - se.doclist[1].item_code = "_Test Serialized Item With Series" - se.doclist[1].qty = 2 - se.doclist[1].transfer_qty = 2 + se = frappe.copy_doc(test_records[0]) + se.get("mtn_details")[0].item_code = "_Test Serialized Item With Series" + se.get("mtn_details")[0].qty = 2 + se.get("mtn_details")[0].transfer_qty = 2 se.insert() se.submit() return se -test_records = [ - [ - { - "company": "_Test Company", - "doctype": "Stock Entry", - "posting_date": "2013-01-01", - "posting_time": "17:14:24", - "purpose": "Material Receipt", - "fiscal_year": "_Test Fiscal Year 2013", - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item", - "parentfield": "mtn_details", - "incoming_rate": 100, - "qty": 50.0, - "stock_uom": "_Test UOM", - "transfer_qty": 50.0, - "uom": "_Test UOM", - "t_warehouse": "_Test Warehouse - _TC", - "expense_account": "Stock Adjustment - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - ], - [ - { - "company": "_Test Company", - "doctype": "Stock Entry", - "posting_date": "2013-01-25", - "posting_time": "17:15", - "purpose": "Material Issue", - "fiscal_year": "_Test Fiscal Year 2013", - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item", - "parentfield": "mtn_details", - "incoming_rate": 100, - "qty": 40.0, - "stock_uom": "_Test UOM", - "transfer_qty": 40.0, - "uom": "_Test UOM", - "s_warehouse": "_Test Warehouse - _TC", - "expense_account": "Stock Adjustment - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - ], - [ - { - "company": "_Test Company", - "doctype": "Stock Entry", - "posting_date": "2013-01-25", - "posting_time": "17:14:24", - "purpose": "Material Transfer", - "fiscal_year": "_Test Fiscal Year 2013", - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item", - "parentfield": "mtn_details", - "incoming_rate": 100, - "qty": 45.0, - "stock_uom": "_Test UOM", - "transfer_qty": 45.0, - "uom": "_Test UOM", - "s_warehouse": "_Test Warehouse - _TC", - "t_warehouse": "_Test Warehouse 1 - _TC", - "expense_account": "Stock Adjustment - _TC", - "cost_center": "_Test Cost Center - _TC" - } - ], - [ - { - "company": "_Test Company", - "doctype": "Stock Entry", - "posting_date": "2013-01-25", - "posting_time": "17:14:24", - "purpose": "Manufacture/Repack", - "fiscal_year": "_Test Fiscal Year 2013", - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item", - "parentfield": "mtn_details", - "incoming_rate": 100, - "qty": 50.0, - "stock_uom": "_Test UOM", - "transfer_qty": 50.0, - "uom": "_Test UOM", - "s_warehouse": "_Test Warehouse - _TC", - "expense_account": "Stock Adjustment - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item Home Desktop 100", - "parentfield": "mtn_details", - "incoming_rate": 5000, - "qty": 1, - "stock_uom": "_Test UOM", - "transfer_qty": 1, - "uom": "_Test UOM", - "t_warehouse": "_Test Warehouse - _TC", - "expense_account": "Stock Adjustment - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - ], -] +test_records = frappe.get_test_records('Stock Entry') diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json new file mode 100644 index 00000000000..0bdc9a8e5e0 --- /dev/null +++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json @@ -0,0 +1,308 @@ +{ + "autoname": "MTND/.######", + "creation": "2013-03-29 18:22:12.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "s_warehouse", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Source Warehouse", + "no_copy": 1, + "oldfieldname": "s_warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "t_warehouse", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Target Warehouse", + "no_copy": 1, + "oldfieldname": "t_warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "sec_break1", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "label": "Item Name", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Text", + "permlevel": 0, + "print_width": "300px", + "read_only": 0, + "width": "300px" + }, + { + "fieldname": "quantity_and_rate", + "fieldtype": "Section Break", + "label": "Quantity and Rate", + "permlevel": 0 + }, + { + "fieldname": "qty", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Qty", + "oldfieldname": "qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "uom", + "fieldtype": "Link", + "in_list_view": 0, + "label": "UOM", + "oldfieldname": "uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "incoming_rate", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Valuation Rate", + "oldfieldname": "incoming_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "in_filter": 0, + "label": "Stock UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "conversion_factor", + "fieldtype": "Float", + "label": "Conversion Factor", + "oldfieldname": "conversion_factor", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "label": "Amount", + "oldfieldname": "amount", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "serial_no_batch", + "fieldtype": "Section Break", + "label": "Serial No / Batch", + "permlevel": 0 + }, + { + "fieldname": "serial_no", + "fieldtype": "Text", + "label": "Serial No", + "no_copy": 1, + "oldfieldname": "serial_no", + "oldfieldtype": "Text", + "permlevel": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "batch_no", + "fieldtype": "Link", + "label": "Batch No", + "oldfieldname": "batch_no", + "oldfieldtype": "Link", + "options": "Batch", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "accounting", + "fieldtype": "Section Break", + "label": "Accounting", + "permlevel": 0 + }, + { + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", + "fieldname": "expense_account", + "fieldtype": "Link", + "label": "Difference Account", + "options": "Account", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "col_break5", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": ":Company", + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", + "fieldname": "cost_center", + "fieldtype": "Link", + "hidden": 0, + "label": "Cost Center", + "options": "Cost Center", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "permlevel": 0 + }, + { + "fieldname": "actual_qty", + "fieldtype": "Float", + "in_filter": 1, + "label": "Actual Qty (at source/target)", + "no_copy": 1, + "oldfieldname": "actual_qty", + "oldfieldtype": "Read Only", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 0, + "search_index": 1 + }, + { + "description": "BOM No. for a Finished Good Item", + "fieldname": "bom_no", + "fieldtype": "Link", + "hidden": 1, + "label": "BOM No", + "no_copy": 0, + "options": "BOM", + "permlevel": 0, + "print_hide": 1, + "read_only": 0 + }, + { + "fieldname": "col_break6", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "transfer_qty", + "fieldtype": "Float", + "label": "Qty as per Stock UOM", + "oldfieldname": "transfer_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "reqd": 1 + }, + { + "description": "Material Request used to make this Stock Entry", + "fieldname": "material_request", + "fieldtype": "Link", + "hidden": 1, + "label": "Material Request", + "no_copy": 1, + "options": "Material Request", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "material_request_item", + "fieldtype": "Link", + "hidden": 1, + "label": "Material Request Item", + "no_copy": 1, + "options": "Material Request Item", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "idx": 1, + "istable": 1, + "modified": "2014-02-03 12:59:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Stock Entry Detail", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py index 26c87f1c04a..2570b680183 100644 --- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py +++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class StockEntryDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.txt b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.txt deleted file mode 100644 index 3bc16955bcf..00000000000 --- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.txt +++ /dev/null @@ -1,321 +0,0 @@ -[ - { - "creation": "2013-03-29 18:22:12", - "docstatus": 0, - "modified": "2014-02-03 12:59:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "MTND/.######", - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Stock Entry Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Stock Entry Detail" - }, - { - "doctype": "DocField", - "fieldname": "s_warehouse", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Source Warehouse", - "no_copy": 1, - "oldfieldname": "s_warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "t_warehouse", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Target Warehouse", - "no_copy": 1, - "oldfieldname": "t_warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "sec_break1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "label": "Item Name", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break2", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Text", - "print_width": "300px", - "read_only": 0, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "quantity_and_rate", - "fieldtype": "Section Break", - "label": "Quantity and Rate" - }, - { - "doctype": "DocField", - "fieldname": "qty", - "fieldtype": "Float", - "in_list_view": 1, - "label": "Qty", - "oldfieldname": "qty", - "oldfieldtype": "Currency", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "uom", - "fieldtype": "Link", - "in_list_view": 0, - "label": "UOM", - "oldfieldname": "uom", - "oldfieldtype": "Link", - "options": "UOM", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "incoming_rate", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Valuation Rate", - "oldfieldname": "incoming_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "in_filter": 0, - "label": "Stock UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Link", - "options": "UOM", - "print_hide": 1, - "read_only": 1, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "conversion_factor", - "fieldtype": "Float", - "label": "Conversion Factor", - "oldfieldname": "conversion_factor", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amount", - "fieldtype": "Currency", - "label": "Amount", - "oldfieldname": "amount", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "serial_no_batch", - "fieldtype": "Section Break", - "label": "Serial No / Batch" - }, - { - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Text", - "label": "Serial No", - "no_copy": 1, - "oldfieldname": "serial_no", - "oldfieldtype": "Text", - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break4", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "batch_no", - "fieldtype": "Link", - "label": "Batch No", - "oldfieldname": "batch_no", - "oldfieldtype": "Link", - "options": "Batch", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "accounting", - "fieldtype": "Section Break", - "label": "Accounting" - }, - { - "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", - "doctype": "DocField", - "fieldname": "expense_account", - "fieldtype": "Link", - "label": "Difference Account", - "options": "Account", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break5", - "fieldtype": "Column Break" - }, - { - "default": ":Company", - "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "hidden": 0, - "label": "Cost Center", - "options": "Cost Center", - "print_hide": 1, - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info" - }, - { - "doctype": "DocField", - "fieldname": "actual_qty", - "fieldtype": "Float", - "in_filter": 1, - "label": "Actual Qty (at source/target)", - "no_copy": 1, - "oldfieldname": "actual_qty", - "oldfieldtype": "Read Only", - "print_hide": 1, - "read_only": 1, - "reqd": 0, - "search_index": 1 - }, - { - "description": "BOM No. for a Finished Good Item", - "doctype": "DocField", - "fieldname": "bom_no", - "fieldtype": "Link", - "hidden": 1, - "label": "BOM No", - "no_copy": 0, - "options": "BOM", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break6", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "transfer_qty", - "fieldtype": "Float", - "label": "Qty as per Stock UOM", - "oldfieldname": "transfer_qty", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1, - "reqd": 1 - }, - { - "description": "Material Request used to make this Stock Entry", - "doctype": "DocField", - "fieldname": "material_request", - "fieldtype": "Link", - "hidden": 1, - "label": "Material Request", - "no_copy": 1, - "options": "Material Request", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "material_request_item", - "fieldtype": "Link", - "hidden": 1, - "label": "Material Request Item", - "no_copy": 1, - "options": "Material Request Item", - "print_hide": 1, - "read_only": 1 - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_ledger/stock_ledger.py b/erpnext/stock/doctype/stock_ledger/stock_ledger.py index 664eadbd814..fca9cb0b707 100644 --- a/erpnext/stock/doctype/stock_ledger/stock_ledger.py +++ b/erpnext/stock/doctype/stock_ledger/stock_ledger.py @@ -5,17 +5,14 @@ from __future__ import unicode_literals import frappe from frappe.utils import add_days, cstr, flt, nowdate, cint, now -from frappe.model.doc import Document -from frappe.model.bean import getlist -from frappe.model.code import get_obj + from frappe import session, msgprint from erpnext.stock.utils import get_valid_serial_nos -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class StockLedger(Document): def update_stock(self, values, is_amended = 'No'): for v in values: @@ -39,19 +36,19 @@ class DocType: "is_amended": is_amended }) - get_obj('Warehouse', v["warehouse"]).update_bin(args) + frappe.get_doc('Warehouse', v["warehouse"]).update_bin(args) def make_entry(self, args): args.update({"doctype": "Stock Ledger Entry"}) - sle = frappe.bean([args]) + sle = frappe.get_doc(args) sle.ignore_permissions = 1 sle.insert() - return sle.doc.name + return sle.name def repost(self): """ Repost everything! """ for wh in frappe.db.sql("select name from tabWarehouse"): - get_obj('Warehouse', wh[0]).repost_stock() + frappe.get_doc('Warehouse', wh[0]).repost_stock() diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json new file mode 100644 index 00000000000..2f7628fc48e --- /dev/null +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json @@ -0,0 +1,287 @@ +{ + "allow_copy": 1, + "allow_email": 1, + "allow_print": 1, + "autoname": "SLE/.########", + "creation": "2013-01-29 19:25:42.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Other", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "search_index": 1, + "width": "100px" + }, + { + "fieldname": "serial_no", + "fieldtype": "Text", + "in_filter": 0, + "label": "Serial No", + "permlevel": 0, + "print_width": "100px", + "read_only": 1, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "batch_no", + "fieldtype": "Data", + "label": "Batch No", + "oldfieldname": "batch_no", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "warehouse", + "fieldtype": "Link", + "in_filter": 1, + "label": "Warehouse", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", + "permlevel": 0, + "print_width": "100px", + "read_only": 1, + "search_index": 1, + "width": "100px" + }, + { + "fieldname": "posting_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Posting Date", + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_width": "100px", + "read_only": 1, + "reqd": 0, + "search_index": 1, + "width": "100px" + }, + { + "fieldname": "posting_time", + "fieldtype": "Time", + "in_filter": 0, + "label": "Posting Time", + "oldfieldname": "posting_time", + "oldfieldtype": "Time", + "permlevel": 0, + "print_width": "100px", + "read_only": 1, + "search_index": 0, + "width": "100px" + }, + { + "fieldname": "voucher_type", + "fieldtype": "Data", + "in_filter": 1, + "label": "Voucher Type", + "oldfieldname": "voucher_type", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "search_index": 0, + "width": "150px" + }, + { + "fieldname": "voucher_no", + "fieldtype": "Data", + "in_filter": 1, + "label": "Voucher No", + "oldfieldname": "voucher_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "search_index": 0, + "width": "150px" + }, + { + "fieldname": "voucher_detail_no", + "fieldtype": "Data", + "label": "Voucher Detail No", + "oldfieldname": "voucher_detail_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "actual_qty", + "fieldtype": "Float", + "in_filter": 1, + "label": "Actual Quantity", + "oldfieldname": "actual_qty", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "incoming_rate", + "fieldtype": "Currency", + "label": "Incoming Rate", + "oldfieldname": "incoming_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "label": "Stock UOM", + "oldfieldname": "stock_uom", + "oldfieldtype": "Data", + "options": "UOM", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "qty_after_transaction", + "fieldtype": "Float", + "in_filter": 1, + "label": "Actual Qty After Transaction", + "oldfieldname": "bin_aqat", + "oldfieldtype": "Currency", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "valuation_rate", + "fieldtype": "Currency", + "label": "Valuation Rate", + "oldfieldname": "valuation_rate", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "stock_value", + "fieldtype": "Currency", + "label": "Stock Value", + "oldfieldname": "stock_value", + "oldfieldtype": "Currency", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "stock_value_difference", + "fieldtype": "Currency", + "label": "Stock Value Difference", + "options": "Company:company:default_currency", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "stock_queue", + "fieldtype": "Text", + "hidden": 1, + "in_filter": 0, + "label": "Stock Queue (FIFO)", + "oldfieldname": "fcfs_stack", + "oldfieldtype": "Text", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "report_hide": 1, + "search_index": 0 + }, + { + "fieldname": "project", + "fieldtype": "Link", + "label": "Project", + "options": "Project", + "permlevel": 0 + }, + { + "fieldname": "company", + "fieldtype": "Select", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Data", + "options": "link:Company", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "search_index": 0, + "width": "150px" + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Data", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "150px", + "read_only": 1, + "search_index": 0, + "width": "150px" + }, + { + "fieldname": "is_cancelled", + "fieldtype": "Select", + "hidden": 1, + "label": "Is Cancelled", + "options": "\nNo\nYes", + "permlevel": 0, + "report_hide": 1 + } + ], + "hide_toolbar": 1, + "icon": "icon-list", + "idx": 1, + "in_create": 1, + "modified": "2013-11-03 14:11:43.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Stock Ledger Entry", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 0, + "permlevel": 0, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, + "write": 0 + }, + { + "permlevel": 0, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0 + } + ] +} \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 9bb991175ab..17d683f9883 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -11,104 +11,101 @@ from datetime import date class StockFreezeError(frappe.ValidationError): pass -class DocType(DocListController): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class StockLedgerEntry(DocListController): def validate(self): from erpnext.stock.utils import validate_warehouse_company self.validate_mandatory() self.validate_item() - validate_warehouse_company(self.doc.warehouse, self.doc.company) + validate_warehouse_company(self.warehouse, self.company) self.scrub_posting_time() - + from erpnext.accounts.utils import validate_fiscal_year - validate_fiscal_year(self.doc.posting_date, self.doc.fiscal_year, + validate_fiscal_year(self.posting_date, self.fiscal_year, self.meta.get_label("posting_date")) def on_submit(self): self.check_stock_frozen_date() self.actual_amt_check() - + from erpnext.stock.doctype.serial_no.serial_no import process_serial_no - process_serial_no(self.doc) + process_serial_no(self) #check for item quantity available in stock def actual_amt_check(self): - if self.doc.batch_no: + if self.batch_no: batch_bal_after_transaction = flt(frappe.db.sql("""select sum(actual_qty) from `tabStock Ledger Entry` where warehouse=%s and item_code=%s and batch_no=%s""", - (self.doc.warehouse, self.doc.item_code, self.doc.batch_no))[0][0]) + (self.warehouse, self.item_code, self.batch_no))[0][0]) if batch_bal_after_transaction < 0: - self.doc.fields.update({ - 'batch_bal': batch_bal_after_transaction - self.doc.actual_qty + self.update({ + 'batch_bal': batch_bal_after_transaction - self.actual_qty }) frappe.throw("""Not enough quantity (requested: %(actual_qty)s, \ current: %(batch_bal)s in Batch %(batch_no)s for Item \ %(item_code)s at Warehouse %(warehouse)s \ - as on %(posting_date)s %(posting_time)s""" % self.doc.fields) + as on %(posting_date)s %(posting_time)s""" % self.as_dict()) - self.doc.fields.pop('batch_bal') + self.pop('batch_bal') def validate_mandatory(self): mandatory = ['warehouse','posting_date','voucher_type','voucher_no','actual_qty','company'] for k in mandatory: - if not self.doc.fields.get(k): + if not self.get(k): msgprint("Stock Ledger Entry: '%s' is mandatory" % k, raise_exception = 1) elif k == 'warehouse': - if not frappe.db.exists("Warehouse", self.doc.fields.get(k)): - msgprint("Warehouse: '%s' does not exist in the system. Please check." % - self.doc.fields.get(k), raise_exception = 1) + if not frappe.db.exists("Warehouse", self.get(k)): + msgprint("Warehouse: '%s' does not exist in the system. Please check." % + self.get(k), raise_exception = 1) def validate_item(self): item_det = frappe.db.sql("""select name, has_batch_no, docstatus, is_stock_item, has_serial_no, serial_no_series from tabItem where name=%s""", - self.doc.item_code, as_dict=True)[0] + self.item_code, as_dict=True)[0] if item_det.is_stock_item != 'Yes': - frappe.throw("""Item: "%s" is not a Stock Item.""" % self.doc.item_code) + frappe.throw("""Item: "%s" is not a Stock Item.""" % self.item_code) # check if batch number is required - if item_det.has_batch_no =='Yes' and self.doc.voucher_type != 'Stock Reconciliation': - if not self.doc.batch_no: - frappe.throw("Batch number is mandatory for Item '%s'" % self.doc.item_code) + if item_det.has_batch_no =='Yes' and self.voucher_type != 'Stock Reconciliation': + if not self.batch_no: + frappe.throw("Batch number is mandatory for Item '%s'" % self.item_code) # check if batch belongs to item - if not frappe.db.get_value("Batch", - {"item": self.doc.item_code, "name": self.doc.batch_no}): - frappe.throw("'%s' is not a valid Batch Number for Item '%s'" % - (self.doc.batch_no, self.doc.item_code)) + if not frappe.db.get_value("Batch", + {"item": self.item_code, "name": self.batch_no}): + frappe.throw("'%s' is not a valid Batch Number for Item '%s'" % + (self.batch_no, self.item_code)) - if not self.doc.stock_uom: - self.doc.stock_uom = item_det.stock_uom + if not self.stock_uom: + self.stock_uom = item_det.stock_uom def check_stock_frozen_date(self): stock_frozen_upto = frappe.db.get_value('Stock Settings', None, 'stock_frozen_upto') or '' if stock_frozen_upto: stock_auth_role = frappe.db.get_value('Stock Settings', None,'stock_auth_role') - if getdate(self.doc.posting_date) <= getdate(stock_frozen_upto) and not stock_auth_role in frappe.user.get_roles(): + if getdate(self.posting_date) <= getdate(stock_frozen_upto) and not stock_auth_role in frappe.user.get_roles(): msgprint("You are not authorized to do / modify back dated stock entries before %s" % getdate(stock_frozen_upto).strftime('%d-%m-%Y'), raise_exception=StockFreezeError) stock_frozen_upto_days = int(frappe.db.get_value('Stock Settings', None, 'stock_frozen_upto_days') or 0) if stock_frozen_upto_days: stock_auth_role = frappe.db.get_value('Stock Settings', None,'stock_auth_role') - older_than_x_days_ago = (add_days(getdate(self.doc.posting_date), stock_frozen_upto_days) <= date.today()) + older_than_x_days_ago = (add_days(getdate(self.posting_date), stock_frozen_upto_days) <= date.today()) if older_than_x_days_ago and not stock_auth_role in frappe.user.get_roles(): msgprint("You are not authorized to do / modify back dated stock entries older than %d days ago" %stock_frozen_upto_days, raise_exception=StockFreezeError) def scrub_posting_time(self): - if not self.doc.posting_time or self.doc.posting_time == '00:0': - self.doc.posting_time = '00:00' + if not self.posting_time or self.posting_time == '00:0': + self.posting_time = '00:00' def on_doctype_update(): if not frappe.db.sql("""show index from `tabStock Ledger Entry` where Key_name="posting_sort_index" """): frappe.db.commit() frappe.db.sql("""alter table `tabStock Ledger Entry` - add index posting_sort_index(posting_date, posting_time, name)""") \ No newline at end of file + add index posting_sort_index(posting_date, posting_time, name)""") diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt deleted file mode 100644 index 641a68c3bcd..00000000000 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt +++ /dev/null @@ -1,303 +0,0 @@ -[ - { - "creation": "2013-01-29 19:25:42", - "docstatus": 0, - "modified": "2013-11-03 14:11:43", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_copy": 1, - "allow_email": 1, - "allow_print": 1, - "autoname": "SLE/.########", - "doctype": "DocType", - "document_type": "Other", - "hide_toolbar": 1, - "icon": "icon-list", - "in_create": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Stock Ledger Entry", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "Stock Ledger Entry", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Stock Ledger Entry" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "search_index": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Text", - "in_filter": 0, - "label": "Serial No", - "print_width": "100px", - "read_only": 1, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "batch_no", - "fieldtype": "Data", - "label": "Batch No", - "oldfieldname": "batch_no", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "warehouse", - "fieldtype": "Link", - "in_filter": 1, - "label": "Warehouse", - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", - "print_width": "100px", - "read_only": 1, - "search_index": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Posting Date", - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "print_width": "100px", - "read_only": 1, - "reqd": 0, - "search_index": 1, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "posting_time", - "fieldtype": "Time", - "in_filter": 0, - "label": "Posting Time", - "oldfieldname": "posting_time", - "oldfieldtype": "Time", - "print_width": "100px", - "read_only": 1, - "search_index": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "voucher_type", - "fieldtype": "Data", - "in_filter": 1, - "label": "Voucher Type", - "oldfieldname": "voucher_type", - "oldfieldtype": "Data", - "print_width": "150px", - "read_only": 1, - "search_index": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "voucher_no", - "fieldtype": "Data", - "in_filter": 1, - "label": "Voucher No", - "oldfieldname": "voucher_no", - "oldfieldtype": "Data", - "print_width": "150px", - "read_only": 1, - "search_index": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "voucher_detail_no", - "fieldtype": "Data", - "label": "Voucher Detail No", - "oldfieldname": "voucher_detail_no", - "oldfieldtype": "Data", - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "actual_qty", - "fieldtype": "Float", - "in_filter": 1, - "label": "Actual Quantity", - "oldfieldname": "actual_qty", - "oldfieldtype": "Currency", - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "incoming_rate", - "fieldtype": "Currency", - "label": "Incoming Rate", - "oldfieldname": "incoming_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "label": "Stock UOM", - "oldfieldname": "stock_uom", - "oldfieldtype": "Data", - "options": "UOM", - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "qty_after_transaction", - "fieldtype": "Float", - "in_filter": 1, - "label": "Actual Qty After Transaction", - "oldfieldname": "bin_aqat", - "oldfieldtype": "Currency", - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "valuation_rate", - "fieldtype": "Currency", - "label": "Valuation Rate", - "oldfieldname": "valuation_rate", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "print_width": "150px", - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "stock_value", - "fieldtype": "Currency", - "label": "Stock Value", - "oldfieldname": "stock_value", - "oldfieldtype": "Currency", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "stock_value_difference", - "fieldtype": "Currency", - "label": "Stock Value Difference", - "options": "Company:company:default_currency", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "stock_queue", - "fieldtype": "Text", - "hidden": 1, - "in_filter": 0, - "label": "Stock Queue (FIFO)", - "oldfieldname": "fcfs_stack", - "oldfieldtype": "Text", - "print_hide": 1, - "read_only": 1, - "report_hide": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "project", - "fieldtype": "Link", - "label": "Project", - "options": "Project" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Data", - "options": "link:Company", - "print_width": "150px", - "read_only": 1, - "search_index": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Data", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Data", - "print_width": "150px", - "read_only": 1, - "search_index": 0, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "is_cancelled", - "fieldtype": "Select", - "hidden": 1, - "label": "Is Cancelled", - "options": "\nNo\nYes", - "report_hide": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "role": "Material User", - "write": 0 - }, - { - "doctype": "DocPerm", - "role": "Accounts Manager" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json new file mode 100644 index 00000000000..772830f2b94 --- /dev/null +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json @@ -0,0 +1,143 @@ +{ + "allow_attach": 0, + "allow_copy": 1, + "autoname": "SR/.######", + "creation": "2013-03-28 10:35:31.000000", + "description": "This tool helps you to update or fix the quantity and valuation of stock in the system. It is typically used to synchronise the system values and what actually exists in your warehouses.", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "posting_date", + "fieldtype": "Date", + "in_filter": 0, + "in_list_view": 1, + "label": "Posting Date", + "oldfieldname": "reconciliation_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "posting_time", + "fieldtype": "Time", + "in_filter": 0, + "in_list_view": 1, + "label": "Posting Time", + "oldfieldname": "reconciliation_time", + "oldfieldtype": "Time", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Link", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "options": "Stock Reconciliation", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "label": "Fiscal Year", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "reqd": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0, + "reqd": 1 + }, + { + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", + "fieldname": "expense_account", + "fieldtype": "Link", + "label": "Difference Account", + "options": "Account", + "permlevel": 0 + }, + { + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", + "fieldname": "cost_center", + "fieldtype": "Link", + "label": "Cost Center", + "options": "Cost Center", + "permlevel": 0 + }, + { + "fieldname": "col1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "upload_html", + "fieldtype": "HTML", + "label": "Upload HTML", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "depends_on": "reconciliation_json", + "fieldname": "sb2", + "fieldtype": "Section Break", + "label": "Reconciliation Data", + "permlevel": 0 + }, + { + "fieldname": "reconciliation_html", + "fieldtype": "HTML", + "hidden": 0, + "label": "Reconciliation HTML", + "permlevel": 0, + "print_hide": 0, + "read_only": 1 + }, + { + "fieldname": "reconciliation_json", + "fieldtype": "Long Text", + "hidden": 1, + "label": "Reconciliation JSON", + "no_copy": 1, + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + } + ], + "icon": "icon-upload-alt", + "idx": 1, + "is_submittable": 1, + "max_attachments": 1, + "modified": "2014-01-20 17:49:28.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Stock Reconciliation", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 1, + "create": 1, + "delete": 1, + "permlevel": 0, + "read": 1, + "report": 1, + "role": "Material Manager", + "submit": 1, + "write": 1 + } + ], + "read_only_onload": 0, + "search_fields": "posting_date" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 7eef0a43e7b..1cc9c178c8a 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -10,7 +10,7 @@ from frappe.utils import cstr, flt, cint from erpnext.stock.stock_ledger import update_entries_after from erpnext.controllers.stock_controller import StockController -class DocType(StockController): +class StockReconciliation(StockController): def setup(self): self.head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"] self.entries = [] @@ -28,10 +28,10 @@ class DocType(StockController): self.make_cancel_gl_entries() def validate_data(self): - if not self.doc.reconciliation_json: + if not self.reconciliation_json: return - data = json.loads(self.doc.reconciliation_json) + data = json.loads(self.reconciliation_json) # strip out extra columns (if any) data = [row[:4] for row in data] @@ -45,7 +45,7 @@ class DocType(StockController): if data.index(self.head_row) != 0: head_row_no = data.index(self.head_row) data = data[head_row_no:] - self.doc.reconciliation_json = json.dumps(data) + self.reconciliation_json = json.dumps(data) def _get_msg(row_num, msg): return _("Row # ") + ("%d: " % (row_num+head_row_no+2)) + _(msg) @@ -97,7 +97,7 @@ class DocType(StockController): # using try except to catch all validation msgs and display together try: - item = frappe.doc("Item", item_code) + item = frappe.get_doc("Item", item_code) # end of life and stock item validate_end_of_life(item_code, item.end_of_life, verbose=0) @@ -124,18 +124,18 @@ class DocType(StockController): row_template = ["item_code", "warehouse", "qty", "valuation_rate"] - if not self.doc.reconciliation_json: + if not self.reconciliation_json: msgprint(_("""Stock Reconciliation file not uploaded"""), raise_exception=1) - data = json.loads(self.doc.reconciliation_json) + data = json.loads(self.reconciliation_json) for row_num, row in enumerate(data[data.index(self.head_row)+1:]): row = frappe._dict(zip(row_template, row)) row["row_num"] = row_num previous_sle = get_previous_sle({ "item_code": row.item_code, "warehouse": row.warehouse, - "posting_date": self.doc.posting_date, - "posting_time": self.doc.posting_time + "posting_date": self.posting_date, + "posting_time": self.posting_time }) # check valuation rate mandatory @@ -238,14 +238,14 @@ class DocType(StockController): "doctype": "Stock Ledger Entry", "item_code": row.item_code, "warehouse": row.warehouse, - "posting_date": self.doc.posting_date, - "posting_time": self.doc.posting_time, - "voucher_type": self.doc.doctype, - "voucher_no": self.doc.name, - "company": self.doc.company, + "posting_date": self.posting_date, + "posting_time": self.posting_time, + "voucher_type": self.doctype, + "voucher_no": self.name, + "company": self.company, "stock_uom": frappe.db.get_value("Item", row.item_code, "stock_uom"), "voucher_detail_no": row.voucher_detail_no, - "fiscal_year": self.doc.fiscal_year, + "fiscal_year": self.fiscal_year, "is_cancelled": "No" }) args.update(opts) @@ -260,37 +260,36 @@ class DocType(StockController): existing_entries = frappe.db.sql("""select distinct item_code, warehouse from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""", - (self.doc.doctype, self.doc.name), as_dict=1) + (self.doctype, self.name), as_dict=1) # delete entries frappe.db.sql("""delete from `tabStock Ledger Entry` - where voucher_type=%s and voucher_no=%s""", (self.doc.doctype, self.doc.name)) + where voucher_type=%s and voucher_no=%s""", (self.doctype, self.name)) # repost future entries for selected item_code, warehouse for entries in existing_entries: update_entries_after({ "item_code": entries.item_code, "warehouse": entries.warehouse, - "posting_date": self.doc.posting_date, - "posting_time": self.doc.posting_time + "posting_date": self.posting_date, + "posting_time": self.posting_time }) def get_gl_entries(self, warehouse_account=None): - if not self.doc.cost_center: + if not self.cost_center: msgprint(_("Please enter Cost Center"), raise_exception=1) - return super(DocType, self).get_gl_entries(warehouse_account, - self.doc.expense_account, self.doc.cost_center) + return super(StockReconciliation, self).get_gl_entries(warehouse_account, + self.expense_account, self.cost_center) - def validate_expense_account(self): if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): return - if not self.doc.expense_account: + if not self.expense_account: msgprint(_("Please enter Expense Account"), raise_exception=1) elif not frappe.db.sql("""select * from `tabStock Ledger Entry`"""): - if frappe.db.get_value("Account", self.doc.expense_account, + if frappe.db.get_value("Account", self.expense_account, "report_type") == "Profit and Loss": msgprint(_("""Expense Account can not be a PL Account, as this stock \ reconciliation is an opening entry. \ diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.txt b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.txt deleted file mode 100644 index 90f5bc8e698..00000000000 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.txt +++ /dev/null @@ -1,162 +0,0 @@ -[ - { - "creation": "2013-03-28 10:35:31", - "docstatus": 0, - "modified": "2014-01-20 17:49:28", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 0, - "allow_copy": 1, - "autoname": "SR/.######", - "description": "This tool helps you to update or fix the quantity and valuation of stock in the system. It is typically used to synchronise the system values and what actually exists in your warehouses.", - "doctype": "DocType", - "icon": "icon-upload-alt", - "is_submittable": 1, - "max_attachments": 1, - "module": "Stock", - "name": "__common__", - "read_only_onload": 0, - "search_fields": "posting_date" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Stock Reconciliation", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Stock Reconciliation", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 1, - "role": "Material Manager", - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Stock Reconciliation" - }, - { - "doctype": "DocField", - "fieldname": "posting_date", - "fieldtype": "Date", - "in_filter": 0, - "in_list_view": 1, - "label": "Posting Date", - "oldfieldname": "reconciliation_date", - "oldfieldtype": "Date", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "posting_time", - "fieldtype": "Time", - "in_filter": 0, - "in_list_view": 1, - "label": "Posting Time", - "oldfieldname": "reconciliation_time", - "oldfieldtype": "Time", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Link", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "options": "Stock Reconciliation", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "label": "Fiscal Year", - "options": "link:Fiscal Year", - "print_hide": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company", - "reqd": 1 - }, - { - "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", - "doctype": "DocField", - "fieldname": "expense_account", - "fieldtype": "Link", - "label": "Difference Account", - "options": "Account" - }, - { - "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "label": "Cost Center", - "options": "Cost Center" - }, - { - "doctype": "DocField", - "fieldname": "col1", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "upload_html", - "fieldtype": "HTML", - "label": "Upload HTML", - "print_hide": 1, - "read_only": 1 - }, - { - "depends_on": "reconciliation_json", - "doctype": "DocField", - "fieldname": "sb2", - "fieldtype": "Section Break", - "label": "Reconciliation Data" - }, - { - "doctype": "DocField", - "fieldname": "reconciliation_html", - "fieldtype": "HTML", - "hidden": 0, - "label": "Reconciliation HTML", - "print_hide": 0, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "reconciliation_json", - "fieldtype": "Long Text", - "hidden": 1, - "label": "Reconciliation JSON", - "no_copy": 1, - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index 558e1f14584..37886ce1a1c 100644 --- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -14,15 +14,15 @@ from erpnext.accounts.utils import get_fiscal_year, get_stock_and_account_differ class TestStockReconciliation(unittest.TestCase): def test_reco_for_fifo(self): frappe.defaults.set_global_default("auto_accounting_for_stock", 0) - # [[qty, valuation_rate, posting_date, + # [[qty, valuation_rate, posting_date, # posting_time, expected_stock_value, bin_qty, bin_valuation]] input_data = [ - [50, 1000, "2012-12-26", "12:00", 50000, 45, 48000], - [5, 1000, "2012-12-26", "12:00", 5000, 0, 0], - [15, 1000, "2012-12-26", "12:00", 15000, 10, 12000], - [25, 900, "2012-12-26", "12:00", 22500, 20, 22500], - [20, 500, "2012-12-26", "12:00", 10000, 15, 18000], - [50, 1000, "2013-01-01", "12:00", 50000, 65, 68000], + [50, 1000, "2012-12-26", "12:00", 50000, 45, 48000], + [5, 1000, "2012-12-26", "12:00", 5000, 0, 0], + [15, 1000, "2012-12-26", "12:00", 15000, 10, 12000], + [25, 900, "2012-12-26", "12:00", 22500, 20, 22500], + [20, 500, "2012-12-26", "12:00", 10000, 15, 18000], + [50, 1000, "2013-01-01", "12:00", 50000, 65, 68000], [5, 1000, "2013-01-01", "12:00", 5000, 20, 23000], ["", 1000, "2012-12-26", "12:05", 15000, 10, 12000], [20, "", "2012-12-26", "12:05", 16000, 15, 18000], @@ -30,142 +30,142 @@ class TestStockReconciliation(unittest.TestCase): [1, 1000, "2012-12-01", "00:00", 1000, 11, 13200], [0, "", "2012-12-26", "12:10", 0, -5, 0] ] - + for d in input_data: self.cleanup_data() self.insert_existing_sle("FIFO") stock_reco = self.submit_stock_reconciliation(d[0], d[1], d[2], d[3]) - + # check stock value res = frappe.db.sql("""select stock_value from `tabStock Ledger Entry` where item_code = '_Test Item' and warehouse = '_Test Warehouse - _TC' - and posting_date = %s and posting_time = %s order by name desc limit 1""", + and posting_date = %s and posting_time = %s order by name desc limit 1""", (d[2], d[3])) self.assertEqual(res and flt(res[0][0]) or 0, d[4]) - + # check bin qty and stock value bin = frappe.db.sql("""select actual_qty, stock_value from `tabBin` where item_code = '_Test Item' and warehouse = '_Test Warehouse - _TC'""") - + self.assertEqual(bin and [flt(bin[0][0]), flt(bin[0][1])] or [], [d[5], d[6]]) - + # no gl entries - gl_entries = frappe.db.sql("""select name from `tabGL Entry` + gl_entries = frappe.db.sql("""select name from `tabGL Entry` where voucher_type = 'Stock Reconciliation' and voucher_no = %s""", - stock_reco.doc.name) + stock_reco.name) self.assertFalse(gl_entries) - - + + def test_reco_for_moving_average(self): frappe.defaults.set_global_default("auto_accounting_for_stock", 0) - # [[qty, valuation_rate, posting_date, + # [[qty, valuation_rate, posting_date, # posting_time, expected_stock_value, bin_qty, bin_valuation]] input_data = [ - [50, 1000, "2012-12-26", "12:00", 50000, 45, 48000], - [5, 1000, "2012-12-26", "12:00", 5000, 0, 0], - [15, 1000, "2012-12-26", "12:00", 15000, 10, 12000], - [25, 900, "2012-12-26", "12:00", 22500, 20, 22500], - [20, 500, "2012-12-26", "12:00", 10000, 15, 18000], - [50, 1000, "2013-01-01", "12:00", 50000, 65, 68000], + [50, 1000, "2012-12-26", "12:00", 50000, 45, 48000], + [5, 1000, "2012-12-26", "12:00", 5000, 0, 0], + [15, 1000, "2012-12-26", "12:00", 15000, 10, 12000], + [25, 900, "2012-12-26", "12:00", 22500, 20, 22500], + [20, 500, "2012-12-26", "12:00", 10000, 15, 18000], + [50, 1000, "2013-01-01", "12:00", 50000, 65, 68000], [5, 1000, "2013-01-01", "12:00", 5000, 20, 23000], ["", 1000, "2012-12-26", "12:05", 15000, 10, 12000], [20, "", "2012-12-26", "12:05", 18000, 15, 18000], [10, 2000, "2012-12-26", "12:10", 20000, 5, 6000], [1, 1000, "2012-12-01", "00:00", 1000, 11, 13200], [0, "", "2012-12-26", "12:10", 0, -5, 0] - + ] - + for d in input_data: self.cleanup_data() self.insert_existing_sle("Moving Average") stock_reco = self.submit_stock_reconciliation(d[0], d[1], d[2], d[3]) - + # check stock value in sle res = frappe.db.sql("""select stock_value from `tabStock Ledger Entry` where item_code = '_Test Item' and warehouse = '_Test Warehouse - _TC' - and posting_date = %s and posting_time = %s order by name desc limit 1""", + and posting_date = %s and posting_time = %s order by name desc limit 1""", (d[2], d[3])) - + self.assertEqual(res and flt(res[0][0], 4) or 0, d[4]) - + # bin qty and stock value bin = frappe.db.sql("""select actual_qty, stock_value from `tabBin` where item_code = '_Test Item' and warehouse = '_Test Warehouse - _TC'""") - - self.assertEqual(bin and [flt(bin[0][0]), flt(bin[0][1], 4)] or [], + + self.assertEqual(bin and [flt(bin[0][0]), flt(bin[0][1], 4)] or [], [flt(d[5]), flt(d[6])]) - + # no gl entries - gl_entries = frappe.db.sql("""select name from `tabGL Entry` - where voucher_type = 'Stock Reconciliation' and voucher_no = %s""", - stock_reco.doc.name) + gl_entries = frappe.db.sql("""select name from `tabGL Entry` + where voucher_type = 'Stock Reconciliation' and voucher_no = %s""", + stock_reco.name) self.assertFalse(gl_entries) - + def test_reco_fifo_gl_entries(self): frappe.defaults.set_global_default("auto_accounting_for_stock", 1) - + # [[qty, valuation_rate, posting_date, posting_time, stock_in_hand_debit]] input_data = [ - [50, 1000, "2012-12-26", "12:00"], - [5, 1000, "2012-12-26", "12:00"], - [15, 1000, "2012-12-26", "12:00"], - [25, 900, "2012-12-26", "12:00"], - [20, 500, "2012-12-26", "12:00"], + [50, 1000, "2012-12-26", "12:00"], + [5, 1000, "2012-12-26", "12:00"], + [15, 1000, "2012-12-26", "12:00"], + [25, 900, "2012-12-26", "12:00"], + [20, 500, "2012-12-26", "12:00"], ["", 1000, "2012-12-26", "12:05"], [20, "", "2012-12-26", "12:05"], [10, 2000, "2012-12-26", "12:10"], [0, "", "2012-12-26", "12:10"], - [50, 1000, "2013-01-01", "12:00"], + [50, 1000, "2013-01-01", "12:00"], [5, 1000, "2013-01-01", "12:00"], [1, 1000, "2012-12-01", "00:00"], ] - + for d in input_data: self.cleanup_data() self.insert_existing_sle("FIFO") self.assertFalse(get_stock_and_account_difference(["_Test Account Stock In Hand - _TC"])) stock_reco = self.submit_stock_reconciliation(d[0], d[1], d[2], d[3]) - - + + self.assertFalse(get_stock_and_account_difference(["_Test Account Stock In Hand - _TC"])) stock_reco.cancel() self.assertFalse(get_stock_and_account_difference(["_Test Account Stock In Hand - _TC"])) - + frappe.defaults.set_global_default("auto_accounting_for_stock", 0) - + def test_reco_moving_average_gl_entries(self): frappe.defaults.set_global_default("auto_accounting_for_stock", 1) - - # [[qty, valuation_rate, posting_date, + + # [[qty, valuation_rate, posting_date, # posting_time, stock_in_hand_debit]] input_data = [ - [50, 1000, "2012-12-26", "12:00", 36500], - [5, 1000, "2012-12-26", "12:00", -8500], - [15, 1000, "2012-12-26", "12:00", 1500], - [25, 900, "2012-12-26", "12:00", 9000], - [20, 500, "2012-12-26", "12:00", -3500], + [50, 1000, "2012-12-26", "12:00", 36500], + [5, 1000, "2012-12-26", "12:00", -8500], + [15, 1000, "2012-12-26", "12:00", 1500], + [25, 900, "2012-12-26", "12:00", 9000], + [20, 500, "2012-12-26", "12:00", -3500], ["", 1000, "2012-12-26", "12:05", 1500], [20, "", "2012-12-26", "12:05", 4500], [10, 2000, "2012-12-26", "12:10", 6500], [0, "", "2012-12-26", "12:10", -13500], - [50, 1000, "2013-01-01", "12:00", 50000], + [50, 1000, "2013-01-01", "12:00", 50000], [5, 1000, "2013-01-01", "12:00", 5000], [1, 1000, "2012-12-01", "00:00", 1000], - + ] - + for d in input_data: self.cleanup_data() self.insert_existing_sle("Moving Average") stock_reco = self.submit_stock_reconciliation(d[0], d[1], d[2], d[3]) self.assertFalse(get_stock_and_account_difference(["_Test Warehouse - _TC"])) - + # cancel stock_reco.cancel() self.assertFalse(get_stock_and_account_difference(["_Test Warehouse - _TC"])) - + frappe.defaults.set_global_default("auto_accounting_for_stock", 0) @@ -173,9 +173,9 @@ class TestStockReconciliation(unittest.TestCase): frappe.db.sql("delete from `tabStock Ledger Entry`") frappe.db.sql("delete from tabBin") frappe.db.sql("delete from `tabGL Entry`") - + def submit_stock_reconciliation(self, qty, rate, posting_date, posting_time): - stock_reco = frappe.bean([{ + stock_reco = frappe.get_doc({ "doctype": "Stock Reconciliation", "posting_date": posting_date, "posting_time": posting_time, @@ -187,87 +187,87 @@ class TestStockReconciliation(unittest.TestCase): ["Item Code", "Warehouse", "Quantity", "Valuation Rate"], ["_Test Item", "_Test Warehouse - _TC", qty, rate] ]), - }]) + }) stock_reco.insert() stock_reco.submit() return stock_reco - + def insert_existing_sle(self, valuation_method): frappe.db.set_value("Item", "_Test Item", "valuation_method", valuation_method) frappe.db.set_default("allow_negative_stock", 1) - - stock_entry = [ - { - "company": "_Test Company", - "doctype": "Stock Entry", - "posting_date": "2012-12-12", - "posting_time": "01:00", - "purpose": "Material Receipt", - "fiscal_year": "_Test Fiscal Year 2012", - }, - { - "conversion_factor": 1.0, - "doctype": "Stock Entry Detail", - "item_code": "_Test Item", - "parentfield": "mtn_details", - "incoming_rate": 1000, - "qty": 20.0, - "stock_uom": "_Test UOM", - "transfer_qty": 20.0, - "uom": "_Test UOM", - "t_warehouse": "_Test Warehouse - _TC", - "expense_account": "Stock Adjustment - _TC", - "cost_center": "_Test Cost Center - _TC" - }, - ] - - pr = frappe.bean(copy=stock_entry) + + stock_entry = { + "company": "_Test Company", + "doctype": "Stock Entry", + "posting_date": "2012-12-12", + "posting_time": "01:00", + "purpose": "Material Receipt", + "fiscal_year": "_Test Fiscal Year 2012", + "mtn_details": [ + { + "conversion_factor": 1.0, + "doctype": "Stock Entry Detail", + "item_code": "_Test Item", + "parentfield": "mtn_details", + "incoming_rate": 1000, + "qty": 20.0, + "stock_uom": "_Test UOM", + "transfer_qty": 20.0, + "uom": "_Test UOM", + "t_warehouse": "_Test Warehouse - _TC", + "expense_account": "Stock Adjustment - _TC", + "cost_center": "_Test Cost Center - _TC" + } + ] + } + + pr = frappe.copy_doc(stock_entry) pr.insert() pr.submit() - - pr1 = frappe.bean(copy=stock_entry) - pr1.doc.posting_date = "2012-12-15" - pr1.doc.posting_time = "02:00" - pr1.doclist[1].qty = 10 - pr1.doclist[1].transfer_qty = 10 - pr1.doclist[1].incoming_rate = 700 + + pr1 = frappe.copy_doc(stock_entry) + pr1.posting_date = "2012-12-15" + pr1.posting_time = "02:00" + pr1.get("mtn_details")[0].qty = 10 + pr1.get("mtn_details")[0].transfer_qty = 10 + pr1.get("mtn_details")[0].incoming_rate = 700 pr1.insert() pr1.submit() - - pr2 = frappe.bean(copy=stock_entry) - pr2.doc.posting_date = "2012-12-25" - pr2.doc.posting_time = "03:00" - pr2.doc.purpose = "Material Issue" - pr2.doclist[1].s_warehouse = "_Test Warehouse - _TC" - pr2.doclist[1].t_warehouse = None - pr2.doclist[1].qty = 15 - pr2.doclist[1].transfer_qty = 15 - pr2.doclist[1].incoming_rate = 0 + + pr2 = frappe.copy_doc(stock_entry) + pr2.posting_date = "2012-12-25" + pr2.posting_time = "03:00" + pr2.purpose = "Material Issue" + pr2.get("mtn_details")[0].s_warehouse = "_Test Warehouse - _TC" + pr2.get("mtn_details")[0].t_warehouse = None + pr2.get("mtn_details")[0].qty = 15 + pr2.get("mtn_details")[0].transfer_qty = 15 + pr2.get("mtn_details")[0].incoming_rate = 0 pr2.insert() pr2.submit() - - pr3 = frappe.bean(copy=stock_entry) - pr3.doc.posting_date = "2012-12-31" - pr3.doc.posting_time = "08:00" - pr3.doc.purpose = "Material Issue" - pr3.doclist[1].s_warehouse = "_Test Warehouse - _TC" - pr3.doclist[1].t_warehouse = None - pr3.doclist[1].qty = 20 - pr3.doclist[1].transfer_qty = 20 - pr3.doclist[1].incoming_rate = 0 + + pr3 = frappe.copy_doc(stock_entry) + pr3.posting_date = "2012-12-31" + pr3.posting_time = "08:00" + pr3.purpose = "Material Issue" + pr3.get("mtn_details")[0].s_warehouse = "_Test Warehouse - _TC" + pr3.get("mtn_details")[0].t_warehouse = None + pr3.get("mtn_details")[0].qty = 20 + pr3.get("mtn_details")[0].transfer_qty = 20 + pr3.get("mtn_details")[0].incoming_rate = 0 pr3.insert() pr3.submit() - - - pr4 = frappe.bean(copy=stock_entry) - pr4.doc.posting_date = "2013-01-05" - pr4.doc.fiscal_year = "_Test Fiscal Year 2013" - pr4.doc.posting_time = "07:00" - pr4.doclist[1].qty = 15 - pr4.doclist[1].transfer_qty = 15 - pr4.doclist[1].incoming_rate = 1200 + + + pr4 = frappe.copy_doc(stock_entry) + pr4.posting_date = "2013-01-05" + pr4.fiscal_year = "_Test Fiscal Year 2013" + pr4.posting_time = "07:00" + pr4.get("mtn_details")[0].qty = 15 + pr4.get("mtn_details")[0].transfer_qty = 15 + pr4.get("mtn_details")[0].incoming_rate = 1200 pr4.insert() pr4.submit() - - -test_dependencies = ["Item", "Warehouse"] \ No newline at end of file + + +test_dependencies = ["Item", "Warehouse"] diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.json b/erpnext/stock/doctype/stock_settings/stock_settings.json new file mode 100644 index 00000000000..2879c4b1021 --- /dev/null +++ b/erpnext/stock/doctype/stock_settings/stock_settings.json @@ -0,0 +1,118 @@ +{ + "creation": "2013-06-24 16:37:54.000000", + "description": "Settings", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "default": "Item Code", + "fieldname": "item_naming_by", + "fieldtype": "Select", + "label": "Item Naming By", + "options": "Item Code\nNaming Series", + "permlevel": 0 + }, + { + "description": "Add / Edit", + "fieldname": "item_group", + "fieldtype": "Link", + "label": "Default Item Group", + "options": "Item Group", + "permlevel": 0 + }, + { + "fieldname": "stock_uom", + "fieldtype": "Link", + "label": "Default Stock UOM", + "options": "UOM", + "permlevel": 0 + }, + { + "fieldname": "column_break_4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "allow_negative_stock", + "fieldtype": "Check", + "label": "Allow Negative Stock", + "permlevel": 0 + }, + { + "fieldname": "valuation_method", + "fieldtype": "Select", + "label": "Default Valuation Method", + "options": "FIFO\nMoving Average", + "permlevel": 0 + }, + { + "description": "Percentage you are allowed to receive or deliver more against the quantity ordered. For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units.", + "fieldname": "tolerance", + "fieldtype": "Float", + "label": "Allowance Percent", + "permlevel": 0 + }, + { + "fieldname": "auto_material_request", + "fieldtype": "Section Break", + "label": "Auto Material Request", + "permlevel": 0 + }, + { + "fieldname": "auto_indent", + "fieldtype": "Check", + "label": "Raise Material Request when stock reaches re-order level", + "permlevel": 0 + }, + { + "fieldname": "reorder_email_notify", + "fieldtype": "Check", + "label": "Notify by Email on creation of automatic Material Request", + "permlevel": 0 + }, + { + "fieldname": "freeze_stock_entries", + "fieldtype": "Section Break", + "label": "Freeze Stock Entries", + "permlevel": 0 + }, + { + "fieldname": "stock_frozen_upto", + "fieldtype": "Date", + "label": "Stock Frozen Upto", + "permlevel": 0 + }, + { + "fieldname": "stock_frozen_upto_days", + "fieldtype": "Int", + "label": "Freeze Stocks Older Than [Days]", + "permlevel": 0 + }, + { + "fieldname": "stock_auth_role", + "fieldtype": "Link", + "label": "Role Allowed to edit frozen stock", + "options": "Role", + "permlevel": 0 + } + ], + "icon": "icon-cog", + "idx": 1, + "issingle": 1, + "modified": "2014-02-19 19:02:23.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Stock Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "role": "Material Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.py b/erpnext/stock/doctype/stock_settings/stock_settings.py index 7f03bb1b1e1..b505394f1b3 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.py +++ b/erpnext/stock/doctype/stock_settings/stock_settings.py @@ -7,21 +7,21 @@ from __future__ import unicode_literals import frappe from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class StockSettings(Document): def validate(self): for key in ["item_naming_by", "item_group", "stock_uom", "allow_negative_stock"]: - frappe.db.set_default(key, self.doc.fields.get(key, "")) + frappe.db.set_default(key, self.get(key, "")) from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series set_by_naming_series("Item", "item_code", - self.doc.get("item_naming_by")=="Naming Series", hide_name_field=True) + self.get("item_naming_by")=="Naming Series", hide_name_field=True) stock_frozen_limit = 356 - submitted_stock_frozen = self.doc.stock_frozen_upto_days + submitted_stock_frozen = self.stock_frozen_upto_days if submitted_stock_frozen > stock_frozen_limit: - self.doc.stock_frozen_upto_days = stock_frozen_limit + self.stock_frozen_upto_days = stock_frozen_limit frappe.msgprint (_("`Freeze Stocks Older Than` should be smaller than %d days.") %stock_frozen_limit) diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.txt b/erpnext/stock/doctype/stock_settings/stock_settings.txt deleted file mode 100644 index 556420ceda7..00000000000 --- a/erpnext/stock/doctype/stock_settings/stock_settings.txt +++ /dev/null @@ -1,137 +0,0 @@ -[ - { - "creation": "2013-06-24 16:37:54", - "docstatus": 0, - "modified": "2014-02-19 19:02:23", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Settings", - "doctype": "DocType", - "icon": "icon-cog", - "issingle": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Stock Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Stock Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "role": "Material Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Stock Settings" - }, - { - "default": "Item Code", - "doctype": "DocField", - "fieldname": "item_naming_by", - "fieldtype": "Select", - "label": "Item Naming By", - "options": "Item Code\nNaming Series" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "label": "Default Item Group", - "options": "Item Group" - }, - { - "doctype": "DocField", - "fieldname": "stock_uom", - "fieldtype": "Link", - "label": "Default Stock UOM", - "options": "UOM" - }, - { - "doctype": "DocField", - "fieldname": "column_break_4", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "allow_negative_stock", - "fieldtype": "Check", - "label": "Allow Negative Stock" - }, - { - "doctype": "DocField", - "fieldname": "valuation_method", - "fieldtype": "Select", - "label": "Default Valuation Method", - "options": "FIFO\nMoving Average" - }, - { - "description": "Percentage you are allowed to receive or deliver more against the quantity ordered. For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units.", - "doctype": "DocField", - "fieldname": "tolerance", - "fieldtype": "Float", - "label": "Allowance Percent" - }, - { - "doctype": "DocField", - "fieldname": "auto_material_request", - "fieldtype": "Section Break", - "label": "Auto Material Request" - }, - { - "doctype": "DocField", - "fieldname": "auto_indent", - "fieldtype": "Check", - "label": "Raise Material Request when stock reaches re-order level" - }, - { - "doctype": "DocField", - "fieldname": "reorder_email_notify", - "fieldtype": "Check", - "label": "Notify by Email on creation of automatic Material Request" - }, - { - "doctype": "DocField", - "fieldname": "freeze_stock_entries", - "fieldtype": "Section Break", - "label": "Freeze Stock Entries" - }, - { - "doctype": "DocField", - "fieldname": "stock_frozen_upto", - "fieldtype": "Date", - "label": "Stock Frozen Upto" - }, - { - "doctype": "DocField", - "fieldname": "stock_frozen_upto_days", - "fieldtype": "Int", - "label": "Freeze Stocks Older Than [Days]" - }, - { - "doctype": "DocField", - "fieldname": "stock_auth_role", - "fieldtype": "Link", - "label": "Role Allowed to edit frozen stock", - "options": "Role" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.json b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.json new file mode 100644 index 00000000000..4a0a0ac1b7b --- /dev/null +++ b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.json @@ -0,0 +1,76 @@ +{ + "creation": "2013-01-10 16:34:30.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "label": "Item", + "options": "Item", + "permlevel": 0 + }, + { + "fieldname": "current_stock_uom", + "fieldtype": "Link", + "label": "Current Stock UOM", + "options": "UOM", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "new_stock_uom", + "fieldtype": "Link", + "label": "New Stock UOM", + "options": "UOM", + "permlevel": 0 + }, + { + "fieldname": "conversion_factor", + "fieldtype": "Float", + "label": "Conversion Factor", + "permlevel": 0 + }, + { + "fieldname": "update", + "fieldtype": "Button", + "label": "Update", + "options": "update_stock_uom", + "permlevel": 0 + } + ], + "icon": "icon-magic", + "idx": 1, + "in_create": 0, + "issingle": 1, + "modified": "2013-12-20 19:21:48.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Stock UOM Replace Utility", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "Material Master Manager", + "submit": 0, + "write": 1 + }, + { + "create": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "Material Manager", + "submit": 0, + "write": 1 + } + ], + "read_only": 0 +} \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py index 8ff893872ce..80354ec9faa 100644 --- a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py +++ b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py @@ -7,43 +7,42 @@ from frappe.utils import cstr, flt, cint from frappe import msgprint, _ -class DocType: - def __init__(self, d, dl=[]): - self.doc, self.doclist = d,dl +from frappe.model.document import Document +class StockUOMReplaceUtility(Document): def validate_mandatory(self): - if not cstr(self.doc.item_code): + if not cstr(self.item_code): msgprint("Please Enter an Item.") raise Exception - if not cstr(self.doc.new_stock_uom): + if not cstr(self.new_stock_uom): msgprint("Please Enter New Stock UOM.") raise Exception - if cstr(self.doc.current_stock_uom) == cstr(self.doc.new_stock_uom): + if cstr(self.current_stock_uom) == cstr(self.new_stock_uom): msgprint("Current Stock UOM and Stock UOM are same.") raise Exception # check conversion factor - if not flt(self.doc.conversion_factor): + if not flt(self.conversion_factor): msgprint("Please Enter Conversion Factor.") raise Exception - stock_uom = frappe.db.get_value("Item", self.doc.item_code, "stock_uom") - if cstr(self.doc.new_stock_uom) == cstr(stock_uom): - msgprint("Item Master is already updated with New Stock UOM " + cstr(self.doc.new_stock_uom)) + stock_uom = frappe.db.get_value("Item", self.item_code, "stock_uom") + if cstr(self.new_stock_uom) == cstr(stock_uom): + msgprint("Item Master is already updated with New Stock UOM " + cstr(self.new_stock_uom)) raise Exception def update_item_master(self): - item_bean = frappe.bean("Item", self.doc.item_code) - item_bean.doc.stock_uom = self.doc.new_stock_uom - item_bean.save() + item_doc = frappe.get_doc("Item", self.item_code) + item_doc.stock_uom = self.new_stock_uom + item_doc.save() - msgprint(_("Default UOM updated in item ") + self.doc.item_code) + msgprint(_("Default UOM updated in item ") + self.item_code) def update_bin(self): # update bin - if flt(self.doc.conversion_factor) != flt(1): + if flt(self.conversion_factor) != flt(1): frappe.db.sql("""update `tabBin` set stock_uom = %s, indented_qty = ifnull(indented_qty,0) * %s, @@ -52,12 +51,12 @@ class DocType: planned_qty = ifnull(planned_qty,0) * %s, projected_qty = actual_qty + ordered_qty + indented_qty + planned_qty - reserved_qty - where item_code = %s""", (self.doc.new_stock_uom, self.doc.conversion_factor, - self.doc.conversion_factor, self.doc.conversion_factor, - self.doc.conversion_factor, self.doc.item_code)) + where item_code = %s""", (self.new_stock_uom, self.conversion_factor, + self.conversion_factor, self.conversion_factor, + self.conversion_factor, self.item_code)) else: frappe.db.sql("update `tabBin` set stock_uom = %s where item_code = %s", - (self.doc.new_stock_uom, self.doc.item_code) ) + (self.new_stock_uom, self.item_code) ) # acknowledge user msgprint(" All Bins Updated Successfully.") @@ -66,23 +65,23 @@ class DocType: # update stock ledger entry from erpnext.stock.stock_ledger import update_entries_after - if flt(self.doc.conversion_factor) != flt(1): + if flt(self.conversion_factor) != flt(1): frappe.db.sql("""update `tabStock Ledger Entry` set stock_uom = %s, actual_qty = ifnull(actual_qty,0) * %s where item_code = %s""", - (self.doc.new_stock_uom, self.doc.conversion_factor, self.doc.item_code)) + (self.new_stock_uom, self.conversion_factor, self.item_code)) else: frappe.db.sql("""update `tabStock Ledger Entry` set stock_uom=%s - where item_code=%s""", (self.doc.new_stock_uom, self.doc.item_code)) + where item_code=%s""", (self.new_stock_uom, self.item_code)) # acknowledge user msgprint("Stock Ledger Entries Updated Successfully.") # update item valuation - if flt(self.doc.conversion_factor) != flt(1): + if flt(self.conversion_factor) != flt(1): wh = frappe.db.sql("select name from `tabWarehouse`") for w in wh: - update_entries_after({"item_code": self.doc.item_code, "warehouse": w[0]}) + update_entries_after({"item_code": self.item_code, "warehouse": w[0]}) # acknowledge user msgprint("Item Valuation Updated Successfully.") @@ -100,8 +99,8 @@ class DocType: def validate_uom_integer_type(self): - current_is_integer = frappe.db.get_value("UOM", self.doc.current_stock_uom, "must_be_whole_number") - new_is_integer = frappe.db.get_value("UOM", self.doc.new_stock_uom, "must_be_whole_number") + current_is_integer = frappe.db.get_value("UOM", self.current_stock_uom, "must_be_whole_number") + new_is_integer = frappe.db.get_value("UOM", self.new_stock_uom, "must_be_whole_number") if current_is_integer and not new_is_integer: frappe.msgprint("New UOM must be of type Whole Number", raise_exception=True) @@ -109,7 +108,7 @@ class DocType: if not current_is_integer and new_is_integer: frappe.msgprint("New UOM must NOT be of type Whole Number", raise_exception=True) - if current_is_integer and new_is_integer and cint(self.doc.conversion_factor)!=self.doc.conversion_factor: + if current_is_integer and new_is_integer and cint(self.conversion_factor)!=self.conversion_factor: frappe.msgprint("Conversion Factor cannot be fraction", raise_exception=True) @frappe.whitelist() diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.txt b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.txt deleted file mode 100644 index a4f368efc2c..00000000000 --- a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.txt +++ /dev/null @@ -1,88 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:30", - "docstatus": 0, - "modified": "2013-12-20 19:21:48", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "icon": "icon-magic", - "in_create": 0, - "issingle": 1, - "module": "Stock", - "name": "__common__", - "read_only": 0 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Stock UOM Replace Utility", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Stock UOM Replace Utility", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Stock UOM Replace Utility" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "label": "Item", - "options": "Item" - }, - { - "doctype": "DocField", - "fieldname": "current_stock_uom", - "fieldtype": "Link", - "label": "Current Stock UOM", - "options": "UOM", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "new_stock_uom", - "fieldtype": "Link", - "label": "New Stock UOM", - "options": "UOM" - }, - { - "doctype": "DocField", - "fieldname": "conversion_factor", - "fieldtype": "Float", - "label": "Conversion Factor" - }, - { - "doctype": "DocField", - "fieldname": "update", - "fieldtype": "Button", - "label": "Update", - "options": "update_stock_uom" - }, - { - "doctype": "DocPerm", - "role": "Material Master Manager" - }, - { - "doctype": "DocPerm", - "role": "Material Manager" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.json b/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.json new file mode 100644 index 00000000000..3c9c022bbe3 --- /dev/null +++ b/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.json @@ -0,0 +1,34 @@ +{ + "autoname": "UCDD/.#####", + "creation": "2013-02-22 01:28:04.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "uom", + "fieldtype": "Link", + "in_list_view": 1, + "label": "UOM", + "oldfieldname": "uom", + "oldfieldtype": "Link", + "options": "UOM", + "permlevel": 0 + }, + { + "fieldname": "conversion_factor", + "fieldtype": "Float", + "in_list_view": 1, + "label": "Conversion Factor", + "oldfieldname": "conversion_factor", + "oldfieldtype": "Float", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:21:53.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "UOM Conversion Detail", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py b/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py index 26c87f1c04a..aa6db6d86ea 100644 --- a/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py +++ b/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class UOMConversionDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.txt b/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.txt deleted file mode 100644 index 08439211500..00000000000 --- a/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.txt +++ /dev/null @@ -1,46 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:04", - "docstatus": 0, - "modified": "2013-12-20 19:21:53", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "UCDD/.#####", - "doctype": "DocType", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "UOM Conversion Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "UOM Conversion Detail" - }, - { - "doctype": "DocField", - "fieldname": "uom", - "fieldtype": "Link", - "label": "UOM", - "oldfieldname": "uom", - "oldfieldtype": "Link", - "options": "UOM" - }, - { - "doctype": "DocField", - "fieldname": "conversion_factor", - "fieldtype": "Float", - "label": "Conversion Factor", - "oldfieldname": "conversion_factor", - "oldfieldtype": "Float" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/warehouse/test_records.json b/erpnext/stock/doctype/warehouse/test_records.json new file mode 100644 index 00000000000..e0941af26c2 --- /dev/null +++ b/erpnext/stock/doctype/warehouse/test_records.json @@ -0,0 +1,25 @@ +[ + { + "company": "_Test Company", + "create_account_under": "Stock Assets - _TC", + "doctype": "Warehouse", + "warehouse_name": "_Test Warehouse" + }, + { + "company": "_Test Company", + "create_account_under": "Fixed Assets - _TC", + "doctype": "Warehouse", + "warehouse_name": "_Test Warehouse 1" + }, + { + "company": "_Test Company 1", + "create_account_under": "Stock Assets - _TC", + "doctype": "Warehouse", + "warehouse_name": "_Test Warehouse 2" + }, + { + "company": "_Test Company", + "doctype": "Warehouse", + "warehouse_name": "_Test Warehouse No Account" + } +] diff --git a/erpnext/stock/doctype/warehouse/test_warehouse.py b/erpnext/stock/doctype/warehouse/test_warehouse.py index b0e7641a288..dea61f8ee06 100644 --- a/erpnext/stock/doctype/warehouse/test_warehouse.py +++ b/erpnext/stock/doctype/warehouse/test_warehouse.py @@ -1,28 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Warehouse", - "warehouse_name": "_Test Warehouse", - "company": "_Test Company", - "create_account_under": "Stock Assets - _TC" - }], - [{ - "doctype": "Warehouse", - "warehouse_name": "_Test Warehouse 1", - "company": "_Test Company", - "create_account_under": "Fixed Assets - _TC" - }], - [{ - "doctype": "Warehouse", - "warehouse_name": "_Test Warehouse 2", - "create_account_under": "Stock Assets - _TC", - "company": "_Test Company 1" - }], - [{ - "doctype": "Warehouse", - "warehouse_name": "_Test Warehouse No Account", - "company": "_Test Company", - }], -] + +import frappe +test_records = frappe.get_test_records('Warehouse') \ No newline at end of file diff --git a/erpnext/stock/doctype/warehouse/warehouse.json b/erpnext/stock/doctype/warehouse/warehouse.json new file mode 100644 index 00000000000..52bb7e9e8f0 --- /dev/null +++ b/erpnext/stock/doctype/warehouse/warehouse.json @@ -0,0 +1,215 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "creation": "2013-03-07 18:50:32.000000", + "description": "A logical Warehouse against which stock entries are made.", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "warehouse_detail", + "fieldtype": "Section Break", + "label": "Warehouse Detail", + "oldfieldtype": "Section Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "warehouse_name", + "fieldtype": "Data", + "label": "Warehouse Name", + "oldfieldname": "warehouse_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, + { + "depends_on": "eval:sys_defaults.auto_accounting_for_stock", + "description": "Account for the warehouse (Perpetual Inventory) will be created under this Account.", + "fieldname": "create_account_under", + "fieldtype": "Link", + "label": "Parent Account", + "options": "Account", + "permlevel": 0 + }, + { + "fieldname": "disabled", + "fieldtype": "Check", + "label": "Disabled", + "permlevel": 0 + }, + { + "description": "For Reference Only.", + "fieldname": "warehouse_contact_info", + "fieldtype": "Section Break", + "label": "Warehouse Contact Info", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "email_id", + "fieldtype": "Data", + "hidden": 1, + "label": "Email Id", + "oldfieldname": "email_id", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 0, + "read_only": 0 + }, + { + "fieldname": "phone_no", + "fieldtype": "Data", + "label": "Phone No", + "oldfieldname": "phone_no", + "oldfieldtype": "Int", + "options": "Phone", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "mobile_no", + "fieldtype": "Data", + "label": "Mobile No", + "oldfieldname": "mobile_no", + "oldfieldtype": "Int", + "options": "Phone", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "address_line_1", + "fieldtype": "Data", + "label": "Address Line 1", + "oldfieldname": "address_line_1", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "address_line_2", + "fieldtype": "Data", + "label": "Address Line 2", + "oldfieldname": "address_line_2", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "city", + "fieldtype": "Data", + "in_list_view": 1, + "label": "City", + "oldfieldname": "city", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "state", + "fieldtype": "Data", + "label": "State", + "oldfieldname": "state", + "oldfieldtype": "Select", + "options": "Suggest", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "pin", + "fieldtype": "Int", + "label": "PIN", + "oldfieldname": "pin", + "oldfieldtype": "Int", + "permlevel": 0, + "read_only": 0 + } + ], + "icon": "icon-building", + "idx": 1, + "modified": "2014-03-13 16:26:29.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Warehouse", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material Master Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Material User", + "submit": 0, + "write": 0 + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User" + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User" + }, + { + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User" + } + ] +} \ No newline at end of file diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py index 8ec62351a0e..3b159fc7102 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.py +++ b/erpnext/stock/doctype/warehouse/warehouse.py @@ -6,32 +6,31 @@ import frappe from frappe.utils import cint, validate_email_add from frappe import throw, msgprint, _ -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class Warehouse(Document): def autoname(self): - suffix = " - " + frappe.db.get_value("Company", self.doc.company, "abbr") - if not self.doc.warehouse_name.endswith(suffix): - self.doc.name = self.doc.warehouse_name + suffix + suffix = " - " + frappe.db.get_value("Company", self.company, "abbr") + if not self.warehouse_name.endswith(suffix): + self.name = self.warehouse_name + suffix def validate(self): - if self.doc.email_id and not validate_email_add(self.doc.email_id): + if self.email_id and not validate_email_add(self.email_id): throw(_("Please enter valid Email Id")) self.update_parent_account() def update_parent_account(self): - if not self.doc.__islocal and (self.doc.create_account_under != - frappe.db.get_value("Warehouse", self.doc.name, "create_account_under")): + if not getattr(self, "__islocal", None) and (self.create_account_under != + frappe.db.get_value("Warehouse", self.name, "create_account_under")): warehouse_account = frappe.db.get_value("Account", - {"account_type": "Warehouse", "company": self.doc.company, - "master_name": self.doc.name}, ["name", "parent_account"]) - if warehouse_account and warehouse_account[1] != self.doc.create_account_under: - acc_bean = frappe.bean("Account", warehouse_account[0]) - acc_bean.doc.parent_account = self.doc.create_account_under - acc_bean.save() + {"account_type": "Warehouse", "company": self.company, + "master_name": self.name}, ["name", "parent_account"]) + if warehouse_account and warehouse_account[1] != self.create_account_under: + acc_doc = frappe.get_doc("Account", warehouse_account[0]) + acc_doc.parent_account = self.create_account_under + acc_doc.save() def on_update(self): self.create_account_head() @@ -39,74 +38,74 @@ class DocType: def create_account_head(self): if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): if not frappe.db.get_value("Account", {"account_type": "Warehouse", - "master_name": self.doc.name}) and not frappe.db.get_value("Account", - {"account_name": self.doc.warehouse_name}): - if self.doc.fields.get("__islocal") or not frappe.db.get_value( - "Stock Ledger Entry", {"warehouse": self.doc.name}): + "master_name": self.name}) and not frappe.db.get_value("Account", + {"account_name": self.warehouse_name}): + if self.get("__islocal") or not frappe.db.get_value( + "Stock Ledger Entry", {"warehouse": self.name}): self.validate_parent_account() - ac_bean = frappe.bean({ + ac_doc = frappe.get_doc({ "doctype": "Account", - 'account_name': self.doc.warehouse_name, - 'parent_account': self.doc.create_account_under, + 'account_name': self.warehouse_name, + 'parent_account': self.create_account_under, 'group_or_ledger':'Ledger', - 'company':self.doc.company, + 'company':self.company, "account_type": "Warehouse", - "master_name": self.doc.name, + "master_name": self.name, "freeze_account": "No" }) - ac_bean.ignore_permissions = True - ac_bean.insert() + ac_doc.ignore_permissions = True + ac_doc.insert() - msgprint(_("Account Head") + ": " + ac_bean.doc.name + _(" created")) + msgprint(_("Account Head") + ": " + ac_doc.name + _(" created")) def validate_parent_account(self): - if not self.doc.create_account_under: + if not self.create_account_under: parent_account = frappe.db.get_value("Account", - {"account_name": "Stock Assets", "company": self.doc.company}) + {"account_name": "Stock Assets", "company": self.company}) if parent_account: - self.doc.create_account_under = parent_account + self.create_account_under = parent_account else: frappe.throw(_("Please enter account group under which account \ - for warehouse ") + self.doc.name +_(" will be created")) + for warehouse ") + self.name +_(" will be created")) def on_trash(self): # delete bin bins = frappe.db.sql("select * from `tabBin` where warehouse = %s", - self.doc.name, as_dict=1) + self.name, as_dict=1) for d in bins: if d['actual_qty'] or d['reserved_qty'] or d['ordered_qty'] or \ d['indented_qty'] or d['projected_qty'] or d['planned_qty']: throw("""Warehouse: %s can not be deleted as qty exists for item: %s""" - % (self.doc.name, d['item_code'])) + % (self.name, d['item_code'])) else: frappe.db.sql("delete from `tabBin` where name = %s", d['name']) warehouse_account = frappe.db.get_value("Account", - {"account_type": "Warehouse", "master_name": self.doc.name}) + {"account_type": "Warehouse", "master_name": self.name}) if warehouse_account: frappe.delete_doc("Account", warehouse_account) if frappe.db.sql("""select name from `tabStock Ledger Entry` - where warehouse = %s""", self.doc.name): + where warehouse = %s""", self.name): throw(_("""Warehouse can not be deleted as stock ledger entry exists for this warehouse.""")) def before_rename(self, olddn, newdn, merge=False): # Add company abbr if not provided from erpnext.setup.doctype.company.company import get_name_with_abbr - new_warehouse = get_name_with_abbr(newdn, self.doc.company) + new_warehouse = get_name_with_abbr(newdn, self.company) if merge: if not frappe.db.exists("Warehouse", new_warehouse): frappe.throw(_("Warehouse ") + new_warehouse +_(" does not exists")) - if self.doc.company != frappe.db.get_value("Warehouse", new_warehouse, "company"): + if self.company != frappe.db.get_value("Warehouse", new_warehouse, "company"): frappe.throw(_("Both Warehouse must belong to same Company")) frappe.db.sql("delete from `tabBin` where warehouse=%s", olddn) from erpnext.accounts.utils import rename_account_for - rename_account_for("Warehouse", olddn, newdn, merge, self.doc.company) + rename_account_for("Warehouse", olddn, newdn, merge, self.company) return new_warehouse diff --git a/erpnext/stock/doctype/warehouse/warehouse.txt b/erpnext/stock/doctype/warehouse/warehouse.txt deleted file mode 100644 index 589fa99c115..00000000000 --- a/erpnext/stock/doctype/warehouse/warehouse.txt +++ /dev/null @@ -1,218 +0,0 @@ -[ - { - "creation": "2013-03-07 18:50:32", - "docstatus": 0, - "modified": "2014-03-13 16:26:29", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "description": "A logical Warehouse against which stock entries are made.", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-building", - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Warehouse", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Warehouse", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1 - }, - { - "doctype": "DocType", - "name": "Warehouse" - }, - { - "doctype": "DocField", - "fieldname": "warehouse_detail", - "fieldtype": "Section Break", - "label": "Warehouse Detail", - "oldfieldtype": "Section Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "warehouse_name", - "fieldtype": "Data", - "label": "Warehouse Name", - "oldfieldname": "warehouse_name", - "oldfieldtype": "Data", - "read_only": 0, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, - { - "depends_on": "eval:sys_defaults.auto_accounting_for_stock", - "description": "Account for the warehouse (Perpetual Inventory) will be created under this Account.", - "doctype": "DocField", - "fieldname": "create_account_under", - "fieldtype": "Link", - "label": "Parent Account", - "options": "Account" - }, - { - "doctype": "DocField", - "fieldname": "disabled", - "fieldtype": "Check", - "label": "Disabled" - }, - { - "description": "For Reference Only.", - "doctype": "DocField", - "fieldname": "warehouse_contact_info", - "fieldtype": "Section Break", - "label": "Warehouse Contact Info", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "email_id", - "fieldtype": "Data", - "hidden": 1, - "label": "Email Id", - "oldfieldname": "email_id", - "oldfieldtype": "Data", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "phone_no", - "fieldtype": "Data", - "label": "Phone No", - "oldfieldname": "phone_no", - "oldfieldtype": "Int", - "options": "Phone", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "mobile_no", - "fieldtype": "Data", - "label": "Mobile No", - "oldfieldname": "mobile_no", - "oldfieldtype": "Int", - "options": "Phone", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "address_line_1", - "fieldtype": "Data", - "label": "Address Line 1", - "oldfieldname": "address_line_1", - "oldfieldtype": "Data", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "address_line_2", - "fieldtype": "Data", - "label": "Address Line 2", - "oldfieldname": "address_line_2", - "oldfieldtype": "Data", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "city", - "fieldtype": "Data", - "in_list_view": 1, - "label": "City", - "oldfieldname": "city", - "oldfieldtype": "Data", - "read_only": 0, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "state", - "fieldtype": "Data", - "label": "State", - "oldfieldname": "state", - "oldfieldtype": "Select", - "options": "Suggest", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "pin", - "fieldtype": "Int", - "label": "PIN", - "oldfieldname": "pin", - "oldfieldtype": "Int", - "read_only": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "role": "Material Master Manager", - "submit": 0, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "doctype": "DocPerm", - "role": "Material User", - "submit": 0, - "write": 0 - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase User" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Accounts User" - } -] \ No newline at end of file diff --git a/erpnext/stock/doctype/warehouse_user/warehouse_user.json b/erpnext/stock/doctype/warehouse_user/warehouse_user.json new file mode 100644 index 00000000000..6e797a1ede4 --- /dev/null +++ b/erpnext/stock/doctype/warehouse_user/warehouse_user.json @@ -0,0 +1,25 @@ +{ + "creation": "2013-02-22 01:28:05.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Other", + "fields": [ + { + "fieldname": "user", + "fieldtype": "Link", + "in_list_view": 1, + "label": "User", + "options": "User", + "permlevel": 0, + "print_width": "200px", + "width": "200px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:21:54.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Warehouse User", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/stock/doctype/warehouse_user/warehouse_user.py b/erpnext/stock/doctype/warehouse_user/warehouse_user.py index 968a25b6134..59bfefe3b1c 100644 --- a/erpnext/stock/doctype/warehouse_user/warehouse_user.py +++ b/erpnext/stock/doctype/warehouse_user/warehouse_user.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class WarehouseUser(Document): + pass \ No newline at end of file diff --git a/erpnext/stock/doctype/warehouse_user/warehouse_user.txt b/erpnext/stock/doctype/warehouse_user/warehouse_user.txt deleted file mode 100644 index ae22eecd773..00000000000 --- a/erpnext/stock/doctype/warehouse_user/warehouse_user.txt +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:05", - "docstatus": 0, - "modified": "2013-12-20 19:21:54", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "document_type": "Other", - "istable": 1, - "module": "Stock", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "user", - "fieldtype": "Link", - "in_list_view": 1, - "label": "User", - "name": "__common__", - "options": "User", - "parent": "Warehouse User", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "print_width": "200px", - "width": "200px" - }, - { - "doctype": "DocType", - "name": "Warehouse User" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 39d494c69ac..eeff2750ef2 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe import _, throw from frappe.utils import flt, cint, add_days -from frappe.model.meta import has_field import json @frappe.whitelist() @@ -36,7 +35,7 @@ def get_item_details(args): args = frappe._dict(args) if not args.get("transaction_type"): - args.transaction_type = "buying" if has_field(args.get("doctype"), "supplier") \ + args.transaction_type = "buying" if frappe.get_meta(args.get("doctype")).get_field("supplier") \ else "selling" if not args.get("price_list"): @@ -47,20 +46,20 @@ def get_item_details(args): elif not args.item_code and args.serial_no: args.item_code = get_item_code(serial_no=args.serial_no) - item_bean = frappe.bean("Item", args.item_code) - item = item_bean.doc + item_doc = frappe.get_doc("Item", args.item_code) + item = item_doc validate_item_details(args, item) - out = get_basic_details(args, item_bean) + out = get_basic_details(args, item_doc) - get_party_item_code(args, item_bean, out) + get_party_item_code(args, item_doc, out) if out.get("warehouse"): out.update(get_available_qty(args.item_code, out.warehouse)) out.update(get_projected_qty(item.name, out.warehouse)) - get_price_list_rate(args, item_bean, out) + get_price_list_rate(args, item_doc, out) if args.transaction_type == "selling" and cint(args.is_pos): out.update(get_pos_settings_item_details(args.company, args)) @@ -68,8 +67,8 @@ def get_item_details(args): apply_pricing_rule(out, args) if args.get("doctype") in ("Sales Invoice", "Delivery Note"): - if item_bean.doc.has_serial_no == "Yes" and not args.serial_no: - out.serial_no = get_serial_nos_by_fifo(args, item_bean) + if item_doc.has_serial_no == "Yes" and not args.serial_no: + out.serial_no = get_serial_nos_by_fifo(args, item_doc) if args.transaction_date and item.lead_time_days: out.schedule_date = out.lead_time_date = add_days(args.transaction_date, @@ -117,8 +116,8 @@ def validate_item_details(args, item): _("not a sub-contracted item.") + _("Please select a sub-contracted item or do not sub-contract the transaction.")) -def get_basic_details(args, item_bean): - item = item_bean.doc +def get_basic_details(args, item_doc): + item = item_doc from frappe.defaults import get_user_default_as_list user_default_warehouse_list = get_user_default_as_list('warehouse') @@ -138,7 +137,7 @@ def get_basic_details(args, item_bean): if args.transaction_type == "selling" else item.buying_cost_center, "batch_no": None, "item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in - item_bean.doclist.get({"parentfield": "item_tax"})))), + item_doc.get("item_tax")))), "uom": item.stock_uom, "min_order_qty": flt(item.min_order_qty) if args.doctype == "Material Request" else "", "conversion_factor": 1.0, @@ -153,12 +152,12 @@ def get_basic_details(args, item_bean): }) for fieldname in ("item_name", "item_group", "barcode", "brand", "stock_uom"): - out[fieldname] = item.fields.get(fieldname) + out[fieldname] = item.get(fieldname) return out -def get_price_list_rate(args, item_bean, out): - meta = frappe.get_doctype(args.doctype) +def get_price_list_rate(args, item_doc, out): + meta = frappe.get_meta(args.doctype) if meta.get_field("currency"): validate_price_list(args) @@ -174,7 +173,7 @@ def get_price_list_rate(args, item_bean, out): if not out.price_list_rate and args.transaction_type == "buying": from erpnext.stock.doctype.item.item import get_last_purchase_details - out.update(get_last_purchase_details(item_bean.doc.name, + out.update(get_last_purchase_details(item_doc.name, args.docname, args.conversion_rate)) def validate_price_list(args): @@ -208,14 +207,12 @@ def validate_conversion_rate(args, meta): get_field_precision(meta.get_field("plc_conversion_rate"), frappe._dict({"fields": args}))) -def get_party_item_code(args, item_bean, out): +def get_party_item_code(args, item_doc, out): if args.transaction_type == "selling": - customer_item_code = item_bean.doclist.get({"parentfield": "item_customer_details", - "customer_name": args.customer}) + customer_item_code = item_doc.get("item_customer_details", {"customer_name": args.customer}) out.customer_item_code = customer_item_code[0].ref_code if customer_item_code else None else: - item_supplier = item_bean.doclist.get({"parentfield": "item_supplier_details", - "supplier": args.supplier}) + item_supplier = item_doc.get("item_supplier_details", {"supplier": args.supplier}) out.supplier_part_no = item_supplier[0].supplier_part_no if item_supplier else None @@ -354,7 +351,7 @@ def apply_internal_priority(pricing_rules, field_set, args_dict): return filtered_rules or pricing_rules -def get_serial_nos_by_fifo(args, item_bean): +def get_serial_nos_by_fifo(args, item_doc): return "\n".join(frappe.db.sql_list("""select name from `tabSerial No` where item_code=%(item_code)s and warehouse=%(warehouse)s and status='Available' order by timestamp(purchase_date, purchase_time) asc limit %(qty)s""", { diff --git a/erpnext/stock/page/stock_ageing/stock_ageing.json b/erpnext/stock/page/stock_ageing/stock_ageing.json new file mode 100644 index 00000000000..34c259e46d7 --- /dev/null +++ b/erpnext/stock/page/stock_ageing/stock_ageing.json @@ -0,0 +1,23 @@ +{ + "creation": "2012-09-21 20:15:14.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-table", + "idx": 1, + "modified": "2013-07-11 14:44:08.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "stock-ageing", + "owner": "Administrator", + "page_name": "stock-ageing", + "roles": [ + { + "role": "Analytics" + }, + { + "role": "Material Manager" + } + ], + "standard": "Yes", + "title": "Stock Ageing" +} \ No newline at end of file diff --git a/erpnext/stock/page/stock_ageing/stock_ageing.txt b/erpnext/stock/page/stock_ageing/stock_ageing.txt deleted file mode 100644 index cd1cfbd1c9a..00000000000 --- a/erpnext/stock/page/stock_ageing/stock_ageing.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2012-09-21 20:15:14", - "docstatus": 0, - "modified": "2013-07-11 14:44:08", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Stock", - "name": "__common__", - "page_name": "stock-ageing", - "standard": "Yes", - "title": "Stock Ageing" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-ageing", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-ageing" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - } -] \ No newline at end of file diff --git a/erpnext/stock/page/stock_analytics/stock_analytics.json b/erpnext/stock/page/stock_analytics/stock_analytics.json new file mode 100644 index 00000000000..3b8380acc26 --- /dev/null +++ b/erpnext/stock/page/stock_analytics/stock_analytics.json @@ -0,0 +1,23 @@ +{ + "creation": "2012-09-21 20:15:14.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-bar-chart", + "idx": 1, + "modified": "2013-07-11 14:44:10.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "stock-analytics", + "owner": "Administrator", + "page_name": "stock-analytics", + "roles": [ + { + "role": "Analytics" + }, + { + "role": "Material Manager" + } + ], + "standard": "Yes", + "title": "Stock Analytics" +} \ No newline at end of file diff --git a/erpnext/stock/page/stock_analytics/stock_analytics.txt b/erpnext/stock/page/stock_analytics/stock_analytics.txt deleted file mode 100644 index 140b1024f74..00000000000 --- a/erpnext/stock/page/stock_analytics/stock_analytics.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2012-09-21 20:15:14", - "docstatus": 0, - "modified": "2013-07-11 14:44:10", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-bar-chart", - "module": "Stock", - "name": "__common__", - "page_name": "stock-analytics", - "standard": "Yes", - "title": "Stock Analytics" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-analytics", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-analytics" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - } -] \ No newline at end of file diff --git a/erpnext/stock/page/stock_balance/stock_balance.json b/erpnext/stock/page/stock_balance/stock_balance.json new file mode 100644 index 00000000000..6f25be44074 --- /dev/null +++ b/erpnext/stock/page/stock_balance/stock_balance.json @@ -0,0 +1,23 @@ +{ + "creation": "2012-12-27 18:57:47.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-table", + "idx": 1, + "modified": "2013-07-11 14:44:15.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "stock-balance", + "owner": "Administrator", + "page_name": "stock-balance", + "roles": [ + { + "role": "Material Manager" + }, + { + "role": "Analytics" + } + ], + "standard": "Yes", + "title": "Stock Balance" +} \ No newline at end of file diff --git a/erpnext/stock/page/stock_balance/stock_balance.txt b/erpnext/stock/page/stock_balance/stock_balance.txt deleted file mode 100644 index 536448c0728..00000000000 --- a/erpnext/stock/page/stock_balance/stock_balance.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2012-12-27 18:57:47", - "docstatus": 0, - "modified": "2013-07-11 14:44:15", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Stock", - "name": "__common__", - "page_name": "stock-balance", - "standard": "Yes", - "title": "Stock Balance" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-balance", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-balance" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - }, - { - "doctype": "Page Role", - "role": "Analytics" - } -] \ No newline at end of file diff --git a/erpnext/stock/page/stock_ledger/stock_ledger.json b/erpnext/stock/page/stock_ledger/stock_ledger.json new file mode 100644 index 00000000000..e2bd8f7729c --- /dev/null +++ b/erpnext/stock/page/stock_ledger/stock_ledger.json @@ -0,0 +1,26 @@ +{ + "creation": "2012-09-21 20:15:14.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-table", + "idx": 1, + "modified": "2013-07-11 14:44:19.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "stock-ledger", + "owner": "Administrator", + "page_name": "stock-ledger", + "roles": [ + { + "role": "Analytics" + }, + { + "role": "Material Manager" + }, + { + "role": "Material User" + } + ], + "standard": "Yes", + "title": "Stock Ledger" +} \ No newline at end of file diff --git a/erpnext/stock/page/stock_ledger/stock_ledger.txt b/erpnext/stock/page/stock_ledger/stock_ledger.txt deleted file mode 100644 index 9c2a4b75e57..00000000000 --- a/erpnext/stock/page/stock_ledger/stock_ledger.txt +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "creation": "2012-09-21 20:15:14", - "docstatus": 0, - "modified": "2013-07-11 14:44:19", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Stock", - "name": "__common__", - "page_name": "stock-ledger", - "standard": "Yes", - "title": "Stock Ledger" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-ledger", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-ledger" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - }, - { - "doctype": "Page Role", - "role": "Material User" - } -] \ No newline at end of file diff --git a/erpnext/stock/page/stock_level/stock_level.json b/erpnext/stock/page/stock_level/stock_level.json new file mode 100644 index 00000000000..c6f3f96d766 --- /dev/null +++ b/erpnext/stock/page/stock_level/stock_level.json @@ -0,0 +1,23 @@ +{ + "creation": "2012-12-31 10:52:14.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-table", + "idx": 1, + "modified": "2013-07-11 14:44:21.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "stock-level", + "owner": "Administrator", + "page_name": "stock-level", + "roles": [ + { + "role": "Material Manager" + }, + { + "role": "Analytics" + } + ], + "standard": "Yes", + "title": "Stock Level" +} \ No newline at end of file diff --git a/erpnext/stock/page/stock_level/stock_level.txt b/erpnext/stock/page/stock_level/stock_level.txt deleted file mode 100644 index bae3d9c9b25..00000000000 --- a/erpnext/stock/page/stock_level/stock_level.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2012-12-31 10:52:14", - "docstatus": 0, - "modified": "2013-07-11 14:44:21", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Stock", - "name": "__common__", - "page_name": "stock-level", - "standard": "Yes", - "title": "Stock Level" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-level", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-level" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - }, - { - "doctype": "Page Role", - "role": "Analytics" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.json b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.json new file mode 100644 index 00000000000..e79ca823e6a --- /dev/null +++ b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-04 11:03:47.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Batch-Wise Balance History", + "owner": "Administrator", + "ref_doctype": "Stock Ledger Entry", + "report_name": "Batch-Wise Balance History", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.txt b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.txt deleted file mode 100644 index 6a70042ffdd..00000000000 --- a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-04 11:03:47", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Stock Ledger Entry", - "report_name": "Batch-Wise Balance History", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Batch-Wise Balance History" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.json b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.json new file mode 100644 index 00000000000..ccedc4b255a --- /dev/null +++ b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-13 18:42:11.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Delivery Note Trends", + "owner": "Administrator", + "ref_doctype": "Delivery Note", + "report_name": "Delivery Note Trends", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.txt b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.txt deleted file mode 100644 index 2d7c9536da5..00000000000 --- a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-13 18:42:11", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Delivery Note", - "report_name": "Delivery Note Trends", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Delivery Note Trends" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/item_prices/item_prices.json b/erpnext/stock/report/item_prices/item_prices.json new file mode 100644 index 00000000000..cf0dde26a44 --- /dev/null +++ b/erpnext/stock/report/item_prices/item_prices.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-05 11:43:30.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item Prices", + "owner": "Administrator", + "ref_doctype": "Stock Ledger Entry", + "report_name": "Item Prices", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/item_prices/item_prices.txt b/erpnext/stock/report/item_prices/item_prices.txt deleted file mode 100644 index e5e96347c69..00000000000 --- a/erpnext/stock/report/item_prices/item_prices.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-05 11:43:30", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Stock Ledger Entry", - "report_name": "Item Prices", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Item Prices" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/item_shortage_report/item_shortage_report.json b/erpnext/stock/report/item_shortage_report/item_shortage_report.json new file mode 100644 index 00000000000..4af235a871a --- /dev/null +++ b/erpnext/stock/report/item_shortage_report/item_shortage_report.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-08-20 13:43:30.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "json": "{\"filters\":[[\"Bin\",\"projected_qty\",\"<\",\"0\"]],\"columns\":[[\"warehouse\",\"Bin\"],[\"item_code\",\"Bin\"],[\"actual_qty\",\"Bin\"],[\"ordered_qty\",\"Bin\"],[\"planned_qty\",\"Bin\"],[\"reserved_qty\",\"Bin\"],[\"projected_qty\",\"Bin\"]],\"sort_by\":\"Bin.projected_qty\",\"sort_order\":\"asc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item Shortage Report", + "owner": "Administrator", + "ref_doctype": "Bin", + "report_name": "Item Shortage Report", + "report_type": "Report Builder" +} \ No newline at end of file diff --git a/erpnext/stock/report/item_shortage_report/item_shortage_report.txt b/erpnext/stock/report/item_shortage_report/item_shortage_report.txt deleted file mode 100644 index 615c373986a..00000000000 --- a/erpnext/stock/report/item_shortage_report/item_shortage_report.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-08-20 13:43:30", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "json": "{\"filters\":[[\"Bin\",\"projected_qty\",\"<\",\"0\"]],\"columns\":[[\"warehouse\",\"Bin\"],[\"item_code\",\"Bin\"],[\"actual_qty\",\"Bin\"],[\"ordered_qty\",\"Bin\"],[\"planned_qty\",\"Bin\"],[\"reserved_qty\",\"Bin\"],[\"projected_qty\",\"Bin\"]],\"sort_by\":\"Bin.projected_qty\",\"sort_order\":\"asc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Bin", - "report_name": "Item Shortage Report", - "report_type": "Report Builder" - }, - { - "doctype": "Report", - "name": "Item Shortage Report" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.json b/erpnext/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.json new file mode 100644 index 00000000000..6d4b7f74df2 --- /dev/null +++ b/erpnext/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-09-25 10:21:15.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "json": "{\"filters\":[[\"Item Price\",\"price_list\",\"like\",\"%\"],[\"Item Price\",\"item_code\",\"like\",\"%\"]],\"columns\":[[\"name\",\"Item Price\"],[\"price_list\",\"Item Price\"],[\"item_code\",\"Item Price\"],[\"item_name\",\"Item Price\"],[\"item_description\",\"Item Price\"],[\"ref_rate\",\"Item Price\"],[\"buying\",\"Item Price\"],[\"selling\",\"Item Price\"],[\"currency\",\"Item Price\"]],\"sort_by\":\"Item Price.modified\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Item-wise Price List Rate", + "owner": "Administrator", + "ref_doctype": "Price List", + "report_name": "Item-wise Price List Rate", + "report_type": "Report Builder" +} \ No newline at end of file diff --git a/erpnext/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.txt b/erpnext/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.txt deleted file mode 100644 index 14b08729439..00000000000 --- a/erpnext/stock/report/item_wise_price_list_rate/item_wise_price_list_rate.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-09-25 10:21:15", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "json": "{\"filters\":[[\"Item Price\",\"price_list\",\"like\",\"%\"],[\"Item Price\",\"item_code\",\"like\",\"%\"]],\"columns\":[[\"name\",\"Item Price\"],[\"price_list\",\"Item Price\"],[\"item_code\",\"Item Price\"],[\"item_name\",\"Item Price\"],[\"item_description\",\"Item Price\"],[\"ref_rate\",\"Item Price\"],[\"buying\",\"Item Price\"],[\"selling\",\"Item Price\"],[\"currency\",\"Item Price\"]],\"sort_by\":\"Item Price.modified\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Price List", - "report_name": "Item-wise Price List Rate", - "report_type": "Report Builder" - }, - { - "doctype": "Report", - "name": "Item-wise Price List Rate" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/items_to_be_requested/items_to_be_requested.json b/erpnext/stock/report/items_to_be_requested/items_to_be_requested.json new file mode 100644 index 00000000000..a975110e092 --- /dev/null +++ b/erpnext/stock/report/items_to_be_requested/items_to_be_requested.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-08-20 15:08:10.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Items To Be Requested", + "owner": "Administrator", + "query": "SELECT\n tabBin.item_code as \"Item:Link/Item:120\",\n tabBin.warehouse as \"Warehouse:Link/Warehouse:120\",\n tabBin.actual_qty as \"Actual:Float:90\",\n tabBin.indented_qty as \"Requested:Float:90\",\n tabBin.reserved_qty as \"Reserved:Float:90\",\n tabBin.ordered_qty as \"Ordered:Float:90\",\n tabBin.projected_qty as \"Projected:Float:90\"\nFROM\n tabBin, tabItem\nWHERE\n tabBin.item_code = tabItem.name\n AND tabItem.is_purchase_item = \"Yes\"\n AND tabBin.projected_qty < 0\nORDER BY\n tabBin.projected_qty ASC", + "ref_doctype": "Item", + "report_name": "Items To Be Requested", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/items_to_be_requested/items_to_be_requested.txt b/erpnext/stock/report/items_to_be_requested/items_to_be_requested.txt deleted file mode 100644 index 97f45ce0ff5..00000000000 --- a/erpnext/stock/report/items_to_be_requested/items_to_be_requested.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-08-20 15:08:10", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "query": "SELECT\n tabBin.item_code as \"Item:Link/Item:120\",\n tabBin.warehouse as \"Warehouse:Link/Warehouse:120\",\n tabBin.actual_qty as \"Actual:Float:90\",\n tabBin.indented_qty as \"Requested:Float:90\",\n tabBin.reserved_qty as \"Reserved:Float:90\",\n tabBin.ordered_qty as \"Ordered:Float:90\",\n tabBin.projected_qty as \"Projected:Float:90\"\nFROM\n tabBin, tabItem\nWHERE\n tabBin.item_code = tabItem.name\n AND tabItem.is_purchase_item = \"Yes\"\n AND tabBin.projected_qty < 0\nORDER BY\n tabBin.projected_qty ASC", - "ref_doctype": "Item", - "report_name": "Items To Be Requested", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Items To Be Requested" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.json b/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.json new file mode 100644 index 00000000000..36cbcaa0879 --- /dev/null +++ b/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-07 12:47:22.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Itemwise Recommended Reorder Level", + "owner": "Administrator", + "ref_doctype": "Item", + "report_name": "Itemwise Recommended Reorder Level", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.txt b/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.txt deleted file mode 100644 index 5f6cad974de..00000000000 --- a/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-07 12:47:22", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Item", - "report_name": "Itemwise Recommended Reorder Level", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Itemwise Recommended Reorder Level" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.json b/erpnext/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.json new file mode 100644 index 00000000000..c79c0bc74b5 --- /dev/null +++ b/erpnext/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-08-09 12:20:58.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Material Requests for which Supplier Quotations are not created", + "owner": "Administrator", + "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n mr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand not exists(select name from `tabSupplier Quotation Item` where prevdoc_docname=mr.name)\norder by mr.transaction_date asc", + "ref_doctype": "Material Request", + "report_name": "Material Requests for which Supplier Quotations are not created", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.txt b/erpnext/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.txt deleted file mode 100644 index 05f7afbf615..00000000000 --- a/erpnext/stock/report/material_requests_for_which_supplier_quotations_are_not_created/material_requests_for_which_supplier_quotations_are_not_created.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-08-09 12:20:58", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n mr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand not exists(select name from `tabSupplier Quotation Item` where prevdoc_docname=mr.name)\norder by mr.transaction_date asc", - "ref_doctype": "Material Request", - "report_name": "Material Requests for which Supplier Quotations are not created", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Material Requests for which Supplier Quotations are not created" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.json b/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.json new file mode 100644 index 00000000000..d37cdab410d --- /dev/null +++ b/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-02-22 18:01:55.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Ordered Items To Be Delivered", + "owner": "Administrator", + "query": "select \n `tabSales Order`.`name` as \"Sales Order:Link/Sales Order:120\",\n `tabSales Order`.`customer` as \"Customer:Link/Customer:120\",\n `tabSales Order`.`transaction_date` as \"Date:Date\",\n `tabSales Order`.`project_name` as \"Project\",\n `tabSales Order Item`.item_code as \"Item:Link/Item:120\",\n `tabSales Order Item`.qty as \"Qty:Float:140\",\n `tabSales Order Item`.delivered_qty as \"Delivered Qty:Float:140\",\n (`tabSales Order Item`.qty - ifnull(`tabSales Order Item`.delivered_qty, 0)) as \"Qty to Deliver:Float:140\",\n `tabSales Order Item`.base_amount as \"Amount:Float:140\",\n `tabSales Order`.`delivery_date` as \"Expected Delivery Date:Date:120\",\n `tabSales Order Item`.item_name as \"Item Name::150\",\n `tabSales Order Item`.description as \"Description::200\",\n `tabSales Order Item`.item_group as \"Item Group:Link/Item Group:120\"\nfrom\n `tabSales Order`, `tabSales Order Item`\nwhere\n `tabSales Order Item`.`parent` = `tabSales Order`.`name`\n and `tabSales Order`.docstatus = 1\n and `tabSales Order`.status != \"Stopped\"\n and ifnull(`tabSales Order Item`.delivered_qty,0) < ifnull(`tabSales Order Item`.qty,0)\norder by `tabSales Order`.transaction_date asc", + "ref_doctype": "Delivery Note", + "report_name": "Ordered Items To Be Delivered", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.txt b/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.txt deleted file mode 100644 index a0a34b99a5c..00000000000 --- a/erpnext/stock/report/ordered_items_to_be_delivered/ordered_items_to_be_delivered.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-02-22 18:01:55", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "query": "select \n `tabSales Order`.`name` as \"Sales Order:Link/Sales Order:120\",\n `tabSales Order`.`customer` as \"Customer:Link/Customer:120\",\n `tabSales Order`.`transaction_date` as \"Date:Date\",\n `tabSales Order`.`project_name` as \"Project\",\n `tabSales Order Item`.item_code as \"Item:Link/Item:120\",\n `tabSales Order Item`.qty as \"Qty:Float:140\",\n `tabSales Order Item`.delivered_qty as \"Delivered Qty:Float:140\",\n (`tabSales Order Item`.qty - ifnull(`tabSales Order Item`.delivered_qty, 0)) as \"Qty to Deliver:Float:140\",\n `tabSales Order Item`.base_amount as \"Amount:Float:140\",\n `tabSales Order`.`delivery_date` as \"Expected Delivery Date:Date:120\",\n `tabSales Order Item`.item_name as \"Item Name::150\",\n `tabSales Order Item`.description as \"Description::200\",\n `tabSales Order Item`.item_group as \"Item Group:Link/Item Group:120\"\nfrom\n `tabSales Order`, `tabSales Order Item`\nwhere\n `tabSales Order Item`.`parent` = `tabSales Order`.`name`\n and `tabSales Order`.docstatus = 1\n and `tabSales Order`.status != \"Stopped\"\n and ifnull(`tabSales Order Item`.delivered_qty,0) < ifnull(`tabSales Order Item`.qty,0)\norder by `tabSales Order`.transaction_date asc", - "ref_doctype": "Delivery Note", - "report_name": "Ordered Items To Be Delivered", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Ordered Items To Be Delivered" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/purchase_in_transit/purchase_in_transit.json b/erpnext/stock/report/purchase_in_transit/purchase_in_transit.json new file mode 100644 index 00000000000..f80538503b7 --- /dev/null +++ b/erpnext/stock/report/purchase_in_transit/purchase_in_transit.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-05-06 12:09:05.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Purchase In Transit", + "owner": "Administrator", + "query": "SELECT\n pi.name as \"Purchase Invoice:Link/Purchase Invoice:120\",\n\tpi.posting_date as \"Posting Date:Date:100\",\n\tpi.credit_to as \"Supplier Account:Link/Account:120\",\n\tpi_item.item_code as \"Item Code:Link/Item:120\",\n\tpi_item.description as \"Description:Data:140\",\n\tpi_item.qty as \"Qty:Float:120\",\n\tpi_item.base_amount as \"Amount:Currency:120\",\n\tpi_item.purchase_order as \"Purchase Order:Link/Purchase Order:120\",\n\tpi_item.purchase_receipt as \"Purchase Receipt:Link/Purchase Receipt:120\",\n\tpr.posting_date as \"PR Posting Date:Date:130\",\n\tpi.company as \"Company:Link/Company:120\"\nFROM\n\t`tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item, `tabPurchase Receipt` pr\nWHERE\n\tpi.name = pi_item.parent and pi_item.purchase_receipt = pr.name\n\tand pi.docstatus = 1 and pr.posting_date > pi.posting_date\nORDER BY\n\tpi.name desc", + "ref_doctype": "Purchase Receipt", + "report_name": "Purchase In Transit", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/purchase_in_transit/purchase_in_transit.txt b/erpnext/stock/report/purchase_in_transit/purchase_in_transit.txt deleted file mode 100644 index d0e17e0ab3a..00000000000 --- a/erpnext/stock/report/purchase_in_transit/purchase_in_transit.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-05-06 12:09:05", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "query": "SELECT\n pi.name as \"Purchase Invoice:Link/Purchase Invoice:120\",\n\tpi.posting_date as \"Posting Date:Date:100\",\n\tpi.credit_to as \"Supplier Account:Link/Account:120\",\n\tpi_item.item_code as \"Item Code:Link/Item:120\",\n\tpi_item.description as \"Description:Data:140\",\n\tpi_item.qty as \"Qty:Float:120\",\n\tpi_item.base_amount as \"Amount:Currency:120\",\n\tpi_item.purchase_order as \"Purchase Order:Link/Purchase Order:120\",\n\tpi_item.purchase_receipt as \"Purchase Receipt:Link/Purchase Receipt:120\",\n\tpr.posting_date as \"PR Posting Date:Date:130\",\n\tpi.company as \"Company:Link/Company:120\"\nFROM\n\t`tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item, `tabPurchase Receipt` pr\nWHERE\n\tpi.name = pi_item.parent and pi_item.purchase_receipt = pr.name\n\tand pi.docstatus = 1 and pr.posting_date > pi.posting_date\nORDER BY\n\tpi.name desc", - "ref_doctype": "Purchase Receipt", - "report_name": "Purchase In Transit", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Purchase In Transit" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json b/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json new file mode 100644 index 00000000000..3fb562f2b51 --- /dev/null +++ b/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.json @@ -0,0 +1,17 @@ +{ + "add_total_row": 1, + "creation": "2013-02-22 18:01:55.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Purchase Order Items To Be Received", + "owner": "Administrator", + "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n\t`tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Order Item`.received_qty as \"Received Qty:Float:100\", \n\t(`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.received_qty, 0)) as \"Qty to Receive:Float:100\",\n `tabPurchase Order Item`.warehouse as \"Warehouse:Link/Warehouse:150\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\",\n `tabPurchase Order Item`.brand as \"Brand::100\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.received_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc", + "ref_doctype": "Purchase Receipt", + "report_name": "Purchase Order Items To Be Received", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt b/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt deleted file mode 100644 index 41aa05e6a2d..00000000000 --- a/erpnext/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "creation": "2013-02-22 18:01:55", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n\t`tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Order Item`.received_qty as \"Received Qty:Float:100\", \n\t(`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.received_qty, 0)) as \"Qty to Receive:Float:100\",\n `tabPurchase Order Item`.warehouse as \"Warehouse:Link/Warehouse:150\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\",\n `tabPurchase Order Item`.brand as \"Brand::100\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.received_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc", - "ref_doctype": "Purchase Receipt", - "report_name": "Purchase Order Items To Be Received", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Purchase Order Items To Be Received" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.json b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.json new file mode 100644 index 00000000000..cd564ef72a4 --- /dev/null +++ b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-13 18:45:44.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Purchase Receipt Trends", + "owner": "Administrator", + "ref_doctype": "Purchase Receipt", + "report_name": "Purchase Receipt Trends", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.txt b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.txt deleted file mode 100644 index 11e05925121..00000000000 --- a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-13 18:45:44", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Purchase Receipt", - "report_name": "Purchase Receipt Trends", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Purchase Receipt Trends" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.json b/erpnext/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.json new file mode 100644 index 00000000000..1f31d201326 --- /dev/null +++ b/erpnext/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.json @@ -0,0 +1,17 @@ +{ + "add_total_row": 1, + "creation": "2013-05-13 16:23:05.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Requested Items To Be Transferred", + "owner": "Administrator", + "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.ordered_qty as \"Transferred Qty:Float:100\", \n\t(mr_item.qty - ifnull(mr_item.ordered_qty, 0)) as \"Qty to Transfer:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Transfer\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand ifnull(mr_item.ordered_qty, 0) < ifnull(mr_item.qty, 0)\norder by mr.transaction_date asc", + "ref_doctype": "Stock Entry", + "report_name": "Requested Items To Be Transferred", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt b/erpnext/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt deleted file mode 100644 index c86de91790d..00000000000 --- a/erpnext/stock/report/requested_items_to_be_transferred/requested_items_to_be_transferred.txt +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "creation": "2013-05-13 16:23:05", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.ordered_qty as \"Transferred Qty:Float:100\", \n\t(mr_item.qty - ifnull(mr_item.ordered_qty, 0)) as \"Qty to Transfer:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Transfer\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand ifnull(mr_item.ordered_qty, 0) < ifnull(mr_item.qty, 0)\norder by mr.transaction_date asc", - "ref_doctype": "Stock Entry", - "report_name": "Requested Items To Be Transferred", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Requested Items To Be Transferred" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.json b/erpnext/stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.json new file mode 100644 index 00000000000..e47627ad5d0 --- /dev/null +++ b/erpnext/stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-01-14 10:52:58.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "json": "{\"filters\":[[\"Serial No\",\"status\",\"=\",\"Delivered\"]],\"columns\":[[\"name\",\"Serial No\"],[\"item_code\",\"Serial No\"],[\"amc_expiry_date\",\"Serial No\"],[\"maintenance_status\",\"Serial No\"],[\"delivery_document_no\",\"Serial No\"],[\"customer\",\"Serial No\"],[\"customer_name\",\"Serial No\"],[\"item_name\",\"Serial No\"],[\"description\",\"Serial No\"],[\"item_group\",\"Serial No\"],[\"brand\",\"Serial No\"]],\"sort_by\":\"Serial No.amc_expiry_date\",\"sort_order\":\"asc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Serial No Service Contract Expiry", + "owner": "Administrator", + "ref_doctype": "Serial No", + "report_name": "Serial No Service Contract Expiry", + "report_type": "Report Builder" +} \ No newline at end of file diff --git a/erpnext/stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.txt b/erpnext/stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.txt deleted file mode 100644 index b37b601726d..00000000000 --- a/erpnext/stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-01-14 10:52:58", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "json": "{\"filters\":[[\"Serial No\",\"status\",\"=\",\"Delivered\"]],\"columns\":[[\"name\",\"Serial No\"],[\"item_code\",\"Serial No\"],[\"amc_expiry_date\",\"Serial No\"],[\"maintenance_status\",\"Serial No\"],[\"delivery_document_no\",\"Serial No\"],[\"customer\",\"Serial No\"],[\"customer_name\",\"Serial No\"],[\"item_name\",\"Serial No\"],[\"description\",\"Serial No\"],[\"item_group\",\"Serial No\"],[\"brand\",\"Serial No\"]],\"sort_by\":\"Serial No.amc_expiry_date\",\"sort_order\":\"asc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Serial No", - "report_name": "Serial No Service Contract Expiry", - "report_type": "Report Builder" - }, - { - "doctype": "Report", - "name": "Serial No Service Contract Expiry" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/serial_no_status/serial_no_status.json b/erpnext/stock/report/serial_no_status/serial_no_status.json new file mode 100644 index 00000000000..047259c6d17 --- /dev/null +++ b/erpnext/stock/report/serial_no_status/serial_no_status.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-01-14 10:52:58.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "json": "{\"filters\":[],\"columns\":[[\"name\",\"Serial No\"],[\"item_code\",\"Serial No\"],[\"warehouse\",\"Serial No\"],[\"status\",\"Serial No\"],[\"item_name\",\"Serial No\"],[\"description\",\"Serial No\"],[\"item_group\",\"Serial No\"],[\"brand\",\"Serial No\"],[\"purchase_document_no\",\"Serial No\"],[\"purchase_date\",\"Serial No\"],[\"customer\",\"Serial No\"],[\"customer_name\",\"Serial No\"],[\"purchase_rate\",\"Serial No\"],[\"delivery_document_no\",\"Serial No\"],[\"delivery_date\",\"Serial No\"],[\"supplier\",\"Serial No\"],[\"supplier_name\",\"Serial No\"]],\"sort_by\":\"Serial No.name\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Serial No Status", + "owner": "Administrator", + "ref_doctype": "Serial No", + "report_name": "Serial No Status", + "report_type": "Report Builder" +} \ No newline at end of file diff --git a/erpnext/stock/report/serial_no_status/serial_no_status.txt b/erpnext/stock/report/serial_no_status/serial_no_status.txt deleted file mode 100644 index 68e4c2e3159..00000000000 --- a/erpnext/stock/report/serial_no_status/serial_no_status.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-01-14 10:52:58", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "json": "{\"filters\":[],\"columns\":[[\"name\",\"Serial No\"],[\"item_code\",\"Serial No\"],[\"warehouse\",\"Serial No\"],[\"status\",\"Serial No\"],[\"item_name\",\"Serial No\"],[\"description\",\"Serial No\"],[\"item_group\",\"Serial No\"],[\"brand\",\"Serial No\"],[\"purchase_document_no\",\"Serial No\"],[\"purchase_date\",\"Serial No\"],[\"customer\",\"Serial No\"],[\"customer_name\",\"Serial No\"],[\"purchase_rate\",\"Serial No\"],[\"delivery_document_no\",\"Serial No\"],[\"delivery_date\",\"Serial No\"],[\"supplier\",\"Serial No\"],[\"supplier_name\",\"Serial No\"]],\"sort_by\":\"Serial No.name\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Serial No", - "report_name": "Serial No Status", - "report_type": "Report Builder" - }, - { - "doctype": "Report", - "name": "Serial No Status" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.json b/erpnext/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.json new file mode 100644 index 00000000000..0e48a3c47d8 --- /dev/null +++ b/erpnext/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-01-14 10:52:58.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "json": "{\"filters\":[[\"Serial No\",\"status\",\"=\",\"Delivered\"]],\"columns\":[[\"name\",\"Serial No\"],[\"item_code\",\"Serial No\"],[\"warranty_expiry_date\",\"Serial No\"],[\"warranty_period\",\"Serial No\"],[\"maintenance_status\",\"Serial No\"],[\"purchase_document_no\",\"Serial No\"],[\"purchase_date\",\"Serial No\"],[\"supplier\",\"Serial No\"],[\"supplier_name\",\"Serial No\"],[\"delivery_document_no\",\"Serial No\"],[\"delivery_date\",\"Serial No\"],[\"customer\",\"Serial No\"],[\"customer_name\",\"Serial No\"],[\"item_name\",\"Serial No\"],[\"description\",\"Serial No\"],[\"item_group\",\"Serial No\"],[\"brand\",\"Serial No\"]],\"sort_by\":\"Serial No.warranty_expiry_date\",\"sort_order\":\"asc\",\"sort_by_next\":\"\",\"sort_order_next\":\"asc\"}", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Serial No Warranty Expiry", + "owner": "Administrator", + "ref_doctype": "Serial No", + "report_name": "Serial No Warranty Expiry", + "report_type": "Report Builder" +} \ No newline at end of file diff --git a/erpnext/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt b/erpnext/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt deleted file mode 100644 index 6471a58a1b0..00000000000 --- a/erpnext/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-01-14 10:52:58", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "json": "{\"filters\":[[\"Serial No\",\"status\",\"=\",\"Delivered\"]],\"columns\":[[\"name\",\"Serial No\"],[\"item_code\",\"Serial No\"],[\"warranty_expiry_date\",\"Serial No\"],[\"warranty_period\",\"Serial No\"],[\"maintenance_status\",\"Serial No\"],[\"purchase_document_no\",\"Serial No\"],[\"purchase_date\",\"Serial No\"],[\"supplier\",\"Serial No\"],[\"supplier_name\",\"Serial No\"],[\"delivery_document_no\",\"Serial No\"],[\"delivery_date\",\"Serial No\"],[\"customer\",\"Serial No\"],[\"customer_name\",\"Serial No\"],[\"item_name\",\"Serial No\"],[\"description\",\"Serial No\"],[\"item_group\",\"Serial No\"],[\"brand\",\"Serial No\"]],\"sort_by\":\"Serial No.warranty_expiry_date\",\"sort_order\":\"asc\",\"sort_by_next\":\"\",\"sort_order_next\":\"asc\"}", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Serial No", - "report_name": "Serial No Warranty Expiry", - "report_type": "Report Builder" - }, - { - "doctype": "Report", - "name": "Serial No Warranty Expiry" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/stock_ageing/stock_ageing.json b/erpnext/stock/report/stock_ageing/stock_ageing.json new file mode 100644 index 00000000000..af8b9c37e4e --- /dev/null +++ b/erpnext/stock/report/stock_ageing/stock_ageing.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-12-02 17:09:31.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Stock Ageing", + "owner": "Administrator", + "ref_doctype": "Item", + "report_name": "Stock Ageing", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/stock_ageing/stock_ageing.txt b/erpnext/stock/report/stock_ageing/stock_ageing.txt deleted file mode 100644 index 18a7ec8cb34..00000000000 --- a/erpnext/stock/report/stock_ageing/stock_ageing.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-12-02 17:09:31", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Item", - "report_name": "Stock Ageing", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Stock Ageing" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.json b/erpnext/stock/report/stock_ledger/stock_ledger.json new file mode 100644 index 00000000000..da2056ef607 --- /dev/null +++ b/erpnext/stock/report/stock_ledger/stock_ledger.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-11-29 17:08:23.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Stock Ledger", + "owner": "Administrator", + "ref_doctype": "Stock Ledger Entry", + "report_name": "Stock Ledger", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.txt b/erpnext/stock/report/stock_ledger/stock_ledger.txt deleted file mode 100644 index 7da9f93dba3..00000000000 --- a/erpnext/stock/report/stock_ledger/stock_ledger.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-11-29 17:08:23", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Stock Ledger Entry", - "report_name": "Stock Ledger", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Stock Ledger" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/stock_projected_qty/stock_projected_qty.json b/erpnext/stock/report/stock_projected_qty/stock_projected_qty.json new file mode 100644 index 00000000000..2b6be03329a --- /dev/null +++ b/erpnext/stock/report/stock_projected_qty/stock_projected_qty.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-12-04 18:21:56.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Stock Projected Qty", + "owner": "Administrator", + "ref_doctype": "Item", + "report_name": "Stock Projected Qty", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/stock_projected_qty/stock_projected_qty.txt b/erpnext/stock/report/stock_projected_qty/stock_projected_qty.txt deleted file mode 100644 index 4eb46c5ea0a..00000000000 --- a/erpnext/stock/report/stock_projected_qty/stock_projected_qty.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-12-04 18:21:56", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Item", - "report_name": "Stock Projected Qty", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Stock Projected Qty" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.json b/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.json new file mode 100644 index 00000000000..ff495d94bf0 --- /dev/null +++ b/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.json @@ -0,0 +1,16 @@ +{ + "add_total_row": 1, + "creation": "2013-11-29 15:45:39.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Supplier-Wise Sales Analytics", + "owner": "Administrator", + "ref_doctype": "Stock Ledger Entry", + "report_name": "Supplier-Wise Sales Analytics", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.txt b/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.txt deleted file mode 100644 index 53eeca7bf6b..00000000000 --- a/erpnext/stock/report/supplier_wise_sales_analytics/supplier_wise_sales_analytics.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-11-29 15:45:39", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "add_total_row": 1, - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Stock Ledger Entry", - "report_name": "Supplier-Wise Sales Analytics", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Supplier-Wise Sales Analytics" - } -] \ No newline at end of file diff --git a/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.json b/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.json new file mode 100644 index 00000000000..c91906f54e4 --- /dev/null +++ b/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.json @@ -0,0 +1,15 @@ +{ + "creation": "2013-06-05 11:00:31.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:28.000000", + "modified_by": "Administrator", + "module": "Stock", + "name": "Warehouse-Wise Stock Balance", + "owner": "Administrator", + "ref_doctype": "Stock Ledger Entry", + "report_name": "Warehouse-Wise Stock Balance", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.txt b/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.txt deleted file mode 100644 index c8e36eb95da..00000000000 --- a/erpnext/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-06-05 11:00:31", - "docstatus": 0, - "modified": "2014-03-07 15:30:28", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Stock", - "name": "__common__", - "ref_doctype": "Stock Ledger Entry", - "report_name": "Warehouse-Wise Stock Balance", - "report_type": "Script Report" - }, - { - "doctype": "Report", - "name": "Warehouse-Wise Stock Balance" - } -] \ No newline at end of file diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 822c8f288d4..34558fbbc48 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -17,53 +17,52 @@ _exceptions = frappe.local('stockledger_exceptions') def make_sl_entries(sl_entries, is_amended=None): if sl_entries: from erpnext.stock.utils import update_bin - + cancel = True if sl_entries[0].get("is_cancelled") == "Yes" else False if cancel: set_as_cancel(sl_entries[0].get('voucher_no'), sl_entries[0].get('voucher_type')) - + for sle in sl_entries: sle_id = None if sle.get('is_cancelled') == 'Yes': sle['actual_qty'] = -flt(sle['actual_qty']) - + if sle.get("actual_qty"): sle_id = make_entry(sle) - + args = sle.copy() args.update({ "sle_id": sle_id, "is_amended": is_amended }) update_bin(args) - if cancel: - delete_cancelled_entry(sl_entries[0].get('voucher_type'), + delete_cancelled_entry(sl_entries[0].get('voucher_type'), sl_entries[0].get('voucher_no')) - + def set_as_cancel(voucher_type, voucher_no): frappe.db.sql("""update `tabStock Ledger Entry` set is_cancelled='Yes', modified=%s, modified_by=%s - where voucher_no=%s and voucher_type=%s""", + where voucher_no=%s and voucher_type=%s""", (now(), frappe.session.user, voucher_type, voucher_no)) - + def make_entry(args): args.update({"doctype": "Stock Ledger Entry"}) - sle = frappe.bean([args]) + sle = frappe.get_doc(args) sle.ignore_permissions = 1 sle.insert() sle.submit() - return sle.doc.name - + return sle.name + def delete_cancelled_entry(voucher_type, voucher_no): - frappe.db.sql("""delete from `tabStock Ledger Entry` + frappe.db.sql("""delete from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no)) def update_entries_after(args, verbose=1): """ - update valution rate and qty after transaction + update valution rate and qty after transaction from the current time-bucket onwards - + args = { "item_code": "ABC", "warehouse": "XYZ", @@ -73,15 +72,15 @@ def update_entries_after(args, verbose=1): """ if not _exceptions: frappe.local.stockledger_exceptions = [] - + previous_sle = get_sle_before_datetime(args) - + qty_after_transaction = flt(previous_sle.get("qty_after_transaction")) valuation_rate = flt(previous_sle.get("valuation_rate")) stock_queue = json.loads(previous_sle.get("stock_queue") or "[]") stock_value = flt(previous_sle.get("stock_value")) prev_stock_value = flt(previous_sle.get("stock_value")) - + entries_to_fix = get_sle_after_datetime(previous_sle or \ {"item_code": args["item_code"], "warehouse": args["warehouse"]}, for_update=True) @@ -90,7 +89,7 @@ def update_entries_after(args, verbose=1): for sle in entries_to_fix: if sle.serial_no or not cint(frappe.db.get_default("allow_negative_stock")): - # validate negative stock for serialized items, fifo valuation + # validate negative stock for serialized items, fifo valuation # or when negative stock is not allowed for moving average if not validate_negative_stock(qty_after_transaction, sle): qty_after_transaction += flt(sle.actual_qty) @@ -102,9 +101,9 @@ def update_entries_after(args, verbose=1): valuation_rate = get_moving_average_values(qty_after_transaction, sle, valuation_rate) else: valuation_rate = get_fifo_values(qty_after_transaction, sle, stock_queue) - + qty_after_transaction += flt(sle.actual_qty) - + # get stock value if sle.serial_no: stock_value = qty_after_transaction * valuation_rate @@ -113,44 +112,44 @@ def update_entries_after(args, verbose=1): (qty_after_transaction * valuation_rate) or 0 else: stock_value = sum((flt(batch[0]) * flt(batch[1]) for batch in stock_queue)) - + # rounding as per precision from frappe.model.meta import get_field_precision - meta = frappe.get_doctype("Stock Ledger Entry") - - stock_value = flt(stock_value, get_field_precision(meta.get_field("stock_value"), + meta = frappe.get_meta("Stock Ledger Entry") + + stock_value = flt(stock_value, get_field_precision(meta.get_field("stock_value"), frappe._dict({"fields": sle}))) - + stock_value_difference = stock_value - prev_stock_value prev_stock_value = stock_value - + # update current sle frappe.db.sql("""update `tabStock Ledger Entry` set qty_after_transaction=%s, valuation_rate=%s, stock_queue=%s, - stock_value=%s, stock_value_difference=%s where name=%s""", + stock_value=%s, stock_value_difference=%s where name=%s""", (qty_after_transaction, valuation_rate, json.dumps(stock_queue), stock_value, stock_value_difference, sle.name)) - + if _exceptions: _raise_exceptions(args, verbose) - + # update bin - if not frappe.db.exists({"doctype": "Bin", "item_code": args["item_code"], + if not frappe.db.exists({"doctype": "Bin", "item_code": args["item_code"], "warehouse": args["warehouse"]}): - bin_wrapper = frappe.bean([{ + bin_wrapper = frappe.get_doc({ "doctype": "Bin", "item_code": args["item_code"], "warehouse": args["warehouse"], - }]) + }) bin_wrapper.ignore_permissions = 1 bin_wrapper.insert() - + frappe.db.sql("""update `tabBin` set valuation_rate=%s, actual_qty=%s, - stock_value=%s, + stock_value=%s, projected_qty = (actual_qty + indented_qty + ordered_qty + planned_qty - reserved_qty) where item_code=%s and warehouse=%s""", (valuation_rate, qty_after_transaction, stock_value, args["item_code"], args["warehouse"])) - + def get_sle_before_datetime(args, for_update=False): """ get previous stock ledger entry before current time-bucket @@ -164,24 +163,28 @@ def get_sle_before_datetime(args, for_update=False): sle = get_stock_ledger_entries(args, ["timestamp(posting_date, posting_time) < timestamp(%(posting_date)s, %(posting_time)s)"], "desc", "limit 1", for_update=for_update) - + return sle and sle[0] or frappe._dict() - + def get_sle_after_datetime(args, for_update=False): """get Stock Ledger Entries after a particular datetime, for reposting""" - # NOTE: using for update of - return get_stock_ledger_entries(args, - ["timestamp(posting_date, posting_time) > timestamp(%(posting_date)s, %(posting_time)s)"], - "asc", for_update=for_update) - + # NOTE: using for update of + conditions = ["timestamp(posting_date, posting_time) > timestamp(%(posting_date)s, %(posting_time)s)"] + + # Excluding name: Workaround for MariaDB timestamp() floating microsecond issue + if args.get("name"): + conditions.append("name!=%(name)s") + + return get_stock_ledger_entries(args, conditions, "asc", for_update=for_update) + def get_stock_ledger_entries(args, conditions=None, order="desc", limit=None, for_update=False): """get stock ledger entries filtered by specific posting datetime conditions""" if not args.get("posting_date"): args["posting_date"] = "1900-01-01" if not args.get("posting_time"): args["posting_time"] = "00:00" - - return frappe.db.sql("""select * from `tabStock Ledger Entry` + + return frappe.db.sql("""select *, timestamp(posting_date, posting_time) as "timestamp" from `tabStock Ledger Entry` where item_code = %%(item_code)s and warehouse = %%(warehouse)s and ifnull(is_cancelled, 'No')='No' @@ -193,7 +196,7 @@ def get_stock_ledger_entries(args, conditions=None, order="desc", limit=None, fo "for_update": for_update and "for update" or "", "order": order }, args, as_dict=1) - + def validate_negative_stock(qty_after_transaction, sle): """ validate negative stock for entries current datetime onwards @@ -203,7 +206,7 @@ def validate_negative_stock(qty_after_transaction, sle): if not _exceptions: frappe.local.stockledger_exceptions = [] - + if diff < 0 and abs(diff) > 0.0001: # negative stock! exc = sle.copy().update({"diff": diff}) @@ -211,12 +214,12 @@ def validate_negative_stock(qty_after_transaction, sle): return False else: return True - + def get_serialized_values(qty_after_transaction, sle, valuation_rate): incoming_rate = flt(sle.incoming_rate) actual_qty = flt(sle.actual_qty) serial_no = cstr(sle.serial_no).split("\n") - + if incoming_rate < 0: # wrong incoming rate incoming_rate = valuation_rate @@ -226,7 +229,7 @@ def get_serialized_values(qty_after_transaction, sle, valuation_rate): incoming_rate = flt(frappe.db.sql("""select avg(ifnull(purchase_rate, 0)) from `tabSerial No` where name in (%s)""" % (", ".join(["%s"]*len(serial_no))), tuple(serial_no))[0][0]) - + if incoming_rate and not valuation_rate: valuation_rate = incoming_rate else: @@ -237,33 +240,33 @@ def get_serialized_values(qty_after_transaction, sle, valuation_rate): # calculate new valuation rate only if stock value is positive # else it remains the same as that of previous entry valuation_rate = new_stock_value / new_stock_qty - + return valuation_rate - + def get_moving_average_values(qty_after_transaction, sle, valuation_rate): incoming_rate = flt(sle.incoming_rate) - actual_qty = flt(sle.actual_qty) - + actual_qty = flt(sle.actual_qty) + if not incoming_rate: # In case of delivery/stock issue in_rate = 0 or wrong incoming rate incoming_rate = valuation_rate - + elif qty_after_transaction < 0: # if negative stock, take current valuation rate as incoming rate valuation_rate = incoming_rate - + new_stock_qty = qty_after_transaction + actual_qty new_stock_value = qty_after_transaction * valuation_rate + actual_qty * incoming_rate - + if new_stock_qty > 0 and new_stock_value > 0: valuation_rate = new_stock_value / flt(new_stock_qty) elif new_stock_qty <= 0: valuation_rate = 0.0 - + # NOTE: val_rate is same as previous entry if new stock value is negative - + return valuation_rate - + def get_fifo_values(qty_after_transaction, sle, stock_queue): incoming_rate = flt(sle.incoming_rate) actual_qty = flt(sle.actual_qty) @@ -282,9 +285,9 @@ def get_fifo_values(qty_after_transaction, sle, stock_queue): while qty_to_pop: if not stock_queue: stock_queue.append([0, 0]) - + batch = stock_queue[0] - + if 0 < batch[0] <= qty_to_pop: # if batch qty > 0 # not enough or exactly same qty in current batch, clear batch @@ -296,7 +299,7 @@ def get_fifo_values(qty_after_transaction, sle, stock_queue): incoming_cost += flt(qty_to_pop) * flt(batch[1]) batch[0] -= qty_to_pop qty_to_pop = 0 - + stock_value = sum((flt(batch[0]) * flt(batch[1]) for batch in stock_queue)) stock_qty = sum((flt(batch[0]) for batch in stock_queue)) @@ -306,9 +309,9 @@ def get_fifo_values(qty_after_transaction, sle, stock_queue): def _raise_exceptions(args, verbose=1): deficiency = min(e["diff"] for e in _exceptions) - msg = """Negative stock error: + msg = """Negative stock error: Cannot complete this transaction because stock will start - becoming negative (%s) for Item %s in Warehouse + becoming negative (%s) for Item %s in Warehouse %s on %s %s in Transaction %s %s. Total Quantity Deficiency: %s""" % \ (_exceptions[0]["diff"], args.get("item_code"), args.get("warehouse"), @@ -319,13 +322,13 @@ def _raise_exceptions(args, verbose=1): msgprint(msg, raise_exception=NegativeStockError) else: raise NegativeStockError, msg - + def get_previous_sle(args, for_update=False): """ - get the last sle on or before the current time-bucket, + get the last sle on or before the current time-bucket, to get actual qty before transaction, this function is called from various transaction like stock entry, reco etc - + args = { "item_code": "ABC", "warehouse": "XYZ", @@ -335,7 +338,7 @@ def get_previous_sle(args, for_update=False): } """ if not args.get("sle"): args["sle"] = "" - + sle = get_stock_ledger_entries(args, ["name != %(sle)s", "timestamp(posting_date, posting_time) <= timestamp(%(posting_date)s, %(posting_time)s)"], "desc", "limit 1", for_update=for_update) diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index 3a0766aca8a..bce94f389d0 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -9,48 +9,46 @@ from frappe.defaults import get_global_default from frappe.utils.email_lib import sendmail class InvalidWarehouseCompany(frappe.ValidationError): pass - + def get_stock_balance_on(warehouse, posting_date=None): if not posting_date: posting_date = nowdate() - + stock_ledger_entries = frappe.db.sql(""" - SELECT + SELECT item_code, stock_value - FROM + FROM `tabStock Ledger Entry` - WHERE + WHERE warehouse=%s AND posting_date <= %s ORDER BY timestamp(posting_date, posting_time) DESC, name DESC """, (warehouse, posting_date), as_dict=1) - + sle_map = {} for sle in stock_ledger_entries: sle_map.setdefault(sle.item_code, flt(sle.stock_value)) - + return sum(sle_map.values()) - + def get_latest_stock_balance(): bin_map = {} - for d in frappe.db.sql("""SELECT item_code, warehouse, stock_value as stock_value + for d in frappe.db.sql("""SELECT item_code, warehouse, stock_value as stock_value FROM tabBin""", as_dict=1): bin_map.setdefault(d.warehouse, {}).setdefault(d.item_code, flt(d.stock_value)) - + return bin_map - + def get_bin(item_code, warehouse): bin = frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse}) if not bin: - bin_wrapper = frappe.bean([{ + bin_obj = frappe.get_doc({ "doctype": "Bin", "item_code": item_code, "warehouse": warehouse, - }]) - bin_wrapper.ignore_permissions = 1 - bin_wrapper.insert() - bin_obj = bin_wrapper.make_controller() + }) + bin_obj.ignore_permissions = 1 + bin_obj.insert() else: - from frappe.model.code import get_obj - bin_obj = get_obj('Bin', bin) + bin_obj = frappe.get_doc('Bin', bin) return bin_obj def update_bin(args): @@ -60,18 +58,18 @@ def update_bin(args): bin.update_stock(args) return bin else: - msgprint("[Stock Update] Ignored %s since it is not a stock item" + msgprint("[Stock Update] Ignored %s since it is not a stock item" % args.get("item_code")) def get_incoming_rate(args): """Get Incoming Rate based on valuation method""" from erpnext.stock.stock_ledger import get_previous_sle - + in_rate = 0 if args.get("serial_no"): in_rate = get_avg_purchase_rate(args.get("serial_no")) elif args.get("bom_no"): - result = frappe.db.sql("""select ifnull(total_cost, 0) / ifnull(quantity, 1) + result = frappe.db.sql("""select ifnull(total_cost, 0) / ifnull(quantity, 1) from `tabBOM` where name = %s and docstatus=1 and is_active=1""", args.get("bom_no")) in_rate = result and flt(result[0][0]) or 0 else: @@ -86,12 +84,12 @@ def get_incoming_rate(args): elif valuation_method == 'Moving Average': in_rate = previous_sle.get('valuation_rate') or 0 return in_rate - + def get_avg_purchase_rate(serial_nos): """get average value of serial numbers""" - + serial_nos = get_valid_serial_nos(serial_nos) - return flt(frappe.db.sql("""select avg(ifnull(purchase_rate, 0)) from `tabSerial No` + return flt(frappe.db.sql("""select avg(ifnull(purchase_rate, 0)) from `tabSerial No` where name in (%s)""" % ", ".join(["%s"] * len(serial_nos)), tuple(serial_nos))[0][0]) @@ -101,11 +99,11 @@ def get_valuation_method(item_code): if not val_method: val_method = get_global_default('valuation_method') or "FIFO" return val_method - + def get_fifo_rate(previous_stock_queue, qty): """get FIFO (average) Rate from Queue""" if qty >= 0: - total = sum(f[0] for f in previous_stock_queue) + total = sum(f[0] for f in previous_stock_queue) return total and sum(f[0] * f[1] for f in previous_stock_queue) / flt(total) or 0.0 else: outgoing_cost = 0 @@ -125,12 +123,12 @@ def get_fifo_rate(previous_stock_queue, qty): qty_to_pop = 0 # if queue gets blank and qty_to_pop remaining, get average rate of full queue return outgoing_cost / abs(qty) - qty_to_pop - + def get_valid_serial_nos(sr_nos, qty=0, item_code=''): """split serial nos, validate and return list of valid serial nos""" # TODO: remove duplicates in client side serial_nos = cstr(sr_nos).strip().replace(',', '\n').split('\n') - + valid_serial_nos = [] for val in serial_nos: if val: @@ -139,12 +137,12 @@ def get_valid_serial_nos(sr_nos, qty=0, item_code=''): msgprint("You have entered duplicate serial no: '%s'" % val, raise_exception=1) else: valid_serial_nos.append(val) - + if qty and len(valid_serial_nos) != abs(qty): msgprint("Please enter serial nos for " + cstr(abs(qty)) + " quantity against item code: " + item_code, raise_exception=1) - + return valid_serial_nos def validate_warehouse_company(warehouse, company): @@ -153,48 +151,48 @@ def validate_warehouse_company(warehouse, company): frappe.msgprint(_("Warehouse does not belong to company.") + " (" + \ warehouse + ", " + company +")", raise_exception=InvalidWarehouseCompany) -def get_sales_bom_buying_amount(item_code, warehouse, voucher_type, voucher_no, voucher_detail_no, +def get_sales_bom_buying_amount(item_code, warehouse, voucher_type, voucher_no, voucher_detail_no, stock_ledger_entries, item_sales_bom): # sales bom item buying_amount = 0.0 for bom_item in item_sales_bom[item_code]: if bom_item.get("parent_detail_docname")==voucher_detail_no: - buying_amount += get_buying_amount(voucher_type, voucher_no, voucher_detail_no, + buying_amount += get_buying_amount(voucher_type, voucher_no, voucher_detail_no, stock_ledger_entries.get((bom_item.item_code, warehouse), [])) return buying_amount - + def get_buying_amount(voucher_type, voucher_no, item_row, stock_ledger_entries): # IMP NOTE - # stock_ledger_entries should already be filtered by item_code and warehouse and + # stock_ledger_entries should already be filtered by item_code and warehouse and # sorted by posting_date desc, posting_time desc for i, sle in enumerate(stock_ledger_entries): if sle.voucher_type == voucher_type and sle.voucher_no == voucher_no and \ sle.voucher_detail_no == item_row: previous_stock_value = len(stock_ledger_entries) > i+1 and \ flt(stock_ledger_entries[i+1].stock_value) or 0.0 - buying_amount = previous_stock_value - flt(sle.stock_value) - + buying_amount = previous_stock_value - flt(sle.stock_value) + return buying_amount return 0.0 - + def reorder_item(): """ Reorder item if stock reaches reorder level""" if getattr(frappe.local, "auto_indent", None) is None: frappe.local.auto_indent = cint(frappe.db.get_value('Stock Settings', None, 'auto_indent')) - + if frappe.local.auto_indent: material_requests = {} bin_list = frappe.db.sql("""select item_code, warehouse, projected_qty from tabBin where ifnull(item_code, '') != '' and ifnull(warehouse, '') != '' - and exists (select name from `tabItem` - where `tabItem`.name = `tabBin`.item_code and + and exists (select name from `tabItem` + where `tabItem`.name = `tabBin`.item_code and is_stock_item='Yes' and (is_purchase_item='Yes' or is_sub_contracted_item='Yes') and - (ifnull(end_of_life, '')='' or end_of_life > now()))""", as_dict=True) + (ifnull(end_of_life, '')='' or end_of_life > curdate()))""", as_dict=True) for bin in bin_list: #check if re-order is required - item_reorder = frappe.db.get("Item Reorder", + item_reorder = frappe.db.get("Item Reorder", {"parent": bin.item_code, "warehouse": bin.warehouse}) if item_reorder: reorder_level = item_reorder.warehouse_reorder_level @@ -204,15 +202,15 @@ def reorder_item(): reorder_level, reorder_qty = frappe.db.get_value("Item", bin.item_code, ["re_order_level", "re_order_qty"]) material_request_type = "Purchase" - + if flt(reorder_level) and flt(bin.projected_qty) < flt(reorder_level): if flt(reorder_level) - flt(bin.projected_qty) > flt(reorder_qty): reorder_qty = flt(reorder_level) - flt(bin.projected_qty) - + company = frappe.db.get_value("Warehouse", bin.warehouse, "company") or \ frappe.defaults.get_defaults()["company"] or \ frappe.db.sql("""select name from tabCompany limit 1""")[0][0] - + material_requests.setdefault(material_request_type, frappe._dict()).setdefault( company, []).append(frappe._dict({ "item_code": bin.item_code, @@ -220,7 +218,7 @@ def reorder_item(): "reorder_qty": reorder_qty }) ) - + create_material_request(material_requests) def create_material_request(material_requests): @@ -236,21 +234,19 @@ def create_material_request(material_requests): items = material_requests[request_type][company] if not items: continue - - mr = [{ - "doctype": "Material Request", + + mr = frappe.new_doc("Material Request") + mr.update({ "company": company, "fiscal_year": current_fiscal_year, "transaction_date": nowdate(), "material_request_type": request_type - }] - + }) + for d in items: - item = frappe.doc("Item", d.item_code) - mr.append({ + item = frappe.get_doc("Item", d.item_code) + mr.append("indent_details", { "doctype": "Material Request Item", - "parenttype": "Material Request", - "parentfield": "indent_details", "item_code": d.item_code, "schedule_date": add_days(nowdate(),cint(item.lead_time_days)), "uom": item.stock_uom, @@ -261,11 +257,10 @@ def create_material_request(material_requests): "qty": d.reorder_qty, "brand": item.brand, }) - - mr_bean = frappe.bean(mr) - mr_bean.insert() - mr_bean.submit() - mr_list.append(mr_bean) + + mr.insert() + mr.submit() + mr_list.append(mr) except: if frappe.local.message_log: @@ -276,41 +271,41 @@ def create_material_request(material_requests): if mr_list: if getattr(frappe.local, "reorder_email_notify", None) is None: - frappe.local.reorder_email_notify = cint(frappe.db.get_value('Stock Settings', None, + frappe.local.reorder_email_notify = cint(frappe.db.get_value('Stock Settings', None, 'reorder_email_notify')) - + if(frappe.local.reorder_email_notify): send_email_notification(mr_list) if exceptions_list: notify_errors(exceptions_list) - + def send_email_notification(mr_list): """ Notify user about auto creation of indent""" - - email_list = frappe.db.sql_list("""select distinct r.parent + + email_list = frappe.db.sql_list("""select distinct r.parent from tabUserRole r, tabUser p where p.name = r.parent and p.enabled = 1 and p.docstatus < 2 - and r.role in ('Purchase Manager','Material Manager') + and r.role in ('Purchase Manager','Material Manager') and p.name not in ('Administrator', 'All', 'Guest')""") - + msg="""

Following Material Requests has been raised automatically \ based on item reorder level:

""" for mr in mr_list: - msg += "

" + mr.doc.name + """

+ msg += "

" + mr.name + """

""" - for item in mr.doclist.get({"parentfield": "indent_details"}): + for item in mr.get("indent_details"): msg += "" msg += "
Item CodeWarehouseQtyUOM
" + item.item_code + "" + item.warehouse + "" + \ cstr(item.qty) + "" + cstr(item.uom) + "
" sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg) - + def notify_errors(exceptions_list): subject = "[Important] [ERPNext] Error(s) while creating Material Requests based on Re-order Levels" msg = """Dear System Manager, An error occured for certain Items while creating Material Requests based on Re-order level. - + Please rectify these issues: --- diff --git a/erpnext/support/doctype/customer_issue/customer_issue.json b/erpnext/support/doctype/customer_issue/customer_issue.json new file mode 100644 index 00000000000..1f357444ea3 --- /dev/null +++ b/erpnext/support/doctype/customer_issue/customer_issue.json @@ -0,0 +1,419 @@ +{ + "allow_import": 1, + "autoname": "naming_series:", + "creation": "2013-01-10 16:34:30.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "customer_section", + "fieldtype": "Section Break", + "label": "Customer", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "in_filter": 0, + "label": "Series", + "no_copy": 1, + "oldfieldname": "naming_series", + "oldfieldtype": "Select", + "options": "\nCI/2010-2011/", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "default": "Open", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nOpen\nClosed\nWork In Progress\nCancelled", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "default": "Today", + "fieldname": "complaint_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Issue Date", + "oldfieldname": "complaint_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "customer_address", + "fieldtype": "Link", + "label": "Customer Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "contact_person", + "fieldtype": "Link", + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "issue_details", + "fieldtype": "Section Break", + "label": "Issue Details", + "oldfieldtype": "Section Break", + "options": "icon-ticket", + "permlevel": 0 + }, + { + "fieldname": "complaint", + "fieldtype": "Small Text", + "label": "Issue", + "no_copy": 1, + "oldfieldname": "complaint", + "oldfieldtype": "Small Text", + "permlevel": 0, + "reqd": 1 + }, + { + "description": "Item, Warranty, AMC (Annual Maintenance Contract) details will be automatically fetched when Serial Number is selected.", + "fieldname": "serial_no", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Serial No", + "options": "Serial No", + "permlevel": 0 + }, + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "depends_on": "eval:doc.item_code", + "fieldname": "item_name", + "fieldtype": "Data", + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "eval:doc.item_code", + "fieldname": "description", + "fieldtype": "Small Text", + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1, + "width": "300px" + }, + { + "fieldname": "warranty_amc_status", + "fieldtype": "Select", + "hidden": 0, + "in_filter": 1, + "in_list_view": 1, + "label": "Warranty / AMC Status", + "options": "\nUnder Warranty\nOut of Warranty\nUnder AMC\nOut of AMC", + "permlevel": 0 + }, + { + "fieldname": "warranty_expiry_date", + "fieldtype": "Date", + "label": "Warranty Expiry Date", + "permlevel": 0 + }, + { + "fieldname": "amc_expiry_date", + "fieldtype": "Date", + "label": "AMC Expiry Date", + "permlevel": 0 + }, + { + "description": "To assign this issue, use the \"Assign\" button in the sidebar.", + "fieldname": "resolution_section", + "fieldtype": "Section Break", + "label": "Resolution", + "oldfieldtype": "Section Break", + "options": "icon-thumbs-up", + "permlevel": 0 + }, + { + "fieldname": "resolution_date", + "fieldtype": "Datetime", + "in_filter": 1, + "label": "Resolution Date", + "no_copy": 1, + "oldfieldname": "resolution_date", + "oldfieldtype": "Date", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "resolved_by", + "fieldtype": "Link", + "in_filter": 1, + "label": "Resolved By", + "no_copy": 1, + "oldfieldname": "resolved_by", + "oldfieldtype": "Link", + "options": "User", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "resolution_details", + "fieldtype": "Text", + "label": "Resolution Details", + "no_copy": 1, + "oldfieldname": "resolution_details", + "oldfieldtype": "Text", + "permlevel": 0 + }, + { + "fieldname": "contact_info", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "depends_on": "customer", + "fieldname": "customer_name", + "fieldtype": "Data", + "label": "Customer Name", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "customer", + "description": "Add / Edit", + "fieldname": "customer_group", + "fieldtype": "Link", + "label": "Customer Group", + "options": "Customer Group", + "permlevel": 0, + "print_hide": 1, + "reqd": 0 + }, + { + "depends_on": "customer", + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "in_filter": 1, + "label": "Territory", + "oldfieldname": "territory", + "oldfieldtype": "Link", + "options": "Territory", + "permlevel": 0, + "print_hide": 1, + "reqd": 0, + "search_index": 1 + }, + { + "depends_on": "customer", + "fieldname": "contact_display", + "fieldtype": "Small Text", + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "customer", + "fieldname": "contact_mobile", + "fieldtype": "Data", + "label": "Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "customer", + "fieldname": "contact_email", + "fieldtype": "Data", + "label": "Contact Email", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "depends_on": "customer", + "description": "If different than customer address", + "fieldname": "service_address", + "fieldtype": "Small Text", + "label": "Service Address", + "oldfieldname": "service_address", + "oldfieldtype": "Small Text", + "permlevel": 0 + }, + { + "depends_on": "customer", + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 0, + "label": "Address", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "options": "icon-file-text", + "permlevel": 0 + }, + { + "fieldname": "col_break5", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "col_break6", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "complaint_raised_by", + "fieldtype": "Data", + "label": "Raised By", + "oldfieldname": "complaint_raised_by", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "from_company", + "fieldtype": "Data", + "label": "From Company", + "oldfieldname": "from_company", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "hidden": 1, + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "width": "150px" + } + ], + "icon": "icon-bug", + "idx": 1, + "is_submittable": 0, + "modified": "2014-01-20 17:48:35.000000", + "modified_by": "Administrator", + "module": "Support", + "name": "Customer Issue", + "owner": "harshada@webnotestech.com", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Maintenance User", + "submit": 0, + "write": 1 + } + ], + "search_fields": "status,customer,customer_name,territory" +} \ No newline at end of file diff --git a/erpnext/support/doctype/customer_issue/customer_issue.py b/erpnext/support/doctype/customer_issue/customer_issue.py index 128accd1447..7c6e1b256c4 100644 --- a/erpnext/support/doctype/customer_issue/customer_issue.py +++ b/erpnext/support/doctype/customer_issue/customer_issue.py @@ -11,39 +11,36 @@ from frappe.utils import today from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class CustomerIssue(TransactionBase): def validate(self): - if session['user'] != 'Guest' and not self.doc.customer: + if session['user'] != 'Guest' and not self.customer: msgprint("Please select Customer from whom issue is raised", raise_exception=True) - if self.doc.status=="Closed" and \ - frappe.db.get_value("Customer Issue", self.doc.name, "status")!="Closed": - self.doc.resolution_date = today() - self.doc.resolved_by = frappe.session.user + if self.status=="Closed" and \ + frappe.db.get_value("Customer Issue", self.name, "status")!="Closed": + self.resolution_date = today() + self.resolved_by = frappe.session.user def on_cancel(self): lst = frappe.db.sql("""select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t2.prevdoc_docname = %s and t1.docstatus!=2""", - (self.doc.name)) + (self.name)) if lst: lst1 = ','.join([x[0] for x in lst]) msgprint("Maintenance Visit No. "+lst1+" already created against this customer issue. So can not be Cancelled") raise Exception else: - frappe.db.set(self.doc, 'status', 'Cancelled') + frappe.db.set(self, 'status', 'Cancelled') def on_update(self): pass @frappe.whitelist() -def make_maintenance_visit(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist +def make_maintenance_visit(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc visit = frappe.db.sql("""select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 @@ -51,7 +48,7 @@ def make_maintenance_visit(source_name, target_doclist=None): and t1.docstatus=1 and t1.completion_status='Fully Completed'""", source_name) if not visit: - doclist = get_mapped_doclist("Customer Issue", source_name, { + doclist = get_mapped_doc("Customer Issue", source_name, { "Customer Issue": { "doctype": "Maintenance Visit", "field_map": { @@ -60,6 +57,6 @@ def make_maintenance_visit(source_name, target_doclist=None): "name": "prevdoc_docname" } } - }, target_doclist) + }, target_doc) - return [d.fields for d in doclist] \ No newline at end of file + return doclist \ No newline at end of file diff --git a/erpnext/support/doctype/customer_issue/customer_issue.txt b/erpnext/support/doctype/customer_issue/customer_issue.txt deleted file mode 100644 index 90ac593ce9e..00000000000 --- a/erpnext/support/doctype/customer_issue/customer_issue.txt +++ /dev/null @@ -1,438 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:30", - "docstatus": 0, - "modified": "2014-01-20 17:48:35", - "modified_by": "Administrator", - "owner": "harshada@webnotestech.com" - }, - { - "allow_import": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "icon": "icon-bug", - "is_submittable": 0, - "module": "Support", - "name": "__common__", - "search_fields": "status,customer,customer_name,territory" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Customer Issue", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Customer Issue", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Maintenance User", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Customer Issue" - }, - { - "doctype": "DocField", - "fieldname": "customer_section", - "fieldtype": "Section Break", - "label": "Customer", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "in_filter": 0, - "label": "Series", - "no_copy": 1, - "oldfieldname": "naming_series", - "oldfieldtype": "Select", - "options": "\nCI/2010-2011/", - "reqd": 1, - "search_index": 0 - }, - { - "default": "Open", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nOpen\nClosed\nWork In Progress\nCancelled", - "reqd": 1, - "search_index": 1 - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "complaint_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Issue Date", - "oldfieldname": "complaint_date", - "oldfieldtype": "Date", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer_address", - "fieldtype": "Link", - "label": "Customer Address", - "options": "Address", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "label": "Contact Person", - "options": "Contact", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "issue_details", - "fieldtype": "Section Break", - "label": "Issue Details", - "oldfieldtype": "Section Break", - "options": "icon-ticket" - }, - { - "doctype": "DocField", - "fieldname": "complaint", - "fieldtype": "Small Text", - "label": "Issue", - "no_copy": 1, - "oldfieldname": "complaint", - "oldfieldtype": "Small Text", - "reqd": 1 - }, - { - "description": "Item, Warranty, AMC (Annual Maintenance Contract) details will be automatically fetched when Serial Number is selected.", - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Serial No", - "options": "Serial No" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "depends_on": "eval:doc.item_code", - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "depends_on": "eval:doc.item_code", - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "read_only": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "warranty_amc_status", - "fieldtype": "Select", - "hidden": 0, - "in_filter": 1, - "in_list_view": 1, - "label": "Warranty / AMC Status", - "options": "\nUnder Warranty\nOut of Warranty\nUnder AMC\nOut of AMC" - }, - { - "doctype": "DocField", - "fieldname": "warranty_expiry_date", - "fieldtype": "Date", - "label": "Warranty Expiry Date" - }, - { - "doctype": "DocField", - "fieldname": "amc_expiry_date", - "fieldtype": "Date", - "label": "AMC Expiry Date" - }, - { - "description": "To assign this issue, use the \"Assign\" button in the sidebar.", - "doctype": "DocField", - "fieldname": "resolution_section", - "fieldtype": "Section Break", - "label": "Resolution", - "oldfieldtype": "Section Break", - "options": "icon-thumbs-up" - }, - { - "doctype": "DocField", - "fieldname": "resolution_date", - "fieldtype": "Datetime", - "in_filter": 1, - "label": "Resolution Date", - "no_copy": 1, - "oldfieldname": "resolution_date", - "oldfieldtype": "Date", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "resolved_by", - "fieldtype": "Link", - "in_filter": 1, - "label": "Resolved By", - "no_copy": 1, - "oldfieldname": "resolved_by", - "oldfieldtype": "Link", - "options": "User", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "resolution_details", - "fieldtype": "Text", - "label": "Resolution Details", - "no_copy": 1, - "oldfieldname": "resolution_details", - "oldfieldtype": "Text" - }, - { - "doctype": "DocField", - "fieldname": "contact_info", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn" - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "label": "Customer Name", - "read_only": 1 - }, - { - "depends_on": "customer", - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "label": "Customer Group", - "options": "Customer Group", - "print_hide": 1, - "reqd": 0 - }, - { - "depends_on": "customer", - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "in_filter": 1, - "label": "Territory", - "oldfieldname": "territory", - "oldfieldtype": "Link", - "options": "Territory", - "print_hide": 1, - "reqd": 0, - "search_index": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "label": "Contact", - "read_only": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Data", - "label": "Mobile No", - "read_only": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Data", - "label": "Contact Email", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break4", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "depends_on": "customer", - "description": "If different than customer address", - "doctype": "DocField", - "fieldname": "service_address", - "fieldtype": "Small Text", - "label": "Service Address", - "oldfieldname": "service_address", - "oldfieldtype": "Small Text" - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 0, - "label": "Address", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "options": "icon-file-text" - }, - { - "doctype": "DocField", - "fieldname": "col_break5", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break6", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "complaint_raised_by", - "fieldtype": "Data", - "label": "Raised By", - "oldfieldname": "complaint_raised_by", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "from_company", - "fieldtype": "Data", - "label": "From Company", - "oldfieldname": "from_company", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "hidden": 1, - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "width": "150px" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js index 328ca1d82c4..c6ac73c0f79 100644 --- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js +++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js @@ -94,8 +94,7 @@ cur_frm.cscript.periodicity = function(doc, cdt, cdn){ cur_frm.cscript.generate_schedule = function(doc, cdt, cdn) { if (!doc.__islocal) { - return $c('runserverobj', args={'method':'generate_schedule', - 'docs':frappe.model.compress(make_doclist(cdt,cdn))}, + return $c('runserverobj', args={'method':'generate_schedule', 'docs':doc}, function(r, rt) { refresh_field('maintenance_schedule_detail'); }); diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.json b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.json new file mode 100644 index 00000000000..7035f43215d --- /dev/null +++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.json @@ -0,0 +1,243 @@ +{ + "autoname": "MS.#####", + "creation": "2013-01-10 16:34:30.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "customer_details", + "fieldtype": "Section Break", + "label": "Customer Details", + "oldfieldtype": "Section Break", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 0, + "label": "Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": "Draft", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "\nDraft\nSubmitted\nCancelled", + "permlevel": 0, + "read_only": 1, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "transaction_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Transaction Date", + "oldfieldname": "transaction_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "items", + "fieldtype": "Section Break", + "label": "Items", + "oldfieldtype": "Section Break", + "options": "icon-shopping-cart", + "permlevel": 0 + }, + { + "fieldname": "item_maintenance_detail", + "fieldtype": "Table", + "label": "Maintenance Schedule Item", + "oldfieldname": "item_maintenance_detail", + "oldfieldtype": "Table", + "options": "Maintenance Schedule Item", + "permlevel": 0 + }, + { + "fieldname": "schedule", + "fieldtype": "Section Break", + "label": "Schedule", + "oldfieldtype": "Section Break", + "options": "icon-time", + "permlevel": 0 + }, + { + "fieldname": "generate_schedule", + "fieldtype": "Button", + "label": "Generate Schedule", + "oldfieldtype": "Button", + "permlevel": 0 + }, + { + "fieldname": "maintenance_schedule_detail", + "fieldtype": "Table", + "label": "Maintenance Schedule Detail", + "oldfieldname": "maintenance_schedule_detail", + "oldfieldtype": "Table", + "options": "Maintenance Schedule Detail", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_info", + "fieldtype": "Section Break", + "label": "Contact Info", + "permlevel": 0 + }, + { + "depends_on": "customer", + "fieldname": "customer_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Customer Name", + "oldfieldname": "customer_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "reqd": 0, + "search_index": 0 + }, + { + "depends_on": "customer", + "fieldname": "contact_person", + "fieldtype": "Link", + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1 + }, + { + "depends_on": "customer", + "fieldname": "contact_mobile", + "fieldtype": "Data", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "customer", + "fieldname": "contact_email", + "fieldtype": "Data", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "print_hide": 1, + "read_only": 1 + }, + { + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break_17", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "depends_on": "customer", + "fieldname": "customer_address", + "fieldtype": "Link", + "label": "Customer Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "customer", + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "in_filter": 1, + "label": "Territory", + "oldfieldname": "territory", + "oldfieldtype": "Link", + "options": "Territory", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "depends_on": "customer", + "description": "Add / Edit", + "fieldname": "customer_group", + "fieldtype": "Link", + "label": "Customer Group", + "options": "Customer Group", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + } + ], + "icon": "icon-calendar", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:48:56.000000", + "modified_by": "Administrator", + "module": "Support", + "name": "Maintenance Schedule", + "owner": "Administrator", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Maintenance Manager", + "submit": 1, + "write": 1 + } + ], + "search_fields": "status,customer,customer_name, sales_order_no" +} \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py index 2fcd200493d..afc08e8f066 100644 --- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py +++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py @@ -5,16 +5,12 @@ from __future__ import unicode_literals import frappe from frappe.utils import add_days, cstr, getdate, cint -from frappe.model.doc import addchild -from frappe.model.bean import getlist + from frappe import throw, _ from erpnext.utilities.transaction_base import TransactionBase, delete_events from erpnext.stock.utils import get_valid_serial_nos -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class MaintenanceSchedule(TransactionBase): def get_item_details(self, item_code): item = frappe.db.sql("""select item_name, description from `tabItem` @@ -26,17 +22,16 @@ class DocType(TransactionBase): return ret def generate_schedule(self): - self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail') + self.set('maintenance_schedule_detail', []) frappe.db.sql("""delete from `tabMaintenance Schedule Detail` - where parent=%s""", (self.doc.name)) + where parent=%s""", (self.name)) count = 1 - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): self.validate_maintenance_detail() s_list = [] s_list = self.create_schedule_list(d.start_date, d.end_date, d.no_of_visits, d.sales_person) for i in range(d.no_of_visits): - child = addchild(self.doc, 'maintenance_schedule_detail', - 'Maintenance Schedule Detail', self.doclist) + child = self.append('maintenance_schedule_detail') child.item_code = d.item_code child.item_name = d.item_name child.scheduled_date = s_list[i].strftime('%Y-%m-%d') @@ -50,42 +45,42 @@ class DocType(TransactionBase): self.on_update() def on_submit(self): - if not getlist(self.doclist, 'maintenance_schedule_detail'): + if not self.get('maintenance_schedule_detail'): throw("Please click on 'Generate Schedule' to get schedule") self.check_serial_no_added() self.validate_schedule() email_map = {} - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if d.serial_no: serial_nos = get_valid_serial_nos(d.serial_no) self.validate_serial_no(serial_nos, d.start_date) self.update_amc_date(serial_nos, d.end_date) if d.sales_person not in email_map: - sp = frappe.bean("Sales Person", d.sales_person).make_controller() + sp = frappe.get_doc("Sales Person", d.sales_person) email_map[d.sales_person] = sp.get_email_id() scheduled_date = frappe.db.sql("""select scheduled_date from `tabMaintenance Schedule Detail` where sales_person=%s and item_code=%s and - parent=%s""", (d.sales_person, d.item_code, self.doc.name), as_dict=1) + parent=%s""", (d.sales_person, d.item_code, self.name), as_dict=1) for key in scheduled_date: if email_map[d.sales_person]: description = "Reference: %s, Item Code: %s and Customer: %s" % \ - (self.doc.name, d.item_code, self.doc.customer) - frappe.bean({ + (self.name, d.item_code, self.customer) + frappe.get_doc({ "doctype": "Event", - "owner": email_map[d.sales_person] or self.doc.owner, + "owner": email_map[d.sales_person] or self.owner, "subject": description, "description": description, "starts_on": key["scheduled_date"] + " 10:00:00", "event_type": "Private", - "ref_type": self.doc.doctype, - "ref_name": self.doc.name + "ref_type": self.doctype, + "ref_name": self.name }).insert(ignore_permissions=1) - frappe.db.set(self.doc, 'status', 'Submitted') + frappe.db.set(self, 'status', 'Submitted') def create_schedule_list(self, start_date, end_date, no_of_visit, sales_person): schedule_list = [] @@ -174,10 +169,10 @@ class DocType(TransactionBase): return ret def validate_maintenance_detail(self): - if not getlist(self.doclist, 'item_maintenance_detail'): + if not self.get('item_maintenance_detail'): throw(_("Please enter Maintaince Details first")) - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if not d.item_code: throw(_("Please select item code")) elif not d.start_date or not d.end_date: @@ -191,7 +186,7 @@ class DocType(TransactionBase): throw(_("Start date should be less than end date for item") + " " + d.item_code) def validate_sales_order(self): - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if d.prevdoc_docname: chk = frappe.db.sql("""select ms.name from `tabMaintenance Schedule` ms, `tabMaintenance Schedule Item` msi where msi.parent=ms.name and @@ -204,13 +199,13 @@ class DocType(TransactionBase): self.validate_sales_order() def on_update(self): - frappe.db.set(self.doc, 'status', 'Draft') + frappe.db.set(self, 'status', 'Draft') def update_amc_date(self, serial_nos, amc_expiry_date=None): for serial_no in serial_nos: - serial_no_bean = frappe.bean("Serial No", serial_no) - serial_no_bean.doc.amc_expiry_date = amc_expiry_date - serial_no_bean.save() + serial_no_doc = frappe.get_doc("Serial No", serial_no) + serial_no_doc.amc_expiry_date = amc_expiry_date + serial_no_doc.save() def validate_serial_no(self, serial_nos, amc_start_date): for serial_no in serial_nos: @@ -233,11 +228,11 @@ class DocType(TransactionBase): def validate_schedule(self): item_lst1 =[] item_lst2 =[] - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if d.item_code not in item_lst1: item_lst1.append(d.item_code) - for m in getlist(self.doclist, 'maintenance_schedule_detail'): + for m in self.get('maintenance_schedule_detail'): if m.item_code not in item_lst2: item_lst2.append(m.item_code) @@ -252,34 +247,34 @@ class DocType(TransactionBase): def check_serial_no_added(self): serial_present =[] - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if d.serial_no: serial_present.append(d.item_code) - for m in getlist(self.doclist, 'maintenance_schedule_detail'): + for m in self.get('maintenance_schedule_detail'): if serial_present: if m.item_code in serial_present and not m.serial_no: throw("Please click on 'Generate Schedule' to fetch serial no added for item "+m.item_code) def on_cancel(self): - for d in getlist(self.doclist, 'item_maintenance_detail'): + for d in self.get('item_maintenance_detail'): if d.serial_no: serial_nos = get_valid_serial_nos(d.serial_no) self.update_amc_date(serial_nos) - frappe.db.set(self.doc, 'status', 'Cancelled') - delete_events(self.doc.doctype, self.doc.name) + frappe.db.set(self, 'status', 'Cancelled') + delete_events(self.doctype, self.name) def on_trash(self): - delete_events(self.doc.doctype, self.doc.name) + delete_events(self.doctype, self.name) @frappe.whitelist() -def make_maintenance_visit(source_name, target_doclist=None): - from frappe.model.mapper import get_mapped_doclist +def make_maintenance_visit(source_name, target_doc=None): + from frappe.model.mapper import get_mapped_doc def update_status(source, target, parent): target.maintenance_type = "Scheduled" - doclist = get_mapped_doclist("Maintenance Schedule", source_name, { + doclist = get_mapped_doc("Maintenance Schedule", source_name, { "Maintenance Schedule": { "doctype": "Maintenance Visit", "field_map": { @@ -298,6 +293,6 @@ def make_maintenance_visit(source_name, target_doclist=None): "sales_person": "service_person" } } - }, target_doclist) + }, target_doc) - return [d.fields for d in doclist] \ No newline at end of file + return doclist \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.txt b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.txt deleted file mode 100644 index 56278898aa9..00000000000 --- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.txt +++ /dev/null @@ -1,262 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:30", - "docstatus": 0, - "modified": "2014-01-20 17:48:56", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "MS.#####", - "doctype": "DocType", - "icon": "icon-calendar", - "is_submittable": 1, - "module": "Support", - "name": "__common__", - "search_fields": "status,customer,customer_name, sales_order_no" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Maintenance Schedule", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Maintenance Schedule", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Maintenance Manager", - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Maintenance Schedule" - }, - { - "doctype": "DocField", - "fieldname": "customer_details", - "fieldtype": "Section Break", - "label": "Customer Details", - "oldfieldtype": "Section Break", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 0, - "label": "Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break" - }, - { - "default": "Draft", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "\nDraft\nSubmitted\nCancelled", - "read_only": 1, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "transaction_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Transaction Date", - "oldfieldname": "transaction_date", - "oldfieldtype": "Date", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "items", - "fieldtype": "Section Break", - "label": "Items", - "oldfieldtype": "Section Break", - "options": "icon-shopping-cart" - }, - { - "doctype": "DocField", - "fieldname": "item_maintenance_detail", - "fieldtype": "Table", - "label": "Maintenance Schedule Item", - "oldfieldname": "item_maintenance_detail", - "oldfieldtype": "Table", - "options": "Maintenance Schedule Item" - }, - { - "doctype": "DocField", - "fieldname": "schedule", - "fieldtype": "Section Break", - "label": "Schedule", - "oldfieldtype": "Section Break", - "options": "icon-time" - }, - { - "doctype": "DocField", - "fieldname": "generate_schedule", - "fieldtype": "Button", - "label": "Generate Schedule", - "oldfieldtype": "Button" - }, - { - "doctype": "DocField", - "fieldname": "maintenance_schedule_detail", - "fieldtype": "Table", - "label": "Maintenance Schedule Detail", - "oldfieldname": "maintenance_schedule_detail", - "oldfieldtype": "Table", - "options": "Maintenance Schedule Detail", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_info", - "fieldtype": "Section Break", - "label": "Contact Info" - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Customer Name", - "oldfieldname": "customer_name", - "oldfieldtype": "Data", - "read_only": 1, - "reqd": 0, - "search_index": 0 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "label": "Contact Person", - "options": "Contact", - "print_hide": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Data", - "hidden": 1, - "label": "Mobile No", - "read_only": 1 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Data", - "hidden": 1, - "label": "Contact Email", - "print_hide": 1, - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_17", - "fieldtype": "Column Break" - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "customer_address", - "fieldtype": "Link", - "label": "Customer Address", - "options": "Address", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "read_only": 1 - }, - { - "depends_on": "customer", - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "in_filter": 1, - "label": "Territory", - "oldfieldname": "territory", - "oldfieldtype": "Link", - "options": "Territory", - "reqd": 1, - "search_index": 0 - }, - { - "depends_on": "customer", - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "label": "Customer Group", - "options": "Customer Group", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.json b/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.json new file mode 100644 index 00000000000..aee7274608d --- /dev/null +++ b/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.json @@ -0,0 +1,97 @@ +{ + "autoname": "MSD.#####", + "creation": "2013-02-22 01:28:05.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "read_only": 1, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_filter": 0, + "in_list_view": 1, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "allow_on_submit": 0, + "fieldname": "scheduled_date", + "fieldtype": "Date", + "in_filter": 1, + "in_list_view": 1, + "label": "Scheduled Date", + "oldfieldname": "scheduled_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "actual_date", + "fieldtype": "Date", + "hidden": 1, + "in_list_view": 0, + "label": "Actual Date", + "no_copy": 1, + "oldfieldname": "actual_date", + "oldfieldtype": "Date", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "report_hide": 1 + }, + { + "allow_on_submit": 0, + "fieldname": "sales_person", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Sales Person", + "oldfieldname": "incharge_name", + "oldfieldtype": "Link", + "options": "Sales Person", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "serial_no", + "fieldtype": "Small Text", + "in_filter": 1, + "in_list_view": 1, + "label": "Serial No", + "no_copy": 0, + "oldfieldname": "serial_no", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "160px", + "read_only": 1, + "search_index": 0, + "width": "160px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-31 12:13:38.000000", + "modified_by": "Administrator", + "module": "Support", + "name": "Maintenance Schedule Detail", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py b/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py index 26c87f1c04a..8c15d32c839 100644 --- a/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py +++ b/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class MaintenanceScheduleDetail(Document): + pass \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.txt b/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.txt deleted file mode 100644 index 8ed6856d240..00000000000 --- a/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.txt +++ /dev/null @@ -1,110 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:05", - "docstatus": 0, - "modified": "2013-12-31 12:13:38", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "MSD.#####", - "doctype": "DocType", - "istable": 1, - "module": "Support", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Maintenance Schedule Detail", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Maintenance Schedule Detail" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "read_only": 1, - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_filter": 0, - "in_list_view": 1, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "read_only": 1, - "search_index": 0 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "scheduled_date", - "fieldtype": "Date", - "in_filter": 1, - "in_list_view": 1, - "label": "Scheduled Date", - "oldfieldname": "scheduled_date", - "oldfieldtype": "Date", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "actual_date", - "fieldtype": "Date", - "hidden": 1, - "in_list_view": 0, - "label": "Actual Date", - "no_copy": 1, - "oldfieldname": "actual_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 0, - "report_hide": 1 - }, - { - "allow_on_submit": 0, - "doctype": "DocField", - "fieldname": "sales_person", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Sales Person", - "oldfieldname": "incharge_name", - "oldfieldtype": "Link", - "options": "Sales Person", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Small Text", - "in_filter": 1, - "in_list_view": 1, - "label": "Serial No", - "no_copy": 0, - "oldfieldname": "serial_no", - "oldfieldtype": "Small Text", - "print_width": "160px", - "read_only": 1, - "search_index": 0, - "width": "160px" - } -] \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.json b/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.json new file mode 100644 index 00000000000..38fa4b590c1 --- /dev/null +++ b/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.json @@ -0,0 +1,141 @@ +{ + "autoname": "IMD.#####", + "creation": "2013-02-22 01:28:05.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "description", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Data", + "permlevel": 0, + "print_width": "300px", + "read_only": 1, + "width": "300px" + }, + { + "fieldname": "schedule_details", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Schedule Details", + "permlevel": 0 + }, + { + "fieldname": "start_date", + "fieldtype": "Date", + "in_filter": 1, + "in_list_view": 1, + "label": "Start Date", + "oldfieldname": "start_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "end_date", + "fieldtype": "Date", + "in_filter": 1, + "in_list_view": 1, + "label": "End Date", + "oldfieldname": "end_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "periodicity", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Periodicity", + "oldfieldname": "periodicity", + "oldfieldtype": "Select", + "options": "\nWeekly\nMonthly\nQuarterly\nHalf Yearly\nYearly\nRandom", + "permlevel": 0 + }, + { + "fieldname": "no_of_visits", + "fieldtype": "Int", + "label": "No of Visits", + "oldfieldname": "no_of_visits", + "oldfieldtype": "Int", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "sales_person", + "fieldtype": "Link", + "in_filter": 1, + "label": "Sales Person", + "oldfieldname": "incharge_name", + "oldfieldtype": "Link", + "options": "Sales Person", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "reference", + "fieldtype": "Section Break", + "label": "Reference", + "permlevel": 0 + }, + { + "fieldname": "serial_no", + "fieldtype": "Small Text", + "label": "Serial No", + "oldfieldname": "serial_no", + "oldfieldtype": "Small Text", + "permlevel": 0 + }, + { + "fieldname": "prevdoc_docname", + "fieldtype": "Data", + "in_filter": 1, + "label": "Against Docname", + "no_copy": 1, + "oldfieldname": "prevdoc_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "search_index": 1, + "width": "150px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-31 12:08:32.000000", + "modified_by": "Administrator", + "module": "Support", + "name": "Maintenance Schedule Item", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py b/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py index 26c87f1c04a..47000c126a0 100644 --- a/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py +++ b/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class MaintenanceScheduleItem(Document): + pass \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.txt b/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.txt deleted file mode 100644 index 43d281d9e6e..00000000000 --- a/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.txt +++ /dev/null @@ -1,154 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:05", - "docstatus": 0, - "modified": "2013-12-31 12:08:32", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "IMD.#####", - "doctype": "DocType", - "istable": 1, - "module": "Support", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Maintenance Schedule Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Maintenance Schedule Item" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Data", - "print_width": "300px", - "read_only": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "schedule_details", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Schedule Details" - }, - { - "doctype": "DocField", - "fieldname": "start_date", - "fieldtype": "Date", - "in_filter": 1, - "in_list_view": 1, - "label": "Start Date", - "oldfieldname": "start_date", - "oldfieldtype": "Date", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "end_date", - "fieldtype": "Date", - "in_filter": 1, - "in_list_view": 1, - "label": "End Date", - "oldfieldname": "end_date", - "oldfieldtype": "Date", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "periodicity", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Periodicity", - "oldfieldname": "periodicity", - "oldfieldtype": "Select", - "options": "\nWeekly\nMonthly\nQuarterly\nHalf Yearly\nYearly\nRandom" - }, - { - "doctype": "DocField", - "fieldname": "no_of_visits", - "fieldtype": "Int", - "label": "No of Visits", - "oldfieldname": "no_of_visits", - "oldfieldtype": "Int", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "sales_person", - "fieldtype": "Link", - "in_filter": 1, - "label": "Sales Person", - "oldfieldname": "incharge_name", - "oldfieldtype": "Link", - "options": "Sales Person", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "reference", - "fieldtype": "Section Break", - "label": "Reference" - }, - { - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Small Text", - "label": "Serial No", - "oldfieldname": "serial_no", - "oldfieldtype": "Small Text" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_docname", - "fieldtype": "Data", - "in_filter": 1, - "label": "Against Docname", - "no_copy": 1, - "oldfieldname": "prevdoc_docname", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "search_index": 1, - "width": "150px" - } -] \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.json b/erpnext/support/doctype/maintenance_visit/maintenance_visit.json new file mode 100644 index 00000000000..7d93bba6c9e --- /dev/null +++ b/erpnext/support/doctype/maintenance_visit/maintenance_visit.json @@ -0,0 +1,302 @@ +{ + "autoname": "MV.#####", + "creation": "2013-01-10 16:34:31.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "customer_details", + "fieldtype": "Section Break", + "label": "Customer Details", + "oldfieldtype": "Section Break", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "in_filter": 1, + "label": "Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "customer_name", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 1, + "label": "Customer Name", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "address_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Address", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_display", + "fieldtype": "Small Text", + "hidden": 1, + "label": "Contact", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_mobile", + "fieldtype": "Data", + "hidden": 1, + "label": "Mobile No", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "contact_email", + "fieldtype": "Data", + "hidden": 1, + "label": "Contact Email", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "default": "Today", + "fieldname": "mntc_date", + "fieldtype": "Date", + "label": "Maintenance Date", + "no_copy": 1, + "oldfieldname": "mntc_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "mntc_time", + "fieldtype": "Time", + "label": "Maintenance Time", + "no_copy": 1, + "oldfieldname": "mntc_time", + "oldfieldtype": "Time", + "permlevel": 0 + }, + { + "fieldname": "maintenance_details", + "fieldtype": "Section Break", + "label": "Maintenance Details", + "oldfieldtype": "Section Break", + "options": "icon-wrench", + "permlevel": 0 + }, + { + "fieldname": "completion_status", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Completion Status", + "oldfieldname": "completion_status", + "oldfieldtype": "Select", + "options": "\nPartially Completed\nFully Completed", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "column_break_14", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": "Unscheduled", + "fieldname": "maintenance_type", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Maintenance Type", + "oldfieldname": "maintenance_type", + "oldfieldtype": "Select", + "options": "\nScheduled\nUnscheduled\nBreakdown", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "section_break0", + "fieldtype": "Section Break", + "oldfieldtype": "Section Break", + "options": "icon-wrench", + "permlevel": 0 + }, + { + "fieldname": "maintenance_visit_details", + "fieldtype": "Table", + "label": "Maintenance Visit Purpose", + "oldfieldname": "maintenance_visit_details", + "oldfieldtype": "Table", + "options": "Maintenance Visit Purpose", + "permlevel": 0 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "oldfieldtype": "Section Break", + "options": "icon-file-text", + "permlevel": 0 + }, + { + "fieldname": "customer_feedback", + "fieldtype": "Small Text", + "label": "Customer Feedback", + "oldfieldname": "customer_feedback", + "oldfieldtype": "Small Text", + "permlevel": 0 + }, + { + "fieldname": "col_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": "Draft", + "fieldname": "status", + "fieldtype": "Data", + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Data", + "options": "\nDraft\nCancelled\nSubmitted", + "permlevel": 0, + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "amended_from", + "fieldtype": "Data", + "ignore_restrictions": 1, + "label": "Amended From", + "no_copy": 1, + "oldfieldname": "amended_from", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "read_only": 1, + "width": "150px" + }, + { + "fieldname": "company", + "fieldtype": "Select", + "in_filter": 1, + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Select", + "options": "link:Company", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "fiscal_year", + "fieldtype": "Select", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "link:Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "reqd": 1, + "search_index": 0 + }, + { + "depends_on": "customer", + "fieldname": "contact_info_section", + "fieldtype": "Section Break", + "label": "Contact Info", + "options": "icon-bullhorn", + "permlevel": 0 + }, + { + "fieldname": "customer_address", + "fieldtype": "Link", + "label": "Customer Address", + "options": "Address", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "contact_person", + "fieldtype": "Link", + "label": "Contact Person", + "options": "Contact", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "col_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "Add / Edit", + "fieldname": "territory", + "fieldtype": "Link", + "label": "Territory", + "options": "Territory", + "permlevel": 0, + "print_hide": 1 + }, + { + "description": "Add / Edit", + "fieldname": "customer_group", + "fieldtype": "Link", + "label": "Customer Group", + "options": "Customer Group", + "permlevel": 0, + "print_hide": 1 + } + ], + "icon": "icon-file-text", + "idx": 1, + "is_submittable": 1, + "modified": "2014-01-20 17:48:57.000000", + "modified_by": "Administrator", + "module": "Support", + "name": "Maintenance Visit", + "owner": "ashwini@webnotestech.com", + "permissions": [ + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Maintenance User", + "submit": 1, + "write": 1 + } + ], + "search_fields": "status,maintenance_type,customer,customer_name, address,mntc_date,company,fiscal_year" +} \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.py b/erpnext/support/doctype/maintenance_visit/maintenance_visit.py index 1ddf67be6c3..b11d6562c24 100644 --- a/erpnext/support/doctype/maintenance_visit/maintenance_visit.py +++ b/erpnext/support/doctype/maintenance_visit/maintenance_visit.py @@ -5,47 +5,44 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr -from frappe.model.bean import getlist + from frappe import msgprint from erpnext.utilities.transaction_base import TransactionBase -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class MaintenanceVisit(TransactionBase): def get_item_details(self, item_code): return frappe.db.get_value("Item", item_code, ["item_name", "description"], as_dict=1) def validate_serial_no(self): - for d in getlist(self.doclist, 'maintenance_visit_details'): + for d in self.get('maintenance_visit_details'): if d.serial_no and not frappe.db.exists("Serial No", d.serial_no): frappe.throw("Serial No: "+ d.serial_no + " not exists in the system") def validate(self): - if not getlist(self.doclist, 'maintenance_visit_details'): + if not self.get('maintenance_visit_details'): msgprint("Please enter maintenance details") raise Exception self.validate_serial_no() def update_customer_issue(self, flag): - for d in getlist(self.doclist, 'maintenance_visit_details'): + for d in self.get('maintenance_visit_details'): if d.prevdoc_docname and d.prevdoc_doctype == 'Customer Issue' : if flag==1: - mntc_date = self.doc.mntc_date + mntc_date = self.mntc_date service_person = d.service_person work_done = d.work_done - if self.doc.completion_status == 'Fully Completed': + if self.completion_status == 'Fully Completed': status = 'Closed' - elif self.doc.completion_status == 'Partially Completed': + elif self.completion_status == 'Partially Completed': status = 'Work In Progress' else: - nm = frappe.db.sql("select t1.name, t1.mntc_date, t2.service_person, t2.work_done from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.completion_status = 'Partially Completed' and t2.prevdoc_docname = %s and t1.name!=%s and t1.docstatus = 1 order by t1.name desc limit 1", (d.prevdoc_docname, self.doc.name)) + nm = frappe.db.sql("select t1.name, t1.mntc_date, t2.service_person, t2.work_done from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.completion_status = 'Partially Completed' and t2.prevdoc_docname = %s and t1.name!=%s and t1.docstatus = 1 order by t1.name desc limit 1", (d.prevdoc_docname, self.name)) if nm: status = 'Work In Progress' @@ -64,13 +61,13 @@ class DocType(TransactionBase): def check_if_last_visit(self): """check if last maintenance visit against same sales order/ customer issue""" check_for_docname = check_for_doctype = None - for d in getlist(self.doclist, 'maintenance_visit_details'): + for d in self.get('maintenance_visit_details'): if d.prevdoc_docname: check_for_docname = d.prevdoc_docname check_for_doctype = d.prevdoc_doctype if check_for_docname: - check = frappe.db.sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.name!=%s and t2.prevdoc_docname=%s and t1.docstatus = 1 and (t1.mntc_date > %s or (t1.mntc_date = %s and t1.mntc_time > %s))", (self.doc.name, check_for_docname, self.doc.mntc_date, self.doc.mntc_date, self.doc.mntc_time)) + check = frappe.db.sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.name!=%s and t2.prevdoc_docname=%s and t1.docstatus = 1 and (t1.mntc_date > %s or (t1.mntc_date = %s and t1.mntc_time > %s))", (self.name, check_for_docname, self.mntc_date, self.mntc_date, self.mntc_time)) if check: check_lst = [x[0] for x in check] @@ -82,11 +79,11 @@ class DocType(TransactionBase): def on_submit(self): self.update_customer_issue(1) - frappe.db.set(self.doc, 'status', 'Submitted') + frappe.db.set(self, 'status', 'Submitted') def on_cancel(self): self.check_if_last_visit() - frappe.db.set(self.doc, 'status', 'Cancelled') + frappe.db.set(self, 'status', 'Cancelled') def on_update(self): pass \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.txt b/erpnext/support/doctype/maintenance_visit/maintenance_visit.txt deleted file mode 100644 index 6a03292dca1..00000000000 --- a/erpnext/support/doctype/maintenance_visit/maintenance_visit.txt +++ /dev/null @@ -1,321 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:31", - "docstatus": 0, - "modified": "2014-01-20 17:48:57", - "modified_by": "Administrator", - "owner": "ashwini@webnotestech.com" - }, - { - "autoname": "MV.#####", - "doctype": "DocType", - "icon": "icon-file-text", - "is_submittable": 1, - "module": "Support", - "name": "__common__", - "search_fields": "status,maintenance_type,customer,customer_name, address,mntc_date,company,fiscal_year" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Maintenance Visit", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Maintenance Visit", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Maintenance User", - "submit": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Maintenance Visit" - }, - { - "doctype": "DocField", - "fieldname": "customer_details", - "fieldtype": "Section Break", - "label": "Customer Details", - "oldfieldtype": "Section Break", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "in_filter": 1, - "label": "Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 1, - "label": "Customer Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Address", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_display", - "fieldtype": "Small Text", - "hidden": 1, - "label": "Contact", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_mobile", - "fieldtype": "Data", - "hidden": 1, - "label": "Mobile No", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_email", - "fieldtype": "Data", - "hidden": 1, - "label": "Contact Email", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "mntc_date", - "fieldtype": "Date", - "label": "Maintenance Date", - "no_copy": 1, - "oldfieldname": "mntc_date", - "oldfieldtype": "Date", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "mntc_time", - "fieldtype": "Time", - "label": "Maintenance Time", - "no_copy": 1, - "oldfieldname": "mntc_time", - "oldfieldtype": "Time" - }, - { - "doctype": "DocField", - "fieldname": "maintenance_details", - "fieldtype": "Section Break", - "label": "Maintenance Details", - "oldfieldtype": "Section Break", - "options": "icon-wrench" - }, - { - "doctype": "DocField", - "fieldname": "completion_status", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Completion Status", - "oldfieldname": "completion_status", - "oldfieldtype": "Select", - "options": "\nPartially Completed\nFully Completed", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_14", - "fieldtype": "Column Break" - }, - { - "default": "Unscheduled", - "doctype": "DocField", - "fieldname": "maintenance_type", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Maintenance Type", - "oldfieldname": "maintenance_type", - "oldfieldtype": "Select", - "options": "\nScheduled\nUnscheduled\nBreakdown", - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "oldfieldtype": "Section Break", - "options": "icon-wrench" - }, - { - "doctype": "DocField", - "fieldname": "maintenance_visit_details", - "fieldtype": "Table", - "label": "Maintenance Visit Purpose", - "oldfieldname": "maintenance_visit_details", - "oldfieldtype": "Table", - "options": "Maintenance Visit Purpose" - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "oldfieldtype": "Section Break", - "options": "icon-file-text" - }, - { - "doctype": "DocField", - "fieldname": "customer_feedback", - "fieldtype": "Small Text", - "label": "Customer Feedback", - "oldfieldname": "customer_feedback", - "oldfieldtype": "Small Text" - }, - { - "doctype": "DocField", - "fieldname": "col_break3", - "fieldtype": "Column Break" - }, - { - "default": "Draft", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Data", - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Data", - "options": "\nDraft\nCancelled\nSubmitted", - "read_only": 1, - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "amended_from", - "fieldtype": "Data", - "ignore_restrictions": 1, - "label": "Amended From", - "no_copy": 1, - "oldfieldname": "amended_from", - "oldfieldtype": "Data", - "print_hide": 1, - "read_only": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Select", - "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Select", - "options": "link:Company", - "print_hide": 1, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "link:Fiscal Year", - "print_hide": 1, - "reqd": 1, - "search_index": 0 - }, - { - "depends_on": "customer", - "doctype": "DocField", - "fieldname": "contact_info_section", - "fieldtype": "Section Break", - "label": "Contact Info", - "options": "icon-bullhorn" - }, - { - "doctype": "DocField", - "fieldname": "customer_address", - "fieldtype": "Link", - "label": "Customer Address", - "options": "Address", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "label": "Contact Person", - "options": "Contact", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break4", - "fieldtype": "Column Break" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "label": "Territory", - "options": "Territory", - "print_hide": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "label": "Customer Group", - "options": "Customer Group", - "print_hide": 1 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.json b/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.json new file mode 100644 index 00000000000..32e3769b7ce --- /dev/null +++ b/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.json @@ -0,0 +1,129 @@ +{ + "autoname": "MVD.#####", + "creation": "2013-02-22 01:28:06.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "item_code", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Item Code", + "oldfieldname": "item_code", + "oldfieldtype": "Link", + "options": "Item", + "permlevel": 0 + }, + { + "fieldname": "item_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Item Name", + "oldfieldname": "item_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "serial_no", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Serial No", + "oldfieldname": "serial_no", + "oldfieldtype": "Small Text", + "permlevel": 0 + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Description", + "oldfieldname": "description", + "oldfieldtype": "Small Text", + "permlevel": 0, + "print_width": "300px", + "reqd": 1, + "width": "300px" + }, + { + "fieldname": "work_details", + "fieldtype": "Section Break", + "in_list_view": 0, + "label": "Work Details", + "permlevel": 0 + }, + { + "fieldname": "service_person", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Sales Person", + "oldfieldname": "service_person", + "oldfieldtype": "Link", + "options": "Sales Person", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "work_done", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Work Done", + "oldfieldname": "work_done", + "oldfieldtype": "Small Text", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "prevdoc_docname", + "fieldtype": "Data", + "hidden": 0, + "label": "Against Document No", + "no_copy": 1, + "oldfieldname": "prevdoc_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "160px", + "read_only": 1, + "report_hide": 1, + "width": "160px" + }, + { + "fieldname": "prevdoc_detail_docname", + "fieldtype": "Data", + "hidden": 1, + "label": "Against Document Detail No", + "no_copy": 1, + "oldfieldname": "prevdoc_detail_docname", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "160px", + "read_only": 1, + "report_hide": 1, + "width": "160px" + }, + { + "fieldname": "prevdoc_doctype", + "fieldtype": "Data", + "hidden": 0, + "label": "Document Type", + "no_copy": 1, + "oldfieldname": "prevdoc_doctype", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "report_hide": 1, + "width": "150px" + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:20.000000", + "modified_by": "Administrator", + "module": "Support", + "name": "Maintenance Visit Purpose", + "owner": "ashwini@webnotestech.com" +} \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py b/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py index 26c87f1c04a..ac30b7a90e2 100644 --- a/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py +++ b/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class MaintenanceVisitPurpose(Document): + pass \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.txt b/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.txt deleted file mode 100644 index 6a45e55c4ed..00000000000 --- a/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.txt +++ /dev/null @@ -1,142 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:06", - "docstatus": 0, - "modified": "2013-12-20 19:23:20", - "modified_by": "Administrator", - "owner": "ashwini@webnotestech.com" - }, - { - "autoname": "MVD.#####", - "doctype": "DocType", - "istable": 1, - "module": "Support", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Maintenance Visit Purpose", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Maintenance Visit Purpose" - }, - { - "doctype": "DocField", - "fieldname": "item_code", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item Code", - "oldfieldname": "item_code", - "oldfieldtype": "Link", - "options": "Item" - }, - { - "doctype": "DocField", - "fieldname": "item_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Item Name", - "oldfieldname": "item_name", - "oldfieldtype": "Data", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "serial_no", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Serial No", - "oldfieldname": "serial_no", - "oldfieldtype": "Small Text" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Description", - "oldfieldname": "description", - "oldfieldtype": "Small Text", - "print_width": "300px", - "reqd": 1, - "width": "300px" - }, - { - "doctype": "DocField", - "fieldname": "work_details", - "fieldtype": "Section Break", - "in_list_view": 0, - "label": "Work Details" - }, - { - "doctype": "DocField", - "fieldname": "service_person", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Sales Person", - "oldfieldname": "service_person", - "oldfieldtype": "Link", - "options": "Sales Person", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "work_done", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Work Done", - "oldfieldname": "work_done", - "oldfieldtype": "Small Text", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_docname", - "fieldtype": "Data", - "hidden": 0, - "label": "Against Document No", - "no_copy": 1, - "oldfieldname": "prevdoc_docname", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "160px", - "read_only": 1, - "report_hide": 1, - "width": "160px" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_detail_docname", - "fieldtype": "Data", - "hidden": 1, - "label": "Against Document Detail No", - "no_copy": 1, - "oldfieldname": "prevdoc_detail_docname", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "160px", - "read_only": 1, - "report_hide": 1, - "width": "160px" - }, - { - "doctype": "DocField", - "fieldname": "prevdoc_doctype", - "fieldtype": "Data", - "hidden": 0, - "label": "Document Type", - "no_copy": 1, - "oldfieldname": "prevdoc_doctype", - "oldfieldtype": "Data", - "print_hide": 1, - "print_width": "150px", - "read_only": 1, - "report_hide": 1, - "width": "150px" - } -] \ No newline at end of file diff --git a/erpnext/support/doctype/newsletter/newsletter.js b/erpnext/support/doctype/newsletter/newsletter.js index dfa9af9a2e4..5c88692c91b 100644 --- a/erpnext/support/doctype/newsletter/newsletter.js +++ b/erpnext/support/doctype/newsletter/newsletter.js @@ -17,7 +17,7 @@ cur_frm.cscript.refresh = function(doc) { if(!doc.__islocal && !cint(doc.email_sent) && !doc.__unsaved && inList(frappe.boot.user.can_write, doc.doctype)) { cur_frm.add_custom_button(frappe._('Send'), function() { - return $c_obj(make_doclist(doc.doctype, doc.name), 'send_emails', '', function(r) { + return $c_obj(doc, 'send_emails', '', function(r) { cur_frm.refresh(); }); }) diff --git a/erpnext/support/doctype/newsletter/newsletter.json b/erpnext/support/doctype/newsletter/newsletter.json new file mode 100644 index 00000000000..600ac3fad53 --- /dev/null +++ b/erpnext/support/doctype/newsletter/newsletter.json @@ -0,0 +1,169 @@ +{ + "autoname": "naming_series:", + "creation": "2013-01-10 16:34:31.000000", + "description": "Create and Send Newsletters", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Other", + "fields": [ + { + "description": "Select who you want to send this newsletter to", + "fieldname": "send_to", + "fieldtype": "Section Break", + "label": "Send To", + "permlevel": 0 + }, + { + "default": "NL-", + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "options": "NL-", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "send_to_type", + "fieldtype": "Select", + "label": "Send To Type", + "options": "Lead\nContact\nEmployee\nCustom", + "permlevel": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.send_to_type==\"Lead\"", + "fieldname": "lead_source", + "fieldtype": "Select", + "label": "Lead Source", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.send_to_type==\"Lead\"", + "fieldname": "lead_status", + "fieldtype": "Select", + "label": "Lead Status", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.send_to_type==\"Contact\"", + "fieldname": "contact_type", + "fieldtype": "Select", + "label": "Contact Type", + "options": "Customer\nSupplier", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.send_to_type==\"Custom\"", + "description": "Comma separated list of email addresses", + "fieldname": "email_list", + "fieldtype": "Text", + "label": "Send to this list", + "permlevel": 0 + }, + { + "fieldname": "newsletter_content", + "fieldtype": "Section Break", + "label": "Newsletter Content", + "permlevel": 0 + }, + { + "description": "If specified, send the newsletter using this email address", + "fieldname": "send_from", + "fieldtype": "Data", + "label": "Send From", + "no_copy": 1, + "permlevel": 0 + }, + { + "fieldname": "subject", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Subject", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "message", + "fieldtype": "Text Editor", + "label": "Message", + "permlevel": 0, + "reqd": 0 + }, + { + "description": "Check how the newsletter looks in an email by sending it to your email.", + "fieldname": "test_the_newsletter", + "fieldtype": "Section Break", + "label": "Test the Newsletter", + "permlevel": 0 + }, + { + "description": "A Lead with this email id should exist", + "fieldname": "test_email_id", + "fieldtype": "Data", + "label": "Test Email Id", + "permlevel": 0 + }, + { + "fieldname": "test_send", + "fieldtype": "Button", + "label": "Test", + "options": "test_send", + "permlevel": 0 + }, + { + "fieldname": "newsletter_status", + "fieldtype": "Section Break", + "label": "Newsletter Status", + "permlevel": 0 + }, + { + "fieldname": "email_sent", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Email Sent?", + "no_copy": 1, + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-envelope", + "idx": 1, + "modified": "2014-02-03 11:32:22.000000", + "modified_by": "Administrator", + "module": "Support", + "name": "Newsletter", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 0, + "permlevel": 0, + "print": 0, + "read": 1, + "report": 0, + "role": "Sales Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 0, + "permlevel": 0, + "print": 0, + "read": 1, + "report": 0, + "role": "Support Manager", + "submit": 0, + "write": 1 + } + ], + "title_field": "subject" +} \ No newline at end of file diff --git a/erpnext/support/doctype/newsletter/newsletter.py b/erpnext/support/doctype/newsletter/newsletter.py index 72d05aff285..2dce58a4409 100644 --- a/erpnext/support/doctype/newsletter/newsletter.py +++ b/erpnext/support/doctype/newsletter/newsletter.py @@ -7,29 +7,27 @@ import frappe import frappe.utils from frappe.utils import cstr from frappe import msgprint, throw, _ +from frappe.model.document import Document -class DocType(): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - +class Newsletter(Document): def onload(self): - if self.doc.email_sent: - self.doc.fields["__status_count"] = dict(frappe.db.sql("""select status, count(*) + if self.email_sent: + self.set("__status_count", dict(frappe.db.sql("""select status, count(*) from `tabBulk Email` where ref_doctype=%s and ref_docname=%s - group by status""", (self.doc.doctype, self.doc.name))) or None + group by status""", (self.doctype, self.name))) or None) def test_send(self, doctype="Lead"): - self.recipients = self.doc.test_email_id.split(",") + self.recipients = self.test_email_id.split(",") self.send_to_doctype = "Lead" self.send_bulk() msgprint("{send} {email}".format**{ "send": _("Scheduled to send to"), - "email": self.doc.test_email_id + "email": self.test_email_id }) def send_emails(self): """send emails to leads and customers""" - if self.doc.email_sent: + if self.email_sent: throw(_("Newsletter has already been sent")) self.recipients = self.get_recipients() @@ -41,27 +39,27 @@ class DocType(): "doctype": self.send_to_doctype })) - frappe.db.set(self.doc, "email_sent", 1) + frappe.db.set(self, "email_sent", 1) def get_recipients(self): self.email_field = None - if self.doc.send_to_type=="Contact": + if self.send_to_type=="Contact": self.send_to_doctype = "Contact" - if self.doc.contact_type == "Customer": + if self.contact_type == "Customer": return frappe.db.sql_list("""select email_id from tabContact where ifnull(email_id, '') != '' and ifnull(customer, '') != ''""") - elif self.doc.contact_type == "Supplier": + elif self.contact_type == "Supplier": return frappe.db.sql_list("""select email_id from tabContact where ifnull(email_id, '') != '' and ifnull(supplier, '') != ''""") - elif self.doc.send_to_type=="Lead": + elif self.send_to_type=="Lead": self.send_to_doctype = "Lead" conditions = [] - if self.doc.lead_source and self.doc.lead_source != "All": - conditions.append(" and source='%s'" % self.doc.lead_source.replace("'", "\'")) - if self.doc.lead_status and self.doc.lead_status != "All": - conditions.append(" and status='%s'" % self.doc.lead_status.replace("'", "\'")) + if self.lead_source and self.lead_source != "All": + conditions.append(" and source='%s'" % self.lead_source.replace("'", "\'")) + if self.lead_status and self.lead_status != "All": + conditions.append(" and status='%s'" % self.lead_status.replace("'", "\'")) if conditions: conditions = "".join(conditions) @@ -69,7 +67,7 @@ class DocType(): return frappe.db.sql_list("""select email_id from tabLead where ifnull(email_id, '') != '' %s""" % (conditions or "")) - elif self.doc.send_to_type=="Employee": + elif self.send_to_type=="Employee": self.send_to_doctype = "Employee" self.email_field = "company_email" @@ -77,8 +75,8 @@ class DocType(): if(ifnull(company_email, '')!='', company_email, personal_email) as email_id from `tabEmployee` where status='Active'""") - elif self.doc.email_list: - email_list = [cstr(email).strip() for email in self.doc.email_list.split(",")] + elif self.email_list: + email_list = [cstr(email).strip() for email in self.email_list.split(",")] for email in email_list: create_lead(email) @@ -88,7 +86,7 @@ class DocType(): def send_bulk(self): self.validate_send() - sender = self.doc.send_from or frappe.utils.get_formatted_email(self.doc.owner) + sender = self.send_from or frappe.utils.get_formatted_email(self.owner) from frappe.utils.email_lib.bulk import send @@ -96,15 +94,15 @@ class DocType(): frappe.db.auto_commit_on_many_writes = True send(recipients = self.recipients, sender = sender, - subject = self.doc.subject, message = self.doc.message, + subject = self.subject, message = self.message, doctype = self.send_to_doctype, email_field = self.email_field or "email_id", - ref_doctype = self.doc.doctype, ref_docname = self.doc.name) + ref_doctype = self.doctype, ref_docname = self.name) if not frappe.flags.in_test: frappe.db.auto_commit_on_many_writes = False def validate_send(self): - if self.doc.fields.get("__islocal"): + if self.get("__islocal"): throw(_("Please save the Newsletter before sending.")) from frappe import conf @@ -125,13 +123,13 @@ def get_lead_options(): def create_lead(email_id): """create a lead if it does not exist""" from email.utils import parseaddr - from frappe.model.doc import get_default_naming_series + from frappe.model.naming import get_default_naming_series real_name, email_id = parseaddr(email_id) if frappe.db.get_value("Lead", {"email_id": email_id}): return - lead = frappe.bean({ + lead = frappe.get_doc({ "doctype": "Lead", "email_id": email_id, "lead_name": real_name or email_id, diff --git a/erpnext/support/doctype/newsletter/newsletter.txt b/erpnext/support/doctype/newsletter/newsletter.txt deleted file mode 100644 index d0ce1f42b33..00000000000 --- a/erpnext/support/doctype/newsletter/newsletter.txt +++ /dev/null @@ -1,179 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:31", - "docstatus": 0, - "modified": "2014-02-03 11:32:22", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "naming_series:", - "description": "Create and Send Newsletters", - "doctype": "DocType", - "document_type": "Other", - "icon": "icon-envelope", - "module": "Support", - "name": "__common__", - "title_field": "subject" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Newsletter", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 0, - "name": "__common__", - "parent": "Newsletter", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 0, - "read": 1, - "report": 0, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Newsletter" - }, - { - "description": "Select who you want to send this newsletter to", - "doctype": "DocField", - "fieldname": "send_to", - "fieldtype": "Section Break", - "label": "Send To" - }, - { - "default": "NL-", - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "label": "Series", - "options": "NL-", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "send_to_type", - "fieldtype": "Select", - "label": "Send To Type", - "options": "Lead\nContact\nEmployee\nCustom" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break" - }, - { - "depends_on": "eval:doc.send_to_type==\"Lead\"", - "doctype": "DocField", - "fieldname": "lead_source", - "fieldtype": "Select", - "label": "Lead Source" - }, - { - "depends_on": "eval:doc.send_to_type==\"Lead\"", - "doctype": "DocField", - "fieldname": "lead_status", - "fieldtype": "Select", - "label": "Lead Status" - }, - { - "depends_on": "eval:doc.send_to_type==\"Contact\"", - "doctype": "DocField", - "fieldname": "contact_type", - "fieldtype": "Select", - "label": "Contact Type", - "options": "Customer\nSupplier" - }, - { - "depends_on": "eval:doc.send_to_type==\"Custom\"", - "description": "Comma separated list of email addresses", - "doctype": "DocField", - "fieldname": "email_list", - "fieldtype": "Text", - "label": "Send to this list" - }, - { - "doctype": "DocField", - "fieldname": "newsletter_content", - "fieldtype": "Section Break", - "label": "Newsletter Content" - }, - { - "description": "If specified, send the newsletter using this email address", - "doctype": "DocField", - "fieldname": "send_from", - "fieldtype": "Data", - "label": "Send From", - "no_copy": 1 - }, - { - "doctype": "DocField", - "fieldname": "subject", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Subject", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "message", - "fieldtype": "Text Editor", - "label": "Message", - "reqd": 0 - }, - { - "description": "Check how the newsletter looks in an email by sending it to your email.", - "doctype": "DocField", - "fieldname": "test_the_newsletter", - "fieldtype": "Section Break", - "label": "Test the Newsletter" - }, - { - "description": "A Lead with this email id should exist", - "doctype": "DocField", - "fieldname": "test_email_id", - "fieldtype": "Data", - "label": "Test Email Id" - }, - { - "doctype": "DocField", - "fieldname": "test_send", - "fieldtype": "Button", - "label": "Test", - "options": "test_send" - }, - { - "doctype": "DocField", - "fieldname": "newsletter_status", - "fieldtype": "Section Break", - "label": "Newsletter Status" - }, - { - "doctype": "DocField", - "fieldname": "email_sent", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Email Sent?", - "no_copy": 1, - "read_only": 1 - }, - { - "doctype": "DocPerm", - "role": "Sales Manager" - }, - { - "doctype": "DocPerm", - "role": "Support Manager" - } -] \ No newline at end of file diff --git a/erpnext/support/doctype/newsletter/test_newsletter.py b/erpnext/support/doctype/newsletter/test_newsletter.py index 1eff657746b..a8ff683fd5f 100644 --- a/erpnext/support/doctype/newsletter/test_newsletter.py +++ b/erpnext/support/doctype/newsletter/test_newsletter.py @@ -5,63 +5,38 @@ import frappe, unittest class TestNewsletter(unittest.TestCase): def test_get_recipients_lead(self): - w = frappe.bean(test_records[0]) + w = frappe.get_doc(test_records[0]) w.insert() - self.assertTrue("test_lead@example.com" in w.controller.get_recipients()) + self.assertTrue("test_lead@example.com" in w.get_recipients()) frappe.db.sql("""delete from `tabBulk Email`""") - w.controller.send_emails() + w.send_emails() self.assertTrue(frappe.db.get_value("Bulk Email", {"recipient": "test_lead@example.com"})) def test_get_recipients_lead_by_status(self): - w = frappe.bean(test_records[0]) - w.doc.lead_status="Converted" + w = frappe.get_doc(test_records[0]) + w.lead_status="Converted" w.insert() - self.assertTrue("test_lead3@example.com" in w.controller.get_recipients()) + self.assertTrue("test_lead3@example.com" in w.get_recipients()) def test_get_recipients_contact_customer(self): - w = frappe.bean(test_records[1]) + w = frappe.get_doc(test_records[1]) w.insert() - self.assertTrue("test_contact_customer@example.com" in w.controller.get_recipients()) + self.assertTrue("test_contact_customer@example.com" in w.get_recipients()) def test_get_recipients_contact_supplier(self): - w = frappe.bean(test_records[1]) - w.doc.contact_type="Supplier" + w = frappe.get_doc(test_records[1]) + w.contact_type="Supplier" w.insert() - self.assertTrue("test_contact_supplier@example.com" in w.controller.get_recipients()) + self.assertTrue("test_contact_supplier@example.com" in w.get_recipients()) def test_get_recipients_custom(self): - w = frappe.bean(test_records[2]) + w = frappe.get_doc(test_records[2]) w.insert() - self.assertTrue("test_custom2@example.com" in w.controller.get_recipients()) - self.assertTrue(frappe.db.get("Lead", + self.assertTrue("test_custom2@example.com" in w.get_recipients()) + self.assertTrue(frappe.db.get("Lead", {"email_id": "test_custom2@example.com"})) test_dependencies = ["Lead", "Contact"] -test_records =[ - [{ - "doctype": "Newsletter", - "subject": "_Test Newsletter to Lead", - "send_to_type": "Lead", - "lead_source": "All", - "message": "This is a test newsletter", - "send_from": "admin@example.com" - }], - [{ - "doctype": "Newsletter", - "subject": "_Test Newsletter to Contact", - "send_to_type": "Contact", - "contact_type": "Customer", - "message": "This is a test newsletter", - "send_from": "admin@example.com" - }], - [{ - "doctype": "Newsletter", - "subject": "_Test Newsletter to Custom", - "send_to_type": "Custom", - "email_list": "test_custom@example.com, test_custom1@example.com, test_custom2@example.com", - "message": "This is a test newsletter", - "send_from": "admin@example.com" - }], -] +test_records = frappe.get_test_records('Newsletter') diff --git a/erpnext/support/doctype/newsletter/test_records.json b/erpnext/support/doctype/newsletter/test_records.json new file mode 100644 index 00000000000..cceabca3557 --- /dev/null +++ b/erpnext/support/doctype/newsletter/test_records.json @@ -0,0 +1,26 @@ +[ + { + "doctype": "Newsletter", + "lead_source": "All", + "message": "This is a test newsletter", + "send_from": "admin@example.com", + "send_to_type": "Lead", + "subject": "_Test Newsletter to Lead" + }, + { + "contact_type": "Customer", + "doctype": "Newsletter", + "message": "This is a test newsletter", + "send_from": "admin@example.com", + "send_to_type": "Contact", + "subject": "_Test Newsletter to Contact" + }, + { + "doctype": "Newsletter", + "email_list": "test_custom@example.com, test_custom1@example.com, test_custom2@example.com", + "message": "This is a test newsletter", + "send_from": "admin@example.com", + "send_to_type": "Custom", + "subject": "_Test Newsletter to Custom" + } +] \ No newline at end of file diff --git a/erpnext/support/doctype/support_email_settings/support_email_settings.json b/erpnext/support/doctype/support_email_settings/support_email_settings.json new file mode 100644 index 00000000000..dd45049d27d --- /dev/null +++ b/erpnext/support/doctype/support_email_settings/support_email_settings.json @@ -0,0 +1,92 @@ +{ + "allow_copy": 1, + "creation": "2014-03-03 19:48:46.000000", + "description": "Email Settings for Outgoing and Incoming Emails.", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Check this to pull emails from your mailbox", + "fieldname": "sync_support_mails", + "fieldtype": "Check", + "label": "Sync Support Mails", + "permlevel": 0 + }, + { + "description": "Your support email id - must be a valid email - this is where your emails will come!", + "fieldname": "support_email", + "fieldtype": "Data", + "label": "Support Email", + "permlevel": 0 + }, + { + "description": "POP3 mail server (e.g. pop.gmail.com)", + "fieldname": "mail_server", + "fieldtype": "Data", + "label": "POP3 Mail Server", + "permlevel": 0 + }, + { + "fieldname": "use_ssl", + "fieldtype": "Check", + "label": "Use SSL", + "permlevel": 0 + }, + { + "fieldname": "mail_login", + "fieldtype": "Data", + "label": "User Name", + "permlevel": 0 + }, + { + "fieldname": "mail_password", + "fieldtype": "Password", + "label": "Support Password", + "permlevel": 0 + }, + { + "fieldname": "cb1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "Signature to be appended at the end of every email", + "fieldname": "support_signature", + "fieldtype": "Text", + "label": "Signature", + "permlevel": 0 + }, + { + "default": "1", + "fieldname": "send_autoreply", + "fieldtype": "Check", + "label": "Send Autoreply", + "permlevel": 0 + }, + { + "description": "Autoreply when a new mail is received", + "fieldname": "support_autoreply", + "fieldtype": "Text", + "label": "Custom Autoreply Message", + "permlevel": 0 + } + ], + "icon": "icon-cog", + "idx": 1, + "in_create": 1, + "issingle": 1, + "modified": "2014-03-03 20:20:34.000000", + "modified_by": "Administrator", + "module": "Support", + "name": "Support Email Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "permlevel": 0, + "read": 1, + "role": "System Manager", + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/support/doctype/support_email_settings/support_email_settings.py b/erpnext/support/doctype/support_email_settings/support_email_settings.py index 203bf72d517..1efa628a1b5 100644 --- a/erpnext/support/doctype/support_email_settings/support_email_settings.py +++ b/erpnext/support/doctype/support_email_settings/support_email_settings.py @@ -6,29 +6,27 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document +from frappe.utils.email_lib.receive import POP3Mailbox +import _socket, poplib + +class SupportEmailSettings(Document): def validate(self): """ Checks support ticket email settings """ - if self.doc.sync_support_mails and self.doc.mail_server: - from frappe.utils.email_lib.receive import POP3Mailbox - from frappe.model.doc import Document - import _socket, poplib - - inc_email = Document('Incoming Email Settings') - inc_email.encode() - inc_email.host = self.doc.mail_server - inc_email.use_ssl = self.doc.use_ssl + if self.sync_support_mails and self.mail_server: + inc_email = frappe.get_doc('Incoming Email Settings') + # inc_email.encode() + inc_email.host = self.mail_server + inc_email.use_ssl = self.use_ssl try: err_msg = 'User Name or Support Password missing. Please enter and try again.' - if not (self.doc.mail_login and self.doc.mail_password): + if not (self.mail_login and self.mail_password): raise AttributeError, err_msg - inc_email.username = self.doc.mail_login - inc_email.password = self.doc.mail_password + inc_email.username = self.mail_login + inc_email.password = self.mail_password except AttributeError, e: frappe.msgprint(err_msg) raise diff --git a/erpnext/support/doctype/support_email_settings/support_email_settings.txt b/erpnext/support/doctype/support_email_settings/support_email_settings.txt deleted file mode 100644 index 5775c284663..00000000000 --- a/erpnext/support/doctype/support_email_settings/support_email_settings.txt +++ /dev/null @@ -1,111 +0,0 @@ -[ - { - "creation": "2014-03-03 19:48:46", - "docstatus": 0, - "modified": "2014-03-03 20:20:34", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_copy": 1, - "description": "Email Settings for Outgoing and Incoming Emails.", - "doctype": "DocType", - "icon": "icon-cog", - "in_create": 1, - "issingle": 1, - "module": "Support", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Support Email Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Support Email Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "role": "System Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Support Email Settings" - }, - { - "description": "Check this to pull emails from your mailbox", - "doctype": "DocField", - "fieldname": "sync_support_mails", - "fieldtype": "Check", - "label": "Sync Support Mails" - }, - { - "description": "Your support email id - must be a valid email - this is where your emails will come!", - "doctype": "DocField", - "fieldname": "support_email", - "fieldtype": "Data", - "label": "Support Email" - }, - { - "description": "POP3 mail server (e.g. pop.gmail.com)", - "doctype": "DocField", - "fieldname": "mail_server", - "fieldtype": "Data", - "label": "POP3 Mail Server" - }, - { - "doctype": "DocField", - "fieldname": "use_ssl", - "fieldtype": "Check", - "label": "Use SSL" - }, - { - "doctype": "DocField", - "fieldname": "mail_login", - "fieldtype": "Data", - "label": "User Name" - }, - { - "doctype": "DocField", - "fieldname": "mail_password", - "fieldtype": "Password", - "label": "Support Password" - }, - { - "doctype": "DocField", - "fieldname": "cb1", - "fieldtype": "Column Break" - }, - { - "description": "Signature to be appended at the end of every email", - "doctype": "DocField", - "fieldname": "support_signature", - "fieldtype": "Text", - "label": "Signature" - }, - { - "default": "1", - "doctype": "DocField", - "fieldname": "send_autoreply", - "fieldtype": "Check", - "label": "Send Autoreply" - }, - { - "description": "Autoreply when a new mail is received", - "doctype": "DocField", - "fieldname": "support_autoreply", - "fieldtype": "Text", - "label": "Custom Autoreply Message" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/support/doctype/support_ticket/get_support_mails.py b/erpnext/support/doctype/support_ticket/get_support_mails.py index 8ac5eba17a1..92e90312b95 100644 --- a/erpnext/support/doctype/support_ticket/get_support_mails.py +++ b/erpnext/support/doctype/support_ticket/get_support_mails.py @@ -10,7 +10,7 @@ from frappe.core.doctype.communication.communication import _make class SupportMailbox(POP3Mailbox): def setup(self, args=None): - self.email_settings = frappe.doc("Support Email Settings", "Support Email Settings") + self.email_settings = frappe.get_doc("Support Email Settings", "Support Email Settings") self.settings = args or frappe._dict({ "use_ssl": self.email_settings.use_ssl, "host": self.email_settings.mail_server, @@ -19,7 +19,7 @@ class SupportMailbox(POP3Mailbox): }) def process_message(self, mail): - if mail.from_email == self.email_settings.fields.get('support_email'): + if mail.from_email == self.email_settings.get('support_email'): return thread_id = mail.get_thread_id() new_ticket = False @@ -32,11 +32,11 @@ class SupportMailbox(POP3Mailbox): if new_ticket and cint(self.email_settings.send_autoreply) and \ "mailer-daemon" not in mail.from_email.lower(): - self.send_auto_reply(ticket.doc) + self.send_auto_reply(ticket) def send_auto_reply(self, d): - signature = self.email_settings.fields.get('support_signature') or '' - response = self.email_settings.fields.get('support_autoreply') or (""" + signature = self.email_settings.get('support_signature') or '' + response = self.email_settings.get('support_autoreply') or (""" A new Ticket has been raised for your query. If you have any additional information, please reply back to this mail. @@ -48,7 +48,7 @@ Original Query: sendmail(\ recipients = [cstr(d.raised_by)], \ - sender = cstr(self.email_settings.fields.get('support_email')), \ + sender = cstr(self.email_settings.get('support_email')), \ subject = '['+cstr(d.name)+'] ' + cstr(d.subject), \ msg = cstr(response)) @@ -58,28 +58,28 @@ def get_support_mails(): def add_support_communication(subject, content, sender, docname=None, mail=None): if docname: - ticket = frappe.bean("Support Ticket", docname) - ticket.doc.status = 'Open' + ticket = frappe.get_doc("Support Ticket", docname) + ticket.status = 'Open' ticket.ignore_permissions = True - ticket.doc.save() + ticket.save() else: - ticket = frappe.bean([decode_dict({ + ticket = frappe.get_doc(decode_dict({ "doctype":"Support Ticket", "description": content, "subject": subject, "raised_by": sender, "content_type": mail.content_type if mail else None, "status": "Open", - })]) + })) ticket.ignore_permissions = True ticket.ignore_mandatory = True ticket.insert() _make(content=content, sender=sender, subject = subject, - doctype="Support Ticket", name=ticket.doc.name, + doctype="Support Ticket", name=ticket.name, date=mail.date if mail else today(), sent_or_received="Received") if mail: - mail.save_attachments_in_doc(ticket.doc) + mail.save_attachments_in_doc(ticket) return ticket \ No newline at end of file diff --git a/erpnext/support/doctype/support_ticket/support_ticket.js b/erpnext/support/doctype/support_ticket/support_ticket.js index 034fa8694ff..c18653549cc 100644 --- a/erpnext/support/doctype/support_ticket/support_ticket.js +++ b/erpnext/support/doctype/support_ticket/support_ticket.js @@ -34,7 +34,7 @@ $.extend(cur_frm.cscript, { make_listing: function(doc) { var wrapper = cur_frm.fields_dict['thread_html'].wrapper; - var comm_list = frappe.model.get("Communication", {"parent": doc.name, "parenttype":"Support Ticket"}) + var comm_list = frappe.get_list("Communication", {"parent": doc.name, "parenttype":"Support Ticket"}) if(!comm_list.length) { comm_list.push({ diff --git a/erpnext/support/doctype/support_ticket/support_ticket.json b/erpnext/support/doctype/support_ticket/support_ticket.json new file mode 100644 index 00000000000..1a2e856c543 --- /dev/null +++ b/erpnext/support/doctype/support_ticket/support_ticket.json @@ -0,0 +1,290 @@ +{ + "allow_attach": 1, + "autoname": "naming_series:", + "creation": "2013-02-01 10:36:25.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "subject_section", + "fieldtype": "Section Break", + "label": "Subject", + "options": "icon-flag", + "permlevel": 0 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "hidden": 0, + "label": "Series", + "no_copy": 1, + "options": "SUP", + "permlevel": 0, + "print_hide": 1, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "subject", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Subject", + "permlevel": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "cb00", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": "Open", + "fieldname": "status", + "fieldtype": "Select", + "in_filter": 0, + "in_list_view": 1, + "label": "Status", + "no_copy": 1, + "oldfieldname": "status", + "oldfieldtype": "Select", + "options": "Open\nReplied\nHold\nClosed", + "permlevel": 0, + "read_only": 0, + "reqd": 0, + "search_index": 1 + }, + { + "depends_on": "eval:doc.__islocal", + "fieldname": "raised_by", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Raised By (Email)", + "oldfieldname": "raised_by", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "sb00", + "fieldtype": "Section Break", + "label": "Messages", + "options": "icon-comments", + "permlevel": 0 + }, + { + "depends_on": "eval:doc.__islocal", + "fieldname": "description", + "fieldtype": "Text", + "label": "Description", + "oldfieldname": "problem_description", + "oldfieldtype": "Text", + "permlevel": 0, + "reqd": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "thread_html", + "fieldtype": "HTML", + "label": "Thread HTML", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "additional_info", + "fieldtype": "Section Break", + "label": "Reference", + "options": "icon-pushpin", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 1, + "width": "50%" + }, + { + "fieldname": "lead", + "fieldtype": "Link", + "label": "Lead", + "options": "Lead", + "permlevel": 0 + }, + { + "fieldname": "contact", + "fieldtype": "Link", + "label": "Contact", + "options": "Contact", + "permlevel": 0 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "in_filter": 1, + "label": "Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "customer_name", + "fieldtype": "Data", + "in_filter": 1, + "label": "Customer Name", + "oldfieldname": "customer_name", + "oldfieldtype": "Data", + "permlevel": 0, + "read_only": 1, + "reqd": 0, + "search_index": 0 + }, + { + "default": "Today", + "fieldname": "opening_date", + "fieldtype": "Date", + "label": "Opening Date", + "no_copy": 1, + "oldfieldname": "opening_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "opening_time", + "fieldtype": "Time", + "label": "Opening Time", + "no_copy": 1, + "oldfieldname": "opening_time", + "oldfieldtype": "Time", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0, + "print_hide": 1, + "reqd": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "first_responded_on", + "fieldtype": "Datetime", + "label": "First Responded On", + "permlevel": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "resolution_date", + "fieldtype": "Datetime", + "in_filter": 0, + "label": "Resolution Date", + "no_copy": 1, + "oldfieldname": "resolution_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "resolution_details", + "fieldtype": "Small Text", + "label": "Resolution Details", + "no_copy": 1, + "oldfieldname": "resolution_details", + "oldfieldtype": "Text", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "content_type", + "fieldtype": "Data", + "hidden": 1, + "label": "Content Type", + "permlevel": 0 + }, + { + "fieldname": "communications", + "fieldtype": "Table", + "hidden": 1, + "label": "Communications", + "options": "Communication", + "permlevel": 0, + "print_hide": 1 + } + ], + "icon": "icon-ticket", + "idx": 1, + "modified": "2014-01-20 17:49:31.000000", + "modified_by": "Administrator", + "module": "Support", + "name": "Support Ticket", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Guest", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Customer", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Support Team", + "submit": 0, + "write": 1 + } + ], + "search_fields": "status,customer,allocated_to,subject,raised_by" +} \ No newline at end of file diff --git a/erpnext/support/doctype/support_ticket/support_ticket.py b/erpnext/support/doctype/support_ticket/support_ticket.py index 57d141ea013..9517ea48def 100644 --- a/erpnext/support/doctype/support_ticket/support_ticket.py +++ b/erpnext/support/doctype/support_ticket/support_ticket.py @@ -7,16 +7,13 @@ import frappe from erpnext.utilities.transaction_base import TransactionBase from frappe.utils import now, extract_email_id -class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class SupportTicket(TransactionBase): def get_sender(self, comm): return frappe.db.get_value('Support Email Settings',None,'support_email') def get_subject(self, comm): - return '[' + self.doc.name + '] ' + (comm.subject or 'No Subject Specified') + return '[' + self.name + '] ' + (comm.subject or 'No Subject Specified') def get_content(self, comm): signature = frappe.db.get_value('Support Email Settings',None,'support_signature') @@ -30,38 +27,38 @@ class DocType(TransactionBase): def validate(self): self.update_status() - self.set_lead_contact(self.doc.raised_by) + self.set_lead_contact(self.raised_by) - if self.doc.status == "Closed": + if self.status == "Closed": from frappe.widgets.form.assign_to import clear - clear(self.doc.doctype, self.doc.name) + clear(self.doctype, self.name) def set_lead_contact(self, email_id): import email.utils email_id = email.utils.parseaddr(email_id) if email_id: - if not self.doc.lead: - self.doc.lead = frappe.db.get_value("Lead", {"email_id": email_id}) - if not self.doc.contact: - self.doc.contact = frappe.db.get_value("Contact", {"email_id": email_id}) + if not self.lead: + self.lead = frappe.db.get_value("Lead", {"email_id": email_id}) + if not self.contact: + self.contact = frappe.db.get_value("Contact", {"email_id": email_id}) - if not self.doc.company: - self.doc.company = frappe.db.get_value("Lead", self.doc.lead, "company") or \ + if not self.company: + self.company = frappe.db.get_value("Lead", self.lead, "company") or \ frappe.db.get_default("company") def update_status(self): - status = frappe.db.get_value("Support Ticket", self.doc.name, "status") - if self.doc.status!="Open" and status =="Open" and not self.doc.first_responded_on: - self.doc.first_responded_on = now() - if self.doc.status=="Closed" and status !="Closed": - self.doc.resolution_date = now() - if self.doc.status=="Open" and status !="Open": - self.doc.resolution_date = "" + status = frappe.db.get_value("Support Ticket", self.name, "status") + if self.status!="Open" and status =="Open" and not self.first_responded_on: + self.first_responded_on = now() + if self.status=="Closed" and status !="Closed": + self.resolution_date = now() + if self.status=="Open" and status !="Open": + self.resolution_date = "" @frappe.whitelist() def set_status(name, status): - st = frappe.bean("Support Ticket", name) - st.doc.status = status + st = frappe.get_doc("Support Ticket", name) + st.status = status st.save() def auto_close_tickets(): diff --git a/erpnext/support/doctype/support_ticket/support_ticket.txt b/erpnext/support/doctype/support_ticket/support_ticket.txt deleted file mode 100644 index 2eac196af69..00000000000 --- a/erpnext/support/doctype/support_ticket/support_ticket.txt +++ /dev/null @@ -1,291 +0,0 @@ -[ - { - "creation": "2013-02-01 10:36:25", - "docstatus": 0, - "modified": "2014-01-20 17:49:31", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "autoname": "naming_series:", - "doctype": "DocType", - "icon": "icon-ticket", - "module": "Support", - "name": "__common__", - "search_fields": "status,customer,allocated_to,subject,raised_by" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Support Ticket", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Support Ticket", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Support Ticket" - }, - { - "doctype": "DocField", - "fieldname": "subject_section", - "fieldtype": "Section Break", - "label": "Subject", - "options": "icon-flag" - }, - { - "doctype": "DocField", - "fieldname": "naming_series", - "fieldtype": "Select", - "hidden": 0, - "label": "Series", - "no_copy": 1, - "options": "SUP", - "print_hide": 1, - "reqd": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "subject", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Subject", - "report_hide": 0, - "reqd": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "cb00", - "fieldtype": "Column Break" - }, - { - "default": "Open", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "in_filter": 0, - "in_list_view": 1, - "label": "Status", - "no_copy": 1, - "oldfieldname": "status", - "oldfieldtype": "Select", - "options": "Open\nReplied\nHold\nClosed", - "read_only": 0, - "reqd": 0, - "search_index": 1 - }, - { - "depends_on": "eval:doc.__islocal", - "doctype": "DocField", - "fieldname": "raised_by", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Raised By (Email)", - "oldfieldname": "raised_by", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "sb00", - "fieldtype": "Section Break", - "label": "Messages", - "options": "icon-comments" - }, - { - "depends_on": "eval:doc.__islocal", - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "label": "Description", - "oldfieldname": "problem_description", - "oldfieldtype": "Text", - "reqd": 0 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "thread_html", - "fieldtype": "HTML", - "label": "Thread HTML", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "additional_info", - "fieldtype": "Section Break", - "label": "Reference", - "options": "icon-pushpin", - "read_only": 1 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 1, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "lead", - "fieldtype": "Link", - "label": "Lead", - "options": "Lead" - }, - { - "doctype": "DocField", - "fieldname": "contact", - "fieldtype": "Link", - "label": "Contact", - "options": "Contact" - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "in_filter": 1, - "label": "Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 1, - "read_only": 0, - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "in_filter": 1, - "label": "Customer Name", - "oldfieldname": "customer_name", - "oldfieldtype": "Data", - "read_only": 1, - "reqd": 0, - "search_index": 0 - }, - { - "default": "Today", - "doctype": "DocField", - "fieldname": "opening_date", - "fieldtype": "Date", - "label": "Opening Date", - "no_copy": 1, - "oldfieldname": "opening_date", - "oldfieldtype": "Date", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "opening_time", - "fieldtype": "Time", - "label": "Opening Time", - "no_copy": 1, - "oldfieldname": "opening_time", - "oldfieldtype": "Time", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company", - "print_hide": 1, - "reqd": 0 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "first_responded_on", - "fieldtype": "Datetime", - "label": "First Responded On" - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "resolution_date", - "fieldtype": "Datetime", - "in_filter": 0, - "label": "Resolution Date", - "no_copy": 1, - "oldfieldname": "resolution_date", - "oldfieldtype": "Date", - "read_only": 1, - "search_index": 0 - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "resolution_details", - "fieldtype": "Small Text", - "label": "Resolution Details", - "no_copy": 1, - "oldfieldname": "resolution_details", - "oldfieldtype": "Text", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "content_type", - "fieldtype": "Data", - "hidden": 1, - "label": "Content Type" - }, - { - "doctype": "DocField", - "fieldname": "communications", - "fieldtype": "Table", - "hidden": 1, - "label": "Communications", - "options": "Communication", - "print_hide": 1 - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Guest" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Customer" - }, - { - "delete": 1, - "doctype": "DocPerm", - "role": "Support Team" - } -] \ No newline at end of file diff --git a/erpnext/support/page/support_analytics/support_analytics.json b/erpnext/support/page/support_analytics/support_analytics.json new file mode 100644 index 00000000000..3d8b4860cef --- /dev/null +++ b/erpnext/support/page/support_analytics/support_analytics.json @@ -0,0 +1,20 @@ +{ + "creation": "2013-01-04 15:31:45.000000", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-bar-chart", + "idx": 1, + "modified": "2013-07-11 14:44:24.000000", + "modified_by": "Administrator", + "module": "Support", + "name": "support-analytics", + "owner": "Administrator", + "page_name": "support-analytics", + "roles": [ + { + "role": "Support Team" + } + ], + "standard": "Yes", + "title": "Support Analytics" +} \ No newline at end of file diff --git a/erpnext/support/page/support_analytics/support_analytics.txt b/erpnext/support/page/support_analytics/support_analytics.txt deleted file mode 100644 index 3b9f190a56a..00000000000 --- a/erpnext/support/page/support_analytics/support_analytics.txt +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "creation": "2013-01-04 15:31:45", - "docstatus": 0, - "modified": "2013-07-11 14:44:24", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-bar-chart", - "module": "Support", - "name": "__common__", - "page_name": "support-analytics", - "standard": "Yes", - "title": "Support Analytics" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "support-analytics", - "parentfield": "roles", - "parenttype": "Page", - "role": "Support Team" - }, - { - "doctype": "Page", - "name": "support-analytics" - }, - { - "doctype": "Page Role" - } -] \ No newline at end of file diff --git a/erpnext/support/report/maintenance_schedules/maintenance_schedules.json b/erpnext/support/report/maintenance_schedules/maintenance_schedules.json new file mode 100644 index 00000000000..b8885d47649 --- /dev/null +++ b/erpnext/support/report/maintenance_schedules/maintenance_schedules.json @@ -0,0 +1,16 @@ +{ + "creation": "2013-05-06 14:25:21.000000", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-03-07 15:30:27.000000", + "modified_by": "Administrator", + "module": "Support", + "name": "Maintenance Schedules", + "owner": "Administrator", + "query": "SELECT\n ms_sch.scheduled_date as \"Schedule Date:Date:120\",\n\tms_sch.item_code as \"Item Code:Link/Item:120\",\n\tms_sch.item_name as \"Item Name::120\",\n\tms_sch.serial_no as \"Serial No::120\",\n\tms_sch.sales_person as \"Sales Person::120\",\n\tms.customer_name as \"Customer:Link/Customer:120\",\n\tms.address_display as \"Customer Address::120\",\n\tms_item.prevdoc_docname as \"Sales Order:Link/Sales Order:120\",\n\tms.company as \"Company:Link/Company:120\"\n\t\nFROM\n\t`tabMaintenance Schedule` ms, \n `tabMaintenance Schedule Detail` ms_sch, \n `tabMaintenance Schedule Item` ms_item\nWHERE\n\tms.name = ms_sch.parent and ms.name = ms_item.parent and ms.docstatus = 1\nORDER BY\n\tms_sch.scheduled_date asc, ms_sch.item_code asc", + "ref_doctype": "Maintenance Schedule", + "report_name": "Maintenance Schedules", + "report_type": "Query Report" +} \ No newline at end of file diff --git a/erpnext/support/report/maintenance_schedules/maintenance_schedules.txt b/erpnext/support/report/maintenance_schedules/maintenance_schedules.txt deleted file mode 100644 index a4c6fdb5e04..00000000000 --- a/erpnext/support/report/maintenance_schedules/maintenance_schedules.txt +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "creation": "2013-05-06 14:25:21", - "docstatus": 0, - "modified": "2014-03-07 15:30:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "module": "Support", - "name": "__common__", - "query": "SELECT\n ms_sch.scheduled_date as \"Schedule Date:Date:120\",\n\tms_sch.item_code as \"Item Code:Link/Item:120\",\n\tms_sch.item_name as \"Item Name::120\",\n\tms_sch.serial_no as \"Serial No::120\",\n\tms_sch.sales_person as \"Sales Person::120\",\n\tms.customer_name as \"Customer:Link/Customer:120\",\n\tms.address_display as \"Customer Address::120\",\n\tms_item.prevdoc_docname as \"Sales Order:Link/Sales Order:120\",\n\tms.company as \"Company:Link/Company:120\"\n\t\nFROM\n\t`tabMaintenance Schedule` ms, \n `tabMaintenance Schedule Detail` ms_sch, \n `tabMaintenance Schedule Item` ms_item\nWHERE\n\tms.name = ms_sch.parent and ms.name = ms_item.parent and ms.docstatus = 1\nORDER BY\n\tms_sch.scheduled_date asc, ms_sch.item_code asc", - "ref_doctype": "Maintenance Schedule", - "report_name": "Maintenance Schedules", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Maintenance Schedules" - } -] \ No newline at end of file diff --git a/erpnext/utilities/cleanup_data.py b/erpnext/utilities/cleanup_data.py index c6a78c3163c..30b16bcbf21 100644 --- a/erpnext/utilities/cleanup_data.py +++ b/erpnext/utilities/cleanup_data.py @@ -154,11 +154,10 @@ def reset_global_defaults(): 'default_price_list_currency': None, } - from frappe.model.code import get_obj - gd = get_obj('Global Defaults', 'Global Defaults') + gd = frappe.get_doc('Global Defaults', 'Global Defaults') for d in flds: - gd.doc.fields[d] = flds[d] - gd.doc.save() + gd.set(d, flds[d]) + gd.save() frappe.clear_cache() diff --git a/erpnext/utilities/doctype/address/address.json b/erpnext/utilities/doctype/address/address.json new file mode 100644 index 00000000000..e1532d681de --- /dev/null +++ b/erpnext/utilities/doctype/address/address.json @@ -0,0 +1,262 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "creation": "2013-01-10 16:34:32.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "address_details", + "fieldtype": "Section Break", + "label": "Address Details", + "options": "icon-map-marker", + "permlevel": 0 + }, + { + "description": "Name of person or organization that this address belongs to.", + "fieldname": "address_title", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Address Title", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "address_type", + "fieldtype": "Select", + "label": "Address Type", + "options": "Billing\nShipping\nOffice\nPersonal\nPlant\nPostal\nShop\nSubsidiary\nWarehouse\nOther", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "address_line1", + "fieldtype": "Data", + "label": "Address Line 1", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "address_line2", + "fieldtype": "Data", + "label": "Address Line 2", + "permlevel": 0 + }, + { + "fieldname": "city", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "City/Town", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "state", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "State", + "options": "Suggest", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "pincode", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 1, + "label": "Pincode", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "country", + "fieldtype": "Select", + "in_filter": 1, + "in_list_view": 1, + "label": "Country", + "options": "link:Country", + "permlevel": 0, + "reqd": 1, + "search_index": 1 + }, + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "print_hide": 0, + "width": "50%" + }, + { + "fieldname": "email_id", + "fieldtype": "Data", + "label": "Email Id", + "permlevel": 0 + }, + { + "fieldname": "phone", + "fieldtype": "Data", + "label": "Phone", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "fax", + "fieldtype": "Data", + "in_filter": 1, + "label": "Fax", + "permlevel": 0 + }, + { + "default": "0", + "description": "Check to make primary address", + "fieldname": "is_primary_address", + "fieldtype": "Check", + "label": "Preferred Billing Address", + "permlevel": 0 + }, + { + "default": "0", + "description": "Check to make Shipping Address", + "fieldname": "is_shipping_address", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Preferred Shipping Address", + "permlevel": 0 + }, + { + "fieldname": "linked_with", + "fieldtype": "Section Break", + "label": "Reference", + "options": "icon-pushpin", + "permlevel": 0 + }, + { + "fieldname": "customer", + "fieldtype": "Link", + "label": "Customer", + "options": "Customer", + "permlevel": 0 + }, + { + "fieldname": "customer_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 0, + "label": "Customer Name", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "supplier", + "fieldtype": "Link", + "label": "Supplier", + "options": "Supplier", + "permlevel": 0 + }, + { + "fieldname": "supplier_name", + "fieldtype": "Data", + "in_filter": 1, + "in_list_view": 0, + "label": "Supplier Name", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, + { + "fieldname": "sales_partner", + "fieldtype": "Link", + "label": "Sales Partner", + "options": "Sales Partner", + "permlevel": 0 + }, + { + "fieldname": "column_break_22", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "depends_on": "eval:!doc.supplier && !doc.sales_partner", + "fieldname": "lead", + "fieldtype": "Link", + "label": "Lead", + "options": "Lead", + "permlevel": 0 + }, + { + "depends_on": "eval:!doc.supplier && !doc.sales_partner", + "fieldname": "lead_name", + "fieldtype": "Data", + "label": "Lead Name", + "permlevel": 0, + "read_only": 1 + } + ], + "icon": "icon-map-marker", + "idx": 1, + "in_dialog": 0, + "modified": "2014-01-27 11:19:06.000000", + "modified_by": "Administrator", + "module": "Utilities", + "name": "Address", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Maintenance User", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 0, + "write": 1 + } + ], + "search_fields": "customer, supplier, sales_partner, country, state" +} \ No newline at end of file diff --git a/erpnext/utilities/doctype/address/address.py b/erpnext/utilities/doctype/address/address.py index b80f13a337d..04d54f2378f 100644 --- a/erpnext/utilities/doctype/address/address.py +++ b/erpnext/utilities/doctype/address/address.py @@ -7,18 +7,17 @@ import frappe from frappe import msgprint, throw, _ from frappe.utils import cstr, cint -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +from frappe.model.document import Document + +class Address(Document): def autoname(self): - if not self.doc.address_title: - self.doc.address_title = self.doc.customer \ - or self.doc.supplier or self.doc.sales_partner or self.doc.lead + if not self.address_title: + self.address_title = self.customer \ + or self.supplier or self.sales_partner or self.lead - if self.doc.address_title: - self.doc.name = cstr(self.doc.address_title).strip() + "-" + cstr(self.doc.address_type).strip() + if self.address_title: + self.name = cstr(self.address_title).strip() + "-" + cstr(self.address_type).strip() else: throw(_("Address Title is mandatory.")) @@ -28,28 +27,28 @@ class DocType: def validate_primary_address(self): """Validate that there can only be one primary address for particular customer, supplier""" - if self.doc.is_primary_address == 1: + if self.is_primary_address == 1: self._unset_other("is_primary_address") - elif self.doc.is_shipping_address != 1: + elif self.is_shipping_address != 1: for fieldname in ["customer", "supplier", "sales_partner", "lead"]: - if self.doc.fields.get(fieldname): + if self.get(fieldname): if not frappe.db.sql("""select name from `tabAddress` where is_primary_address=1 and `%s`=%s and name!=%s""" % (fieldname, "%s", "%s"), - (self.doc.fields[fieldname], self.doc.name)): - self.doc.is_primary_address = 1 + (self.get(fieldname), self.name)): + self.is_primary_address = 1 break def validate_shipping_address(self): """Validate that there can only be one shipping address for particular customer, supplier""" - if self.doc.is_shipping_address == 1: + if self.is_shipping_address == 1: self._unset_other("is_shipping_address") def _unset_other(self, is_address_type): for fieldname in ["customer", "supplier", "sales_partner", "lead"]: - if self.doc.fields.get(fieldname): + if self.get(fieldname): frappe.db.sql("""update `tabAddress` set `%s`=0 where `%s`=%s and name!=%s""" % - (is_address_type, fieldname, "%s", "%s"), (self.doc.fields[fieldname], self.doc.name)) + (is_address_type, fieldname, "%s", "%s"), (self.get(fieldname), self.name)) break @frappe.whitelist() @@ -57,7 +56,7 @@ def get_address_display(address_dict): if not isinstance(address_dict, dict): address_dict = frappe.db.get_value("Address", address_dict, "*", as_dict=True) or {} - meta = frappe.get_doctype("Address") + meta = frappe.get_meta("Address") sequence = (("", "address_line1"), ("\n", "address_line2"), ("\n", "city"), diff --git a/erpnext/utilities/doctype/address/address.txt b/erpnext/utilities/doctype/address/address.txt deleted file mode 100644 index aa9230dcb6c..00000000000 --- a/erpnext/utilities/doctype/address/address.txt +++ /dev/null @@ -1,254 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:32", - "docstatus": 0, - "modified": "2014-01-27 11:19:06", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-map-marker", - "in_dialog": 0, - "module": "Utilities", - "name": "__common__", - "search_fields": "customer, supplier, sales_partner, country, state" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Address", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Address", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Address" - }, - { - "doctype": "DocField", - "fieldname": "address_details", - "fieldtype": "Section Break", - "label": "Address Details", - "options": "icon-map-marker" - }, - { - "description": "Name of person or organization that this address belongs to.", - "doctype": "DocField", - "fieldname": "address_title", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Address Title", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "address_type", - "fieldtype": "Select", - "label": "Address Type", - "options": "Billing\nShipping\nOffice\nPersonal\nPlant\nPostal\nShop\nSubsidiary\nWarehouse\nOther", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_line1", - "fieldtype": "Data", - "label": "Address Line 1", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "address_line2", - "fieldtype": "Data", - "label": "Address Line 2" - }, - { - "doctype": "DocField", - "fieldname": "city", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "City/Town", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "state", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "State", - "options": "Suggest", - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "pincode", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 1, - "label": "Pincode", - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "country", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Country", - "options": "link:Country", - "reqd": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "print_hide": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "email_id", - "fieldtype": "Data", - "label": "Email Id" - }, - { - "doctype": "DocField", - "fieldname": "phone", - "fieldtype": "Data", - "label": "Phone", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "fax", - "fieldtype": "Data", - "in_filter": 1, - "label": "Fax" - }, - { - "default": "0", - "description": "Check to make primary address", - "doctype": "DocField", - "fieldname": "is_primary_address", - "fieldtype": "Check", - "label": "Preferred Billing Address" - }, - { - "default": "0", - "description": "Check to make Shipping Address", - "doctype": "DocField", - "fieldname": "is_shipping_address", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Preferred Shipping Address" - }, - { - "doctype": "DocField", - "fieldname": "linked_with", - "fieldtype": "Section Break", - "label": "Reference", - "options": "icon-pushpin" - }, - { - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "label": "Customer", - "options": "Customer" - }, - { - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 0, - "label": "Customer Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "supplier", - "fieldtype": "Link", - "label": "Supplier", - "options": "Supplier" - }, - { - "doctype": "DocField", - "fieldname": "supplier_name", - "fieldtype": "Data", - "in_filter": 1, - "in_list_view": 0, - "label": "Supplier Name", - "read_only": 1, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "sales_partner", - "fieldtype": "Link", - "label": "Sales Partner", - "options": "Sales Partner" - }, - { - "doctype": "DocField", - "fieldname": "column_break_22", - "fieldtype": "Column Break" - }, - { - "depends_on": "eval:!doc.supplier && !doc.sales_partner", - "doctype": "DocField", - "fieldname": "lead", - "fieldtype": "Link", - "label": "Lead", - "options": "Lead" - }, - { - "depends_on": "eval:!doc.supplier && !doc.sales_partner", - "doctype": "DocField", - "fieldname": "lead_name", - "fieldtype": "Data", - "label": "Lead Name", - "read_only": 1 - }, - { - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "doctype": "DocPerm", - "role": "Purchase User" - }, - { - "doctype": "DocPerm", - "role": "Maintenance User" - }, - { - "doctype": "DocPerm", - "role": "Accounts User" - } -] \ No newline at end of file diff --git a/erpnext/utilities/doctype/address/test_address.py b/erpnext/utilities/doctype/address/test_address.py index befbe82b246..815449aaa7a 100644 --- a/erpnext/utilities/doctype/address/test_address.py +++ b/erpnext/utilities/doctype/address/test_address.py @@ -1,17 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Address", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "address_type": "Office", - "address_title": "_Test Address", - "address_line1": "_Test Address Line 1", - "city": "_Test City", - "country": "India", - "phone": "+91 0000000000", - "is_primary_address": 1 - }], -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Address') \ No newline at end of file diff --git a/erpnext/utilities/doctype/address/test_records.json b/erpnext/utilities/doctype/address/test_records.json new file mode 100644 index 00000000000..41a6abcd095 --- /dev/null +++ b/erpnext/utilities/doctype/address/test_records.json @@ -0,0 +1,14 @@ +[ + { + "address_line1": "_Test Address Line 1", + "address_title": "_Test Address", + "address_type": "Office", + "city": "_Test City", + "country": "India", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "doctype": "Address", + "is_primary_address": 1, + "phone": "+91 0000000000" + } +] \ No newline at end of file diff --git a/erpnext/utilities/doctype/contact/contact.js b/erpnext/utilities/doctype/contact/contact.js index eb7681f8865..f2a2fdcef29 100644 --- a/erpnext/utilities/doctype/contact/contact.js +++ b/erpnext/utilities/doctype/contact/contact.js @@ -5,7 +5,7 @@ cur_frm.cscript.refresh = function(doc) { cur_frm.communication_view = new frappe.views.CommunicationList({ - list: frappe.model.get("Communication", {"parent": doc.name, "parenttype": "Contact"}), + list: frappe.get_list("Communication", {"parent": doc.name, "parenttype": "Contact"}), parent: cur_frm.fields_dict.communication_html.wrapper, doc: doc, recipients: doc.email_id diff --git a/erpnext/utilities/doctype/contact/contact.json b/erpnext/utilities/doctype/contact/contact.json new file mode 100644 index 00000000000..bf9f075d1f9 --- /dev/null +++ b/erpnext/utilities/doctype/contact/contact.json @@ -0,0 +1,362 @@ +{ + "allow_import": 1, + "allow_rename": 1, + "creation": "2013-01-10 16:34:32.000000", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "fieldname": "contact_section", + "fieldtype": "Section Break", + "label": "Contact Details", + "options": "icon-user", + "permlevel": 0 + }, + { + "fieldname": "first_name", + "fieldtype": "Data", + "label": "First Name", + "oldfieldname": "first_name", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "last_name", + "fieldtype": "Data", + "label": "Last Name", + "oldfieldname": "last_name", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "fieldname": "cb00", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": "Passive", + "fieldname": "status", + "fieldtype": "Select", + "label": "Status", + "options": "Passive\nOpen\nReplied", + "permlevel": 0 + }, + { + "fieldname": "email_id", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Email Id", + "oldfieldname": "email_id", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 0, + "search_index": 1 + }, + { + "fieldname": "phone", + "fieldtype": "Data", + "label": "Phone", + "oldfieldname": "contact_no", + "oldfieldtype": "Data", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "sb00", + "fieldtype": "Section Break", + "label": "Communication History", + "options": "icon-comments", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "communication_html", + "fieldtype": "HTML", + "label": "Communication HTML", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "contact_details", + "fieldtype": "Section Break", + "label": "Reference", + "options": "icon-pushpin", + "permlevel": 0 + }, + { + "depends_on": "eval:!doc.supplier && !doc.sales_partner", + "fieldname": "customer", + "fieldtype": "Link", + "label": "Customer", + "oldfieldname": "customer", + "oldfieldtype": "Link", + "options": "Customer", + "permlevel": 0, + "print_hide": 0 + }, + { + "depends_on": "eval:!doc.supplier && !doc.sales_partner", + "fieldname": "customer_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Customer Name", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "depends_on": "eval:!doc.customer && !doc.sales_partner", + "fieldname": "supplier", + "fieldtype": "Link", + "label": "Supplier", + "options": "Supplier", + "permlevel": 0 + }, + { + "allow_on_submit": 0, + "depends_on": "eval:!doc.customer && !doc.sales_partner", + "fieldname": "supplier_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Supplier Name", + "permlevel": 0, + "read_only": 1 + }, + { + "depends_on": "eval:!doc.customer && !doc.supplier", + "fieldname": "sales_partner", + "fieldtype": "Link", + "label": "Sales Partner", + "options": "Sales Partner", + "permlevel": 0 + }, + { + "default": "0", + "depends_on": "eval:(doc.customer || doc.supplier || doc.sales_partner)", + "fieldname": "is_primary_contact", + "fieldtype": "Check", + "label": "Is Primary Contact", + "oldfieldname": "is_primary_contact", + "oldfieldtype": "Select", + "permlevel": 0 + }, + { + "fieldname": "more_info", + "fieldtype": "Section Break", + "label": "More Info", + "options": "icon-file-text", + "permlevel": 0 + }, + { + "fieldname": "mobile_no", + "fieldtype": "Data", + "label": "Mobile No", + "oldfieldname": "mobile_no", + "oldfieldtype": "Data", + "permlevel": 0 + }, + { + "description": "Enter department to which this Contact belongs", + "fieldname": "department", + "fieldtype": "Data", + "label": "Department", + "options": "Suggest", + "permlevel": 0 + }, + { + "description": "Enter designation of this Contact", + "fieldname": "designation", + "fieldtype": "Data", + "label": "Designation", + "options": "Suggest", + "permlevel": 0 + }, + { + "fieldname": "unsubscribed", + "fieldtype": "Check", + "label": "Unsubscribed", + "permlevel": 0 + }, + { + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "oldfieldtype": "Small Text", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "communications", + "fieldtype": "Table", + "hidden": 1, + "label": "Communications", + "options": "Communication", + "permlevel": 0, + "print_hide": 1 + } + ], + "icon": "icon-user", + "idx": 1, + "in_create": 0, + "in_dialog": 0, + "modified": "2014-01-20 17:48:29.000000", + "modified_by": "Administrator", + "module": "Utilities", + "name": "Contact", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Master Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Master Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Maintenance Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Sales User", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Purchase User", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Maintenance User", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/utilities/doctype/contact/contact.py b/erpnext/utilities/doctype/contact/contact.py index 948b753fcd9..28597efdcb0 100644 --- a/erpnext/utilities/doctype/contact/contact.py +++ b/erpnext/utilities/doctype/contact/contact.py @@ -7,20 +7,17 @@ from frappe.utils import cstr, extract_email_id from erpnext.controllers.status_updater import StatusUpdater -class DocType(StatusUpdater): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist +class Contact(StatusUpdater): def autoname(self): # concat first and last name - self.doc.name = " ".join(filter(None, - [cstr(self.doc.fields.get(f)).strip() for f in ["first_name", "last_name"]])) + self.name = " ".join(filter(None, + [cstr(self.get(f)).strip() for f in ["first_name", "last_name"]])) # concat party name if reqd for fieldname in ("customer", "supplier", "sales_partner"): - if self.doc.fields.get(fieldname): - self.doc.name = self.doc.name + "-" + cstr(self.doc.fields.get(fieldname)).strip() + if self.get(fieldname): + self.name = self.name + "-" + cstr(self.get(fieldname)).strip() break def validate(self): @@ -28,38 +25,38 @@ class DocType(StatusUpdater): self.validate_primary_contact() def validate_primary_contact(self): - if self.doc.is_primary_contact == 1: - if self.doc.customer: + if self.is_primary_contact == 1: + if self.customer: frappe.db.sql("update tabContact set is_primary_contact=0 where customer = %s", - (self.doc.customer)) - elif self.doc.supplier: + (self.customer)) + elif self.supplier: frappe.db.sql("update tabContact set is_primary_contact=0 where supplier = %s", - (self.doc.supplier)) - elif self.doc.sales_partner: + (self.supplier)) + elif self.sales_partner: frappe.db.sql("""update tabContact set is_primary_contact=0 - where sales_partner = %s""", (self.doc.sales_partner)) + where sales_partner = %s""", (self.sales_partner)) else: - if self.doc.customer: + if self.customer: if not frappe.db.sql("select name from tabContact \ - where is_primary_contact=1 and customer = %s", (self.doc.customer)): - self.doc.is_primary_contact = 1 - elif self.doc.supplier: + where is_primary_contact=1 and customer = %s", (self.customer)): + self.is_primary_contact = 1 + elif self.supplier: if not frappe.db.sql("select name from tabContact \ - where is_primary_contact=1 and supplier = %s", (self.doc.supplier)): - self.doc.is_primary_contact = 1 - elif self.doc.sales_partner: + where is_primary_contact=1 and supplier = %s", (self.supplier)): + self.is_primary_contact = 1 + elif self.sales_partner: if not frappe.db.sql("select name from tabContact \ where is_primary_contact=1 and sales_partner = %s", - self.doc.sales_partner): - self.doc.is_primary_contact = 1 + self.sales_partner): + self.is_primary_contact = 1 def on_trash(self): frappe.db.sql("""update `tabSupport Ticket` set contact='' where contact=%s""", - self.doc.name) + self.name) @frappe.whitelist() def get_contact_details(contact): - contact = frappe.doc("Contact", contact) + contact = frappe.get_doc("Contact", contact) out = { "contact_person": contact.get("name"), "contact_display": " ".join(filter(None, diff --git a/erpnext/utilities/doctype/contact/contact.txt b/erpnext/utilities/doctype/contact/contact.txt deleted file mode 100644 index 5a3e32d650d..00000000000 --- a/erpnext/utilities/doctype/contact/contact.txt +++ /dev/null @@ -1,301 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:32", - "docstatus": 0, - "modified": "2014-01-20 17:48:29", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_import": 1, - "allow_rename": 1, - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-user", - "in_create": 0, - "in_dialog": 0, - "module": "Utilities", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Contact", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Contact", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Contact" - }, - { - "doctype": "DocField", - "fieldname": "contact_section", - "fieldtype": "Section Break", - "label": "Contact Details", - "options": "icon-user" - }, - { - "doctype": "DocField", - "fieldname": "first_name", - "fieldtype": "Data", - "label": "First Name", - "oldfieldname": "first_name", - "oldfieldtype": "Data", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "last_name", - "fieldtype": "Data", - "label": "Last Name", - "oldfieldname": "last_name", - "oldfieldtype": "Data" - }, - { - "doctype": "DocField", - "fieldname": "cb00", - "fieldtype": "Column Break" - }, - { - "default": "Passive", - "doctype": "DocField", - "fieldname": "status", - "fieldtype": "Select", - "label": "Status", - "options": "Passive\nOpen\nReplied" - }, - { - "doctype": "DocField", - "fieldname": "email_id", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Email Id", - "oldfieldname": "email_id", - "oldfieldtype": "Data", - "reqd": 0, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "phone", - "fieldtype": "Data", - "label": "Phone", - "oldfieldname": "contact_no", - "oldfieldtype": "Data", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "sb00", - "fieldtype": "Section Break", - "label": "Communication History", - "options": "icon-comments", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "communication_html", - "fieldtype": "HTML", - "label": "Communication HTML", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "contact_details", - "fieldtype": "Section Break", - "label": "Reference", - "options": "icon-pushpin" - }, - { - "depends_on": "eval:!doc.supplier && !doc.sales_partner", - "doctype": "DocField", - "fieldname": "customer", - "fieldtype": "Link", - "label": "Customer", - "oldfieldname": "customer", - "oldfieldtype": "Link", - "options": "Customer", - "print_hide": 0 - }, - { - "depends_on": "eval:!doc.supplier && !doc.sales_partner", - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Customer Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", - "width": "50%" - }, - { - "depends_on": "eval:!doc.customer && !doc.sales_partner", - "doctype": "DocField", - "fieldname": "supplier", - "fieldtype": "Link", - "label": "Supplier", - "options": "Supplier" - }, - { - "allow_on_submit": 0, - "depends_on": "eval:!doc.customer && !doc.sales_partner", - "doctype": "DocField", - "fieldname": "supplier_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Supplier Name", - "read_only": 1 - }, - { - "depends_on": "eval:!doc.customer && !doc.supplier", - "doctype": "DocField", - "fieldname": "sales_partner", - "fieldtype": "Link", - "label": "Sales Partner", - "options": "Sales Partner" - }, - { - "default": "0", - "depends_on": "eval:(doc.customer || doc.supplier || doc.sales_partner)", - "doctype": "DocField", - "fieldname": "is_primary_contact", - "fieldtype": "Check", - "label": "Is Primary Contact", - "oldfieldname": "is_primary_contact", - "oldfieldtype": "Select" - }, - { - "doctype": "DocField", - "fieldname": "more_info", - "fieldtype": "Section Break", - "label": "More Info", - "options": "icon-file-text" - }, - { - "doctype": "DocField", - "fieldname": "mobile_no", - "fieldtype": "Data", - "label": "Mobile No", - "oldfieldname": "mobile_no", - "oldfieldtype": "Data" - }, - { - "description": "Enter department to which this Contact belongs", - "doctype": "DocField", - "fieldname": "department", - "fieldtype": "Data", - "label": "Department", - "options": "Suggest" - }, - { - "description": "Enter designation of this Contact", - "doctype": "DocField", - "fieldname": "designation", - "fieldtype": "Data", - "label": "Designation", - "options": "Suggest" - }, - { - "doctype": "DocField", - "fieldname": "unsubscribed", - "fieldtype": "Check", - "label": "Unsubscribed" - }, - { - "doctype": "DocField", - "fieldname": "trash_reason", - "fieldtype": "Small Text", - "label": "Trash Reason", - "oldfieldname": "trash_reason", - "oldfieldtype": "Small Text", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "communications", - "fieldtype": "Table", - "hidden": 1, - "label": "Communications", - "options": "Communication", - "print_hide": 1 - }, - { - "delete": 1, - "doctype": "DocPerm", - "role": "System Manager" - }, - { - "amend": 0, - "delete": 1, - "doctype": "DocPerm", - "role": "Sales Master Manager" - }, - { - "delete": 1, - "doctype": "DocPerm", - "role": "Purchase Master Manager" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Sales Manager" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase Manager" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Maintenance Manager" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Accounts Manager" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Purchase User" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Maintenance User" - }, - { - "delete": 0, - "doctype": "DocPerm", - "role": "Accounts User" - } -] \ No newline at end of file diff --git a/erpnext/utilities/doctype/contact/test_contact.py b/erpnext/utilities/doctype/contact/test_contact.py index 5e7898f08a5..129ec300525 100644 --- a/erpnext/utilities/doctype/contact/test_contact.py +++ b/erpnext/utilities/doctype/contact/test_contact.py @@ -1,25 +1,6 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt -test_records = [ - [{ - "doctype": "Contact", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "first_name": "_Test Contact For _Test Customer", - "email_id": "test_contact_customer@example.com", - "phone": "+91 0000000000", - "status": "Open", - "is_primary_contact": 1 - }], - [{ - "doctype": "Contact", - "supplier": "_Test Supplier", - "supplier_name": "_Test Supplier", - "first_name": "_Test Contact For _Test Supplier", - "email_id": "test_contact_supplier@example.com", - "phone": "+91 0000000000", - "status": "Open", - "is_primary_contact": 1 - }] -] \ No newline at end of file + +import frappe +test_records = frappe.get_test_records('Contact') \ No newline at end of file diff --git a/erpnext/utilities/doctype/contact/test_records.json b/erpnext/utilities/doctype/contact/test_records.json new file mode 100644 index 00000000000..133a7b68830 --- /dev/null +++ b/erpnext/utilities/doctype/contact/test_records.json @@ -0,0 +1,22 @@ +[ + { + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "doctype": "Contact", + "email_id": "test_contact_customer@example.com", + "first_name": "_Test Contact For _Test Customer", + "is_primary_contact": 1, + "phone": "+91 0000000000", + "status": "Open" + }, + { + "doctype": "Contact", + "email_id": "test_contact_supplier@example.com", + "first_name": "_Test Contact For _Test Supplier", + "is_primary_contact": 1, + "phone": "+91 0000000000", + "status": "Open", + "supplier": "_Test Supplier", + "supplier_name": "_Test Supplier" + } +] \ No newline at end of file diff --git a/erpnext/utilities/doctype/note/note.json b/erpnext/utilities/doctype/note/note.json new file mode 100644 index 00000000000..9eab6a18ac0 --- /dev/null +++ b/erpnext/utilities/doctype/note/note.json @@ -0,0 +1,69 @@ +{ + "allow_rename": 1, + "creation": "2013-05-24 13:41:00.000000", + "description": "Note is a free page where users can share documents / notes", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Transaction", + "fields": [ + { + "fieldname": "title", + "fieldtype": "Data", + "label": "Title", + "permlevel": 0, + "print_hide": 1 + }, + { + "description": "Help: To link to another record in the system, use \"#Form/Note/[Note Name]\" as the Link URL. (don't use \"http://\")", + "fieldname": "content", + "fieldtype": "Text Editor", + "in_list_view": 0, + "label": "Content", + "permlevel": 0 + }, + { + "fieldname": "share", + "fieldtype": "Section Break", + "label": "Share", + "permlevel": 0 + }, + { + "description": "Everyone can read", + "fieldname": "public", + "fieldtype": "Check", + "label": "Public", + "permlevel": 0, + "print_hide": 1 + }, + { + "fieldname": "share_with", + "fieldtype": "Table", + "label": "Share With", + "options": "Note User", + "permlevel": 0, + "print_hide": 1 + } + ], + "icon": "icon-file-text", + "idx": 1, + "modified": "2014-01-22 16:05:35.000000", + "modified_by": "Administrator", + "module": "Utilities", + "name": "Note", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "restricted": 1, + "role": "All", + "write": 1 + } + ], + "read_only_onload": 1 +} \ No newline at end of file diff --git a/erpnext/utilities/doctype/note/note.py b/erpnext/utilities/doctype/note/note.py index 99846d9f9b7..f0c7f0e922d 100644 --- a/erpnext/utilities/doctype/note/note.py +++ b/erpnext/utilities/doctype/note/note.py @@ -6,23 +6,23 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class Note(Document): def autoname(self): # replace forbidden characters import re - self.doc.name = re.sub("[%'\"#*?`]", "", self.doc.title.strip()) + self.name = re.sub("[%'\"#*?`]", "", self.title.strip()) def onload(self): - if not self.doc.public and frappe.session.user != self.doc.owner: - if frappe.session.user not in [d.user for d in self.doclist if d.doctype=="Note User"]: + if not self.public and frappe.session.user != self.owner: + if frappe.session.user not in [d.user for d in self.get("share_with")]: frappe.msgprint("You are not authorized to read this record.", raise_exception=True) def validate(self): - if not self.doc.fields.get("__islocal"): - if frappe.session.user != self.doc.owner: + if not self.get("__islocal"): + if frappe.session.user != self.owner: if frappe.session.user not in frappe.db.sql_list("""select user from `tabNote User` - where parent=%s and permission='Edit'""", self.doc.name): + where parent=%s and permission='Edit'""", self.name): frappe.msgprint("You are not authorized to edit this record.", raise_exception=True) diff --git a/erpnext/utilities/doctype/note/note.txt b/erpnext/utilities/doctype/note/note.txt deleted file mode 100644 index 94e5a0fbb34..00000000000 --- a/erpnext/utilities/doctype/note/note.txt +++ /dev/null @@ -1,88 +0,0 @@ -[ - { - "creation": "2013-05-24 13:41:00", - "docstatus": 0, - "modified": "2014-01-22 16:05:35", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_rename": 1, - "description": "Note is a free page where users can share documents / notes", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-file-text", - "module": "Utilities", - "name": "__common__", - "read_only_onload": 1 - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Note", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 0, - "create": 1, - "delete": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Note", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "restricted": 1, - "role": "All", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Note" - }, - { - "doctype": "DocField", - "fieldname": "title", - "fieldtype": "Data", - "label": "Title", - "print_hide": 1 - }, - { - "description": "Help: To link to another record in the system, use \"#Form/Note/[Note Name]\" as the Link URL. (don't use \"http://\")", - "doctype": "DocField", - "fieldname": "content", - "fieldtype": "Text Editor", - "in_list_view": 0, - "label": "Content" - }, - { - "doctype": "DocField", - "fieldname": "share", - "fieldtype": "Section Break", - "label": "Share" - }, - { - "description": "Everyone can read", - "doctype": "DocField", - "fieldname": "public", - "fieldtype": "Check", - "label": "Public", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "share_with", - "fieldtype": "Table", - "label": "Share With", - "options": "Note User", - "print_hide": 1 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/utilities/doctype/note_user/note_user.json b/erpnext/utilities/doctype/note_user/note_user.json new file mode 100644 index 00000000000..f72f1bd2910 --- /dev/null +++ b/erpnext/utilities/doctype/note_user/note_user.json @@ -0,0 +1,34 @@ +{ + "creation": "2013-05-24 14:24:48.000000", + "description": "List of users who can edit a particular Note", + "docstatus": 0, + "doctype": "DocType", + "document_type": "Other", + "fields": [ + { + "fieldname": "user", + "fieldtype": "Link", + "in_list_view": 1, + "label": "User", + "options": "User", + "permlevel": 0, + "reqd": 1 + }, + { + "default": "Edit", + "fieldname": "permission", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Permission", + "options": "Edit\nRead", + "permlevel": 0 + } + ], + "idx": 1, + "istable": 1, + "modified": "2013-12-20 19:23:23.000000", + "modified_by": "Administrator", + "module": "Utilities", + "name": "Note User", + "owner": "Administrator" +} \ No newline at end of file diff --git a/erpnext/utilities/doctype/note_user/note_user.py b/erpnext/utilities/doctype/note_user/note_user.py index 968a25b6134..1594f787cad 100644 --- a/erpnext/utilities/doctype/note_user/note_user.py +++ b/erpnext/utilities/doctype/note_user/note_user.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class NoteUser(Document): + pass \ No newline at end of file diff --git a/erpnext/utilities/doctype/note_user/note_user.txt b/erpnext/utilities/doctype/note_user/note_user.txt deleted file mode 100644 index 6ae80de1a4e..00000000000 --- a/erpnext/utilities/doctype/note_user/note_user.txt +++ /dev/null @@ -1,46 +0,0 @@ -[ - { - "creation": "2013-05-24 14:24:48", - "docstatus": 0, - "modified": "2013-12-20 19:23:23", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "List of users who can edit a particular Note", - "doctype": "DocType", - "document_type": "Other", - "istable": 1, - "module": "Utilities", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Note User", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Note User" - }, - { - "doctype": "DocField", - "fieldname": "user", - "fieldtype": "Link", - "label": "User", - "options": "User", - "reqd": 1 - }, - { - "default": "Edit", - "doctype": "DocField", - "fieldname": "permission", - "fieldtype": "Select", - "label": "Permission", - "options": "Edit\nRead" - } -] \ No newline at end of file diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.json b/erpnext/utilities/doctype/rename_tool/rename_tool.json new file mode 100644 index 00000000000..a7384ec59c5 --- /dev/null +++ b/erpnext/utilities/doctype/rename_tool/rename_tool.json @@ -0,0 +1,51 @@ +{ + "allow_attach": 0, + "allow_email": 1, + "allow_print": 1, + "creation": "2012-12-03 10:25:59.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "description": "Type of document to rename.", + "fieldname": "select_doctype", + "fieldtype": "Select", + "label": "Select DocType", + "permlevel": 0 + }, + { + "fieldname": "upload_html", + "fieldtype": "HTML", + "label": "Upload HTML", + "permlevel": 0 + }, + { + "fieldname": "rename_log", + "fieldtype": "HTML", + "label": "Rename Log", + "permlevel": 0 + } + ], + "hide_heading": 0, + "hide_toolbar": 1, + "icon": "icon-magic", + "idx": 1, + "issingle": 1, + "max_attachments": 1, + "modified": "2013-07-05 14:52:51.000000", + "modified_by": "Administrator", + "module": "Utilities", + "name": "Rename Tool", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "permlevel": 0, + "read": 1, + "report": 0, + "role": "System Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.py b/erpnext/utilities/doctype/rename_tool/rename_tool.py index 835e6471e76..42c69f624ce 100644 --- a/erpnext/utilities/doctype/rename_tool/rename_tool.py +++ b/erpnext/utilities/doctype/rename_tool/rename_tool.py @@ -7,9 +7,10 @@ from __future__ import unicode_literals import frappe from frappe import _ -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl +from frappe.model.document import Document + +class RenameTool(Document): + pass @frappe.whitelist() def get_doctypes(): diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.txt b/erpnext/utilities/doctype/rename_tool/rename_tool.txt deleted file mode 100644 index e397cf3de4d..00000000000 --- a/erpnext/utilities/doctype/rename_tool/rename_tool.txt +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "creation": "2012-12-03 10:25:59", - "docstatus": 0, - "modified": "2013-07-05 14:52:51", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 0, - "allow_email": 1, - "allow_print": 1, - "doctype": "DocType", - "hide_heading": 0, - "hide_toolbar": 1, - "icon": "icon-magic", - "issingle": 1, - "max_attachments": 1, - "module": "Utilities", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Rename Tool", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Rename Tool", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 0, - "role": "System Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Rename Tool" - }, - { - "description": "Type of document to rename.", - "doctype": "DocField", - "fieldname": "select_doctype", - "fieldtype": "Select", - "label": "Select DocType" - }, - { - "doctype": "DocField", - "fieldname": "upload_html", - "fieldtype": "HTML", - "label": "Upload HTML" - }, - { - "doctype": "DocField", - "fieldname": "rename_log", - "fieldtype": "HTML", - "label": "Rename Log" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/utilities/doctype/sms_control/sms_control.json b/erpnext/utilities/doctype/sms_control/sms_control.json new file mode 100644 index 00000000000..1c933f27657 --- /dev/null +++ b/erpnext/utilities/doctype/sms_control/sms_control.json @@ -0,0 +1,29 @@ +{ + "creation": "2013-01-10 16:34:32.000000", + "docstatus": 0, + "doctype": "DocType", + "icon": "icon-mobile-phone", + "idx": 1, + "in_create": 0, + "issingle": 1, + "modified": "2013-12-20 19:21:47.000000", + "modified_by": "Administrator", + "module": "Utilities", + "name": "SMS Control", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "export": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "System Manager", + "submit": 0, + "write": 1 + } + ] +} \ No newline at end of file diff --git a/erpnext/utilities/doctype/sms_control/sms_control.py b/erpnext/utilities/doctype/sms_control/sms_control.py index 832c443a8df..ba858c6dd30 100644 --- a/erpnext/utilities/doctype/sms_control/sms_control.py +++ b/erpnext/utilities/doctype/sms_control/sms_control.py @@ -5,15 +5,12 @@ from __future__ import unicode_literals import frappe, json from frappe.utils import nowdate, cstr -from frappe.model.code import get_obj -from frappe.model.doc import Document from frappe import msgprint, throw, _ -from frappe.model.bean import getlist -class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist + +from frappe.model.document import Document + +class SMSControl(Document): def validate_receiver_nos(self,receiver_list): validated_receiver_list = [] @@ -36,7 +33,7 @@ class DocType: sender_name = frappe.db.get_value('Global Defaults', None, 'sms_sender_name') or \ 'ERPNXT' if len(sender_name) > 6 and \ - frappe.db.get_value("Control Panel", None, "country") == "India": + frappe.db.get_default("country") == "India": throw(_(""" As per TRAI rule, sender name must be exactly 6 characters. Kindly change sender name in Setup --> Global Defaults. @@ -71,15 +68,15 @@ class DocType: msgprint(ret) def send_via_gateway(self, arg): - ss = get_obj('SMS Settings', 'SMS Settings', with_children=1) - args = {ss.doc.message_parameter : arg.get('message')} - for d in getlist(ss.doclist, 'static_parameter_details'): + ss = frappe.get_doc('SMS Settings', 'SMS Settings') + args = {ss.message_parameter : arg.get('message')} + for d in ss.get("static_parameter_details"): args[d.parameter] = d.value resp = [] for d in arg.get('receiver_list'): - args[ss.doc.receiver_parameter] = d - resp.append(self.send_request(ss.doc.sms_gateway_url, args)) + args[ss.receiver_parameter] = d + resp.append(self.send_request(ss.sms_gateway_url, args)) return resp @@ -110,11 +107,11 @@ class DocType: # Create SMS Log # ========================================================= def create_sms_log(self, arg, sent_sms): - sl = Document('SMS Log') + sl = frappe.get_doc('SMS Log') sl.sender_name = arg['sender_name'] sl.sent_on = nowdate() sl.receiver_list = cstr(arg['receiver_list']) sl.message = arg['message'] sl.no_of_requested_sms = len(arg['receiver_list']) sl.no_of_sent_sms = sent_sms - sl.save(new=1) + sl.save() diff --git a/erpnext/utilities/doctype/sms_control/sms_control.txt b/erpnext/utilities/doctype/sms_control/sms_control.txt deleted file mode 100644 index f8e0fae9dce..00000000000 --- a/erpnext/utilities/doctype/sms_control/sms_control.txt +++ /dev/null @@ -1,42 +0,0 @@ -[ - { - "creation": "2013-01-10 16:34:32", - "docstatus": 0, - "modified": "2013-12-20 19:21:47", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "icon": "icon-mobile-phone", - "in_create": 0, - "issingle": 1, - "module": "Utilities", - "name": "__common__" - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "export": 0, - "import": 0, - "name": "__common__", - "parent": "SMS Control", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "role": "System Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "SMS Control" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/utilities/doctype/sms_log/sms_log.json b/erpnext/utilities/doctype/sms_log/sms_log.json new file mode 100644 index 00000000000..e3c77416763 --- /dev/null +++ b/erpnext/utilities/doctype/sms_log/sms_log.json @@ -0,0 +1,75 @@ +{ + "autoname": "SMSLOG/.########", + "creation": "2012-03-27 14:36:47.000000", + "docstatus": 0, + "doctype": "DocType", + "fields": [ + { + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "sender_name", + "fieldtype": "Data", + "label": "Sender Name", + "permlevel": 0 + }, + { + "fieldname": "sent_on", + "fieldtype": "Date", + "label": "Sent On", + "permlevel": 0 + }, + { + "fieldname": "receiver_list", + "fieldtype": "Small Text", + "label": "Receiver List", + "permlevel": 0 + }, + { + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0, + "width": "50%" + }, + { + "fieldname": "no_of_requested_sms", + "fieldtype": "Int", + "label": "No of Requested SMS", + "permlevel": 0 + }, + { + "fieldname": "no_of_sent_sms", + "fieldtype": "Int", + "label": "No of Sent SMS", + "permlevel": 0 + }, + { + "fieldname": "message", + "fieldtype": "Small Text", + "label": "Message", + "permlevel": 0 + } + ], + "icon": "icon-mobile-phone", + "idx": 1, + "modified": "2013-12-20 19:24:35.000000", + "modified_by": "Administrator", + "module": "Utilities", + "name": "SMS Log", + "owner": "Administrator", + "permissions": [ + { + "create": 0, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "write": 0 + } + ] +} \ No newline at end of file diff --git a/erpnext/utilities/doctype/sms_log/sms_log.py b/erpnext/utilities/doctype/sms_log/sms_log.py index 26c87f1c04a..771cb699b33 100644 --- a/erpnext/utilities/doctype/sms_log/sms_log.py +++ b/erpnext/utilities/doctype/sms_log/sms_log.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file +from frappe.model.document import Document + +class SMSLog(Document): + pass diff --git a/erpnext/utilities/doctype/sms_log/sms_log.txt b/erpnext/utilities/doctype/sms_log/sms_log.txt deleted file mode 100644 index 43cb1ffbcd0..00000000000 --- a/erpnext/utilities/doctype/sms_log/sms_log.txt +++ /dev/null @@ -1,94 +0,0 @@ -[ - { - "creation": "2012-03-27 14:36:47", - "docstatus": 0, - "modified": "2013-12-20 19:24:35", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "SMSLOG/.########", - "doctype": "DocType", - "icon": "icon-mobile-phone", - "module": "Utilities", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "SMS Log", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 0, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "SMS Log", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "write": 0 - }, - { - "doctype": "DocType", - "name": "SMS Log" - }, - { - "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "sender_name", - "fieldtype": "Data", - "label": "Sender Name" - }, - { - "doctype": "DocField", - "fieldname": "sent_on", - "fieldtype": "Date", - "label": "Sent On" - }, - { - "doctype": "DocField", - "fieldname": "receiver_list", - "fieldtype": "Small Text", - "label": "Receiver List" - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "no_of_requested_sms", - "fieldtype": "Int", - "label": "No of Requested SMS" - }, - { - "doctype": "DocField", - "fieldname": "no_of_sent_sms", - "fieldtype": "Int", - "label": "No of Sent SMS" - }, - { - "doctype": "DocField", - "fieldname": "message", - "fieldtype": "Small Text", - "label": "Message" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py index b9211fb2486..507974bfc76 100644 --- a/erpnext/utilities/repost_stock.py +++ b/erpnext/utilities/repost_stock.py @@ -120,12 +120,12 @@ def update_bin(item_code, warehouse, qty_dict=None): bin = get_bin(item_code, warehouse) mismatch = False for fld, val in qty_dict.items(): - if flt(bin.doc.fields.get(fld)) != flt(val): - bin.doc.fields[fld] = flt(val) + if flt(bin.get(fld)) != flt(val): + bin.set(fld, flt(val)) mismatch = True if mismatch: - bin.doc.projected_qty = flt(bin.doc.actual_qty) + flt(bin.doc.ordered_qty) + \ - flt(bin.doc.indented_qty) + flt(bin.doc.planned_qty) - flt(bin.doc.reserved_qty) + bin.projected_qty = flt(bin.actual_qty) + flt(bin.ordered_qty) + \ + flt(bin.indented_qty) + flt(bin.planned_qty) - flt(bin.reserved_qty) - bin.doc.save() \ No newline at end of file + bin.save() \ No newline at end of file diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 11dfc5252b0..1934f4c95f9 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -11,61 +11,60 @@ from erpnext.controllers.status_updater import StatusUpdater class TransactionBase(StatusUpdater): def load_notification_message(self): - dt = self.doc.doctype.lower().replace(" ", "_") + dt = self.doctype.lower().replace(" ", "_") if int(frappe.db.get_value("Notification Control", None, dt) or 0): - self.doc.fields["__notification_message"] = \ - frappe.db.get_value("Notification Control", None, dt + "_message") + self.set("__notification_message", + frappe.db.get_value("Notification Control", None, dt + "_message")) def validate_posting_time(self): - if not self.doc.posting_time: - self.doc.posting_time = now_datetime().strftime('%H:%M:%S') + if not self.posting_time: + self.posting_time = now_datetime().strftime('%H:%M:%S') def add_calendar_event(self, opts, force=False): - if self.doc.contact_by != cstr(self._prev.contact_by) or \ - self.doc.contact_date != cstr(self._prev.contact_date) or force: + if self.contact_by != cstr(self._prev.contact_by) or \ + self.contact_date != cstr(self._prev.contact_date) or force: self.delete_events() self._add_calendar_event(opts) def delete_events(self): frappe.delete_doc("Event", frappe.db.sql_list("""select name from `tabEvent` - where ref_type=%s and ref_name=%s""", (self.doc.doctype, self.doc.name)), + where ref_type=%s and ref_name=%s""", (self.doctype, self.name)), ignore_permissions=True) def _add_calendar_event(self, opts): opts = frappe._dict(opts) - if self.doc.contact_date: - event_doclist = [{ + if self.contact_date: + event_doclist = frappe.get_doc({ "doctype": "Event", - "owner": opts.owner or self.doc.owner, + "owner": opts.owner or self.owner, "subject": opts.subject, "description": opts.description, - "starts_on": self.doc.contact_date + " 10:00:00", + "starts_on": self.contact_date + " 10:00:00", "event_type": "Private", - "ref_type": self.doc.doctype, - "ref_name": self.doc.name - }] + "ref_type": self.doctype, + "ref_name": self.name + }) - if frappe.db.exists("User", self.doc.contact_by): - event_doclist.append({ + if frappe.db.exists("User", self.contact_by): + event_doclist.append("event_individuals", { "doctype": "Event User", - "parentfield": "event_individuals", - "person": self.doc.contact_by + "person": self.contact_by }) - frappe.bean(event_doclist).insert() + event_doclist.insert() def validate_uom_is_integer(self, uom_field, qty_fields): - validate_uom_is_integer(self.doclist, uom_field, qty_fields) + validate_uom_is_integer(self, uom_field, qty_fields) def validate_with_previous_doc(self, source_dt, ref): for key, val in ref.items(): is_child = val.get("is_child_table") ref_doc = {} item_ref_dn = [] - for d in self.doclist.get({"doctype": source_dt}): - ref_dn = d.fields.get(val["ref_dn_field"]) + for d in self.get_all_children(source_dt): + ref_dn = d.get(val["ref_dn_field"]) if ref_dn: if is_child: self.compare_values({key: [ref_dn]}, val["compare_fields"], d) @@ -97,22 +96,23 @@ def delete_events(ref_type, ref_name): class UOMMustBeIntegerError(frappe.ValidationError): pass -def validate_uom_is_integer(doclist, uom_field, qty_fields): +def validate_uom_is_integer(doc, uom_field, qty_fields): if isinstance(qty_fields, basestring): qty_fields = [qty_fields] + distinct_uoms = list(set([d.get(uom_field) for d in doc.get_all_children()])) integer_uoms = filter(lambda uom: frappe.db.get_value("UOM", uom, - "must_be_whole_number") or None, doclist.get_distinct_values(uom_field)) + "must_be_whole_number") or None, distinct_uoms) if not integer_uoms: return - for d in doclist: - if d.fields.get(uom_field) in integer_uoms: + for d in doc.get_all_children(): + if d.get(uom_field) in integer_uoms: for f in qty_fields: - if d.fields.get(f): - if cint(d.fields[f])!=d.fields[f]: - frappe.msgprint(_("For UOM") + " '" + d.fields[uom_field] \ + if d.get(f): + if cint(d.get(f))!=d.get(f): + frappe.msgprint(_("For UOM") + " '" + d.get(uom_field) \ + "': " + _("Quantity cannot be a fraction.") \ + " " + _("In Row") + ": " + str(d.idx), raise_exception=UOMMustBeIntegerError)