[fix] [cleanup] fixes while testing and code cleanup

This commit is contained in:
Nabin Hait
2013-07-11 17:49:18 +05:30
parent 1ac928ed5c
commit cfecd2bc16
39 changed files with 197 additions and 409 deletions

View File

@@ -19,7 +19,7 @@ import webnotes
from webnotes import _, msgprint
from webnotes.utils import flt, cint, today
from setup.utils import get_company_currency, get_price_list_currency
from accounts.utils import get_fiscal_year
from accounts.utils import get_fiscal_year, validate_fiscal_year
from utilities.transaction_base import TransactionBase, validate_conversion_rate
import json
@@ -27,6 +27,8 @@ class AccountsController(TransactionBase):
def validate(self):
self.set_missing_values(for_validate=True)
self.validate_date_with_fiscal_year()
if self.meta.get_field("currency"):
self.company_currency = get_company_currency(self.doc.company)
@@ -43,6 +45,18 @@ class AccountsController(TransactionBase):
self.doc.fields[fieldname] = today()
if not self.doc.fiscal_year:
self.doc.fiscal_year = get_fiscal_year(self.doc.fields[fieldname])[0]
def validate_date_with_fiscal_year(self):
if self.meta.get_field("fiscal_year") :
date_field = ""
if self.meta.get_field("posting_date"):
date_field = "posting_date"
elif self.meta.get_field("transaction_date"):
date_field = "transaction_date"
if date_field and self.doc.fields[date_field]:
validate_fiscal_year(self.doc.fields[date_field], self.doc.fiscal_year,
label=self.meta.get_label(date_field))
def set_price_list_currency(self, buying_or_selling):
# TODO - change this, since price list now has only one currency allowed

View File

@@ -16,7 +16,6 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr
def get_filters_cond(doctype, filters, conditions):
if filters:
@@ -202,7 +201,7 @@ def bom(doctype, txt, searchfield, start, page_len, filters):
from tabBOM
where tabBOM.docstatus=1
and tabBOM.is_active=1
and tabBOM.%(key)s like "%s"
and tabBOM.%(key)s like "%(txt)s"
%(fcond)s %(mcond)s
limit %(start)s, %(page_len)s """ % {'key': searchfield, 'txt': "%%%s%%" % txt,
'fcond': get_filters_cond(doctype, filters, conditions),