Fixes related to appifing shopping cart

This commit is contained in:
Nabin Hait 2014-01-23 15:33:30 +05:30
parent 6a23cfa5cd
commit 5ae6a61c4d
6 changed files with 7 additions and 56 deletions

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import webnotes
def make_test_records(verbose):
def _make_test_records(verbose):
from webnotes.test_runner import make_test_objects
accounts = [

View File

@ -668,7 +668,7 @@ class TestSalesInvoice(unittest.TestCase):
def test_recurring_invoice(self):
from webnotes.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate
from accounts.utils import get_fiscal_year
from erpnext.accounts.utils import get_fiscal_year
today = nowdate()
base_si = webnotes.bean(copy=test_records[0])
base_si.doc.fields.update({

View File

@ -48,7 +48,7 @@ class AccountsController(TransactionBase):
{"master_type": fieldname.title(), "master_name": self.doc.fields[fieldname],
"company": self.doc.company}, "name")
if accounts:
from accounts.doctype.gl_entry.gl_entry import validate_frozen_account
from erpnext.accounts.doctype.gl_entry.gl_entry import validate_frozen_account
for account in accounts:
validate_frozen_account(account[0])
@ -413,7 +413,7 @@ class AccountsController(TransactionBase):
})
def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield):
from controllers.status_updater import get_tolerance_for
from erpnext.controllers.status_updater import get_tolerance_for
item_tolerance = {}
global_tolerance = None

View File

@ -5,10 +5,8 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils.nestedset import DocTypeNestedSet
from webnotes.webutils import WebsiteGenerator
from webnotes.webutils import delete_page_cache
class DocType(DocTypeNestedSet, WebsiteGenerator):
class DocType(DocTypeNestedSet):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
@ -16,35 +14,12 @@ class DocType(DocTypeNestedSet, WebsiteGenerator):
def on_update(self):
DocTypeNestedSet.on_update(self)
WebsiteGenerator.on_update(self)
self.validate_name_with_item()
invalidate_cache_for(self.doc.name)
self.validate_one_root()
def validate_name_with_item(self):
if webnotes.conn.exists("Item", self.doc.name):
webnotes.msgprint("An item exists with same name (%s), please change the \
item group name or rename the item" % self.doc.name, raise_exception=1)
def get_group_item_count(item_group):
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(item_group)])
return webnotes.conn.sql("""select count(*) from `tabItem`
where docstatus = 0 and show_in_website = 1
and (item_group in (%s)
or name in (select parent from `tabWebsite Item Group`
where item_group in (%s))) """ % (child_groups, child_groups))[0][0]
def get_parent_item_groups(item_group_name):
item_group = webnotes.doc("Item Group", item_group_name)
return webnotes.conn.sql("""select name, page_name from `tabItem Group`
where lft <= %s and rgt >= %s
and ifnull(show_in_website,0)=1
order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True)
def invalidate_cache_for(item_group):
for i in get_parent_item_groups(item_group):
if i.page_name:
delete_page_cache(i.page_name)

View File

@ -4,9 +4,8 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, cstr, filter_strip_join
from webnotes.webutils import WebsiteGenerator, clear_cache
class DocType(WebsiteGenerator):
class DocType():
def __init__(self, doc, doclist=None):
self.doc = doc
self.doclist = doclist
@ -15,11 +14,6 @@ class DocType(WebsiteGenerator):
if self.doc.partner_website and not self.doc.partner_website.startswith("http"):
self.doc.partner_website = "http://" + self.doc.partner_website
def on_update(self):
WebsiteGenerator.on_update(self)
if self.doc.page_name:
clear_cache("partners")
def get_contacts(self,nm):
if nm:
contact_details =webnotes.conn.convert_to_lists(webnotes.conn.sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where sales_partner = '%s'"%nm))

View File

@ -8,13 +8,12 @@ from webnotes.utils import cstr, flt
from webnotes.model.doc import addchild
from webnotes.model.bean import getlist
from webnotes import msgprint, _
from webnotes.webutils import WebsiteGenerator
from webnotes.model.controller import DocListController
class WarehouseNotSet(Exception): pass
class DocType(DocListController, WebsiteGenerator):
class DocType(DocListController):
def onload(self):
self.doc.fields["__sle_exists"] = self.check_if_sle_exists()
@ -48,7 +47,6 @@ class DocType(DocListController, WebsiteGenerator):
def on_update(self):
self.validate_name_with_item_group()
self.update_website()
self.update_item_price()
def check_warehouse_is_set_for_stock_item(self):
@ -197,14 +195,6 @@ class DocType(DocListController, WebsiteGenerator):
please change the item name or rename the item group" %
self.doc.name, raise_exception=1)
def update_website(self):
from erpnext.setup.doctype.item_group.item_group import invalidate_cache_for
invalidate_cache_for(self.doc.item_group)
[invalidate_cache_for(d.item_group) for d in \
self.doclist.get({"doctype":"Website Item Group"})]
WebsiteGenerator.on_update(self)
def update_item_price(self):
webnotes.conn.sql("""update `tabItem Price` set item_name=%s,
item_description=%s, modified=NOW() where item_code=%s""",
@ -232,7 +222,6 @@ class DocType(DocListController, WebsiteGenerator):
def on_trash(self):
webnotes.conn.sql("""delete from tabBin where item_code=%s""", self.doc.item_code)
WebsiteGenerator.on_trash(self)
def before_rename(self, olddn, newdn, merge=False):
if merge:
@ -250,18 +239,11 @@ class DocType(DocListController, WebsiteGenerator):
def after_rename(self, olddn, newdn, merge):
webnotes.conn.set_value("Item", newdn, "item_code", newdn)
self.update_website_page_name()
if merge:
self.set_last_purchase_rate(newdn)
self.recalculate_bin_qty(newdn)
def update_website_page_name(self):
if self.doc.page_name:
self.update_website()
from webnotes.webutils import clear_cache
clear_cache(self.doc.page_name)
def set_last_purchase_rate(self, newdn):
from erpnext.buying.utils import get_last_purchase_details
last_purchase_rate = get_last_purchase_details(newdn).get("purchase_rate", 0)