Merge branch 'master' into edge

This commit is contained in:
Anand Doshi 2013-04-19 11:43:16 +05:30
commit 90dad5c5b5
20 changed files with 187 additions and 201 deletions

View File

@ -35,8 +35,9 @@ class DocType:
self.check_credit_limit()
self.check_pl_account()
def on_update(self,adv_adj, cancel, update_outstanding = 'Yes'):
def on_update(self, adv_adj, cancel, update_outstanding = 'Yes'):
self.validate_account_details(adv_adj)
self.validate_cost_center()
self.check_freezing_date(adv_adj)
self.check_negative_balance(adv_adj)
@ -97,21 +98,36 @@ class DocType:
from tabAccount where name=%s""", self.doc.account, as_dict=1)
if ret and ret[0]["group_or_ledger"]=='Group':
msgprint(_("Account: ") + self.doc.account + _(" is not a ledger"), raise_exception=1)
msgprint(_("Account") + ": " + self.doc.account + _(" is not a ledger"), raise_exception=1)
if ret and ret[0]["docstatus"]==2:
msgprint(_("Account: ") + self.doc.account + _(" is not active"), raise_exception=1)
msgprint(_("Account") + ": " + self.doc.account + _(" is not active"), raise_exception=1)
# Account has been freezed for other users except account manager
if ret and ret[0]["freeze_account"]== 'Yes' and not adv_adj \
and not 'Accounts Manager' in webnotes.user.get_roles():
msgprint(_("Account: ") + self.doc.account + _(" has been freezed. \
msgprint(_("Account") + ": " + self.doc.account + _(" has been freezed. \
Only Accounts Manager can do transaction against this account"), raise_exception=1)
if ret and ret[0]["company"] != self.doc.company:
msgprint(_("Account: ") + self.doc.account + _(" does not belong to the company: ") +
self.doc.company, raise_exception=1)
msgprint(_("Account") + ": " + self.doc.account + _(" does not belong to the company") \
+ ": " + self.doc.company, raise_exception=1)
def validate_cost_center(self):
if not hasattr(self, "cost_center_company"):
self.cost_center_company = {}
def _get_cost_center_company():
if not self.cost_center_company.get(self.doc.cost_center):
self.cost_center_company[self.doc.cost_center] = webnotes.conn.get_value("Cost Center",
self.doc.cost_center, "company_name")
return self.cost_center_company[self.doc.cost_center]
if self.doc.cost_center and _get_cost_center_company() != self.doc.company:
msgprint(_("Cost Center") + ": " + self.doc.cost_center \
+ _(" does not belong to the company") + ": " + self.doc.company, raise_exception=True)
def check_freezing_date(self, adv_adj):
"""
Nobody can do GL Entries where posting date is before freezing date

View File

@ -2,7 +2,7 @@
{
"creation": "2013-02-22 01:27:39",
"docstatus": 0,
"modified": "2013-03-07 07:03:23",
"modified": "2013-04-17 14:05:18",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -58,6 +58,7 @@
"options": "Company:company:default_currency"
},
{
"default": ":Company",
"doctype": "DocField",
"fieldname": "cost_center",
"fieldtype": "Link",

View File

@ -1,68 +1,68 @@
[
{
"owner": "harshada@webnotestech.com",
"creation": "2012-12-04 17:49:20",
"docstatus": 0,
"creation": "2012-07-03 13:30:49",
"modified": "2013-04-19 10:59:05",
"modified_by": "Administrator",
"modified": "2012-12-04 16:33:37"
"owner": "harshada@webnotestech.com"
},
{
"name": "__common__",
"allow_rename": 1,
"autoname": "field:mode_of_payment",
"module": "Accounts",
"doctype": "DocType",
"document_type": "Master"
"document_type": "Master",
"module": "Accounts",
"name": "__common__"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Mode of Payment",
"doctype": "DocField",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0,
"parentfield": "fields"
"read_only": 0
},
{
"parent": "Mode of Payment",
"read": 1,
"doctype": "DocPerm",
"cancel": 1,
"name": "__common__",
"amend": 0,
"create": 1,
"submit": 0,
"write": 1,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Mode of Payment",
"parentfield": "permissions",
"parenttype": "DocType",
"role": "Accounts Manager",
"report": 1,
"permlevel": 0,
"parentfield": "permissions"
"read": 1,
"report": 1,
"role": "Accounts Manager",
"submit": 0,
"write": 1
},
{
"name": "Mode of Payment",
"doctype": "DocType"
"doctype": "DocType",
"name": "Mode of Payment"
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Mode of Payment",
"oldfieldname": "mode_of_payment",
"fieldname": "mode_of_payment",
"fieldtype": "Data",
"label": "Mode of Payment",
"oldfieldname": "mode_of_payment",
"oldfieldtype": "Data",
"reqd": 1
},
{
"doctype": "DocField",
"label": "Company",
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company"
},
{
"description": "Default Bank / Cash account will be automatically updated in POS Invoice when this mode is selected.",
"doctype": "DocField",
"label": "Default Account",
"fieldname": "default_account",
"fieldtype": "Link",
"label": "Default Account",
"options": "Account"
},
{

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-07 11:42:55",
"creation": "2013-04-10 08:35:38",
"docstatus": 0,
"modified": "2013-03-29 13:44:37",
"modified": "2013-04-17 14:05:20",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -170,6 +170,7 @@
"width": "120px"
},
{
"default": ":Company",
"doctype": "DocField",
"fieldname": "cost_center",
"fieldtype": "Link",

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-08 15:36:47",
"creation": "2013-03-26 06:51:12",
"docstatus": 0,
"modified": "2013-03-22 16:45:28",
"modified": "2013-04-17 14:05:19",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -58,6 +58,7 @@
"reqd": 1
},
{
"default": ":Company",
"doctype": "DocField",
"fieldname": "cost_center",
"fieldtype": "Link",

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-29 18:21:58",
"creation": "2013-04-10 08:35:44",
"docstatus": 0,
"modified": "2013-03-29 19:32:32",
"modified": "2013-04-17 14:05:20",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -219,6 +219,7 @@
"width": "120px"
},
{
"default": ":Company",
"doctype": "DocField",
"fieldname": "cost_center",
"fieldtype": "Link",

View File

@ -2,7 +2,7 @@
{
"creation": "2013-02-22 01:27:41",
"docstatus": 0,
"modified": "2013-03-07 07:03:31",
"modified": "2013-04-17 14:05:18",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -48,6 +48,7 @@
"search_index": 1
},
{
"default": ":Company",
"doctype": "DocField",
"fieldname": "cost_center_other_charges",
"fieldtype": "Link",

View File

@ -41,6 +41,11 @@
<li>dateutil
<li>termcolor
<li>python-memcached
<li>requests
<li>chardet
<li>pygeoip
<li>dropbox
<li>google-api-python-client
</ul>
</td>
</tr>
@ -100,7 +105,12 @@
<tr>
<td><a href="https://github.com/dcneiner/Downloadify">Downloadify - Flash Download Widget</a></td>
<td>A tiny javascript + Flash library that enables the creation and download of text files without server interaction.</td>
</tr>
</tr>
<tr>
<td><a href="http://dev.maxmind.com/geoip/geolite">GeoLite data by MaxMind</a></td>
<td>GeoLite data created by MaxMind, available from
<a href="https://www.maxmind.com">https://www.maxmind.com</a></td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,10 @@
import webnotes
def execute():
for dt, fieldname in \
(("Journal Voucher Detail", "cost_center"),
("Sales Taxes and Charges", "cost_center_other_charges"),
("Purchase Taxes and Charges", "cost_center"), ("Delivery Note Item", "cost_center"),
("Purchase Invoice Item", "cost_center"), ("Sales Invoice Item", "cost_center")):
webnotes.conn.sql_ddl("""alter table `tab%s` alter `%s` drop default""" % (dt, fieldname))
webnotes.reload_doc(webnotes.conn.get_value("DocType", dt, "module"), "DocType", dt)

View File

@ -231,7 +231,6 @@ patch_list = [
"patches.march_2013.p12_set_item_tax_rate_in_json",
"patches.march_2013.p07_update_valuation_rate",
"patches.march_2013.p08_create_aii_accounts",
# "patches.march_2013.p03_update_buying_amount",
"patches.april_2013.p01_update_serial_no_valuation_rate",
"patches.april_2013.p02_add_country_and_currency",
"patches.april_2013.p03_fixes_for_lead_in_quotation",
@ -244,5 +243,6 @@ patch_list = [
"patches.april_2013.p05_update_file_data",
"patches.april_2013.p06_update_file_size",
"patches.april_2013.p05_fixes_in_reverse_modules",
"execute:webnotes.reload_doc('stock', 'DocType Mapper', 'Delivery Note-Packing Slip')"
"execute:webnotes.delete_doc('DocType Mapper', 'Delivery Note-Packing Slip')",
"patches.april_2013.p06_default_cost_center",
]

View File

@ -245,6 +245,9 @@ class DocType:
for cc in cc_list:
add_cc(cc)
webnotes.conn.set_value("Company", self.doc.name, "cost_center",
"Default CC Ledger - " + self.doc.abbr)
def on_update(self):
self.set_letter_head()

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-26 11:03:08",
"creation": "2013-04-10 08:35:39",
"docstatus": 0,
"modified": "2013-03-28 16:04:27",
"modified": "2013-04-17 14:07:46",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -141,6 +141,15 @@
"options": "Account",
"read_only": 0
},
{
"depends_on": "eval:!doc.__islocal",
"doctype": "DocField",
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Cost Center",
"no_copy": 1,
"options": "Cost Center"
},
{
"doctype": "DocField",
"fieldname": "column_break0",

View File

@ -36,7 +36,8 @@ def boot_session(bootinfo):
for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
if hasattr(conf, key): bootinfo[key] = getattr(conf, key)
bootinfo['docs'] += webnotes.conn.sql("select name, default_currency from `tabCompany`",
bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center,
cost_center as 'cost_center_other_charges' from `tabCompany`""",
as_dict=1, update={"doctype":":Company"})
def get_letter_heads():

View File

@ -158,7 +158,6 @@ cur_frm.fields_dict['sales_order_no'].get_query = function(doc) {
}
// ****************************** DELIVERY TYPE ************************************
cur_frm.cscript.delivery_type = function(doc, cdt, cdn) {
if (doc.delivery_type = 'Sample') cfn_set_fields(doc, cdt, cdn);
}
@ -185,7 +184,6 @@ cur_frm.fields_dict['transporter_name'].get_query = function(doc) {
return 'SELECT DISTINCT `tabSupplier`.`name` FROM `tabSupplier` WHERE `tabSupplier`.supplier_type = "transporter" AND `tabSupplier`.docstatus != 2 AND `tabSupplier`.%(key)s LIKE "%s" ORDER BY `tabSupplier`.`name` LIMIT 50';
}
//-----------------------------------Make Sales Invoice----------------------------------------------
cur_frm.cscript['Make Sales Invoice'] = function() {
var doc = cur_frm.doc
n = wn.model.make_new_doc_and_get_name('Sales Invoice');
@ -201,7 +199,6 @@ cur_frm.cscript['Make Sales Invoice'] = function() {
);
}
//-----------------------------------Make Installation Note----------------------------------------------
cur_frm.cscript['Make Installation Note'] = function() {
var doc = cur_frm.doc;
if(doc.per_installed < 99.99){
@ -221,31 +218,19 @@ cur_frm.cscript['Make Installation Note'] = function() {
msgprint("Item installation is already completed")
}
//-----------------------------------Make Sales Invoice----------------------------------------------
cur_frm.cscript['Make Packing Slip'] = function() {
var doc = cur_frm.doc
n = wn.model.make_new_doc_and_get_name('Packing Slip');
$c('dt_map', args={
'docs':wn.model.compress([locals['Packing Slip'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Packing Slip',
'from_docname':doc.name,
'from_to_list':"[['Delivery Note','Packing Slip'],['Delivery Note Item','Packing Slip Item']]"
}, function(r,rt) {
loaddoc('Packing Slip', n);
}
);
ps = locals["Packing Slip"][n];
ps.delivery_note = cur_frm.doc.name;
loaddoc('Packing Slip', n);
}
//get query select Territory
//=======================================================================================================================
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
}
//------------------------for printing without amount----------
var set_print_hide= function(doc, cdt, cdn){
var dn_fields = wn.meta.docfield_map['Delivery Note'];
var dn_item_fields = wn.meta.docfield_map['Delivery Note Item'];

View File

@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import cstr, flt, getdate, cint
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
from webnotes import msgprint, _
import webnotes.defaults
@ -333,17 +333,15 @@ class DocType(SellingController):
"""
Cancel submitted packing slips related to this delivery note
"""
res = webnotes.conn.sql("""\
SELECT name, count(*) FROM `tabPacking Slip`
WHERE delivery_note = %s AND docstatus = 1
""", self.doc.name)
res = webnotes.conn.sql("""SELECT name FROM `tabPacking Slip` WHERE delivery_note = %s
AND docstatus = 1""", self.doc.name)
if res and res[0][1]>0:
if res:
from webnotes.model.bean import Bean
for r in res:
ps = Bean(dt='Packing Slip', dn=r[0])
ps.cancel()
webnotes.msgprint("%s Packing Slip(s) Cancelled" % res[0][1])
webnotes.msgprint(_("Packing Slip(s) Cancelled"))
def update_stock_ledger(self, update_stock):
@ -421,4 +419,4 @@ class DocType(SellingController):
if gl_entries:
from accounts.general_ledger import make_gl_entries
make_gl_entries(gl_entries)
make_gl_entries(gl_entries)

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-26 11:03:09",
"creation": "2013-04-01 10:49:21",
"docstatus": 0,
"modified": "2013-03-28 15:42:41",
"modified": "2013-04-17 17:20:58",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -257,6 +257,7 @@
"width": "120px"
},
{
"default": ":Company",
"doctype": "DocField",
"fieldname": "cost_center",
"fieldtype": "Link",
@ -332,17 +333,6 @@
"read_only": 1,
"width": "150px"
},
{
"allow_on_submit": 1,
"default": "0",
"doctype": "DocField",
"fieldname": "packed_qty",
"fieldtype": "Float",
"label": "Packed Quantity",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "prevdoc_doctype",

View File

@ -23,52 +23,36 @@ cur_frm.fields_dict['item_details'].grid.get_field('item_code').get_query =
function(doc, cdt, cdn) {
var query = 'SELECT name, item_name, description FROM `tabItem` WHERE name IN ( \
SELECT item_code FROM `tabDelivery Note Item` dnd \
WHERE parent="' + doc.delivery_note + '" AND IFNULL(qty, 0) > IFNULL(packed_qty, 0)) AND %(key)s LIKE "%s" LIMIT 50';
WHERE parent="' + doc.delivery_note + '" AND IFNULL(qty, 0) > IFNULL(packed_qty, 0)) \
AND %(key)s LIKE "%s" LIMIT 50';
return query;
}
// Fetch item details
cur_frm.add_fetch("item_code", "item_name", "item_name");
cur_frm.add_fetch("item_code", "stock_uom", "stock_uom");
cur_frm.add_fetch("item_code", "net_weight", "net_weight");
cur_frm.add_fetch("item_code", "weight_uom", "weight_uom");
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
if(doc.delivery_note && doc.__islocal) {
var ps_detail = getchildren('Packing Slip Item', doc.name, 'item_details');
if(!(flt(ps_detail.net_weight) && cstr(ps_detail.weight_uom))) {
cur_frm.cscript.update_item_details(doc);
}
cur_frm.cscript.get_items(doc, cdt, cdn);
}
}
cur_frm.cscript.refresh = function(doc, dt, dn) {
if(!doc.amended_from) {
hide_field('misc_details');
} else {
unhide_field('misc_details');
}
}
cur_frm.cscript.update_item_details = function(doc) {
$c_obj(make_doclist(doc.doctype, doc.name), 'update_item_details', '', function(r, rt) {
if(r.exc) {
msgprint(r.exc);
} else {
refresh_many(['item_details', 'naming_series', 'from_case_no', 'to_case_no'])
cur_frm.cscript.get_items = function(doc, cdt, cdn) {
this.frm.call({
doc: this.frm.doc,
method: "get_items",
callback: function(r) {
if(!r.exc) cur_frm.refresh();
}
});
}
cur_frm.cscript.refresh = function(doc, dt, dn) {
cur_frm.toggle_display("misc_details", doc.amended_from);
}
cur_frm.cscript.validate = function(doc, cdt, cdn) {
cur_frm.cscript.validate_case_nos(doc);
cur_frm.cscript.validate_calculate_item_details(doc);
}
// To Case No. cannot be less than From Case No.
cur_frm.cscript.validate_case_nos = function(doc) {
doc = locals[doc.doctype][doc.name];
@ -99,7 +83,7 @@ cur_frm.cscript.validate_calculate_item_details = function(doc) {
cur_frm.cscript.validate_duplicate_items = function(doc, ps_detail) {
for(var i=0; i<ps_detail.length; i++) {
for(var j=0; j<ps_detail.length; j++) {
if(i!=j && ps_detail[i].dn_detail && ps_detail[i].dn_detail==ps_detail[j].dn_detail) {
if(i!=j && ps_detail[i].item_code && ps_detail[i].item_code==ps_detail[j].item_code) {
msgprint("You have entered duplicate items. Please rectify and try again.");
validated = false;
return;

View File

@ -16,13 +16,14 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt, cint, now
from webnotes.utils import flt, cint
from webnotes import msgprint, _
from webnotes.model.doc import addchild
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self):
"""
* Validate existence of submitted Delivery Note
@ -32,48 +33,48 @@ class DocType:
It is necessary to validate case nos before checking quantity
"""
self.validate_delivery_note()
self.validate_items_mandatory()
self.validate_case_nos()
self.validate_qty()
def validate_delivery_note(self):
"""
Validates if delivery note has status as submitted
Validates if delivery note has status as draft
"""
res = webnotes.conn.sql("""SELECT docstatus FROM `tabDelivery Note`
WHERE name=%(delivery_note)s""", self.doc.fields)
if not(res and res[0][0]==0):
webnotes.msgprint("""Invalid Delivery Note. Delivery Note should exist
and should be in draft state. Please rectify and try again.""", raise_exception=1)
if cint(webnotes.conn.get_value("Delivery Note", self.doc.delivery_note, "docstatus")) != 0:
msgprint(_("""Invalid Delivery Note. Delivery Note should exist and should be in
draft state. Please rectify and try again."""), raise_exception=1)
def validate_items_mandatory(self):
rows = [d.item_code for d in self.doclist.get({"parentfield": "item_details"})]
if not rows:
webnotes.msgprint(_("No Items to Pack"), raise_exception=1)
def validate_case_nos(self):
"""
Validate if case nos overlap
If they do, recommend next case no.
Validate if case nos overlap. If they do, recommend next case no.
"""
if not cint(self.doc.from_case_no):
webnotes.msgprint("Please specify a valid 'From Case No.'", raise_exception=1)
webnotes.msgprint(_("Please specify a valid 'From Case No.'"), raise_exception=1)
elif not self.doc.to_case_no:
self.doc.to_case_no = self.doc.from_case_no
elif self.doc.from_case_no > self.doc.to_case_no:
webnotes.msgprint("'To Case No.' cannot be less than 'From Case No.'",
webnotes.msgprint(_("'To Case No.' cannot be less than 'From Case No.'"),
raise_exception=1)
res = webnotes.conn.sql("""SELECT name FROM `tabPacking Slip`
WHERE delivery_note = %(delivery_note)s AND docstatus = 1 AND
(from_case_no BETWEEN %(from_case_no)s AND %(to_case_no)s
OR to_case_no BETWEEN %(from_case_no)s AND %(to_case_no)s)
OR to_case_no BETWEEN %(from_case_no)s AND %(to_case_no)s
OR %(from_case_no)s BETWEEN from_case_no AND to_case_no)
""", self.doc.fields)
if res:
webnotes.msgprint("""Case No(s). already in use. Please rectify and try again.
Recommended <b>From Case No. = %s</b>""" % self.get_recommended_case_no(),
webnotes.msgprint(_("""Case No(s) already in use. Please rectify and try again.
Recommended <b>From Case No. = %s</b>""") % self.get_recommended_case_no(),
raise_exception=1)
def validate_qty(self):
"""
Check packed qty across packing slips and delivery note
@ -82,8 +83,9 @@ class DocType:
dn_details, ps_item_qty, no_of_cases = self.get_details_for_packing()
for item in dn_details:
new_packed_qty = (flt(ps_item_qty[item['item_code']]) * no_of_cases) + flt(item['packed_qty'])
if new_packed_qty > flt(item['qty']):
new_packed_qty = (flt(ps_item_qty[item['item_code']]) * no_of_cases) + \
flt(item['packed_qty'])
if new_packed_qty > flt(item['qty']) and no_of_cases:
self.recommend_new_qty(item, ps_item_qty, no_of_cases)
@ -95,26 +97,25 @@ class DocType:
* No. of Cases of this packing slip
"""
items = [d.item_code for d in self.doclist.get({"parentfield": "item_details"})]
rows = [d.item_code for d in self.doclist.get({"parentfield": "item_details"})]
if not items: webnotes.msgprint("No Items to Pack",
raise_exception=1)
condition = ""
if rows:
condition = " and item_code in (%s)" % (", ".join(["%s"]*len(rows)))
# gets item code, qty per item code, latest packed qty per item code and stock uom
res = webnotes.conn.sql("""select item_code, ifnull(sum(qty), 0) as qty,
(select sum(ifnull(psi.qty, 0) * (abs(ps.to_case_no - ps.from_case_no) + 1))
from `tabPacking Slip` ps, `tabPacking Slip Item` psi
where ps.name = psi.parent and ps.docstatus = 1
and ps.delivery_note = dni.parent and psi.item_code=dni.item_code)
as packed_qty,
stock_uom
and ps.delivery_note = dni.parent and psi.item_code=dni.item_code) as packed_qty,
stock_uom, item_name
from `tabDelivery Note Item` dni
where parent=%s and item_code in (%s)
group by item_code""" % ("%s", ", ".join(["%s"]*len(items))),
tuple([self.doc.delivery_note] + items), as_dict=1)
ps_item_qty = dict([[d.item_code, d.qty] for d in self.doclist])
where parent=%s %s
group by item_code""" % ("%s", condition),
tuple([self.doc.delivery_note] + rows), as_dict=1)
ps_item_qty = dict([[d.item_code, d.qty] for d in self.doclist])
no_of_cases = cint(self.doc.to_case_no) - cint(self.doc.from_case_no) + 1
return res, ps_item_qty, no_of_cases
@ -134,45 +135,6 @@ class DocType:
<b>Recommended quantity for %(item_code)s = %(recommended_qty)s
%(stock_uom)s</b>""" % item, raise_exception=1)
def on_submit(self):
"""
* Update packed qty for all items
"""
self.update_packed_qty(event='submit')
def on_cancel(self):
"""
* Update packed qty for all items
"""
self.update_packed_qty(event='cancel')
def update_packed_qty(self, event=''):
"""
Updates packed qty for all items
"""
if event not in ['submit', 'cancel']:
raise Exception('update_packed_quantity can only be called on submit or cancel')
# Get Delivery Note Items, Item Quantity Dict and No. of Cases for this Packing slip
dn_details, ps_item_qty, no_of_cases = self.get_details_for_packing()
for item in dn_details:
new_packed_qty = flt(item['packed_qty'])
if (new_packed_qty < 0) or (new_packed_qty > flt(item['qty'])):
webnotes.msgprint("""Invalid new packed quantity for item %s.
Please try again or contact support@erpnext.com""" %
item['item_code'], raise_exception=1)
webnotes.conn.sql("""UPDATE `tabDelivery Note Item`
SET packed_qty = %s WHERE parent = %s AND item_code = %s""",
(new_packed_qty, self.doc.delivery_note, item['item_code']))
webnotes.conn.set_value("Delivery Note", self.doc.delivery_note, "modified", now())
def update_item_details(self):
"""
Fill empty columns in Packing Slip Item
@ -181,17 +143,12 @@ class DocType:
self.doc.from_case_no = self.get_recommended_case_no()
for d in self.doclist.get({"parentfield": "item_details"}):
self.set_item_details(d)
def set_item_details(self, row):
res = webnotes.conn.sql("""SELECT net_weight, weight_uom FROM `tabItem`
WHERE name=%s""", row.item_code, as_dict=1)
res = webnotes.conn.get_value("Item", d.item_code,
["net_weight", "weight_uom"], as_dict=True)
if res and len(res)>0:
row.net_weight = res[0]["net_weight"]
row.weight_uom = res[0]["weight_uom"]
if res and len(res)>0:
d.net_weight = res["net_weight"]
d.weight_uom = res["weight_uom"]
def get_recommended_case_no(self):
"""
@ -200,5 +157,18 @@ class DocType:
"""
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
return cint(recommended_case_no[0][0]) + 1
def get_items(self):
self.doclist = self.doc.clear_table(self.doclist, "item_details", 1)
dn_details = self.get_details_for_packing()[0]
for item in dn_details:
if flt(item.qty) > flt(item.packed_qty):
ch = addchild(self.doc, 'item_details', 'Packing Slip Item', self.doclist)
ch.item_code = item.item_code
ch.item_name = item.item_name
ch.stock_uom = item.stock_uom
ch.qty = flt(item.qty) - flt(item.packed_qty)
self.update_item_details()

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-07 18:50:31",
"creation": "2013-04-11 15:32:24",
"docstatus": 0,
"modified": "2013-04-05 15:40:59",
"modified": "2013-04-16 17:33:38",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -130,6 +130,12 @@
"label": "Package Item Details",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "get_items",
"fieldtype": "Button",
"label": "Get Items"
},
{
"doctype": "DocField",
"fieldname": "item_details",

View File

@ -84,7 +84,6 @@ class DocType:
item_details = webnotes.conn.sql("""select item_group, warranty_period
from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or
end_of_life = '0000-00-00' or end_of_life > now()) """ %(d.item_code), as_dict=1)
webnotes.errprint([d.item_code, d.valuation_rate])
s.purchase_document_type = obj.doc.doctype
s.purchase_document_no = obj.doc.name