Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Akhilesh Darjee 2013-09-23 11:53:30 +05:30
commit 4e1b7dcc08
283 changed files with 962 additions and 6499 deletions

View File

@ -7,7 +7,7 @@ import webnotes
from webnotes.utils import cint, cstr, flt, fmt_money, formatdate, getdate
from webnotes.model.doc import addchild
from webnotes.model.bean import getlist
from webnotes import msgprint
from webnotes import msgprint, _
from setup.utils import get_company_currency
from controllers.accounts_controller import AccountsController

View File

@ -9,7 +9,7 @@ from webnotes.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdat
get_first_day, get_last_day
from webnotes.utils.email_lib import sendmail
from webnotes.utils import comma_and
from webnotes.utils import comma_and, get_url
from webnotes.model.doc import make_autoname
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
@ -148,6 +148,9 @@ class DocType(SellingController):
self.validate_recurring_invoice()
self.convert_to_recurring()
def get_portal_page(self):
return "invoice" if self.doc.docstatus==1 else None
def set_missing_values(self, for_validate=False):
self.set_pos_fields(for_validate)
@ -916,7 +919,7 @@ def notify_errors(inv, owner):
Regards,
Administrator
""" % (inv, website.get_site_address(), inv)
""" % (inv, get_url(), inv)
subj = "[Urgent] Error while creating recurring invoice from %s" % inv
from webnotes.profile import get_system_managers

View File

@ -0,0 +1,5 @@
{% extends "app/portal/templates/sale.html" %}
{% block status -%}
{% if doc.status %}{{ doc.status }}{% endif %}
{%- endblock %}

View File

@ -0,0 +1,30 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.utils import flt, fmt_money
no_cache = True
def get_context():
from portal.utils import get_transaction_context
context = get_transaction_context("Sales Invoice", webnotes.form_dict.name)
modify_status(context.get("doc"))
context.update({
"parent_link": "invoices",
"parent_title": "Invoices"
})
return context
def modify_status(doc):
doc.status = ""
if flt(doc.outstanding_amount):
doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
("label-warning", "icon-exclamation-sign",
_("To Pay") + " = " + fmt_money(doc.outstanding_amount, currency=doc.currency))
else:
doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
("label-success", "icon-ok", _("Paid"))

View File

@ -0,0 +1 @@
{% extends "app/portal/templates/sales_transactions.html" %}

View File

@ -0,0 +1,28 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
no_cache = True
def get_context():
from portal.utils import get_currency_context
context = get_currency_context()
context.update({
"title": "Invoices",
"method": "accounts.doctype.sales_invoice.templates.pages.invoices.get_invoices",
"icon": "icon-file-text",
"empty_list_message": "No Invoices Found",
"page": "invoice"
})
return context
@webnotes.whitelist()
def get_invoices(start=0):
from portal.utils import get_transaction_list
from accounts.doctype.sales_invoice.templates.pages.invoice import modify_status
invoices = get_transaction_list("Sales Invoice", start, ["outstanding_amount"])
for d in invoices:
modify_status(d)
return invoices

View File

@ -104,7 +104,7 @@ def import_vouchers(common_values, data, start_idx, import_type):
if account.master_name:
map_fields(["against_sales_invoice:against_invoice",
"against_purhase_invoice:against_voucher",
"against_purchase_invoice:against_voucher",
"against_journal_voucher:against_jv"], d, detail.fields)
webnotes.conn.commit()

View File

@ -1,5 +1,6 @@
{
"app_name": "ERPNext",
"base_template": "app/portal/templates/base.html",
"modules": {
"Selling": {
"link": "selling-home",
@ -43,12 +44,6 @@
"color": "#7f8c8d",
"icon": "icon-cogs"
},
"Website": {
"type": "module",
"link": "website-home",
"color": "#16a085",
"icon": "icon-globe"
},
"HR": {
"type": "module",
"link": "hr-home",
@ -77,138 +72,5 @@
"label": "Notes",
"icon": "icon-file-alt"
}
},
"web": {
"pages": {
"about": {
"template": "app/website/templates/pages/about",
"args_method": "website.doctype.about_us_settings.about_us_settings.get_args"
},
"account": {
"no_cache": true,
"template": "app/website/templates/pages/account"
},
"blog": {
"template": "app/website/templates/pages/blog",
"args_method": "website.helpers.blog.get_blog_template_args"
},
"contact": {
"template": "app/website/templates/pages/contact",
"args_doctype": "Contact Us Settings"
},
"index": {
"template": "app/website/templates/pages/index"
},
"order": {
"no_cache": true,
"template": "app/website/templates/pages/sale",
"args_method": "website.helpers.transaction.get_order_args",
"portal": {
"doctype": "Sales Order",
"conditions": {
"docstatus": 1
}
}
},
"orders": {
"no_cache": true,
"template": "app/website/templates/pages/sales_transactions",
"args_method": "website.helpers.transaction.order_list_args"
},
"invoice": {
"no_cache": true,
"template": "app/website/templates/pages/sale",
"args_method": "website.helpers.transaction.get_invoice_args",
"portal": {
"doctype": "Sales Invoice",
"conditions": {
"docstatus": 1
}
}
},
"invoices": {
"no_cache": true,
"template": "app/website/templates/pages/sales_transactions",
"args_method": "website.helpers.transaction.invoice_list_args"
},
"shipment": {
"no_cache": true,
"template": "app/website/templates/pages/sale",
"args_method": "website.helpers.transaction.get_shipment_args",
"portal": {
"doctype": "Delivery Note",
"conditions": {
"docstatus": 1
}
}
},
"shipments": {
"no_cache": true,
"template": "app/website/templates/pages/sales_transactions",
"args_method": "website.helpers.transaction.shipment_list_args"
},
"product_search": {
"template": "app/website/templates/pages/product_search"
},
"ticket": {
"no_cache": true,
"template": "app/website/templates/pages/ticket",
"args_method": "support.doctype.support_ticket.support_ticket.get_website_args",
"portal": {
"doctype": "Support Ticket"
}
},
"tickets": {
"template": "app/website/templates/pages/tickets",
"args_method": "website.helpers.transaction.ticket_list_args"
},
"address": {
"no_cache": true,
"template": "app/website/templates/pages/address",
"args_method": "utilities.doctype.address.address.get_website_args"
},
"addresses": {
"template": "app/website/templates/pages/addresses"
},
"writers": {
"template": "app/website/templates/pages/writers",
"args_method": "website.doctype.blogger.blogger.get_writers_args"
},
"profile": {
"no_cache": true,
"template": "app/website/templates/pages/profile",
"args_method": "startup.webutils.get_profile_args"
},
"cart": {
"no_cache": true,
"template": "app/website/templates/pages/cart.html"
},
"partners": {
"template": "app/website/templates/pages/partners",
"args_method": "website.helpers.partner.get_partner_args"
}
},
"generators": {
"Web Page": {
"template": "app/website/templates/html/web_page.html",
"condition_field": "published"
},
"Blog Post": {
"template": "app/website/templates/html/blog_page.html",
"condition_field": "published"
},
"Item": {
"template": "app/website/templates/html/product_page.html",
"condition_field": "show_in_website"
},
"Item Group":{
"template": "app/website/templates/html/product_group.html",
"condition_field": "show_in_website"
},
"Sales Partner": {
"template": "app/website/templates/html/partner_page.html",
"condition_field": "show_in_website"
}
}
}
}

View File

@ -106,13 +106,12 @@ class TestLeaveApplication(unittest.TestCase):
add_role("test1@example.com", "Leave Approver")
add_role("test2@example.com", "Leave Approver")
self._test_leave_approval_basic_case_1()
self._test_leave_approval_basic_case_2()
self._test_leave_approval_basic_case()
self._test_leave_approval_invalid_leave_approver_insert()
self._test_leave_approval_invalid_leave_approver_submit()
self._test_leave_approval_valid_leave_approver_insert()
def _test_leave_approval_basic_case_1(self):
def _test_leave_approval_basic_case(self):
self._clear_applications()
# create leave application as Employee
@ -128,19 +127,6 @@ class TestLeaveApplication(unittest.TestCase):
self.assertEqual(webnotes.conn.get_value("Leave Application", application.doc.name,
"docstatus"), 1)
def _test_leave_approval_basic_case_2(self):
self._clear_applications()
# create leave application by any leave approver,
# when no leave approver specified in employee's leave approvers list
application = self.get_application(test_records[1])
application.doc.leave_approver = "test1@example.com"
application.insert()
application.doc.status = "Approved"
application.submit()
self.assertEqual(webnotes.conn.get_value("Leave Application", application.doc.name,
"docstatus"), 1)
def _test_leave_approval_invalid_leave_approver_insert(self):
from hr.doctype.leave_application.leave_application import InvalidLeaveApproverError
@ -186,11 +172,13 @@ class TestLeaveApplication(unittest.TestCase):
original_department = webnotes.conn.get_value("Employee", "_T-Employee-0001", "department")
webnotes.conn.set_value("Employee", "_T-Employee-0001", "department", None)
# change to valid leave approver and try to create and submit leave application
webnotes.session.user = "test2@example.com"
webnotes.session.user = "test@example.com"
application = self.get_application(test_records[1])
application.doc.leave_approver = "test2@example.com"
application.insert()
# change to valid leave approver and try to submit leave application
webnotes.session.user = "test2@example.com"
application.doc.status = "Approved"
application.submit()
self.assertEqual(webnotes.conn.get_value("Leave Application", application.doc.name,

View File

@ -289,7 +289,7 @@ NameVirtualHost *:8080
RewriteCond %%{REQUEST_FILENAME} !-f
RewriteCond %%{REQUEST_FILENAME} !-d
RewriteCond %%{REQUEST_FILENAME} !-l
RewriteRule ^([^/]+)$ /web.py?page=$1 [QSA,L]
RewriteRule ^([^/]+)$ /web.py?page=$1 [QSA,L]
</Directory>
</VirtualHost>""" % (install_path, install_path)

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1,9 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.model import delete_doc
webnotes.conn.sql("update `tabDocType` set module = 'Utilities' where name in ('Question', 'Answer')")
delete_doc('Module Def', 'Knowledge Base')

View File

@ -1,10 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.model import delete_doc
delete_doc('DocType', 'About Us Team')
delete_doc('DocType', 'About Us Settings')
delete_doc('DocType', 'Contact Us Settings')

View File

@ -1,16 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.model.code import get_obj
ns_list = webnotes.conn.sql("""\
SELECT `tabDocField`.`parent`, `tabDocField`.`options`
FROM `tabDocField`, `tabDocType`
WHERE `tabDocField`.`fieldname` = 'naming_series'
AND `tabDocType`.name=`tabDocField`.parent""")
ns_obj = get_obj('Naming Series')
for ns in ns_list:
if ns[0] and isinstance(ns[1], basestring):
ns_obj.set_series_for(ns[0], ns[1].split("\n"))

View File

@ -1,8 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.modules import reload_doc
reload_doc('accounts', 'doctype', 'c_form')

View File

@ -1,7 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("update `tabDocField` set `default` = '' where fieldname = 'cost_center' and parent = 'RV Detail' and `default` = 'Purchase - TC'")

View File

@ -1,16 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
res = webnotes.conn.sql("""select distinct item_code, warehouse from `tabStock Ledger Entry`
where posting_time > '00:00:00' and posting_time < '00:01:00'""", as_dict=1)
webnotes.conn.sql("update `tabStock Ledger Entry` set posting_time = '00:00:00' where posting_time > '00:00:00' and posting_time < '00:01:00'")
from stock.stock_ledger import update_entries_after
for d in res:
update_entries_after({
"item_code": d.item_code,
"warehouse": d.warehouse,
})

View File

@ -1,18 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.model.doc import addchild
from webnotes.model.code import get_obj
webnotes.conn.sql("delete from `tabDocPerm` where role = 'All' and permlevel = 0 and parent in ('Appraisal', 'Ticket', 'Project')")
appr = get_obj('DocType', 'Appraisal', with_children=1)
ch = addchild(appr.doc, 'permissions', 'DocPerm')
ch.permlevel = 0
ch.role = 'Employee'
ch.read = 1
ch.write = 1
ch.save()

View File

@ -1,7 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("update `tabDocPerm` set permlevel = 0 where parent = 'Address'")

View File

@ -1,25 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.model.doc import addchild
from webnotes.model.code import get_obj
webnotes.conn.sql("delete from `tabDocPerm` where role = 'All' and parent = 'Address'")
role1 = ['Sales User', 'Purchase User', 'Accounts User', 'Maintenance User']
role2 = ['Sales Manager', 'Sales Master Manager', 'Purchase Manager', 'Purchase Master Manager', 'Accounts Manager', 'Maintenance Manager']
addr = get_obj('DocType', 'Address', with_children=1)
for d in role1+role2:
ch = addchild(addr.doc, 'permissions', 'DocPerm')
ch.role = d
ch.read = 1
ch.write = 1
ch.create = 1
if d in role2:
ch.cancel = 1
ch.save()

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1,37 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
import webnotes.model.doc
webnotes.conn.sql("delete from `tabDocPerm` where parent='Profile' and permlevel=1")
new_perms = [
{
'parent': 'Profile',
'parentfield': 'permissions',
'parenttype': 'DocType',
'role': 'Administrator',
'permlevel': 1,
'read': 1,
'write': 1
},
{
'parent': 'Profile',
'parentfield': 'permissions',
'parenttype': 'DocType',
'role': 'System Manager',
'permlevel': 1,
'read': 1,
'write': 1
},
]
for perms in new_perms:
doc = webnotes.model.doc.Document('DocPerm')
doc.fields.update(perms)
doc.save()
webnotes.conn.commit()
webnotes.conn.begin()
webnotes.reload_doc('core', 'doctype', 'profile')

View File

@ -1,13 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.model.code import get_obj
from selling.doctype.sales_common.sales_common import StatusUpdater
invoices = webnotes.conn.sql("select name from `tabSales Invoice` where docstatus = 1")
for inv in invoices:
inv_obj = get_obj('Sales Invoice', inv[0], with_children=1)
StatusUpdater(inv_obj, 1).update_all_qty()

View File

@ -1,19 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
def execute():
from webnotes.widgets.form.assign_to import add
for t in webnotes.conn.sql("""select * from tabTask
where ifnull(allocated_to, '')!=''""", as_dict=1):
add({
'doctype': "Task",
'name': t['name'],
'assign_to': t['allocated_to'],
'assigned_by': t['owner'],
'description': t['subject'],
'date': t['creation'],
"no_notification": True
})

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import webnotes
def execute():
webnotes.reload_doc("website", "doctype", "shopping_cart_price_list")
webnotes.reload_doc("selling", "doctype", "shopping_cart_price_list")
for t in [
("Supplier Quotation", "price_list_name", "buying_price_list"),

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1,14 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("""\
delete from `tabDocPerm`
where parent in ('Address', 'Contact')""")
webnotes.conn.commit()
webnotes.reload_doc('utilities', 'doctype', 'address')
webnotes.reload_doc('utilities', 'doctype', 'contact')
webnotes.conn.begin()

View File

@ -1,17 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
def execute():
webnotes.conn.commit()
from webnotes.install_lib.install import Installer
Installer(None, None).create_auth_table()
webnotes.conn.begin()
for user, password in webnotes.conn.sql("""select name, password from tabProfile"""):
if password:
webnotes.conn.sql("""insert into __Auth (user, `password`) values (%s, %s)""",
(user, password))

View File

@ -1,7 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("update `tabDocPerm` set permlevel = 0 where parent = 'Bin'")

View File

@ -1,13 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("""update tabAccount set freeze_account='No' where freeze_account is null""")
webnotes.conn.sql("""update `tabPurchase Taxes and Charges`
set category='Valuation and Total' where category='For Both'""")
webnotes.conn.sql("""update `tabPurchase Taxes and Charges`
set category='Valuation' where category='For Valuation'""")
webnotes.conn.sql("""update `tabPurchase Taxes and Charges`
set category='Total' where category='For Total'""")

View File

@ -1,11 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.model import delete_doc
delete_doc('DocType', 'Bulk Rename Tool')
webnotes.conn.commit()
webnotes.conn.sql("drop table `tabBulk Rename Tool`")
webnotes.conn.begin()

View File

@ -1,14 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
"""
deprecate:
* doctype - import data control
* page - import data (old)
"""
import webnotes
from webnotes.model import delete_doc
delete_doc('DocType', 'Import Data Control')
delete_doc('Page', 'Import Data')

View File

@ -1,48 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.utils import flt
wrong_plist = webnotes.conn.sql("""
select dnpi.name, dnpi.parent, dnpi.docstatus, dnpi.serial_no
from `tabDelivery Note Packing Item` dnpi
where ifnull(dnpi.parent, '') != ''
and ifnull(dnpi.parent, '') not like 'old_par%'
and dnpi.parenttype = 'Delivery Note'
and not exists (
select * from `tabDelivery Note Item` dni
where dni.item_code = dnpi.parent_item and
dni.name = dnpi.parent_detail_docname and
dni.parent = dnpi.parent
)
""", as_dict=1)
for d in wrong_plist:
if d['docstatus'] == 2 and d['serial_no']:
for s in d['serial_no'].splitlines():
sle = webnotes.conn.sql("""
select actual_qty, warehouse, voucher_no
from `tabStock Ledger Entry`
where (
serial_no like '%s\n%%'
or serial_no like '%%\n%s'
or serial_no like '%%\n%s\n%%'
or serial_no = '%s'
)
and voucher_no != '%s'
and ifnull(is_cancelled, 'No') = 'No'
order by name desc
limit 1
"""% (s, s, s, s, d['parent']), as_dict=1)
status = 'Not in Use'
if sle and flt(sle[0]['actual_qty']) > 0:
status = 'Available'
elif sle and flt(sle[0]['actual_qty']) < 0:
status = 'Delivered'
webnotes.conn.sql("update `tabSerial No` set status = %s, warehouse = %s where name = %s", (status, sle[0]['warehouse'], s))
webnotes.conn.sql("delete from `tabDelivery Note Packing Item` where name = %s", d['name'])

View File

@ -1,20 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("""update `tabPurchase Order Item` t1, `tabPurchase Order` t2
set t1.project_name = t2.project_name where t1.parent = t2.name
and ifnull(t1.project_name, '') = ''""")
webnotes.conn.sql("""update `tabPurchase Invoice Item` t1, `tabPurchase Invoice` t2
set t1.project_name = t2.project_name where t1.parent = t2.name
and ifnull(t1.project_name, '') = ''""")
webnotes.conn.sql("""update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2
set t1.project_name = t2.project_name where t1.parent = t2.name
and ifnull(t1.project_name, '') = ''""")
webnotes.conn.commit()
webnotes.reload_doc("buying", "doctype", "purchase_order")
webnotes.reload_doc("accounts", "doctype", "purchase_invoice")
webnotes.conn.begin()

View File

@ -1,9 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("""\
update `tabDocPerm` set `match`=NULL
where parent='Event' and role='All' and permlevel=0""")

View File

@ -1,100 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from stock.stock_ledger import update_entries_after
def execute():
# add index
webnotes.conn.commit()
try:
webnotes.conn.sql("""alter table `tabDelivery Note Packing Item`
add index item_code_warehouse (item_code, warehouse)""")
except:
pass
webnotes.conn.begin()
webnotes.conn.auto_commit_on_many_writes = 1
repost_reserved_qty()
cleanup_wrong_sle()
webnotes.conn.auto_commit_on_many_writes = 0
def repost_reserved_qty():
from webnotes.utils import flt
bins = webnotes.conn.sql("select item_code, warehouse, name, reserved_qty from `tabBin`")
i = 0
for d in bins:
i += 1
reserved_qty = webnotes.conn.sql("""
select
sum((dnpi_qty / so_item_qty) * (so_item_qty - so_item_delivered_qty))
from
(
select
qty as dnpi_qty,
(
select qty from `tabSales Order Item`
where name = dnpi.parent_detail_docname
) as so_item_qty,
(
select ifnull(delivered_qty, 0) from `tabSales Order Item`
where name = dnpi.parent_detail_docname
) as so_item_delivered_qty
from
(
select qty, parent_detail_docname
from `tabDelivery Note Packing Item` dnpi_in
where item_code = %s and warehouse = %s
and parenttype="Sales Order"
and exists (select * from `tabSales Order` so
where name = dnpi_in.parent and docstatus = 1 and status != 'Stopped')
) dnpi
) tab
where
so_item_qty >= so_item_delivered_qty
""", (d[0], d[1]))
if flt(d[3]) != flt(reserved_qty[0][0]):
webnotes.conn.sql("""
update `tabBin` set reserved_qty = %s where name = %s
""", (reserved_qty and reserved_qty[0][0] or 0, d[2]))
def cleanup_wrong_sle():
sle = webnotes.conn.sql("""
select item_code, warehouse, voucher_no, name
from `tabStock Ledger Entry` sle
where voucher_type = 'Delivery Note'
and not exists(
select name from `tabDelivery Note Packing Item`
where item_code = sle.item_code
and qty = abs(sle.actual_qty)
and parent = sle.voucher_no
) and not exists (
select name from `tabDelivery Note Item`
where item_code = sle.item_code
and qty = abs(sle.actual_qty)
and parent = sle.voucher_no
)
""")
if sle:
for d in sle:
webnotes.conn.sql("update `tabStock Ledger Entry` set is_cancelled = 'Yes' where name = %s", d[3])
create_comment(d[3])
update_entries_after({
"item_code": d[0],
"warehouse": d[1],
"posting_date": "2012-07-01",
"posting_time": "12:05"
})
def create_comment(dn):
from webnotes.model.doc import Document
cmt = Document('Comment')
cmt.comment = 'Cancelled by administrator due to wrong entry in packing list'
cmt.comment_by = 'Administrator'
cmt.comment_by_fullname = 'Administrator'
cmt.comment_doctype = 'Stock Ledger Entry'
cmt.comment_docname = dn
cmt.save(1)

View File

@ -1,9 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
"""appends from __future__ import unicode_literals to py files if necessary"""
import wnf
wnf.append_future_import()

View File

@ -1,12 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("""update `tabPurchase Taxes and Charges`
set category='Valuation and Total' where category='For Both'""")
webnotes.conn.sql("""update `tabPurchase Taxes and Charges`
set category='Valuation' where category='For Valuation'""")
webnotes.conn.sql("""update `tabPurchase Taxes and Charges`
set category='Total' where category='For Total'""")

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1,9 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.commit()
webnotes.conn.sql("alter table `tabSessions` modify user varchar(180)")
webnotes.conn.begin()

View File

@ -1,11 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.model.code import get_obj
fs = get_obj('Features Setup')
fs.doc.fs_item_barcode = 0
fs.doc.save()
fs.validate()

View File

@ -1,89 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
# sync doctypes required for the patch
webnotes.reload_doc('website', 'doctype', 'web_page')
webnotes.reload_doc('website', 'doctype', 'website_settings')
webnotes.reload_doc('stock', 'doctype', 'item')
cleanup()
save_pages()
save_website_settings()
def cleanup():
import webnotes
# delete pages from `tabPage` of module Website or of type Webpage
webnotes.conn.sql("""\
delete from `tabPage`
where module='Website' and ifnull(web_page, 'No') = 'Yes'""")
# change show_in_website value in item table to 0 or 1
webnotes.conn.sql("""\
update `tabItem`
set show_in_website = if(show_in_website = 'Yes', 1, 0)
where show_in_website is not null""")
# move comments from comment_doctype Page to Blog
webnotes.conn.sql("""\
update `tabComment` comm, `tabBlog` blog
set comm.comment_doctype = 'Blog', comm.comment_docname = blog.name
where comm.comment_docname = blog.page_name""")
# delete deprecated pages
import webnotes.model
for page in ['products', 'contact', 'blog', 'about']:
try:
webnotes.model.delete_doc('Page', page)
except Exception, e:
webnotes.modules.patch_handler.log(unicode(e))
import os
import conf
# delete other html files
exception_list = ['app.html', 'unsupported.html', 'blank.html']
conf_dir = os.path.dirname(os.path.abspath(conf.__file__))
public_path = os.path.join(conf_dir, 'public')
for f in os.listdir(public_path):
if f.endswith('.html') and f not in exception_list:
os.remove(os.path.join(public_path, f))
def save_pages():
"""save all web pages, blogs to create content"""
query_map = {
'Web Page': """select name from `tabWeb Page` where docstatus=0""",
'Blog': """\
select name from `tabBlog`
where docstatus = 0 and ifnull(published, 0) = 1""",
'Item': """\
select name from `tabItem`
where docstatus = 0 and ifnull(show_in_website, 0) = 1""",
}
import webnotes
from webnotes.model.bean import Bean
import webnotes.modules.patch_handler
for dt in query_map:
for result in webnotes.conn.sql(query_map[dt], as_dict=1):
try:
Bean(dt, result['name'].encode('utf-8')).save()
except Exception, e:
webnotes.modules.patch_handler.log(unicode(e))
def save_website_settings():
from webnotes.model.code import get_obj
# rewrite pages
get_obj('Website Settings').on_update()
ss = get_obj('Style Settings')
ss.validate()
ss.doc.save()
ss.on_update()

View File

@ -1,13 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.reload_doc('buying', 'doctype', 'purchase_order_item')
webnotes.reload_doc('accounts', 'doctype', 'purchase_invoice_item')
webnotes.reload_doc('stock', 'doctype', 'purchase_receipt_item')
webnotes.conn.sql("update `tabPurchase Invoice Item` t1, `tabPurchase Order Item` t2 set t1.uom = t2.uom where ifnull(t1.po_detail, '') != '' and t1.po_detail = t2.name")
webnotes.conn.sql("update `tabPurchase Invoice Item` t1, `tabPurchase Receipt Item` t2 set t1.uom = t2.uom where ifnull(t1.pr_detail, '') != '' and t1.pr_detail = t2.name")

View File

@ -1,21 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
"""delete entries of child table having parent like old_par%% or ''"""
import webnotes
res = webnotes.conn.sql("""\
select dt.name from `tabDocType` dt
where ifnull(dt.istable, 0)=1 and
exists (
select * from `tabDocField` df
where df.fieldtype='Table' and
df.options=dt.name
)""")
for r in res:
if r[0]:
webnotes.conn.sql("""\
delete from `tab%s`
where (ifnull(parent, '')='' or parent like "old_par%%") and
ifnull(parenttype, '')!=''""" % r[0])

View File

@ -1,7 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("update `tabQuotation` t1, `tabLead` t2 set t1.organization = t2.company_name where ifnull(t1.lead, '') != '' and t1.quotation_to = 'Lead' and ifnull(t1.organization, '') = '' and t1.lead = t2.name")

View File

@ -1,12 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
"""allow read permission to all for report list"""
import webnotes
webnotes.conn.sql("""\
delete from `tabDocPerm`
where parent in ('Report', 'Search Criteria')""")
webnotes.reload_doc('core', 'doctype', 'report')

View File

@ -1,10 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
"""add unique constraint to series table's name column"""
import webnotes
webnotes.conn.commit()
webnotes.conn.sql("alter table `tabSeries` add unique (name)")
webnotes.conn.begin()

View File

@ -1,9 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.reload_doc('accounts', 'doctype', 'sales_invoice')
webnotes.conn.sql("update `tabSales Invoice` set recurring_type = 'Monthly' where ifnull(convert_into_recurring_invoice, 0) = 1")

View File

@ -1,18 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
"""New Send Autoreply checkbox in Email Settings"""
import webnotes
import webnotes.utils
webnotes.conn.commit()
webnotes.reload_doc('setup', 'doctype', 'email_settings')
webnotes.conn.begin()
sync_support_mails = webnotes.utils.cint(webnotes.conn.get_value('Email Settings',
None, 'sync_support_mails'))
if sync_support_mails:
webnotes.conn.set_value('Email Settings', None, 'send_autoreply', 1)

View File

@ -4,7 +4,7 @@
import webnotes
def execute():
webnotes.reload_doc("website", "doctype", "shopping_cart_settings")
webnotes.reload_doc("selling", "doctype", "shopping_cart_settings")
# create two default territories, one for home country and one named Rest of the World
from setup.doctype.setup_control.setup_control import create_territories

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1,46 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
# do not run this patch
from __future__ import unicode_literals
def execute():
import webnotes
import webnotes.modules
forbidden = ['%', "'", '"', '#', '*', '?', '`', '(', ')', '<', '>', '-',
'\\', '/', '.', '&', '!', '@', '$', '^', '+']
doctype_list = webnotes.conn.sql("SELECT name, module FROM `tabDocType`")
for doctype, module in doctype_list:
docfield_list = webnotes.conn.sql("""\
SELECT name, label, fieldtype FROM `tabDocField`
WHERE parent = %s AND IFNULL(fieldname, '') = ''""", doctype)
field_type_count = {}
count = 0
for name, label, fieldtype in docfield_list:
fieldname = None
if label:
temp_label = label
if len(temp_label)==1:
temp_label = fieldtype + temp_label
fieldname = temp_label.lower().replace(' ', '_')
if "<" in fieldname:
count = field_type_count.setdefault(fieldtype, 0)
fieldname = fieldtype.lower().replace(' ', '_') + str(count)
field_type_count[fieldtype] = count + 1
elif fieldtype:
count = field_type_count.setdefault(fieldtype, 0)
fieldname = fieldtype.lower().replace(' ', '_') + str(count)
field_type_count[fieldtype] = count + 1
if fieldname:
for f in forbidden: fieldname = fieldname.replace(f, '')
fieldname = fieldname.replace('__', '_')
if fieldname.endswith('_'):
fieldname = fieldname[:-1]
if fieldname.startswith('_'):
fieldname = fieldname[1:]
#print fieldname
webnotes.conn.sql("""\
UPDATE `tabDocField` SET fieldname = %s
WHERE name = %s""", (fieldname, name))
webnotes.modules.export_doc('DocType', doctype)

View File

@ -1,81 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
def execute():
"""
* Remove unnecessary doctype properties
* Remove docfield property setters if fieldname doesn't exist
* Remove prev_field properties if value fieldname doesn't exist
"""
change_property_setter_fieldnames()
clean_doctype_properties()
clean_docfield_properties()
def change_property_setter_fieldnames():
webnotes.reload_doc('core', 'doctype', 'property_setter')
docfield_list = webnotes.conn.sql("""\
SELECT name, fieldname FROM `tabDocField`""", as_list=1)
custom_field_list = webnotes.conn.sql("""\
SELECT name, fieldname FROM `tabCustom Field`""", as_list=1)
field_list = docfield_list + custom_field_list
property_setter_list = webnotes.conn.sql("""\
SELECT name, doc_name, value, property
FROM `tabProperty Setter`
WHERE doctype_or_field='DocField'""")
field_dict = dict(field_list)
for name, doc_name, value, prop in property_setter_list:
if doc_name in field_dict:
webnotes.conn.sql("""\
UPDATE `tabProperty Setter`
SET field_name = %s
WHERE name = %s""", (field_dict.get(doc_name), name))
if value in field_dict and prop=='previous_field':
webnotes.conn.sql("""\
UPDATE `tabProperty Setter`
SET value = %s
WHERE name = %s""", (field_dict.get(value), name))
def clean_doctype_properties():
desc = webnotes.conn.sql("DESC `tabDocType`", as_dict=1)
property_list = '", "'.join([d.get('Field') for d in desc])
webnotes.conn.sql("""\
DELETE FROM `tabProperty Setter`
WHERE doctype_or_field = 'DocType'
AND property NOT IN ("%s")""" % property_list)
def clean_docfield_properties():
delete_list_1 = webnotes.conn.sql("""\
SELECT name FROM `tabProperty Setter` ps
WHERE doctype_or_field = 'DocField'
AND NOT EXISTS (
SELECT fieldname FROM `tabDocField` df
WHERE df.parent = ps.doc_type
AND df.fieldname = ps.field_name
) AND NOT EXISTS (
SELECT fieldname FROM `tabCustom Field` cf
WHERE cf.dt = ps.doc_type
AND cf.fieldname = ps.field_name
)""")
delete_list_2 = webnotes.conn.sql("""\
SELECT name FROM `tabProperty Setter` ps
WHERE doctype_or_field = 'DocField'
AND property = 'previous_field'
AND NOT EXISTS (
SELECT fieldname FROM `tabDocField` df
WHERE df.parent = ps.doc_type
AND df.fieldname = ps.value
) AND NOT EXISTS (
SELECT fieldname FROM `tabCustom Field` cf
WHERE cf.dt = ps.doc_type
AND cf.fieldname = ps.value
)""")
delete_list = [d[0] for d in delete_list_1] + [d[0] for d in delete_list_2]
webnotes.conn.sql("""\
DELETE FROM `tabProperty Setter`
WHERE NAME IN ("%s")""" % '", "'.join(delete_list))

View File

@ -1,11 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
def execute():
webnotes.conn.sql("""\
DELETE FROM `tabSingles`
WHERE doctype = 'Control Panel'
AND field IN ("sync_with_gateway", "mail_password", "auto_email_id",
"mail_port", "outgoing_mail_server", "mail_login", "use_ssl")""")

View File

@ -1,118 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
# do not run this patch
from __future__ import unicode_literals
field_list = [
['Contact', 'notes'],
['Contact', 'birthday'],
['Contact', 'anniversary'],
['Customer', 'state_tax_type'],
['Customer', 'tin_no'],
['Customer', 'excise_registration_number'],
['Customer', 'customer_discount_details'],
['Customer', 'notes'],
['Customer', 'follow_up_section'],
['Customer', 'follow_up'],
['Delivery Note', 'shipping_contact_no'],
['Delivery Note', 'shipping_tin_no'],
['Delivery Note', 'shipping_excise_no'],
['Delivery Note', 'tin_no'],
['Delivery Note', 'excise_no'],
['Delivery Note Detail', 'cetsh_number'],
['Item', 'base_material'],
['Item', 'tool_type'],
['Item', 'no_of_flutes'],
['Item', 'special_treatment'],
['Item', 'length'],
['Item', 'width'],
['Item', 'height_dia'],
['Item', 'pl_item'],
['Item', 'cetsh_number'],
['Item', 'stock_maintained'],
['Item', 'is_rm'],
['Journal Voucher Detail', 'line_remarks'],
['Lead', 'designation'],
['Purchase Order', 'challan_number'],
['Quotation', 'cust_enq_no'],
['Quotation', 'enq_date'],
['Quotation', 'quote_valid'],
['Quotation', 'due_date'],
['Receivable Voucher', 'voucher_time'],
['Receivable Voucher', 'removal_time'],
['Receivable Voucher', 'removal_date'],
['Receivable Voucher', 'shipping_address'],
['Receivable Voucher', 'shipping_location'],
['Receivable Voucher', 'ship_to'],
['Receivable Voucher', 'shipping_contact_no'],
['Receivable Voucher', 'shipping_excise_no'],
['Receivable Voucher', 'shipping_tin_no'],
['Receivable Voucher', 'po_no'],
['Receivable Voucher', 'po_date'],
['Receivable Voucher', 'lr_no'],
['Receivable Voucher', 'transporters'],
['Receivable Voucher', 'ship_terms'],
['Receivable Voucher', 'tin_no'],
['Receivable Voucher', 'excise_no'],
['RV Detail', 'cetsh_number'],
['Sales Order', 'shipping_contact_no'],
['Sales Order', 'shipping_tin_no'],
['Sales Order', 'shipping_excise_no'],
['Sales Order', 'tin_no'],
['Sales Order', 'excise_number'],
['Sales Order Detail', 'cetsh_number'],
['Sales Order Detail', 'prd_notes'],
['Shipping Address', 'phone_no'],
['Shipping Address', 'tin_no'],
['Shipping Address', 'excise_no'],
['Stock Entry', 'process_custom'],
['Stock Entry', 'city'],
['Stock Entry', 'address_line_2'],
['Stock Entry', 'address_line_1'],
['Stock Entry', 'comp_other'],
['Stock Entry', 'mobile_no'],
['Stock Entry', 'phone_no'],
['Stock Entry', 'country'],
['Stock Entry', 'state'],
['Stock Entry', 'challan_number'],
['Stock Entry Detail', 'machine'],
['Stock Entry Detail', 'worker'],
['Supplier', 'notes'],
['Supplier', 'purchase_other_charges'],
['Supplier', 'tax_details'],
['Supplier', 'tin_number'],
['Supplier', 'excise_regd_number'],
['Supplier', 'service_tax_regd_number'],
['Warehouse', 'comp_other'],
['Warehouse', 'process'],
['Warehouse', 'country'],
['Warehouse', 'tax_registration_number'],
['Warehouse Type', 'process'],
['Workstation', 'maintenance_data'],
]
import webnotes
from webnotes.model.code import get_obj
from webnotes.model.doc import Document
def execute():
webnotes.reload_doc('core', 'doctype', 'custom_field')
for f in field_list:
res = webnotes.conn.sql("""SELECT name FROM `tabCustom Field`
WHERE dt=%s AND fieldname=%s""", (f[0], f[1]))
if res: continue
docfield = webnotes.conn.sql("""SELECT * FROM `tabDocField`
WHERE parent=%s AND fieldname=%s""", (f[0], f[1]), as_dict=1)
if not docfield: continue
custom_field = docfield[0]
# scrub custom field dict
custom_field['dt'] = custom_field['parent']
del custom_field['parent']
d = Document('Custom Field', fielddata=custom_field)
d.name = custom_field['dt'] + '-' + custom_field['fieldname']
d.save(1, ignore_fields=1)
#obj = get_obj(doc=d)
#obj.on_update()

View File

@ -1,12 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("DELETE FROM `tabDocField` WHERE options='DocFormat'")
webnotes.conn.sql("DELETE FROM `tabDocField` WHERE parent='DocFormat'")
webnotes.conn.sql("DELETE FROM `tabDocType` WHERE name='DocFormat'")
webnotes.conn.commit()
webnotes.conn.sql("DROP TABLE `tabDocFormat`")
webnotes.conn.begin()

View File

@ -1,147 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
def execute():
"""
* Custom Field changes
* Add file_list to required tables
* Change floats/currency to decimal(18, 6)
* Remove DocFormat from DocType's fields
* Remove 'no_column' from DocField
* Drop table DocFormat
"""
import webnotes.model.sync
webnotes.model.sync.sync_all(force=1)
handle_custom_fields()
create_file_list()
# do at last - needs commit due to DDL statements
change_to_decimal()
def handle_custom_fields():
"""
* Assign idx to custom fields
* Create property setter entry of previous field
* Remove custom fields from tabDocField
"""
cf = get_cf()
assign_idx(cf)
create_prev_field_prop_setter(cf)
remove_custom_from_docfield(cf)
def get_cf():
return webnotes.conn.sql("""\
SELECT * FROM `tabCustom Field`
WHERE docstatus < 2""", as_dict=1)
def assign_idx(cf):
from webnotes.model.doctype import get
from webnotes.utils import cint
#print len(cf)
for f in cf:
#print f.get('dt'), f.get('name')
if f.get('idx'): continue
temp_doclist = get(f.get('dt'), form=0)
#print len(temp_doclist)
max_idx = max(d.idx for d in temp_doclist if d.doctype=='DocField')
if not max_idx: continue
webnotes.conn.sql("""\
UPDATE `tabCustom Field` SET idx=%s
WHERE name=%s""", (cint(max_idx)+1, f.get('name')))
def create_prev_field_prop_setter(cf):
from webnotes.model.doc import Document
from core.doctype.custom_field.custom_field import get_fields_label
for f in cf:
idx_label_list, field_list = get_fields_label(f.get('dt'), 0)
temp_insert_after = (f.get('insert_after') or '').split(" - ")
if len(temp_insert_after)<=1: continue
similar_idx_label = [il for il in idx_label_list \
if temp_insert_after[0] in il]
if not similar_idx_label: continue
label_index = idx_label_list.index(similar_idx_label[0])
if label_index==-1: return
webnotes.conn.sql("""\
UPDATE `tabCustom Field`
SET insert_after = %s
WHERE name = %s""", (similar_idx_label[0], f.get('name')))
prev_field = field_list[label_index]
res = webnotes.conn.sql("""\
SELECT name FROM `tabProperty Setter`
WHERE doc_type = %s
AND field_name = %s
AND property = 'previous_field'""", (f.get('dt'), f.get('fieldname')))
if not res:
ps = Document('Property Setter', fielddata = {
'doctype_or_field': 'DocField',
'doc_type': f.get('dt'),
'field_name': f.get('fieldname'),
'property': 'previous_field',
'value': prev_field,
'property_type': 'Data',
'select_doctype': f.get('dt')
})
ps.save(1)
def remove_custom_from_docfield(cf):
for f in cf:
webnotes.conn.sql("""\
DELETE FROM `tabDocField`
WHERE parent=%s AND fieldname=%s""", (f.get('dt'),
f.get('fieldname')))
def create_file_list():
should_exist = ['Website Settings', 'Web Page', 'Timesheet', 'Task',
'Support Ticket', 'Supplier', 'Style Settings', 'Stock Reconciliation',
'Stock Entry', 'Serial No', 'Sales Order', 'Sales Invoice',
'Quotation', 'Question', 'Purchase Receipt', 'Purchase Order',
'Project', 'Profile', 'Production Order', 'Product', 'Print Format',
'Price List', 'Purchase Invoice', 'Page',
'Maintenance Visit', 'Maintenance Schedule', 'Letter Head',
'Leave Application', 'Lead', 'Journal Voucher', 'Item', 'Material Request',
'Expense Claim', 'Opportunity', 'Employee', 'Delivery Note',
'Customer Issue', 'Customer', 'Contact Us Settings', 'Company',
'Bulk Rename Tool', 'Blog', 'BOM', 'About Us Settings']
from webnotes.model.code import get_obj
for dt in should_exist:
obj = get_obj('DocType', dt, with_children=1)
obj.doc.allow_attach = 1
obj.doc.save()
obj.make_file_list()
from webnotes.model.db_schema import updatedb
updatedb(obj.doc.name)
webnotes.clear_cache(doctype=obj.doc.name)
def change_to_decimal():
webnotes.conn.commit()
tables = webnotes.conn.sql("SHOW TABLES")
alter_tables_list = []
for tab in tables:
if not tab: continue
desc = webnotes.conn.sql("DESC `%s`" % tab[0], as_dict=1)
flist = []
for d in desc:
if d.get('Type')=='decimal(14,2)':
flist.append(d.get('Field'))
if flist:
#print tab[0], flist
statements = ("MODIFY `%s` decimal(18,6)" % f for f in flist)
statements = ", \n".join(statements)
alter_tables_list.append("ALTER TABLE `%s` \n%s\n" % (tab[0],
statements))
#print "\n\n".join(alter_tables_list)
for at in alter_tables_list:
webnotes.conn.sql(at)
webnotes.conn.begin()

View File

@ -1,18 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("""
UPDATE `tabDocField`
SET fieldtype = 'Link', options = 'Deduction Type'
WHERE parent = 'Deduction Detail'
AND fieldname = 'd_type'
""")
webnotes.conn.sql("""
UPDATE `tabDocField`
SET fieldtype = 'Link', options = 'Earning Type'
WHERE parent = 'Earning Detail'
AND fieldname = 'e_type'
""")

View File

@ -1,27 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
# dont run this patch
from __future__ import unicode_literals
def execute():
import webnotes
import webnotes.model.doctype
from webnotes.utils import cint
from webnotes.model.doc import Document
from webnotes.model.code import get_obj
doctype_list = webnotes.conn.sql("SELECT name FROM `tabDocType`")
for dt in doctype_list:
doclist = webnotes.model.doctype.get(dt[0], form=0)
is_submittable = 0
for d in doclist:
if d.doctype == 'DocPerm' and d.fields.get('permlevel') == 0 \
and cint(d.fields.get('submit')) == 1:
is_submittable = 1
break
if is_submittable:
dt_doc = Document('DocType', doclist[0].name)
dt_doc.is_submittable = 1
dt_doc.save()
obj = get_obj(doc=dt_doc)
obj.make_amendable()
obj.on_update()

View File

@ -1,21 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
doctype_list = webnotes.conn.sql("""SELECT name FROM `tabDocType`
WHERE docstatus<2 AND IFNULL(issingle, 0)=0
AND IFNULL(istable, 0)=0""")
webnotes.conn.commit()
for d in doctype_list:
add_col = True
desc = webnotes.conn.sql("DESC `tab%s`" % d[0], as_dict=1)
for td in desc:
if td.get('Field')=='_user_tags':
add_col = False
if add_col:
webnotes.conn.sql("alter table `tab%s` add column `_user_tags` varchar(180)" % d[0])
webnotes.conn.begin()

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1,31 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("""
delete from `tabSingles`
where doctype='Notification Control'
and field in (
'payable_voucher',
'payment_received_message',
'payment_sent_message',
'enquiry')
""")
ren_list = [
['expense_voucher', 'expense_claim'],
['receivable_voucher', 'sales_invoice'],
['enquiry', 'opportunity'],
]
for r in ren_list:
webnotes.conn.sql("""
update `tabSingles`
set field=%s
where field=%s
and doctype='Notification Control'
""", (r[1], r[0]))
webnotes.conn.commit()
webnotes.conn.begin()
webnotes.reload_doc('setup', 'doctype', 'notification_control')

View File

@ -1,9 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("delete from `tabProperty Setter` where property in ('width', 'previous_field')")
webnotes.conn.sql("delete from `tabSingles` where field = 'footer_font_color' and doctype = 'Style Settings'")

View File

@ -1,13 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.model.doc import Document
if not webnotes.conn.sql("select name from `tabRole` where name = 'Report Manager'"):
r = Document('Role')
r.role_name = 'Report Manager'
r.module = 'Core'
r.save()

View File

@ -1,33 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
"""Make server custom script readonly for system manager"""
import webnotes.model.doc
new_perms = [
{
'parent': 'Custom Script',
'parentfield': 'permissions',
'parenttype': 'DocType',
'role': 'System Manager',
'permlevel': 1,
'read': 1,
},
{
'parent': 'Custom Script',
'parentfield': 'permissions',
'parenttype': 'DocType',
'role': 'Administrator',
'permlevel': 1,
'read': 1,
'write': 1
},
]
for perms in new_perms:
doc = webnotes.model.doc.Document('DocPerm')
doc.fields.update(perms)
doc.save()
webnotes.conn.commit()
webnotes.conn.begin()
webnotes.reload_doc('core', 'doctype', 'custom_script')

View File

@ -1,9 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("delete from `tabCustomize Form Field`")
webnotes.conn.sql("""delete from `tabSingles`
where doctype='Customize Form'""")

View File

@ -1,9 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
sr = webnotes.conn.sql("select max(name) from `tabPage Role`")
if sr and sr[0][0].startswith('PR'):
webnotes.conn.sql("update tabSeries set current = %s where name = 'PR'", int(sr[0][0][2:]))

View File

@ -1,25 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
"""Make profile readonly for role All"""
import webnotes.model.doc
webnotes.conn.sql("delete from `tabDocPerm` where parent='Profile' and role='All'")
new_perms = [
{
'parent': 'Profile',
'parentfield': 'permissions',
'parenttype': 'DocType',
'role': 'All',
'permlevel': 0,
'read': 1,
},
]
for perms in new_perms:
doc = webnotes.model.doc.Document('DocPerm')
doc.fields.update(perms)
doc.save()
webnotes.conn.commit()
webnotes.conn.begin()
webnotes.reload_doc('core', 'doctype', 'profile')

View File

@ -1,19 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
import webnotes.modules
res = webnotes.conn.sql("""\
select module, name, standard from `tabPrint Format`
where name like 'Sales Invoice%'""", as_dict=1)
for r in res:
if r.get('standard')=='Yes' and \
r.get('name') in [
'Sales Invoice Classic',
'Sales Invoice Spartan',
'Sales Invoice Modern'
]:
webnotes.modules.reload_doc(r.get('module'), 'Print Format', r.get('name'))

View File

@ -1,110 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.reload_doc('support', 'doctype', 'communication')
webnotes.conn.commit()
webnotes.conn.begin()
# change doctype property setter and custom fields, and save them
move_customizations()
try:
remove_communication_log()
except Exception, e:
if e.args[0] != 1146:
raise e
def move_customizations():
import webnotes.model.doc
import webnotes.model.doctype
res = webnotes.conn.sql("""\
delete from `tabProperty Setter`
where property='previous_field'
and doc_type = 'Communication Log'""")
res = webnotes.conn.sql("""\
select name from `tabCustom Field`
where dt='Communication Log'""")
for r in res:
d = webnotes.model.doc.Document('Custom Field', r[0])
d.dt = 'Communication'
d.save()
from webnotes.model.db_schema import updatedb
updatedb('Communication')
res = webnotes.conn.sql("""\
select field_name from `tabProperty Setter`
where doc_type='Communication Log' and field_name is not null""")
doclist = webnotes.model.doctype.get('Communication', 0)
field_list = [d.fieldname for d in doclist if d.doctype=='DocField']
for r in res:
if r[0] in field_list:
webnotes.conn.sql("""\
update `tabProperty Setter`
set doc_type = 'Communication'
where field_name=%s and doc_type='Communication Log'""", r[0])
webnotes.conn.sql("""\
delete from `tabProperty Setter`
where doc_type='Communication Log'""")
webnotes.clear_cache(doctype="Communication")
def remove_communication_log():
import webnotes
import webnotes.model
import webnotes.model.doc
import webnotes.model.doctype
webnotes.conn.auto_commit_on_many_writes = True
# get all communication log records
comm_log_list = webnotes.conn.sql("select * from `tabCommunication Log`",
as_dict=1)
field_list = [d.fieldname for d in \
webnotes.model.doctype.get('Communication', 0) \
if d.doctype=='DocField']
# copy it to communication
for comm_log in comm_log_list:
d = webnotes.model.doc.Document('Communication')
for key in comm_log.keys():
if key not in webnotes.model.default_fields:
d.fields[key] = comm_log[key]
parenttype = (comm_log.get('parenttype') or '').lower()
if parenttype in field_list:
d.fields[parenttype] = comm_log.get('parent')
d.naming_series = 'COMM-'
d.subject = 'Follow Up'
d.content = comm_log.get('notes') or ''
d.medium = comm_log.get('follow_up_type') or ''
d.sales_person = comm_log.get('follow_up_by')
d.communication_date = comm_log.get('date')
d.category = 'Miscellaneous'
d.action = 'No Action'
d.save(ignore_fields=1)
# delete records with parent type "Customer", "Lead", "Supplier"
webnotes.conn.sql("""\
delete from `tabCommunication Log`
where parenttype in ('Customer', 'Lead', 'Supplier',
'Opportunity', 'Quotation')""")
# if all records deleted, drop table communication log
# and delete doctype communication log
# if for some reason, records remain, dont drop table and dont delete doctype
count = webnotes.conn.sql("select count(*) from `tabCommunication Log`")[0][0]
if not count:
webnotes.model.delete_doc('DocType', 'Communication Log')
webnotes.conn.commit()
webnotes.conn.sql("drop table `tabCommunication Log`")
webnotes.conn.begin()

View File

@ -1,21 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
"""
* Replace EURO with EUR
* Delete EURO from tabCurrency
"""
import webnotes
tables = webnotes.conn.sql("show tables")
for (tab,) in tables:
desc = webnotes.conn.sql("desc `%s`" % tab, as_dict=1)
for d in desc:
if "currency" in d.get('Field'):
field = d.get('Field')
webnotes.conn.sql("""\
update `%s` set `%s`='EUR'
where `%s`='EURO'""" % (tab, field, field))
webnotes.conn.sql("update `tabSingles` set value='EUR' where value='EURO'")
webnotes.conn.sql("delete from `tabCurrency` where name='EURO'")

View File

@ -1,18 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
dt_list = webnotes.conn.sql("select parent, fieldname from `tabDocField` where fieldname in ('against_doctype', 'prevdoc_doctype')")
ren_dt = {
'Indent' : 'Material Request',
'Enquiry' : 'Opportunity',
'Receivable Voucher' : 'Sales Invoice',
'Payable Voucher' : 'Purchase Invoice'
}
for d in ren_dt:
for dt in dt_list:
webnotes.conn.sql("update `tab%s` set %s = '%s' where %s = '%s'" % (dt[0], dt[1], ren_dt[d], dt[1], d))

View File

@ -1,12 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.model.code import get_obj
gd = get_obj('Global Defaults')
gd.doc.maintain_same_rate = 1
gd.doc.save()
gd.on_update()

View File

@ -1,33 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
"""Make standard print formats readonly for system manager"""
import webnotes.model.doc
new_perms = [
{
'parent': 'Print Format',
'parentfield': 'permissions',
'parenttype': 'DocType',
'role': 'System Manager',
'permlevel': 1,
'read': 1,
},
{
'parent': 'Print Format',
'parentfield': 'permissions',
'parenttype': 'DocType',
'role': 'Administrator',
'permlevel': 1,
'read': 1,
'write': 1
},
]
for perms in new_perms:
doc = webnotes.model.doc.Document('DocPerm')
doc.fields.update(perms)
doc.save()
webnotes.conn.commit()
webnotes.conn.begin()
webnotes.reload_doc('core', 'doctype', 'print_format')

View File

@ -1,21 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.modules import reload_doc
reload_doc('stock', 'doctype', 'stock_reconciliation')
sr = webnotes.conn.sql("select name, file_list from `tabStock Reconciliation` where docstatus = 1")
for d in sr:
if d[1]:
filename = d[1].split(',')[1]
from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename)
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
webnotes.conn.sql("update `tabStock Reconciliation` set diff_info = %s where name = %s and ifnull(diff_info, '') = ''", (content, d[0]))

View File

@ -10,60 +10,6 @@ patch_list = [
"execute:webnotes.reload_doc('core', 'doctype', 'docperm') #2013-07-16",
"execute:webnotes.reload_doc('core', 'doctype', 'page') #2013-07-16",
"execute:webnotes.reload_doc('core', 'doctype', 'report') #2013-07-16",
"patches.mar_2012.clean_property_setter",
"patches.april_2012.naming_series_patch",
"patches.mar_2012.cleanup_control_panel",
"patches.mar_2012.doctype_get_refactor",
"patches.mar_2012.delete_docformat",
"patches.mar_2012.usertags",
"patches.april_2012.reload_c_form",
"patches.april_2012.after_sync_cleanup",
"patches.april_2012.remove_default_from_rv_detail",
"patches.april_2012.update_role_in_address",
"patches.april_2012.update_permlevel_in_address",
"patches.april_2012.update_appraisal_permission",
"patches.april_2012.repost_stock_for_posting_time",
"patches.may_2012.cleanup_property_setter",
"patches.may_2012.rename_prev_doctype",
"patches.may_2012.cleanup_notification_control",
"patches.may_2012.stock_reco_patch",
"patches.may_2012.page_role_series_fix",
"patches.may_2012.reload_sales_invoice_pf",
"patches.may_2012.std_pf_readonly",
"patches.may_2012.customize_form_cleanup",
"patches.may_2012.cs_server_readonly",
"patches.may_2012.clear_session_cache",
"patches.may_2012.same_purchase_rate_patch",
"patches.may_2012.create_report_manager_role",
"patches.may_2012.profile_perm_patch",
"patches.may_2012.remove_euro_currency",
"patches.may_2012.remove_communication_log",
"patches.june_2012.barcode_in_feature_setup",
"patches.june_2012.copy_uom_for_pur_inv_item",
"patches.june_2012.fetch_organization_from_lead",
"patches.june_2012.reports_list_permission",
"patches.june_2012.support_ticket_autoreply",
"patches.june_2012.series_unique_patch",
"patches.june_2012.set_recurring_type",
"patches.june_2012.alter_tabsessions",
"patches.june_2012.delete_old_parent_entries",
"patches.april_2012.delete_about_contact",
"patches.july_2012.reload_pr_po_mapper",
"patches.july_2012.address_contact_perms",
"patches.july_2012.packing_list_cleanup_and_serial_no",
"patches.july_2012.deprecate_import_data_control",
"patches.july_2012.default_freeze_account",
"patches.july_2012.update_purchase_tax",
"patches.june_2012.cms2",
"patches.july_2012.auth_table",
"patches.july_2012.remove_event_role_owner_match",
"patches.july_2012.deprecate_bulk_rename",
"patches.july_2012.bin_permission",
"patches.july_2012.project_patch_repeat",
"patches.july_2012.repost_stock_due_to_wrong_packing_list",
"patches.august_2012.task_allocated_to_assigned",
"patches.august_2012.change_profile_permission",
"patches.august_2012.repost_billed_amt",
"patches.september_2012.stock_report_permissions_for_accounts",
"patches.september_2012.communication_delete_permission",
"patches.september_2012.all_permissions_patch",
@ -255,7 +201,6 @@ patch_list = [
"patches.august_2013.p05_employee_birthdays",
"execute:webnotes.reload_doc('accounts', 'Print Format', 'POS Invoice') # 2013-08-16",
"patches.august_2013.p06_fix_sle_against_stock_entry",
"execute:webnotes.bean('Style Settings').save() #2013-08-20",
"patches.september_2013.p01_add_user_defaults_from_pos_setting",
"execute:webnotes.reload_doc('accounts', 'Print Format', 'POS Invoice') # 2013-09-02",
"patches.september_2013.p01_fix_buying_amount_gl_entries",
@ -264,4 +209,6 @@ patch_list = [
"patches.september_2013.p02_fix_serial_no_status",
"patches.september_2013.p03_modify_item_price_include_in_price_list",
"patches.september_2013.p03_update_stock_uom_in_sle",
"patches.september_2013.p03_move_website_to_framework",
"execute:webnotes.bean('Style Settings').save() #2013-09-19",
]

View File

@ -17,7 +17,7 @@ def execute():
serial_nos = d.serial_no.split("\n")
for sr in serial_nos:
serial_no = sr.strip()
if serial_no:
if serial_no and webnotes.conn.exists("Serial No", serial_no):
serial_bean = webnotes.bean("Serial No", serial_no)
if serial_bean.doc.status == "Not Available":
latest_sle = webnotes.conn.sql("""select voucher_no from `tabStock Ledger Entry`

View File

@ -7,11 +7,13 @@ import webnotes
def execute():
webnotes.reload_doc("setup", "doctype", "price_list")
webnotes.reload_doc("setup", "doctype", "item_price")
webnotes.reload_doc("stock", "doctype", "item")
webnotes.conn.sql("""update `tabItem Price` set parenttype='Price List',
parentfield='item_prices', item_code=parent""")
parentfield='item_prices', `item_code`=`parent`""")
# re-arranging idx of items
webnotes.conn.sql("""update `tabItem Price` set parent=price_list, idx=0""")
webnotes.conn.sql("""update `tabItem Price` set `parent`=`price_list`, idx=0""")
for pl in webnotes.conn.sql("""select name from `tabPrice List`"""):
webnotes.conn.sql("""set @name=0""")
webnotes.conn.sql("""update `tabItem Price` set idx = @name := IF(ISNULL( @name ), 0, @name + 1)

View File

@ -0,0 +1,17 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import get_base_path
import os, shutil
def execute():
# remove pyc files
utils_pyc = os.path.join(get_base_path(), "app", "selling", "utils.pyc")
if os.path.exists(utils_pyc):
os.remove(utils_pyc)
old_path = os.path.join(get_base_path(), "app", "website")
if os.path.exists(old_path):
shutil.rmtree(old_path)

View File

@ -0,0 +1,3 @@
{% extends "lib/website/templates/base.html" %}
{% block footer %}{% include "app/portal/templates/includes/footer.html" %}{% endblock %}

View File

@ -4,33 +4,33 @@
// js inside blog page
$(document).ready(function() {
wn.cart.bind_events();
erpnext.cart.bind_events();
return wn.call({
type: "POST",
method: "website.helpers.cart.get_cart_quotation",
method: "selling.utils.cart.get_cart_quotation",
callback: function(r) {
console.log(r);
$("#cart-container").removeClass("hide");
$(".progress").remove();
if(r.exc) {
if(r.exc.indexOf("WebsitePriceListMissingError")!==-1) {
wn.cart.show_error("Oops!", "Price List not configured.");
erpnext.cart.show_error("Oops!", "Price List not configured.");
} else if(r["403"]) {
wn.cart.show_error("Hey!", "You need to be logged in to view your cart.");
erpnext.cart.show_error("Hey!", "You need to be logged in to view your cart.");
} else {
wn.cart.show_error("Oops!", "Something went wrong.");
erpnext.cart.show_error("Oops!", "Something went wrong.");
}
} else {
wn.cart.set_cart_count();
wn.cart.render(r.message);
erpnext.cart.set_cart_count();
erpnext.cart.render(r.message);
}
}
});
});
// shopping cart
if(!wn.cart) wn.cart = {};
$.extend(wn.cart, {
if(!erpnext.cart) erpnext.cart = {};
$.extend(erpnext.cart, {
show_error: function(title, text) {
$("#cart-container").html('<div class="well"><h4>' + title + '</h4> ' + text + '</div>');
},
@ -39,14 +39,14 @@ $.extend(wn.cart, {
// bind update button
$(document).on("click", ".item-update-cart button", function() {
var item_code = $(this).attr("data-item-code");
wn.cart.update_cart({
erpnext.cart.update_cart({
item_code: item_code,
qty: $('input[data-item-code="'+item_code+'"]').val(),
with_doclist: 1,
btn: this,
callback: function(r) {
if(!r.exc) {
wn.cart.render(r.message);
erpnext.cart.render(r.message);
var $button = $('button[data-item-code="'+item_code+'"]').addClass("btn-success");
setTimeout(function() { $button.removeClass("btn-success"); }, 1000);
}
@ -63,7 +63,7 @@ $.extend(wn.cart, {
});
$(".btn-place-order").on("click", function() {
wn.cart.place_order();
erpnext.cart.place_order(this);
});
},
@ -79,7 +79,7 @@ $.extend(wn.cart, {
var no_items = $.map(doclist, function(d) { return d.item_code || null;}).length===0;
if(no_items) {
wn.cart.show_error("Empty :-(", "Go ahead and add something to your cart.");
erpnext.cart.show_error("Empty :-(", "Go ahead and add something to your cart.");
$("#cart-addresses").toggle(false);
return;
}
@ -89,14 +89,14 @@ $.extend(wn.cart, {
var shipping_rule_labels = $.map(out.shipping_rules || [], function(rule) { return rule[1]; });
$.each(doclist, function(i, doc) {
if(doc.doctype === "Quotation Item") {
wn.cart.render_item_row($cart_items, doc);
erpnext.cart.render_item_row($cart_items, doc);
} else if (doc.doctype === "Sales Taxes and Charges") {
if(out.shipping_rules && out.shipping_rules.length &&
shipping_rule_labels.indexOf(doc.description)!==-1) {
shipping_rule_added = true;
wn.cart.render_tax_row($cart_taxes, doc, out.shipping_rules);
erpnext.cart.render_tax_row($cart_taxes, doc, out.shipping_rules);
} else {
wn.cart.render_tax_row($cart_taxes, doc);
erpnext.cart.render_tax_row($cart_taxes, doc);
}
taxes_exist = true;
@ -104,7 +104,7 @@ $.extend(wn.cart, {
});
if(out.shipping_rules && out.shipping_rules.length && !shipping_rule_added) {
wn.cart.render_tax_row($cart_taxes, {description: "", formatted_tax_amount: ""},
erpnext.cart.render_tax_row($cart_taxes, {description: "", formatted_tax_amount: ""},
out.shipping_rules);
taxes_exist = true;
}
@ -112,7 +112,7 @@ $.extend(wn.cart, {
if(taxes_exist)
$('<hr>').appendTo($cart_taxes);
wn.cart.render_tax_row($cart_totals, {
erpnext.cart.render_tax_row($cart_totals, {
description: "<strong>Total</strong>",
formatted_tax_amount: "<strong>" + doclist[0].formatted_grand_total_export + "</strong>"
});
@ -120,15 +120,15 @@ $.extend(wn.cart, {
if(!(addresses && addresses.length)) {
$cart_shipping_address.html('<div class="well">Hey! Go ahead and add an address</div>');
} else {
wn.cart.render_address($cart_shipping_address, addresses, doclist[0].shipping_address_name);
wn.cart.render_address($cart_billing_address, addresses, doclist[0].customer_address);
erpnext.cart.render_address($cart_shipping_address, addresses, doclist[0].shipping_address_name);
erpnext.cart.render_address($cart_billing_address, addresses, doclist[0].customer_address);
}
},
render_item_row: function($cart_items, doc) {
doc.image_html = doc.image ?
'<div style="height: 120px; overflow: hidden;"><img src="' + doc.image + '" /></div>' :
'{% include "app/website/templates/html/product_missing_image.html" %}';
'{% include "app/stock/doctype/item/templates/includes/product_missing_image.html" %}';
if(doc.description === doc.item_name) doc.description = "";
@ -185,7 +185,7 @@ $.extend(wn.cart, {
}
});
$tax_row.find('select').on("change", function() {
wn.cart.apply_shipping_rule($(this).val(), this);
erpnext.cart.apply_shipping_rule($(this).val(), this);
});
}
},
@ -194,11 +194,11 @@ $.extend(wn.cart, {
return wn.call({
btn: btn,
type: "POST",
method: "website.helpers.cart.apply_shipping_rule",
method: "selling.utils.cart.apply_shipping_rule",
args: { shipping_rule: rule },
callback: function(r) {
if(!r.exc) {
wn.cart.render(r.message);
erpnext.cart.render(r.message);
}
}
});
@ -242,14 +242,14 @@ $.extend(wn.cart, {
return wn.call({
type: "POST",
method: "website.helpers.cart.update_cart_address",
method: "selling.utils.cart.update_cart_address",
args: {
address_fieldname: $address_wrapper.attr("data-fieldname"),
address_name: $(this).attr("data-address-name")
},
callback: function(r) {
if(!r.exc) {
wn.cart.render(r.message);
erpnext.cart.render(r.message);
}
}
});
@ -270,10 +270,11 @@ $.extend(wn.cart, {
.collapse("show");
},
place_order: function() {
place_order: function(btn) {
return wn.call({
type: "POST",
method: "website.helpers.cart.place_order",
method: "selling.utils.cart.place_order",
btn: btn,
callback: function(r) {
if(r.exc) {
var msg = "";

View File

@ -0,0 +1,40 @@
{% extends "lib/website/templates/includes/footer.html" %}
{% block powered %}<a style="font-size: 90%; color: #aaa;" href="http://erpnext.org">ERPNext Powered</a>{% endblock %}
{% block extension %}
<br>
<div class="input-group col-md-6 col-md-offset-3">
<input class="form-control" type="text" id="footer-subscribe-email" placeholder="Your email address...">
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="footer-subscribe-button">Stay Updated</button>
</span>
</div>
<br>
<script>
$("#footer-subscribe-button").click(function() {
$("#footer-subscribe-email").attr('disabled', true);
$("#footer-subscribe-button").html("Sending...")
.attr("disabled", true);
if($("#footer-subscribe-email").val()) {
erpnext.send_message({
subject:"Subscribe me",
sender: $("#footer-subscribe-email").val(),
message: "Subscribe to newsletter (via website footer).",
callback: function(r) {
if(!r.exc) {
$("#footer-subscribe-button").html("Thank You :)")
.addClass("btn-success").attr("disabled", true);
} else {
$("#footer-subscribe-button").html("Error :( Not a valid id?")
.addClass("btn-danger").attr("disabled", false);
$("#footer-subscribe-email").val("").attr('disabled', false);
}
}
});
}
});
</script>
{% endblock %}

View File

@ -1,12 +1,13 @@
{% extends "app/website/templates/html/page.html" %}
{% extends base_template %}
{% block content -%}
<div class="col-md-12">
<ul class="breadcrumb">
<li><a href="index">Home</a></li>
<li><a href="account">My Account</a></li>
<li class="active"><i class="{{ icon }} icon-fixed-width"></i> {{ title }}</li>
</ul>
<p id="msgprint-alert" class="alert alert-danger"
style="display: none;">&nbsp;</p>
<div class="list-group transaction-list">
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
@ -19,6 +20,7 @@
{%- endblock %}
{% block javascript -%}
<script>
$(document).ready(function() {
window.start = 0;
window.$list = $(".transaction-list");
@ -35,7 +37,6 @@ var get_transactions = function(btn) {
callback: function(r) {
$list.find(".progress").remove();
$show_more.toggleClass("hide", !(r.message && r.message.length===20));
if(!(r.message && r.message.length)) {
console.log("empty");
if(!$list.html().trim()) {
@ -53,7 +54,7 @@ var get_transactions = function(btn) {
}
})
};
</script>
// var render = function(doc) { };
<!-- // var render = function(doc) { }; -->
{% endblock %}

View File

@ -1,7 +1,7 @@
{% extends "app/website/templates/html/page.html" %}
{% extends base_template %}
{% block javascript %}
{% include "app/website/templates/js/cart.js" %}
<script>{% include "app/portal/templates/includes/cart.js" %}</script>
{% endblock %}
{% set title="Shopping Cart" %}
@ -13,7 +13,7 @@
<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
</div>
<div id="cart-container" class="hide">
<button class="btn btn-success pull-right btn-place-order" type="button">Place Order</button>
<p class="pull-right"><button class="btn btn-success btn-place-order" type="button">Place Order</button></p>
<div class="clearfix"></div>
<div id="cart-error" class="alert alert-danger" style="display: none;"></div>
<hr>
@ -51,7 +51,7 @@
</div>
<hr>
</div>
<button class="btn btn-success pull-right btn-place-order" type="button">Place Order</button>
<p class="pull-right"><button class="btn btn-success btn-place-order" type="button">Place Order</button></p>
</div>
</div>
{% endblock %}

View File

@ -2,6 +2,5 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
def execute():
import webnotes
webnotes.conn.sql("delete from __SessionCache")
no_cache = True

View File

@ -1,4 +1,4 @@
{% extends "app/website/templates/html/page.html" %}
{% extends base_template %}
{% set title="My Profile" %}
@ -6,19 +6,14 @@
<div class="col-md-12">
<ul class="breadcrumb">
<li><a href="index">Home</a></li>
<li><a href="account">My Account</a></li>
<li class="active"><i class="icon-user icon-fixed-width"></i> My Profile</li>
</ul>
<div class="alert" id="message" style="display: none;"></div>
<div class="alert alert-warning" id="message" style="display: none;"></div>
<form>
<fieldset>
<label>Full Name</label>
<input class="form-control" type="text" id="fullname" placeholder="Your Name">
</fieldset>
<fieldset>
<label>Password</label>
<input class="form-control" type="password" id="password" placeholder="Password">
</fieldset>
<fieldset>
<label>Company Name</label>
<input class="form-control" type="text" id="company_name" placeholder="Company Name" value="{{ company_name }}">
@ -39,11 +34,10 @@ $(document).ready(function() {
$("#fullname").val(getCookie("full_name") || "");
$("#update_profile").click(function() {
wn.call({
method: "startup.webutils.update_profile",
method: "portal.templates.pages.profile.update_profile",
type: "POST",
args: {
fullname: $("#fullname").val(),
password: $("#password").val(),
company_name: $("#company_name").val(),
mobile_no: $("#mobile_no").val(),
phone: $("#phone").val()

View File

@ -0,0 +1,39 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.utils import cstr
no_cache = True
def get_context():
from selling.utils.cart import get_lead_or_customer
party = get_lead_or_customer()
if party.doctype == "Lead":
mobile_no = party.mobile_no
phone = party.phone
else:
mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
"customer": party.name}, ["mobile_no", "phone"])
return {
"company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name),
"mobile_no": cstr(mobile_no),
"phone": cstr(phone)
}
@webnotes.whitelist()
def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None):
from selling.utils.cart import update_party
update_party(fullname, company_name, mobile_no, phone)
if not fullname:
return _("Name is required")
webnotes.conn.set_value("Profile", webnotes.session.user, "first_name", fullname)
webnotes.add_cookies["full_name"] = fullname
return _("Updated")

View File

@ -1,4 +1,4 @@
{% extends "app/website/templates/html/page.html" %}
{% extends base_template %}
{% set title=doc.name %}
@ -6,7 +6,6 @@
<div class="col-md-12">
<ul class="breadcrumb">
<li><a href="index">Home</a></li>
<li><a href="account">My Account</a></li>
<li><a href="{{ parent_link }}">{{ parent_title }}</a></li>
<li class="active"><i class="icon-file icon-fixed-width"></i> {{ doc.name }}</li>
</ul>
@ -18,7 +17,7 @@
<div>
<div class="row">
<div class="col-xs-6">
{% if doc.status -%}<div class="label label-default">{{ doc.status }}</div>{%- endif %}
{% block status -%}{%- endblock %}
</div>
<div class="col-xs-6">
<span class="pull-right">{{ utils.formatdate(doc.posting_date or doc.transaction_date) }}</span>

View File

@ -0,0 +1,32 @@
{% extends "app/portal/templates/includes/transactions.html" %}
{% block javascript -%}
<script>
$(document).ready(function() {
global_number_format = "{{ global_number_format }}";
currency = "{{ currency }}";
wn.currency_symbols = {{ currency_symbols }};
});
</script>
{{ super() }}
<script>
var render = function(doc) {
doc.grand_total_export = format_currency(doc.grand_total_export, doc.currency);
if(!doc.status) doc.status = "";
$(repl('<a href="{{ page }}?name=%(name)s" class="list-group-item">\
<div class="row">\
<div class="col-md-6">\
<div class="row col-md-12">%(name)s</div>\
<div class="row col-md-12 text-muted">%(items)s</div>\
<div class="row col-md-12">%(status)s</div>\
</div>\
<div class="col-md-3 text-right">%(grand_total_export)s</div>\
<div class="col-md-3 text-right text-muted">%(creation)s</div>\
</div>\
</a>', doc)).appendTo($list);
};
</script>
{%- endblock %}

72
portal/utils.py Normal file
View File

@ -0,0 +1,72 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, formatdate
import json
def get_transaction_list(doctype, start, additional_fields=None):
# find customer id
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
"customer")
if customer:
if additional_fields:
additional_fields = ", " + ", ".join(("`%s`" % f for f in additional_fields))
else:
additional_fields = ""
transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export
%s
from `tab%s` where customer=%s and docstatus=1
order by creation desc
limit %s, 20""" % (additional_fields, doctype, "%s", "%s"),
(customer, cint(start)), as_dict=True)
for doc in transactions:
items = webnotes.conn.sql_list("""select item_name
from `tab%s Item` where parent=%s limit 6""" % (doctype, "%s"), doc.name)
doc.items = ", ".join(items[:5]) + ("..." if (len(items) > 5) else "")
doc.creation = formatdate(doc.creation)
return transactions
else:
return []
def get_currency_context():
return {
"global_number_format": webnotes.conn.get_default("number_format") or "#,###.##",
"currency": webnotes.conn.get_default("currency"),
"currency_symbols": json.dumps(dict(webnotes.conn.sql("""select name, symbol
from tabCurrency where ifnull(enabled,0)=1""")))
}
def get_transaction_context(doctype, name):
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
"customer")
bean = webnotes.bean(doctype, name)
if bean.doc.customer != customer:
return {
"doc": {"name": "Not Allowed"}
}
else:
return {
"doc": bean.doc,
"doclist": bean.doclist,
"webnotes": webnotes,
"utils": webnotes.utils
}
@webnotes.whitelist(allow_guest=True)
def send_message(subject="Website Query", message="", sender="", status="Open"):
from website.doctype.contact_us_settings.templates.pages.contact \
import send_message as website_send_message
if not website_send_message(subject, message, sender):
return
# make lead / communication
from selling.doctype.lead.get_leads import add_sales_communication
add_sales_communication(subject or "Website Query", message, sender, sender,
mail=None, status=status)

View File

@ -40,7 +40,7 @@ wn.module_page["Projects"] = [
icon: "icon-wrench",
items: [
{
page: "Projects",
route: "Gantt/Task",
label: wn._("Gantt Chart"),
"description":wn._("Gantt chart of all tasks.")
},

View File

@ -1,7 +1,6 @@
{
"public/css/all-web.css": [
"app/public/js/startup.css",
"app/website/css/website.css"
],
"public/css/all-app.css": [
"app/public/js/startup.css"

View File

@ -2,200 +2,40 @@
// License: GNU General Public License v3. See license.txt
if(!window.erpnext) erpnext = {};
if(!window.wn) wn = {};
// Add / update a new Lead / Communication
// subject, sender, description
erpnext.send_message = function(opts) {
wn.send_message = function(opts, btn) {
return wn.call({
type: "POST",
method: "website.helpers.contact.send_message",
method: "portal.utils.send_message",
btn: btn,
args: opts,
callback: opts.callback
});
}
};
wn.call = function(opts) {
if(opts.btn) {
$(opts.btn).prop("disabled", true);
}
if(opts.msg) {
$(opts.msg).toggle(false);
}
if(!opts.args) opts.args = {};
// get or post?
if(!opts.args._type) {
opts.args._type = opts.type || "GET";
}
// method
if(opts.method) {
opts.args.cmd = opts.method;
}
// stringify
$.each(opts.args, function(key, val) {
if(typeof val != "string") {
opts.args[key] = JSON.stringify(val);
}
});
$.ajax({
type: "POST",
url: "server.py",
data: opts.args,
dataType: "json",
success: function(data) {
if(opts.btn) {
$(opts.btn).prop("disabled", false);
}
if(data.exc) {
if(opts.btn) {
$(opts.btn).addClass("btn-danger");
setTimeout(function() { $(opts.btn).removeClass("btn-danger"); }, 1000);
}
try {
var err = JSON.parse(data.exc);
if($.isArray(err)) {
err = err.join("\n");
}
console.error ? console.error(err) : console.log(err);
} catch(e) {
console.log(data.exc);
}
} else{
if(opts.btn) {
$(opts.btn).addClass("btn-success");
setTimeout(function() { $(opts.btn).removeClass("btn-success"); }, 1000);
}
}
if(opts.msg && data.message) {
$(opts.msg).html(data.message).toggle(true);
}
if(opts.callback)
opts.callback(data);
},
error: function(response) {
console.error ? console.error(response) : console.log(response);
}
});
return false;
}
// for backward compatibility
erpnext.send_message = wn.send_message;
// Setup the user tools
//
$(document).ready(function() {
// update login
var full_name = getCookie("full_name");
erpnext.cart.set_cart_count();
// update profile
if(full_name) {
$("#user-tools").addClass("hide");
$("#user-tools-post-login").removeClass("hide");
$("#user-full-name").text(full_name);
$('.navbar li[data-label="Profile"] a')
.html('<i class="icon-fixed-width icon-user"></i> ' + full_name);
}
wn.cart.set_cart_count();
$("#user-tools a").tooltip({"placement":"bottom"});
$("#user-tools-post-login a").tooltip({"placement":"bottom"});
});
// Utility functions
function valid_email(id) {
if(id.toLowerCase().search("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")==-1)
return 0; else return 1; }
var validate_email = valid_email;
function get_url_arg(name) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if(results == null)
return "";
else
return decodeURIComponent(results[1]);
}
function make_query_string(obj) {
var query_params = [];
$.each(obj, function(k, v) { query_params.push(encodeURIComponent(k) + "=" + encodeURIComponent(v)); });
return "?" + query_params.join("&");
}
function repl(s, dict) {
if(s==null)return '';
for(key in dict) {
s = s.split("%("+key+")s").join(dict[key]);
}
return s;
}
function replace_all(s, t1, t2) {
return s.split(t1).join(t2);
}
function getCookie(name) {
return getCookies()[name];
}
function getCookies() {
var c = document.cookie, v = 0, cookies = {};
if (document.cookie.match(/^\s*\$Version=(?:"1"|1);\s*(.*)/)) {
c = RegExp.$1;
v = 1;
}
if (v === 0) {
c.split(/[,;]/).map(function(cookie) {
var parts = cookie.split(/=/, 2),
name = decodeURIComponent(parts[0].trimLeft()),
value = parts.length > 1 ? decodeURIComponent(parts[1].trimRight()) : null;
if(value && value.charAt(0)==='"') {
value = value.substr(1, value.length-2);
}
cookies[name] = value;
});
} else {
c.match(/(?:^|\s+)([!#$%&'*+\-.0-9A-Z^`a-z|~]+)=([!#$%&'*+\-.0-9A-Z^`a-z|~]*|"(?:[\x20-\x7E\x80\xFF]|\\[\x00-\x7F])*")(?=\s*[,;]|$)/g).map(function($0, $1) {
var name = $0,
value = $1.charAt(0) === '"'
? $1.substr(1, -1).replace(/\\(.)/g, "$1")
: $1;
cookies[name] = value;
});
}
return cookies;
}
if (typeof String.prototype.trimLeft !== "function") {
String.prototype.trimLeft = function() {
return this.replace(/^\s+/, "");
};
}
if (typeof String.prototype.trimRight !== "function") {
String.prototype.trimRight = function() {
return this.replace(/\s+$/, "");
};
}
if (typeof Array.prototype.map !== "function") {
Array.prototype.map = function(callback, thisArg) {
for (var i=0, n=this.length, a=[]; i<n; i++) {
if (i in this) a[i] = callback.call(thisArg, this[i]);
}
return a;
};
}
// shopping cart
if(!wn.cart) wn.cart = {};
var full_name = getCookie("full_name");
if(!erpnext.cart) erpnext.cart = {};
$.extend(wn.cart, {
$.extend(erpnext.cart, {
update_cart: function(opts) {
if(!full_name) {
if(localStorage) {
@ -206,7 +46,7 @@ $.extend(wn.cart, {
} else {
return wn.call({
type: "POST",
method: "website.helpers.cart.update_cart",
method: "selling.utils.cart.update_cart",
args: {
item_code: opts.item_code,
qty: opts.qty,
@ -217,7 +57,7 @@ $.extend(wn.cart, {
if(opts.callback)
opts.callback(r);
wn.cart.set_cart_count();
erpnext.cart.set_cart_count();
}
});
}
@ -225,29 +65,22 @@ $.extend(wn.cart, {
set_cart_count: function() {
var cart_count = getCookie("cart_count");
if(cart_count)
$(".cart-count").html("( "+ cart_count +" )")
}
});
function remove_script_and_style(txt) {
return (!txt || (txt.indexOf("<script>")===-1 && txt.indexOf("<style>")===-1)) ? txt :
$("<div></div>").html(txt).find("script,noscript,style,title,meta").remove().end().html();
}
function is_html(txt) {
if(txt.indexOf("<br>")==-1 && txt.indexOf("<p")==-1
&& txt.indexOf("<img")==-1 && txt.indexOf("<div")==-1) {
return false;
}
return true;
}
function ask_to_login() {
if(!full_name) {
if(localStorage) {
localStorage.setItem("last_visited", window.location.href.split("/").slice(-1)[0]);
var $cart = $("#website-post-login").find('[data-label="Cart"]');
var $badge = $cart.find(".badge");
var $cog = $("#website-post-login").find(".dropdown-toggle");
var $cog_count = $cog.find(".cart-count");
if(cart_count) {
if($badge.length === 0) {
var $badge = $('<span class="badge pull-right"></span>').appendTo($cart.find("a"));
}
$badge.html(cart_count);
if($cog_count.length === 0) {
var $cog_count = $('<sup class="cart-count"></span>').insertAfter($cog.find(".icon-cog"));
}
$cog_count.html(cart_count);
} else {
$badge.remove();
$cog_count.remove();
}
window.location.href = "login";
}
}
});

View File

@ -286,6 +286,9 @@ class DocType(SellingController):
def on_update(self):
pass
def get_portal_page(self):
return "order" if self.doc.docstatus==1 else None
def set_missing_values(source, target):
bean = webnotes.bean(target)
bean.run_method("onload_post_render")

Some files were not shown because too many files have changed in this diff Show More