mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-09 08:02:51 +00:00
fixed conflict while merging
This commit is contained in:
@@ -66,7 +66,7 @@ def make_feed(feedtype, doctype, name, owner, subject, color):
|
||||
|
||||
def update_feed(doc, method=None):
|
||||
"adds a new feed"
|
||||
if method=='on_update':
|
||||
if method in ['on_update', 'on_submit']:
|
||||
subject, color = feed_dict.get(doc.doctype, [None, None])
|
||||
if subject:
|
||||
make_feed('', doc.doctype, doc.name, doc.owner, subject % doc.fields, color)
|
||||
|
||||
20
erpnext/patches/jan_mar_2012/fix_packing_slip.py
Normal file
20
erpnext/patches/jan_mar_2012/fix_packing_slip.py
Normal file
@@ -0,0 +1,20 @@
|
||||
def execute():
|
||||
"""
|
||||
* Change DN to PS mapper
|
||||
+ Set Ref doc should be submitted to 0
|
||||
+ Set validation logic of DN PS Table mapper record to docstatus=0
|
||||
"""
|
||||
import webnotes
|
||||
webnotes.conn.sql("""\
|
||||
UPDATE `tabDocType Mapper`
|
||||
SET ref_doc_submitted=0
|
||||
WHERE name='Delivery Note-Packing Slip'""")
|
||||
|
||||
webnotes.conn.sql("""\
|
||||
UPDATE `tabTable Mapper Detail`
|
||||
SET validation_logic='docstatus=0'
|
||||
WHERE parent='Delivery Note-Packing Slip'
|
||||
AND docstatus=0
|
||||
AND from_table='Delivery Note'
|
||||
AND to_table='Packing Slip'""")
|
||||
|
||||
@@ -8,6 +8,7 @@ def execute():
|
||||
from webnotes.utils import archive
|
||||
arc_tables = webnotes.conn.sql('show tables like "arc%"')
|
||||
try:
|
||||
webnotes.conn.auto_commit_on_many_writes = 1
|
||||
for tab in arc_tables:
|
||||
tab = tab[0]
|
||||
dt = tab[3:]
|
||||
|
||||
@@ -5,6 +5,7 @@ import patches.jan_mar_2012.website.cleanups
|
||||
import patches.jan_mar_2012.website.domain_list
|
||||
import patches.jan_mar_2012.website.file_data_rename
|
||||
import patches.jan_mar_2012.website.analytics
|
||||
import patches.jan_mar_2012.website.allow_product_delete
|
||||
|
||||
|
||||
def execute():
|
||||
@@ -15,3 +16,4 @@ def execute():
|
||||
patches.jan_mar_2012.website.domain_list.execute()
|
||||
patches.jan_mar_2012.website.file_data_rename.execute()
|
||||
patches.jan_mar_2012.website.analytics.execute()
|
||||
patches.jan_mar_2012.website.allow_product_delete.execute()
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
def execute():
|
||||
"""
|
||||
Allow deletion of products
|
||||
"""
|
||||
import webnotes
|
||||
webnotes.conn.sql("""UPDATE `tabDocPerm` SET cancel=1
|
||||
WHERE parent='Product' AND role='Website Manager'
|
||||
AND permlevel=0""")
|
||||
@@ -23,10 +23,11 @@ def execute():
|
||||
txt = get_file_id(txt)
|
||||
|
||||
webnotes.conn.sql("""update `tab%s` set %s=%s where name=%s""" % \
|
||||
(table[0], table[1], '%s', '%s'), (txt, item[0]), debug=1)
|
||||
(table[0], table[1], '%s', '%s'), (txt, item[0]))
|
||||
|
||||
# control panel, client name
|
||||
txt = webnotes.conn.get_value('Control Panel',None,'client_name')
|
||||
if txt:
|
||||
txt = get_file_id(txt)
|
||||
webnotes.conn.set_value('Control Panel', None, 'client_name', txt.replace('index.cgi?cmd=get_file&fname=', 'files/'))
|
||||
|
||||
@@ -34,6 +35,11 @@ def get_file_id(txt):
|
||||
"""old file links may be from fileid or filename"""
|
||||
import re
|
||||
match = re.search('files/([^"\']*)', txt)
|
||||
|
||||
if not match:
|
||||
print txt
|
||||
return txt
|
||||
|
||||
fname = match.groups()[0]
|
||||
if not fname.startswith('FileData'):
|
||||
fid = webnotes.conn.sql("""select name from `tabFile Data`
|
||||
|
||||
@@ -99,5 +99,10 @@ patch_list = [
|
||||
'patch_module': 'patches.jan_mar_2012',
|
||||
'patch_file': 'reload_item',
|
||||
'description': 'reload item'
|
||||
}
|
||||
},
|
||||
{
|
||||
'patch_module': 'patches.jan_mar_2012',
|
||||
'patch_file': 'fix_packing_slip',
|
||||
'description': 'Update Mapper Delivery Note-Packing Slip'
|
||||
},
|
||||
]
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<div class="layout_wrapper">
|
||||
<div id="pe_header"></div>
|
||||
<div id="perm_engine_div" style="margin: 16px;"></div>
|
||||
<div id="submittable_warning" class='help-box' style='display: None'>
|
||||
One of the Roles has <b>Submit</b> permission.
|
||||
You will have to <b>Cancel</b> and then <b>Amend</b> a submitted Document for making changes.
|
||||
</div>
|
||||
</div>
|
||||
@@ -130,8 +130,11 @@ pscript.PermEngine.prototype.get_permissions = function() {
|
||||
|
||||
$c_obj('Permission Control','get_permissions',sel_val(me.type_select), function(r,rt) {
|
||||
// Get permissions
|
||||
if(r.message.perms.length)me.get_results(r.message);
|
||||
if(r.message.perms.length) {
|
||||
me.get_results(r.message);
|
||||
}
|
||||
else me.body.innerHTML = '<div style = "color : red; margin:8px 0px;">No Records Found</div>'
|
||||
pscript.show_submittable();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -184,6 +187,9 @@ pscript.PermEngine.prototype.get_results = function(r){
|
||||
var val = perms[l][$td(permt,0,m+2).fieldname];
|
||||
if(val == 1) chk.checked = 1;
|
||||
else chk.checked = 0;
|
||||
|
||||
if(m==3) { chk.onclick = pscript.show_submittable }
|
||||
|
||||
chk.doctype = doctype;
|
||||
chk.permlevel = perms[l].permlevel; chk.perm_type = col_labels[m+2].toLowerCase(); chk.role = perms[l].role;
|
||||
pscript.all_checkboxes.push(chk);
|
||||
@@ -194,6 +200,24 @@ pscript.PermEngine.prototype.get_results = function(r){
|
||||
me.add_match_select(r, perms, permt, doctype);
|
||||
}
|
||||
|
||||
// Show submittable warning
|
||||
pscript.show_submittable = function() {
|
||||
var submittable = 0;
|
||||
for(i in pscript.all_checkboxes) {
|
||||
c = pscript.all_checkboxes[i];
|
||||
if(c.perm_type=='submit' && c.checked) {
|
||||
submittable = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(submittable) {
|
||||
$('#submittable_warning').toggle(true);
|
||||
} else {
|
||||
$('#submittable_warning').toggle(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// render selects for match
|
||||
// --------------------------------------------
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ def on_login(login_manager):
|
||||
"""
|
||||
called from login manager, before login
|
||||
"""
|
||||
if login_manager.user not in ('Guest', None, ''):
|
||||
if login_manager.user not in ('Guest', None, '') and webnotes.conn.cur_db_name!='accounts' and webnotes.conn.get_value('Control Panel', 'Control Panel', 'account_id')!='s5u011':
|
||||
try:
|
||||
login_manager = login_as(login_manager)
|
||||
update_account_details()
|
||||
@@ -32,7 +32,7 @@ def on_login_post_session(login_manager):
|
||||
sid!=%s""", \
|
||||
(webnotes.session['user'], webnotes.session['sid']), as_list=1)
|
||||
|
||||
if webnotes.session['user'] not in ('Guest'):
|
||||
if webnotes.session['user'] not in ('Guest') and webnotes.conn.cur_db_name!='accounts':
|
||||
# create feed
|
||||
from webnotes.utils import nowtime
|
||||
home.make_feed('Login', 'Profile', login_manager.user, login_manager.user,
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-02-13 11:28:48',
|
||||
'creation': '2012-02-02 11:50:33',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-02-13 11:28:48',
|
||||
'modified': '2012-02-21 16:11:29',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
@@ -34,7 +34,7 @@
|
||||
'from_doctype': u'Delivery Note',
|
||||
'module': u'Stock',
|
||||
'name': '__common__',
|
||||
'ref_doc_submitted': 1,
|
||||
'ref_doc_submitted': 0,
|
||||
'to_doctype': u'Packing Slip'
|
||||
},
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
'from_table': u'Delivery Note',
|
||||
'match_id': 0,
|
||||
'to_table': u'Packing Slip',
|
||||
'validation_logic': u'docstatus=1'
|
||||
'validation_logic': u'docstatus=0'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
|
||||
@@ -51,7 +51,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
unhide_field(['SMS','Send SMS', 'message', 'customer_mobile_no', 'Repair Delivery Note']);
|
||||
}
|
||||
|
||||
if(doc.docstatus==1) {
|
||||
if(doc.docstatus==0 && !doc.__islocal) {
|
||||
cur_frm.add_custom_button('Make Packing Slip', cur_frm.cscript['Make Packing Slip']);
|
||||
}
|
||||
|
||||
|
||||
@@ -318,6 +318,7 @@ class DocType(TransactionBase):
|
||||
# ON SUBMIT
|
||||
# =================================================================================================
|
||||
def on_submit(self):
|
||||
self.validate_packed_qty()
|
||||
set(self.doc, 'message', 'Items against your Order #%s have been delivered. Delivery #%s: ' % (self.doc.po_no, self.doc.name))
|
||||
self.check_qty_in_stock()
|
||||
# Check for Approving Authority
|
||||
@@ -335,6 +336,28 @@ class DocType(TransactionBase):
|
||||
set(self.doc, 'status', 'Submitted')
|
||||
|
||||
|
||||
def validate_packed_qty(self):
|
||||
"""
|
||||
Validate that if packed qty exists, it should be equal to qty
|
||||
"""
|
||||
if not any([d.fields.get('packed_qty') for d in self.doclist]):
|
||||
return
|
||||
packing_error_list = []
|
||||
for d in self.doclist:
|
||||
if d.doctype != 'Delivery Note Detail': continue
|
||||
if d.fields.get('qty') != d.fields.get('packed_qty'):
|
||||
packing_error_list.append([
|
||||
d.fields.get('item_code', ''),
|
||||
d.fields.get('qty', ''),
|
||||
d.fields.get('packed_qty', '')
|
||||
])
|
||||
if packing_error_list:
|
||||
from webnotes.utils import cstr
|
||||
err_msg = "\n".join([("Item: " + d[0] + ", Qty: " + cstr(d[1]) \
|
||||
+ ", Packed: " + cstr(d[2])) for d in packing_error_list])
|
||||
webnotes.msgprint("Packing Error:\n" + err_msg, raise_exception=1)
|
||||
|
||||
|
||||
# *********** Checks whether actual quantity is present in warehouse *************
|
||||
def check_qty_in_stock(self):
|
||||
for d in getlist(self.doclist, 'packing_details'):
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
cur_frm.fields_dict['delivery_note'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT name FROM `tabDelivery Note` WHERE docstatus=1 AND %(key)s LIKE "%s"';
|
||||
return 'SELECT name FROM `tabDelivery Note` WHERE docstatus=0 AND %(key)s LIKE "%s"';
|
||||
}
|
||||
|
||||
|
||||
cur_frm.fields_dict['item_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT name, description FROM `tabItem` WHERE name IN ( \
|
||||
SELECT item_code FROM `tabDelivery Note Detail` \
|
||||
WHERE parent="' + doc.delivery_note + '") AND %(key)s LIKE "%s" LIMIT 50';
|
||||
SELECT item_code FROM `tabDelivery Note Detail` dnd \
|
||||
WHERE parent="' + doc.delivery_note + '" AND qty > packed_qty) AND %(key)s LIKE "%s" LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@ cur_frm.cscript.update_item_details = function(doc) {
|
||||
if(r.exc) {
|
||||
msgprint(r.exc);
|
||||
} else {
|
||||
refresh_field('item_details');
|
||||
refresh_field('naming_series');
|
||||
refresh_many(['item_details', 'naming_series', 'from_case_no', 'to_case_no'])
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,9 +28,10 @@ class DocType:
|
||||
WHERE name=%(delivery_note)s
|
||||
""", self.doc.fields)
|
||||
|
||||
if not(res and res[0][0]==1):
|
||||
if not(res and res[0][0]==0):
|
||||
webnotes.msgprint("""Invalid Delivery Note. Delivery Note should exist
|
||||
and should be submitted. Please rectify and try again.""", raise_exception=1)
|
||||
and should be in draft state. Please rectify and try again.""",
|
||||
raise_exception=1)
|
||||
|
||||
|
||||
def validate_case_nos(self):
|
||||
@@ -46,12 +47,8 @@ class DocType:
|
||||
""", self.doc.fields)
|
||||
|
||||
if res:
|
||||
recommended_case_no = webnotes.conn.sql("""\
|
||||
SELECT MAX(to_case_no) FROM `tabPacking Slip`
|
||||
WHERE delivery_note = %(delivery_note)s AND docstatus=1""", self.doc.fields)
|
||||
|
||||
webnotes.msgprint("""Case No(s). already in use. Please rectify and try again.
|
||||
Recommended <b>From Case No. = %s</b>""" % (cint(recommended_case_no[0][0]) + 1),
|
||||
Recommended <b>From Case No. = %s</b>""" % self.get_recommended_case_no(),
|
||||
raise_exception=1)
|
||||
|
||||
|
||||
@@ -75,13 +72,18 @@ class DocType:
|
||||
* Item Quantity dict of current packing slip doc
|
||||
* No. of Cases of this packing slip
|
||||
"""
|
||||
item_codes = ", ".join([('"' + d.item_code + '"') for d in self.doclist])
|
||||
item_codes = ", ".join([('"' + d.item_code + '"') for d in
|
||||
self.doclist])
|
||||
|
||||
if not item_codes: webnotes.msgprint("No Items to Pack",
|
||||
raise_exception=1)
|
||||
|
||||
res = webnotes.conn.sql("""\
|
||||
SELECT item_code, IFNULL(SUM(qty), 0) as qty, IFNULL(packed_qty, 0) as packed_qty, stock_uom
|
||||
FROM `tabDelivery Note Detail`
|
||||
WHERE parent = "%s" AND item_code IN (%s)
|
||||
GROUP BY item_code""" % (self.doc.delivery_note, item_codes), as_dict=1)
|
||||
GROUP BY item_code""" % (self.doc.delivery_note, item_codes),
|
||||
as_dict=1)
|
||||
|
||||
ps_item_qty = dict([[d.item_code, d.qty] for d in self.doclist])
|
||||
|
||||
@@ -150,7 +152,23 @@ class DocType:
|
||||
"""
|
||||
Fill empty columns in Packing Slip Detail
|
||||
"""
|
||||
self.doc.from_case_no = self.get_recommended_case_no()
|
||||
|
||||
from webnotes.model.code import get_obj
|
||||
for d in self.doclist:
|
||||
psd_obj = get_obj(doc=d)
|
||||
psd_obj.get_item_details(self.doc.delivery_note)
|
||||
|
||||
|
||||
def get_recommended_case_no(self):
|
||||
"""
|
||||
Returns the next case no. for a new packing slip for a delivery
|
||||
note
|
||||
"""
|
||||
recommended_case_no = webnotes.conn.sql("""\
|
||||
SELECT MAX(to_case_no) FROM `tabPacking Slip`
|
||||
WHERE delivery_note = %(delivery_note)s AND docstatus=1""", self.doc.fields)
|
||||
|
||||
return cint(recommended_case_no[0][0]) + 1
|
||||
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-02-14 11:53:45',
|
||||
'creation': '2012-02-17 15:53:22',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-02-22 18:28:20',
|
||||
'modified': '2012-02-22 18:32:46',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user