[pos] [minor] pos print format & pos setting cancel function allowed

This commit is contained in:
Akhilesh Darjee
2013-09-02 18:53:09 +05:30
57 changed files with 460 additions and 311 deletions

View File

@@ -0,0 +1,49 @@
import webnotes
def execute():
create_fiscal_years()
doctypes = webnotes.conn.sql_list("""select parent from tabDocField
where (fieldtype="Link" and options='Fiscal Year')
or (fieldtype="Select" and options='link:Fiscal Year')""")
for dt in doctypes:
date_fields = webnotes.conn.sql_list("""select fieldname from tabDocField
where parent=%s and fieldtype='Date'""", dt)
date_field = get_date_field(date_fields, dt)
if not date_field:
print dt, date_field
else:
webnotes.conn.sql("""update `tab%s` set fiscal_year =
if(%s<='2013-06-30', '2012-2013', '2013-2014')""" % (dt, date_field))
def create_fiscal_years():
fiscal_years = {
"2012-2013": ["2012-07-01", "2013-06-30"],
"2013-2014": ["2013-07-01", "2014-06-30"]
}
for d in fiscal_years:
webnotes.bean({
"doctype": "Fiscal Year",
"year": d,
"year_start_date": fiscal_years[d][0],
"is_fiscal_year_closed": "No"
}).insert()
def get_date_field(date_fields, dt):
date_field = None
if date_fields:
if "posting_date" in date_fields:
date_field = "posting_date"
elif "transaction_date" in date_fields:
date_field = 'transaction_date'
else:
date_field = date_fields[0]
# print dt, date_fields
return date_field

View File

@@ -259,4 +259,6 @@ patch_list = [
"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",
"patches.september_2013.p01_update_communication",
]

View File

@@ -0,0 +1,66 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import webnotes.defaults
from webnotes.utils import cint
def execute():
if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")):
return
# fix delivery note
for dn in webnotes.conn.sql_list("""select name from `tabDelivery Note` where docstatus=1
and posting_date >= "2013-08-06" order by posting_date"""):
recreate_gl_entries("Delivery Note", dn, "delivery_note_details")
# fix sales invoice
for si in webnotes.conn.sql_list("""select name from `tabSales Invoice` where docstatus=1
and update_stock=1 and posting_date >= "2013-08-06" order by posting_date"""):
recreate_gl_entries("Sales Invoice", si, "entries")
def recreate_gl_entries(doctype, name, parentfield):
# calculate buying amount and make gl entries
bean = webnotes.bean(doctype, name)
bean.run_method("set_buying_amount")
company_values = webnotes.conn.get_value("Company", bean.doc.company, ["default_expense_account",
"stock_adjustment_account", "cost_center", "stock_adjustment_cost_center"])
# update missing expense account and cost center
for item in bean.doclist.get({"parentfield": parentfield}):
if item.buying_amount and not validate_item_values(item, bean.doc.company):
res = webnotes.conn.sql("""select expense_account, cost_center
from `tab%s` child where docstatus=1 and item_code=%s and
ifnull(expense_account, '')!='' and ifnull(cost_center, '')!='' and
(select company from `tabAccount` ac where ac.name=child.expense_account)=%s and
(select company from `tabCost Center` cc where cc.name=child.cost_center)=%s
order by creation desc limit 1""" % (item.doctype, "%s", "%s", "%s"),
(item.item_code, bean.doc.company, bean.doc.company))
if res:
item.expense_account = res[0][0]
item.cost_center = res[0][1]
elif company_values:
item.expense_account = company_values[0] or company_values[1]
item.cost_center = company_values[2] or company_values[3]
webnotes.conn.set_value(item.doctype, item.name, "expense_account", item.expense_account)
webnotes.conn.set_value(item.doctype, item.name, "cost_center", item.cost_center)
# remove gl entries
webnotes.conn.sql("""delete from `tabGL Entry` where voucher_type=%s
and voucher_no=%s""", (doctype, name))
bean.run_method("make_gl_entries")
def validate_item_values(item, company):
if item.expense_account and \
webnotes.conn.get_value("Account", item.expense_account, "company")!=company:
return False
elif item.cost_center and \
webnotes.conn.get_value("Cost Center", item.cost_center, "company")!=company:
return False
elif not (item.expense_account and item.cost_center):
return False
return True

View File

@@ -0,0 +1,15 @@
import webnotes
def execute():
for doctype in ("Contact", "Lead", "Job Applicant", "Supplier", "Customer", "Quotation", "Sales Person", "Support Ticket"):
fieldname = doctype.replace(" ", '_').lower()
webnotes.conn.sql("""update tabCommunication
set parenttype=%s, parentfield='communications',
parent=`%s`
where ifnull(`%s`, '')!=''""" % ("%s", fieldname, fieldname), doctype)
webnotes.reload_doc("core", "doctype", "communication")
webnotes.conn.sql("""update tabCommunication set communication_date = creation where
ifnull(communication_date, '')='' """)