fixed conflict while merging with webnotes repo

This commit is contained in:
nabinhait 2011-07-06 09:23:02 +05:30
commit 5deab24401
11 changed files with 944 additions and 216 deletions

View File

@ -168,7 +168,7 @@ class DocType:
against_voucher = sql("select against_voucher, against_voucher_type from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled, 'No')='No' and company=%s and ifnull(against_voucher, '') != '' and ifnull(against_voucher_type, '') != '' group by against_voucher, against_voucher_type", (self.doc.name, self.doc.company))
for d in against_voucher:
# get voucher balance
bal = sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s and ifnull(is_cancelled, 'No')='No'", (d[0], d[1]))
bal = sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s and ifnull(is_cancelled, 'No') = 'No'", (d[0], d[1]))
bal = bal and flt(bal[0][0]) or 0.0
if d[1] == 'Payable Voucher':
bal = -bal

View File

@ -1,8 +1,9 @@
import webnotes
from webnotes import msgprint
feed_dict = {
# Project
'Ticket': ['[%(status)s] %(subject)s', '#000080'],
'Project': ['[%(status)s] %(subject)s', '#000080'],
# Sales
'Lead': ['%(lead_name)s', '#000080'],
@ -29,12 +30,44 @@ feed_dict = {
# Support
'Customer Issue': ['[%(status)s] %(description)s by %(customer_name)s', '#000080'],
'Maintenance Visit':['To %(customer_name)s', '#4169E1'],
'Support Ticket': ['[%(status)s] %(subject)s', '#000080']
'Support Ticket': ['[%(status)s] %(subject)s', '#000080']
}
feed_dict_color = {
# Project
'Project': '#000080',
# Sales
'Lead': '#000080',
'Quotation': '#4169E1',
'Sales Order': '#4169E1',
# Purchase
'Supplier': '#6495ED',
'Purchase Order': '#4169E1',
# Stock
'Delivery Note': '#4169E1',
# Accounts
'Journal Voucher': '#4169E1',
'Payable Voucher': '#4169E1',
'Receivable Voucher': '#4169E1',
# HR
'Expense Voucher': '#4169E1',
'Salary Slip': '#4169E1',
'Leave Transaction': '#4169E1',
# Support
'Customer Issue': '#000080',
'Maintenance Visit': '#4169E1',
'Support Ticket': '#000080'
}
def make_feed(doc, subject, color):
"makes a new Feed record"
#msgprint(subject)
from webnotes.model.doc import Document
webnotes.conn.sql("delete from tabFeed where doc_type=%s and doc_name=%s", (doc.doctype, doc.name))
f = Document('Feed')
@ -43,11 +76,24 @@ def make_feed(doc, subject, color):
f.subject = subject
f.color = color
f.save(1)
def update_feed1(doc):
"adds a new feed"
prop_rec = webnotes.conn.sql("select value from `tabProperty Setter` where doc_type = %s and property = 'subject'", (doc.doctype))
if prop_rec:
subject = prop_rec[0][0]
else:
rec = webnotes.conn.sql("select subject from tabDocType where name=%s", (doc.doctype))
subject = rec[0][0]
subject, color = [subject, feed_dict_color.get(doc.doctype)]
if subject:
subject = subject % doc.fields
make_feed(doc, subject, color)
def update_feed(doc):
"adds a new feed"
subject, color = feed_dict.get(doc.doctype, [None, None])
if subject:
subject = subject % doc.fields
make_feed(doc, subject, color)

View File

@ -1218,9 +1218,10 @@ def execute(patch_no):
sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'Button'")
reload_doc('setup', 'doctype', 'company')
elif patch_no == 308:
from erpnext_structure_cleanup import run_patches
run_patches()
sql("update `tabDocField` set reqd = 0 where fieldname = 'select_item' and parent = 'Property Setter'")
elif patch_no == 309:
sql("delete from `tabDocField` where fieldname = 'item_attachments_details' and parent = 'Item'")
elif patch_no == 310:
sql("delete from `tabModule Def Item` where parent = 'Stock' and doc_name = 'Landed Cost Wizard'")
elif patch_no == 310:
from erpnext_structure_cleanup import run_patches
run_patches()

View File

@ -5,64 +5,60 @@ from webnotes.model.doc import Document
from webnotes.model.doclist import getlist
from webnotes.model.code import get_obj
from webnotes import session, form, is_testing, msgprint, errprint
from webnotes.utils import flt
sql = webnotes.conn.sql
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.nsm_parent_field = 'parent_sales_person';
def check_state(self):
return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.nsm_parent_field = 'parent_sales_person';
def check_state(self):
return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
# update Node Set Model
def update_nsm_model(self):
import webnotes
import webnotes.utils.nestedset
webnotes.utils.nestedset.update_nsm(self)
# update Node Set Model
def update_nsm_model(self):
import webnotes
import webnotes.utils.nestedset
webnotes.utils.nestedset.update_nsm(self)
# ON UPDATE
#--------------------------------------
def on_update(self):
# update nsm
self.update_nsm_model()
# ON UPDATE
#--------------------------------------
def on_update(self):
# update nsm
self.update_nsm_model()
def validate(self):
from webnotes.utils import flt
for d in getlist(self.doclist, 'target_details'):
if not flt(d.target_qty) and not flt(d.target_amount):
msgprint("Either target qty or target amount is mandatory.")
raise Exception
#self.sync_with_contact()
def sync_with_contact(self):
cid = sql("select name from tabContact where sales_person_id = %s and is_sales_person=1", self.doc.name)
if cid:
d = Document('Contact', cid[0][0])
else:
d = Document('Contact')
name_split = self.doc.sales_person_name.split()
d.contact_name = self.doc.sales_person_name
d.first_name = name_split[0]
d.last_name = len(name_split) > 1 and name_split[1] or ''
d.email_id = self.doc.email_id
d.contact_no = d.mobile_no = self.doc.mobile_no
d.designation = self.doc.designation
d.department = self.doc.department
d.sales_person_id = self.doc.name
d.is_sales_person = 1
d.save(new = (not d.name))
def validate(self):
for d in getlist(self.doclist, 'target_details'):
if not flt(d.target_qty) and not flt(d.target_amount):
msgprint("Either target qty or target amount is mandatory.")
raise Exception
#self.sync_with_contact()
def sync_with_contact(self):
cid = sql("select name from tabContact where sales_person_id = %s and is_sales_person=1", self.doc.name)
if cid:
d = Document('Contact', cid[0][0])
else:
d = Document('Contact')
name_split = self.doc.sales_person_name.split()
d.contact_name = self.doc.sales_person_name
d.first_name = name_split[0]
d.last_name = len(name_split) > 1 and name_split[1] or ''
d.email_id = self.doc.email_id
d.contact_no = d.mobile_no = self.doc.mobile_no
d.designation = self.doc.designation
d.department = self.doc.department
d.sales_person_id = self.doc.name
d.is_sales_person = 1
d.save(new = (not d.name))

View File

@ -13,6 +13,8 @@ sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
from server_tools.gateway_utils import update_client_control, get_total_users
# -----------------------------------------------------------------------------------------
@ -36,10 +38,10 @@ class DocType:
#-----------------------
def set_account_details(self, args):
args = eval(args)
self.set_cp_defaults(args['company_name'], args['industry'], args['time_zone'], args['country'], args['account_name'])
#webnotes.logger.error("args in set_account_details of setup_control: " + str(args))
self.set_cp_defaults(args['company'], args['industry'], args['time_zone'], args['country'], args['account_name'])
self.create_profile(args['user'], args['first_name'], args['last_name'])
self.update_client_control()
update_client_control(args['total_users'])
# Account Setup
@ -163,19 +165,38 @@ class DocType:
d = addchild(pr,'userroles', 'UserRole', 1)
d.role = r
d.save(1)
# Update WN ERP Client Control
# -----------------------------
def update_client_control(self):
cl = Document('WN ERP Client Control','WN ERP Client Control')
cl.account_start_date = nowdate()
cl.total_users = 1
cl.is_trial_account = 1
cl.save()
# Sync DB
# -------
def sync_db(arg=''):
import webnotes.model.db_schema
sql("delete from `tabDocType Update Register`")
webnotes.model.db_schema.sync_all()
webnotes.model.db_schema.sync_all()
def is_setup_okay(self, args):
"""
Validates if setup has been performed after database allocation
"""
args = eval(args)
#webnotes.logger.error("args in set_account_details of setup_control: " + str(args))
cp_defaults = webnotes.conn.get_value('Control Panel', None, 'account_id')
user_profile = webnotes.conn.get_value('Profile', args['user'], 'name')
from webnotes.utils import cint
total_users = get_total_users()
#webnotes.logger.error("setup_control.is_setup_okay: " + cp_defaults + " " + user_profile + " " + str(total_users))
#webnotes.logger.error("setup_control.is_setup_okay: Passed Values:" + args['account_name'] + " " + args['user'] + " " + str(args['total_users']))
if (cp_defaults==args['account_name']) and user_profile and \
(total_users==cint(args['total_users'])):
return 'True'

View File

@ -127,15 +127,18 @@ class DocType:
# update mar
# -----------
def update_mar(self, d, qty_diff):
"""
update item valuation in previous date and also on post date if no qty diff
"""
self.update_item_valuation_pre_date(d)
if not flt(d[self.label['qty']]) and not flt(d[self.label['actual_qty']]):
# seems like a special condition when there is no actual quanitity but there is a rate, may be only for setting a rate!
# seems like a special condition when there is no actual quanitity but there is a rate, may be only for setting a rate!
self.make_sl_entry(1,d,1)
self.make_sl_entry(1,d,-1)
else:
self.update_item_valuation_pre_date(d)
if not qty_diff:
self.update_item_valuation_post_date(d)
elif not qty_diff:
self.update_item_valuation_post_date(d)
# update valuation rate as csv file in all sle before reconciliation date
# ------------------------------------------------------------------------

View File

@ -54,7 +54,8 @@ class SupportMailbox(POP3Mailbox):
d.save(1)
# update feed
update_feed(d)
update_feed(d)
def get_support_mails():
"""

View File

@ -33,8 +33,14 @@ $.extend(cur_frm.cscript, {
refresh: function(doc) {
cs.make_listing(doc);
if(!doc.__islocal) {
// can't change the main message & subject once set
if(!doc.__islocal) {
if(doc.allocated_to)
set_field_permlevel('status',2);
if(user==doc.allocated_to && doc.status!='Closed') cur_frm.add_custom_button('Close Ticket', cs['Close Ticket']);
if(doc.status=='Closed') cur_frm.add_custom_button('Re-Open Ticket', cs['Re-Open Ticket']);
// can't change the main message & subject once set
set_field_permlevel('subject',2);
set_field_permlevel('description',2);
set_field_permlevel('raised_by',2);
@ -87,10 +93,37 @@ $.extend(cur_frm.cscript, {
}
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
if(doc.customer) unhide_field(['customer_name','address_display','contact_display','contact_mobile','contact_email']);
},
'Close Ticket': function() {
var doc = cur_frm.doc
var answer = confirm("Close Ticket "+doc.name+"?\n\nAllocated To: "+doc.allocated_to+"\n\nSubject: "+doc.subject+"");
if(answer) {
if(doc.name)
$c_obj([doc],'close_ticket','',function(r,rt) {
cur_frm.refresh();
});
}
},
'Re-Open Ticket': function() {
var doc = cur_frm.doc
var answer = confirm("Re-Open Ticket "+doc.name+"?\n\nAllocated To: "+doc.allocated_to+"\n\nSubject: "+doc.subject+"");
if(answer) {
if(doc.name)
$c_obj([doc],'reopen_ticket','',function(r,rt) {
cur_frm.refresh();
});
}
}
})
EmailMessage = function(parent, args, list, idx) {
var me = this;
$.extend(this, args);

View File

@ -1,6 +1,7 @@
import webnotes
from utilities.transaction_base import TransactionBase
from home import update_feed
class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
@ -46,3 +47,11 @@ class DocType(TransactionBase):
d.mail = response
d.content_type = content_type
d.save(1)
def close_ticket(self):
webnotes.conn.set(self.doc,'status','Closed')
update_feed(self.doc)
def reopen_ticket(self):
webnotes.conn.set(self.doc,'status','Open')
update_feed(self.doc)

File diff suppressed because it is too large Load Diff

View File

@ -48,16 +48,16 @@ class DocType:
act_qty = act_qty and flt(act_qty[0][0]) or 0
# get indented_qty
ind_qty = sql("select sum(if( ifnull(t2.qty, 0) > ifnull(t2.ordered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.ordered_qty, 0), 0) ) from `tabIndent` t1, `tabIndent Detail`t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s'" % (wh, item))
ind_qty = sql("select sum(if( ifnull(t2.qty, 0) > ifnull(t2.ordered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.ordered_qty, 0), 0) ) from `tabIndent` t1, `tabIndent Detail`t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s' and status != 'Stopped'" % (wh, item))
ind_qty = ind_qty and flt(ind_qty[0][0]) or 0
# get ordered_qty
ord_qty = sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.received_qty, 0), (ifnull(t2.qty, 0) - ifnull(t2.received_qty, 0)) * ifnull(t2.conversion_factor, 0) , 0) ) from `tabPurchase Order` t1, `tabPO Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s'" % (wh, item))
ord_qty = sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.received_qty, 0), (ifnull(t2.qty, 0) - ifnull(t2.received_qty, 0)) * ifnull(t2.conversion_factor, 0) , 0) ) from `tabPurchase Order` t1, `tabPO Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s' and status != 'Stopped'" % (wh, item))
ord_qty = ord_qty and flt(ord_qty[0][0]) or 0
# get reserved_qty
res_qty =sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.delivered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.delivered_qty, 0) , 0) ) from `tabSales Order` t1, `tabSales Order Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.reserved_warehouse = '%s' and t2.item_code = '%s' " % (wh, item))
res_qty =sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.delivered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.delivered_qty, 0) , 0) ) from `tabSales Order` t1, `tabSales Order Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.reserved_warehouse = '%s' and t2.item_code = '%s' and status != 'Stopped'" % (wh, item))
res_qty = res_qty and flt(res_qty[0][0]) or 0
# get planned_qty