frappe/frappe#478, removed instances of .fields

This commit is contained in:
Rushabh Mehta 2014-03-31 23:37:40 +05:30
parent 231f6a5b58
commit f2227d033c
32 changed files with 61 additions and 63 deletions

View File

@ -3,7 +3,6 @@ include requirements.txt
include *.json include *.json
include *.md include *.md
include *.py include *.py
include *.txt
recursive-include erpnext *.css recursive-include erpnext *.css
recursive-include erpnext *.csv recursive-include erpnext *.csv
recursive-include erpnext *.html recursive-include erpnext *.html
@ -14,5 +13,4 @@ recursive-include erpnext *.md
recursive-include erpnext *.png recursive-include erpnext *.png
recursive-include erpnext *.py recursive-include erpnext *.py
recursive-include erpnext *.svg recursive-include erpnext *.svg
recursive-include erpnext *.txt
recursive-exclude * *.pyc recursive-exclude * *.pyc

View File

@ -360,7 +360,7 @@ def get_payment_entry_from_sales_invoice(sales_invoice):
# debit bank # debit bank
jv.doclist[2].debit = si.outstanding_amount jv.doclist[2].debit = si.outstanding_amount
return [d.fields for d in jv.doclist] return jv.as_dict()
@frappe.whitelist() @frappe.whitelist()
def get_payment_entry_from_purchase_invoice(purchase_invoice): def get_payment_entry_from_purchase_invoice(purchase_invoice):
@ -378,7 +378,7 @@ def get_payment_entry_from_purchase_invoice(purchase_invoice):
# credit bank # credit bank
jv.doclist[2].credit = pi.outstanding_amount jv.doclist[2].credit = pi.outstanding_amount
return [d.fields for d in jv.doclist] return jv.as_dict()
def get_payment_entry(doc): def get_payment_entry(doc):
bank_account = get_default_bank_cash_account(doc.company, "Bank Voucher") bank_account = get_default_bank_cash_account(doc.company, "Bank Voucher")

View File

@ -326,7 +326,7 @@ class SalesInvoice(SellingController):
if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes': if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes':
for d in self.get('entries'): for d in self.get('entries'):
if frappe.db.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \ 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) 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) }, target_doc, set_missing_values)
return [d.fields for d in doclist] return doclist.as_dict()

View File

@ -32,7 +32,7 @@ class TestSalesInvoice(unittest.TestCase):
w.docstatus = '0' w.docstatus = '0'
w.insert() w.insert()
w2 = frappe.get_doc([d.fields.copy() for d in w.doclist]) w2 = frappe.copy_doc(w)
import time import time
time.sleep(1) time.sleep(1)

View File

@ -82,7 +82,7 @@ class PurchaseCommon(BuyingController):
if d.doctype == 'Purchase Receipt Item': if d.doctype == 'Purchase Receipt Item':
f_lst.pop('received_qty') f_lst.pop('received_qty')
for x in f_lst : for x in f_lst :
if d.fields.has_key(x): if d.meta.has_field(x):
d.set(x, f_lst[x]) d.set(x, f_lst[x])
item = frappe.db.sql("""select is_stock_item, is_purchase_item, 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 # list criteria that should not repeat if item is stock item
e = [d.schedule_date, d.item_code, d.description, d.warehouse, d.uom, 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.meta.has_field('prevdoc_docname') and d.prevdoc_docname or d.meta.has_field('sales_order_no') and d.sales_order_no or '',
d.fields.has_key('prevdoc_detail_docname') and d.prevdoc_detail_docname or '', d.meta.has_field('prevdoc_detail_docname') and d.prevdoc_detail_docname or '',
d.fields.has_key('batch_no') and d.batch_no or ''] d.meta.has_field('batch_no') and d.batch_no or '']
# if is not stock item # if is not stock item
f = [d.schedule_date, d.item_code, d.description] f = [d.schedule_date, d.item_code, d.description]

View File

@ -73,7 +73,7 @@ class PurchaseOrder(BuyingController):
def check_for_stopped_status(self, pc_obj): def check_for_stopped_status(self, pc_obj):
check_list =[] check_list =[]
for d in self.get('po_details'): 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) check_list.append(d.prevdoc_docname)
pc_obj.check_for_stopped_status( d.prevdoc_doctype, 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) }, target_doc, set_missing_values)
return [d.fields for d in doclist] return doclist.as_dict()
@frappe.whitelist() @frappe.whitelist()
def make_purchase_invoice(source_name, target_doc=None): 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) }, target_doc, set_missing_values)
return [d.fields for d in doclist] return doclist.as_dict()

View File

@ -88,4 +88,4 @@ def make_purchase_order(source_name, target_doc=None):
}, },
}, target_doc, set_missing_values) }, target_doc, set_missing_values)
return [d.fields for d in doclist] return doclist.as_dict()

View File

@ -26,7 +26,7 @@ class AccountsController(TransactionBase):
if not self.get(fieldname) and self.meta.get_field(fieldname): if not self.get(fieldname) and self.meta.get_field(fieldname):
self.set(fieldname, today()) self.set(fieldname, today())
if not self.fiscal_year: 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): def validate_date_with_fiscal_year(self):
if self.meta.get_field("fiscal_year") : if self.meta.get_field("fiscal_year") :
@ -36,15 +36,15 @@ class AccountsController(TransactionBase):
elif self.meta.get_field("transaction_date"): elif self.meta.get_field("transaction_date"):
date_field = "transaction_date" date_field = "transaction_date"
if date_field and self.fields[date_field]: if date_field and self.get(date_field):
validate_fiscal_year(self.fields[date_field], self.fiscal_year, validate_fiscal_year(self.get(date_field), self.fiscal_year,
label=self.meta.get_label(date_field)) label=self.meta.get_label(date_field))
def validate_for_freezed_account(self): def validate_for_freezed_account(self):
for fieldname in ["customer", "supplier"]: for fieldname in ["customer", "supplier"]:
if self.meta.get_field(fieldname) and self.get(fieldname): if self.meta.get_field(fieldname) and self.get(fieldname):
accounts = frappe.db.get_values("Account", 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") "company": self.company}, "name")
if accounts: if accounts:
from erpnext.accounts.doctype.gl_entry.gl_entry import validate_frozen_account from erpnext.accounts.doctype.gl_entry.gl_entry import validate_frozen_account
@ -347,13 +347,13 @@ class AccountsController(TransactionBase):
"tax_fraction_for_current_item", "tax_fraction_for_current_item",
"grand_total_fraction_for_current_item"): "grand_total_fraction_for_current_item"):
if fieldname in tax.fields: 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) tax.item_wise_tax_detail = json.dumps(tax.item_wise_tax_detail)
def _set_in_company_currency(self, item, print_field, base_field): def _set_in_company_currency(self, item, print_field, base_field):
"""set values in base currency""" """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(print_field, item)) * self.conversion_rate),
self.precision(base_field, item)) self.precision(base_field, item))
@ -419,7 +419,7 @@ class AccountsController(TransactionBase):
for item in self.get("entries"): for item in self.get("entries"):
if item.get(item_ref_dn): if item.get(item_ref_dn):
ref_amt = flt(frappe.db.get_value(ref_dt + " Item", 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: 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")) 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` already_billed = frappe.db.sql("""select sum(%s) from `tab%s`
where %s=%s and docstatus=1 and parent != %s""" % where %s=%s and docstatus=1 and parent != %s""" %
(based_on, self.tname, item_ref_dn, '%s', '%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)) 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,
@ -443,7 +443,7 @@ class AccountsController(TransactionBase):
frappe.throw(_("Row #") + cstr(item.idx) + ": " + frappe.throw(_("Row #") + cstr(item.idx) + ": " +
_(" Max amount allowed for Item ") + cstr(item.item_code) + _(" Max amount allowed for Item ") + cstr(item.item_code) +
_(" against ") + ref_dt + " " + _(" against ") + ref_dt + " " +
cstr(item.fields[ref_dt.lower().replace(" ", "_")]) + _(" is ") + cstr(item.get(ref_dt.lower().replace(" ", "_"))) + _(" is ") +
cstr(max_allowed_amt) + ". \n" + cstr(max_allowed_amt) + ". \n" +
_("""If you want to increase your overflow tolerance, please increase \ _("""If you want to increase your overflow tolerance, please increase \
tolerance % in Global Defaults or Item master. tolerance % in Global Defaults or Item master.

View File

@ -152,12 +152,12 @@ class BuyingController(StockController):
if not self.meta.get_field("item_tax_amount", parentfield=self.fname): if not self.meta.get_field("item_tax_amount", parentfield=self.fname):
for item in self.item_doclist: 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", if not self.meta.get_field("tax_amount_after_discount_amount",
parentfield=self.other_fname): parentfield=self.other_fname):
for tax in self.tax_doclist: 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 # update valuation rate
def update_valuation_rate(self, parentfield): def update_valuation_rate(self, parentfield):

View File

@ -363,11 +363,11 @@ class SellingController(StockController):
def check_stop_sales_order(self, ref_fieldname): def check_stop_sales_order(self, ref_fieldname):
for d in self.get(self.fname): for d in self.get(self.fname):
if d.get(ref_fieldname): 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": if status == "Stopped":
frappe.throw(self.doctype + frappe.throw(self.doctype +
_(" can not be created/modified against stopped Sales Order ") + _(" can not be created/modified against stopped Sales Order ") +
d.fields[ref_fieldname]) d.get(ref_fieldname))
def check_active_sales_items(obj): def check_active_sales_items(obj):
for d in obj.doclist.get({"parentfield": obj.fname}): for d in obj.doclist.get({"parentfield": obj.fname}):

View File

@ -115,7 +115,7 @@ class StatusUpdater(DocListController):
# get unique transactions to update # get unique transactions to update
for d in self.doclist: for d in self.doclist:
if d.doctype == args['source_dt'] and d.get(args["join_field"]): 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 # get all qty where qty > target_field
item = frappe.db.sql("""select item_code, `{target_ref_field}`, item = frappe.db.sql("""select item_code, `{target_ref_field}`,
@ -244,7 +244,7 @@ class StatusUpdater(DocListController):
if item.get(ref_fieldname) \ if item.get(ref_fieldname) \
and item.get(ref_fieldname) in all_zero_amount_refdoc \ and item.get(ref_fieldname) in all_zero_amount_refdoc \
and item.get(ref_fieldname) not in 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: if zero_amount_refdoc:
self.update_biling_status(zero_amount_refdoc, ref_dt, ref_fieldname) self.update_biling_status(zero_amount_refdoc, ref_dt, ref_fieldname)

View File

@ -223,11 +223,11 @@ class StockController(AccountsController):
make_gl_entries(gl_entries) make_gl_entries(gl_entries)
def check_expense_account(self, item): 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, msgprint(_("""Expense/Difference account is mandatory for item: """) + item.item_code,
raise_exception=1) 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, msgprint(_("""Cost Center is mandatory for item: """) + item.item_code,
raise_exception=1) raise_exception=1)

View File

@ -51,7 +51,7 @@ class SalaryManager(Document):
def check_mandatory(self): def check_mandatory(self):
for f in ['company', 'month', 'fiscal_year']: 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) msgprint("Please select %s to proceed" % f, raise_exception=1)

View File

@ -71,7 +71,7 @@ class SalaryStructure(Document):
@frappe.whitelist() @frappe.whitelist()
def make_salary_slip(source_name, target_doc=None): 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): def get_mapped_doc(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc from frappe.model.mapper import get_mapped_doc

View File

@ -168,4 +168,4 @@ def make_stock_entry(production_order_id, purpose):
stock_entry.to_warehouse = production_order.fg_warehouse stock_entry.to_warehouse = production_order.fg_warehouse
stock_entry.run_method("get_items") stock_entry.run_method("get_items")
return [d.fields for d in stock_entry.doclist] return stock_entry.as_dict()

View File

@ -21,7 +21,7 @@ class TimeLogBatch(Document):
self.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): def update_time_log_values(self, d, tl):
d.fields.update({ d.update({
"hours": tl.hours, "hours": tl.hours,
"activity_type": tl.activity_type, "activity_type": tl.activity_type,
"created_by": tl.owner "created_by": tl.owner

View File

@ -98,7 +98,7 @@ def _make_customer(source_name, target_doc=None, ignore_permissions=False):
} }
}}, target_doc, 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.as_dict()
@frappe.whitelist() @frappe.whitelist()
def make_opportunity(source_name, target_doc=None): def make_opportunity(source_name, target_doc=None):

View File

@ -161,4 +161,4 @@ def make_quotation(source_name, target_doc=None):
} }
}, target_doc, set_missing_values) }, target_doc, set_missing_values)
return [d.fields for d in doclist] return doclist.as_dict()

View File

@ -136,7 +136,7 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
# postprocess: fetch shipping address, set missing values # 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): def _make_customer(source_name, ignore_permissions=False):
quotation = frappe.db.get_value("Quotation", source_name, ["lead", "order_type"]) quotation = frappe.db.get_value("Quotation", source_name, ["lead", "order_type"])

View File

@ -316,7 +316,7 @@ def make_delivery_note(source_name, target_doc=None):
} }
}, target_doc, set_missing_values) }, target_doc, set_missing_values)
return [d.fields for d in doclist] return doclist.as_dict()
@frappe.whitelist() @frappe.whitelist()
def make_sales_invoice(source_name, target_doc=None): 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) }, target_doc, set_missing_values)
return [d.fields for d in doclist] return doclist.as_dict()
@frappe.whitelist() @frappe.whitelist()
def make_maintenance_schedule(source_name, target_doc=None): def make_maintenance_schedule(source_name, target_doc=None):
@ -384,7 +384,7 @@ def make_maintenance_schedule(source_name, target_doc=None):
} }
}, target_doc) }, target_doc)
return [d.fields for d in doclist] return doclist.as_dict()
@frappe.whitelist() @frappe.whitelist()
def make_maintenance_visit(source_name, target_doc=None): def make_maintenance_visit(source_name, target_doc=None):
@ -414,4 +414,4 @@ def make_maintenance_visit(source_name, target_doc=None):
} }
}, target_doc) }, target_doc)
return [d.fields for d in doclist] return doclist.as_dict()

View File

@ -14,4 +14,4 @@ class FeaturesSetup(Document):
from frappe.utils import set_default from frappe.utils import set_default
for key in self.fields: for key in self.fields:
if key not in default_fields: if key not in default_fields:
set_default(key, self.fields[key]) set_default(key, self.get(key))

View File

@ -10,7 +10,7 @@ def boot_session(bootinfo):
import frappe import frappe
bootinfo['custom_css'] = frappe.db.get_value('Style Settings', None, 'custom_css') or '' 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': if frappe.session['user']!='Guest':
bootinfo['letter_heads'] = get_letter_heads() bootinfo['letter_heads'] = get_letter_heads()

View File

@ -25,7 +25,7 @@ class Bin(Document):
def validate_mandatory(self): def validate_mandatory(self):
qf = ['actual_qty', 'reserved_qty', 'ordered_qty', 'indented_qty'] qf = ['actual_qty', 'reserved_qty', 'ordered_qty', 'indented_qty']
for f in qf: 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) self.set(f, 0.0)
def update_stock(self, args): def update_stock(self, args):

View File

@ -335,7 +335,7 @@ def make_sales_invoice(source_name, target_doc=None):
} }
}, target_doc, update_accounts) }, target_doc, update_accounts)
return [d.fields for d in doclist] return doclist.as_dict()
@frappe.whitelist() @frappe.whitelist()
def make_installation_note(source_name, target_doc=None): def make_installation_note(source_name, target_doc=None):
@ -362,4 +362,4 @@ def make_installation_note(source_name, target_doc=None):
} }
}, target_doc) }, target_doc)
return [d.fields for d in doclist] return doclist.as_dict()

View File

@ -233,7 +233,7 @@ class Item(DocListController):
field_list = ["stock_uom", "is_stock_item", "has_serial_no", "has_batch_no"] 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)] 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") frappe.throw(_("To merge, following properties must be same for both items")
+ ": \n" + ", ".join([self.meta.get_label(fld) for fld in field_list])) + ": \n" + ", ".join([self.meta.get_label(fld) for fld in field_list]))

View File

@ -249,7 +249,7 @@ def make_purchase_order(source_name, target_doc=None):
} }
}, target_doc, set_missing_values) }, target_doc, set_missing_values)
return [d.fields for d in doclist] return doclist.as_dict()
@frappe.whitelist() @frappe.whitelist()
def make_purchase_order_based_on_supplier(source_name, target_doc=None): 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) }, target_doc, postprocess)
return [d.fields for d in target_doc] return target_doc.as_dict()
def get_material_requests_based_on_supplier(supplier): 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",
@ -329,7 +329,7 @@ def make_supplier_quotation(source_name, target_doc=None):
} }
}, target_doc, set_missing_values) }, target_doc, set_missing_values)
return [d.fields for d in doclist] return doclist.as_dict()
@frappe.whitelist() @frappe.whitelist()
def make_stock_entry(source_name, target_doc=None): 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) }, target_doc, set_missing_values)
return [d.fields for d in doclist] return doclist.as_dict()

View File

@ -47,7 +47,7 @@ class PriceList(DocListController):
b = frappe.get_doc(module + " Settings") b = frappe.get_doc(module + " Settings")
price_list_fieldname = module.lower() + "_price_list" 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.set(price_list_fieldname, None)
b.save() b.save()

View File

@ -216,7 +216,7 @@ class PurchaseReceipt(BuyingController):
def check_for_stopped_status(self, pc_obj): def check_for_stopped_status(self, pc_obj):
check_list =[] check_list =[]
for d in self.get('purchase_receipt_details'): 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) check_list.append(d.prevdoc_docname)
pc_obj.check_for_stopped_status( d.prevdoc_doctype, 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) }, target_doc, set_missing_values)
return [d.fields for d in doclist] return doclist.as_dict()

View File

@ -59,4 +59,4 @@ def make_maintenance_visit(source_name, target_doc=None):
} }
}, target_doc) }, target_doc)
return [d.fields for d in doclist] return doclist.as_dict()

View File

@ -295,4 +295,4 @@ def make_maintenance_visit(source_name, target_doc=None):
} }
}, target_doc) }, target_doc)
return [d.fields for d in doclist] return doclist.as_dict()

View File

@ -35,7 +35,7 @@ class Address(Document):
if self.get(fieldname): if self.get(fieldname):
if not frappe.db.sql("""select name from `tabAddress` where is_primary_address=1 if not frappe.db.sql("""select name from `tabAddress` where is_primary_address=1
and `%s`=%s and name!=%s""" % (fieldname, "%s", "%s"), and `%s`=%s and name!=%s""" % (fieldname, "%s", "%s"),
(self.fields[fieldname], self.name)): (self.get(fieldname), self.name)):
self.is_primary_address = 1 self.is_primary_address = 1
break break
@ -48,7 +48,7 @@ class Address(Document):
for fieldname in ["customer", "supplier", "sales_partner", "lead"]: for fieldname in ["customer", "supplier", "sales_partner", "lead"]:
if self.get(fieldname): if self.get(fieldname):
frappe.db.sql("""update `tabAddress` set `%s`=0 where `%s`=%s and name!=%s""" % 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 break
@frappe.whitelist() @frappe.whitelist()

View File

@ -110,8 +110,8 @@ def validate_uom_is_integer(doclist, uom_field, qty_fields):
if d.get(uom_field) in integer_uoms: if d.get(uom_field) in integer_uoms:
for f in qty_fields: for f in qty_fields:
if d.get(f): if d.get(f):
if cint(d.fields[f])!=d.fields[f]: if cint(d.get(f))!=d.get(f):
frappe.msgprint(_("For UOM") + " '" + d.fields[uom_field] \ frappe.msgprint(_("For UOM") + " '" + d.get(uom_field) \
+ "': " + _("Quantity cannot be a fraction.") \ + "': " + _("Quantity cannot be a fraction.") \
+ " " + _("In Row") + ": " + str(d.idx), + " " + _("In Row") + ": " + str(d.idx),
raise_exception=UOMMustBeIntegerError) raise_exception=UOMMustBeIntegerError)