[fix] Cleanup and fixes in update stock feature in Purchase Invoice

This commit is contained in:
Nabin Hait
2016-04-18 15:54:01 +05:30
parent ffd1e4efe6
commit 14aa9c5320
16 changed files with 429 additions and 235 deletions

View File

@@ -146,14 +146,6 @@ class AccountsController(TransactionBase):
"""set missing item values"""
from erpnext.stock.get_item_details import get_item_details
if self.doctype == "Purchase Invoice":
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")
stock_items = self.get_stock_items()
if hasattr(self, "items"):
parent_dict = {}
for fieldname in self.meta.get_valid_columns():
@@ -200,14 +192,8 @@ class AccountsController(TransactionBase):
item.rate = flt(item.price_list_rate *
(1.0 - (flt(item.discount_percentage) / 100.0)), item.precision("rate"))
if self.doctype == "Purchase Invoice":
if auto_accounting_for_stock and item.item_code in stock_items \
and self.is_opening == 'No' \
and (not item.po_detail or not frappe.db.get_value("Purchase Order Item",
item.po_detail, "delivered_by_supplier")):
item.expense_account = stock_not_billed_account
item.cost_center = None
if self.doctype == "Purchase Invoice":
self.set_expense_account()
def set_taxes(self):
if not self.meta.get_field("taxes"):