This commit is contained in:
Rushabh Mehta
2014-03-27 16:12:56 +05:30
parent 66d52b55c0
commit d2b34dc30c
214 changed files with 898 additions and 973 deletions

View File

@@ -87,7 +87,7 @@ 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}):
for item in self.get(self.fname):
if item.fields.get("item_code"):
args = item.fields.copy()
args.update(self.doc.fields)
@@ -103,7 +103,7 @@ class AccountsController(TransactionBase):
tax_master_doctype = self.meta.get_field(tax_master_field).options
if not self.doclist.get({"parentfield": tax_parentfield}):
if not self.get(tax_parentfield):
if not self.doc.fields.get(tax_master_field):
# get the default tax master
self.doc.fields[tax_master_field] = \
@@ -134,7 +134,7 @@ class AccountsController(TransactionBase):
self.doclist.append(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):
@@ -156,8 +156,8 @@ class AccountsController(TransactionBase):
self.meta.get_label("conversion_rate"), self.doc.company)
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.item_doclist = self.get(self.fname)
self.tax_doclist = self.get(self.other_fname)
self.calculate_item_values()
self.initialize_taxes()
@@ -368,7 +368,7 @@ class AccountsController(TransactionBase):
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})])
for adv in self.get(advance_parentfield)])
self.doc.total_advance = flt(sum_of_allocated_amount, self.precision("total_advance"))
@@ -408,7 +408,7 @@ class AccountsController(TransactionBase):
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({
"doctype": child_doctype,
@@ -425,7 +425,7 @@ class AccountsController(TransactionBase):
item_tolerance = {}
global_tolerance = None
for item in self.doclist.get({"parentfield": "entries"}):
for item in self.get("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))
@@ -467,7 +467,7 @@ class AccountsController(TransactionBase):
def get_stock_items(self):
stock_items = []
item_codes = list(set(item.item_code for item in
self.doclist.get({"parentfield": self.fname})))
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'""" % \

View File

@@ -58,7 +58,7 @@ class BuyingController(StockController):
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)
@@ -171,19 +171,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
@@ -218,9 +218,9 @@ class BuyingController(StockController):
raise_exception=1)
def update_raw_materials_supplied(self, raw_material_table):
self.doclist = self.doc.clear_table(self.doclist, raw_material_table)
self.set(raw_material_table, [])
if self.doc.is_subcontracted=="Yes":
for item in self.doclist.get({"parentfield": self.fname}):
for item in self.get(self.fname):
if item.item_code in self.sub_contracted_items:
self.add_bom_items(item, raw_material_table)
@@ -271,7 +271,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 +284,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 +294,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"))

View File

@@ -54,7 +54,7 @@ class SellingController(StockController):
# 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
@@ -242,7 +242,7 @@ class SellingController(StockController):
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)
@@ -279,7 +279,7 @@ class SellingController(StockController):
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:
@@ -288,7 +288,7 @@ class SellingController(StockController):
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
@@ -315,7 +315,7 @@ class SellingController(StockController):
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({
@@ -362,7 +362,7 @@ class SellingController(StockController):
return so_qty, so_warehouse
def check_stop_sales_order(self, ref_fieldname):
for d in self.doclist.get({"parentfield": self.fname}):
for d in self.get(self.fname):
if d.fields.get(ref_fieldname):
status = frappe.db.get_value("Sales Order", d.fields[ref_fieldname], "status")
if status == "Stopped":

View File

@@ -240,7 +240,7 @@ class StatusUpdater(DocListController):
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"}):
for item in self.get("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:

View File

@@ -70,7 +70,7 @@ class StockController(AccountsController):
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:
@@ -129,7 +129,7 @@ class StockController(AccountsController):
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 = ""
@@ -256,8 +256,8 @@ class StockController(AccountsController):
def get_distinct_item_warehouse(self):
item_list = []
warehouse_list = []
for item in self.doclist.get({"parentfield": self.fname}) \
+ self.doclist.get({"parentfield": "packing_details"}):
for item in self.get(self.fname) \
+ self.get("packing_details"):
item_list.append(item.item_code)
warehouse_list.append(item.warehouse)