aii: patches and fine tuning

This commit is contained in:
Nabin Hait
2013-03-25 11:06:00 +05:30
parent b632ba5f51
commit 0fc2454384
21 changed files with 255 additions and 124 deletions

View File

@@ -76,14 +76,9 @@ class AccountsController(TransactionBase):
"allocate_amount": 0
})
def get_default_account(self, account_for):
account = webnotes.conn.get_value("Company", self.doc.company, account_for)
if not account:
msgprint(_("Please mention default account for '") +
_(webnotes.get_doctype("company").get_label(account_for) +
_("' in Company: ") + self.doc.company), raise_exception=True)
return account
def get_company_default(self, fieldname):
from accounts.utils import get_company_default
return get_company_default(self.doc.company, fieldname)
@property
def stock_items(self):
@@ -101,8 +96,3 @@ class AccountsController(TransactionBase):
self._abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
return self._abbr
@webnotes.whitelist()
def get_default_account(account_for, company):
return webnotes.conn.get_value("Company", company, account_for)

View File

@@ -332,9 +332,9 @@ class BuyingController(StockController):
# update valuation rate
def update_valuation_rate(self, parentfield):
for d in self.doclist.get({"parentfield": parentfield}):
d.conversion_factor = d.conversion_factor or webnotes.conn.get_value(
d.conversion_factor = d.conversion_factor or flt(webnotes.conn.get_value(
"UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom},
"conversion_factor") or 1
"conversion_factor")) or 1
if d.item_code and d.qty:
# if no item code, which is sometimes the case in purchase invoice,
# then it is not possible to track valuation against it

View File

@@ -18,6 +18,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint
from setup.utils import get_company_currency
from webnotes import msgprint, _
from controllers.stock_controller import StockController
@@ -58,5 +59,10 @@ class SellingController(StockController):
self.doc.doctype, self.doc.name, item.name, stock_ledger_entries,
item_sales_bom)
item.buying_amount = buying_amount > 0 and buying_amount or 0
webnotes.conn.set_value(self.tname, item.name, "buying_amount",
item.buying_amount)
webnotes.conn.set_value(item.doctype, item.name, "buying_amount",
item.buying_amount)
def check_expense_account(self, item):
if item.buying_amount and not item.expense_account:
msgprint(_("""Expense account is mandatory for item: """) + item.item_code,
raise_exception=1)

View File

@@ -23,7 +23,9 @@ class StockController(AccountsController):
def get_gl_entries_for_stock(self, against_stock_account, amount,
stock_in_hand_account=None, cost_center=None):
if not stock_in_hand_account:
stock_in_hand_account = self.get_default_account("stock_in_hand_account")
stock_in_hand_account = self.get_company_default("stock_in_hand_account")
if not cost_center:
cost_center = self.get_company_default("stock_adjustment_cost_center")
if amount:
gl_entries = [
@@ -46,12 +48,6 @@ class StockController(AccountsController):
]
return gl_entries
def check_expense_account(self, item):
if not item.expense_account:
msgprint(_("""Expense account is mandatory for item: """) + item.item_code,
raise_exception=1)
def get_stock_ledger_entries(self, item_list=None, warehouse_list=None):
if not (item_list and warehouse_list):