From f2227d033c874878fd5f5edeec08a55050ef5f3e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 31 Mar 2014 23:37:40 +0530 Subject: [PATCH] frappe/frappe#478, removed instances of .fields --- MANIFEST.in | 2 -- .../journal_voucher/journal_voucher.py | 4 ++-- .../doctype/sales_invoice/sales_invoice.py | 4 ++-- .../sales_invoice/test_sales_invoice.py | 2 +- .../purchase_common/purchase_common.py | 8 ++++---- .../doctype/purchase_order/purchase_order.py | 6 +++--- .../supplier_quotation/supplier_quotation.py | 2 +- erpnext/controllers/accounts_controller.py | 20 +++++++++---------- erpnext/controllers/buying_controller.py | 4 ++-- erpnext/controllers/selling_controller.py | 4 ++-- erpnext/controllers/status_updater.py | 4 ++-- erpnext/controllers/stock_controller.py | 4 ++-- .../doctype/salary_manager/salary_manager.py | 2 +- .../salary_structure/salary_structure.py | 2 +- .../production_order/production_order.py | 2 +- .../doctype/time_log_batch/time_log_batch.py | 2 +- erpnext/selling/doctype/lead/lead.py | 2 +- .../doctype/opportunity/opportunity.py | 2 +- .../selling/doctype/quotation/quotation.py | 2 +- .../doctype/sales_order/sales_order.py | 8 ++++---- .../doctype/features_setup/features_setup.py | 2 +- erpnext/startup/boot.py | 2 +- erpnext/stock/doctype/bin/bin.py | 2 +- .../doctype/delivery_note/delivery_note.py | 4 ++-- erpnext/stock/doctype/item/item.py | 2 +- .../material_request/material_request.py | 8 ++++---- .../stock/doctype/price_list/price_list.py | 2 +- .../purchase_receipt/purchase_receipt.py | 4 ++-- .../doctype/customer_issue/customer_issue.py | 2 +- .../maintenance_schedule.py | 2 +- erpnext/utilities/doctype/address/address.py | 4 ++-- erpnext/utilities/transaction_base.py | 4 ++-- 32 files changed, 61 insertions(+), 63 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 7bf6b4dc44..1414d502cc 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/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py index cbb8fd95a9..a2fbec1da8 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py @@ -360,7 +360,7 @@ def get_payment_entry_from_sales_invoice(sales_invoice): # debit bank jv.doclist[2].debit = si.outstanding_amount - return [d.fields for d in jv.doclist] + return jv.as_dict() @frappe.whitelist() def get_payment_entry_from_purchase_invoice(purchase_invoice): @@ -378,7 +378,7 @@ def get_payment_entry_from_purchase_invoice(purchase_invoice): # credit bank jv.doclist[2].credit = pi.outstanding_amount - return [d.fields for d in jv.doclist] + return jv.as_dict() def get_payment_entry(doc): bank_account = get_default_bank_cash_account(doc.company, "Bank Voucher") diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index d55d3a5676..b3e9a11e87 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -326,7 +326,7 @@ class SalesInvoice(SellingController): if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes': 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) @@ -836,4 +836,4 @@ def make_delivery_note(source_name, target_doc=None): } }, target_doc, set_missing_values) - return [d.fields for d in doclist] \ No newline at end of file + return doclist.as_dict() \ 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 4e366b3e5f..7879dcb93d 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -32,7 +32,7 @@ class TestSalesInvoice(unittest.TestCase): w.docstatus = '0' w.insert() - w2 = frappe.get_doc([d.fields.copy() for d in w.doclist]) + w2 = frappe.copy_doc(w) import time time.sleep(1) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py index ec8c281eea..a57114446c 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.py +++ b/erpnext/buying/doctype/purchase_common/purchase_common.py @@ -82,7 +82,7 @@ class PurchaseCommon(BuyingController): if d.doctype == 'Purchase Receipt Item': f_lst.pop('received_qty') for x in f_lst : - if d.fields.has_key(x): + if d.meta.has_field(x): d.set(x, f_lst[x]) item = frappe.db.sql("""select is_stock_item, is_purchase_item, @@ -103,9 +103,9 @@ class PurchaseCommon(BuyingController): # 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 ''] + d.meta.has_field('prevdoc_docname') and d.prevdoc_docname or d.meta.has_field('sales_order_no') and d.sales_order_no or '', + d.meta.has_field('prevdoc_detail_docname') and d.prevdoc_detail_docname or '', + d.meta.has_field('batch_no') and d.batch_no or ''] # if is not stock item f = [d.schedule_date, d.item_code, d.description] diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index b8504977f6..ca68e2b515 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -73,7 +73,7 @@ class PurchaseOrder(BuyingController): def check_for_stopped_status(self, pc_obj): check_list =[] for d in self.get('po_details'): - if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list: + if d.meta.has_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) @@ -216,7 +216,7 @@ def make_purchase_receipt(source_name, target_doc=None): } }, target_doc, set_missing_values) - return [d.fields for d in doclist] + return doclist.as_dict() @frappe.whitelist() def make_purchase_invoice(source_name, target_doc=None): @@ -254,4 +254,4 @@ def make_purchase_invoice(source_name, target_doc=None): } }, target_doc, set_missing_values) - return [d.fields for d in doclist] \ No newline at end of file + return doclist.as_dict() \ 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 004954f2bc..dbca9b5500 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -88,4 +88,4 @@ def make_purchase_order(source_name, target_doc=None): }, }, target_doc, set_missing_values) - return [d.fields for d in doclist] \ No newline at end of file + return doclist.as_dict() \ No newline at end of file diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 2d54b74d07..777150e7b3 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -26,7 +26,7 @@ class AccountsController(TransactionBase): 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.fields[fieldname])[0] + self.fiscal_year = get_fiscal_year(self.get(fieldname))[0] def validate_date_with_fiscal_year(self): if self.meta.get_field("fiscal_year") : @@ -36,15 +36,15 @@ class AccountsController(TransactionBase): elif self.meta.get_field("transaction_date"): date_field = "transaction_date" - if date_field and self.fields[date_field]: - validate_fiscal_year(self.fields[date_field], self.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.get(fieldname): accounts = frappe.db.get_values("Account", - {"master_type": fieldname.title(), "master_name": self.fields[fieldname], + {"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 @@ -347,13 +347,13 @@ class AccountsController(TransactionBase): "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"): if fieldname in tax.fields: - del tax.fields[fieldname] + del tax.get(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.set(base_field, flt((flt(item.fields[print_field],) + item.set(base_field, flt((flt(item.get(print_field),) self.precision(print_field, item)) * self.conversion_rate), self.precision(base_field, item)) @@ -419,7 +419,7 @@ class AccountsController(TransactionBase): for item in self.get("entries"): if item.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)) + 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 ") + ref_dt + _(" is zero, system will not check for over-billed")) @@ -427,9 +427,9 @@ class AccountsController(TransactionBase): 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.name))[0][0] + (item.get(item_ref_dn), self.name))[0][0] - total_billed_amt = flt(flt(already_billed) + flt(item.fields[based_on]), + 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, @@ -443,7 +443,7 @@ class AccountsController(TransactionBase): 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(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. diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index d0e482e522..b186e5c665 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -152,12 +152,12 @@ class BuyingController(StockController): if not self.meta.get_field("item_tax_amount", parentfield=self.fname): for item in self.item_doclist: - del item.fields["item_tax_amount"] + del item.get("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"] + del tax.get("tax_amount_after_discount_amount") # update valuation rate def update_valuation_rate(self, parentfield): diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index da4d939f60..f2e1c08c1d 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -363,11 +363,11 @@ class SellingController(StockController): def check_stop_sales_order(self, ref_fieldname): for d in self.get(self.fname): if d.get(ref_fieldname): - status = frappe.db.get_value("Sales Order", d.fields[ref_fieldname], "status") + status = frappe.db.get_value("Sales Order", d.get(ref_fieldname), "status") if status == "Stopped": frappe.throw(self.doctype + _(" can not be created/modified against stopped Sales Order ") + - d.fields[ref_fieldname]) + d.get(ref_fieldname)) def check_active_sales_items(obj): for d in obj.doclist.get({"parentfield": obj.fname}): diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 24c5db17d8..ba8118ec17 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -115,7 +115,7 @@ class StatusUpdater(DocListController): # get unique transactions to update for d in self.doclist: if d.doctype == args['source_dt'] and d.get(args["join_field"]): - args['name'] = d.fields[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}`, @@ -244,7 +244,7 @@ class StatusUpdater(DocListController): 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.fields[ref_fieldname]) + zero_amount_refdoc.append(item.get(ref_fieldname)) if zero_amount_refdoc: self.update_biling_status(zero_amount_refdoc, ref_dt, ref_fieldname) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index a24834ea75..33b7fdb26b 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -223,11 +223,11 @@ class StockController(AccountsController): make_gl_entries(gl_entries) def check_expense_account(self, item): - if item.fields.has_key("expense_account") and not item.expense_account: + if item.meta.has_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: + if item.meta.has_field("expense_account") and not item.cost_center: msgprint(_("""Cost Center is mandatory for item: """) + item.item_code, raise_exception=1) diff --git a/erpnext/hr/doctype/salary_manager/salary_manager.py b/erpnext/hr/doctype/salary_manager/salary_manager.py index ac64963bbc..5bb0be56da 100644 --- a/erpnext/hr/doctype/salary_manager/salary_manager.py +++ b/erpnext/hr/doctype/salary_manager/salary_manager.py @@ -51,7 +51,7 @@ class SalaryManager(Document): def check_mandatory(self): for f in ['company', 'month', 'fiscal_year']: - if not self.fields[f]: + if not self.get(f): msgprint("Please select %s to proceed" % f, raise_exception=1) diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py index 09956d136c..05e3268558 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/salary_structure.py @@ -71,7 +71,7 @@ class SalaryStructure(Document): @frappe.whitelist() def make_salary_slip(source_name, target_doc=None): - return [d.fields for d in get_mapped_doc(source_name, target_doc)] + return get_mapped_doc(source_name, target_doc).as_dict() def get_mapped_doc(source_name, target_doc=None): from frappe.model.mapper import get_mapped_doc diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index fd979805a2..efdf2c4f49 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -168,4 +168,4 @@ def make_stock_entry(production_order_id, purpose): 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/projects/doctype/time_log_batch/time_log_batch.py b/erpnext/projects/doctype/time_log_batch/time_log_batch.py index a8e9be8eb7..9405e46c38 100644 --- a/erpnext/projects/doctype/time_log_batch/time_log_batch.py +++ b/erpnext/projects/doctype/time_log_batch/time_log_batch.py @@ -21,7 +21,7 @@ class TimeLogBatch(Document): 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 diff --git a/erpnext/selling/doctype/lead/lead.py b/erpnext/selling/doctype/lead/lead.py index 9e4ead86f4..4fdb8c0bd5 100644 --- a/erpnext/selling/doctype/lead/lead.py +++ b/erpnext/selling/doctype/lead/lead.py @@ -98,7 +98,7 @@ def _make_customer(source_name, target_doc=None, ignore_permissions=False): } }}, target_doc, set_missing_values, ignore_permissions=ignore_permissions) - return [d.fields for d in doclist] + return doclist.as_dict() @frappe.whitelist() def make_opportunity(source_name, target_doc=None): diff --git a/erpnext/selling/doctype/opportunity/opportunity.py b/erpnext/selling/doctype/opportunity/opportunity.py index 5dd7b8f22d..0ded247cb2 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.py +++ b/erpnext/selling/doctype/opportunity/opportunity.py @@ -161,4 +161,4 @@ def make_quotation(source_name, target_doc=None): } }, target_doc, set_missing_values) - return [d.fields for d in doclist] \ No newline at end of file + return doclist.as_dict() \ No newline at end of file diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 900d764afe..0f64880999 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -136,7 +136,7 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False): # postprocess: fetch shipping address, set missing values - return [d.fields for d in doclist] + return doclist.as_dict() def _make_customer(source_name, ignore_permissions=False): quotation = frappe.db.get_value("Quotation", source_name, ["lead", "order_type"]) diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 0dbb78ac26..6db638b2a8 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -316,7 +316,7 @@ def make_delivery_note(source_name, target_doc=None): } }, target_doc, set_missing_values) - return [d.fields for d in doclist] + return doclist.as_dict() @frappe.whitelist() def make_sales_invoice(source_name, target_doc=None): @@ -356,7 +356,7 @@ def make_sales_invoice(source_name, target_doc=None): } }, target_doc, set_missing_values) - return [d.fields for d in doclist] + return doclist.as_dict() @frappe.whitelist() def make_maintenance_schedule(source_name, target_doc=None): @@ -384,7 +384,7 @@ def make_maintenance_schedule(source_name, target_doc=None): } }, target_doc) - return [d.fields for d in doclist] + return doclist.as_dict() @frappe.whitelist() def make_maintenance_visit(source_name, target_doc=None): @@ -414,4 +414,4 @@ def make_maintenance_visit(source_name, target_doc=None): } }, target_doc) - return [d.fields for d in doclist] + return doclist.as_dict() diff --git a/erpnext/setup/doctype/features_setup/features_setup.py b/erpnext/setup/doctype/features_setup/features_setup.py index 55c155238b..1009b27f5a 100644 --- a/erpnext/setup/doctype/features_setup/features_setup.py +++ b/erpnext/setup/doctype/features_setup/features_setup.py @@ -14,4 +14,4 @@ class FeaturesSetup(Document): from frappe.utils import set_default for key in self.fields: if key not in default_fields: - set_default(key, self.fields[key]) + set_default(key, self.get(key)) diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py index 6624b1d91e..973b742a48 100644 --- a/erpnext/startup/boot.py +++ b/erpnext/startup/boot.py @@ -10,7 +10,7 @@ def boot_session(bootinfo): import frappe bootinfo['custom_css'] = frappe.db.get_value('Style Settings', None, 'custom_css') or '' - bootinfo['website_settings'] = frappe.model.getsingle('Website Settings') + bootinfo['website_settings'] = frappe.get_doc('Website Settings') if frappe.session['user']!='Guest': bootinfo['letter_heads'] = get_letter_heads() diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py index 4cc02ab853..a5fd8ecfe6 100644 --- a/erpnext/stock/doctype/bin/bin.py +++ b/erpnext/stock/doctype/bin/bin.py @@ -25,7 +25,7 @@ class Bin(Document): def validate_mandatory(self): qf = ['actual_qty', 'reserved_qty', 'ordered_qty', 'indented_qty'] for f in qf: - if (not self.has_key(f)) or (not self.fields[f]): + if (not self.has_key(f)) or (not self.get(f)): self.set(f, 0.0) def update_stock(self, args): diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index c0302446e6..1489590424 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -335,7 +335,7 @@ def make_sales_invoice(source_name, target_doc=None): } }, target_doc, update_accounts) - return [d.fields for d in doclist] + return doclist.as_dict() @frappe.whitelist() def make_installation_note(source_name, target_doc=None): @@ -362,4 +362,4 @@ def make_installation_note(source_name, target_doc=None): } }, target_doc) - return [d.fields for d in doclist] \ No newline at end of file + return doclist.as_dict() \ No newline at end of file diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index ea43b167fc..4741bde11a 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -233,7 +233,7 @@ class Item(DocListController): 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.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])) diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py index 42c6f23ae2..3dd406f229 100644 --- a/erpnext/stock/doctype/material_request/material_request.py +++ b/erpnext/stock/doctype/material_request/material_request.py @@ -249,7 +249,7 @@ def make_purchase_order(source_name, target_doc=None): } }, target_doc, set_missing_values) - return [d.fields for d in doclist] + return doclist.as_dict() @frappe.whitelist() def make_purchase_order_based_on_supplier(source_name, target_doc=None): @@ -291,7 +291,7 @@ def make_purchase_order_based_on_supplier(source_name, target_doc=None): } }, target_doc, postprocess) - return [d.fields for d in target_doc] + 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", @@ -329,7 +329,7 @@ def make_supplier_quotation(source_name, target_doc=None): } }, target_doc, set_missing_values) - return [d.fields for d in doclist] + return doclist.as_dict() @frappe.whitelist() def make_stock_entry(source_name, target_doc=None): @@ -365,4 +365,4 @@ def make_stock_entry(source_name, target_doc=None): } }, target_doc, set_missing_values) - return [d.fields for d in doclist] + return doclist.as_dict() diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py index 7f5d7e7506..fa53aba342 100644 --- a/erpnext/stock/doctype/price_list/price_list.py +++ b/erpnext/stock/doctype/price_list/price_list.py @@ -47,7 +47,7 @@ class PriceList(DocListController): b = frappe.get_doc(module + " Settings") price_list_fieldname = module.lower() + "_price_list" - if self.name == b.fields[price_list_fieldname]: + if self.name == b.get(price_list_fieldname): b.set(price_list_fieldname, None) b.save() diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 950db93a56..9d363d3fb8 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -216,7 +216,7 @@ class PurchaseReceipt(BuyingController): def check_for_stopped_status(self, pc_obj): check_list =[] for d in self.get('purchase_receipt_details'): - if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list: + if d.meta.has_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) @@ -323,4 +323,4 @@ def make_purchase_invoice(source_name, target_doc=None): } }, target_doc, set_missing_values) - return [d.fields for d in doclist] \ No newline at end of file + return doclist.as_dict() \ 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 7e69382d0d..f82488a903 100644 --- a/erpnext/support/doctype/customer_issue/customer_issue.py +++ b/erpnext/support/doctype/customer_issue/customer_issue.py @@ -59,4 +59,4 @@ def make_maintenance_visit(source_name, target_doc=None): } }, target_doc) - return [d.fields for d in doclist] \ No newline at end of file + return doclist.as_dict() \ 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 1aa22b7c97..1002aba52a 100644 --- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py +++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py @@ -295,4 +295,4 @@ def make_maintenance_visit(source_name, target_doc=None): } }, target_doc) - return [d.fields for d in doclist] \ No newline at end of file + return doclist.as_dict() \ No newline at end of file diff --git a/erpnext/utilities/doctype/address/address.py b/erpnext/utilities/doctype/address/address.py index 9c9316c9f4..04d54f2378 100644 --- a/erpnext/utilities/doctype/address/address.py +++ b/erpnext/utilities/doctype/address/address.py @@ -35,7 +35,7 @@ class Address(Document): 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.fields[fieldname], self.name)): + (self.get(fieldname), self.name)): self.is_primary_address = 1 break @@ -48,7 +48,7 @@ class Address(Document): for fieldname in ["customer", "supplier", "sales_partner", "lead"]: 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.fields[fieldname], self.name)) + (is_address_type, fieldname, "%s", "%s"), (self.get(fieldname), self.name)) break @frappe.whitelist() diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 57a07a76c2..66a1a0320f 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -110,8 +110,8 @@ def validate_uom_is_integer(doclist, uom_field, qty_fields): if d.get(uom_field) in integer_uoms: for f in qty_fields: if d.get(f): - if cint(d.fields[f])!=d.fields[f]: - frappe.msgprint(_("For UOM") + " '" + d.fields[uom_field] \ + 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)