[Cleanup] Sales Common deprecated
diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index 6f35f92..19d2716 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -11,7 +11,7 @@
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
-wn.require('app/selling/doctype/sales_common/sales_common.js');
+wn.require('app/selling/sales_common.js');
wn.require('app/accounts/doctype/sales_invoice/pos.js');
wn.provide("erpnext.accounts");
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index b6548c0..cdae74e 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -48,11 +48,7 @@
self.validate_proj_cust()
self.validate_with_previous_doc()
self.validate_uom_is_integer("stock_uom", "qty")
-
- sales_com_obj = get_obj('Sales Common')
- sales_com_obj.check_stop_sales_order(self)
- sales_com_obj.check_active_sales_items(self)
- sales_com_obj.validate_max_discount(self, 'entries')
+ self.check_stop_sales_order("sales_order")
self.validate_customer_account()
self.validate_debit_acc()
self.validate_fixed_asset_account()
@@ -110,8 +106,7 @@
if cint(self.doc.update_stock) == 1:
self.update_stock_ledger()
- sales_com_obj = get_obj(dt = 'Sales Common')
- sales_com_obj.check_stop_sales_order(self)
+ self.check_stop_sales_order("sales_order")
from accounts.utils import remove_against_link_from_jv
remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_invoice")
@@ -255,19 +250,7 @@
else:
due_date = self.doc.posting_date
- return due_date
-
- def get_barcode_details(self, barcode):
- return get_obj('Sales Common').get_barcode_details(barcode)
-
-
- def get_adj_percent(self, arg=''):
- """Fetch ref rate from item master as per selected price list"""
- get_obj('Sales Common').get_adj_percent(self)
-
- def get_comm_rate(self, sales_partner):
- """Get Commission rate of Sales Partner"""
- return get_obj('Sales Common').get_comm_rate(sales_partner, self)
+ return due_date
def get_advances(self):
super(DocType, self).get_advances(self.doc.debit_to,
@@ -470,10 +453,6 @@
w = ps[0][1]
return w
-
- def make_packing_list(self):
- get_obj('Sales Common').make_packing_list(self,'entries')
-
def on_update(self):
if cint(self.doc.update_stock) == 1:
# Set default warehouse from pos setting
@@ -484,7 +463,8 @@
if not d.warehouse:
d.warehouse = cstr(w)
- self.make_packing_list()
+ from stock.doctype.packed_item.packed_item import make_packing_list
+ make_packing_list(self, 'entries')
else:
self.doclist = self.doc.clear_table(self.doclist, 'packing_details')
@@ -516,8 +496,7 @@
def update_stock_ledger(self):
sl_entries = []
- items = get_obj('Sales Common').get_item_list(self)
- for d in items:
+ for d in self.get_item_list():
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes" \
and d.warehouse:
sl_entries.append(self.get_sl_entries(d, {
@@ -860,7 +839,6 @@
def notify_errors(inv, owner):
import webnotes
- import website
exception_msg = """
Dear User,
diff --git a/controllers/queries.py b/controllers/queries.py
index 637d5e1..ed44f9b 100644
--- a/controllers/queries.py
+++ b/controllers/queries.py
@@ -174,4 +174,36 @@
"fcond": get_filters_cond(doctype, filters, []),
"mcond": get_match_cond(doctype),
"start": "%(start)s", "page_len": "%(page_len)s", "txt": "%(txt)s"
- }, { "start": start, "page_len": page_len, "txt": ("%%%s%%" % txt) })
\ No newline at end of file
+ }, { "start": start, "page_len": page_len, "txt": ("%%%s%%" % txt) })
+
+def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
+ from controllers.queries import get_match_cond
+
+ if filters.has_key('warehouse'):
+ return webnotes.conn.sql("""select batch_no from `tabStock Ledger Entry` sle
+ where item_code = '%(item_code)s'
+ and warehouse = '%(warehouse)s'
+ and batch_no like '%(txt)s'
+ and exists(select * from `tabBatch`
+ where name = sle.batch_no
+ and (ifnull(expiry_date, '')='' or expiry_date >= '%(posting_date)s')
+ and docstatus != 2)
+ %(mcond)s
+ group by batch_no having sum(actual_qty) > 0
+ order by batch_no desc
+ limit %(start)s, %(page_len)s """ % {'item_code': filters['item_code'],
+ 'warehouse': filters['warehouse'], 'posting_date': filters['posting_date'],
+ 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield),
+ 'start': start, 'page_len': page_len})
+ else:
+ return webnotes.conn.sql("""select name from tabBatch
+ where docstatus != 2
+ and item = '%(item_code)s'
+ and (ifnull(expiry_date, '')='' or expiry_date >= '%(posting_date)s')
+ and name like '%(txt)s'
+ %(mcond)s
+ order by name desc
+ limit %(start)s, %(page_len)s""" % {'item_code': filters['item_code'],
+ 'posting_date': filters['posting_date'], 'txt': "%%%s%%" % txt,
+ 'mcond':get_match_cond(doctype, searchfield),'start': start,
+ 'page_len': page_len})
\ No newline at end of file
diff --git a/controllers/selling_controller.py b/controllers/selling_controller.py
index d78cf93..0215dbd 100644
--- a/controllers/selling_controller.py
+++ b/controllers/selling_controller.py
@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import webnotes
-from webnotes.utils import cint, flt, comma_or, _round, add_days, cstr
+from webnotes.utils import cint, flt, comma_or, _round, cstr
from setup.utils import get_company_currency
from selling.utils import get_item_details
from webnotes import msgprint, _
@@ -14,6 +14,11 @@
def onload_post_render(self):
# contact, address, item details and pos details (if applicable)
self.set_missing_values()
+
+ def validate(self):
+ super(SellingController, self).validate()
+ self.validate_max_discount()
+ check_active_sales_items(self)
def get_sender(self, comm):
return webnotes.conn.get_value('Sales Email Settings', None, 'email_id')
@@ -237,3 +242,120 @@
elif self.doc.order_type not in valid_types:
msgprint(_(self.meta.get_label("order_type")) + " " +
_("must be one of") + ": " + comma_or(valid_types), raise_exception=True)
+
+ def check_credit(self, grand_total):
+ customer_account = webnotes.conn.get_value("Account", {"company": self.doc.company,
+ "master_name": self.doc.customer}, "name")
+ if customer_account:
+ total_outstanding = 0
+ total_outstanding = webnotes.conn.sql("""select
+ sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
+ from `tabGL Entry` where account = %s""", customer_account)[0][0]
+
+ outstanding_including_current = flt(total_outstanding) + flt(grand_total)
+ webnotes.bean('Account', customer_account).run_method("check_credit_limit",
+ customer_account, self.doc.company, outstanding_including_current)
+
+ def validate_max_discount(self):
+ for d in self.doclist.get({"parentfield": self.fname}):
+ discount = flt(webnotes.conn.get_value("Item", d.item_code, "max_discount"))
+
+ if discount and flt(d.adj_rate) > discount:
+ webnotes.throw(_("You cannot give more than ") + cstr(discount) + "% " +
+ _("discount on Item Code") + ": " + cstr(d.item_code))
+
+ def get_item_list(self):
+ il = []
+ for d in self.doclist.get({"parentfield": self.fname}):
+ reserved_warehouse = ""
+ reserved_qty_for_main_item = 0
+
+ if self.doc.doctype == "Sales Order":
+ if (webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes' or
+ self.has_sales_bom(d.item_code)) and not d.reserved_warehouse:
+ webnotes.throw(_("Please enter Reserved Warehouse for item ") +
+ d.item_code + _(" as it is stock Item or packing item"))
+ reserved_warehouse = d.reserved_warehouse
+ if flt(d.qty) > flt(d.delivered_qty):
+ reserved_qty_for_main_item = flt(d.qty) - flt(d.delivered_qty)
+
+ if self.doc.doctype == "Delivery Note" and d.against_sales_order:
+ # if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12.
+ # But in this case reserved qty should only be reduced by 10 and not 12
+
+ already_delivered_qty = self.get_already_delivered_qty(self.doc.name,
+ d.against_sales_order, d.prevdoc_detail_docname)
+ so_qty, reserved_warehouse = self.get_so_qty_and_warehouse(d.prevdoc_detail_docname)
+
+ if already_delivered_qty + d.qty > so_qty:
+ reserved_qty_for_main_item = -(so_qty - already_delivered_qty)
+ else:
+ reserved_qty_for_main_item = -flt(d.qty)
+
+ if self.has_sales_bom(d.item_code):
+ for p in self.doclist.get({"parentfield": "packing_details"}):
+ if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
+ # the packing details table's qty is already multiplied with parent's qty
+ il.append(webnotes._dict({
+ 'warehouse': p.warehouse,
+ 'reserved_warehouse': reserved_warehouse,
+ 'item_code': p.item_code,
+ 'qty': flt(p.qty),
+ 'reserved_qty': (flt(p.qty)/flt(d.qty)) * reserved_qty_for_main_item,
+ 'uom': p.uom,
+ 'batch_no': cstr(p.batch_no).strip(),
+ 'serial_no': cstr(p.serial_no).strip(),
+ 'name': d.name
+ }))
+ else:
+ il.append(webnotes._dict({
+ 'warehouse': d.warehouse,
+ 'reserved_warehouse': reserved_warehouse,
+ 'item_code': d.item_code,
+ 'qty': d.qty,
+ 'reserved_qty': reserved_qty_for_main_item,
+ 'uom': d.stock_uom,
+ 'batch_no': cstr(d.batch_no).strip(),
+ 'serial_no': cstr(d.serial_no).strip(),
+ 'name': d.name
+ }))
+ return il
+
+ def has_sales_bom(self, item_code):
+ return webnotes.conn.sql("""select name from `tabSales BOM`
+ where new_item_code=%s and docstatus != 2""", item_code)
+
+ def get_already_delivered_qty(self, dn, so, so_detail):
+ qty = webnotes.conn.sql("""select sum(qty) from `tabDelivery Note Item`
+ where prevdoc_detail_docname = %s and docstatus = 1
+ and against_sales_order = %s
+ and parent != %s""", (so_detail, so, dn))
+ return qty and flt(qty[0][0]) or 0.0
+
+ def get_so_qty_and_warehouse(self, so_detail):
+ so_item = webnotes.conn.sql("""select qty, reserved_warehouse from `tabSales Order Item`
+ where name = %s and docstatus = 1""", so_detail, as_dict=1)
+ so_qty = so_item and flt(so_item[0]["qty"]) or 0.0
+ so_warehouse = so_item and so_item[0]["reserved_warehouse"] or ""
+ return so_qty, so_warehouse
+
+ def check_stop_sales_order(self, ref_fieldname):
+ for d in self.doclist.get({"parentfield": self.fname}):
+ if d.fields.get(ref_fieldname):
+ status = webnotes.conn.get_value("Sales Order", d.fields[ref_fieldname], "status")
+ if status == "Stopped":
+ webnotes.throw(self.doc.doctype +
+ _(" can not be created/modified against stopped Sales Order ") +
+ d.fields[ref_fieldname])
+
+def check_active_sales_items(obj):
+ for d in obj.doclist.get({"parentfield": obj.fname}):
+ if d.item_code:
+ item = webnotes.conn.sql("""select docstatus, is_sales_item,
+ is_service_item, default_income_account from tabItem where name = %s""",
+ d.item_code, as_dict=True)[0]
+ if item.is_sales_item == 'No' and item.is_service_item == 'No':
+ webnotes.throw(_("Item is neither Sales nor Service Item") + ": " + d.item_code)
+ if d.income_account and not item.default_income_account:
+ webnotes.conn.set_value("Item", d.item_code, "default_income_account",
+ d.income_account)
\ No newline at end of file
diff --git a/controllers/stock_controller.py b/controllers/stock_controller.py
index d4c92a9..7d5d045 100644
--- a/controllers/stock_controller.py
+++ b/controllers/stock_controller.py
@@ -99,7 +99,6 @@
return warehouse_account
def update_gl_entries_after(self, warehouse_account=None):
- from accounts.utils import get_stock_and_account_difference
future_stock_vouchers = self.get_future_stock_vouchers()
gle = self.get_voucherwise_gl_entries(future_stock_vouchers)
if not warehouse_account:
diff --git a/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/manufacturing/doctype/production_planning_tool/production_planning_tool.py
index 6f15d4c..277e53a 100644
--- a/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -72,7 +72,7 @@
and (exists (select name from `tabItem` item where item.name=so_item.item_code
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes') %s)
- or exists (select name from `tabDelivery Note Packing Item` dnpi
+ or exists (select name from `tabPacked Item` dnpi
where dnpi.parent = so.name and dnpi.parent_item = so_item.item_code
and exists (select name from `tabItem` item where item.name=dnpi.item_code
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
@@ -119,7 +119,7 @@
dnpi_items = webnotes.conn.sql("""select distinct dnpi.parent, dnpi.item_code, dnpi.warehouse as reserved_warhouse,
(((so_item.qty - ifnull(so_item.delivered_qty, 0)) * dnpi.qty) / so_item.qty)
as pending_qty
- from `tabSales Order Item` so_item, `tabDelivery Note Packing Item` dnpi
+ from `tabSales Order Item` so_item, `tabPacked Item` dnpi
where so_item.parent = dnpi.parent and so_item.docstatus = 1
and dnpi.parent_item = so_item.item_code
and so_item.parent in (%s) and ifnull(so_item.qty, 0) > ifnull(so_item.delivered_qty, 0)
diff --git a/patches/november_2012/update_delivered_billed_percentage_for_pos.py b/patches/november_2012/update_delivered_billed_percentage_for_pos.py
index 0703f94..ffba0f9 100644
--- a/patches/november_2012/update_delivered_billed_percentage_for_pos.py
+++ b/patches/november_2012/update_delivered_billed_percentage_for_pos.py
@@ -3,10 +3,6 @@
def execute():
import webnotes
- from webnotes.model.code import get_obj
-
- #sc_obj = get_obj("Sales Common")
- from selling.doctype.sales_common import sales_common
si = webnotes.conn.sql("""select distinct si.name
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
@@ -16,5 +12,4 @@
and ifnull(si_item.sales_order, '') != ''
""")
for d in si:
- sales_common.StatusUpdater(get_obj("Sales Invoice", d[0], with_children=1), \
- 1).update_all_qty()
\ No newline at end of file
+ webnotes.bean("Sales Invoice", d[0]).run_method("update_qty")
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 9851986..78dc155 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -226,4 +226,6 @@
"patches.october_2013.p05_server_custom_script_to_file",
"patches.october_2013.repost_ordered_qty",
"patches.october_2013.repost_planned_qty",
+ "patches.october_2013.p06_rename_packing_list_doctype",
+ "execute:webnotes.delete_doc('DocType', 'Sales Common')",
]
\ No newline at end of file
diff --git a/selling/doctype/installation_note/installation_note.py b/selling/doctype/installation_note/installation_note.py
index 02b7247..17c3691 100644
--- a/selling/doctype/installation_note/installation_note.py
+++ b/selling/doctype/installation_note/installation_note.py
@@ -6,7 +6,6 @@
from webnotes.utils import cstr, getdate
from webnotes.model.bean import getlist
-from webnotes.model.code import get_obj
from webnotes import msgprint
from stock.utils import get_valid_serial_nos
@@ -36,8 +35,9 @@
self.validate_fiscal_year()
self.validate_installation_date()
self.check_item_table()
- sales_com_obj = get_obj(dt = 'Sales Common')
- sales_com_obj.check_active_sales_items(self)
+
+ from controllers.selling_controller import check_active_sales_items
+ check_active_sales_items(self)
def validate_fiscal_year(self):
from accounts.utils import validate_fiscal_year
diff --git a/selling/doctype/opportunity/opportunity.py b/selling/doctype/opportunity/opportunity.py
index 37672f2..ecba077 100644
--- a/selling/doctype/opportunity/opportunity.py
+++ b/selling/doctype/opportunity/opportunity.py
@@ -59,16 +59,6 @@
msgprint("Customer : %s does not exist in system." % (name))
raise Exception
- def get_contact_details(self, arg):
- arg = eval(arg)
- contact = webnotes.conn.sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s'" %(arg['contact_person'],arg['customer']), as_dict = 1)
- ret = {
- 'contact_no' : contact and contact[0]['contact_no'] or '',
- 'email_id' : contact and contact[0]['email_id'] or ''
- }
- return ret
-
-
def on_update(self):
self.add_calendar_event()
diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js
index 05feed0..4c27d52 100644
--- a/selling/doctype/quotation/quotation.js
+++ b/selling/doctype/quotation/quotation.js
@@ -10,7 +10,7 @@
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
-wn.require('app/selling/doctype/sales_common/sales_common.js');
+wn.require('app/selling/sales_common.js');
wn.require('app/accounts/doctype/sales_invoice/pos.js');
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py
index bd158d5..cf82407 100644
--- a/selling/doctype/quotation/quotation.py
+++ b/selling/doctype/quotation/quotation.py
@@ -19,46 +19,10 @@
self.doclist = doclist
self.tname = 'Quotation Item'
self.fname = 'quotation_details'
-
- # Get contact person details based on customer selected
- # ------------------------------------------------------
- def get_contact_details(self):
- return get_obj('Sales Common').get_contact_details(self,0)
-
- # Get Item Details
- # -----------------
- def get_item_details(self, args=None):
- import json
- args = args and json.loads(args) or {}
- if args.get('item_code'):
- return get_obj('Sales Common').get_item_details(args, self)
- else:
- obj = get_obj('Sales Common')
- for doc in self.doclist:
- if doc.fields.get('item_code'):
- arg = {
- 'item_code': doc.fields.get('item_code'),
- 'income_account': doc.fields.get('income_account'),
- 'cost_center': doc.fields.get('cost_center'),
- 'warehouse': doc.fields.get('warehouse')
- }
- res = obj.get_item_details(arg, self) or {}
- for r in res:
- if not doc.fields.get(r):
- doc.fields[r] = res[r]
-
def has_sales_order(self):
return webnotes.conn.get_value("Sales Order Item", {"prevdoc_docname": self.doc.name, "docstatus": 1})
-
-
- # Re-calculates Basic Rate & amount based on Price List Selected
- # --------------------------------------------------------------
- def get_adj_percent(self, arg=''):
- get_obj('Sales Common').get_adj_percent(self)
-
- # Does not allow same item code to be entered twice
- # -------------------------------------------------
+
def validate_for_items(self):
chk_dupl_itm = []
for d in getlist(self.doclist,'quotation_details'):
@@ -68,9 +32,6 @@
else:
chk_dupl_itm.append([cstr(d.item_code),cstr(d.description)])
-
- #do not allow sales item in maintenance quotation and service item in sales quotation
- #-----------------------------------------------------------------------------------------------
def validate_order_type(self):
super(DocType, self).validate_order_type()
@@ -96,15 +57,8 @@
self.set_status()
self.validate_order_type()
self.validate_for_items()
-
self.validate_uom_is_integer("stock_uom", "qty")
- sales_com_obj = get_obj('Sales Common')
- sales_com_obj.check_active_sales_items(self)
- sales_com_obj.validate_max_discount(self,'quotation_details')
-
- #update enquiry
- #------------------
def update_opportunity(self):
for opportunity in self.doclist.get_distinct_values("prevdoc_docname"):
webnotes.bean("Opportunity", opportunity).get_controller().set_status(update=True)
diff --git a/selling/doctype/sales_common/README.md b/selling/doctype/sales_common/README.md
deleted file mode 100644
index 1c029d2..0000000
--- a/selling/doctype/sales_common/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Common scripts used in Sales Cycle.
\ No newline at end of file
diff --git a/selling/doctype/sales_common/__init__.py b/selling/doctype/sales_common/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/selling/doctype/sales_common/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py
deleted file mode 100644
index e1172eb..0000000
--- a/selling/doctype/sales_common/sales_common.py
+++ /dev/null
@@ -1,317 +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 webnotes.utils import cint, cstr, flt
-from webnotes.model.doc import addchild
-from webnotes.model.bean import getlist
-from webnotes.model.code import get_obj
-from webnotes import msgprint, _
-
-get_value = webnotes.conn.get_value
-
-from utilities.transaction_base import TransactionBase
-
-class DocType(TransactionBase):
- def __init__(self,d,dl):
- self.doc, self.doclist = d, dl
-
-
- def get_contact_details(self, obj = '', primary = 0):
- cond = " and contact_name = '"+cstr(obj.doc.contact_person)+"'"
- if primary: cond = " and is_primary_contact = 'Yes'"
- contact = webnotes.conn.sql("select contact_name, contact_no, email_id, contact_address from `tabContact` where customer = '%s' and docstatus != 2 %s" %(obj.doc.customer, cond), as_dict = 1)
- if not contact:
- return
- c = contact[0]
- obj.doc.contact_person = c['contact_name'] or ''
- obj.doc.contact_no = c['contact_no'] or ''
- obj.doc.email_id = c['email_id'] or ''
- obj.doc.customer_mobile_no = c['contact_no'] or ''
- if c['contact_address']:
- obj.doc.customer_address = c['contact_address']
-
- def get_invoice_details(self, obj = ''):
- if obj.doc.company:
- acc_head = webnotes.conn.sql("select name from `tabAccount` where name = '%s' and docstatus != 2" % (cstr(obj.doc.customer) + " - " + webnotes.conn.get_value('Company', obj.doc.company, 'abbr')))
- obj.doc.debit_to = acc_head and acc_head[0][0] or ''
-
- def get_tax_details(self, item_code, obj):
- import json
- tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item_code)
- t = {}
- for x in tax: t[x[0]] = flt(x[1])
- ret = {
- 'item_tax_rate' : tax and json.dumps(t) or ''
- }
- return ret
-
- def get_serial_details(self, serial_no, obj):
- import json
- item = webnotes.conn.sql("select item_code, make, label,brand, description from `tabSerial No` where name = '%s' and docstatus != 2" %(serial_no), as_dict=1)
- tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item[0]['item_code'])
- t = {}
- for x in tax: t[x[0]] = flt(x[1])
- ret = {
- 'item_code' : item and item[0]['item_code'] or '',
- 'make' : item and item[0]['make'] or '',
- 'label' : item and item[0]['label'] or '',
- 'brand' : item and item[0]['brand'] or '',
- 'description' : item and item[0]['description'] or '',
- 'item_tax_rate' : json.dumps(t)
- }
- return ret
-
- # To verify whether rate entered in details table does not exceed max discount %
- # =======================================================================================
- def validate_max_discount(self,obj, detail_table):
- for d in getlist(obj.doclist, detail_table):
- discount = webnotes.conn.sql("select max_discount from tabItem where name = '%s'" %(d.item_code),as_dict = 1)
- if discount and discount[0]['max_discount'] and (flt(d.adj_rate)>flt(discount[0]['max_discount'])):
- msgprint("You cannot give more than " + cstr(discount[0]['max_discount']) + " % discount on Item Code : "+cstr(d.item_code))
- raise Exception
-
- def get_item_list(self, obj, is_stopped=0):
- """get item list"""
- il = []
- for d in getlist(obj.doclist, obj.fname):
- reserved_warehouse = ""
- reserved_qty_for_main_item = 0
-
- if obj.doc.doctype == "Sales Order":
- if (webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes' or
- self.has_sales_bom(d.item_code)) and not d.reserved_warehouse:
- webnotes.throw(_("Please enter Reserved Warehouse for item ") +
- d.item_code + _(" as it is stock Item or packing item"))
- reserved_warehouse = d.reserved_warehouse
- if flt(d.qty) > flt(d.delivered_qty):
- reserved_qty_for_main_item = flt(d.qty) - flt(d.delivered_qty)
-
- if obj.doc.doctype == "Delivery Note" and d.against_sales_order:
- # if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12.
- # But in this case reserved qty should only be reduced by 10 and not 12
-
- already_delivered_qty = self.get_already_delivered_qty(obj.doc.name,
- d.against_sales_order, d.prevdoc_detail_docname)
- so_qty, reserved_warehouse = self.get_so_qty_and_warehouse(d.prevdoc_detail_docname)
-
- if already_delivered_qty + d.qty > so_qty:
- reserved_qty_for_main_item = -(so_qty - already_delivered_qty)
- else:
- reserved_qty_for_main_item = -flt(d.qty)
-
- if self.has_sales_bom(d.item_code):
- for p in getlist(obj.doclist, 'packing_details'):
- if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
- # the packing details table's qty is already multiplied with parent's qty
- il.append(webnotes._dict({
- 'warehouse': p.warehouse,
- 'reserved_warehouse': reserved_warehouse,
- 'item_code': p.item_code,
- 'qty': flt(p.qty),
- 'reserved_qty': (flt(p.qty)/flt(d.qty)) * reserved_qty_for_main_item,
- 'uom': p.uom,
- 'batch_no': cstr(p.batch_no).strip(),
- 'serial_no': cstr(p.serial_no).strip(),
- 'name': d.name
- }))
- else:
- il.append(webnotes._dict({
- 'warehouse': d.warehouse,
- 'reserved_warehouse': reserved_warehouse,
- 'item_code': d.item_code,
- 'qty': d.qty,
- 'reserved_qty': reserved_qty_for_main_item,
- 'uom': d.stock_uom,
- 'batch_no': cstr(d.batch_no).strip(),
- 'serial_no': cstr(d.serial_no).strip(),
- 'name': d.name
- }))
- return il
-
- def get_already_delivered_qty(self, dn, so, so_detail):
- qty = webnotes.conn.sql("""select sum(qty) from `tabDelivery Note Item`
- where prevdoc_detail_docname = %s and docstatus = 1
- and against_sales_order = %s
- and parent != %s""", (so_detail, so, dn))
- return qty and flt(qty[0][0]) or 0.0
-
- def get_so_qty_and_warehouse(self, so_detail):
- so_item = webnotes.conn.sql("""select qty, reserved_warehouse from `tabSales Order Item`
- where name = %s and docstatus = 1""", so_detail, as_dict=1)
- so_qty = so_item and flt(so_item[0]["qty"]) or 0.0
- so_warehouse = so_item and so_item[0]["reserved_warehouse"] or ""
- return so_qty, so_warehouse
-
- def has_sales_bom(self, item_code):
- return webnotes.conn.sql("select name from `tabSales BOM` where new_item_code=%s and docstatus != 2", item_code)
-
- def get_sales_bom_items(self, item_code):
- return webnotes.conn.sql("""select t1.item_code, t1.qty, t1.uom
- from `tabSales BOM Item` t1, `tabSales BOM` t2
- where t2.new_item_code=%s and t1.parent = t2.name""", item_code, as_dict=1)
-
- def get_packing_item_details(self, item):
- return webnotes.conn.sql("select item_name, description, stock_uom from `tabItem` where name = %s", item, as_dict = 1)[0]
-
- def get_bin_qty(self, item, warehouse):
- det = webnotes.conn.sql("select actual_qty, projected_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (item, warehouse), as_dict = 1)
- return det and det[0] or ''
-
- def update_packing_list_item(self,obj, packing_item_code, qty, warehouse, line):
- bin = self.get_bin_qty(packing_item_code, warehouse)
- item = self.get_packing_item_details(packing_item_code)
-
- # check if exists
- exists = 0
- for d in getlist(obj.doclist, 'packing_details'):
- if d.parent_item == line.item_code and d.item_code == packing_item_code and d.parent_detail_docname == line.name:
- pi, exists = d, 1
- break
-
- if not exists:
- pi = addchild(obj.doc, 'packing_details', 'Delivery Note Packing Item',
- obj.doclist)
-
- pi.parent_item = line.item_code
- pi.item_code = packing_item_code
- pi.item_name = item['item_name']
- pi.parent_detail_docname = line.name
- pi.description = item['description']
- pi.uom = item['stock_uom']
- pi.qty = flt(qty)
- pi.actual_qty = bin and flt(bin['actual_qty']) or 0
- pi.projected_qty = bin and flt(bin['projected_qty']) or 0
- if not pi.warehouse:
- pi.warehouse = warehouse
- if not pi.batch_no:
- pi.batch_no = cstr(line.batch_no)
- pi.idx = self.packing_list_idx
-
- # saved, since this function is called on_update of delivery note
- pi.save()
-
- self.packing_list_idx += 1
-
-
- def make_packing_list(self, obj, fname):
- """make packing list for sales bom item"""
- self.packing_list_idx = 0
- parent_items = []
- for d in getlist(obj.doclist, fname):
- warehouse = fname == "sales_order_details" and d.reserved_warehouse or d.warehouse
- if self.has_sales_bom(d.item_code):
- for i in self.get_sales_bom_items(d.item_code):
- self.update_packing_list_item(obj, i['item_code'], flt(i['qty'])*flt(d.qty), warehouse, d)
-
- if [d.item_code, d.name] not in parent_items:
- parent_items.append([d.item_code, d.name])
-
- obj.doclist = self.cleanup_packing_list(obj, parent_items)
-
- return obj.doclist
-
- def cleanup_packing_list(self, obj, parent_items):
- """Remove all those child items which are no longer present in main item table"""
- delete_list = []
- for d in getlist(obj.doclist, 'packing_details'):
- if [d.parent_item, d.parent_detail_docname] not in parent_items:
- # mark for deletion from doclist
- delete_list.append(d.name)
-
- if not delete_list:
- return obj.doclist
-
- # delete from doclist
- obj.doclist = webnotes.doclist(filter(lambda d: d.name not in delete_list, obj.doclist))
-
- # delete from db
- webnotes.conn.sql("""\
- delete from `tabDelivery Note Packing Item`
- where name in (%s)"""
- % (", ".join(["%s"] * len(delete_list))),
- tuple(delete_list))
-
- return obj.doclist
-
-
- def get_month(self,date):
- """Get month based on date (required in sales person and sales partner)"""
- month_list = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
- month_idx = cint(cstr(date).split('-')[1])-1
- return month_list[month_idx]
-
-
- # **** Check for Stop SO as no transactions can be made against Stopped SO. Need to unstop it. ***
- def check_stop_sales_order(self,obj):
- for d in getlist(obj.doclist,obj.fname):
- ref_doc_name = ''
- if d.fields.has_key('against_sales_order') and d.against_sales_order:
- ref_doc_name = d.against_sales_order
- elif d.fields.has_key('sales_order') and d.sales_order and not d.delivery_note:
- ref_doc_name = d.sales_order
- if ref_doc_name:
- so_status = webnotes.conn.sql("select status from `tabSales Order` where name = %s",ref_doc_name)
- so_status = so_status and so_status[0][0] or ''
- if so_status == 'Stopped':
- msgprint("You cannot do any transaction against Sales Order : '%s' as it is Stopped." %(ref_doc_name))
- raise Exception
-
- def check_active_sales_items(self,obj):
- for d in getlist(obj.doclist, obj.fname):
- if d.item_code:
- item = webnotes.conn.sql("""select docstatus, is_sales_item,
- is_service_item, default_income_account from tabItem where name = %s""",
- d.item_code, as_dict=True)[0]
- if item.is_sales_item == 'No' and item.is_service_item == 'No':
- msgprint("Item : '%s' is neither Sales nor Service Item" % (d.item_code))
- raise Exception
- if d.income_account and not item.default_income_account:
- webnotes.conn.set_value("Item", d.item_code, "default_income_account", d.income_account)
-
-
- def check_credit(self,obj,grand_total):
- acc_head = webnotes.conn.sql("select name from `tabAccount` where company = '%s' and master_name = '%s'"%(obj.doc.company, obj.doc.customer))
- if acc_head:
- tot_outstanding = 0
- dbcr = webnotes.conn.sql("""select sum(debit), sum(credit) from `tabGL Entry`
- where account = %s""", acc_head[0][0])
- if dbcr:
- tot_outstanding = flt(dbcr[0][0])-flt(dbcr[0][1])
-
- exact_outstanding = flt(tot_outstanding) + flt(grand_total)
- get_obj('Account',acc_head[0][0]).check_credit_limit(acc_head[0][0], obj.doc.company, exact_outstanding)
-
-def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
- from controllers.queries import get_match_cond
-
- if filters.has_key('warehouse'):
- return webnotes.conn.sql("""select batch_no from `tabStock Ledger Entry` sle
- where item_code = '%(item_code)s'
- and warehouse = '%(warehouse)s'
- and batch_no like '%(txt)s'
- and exists(select * from `tabBatch`
- where name = sle.batch_no
- and (ifnull(expiry_date, '')='' or expiry_date >= '%(posting_date)s')
- and docstatus != 2)
- %(mcond)s
- group by batch_no having sum(actual_qty) > 0
- order by batch_no desc
- limit %(start)s, %(page_len)s """ % {'item_code': filters['item_code'],
- 'warehouse': filters['warehouse'], 'posting_date': filters['posting_date'],
- 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield),
- 'start': start, 'page_len': page_len})
- else:
- return webnotes.conn.sql("""select name from tabBatch
- where docstatus != 2
- and item = '%(item_code)s'
- and (ifnull(expiry_date, '')='' or expiry_date >= '%(posting_date)s')
- and name like '%(txt)s'
- %(mcond)s
- order by name desc
- limit %(start)s, %(page_len)s""" % {'item_code': filters['item_code'],
- 'posting_date': filters['posting_date'], 'txt': "%%%s%%" % txt,
- 'mcond':get_match_cond(doctype, searchfield),'start': start,
- 'page_len': page_len})
diff --git a/selling/doctype/sales_common/sales_common.txt b/selling/doctype/sales_common/sales_common.txt
deleted file mode 100644
index a407493..0000000
--- a/selling/doctype/sales_common/sales_common.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-[
- {
- "creation": "2012-03-27 14:36:14",
- "docstatus": 0,
- "modified": "2013-07-10 14:54:19",
- "modified_by": "Administrator",
- "owner": "Administrator"
- },
- {
- "doctype": "DocType",
- "issingle": 1,
- "module": "Selling",
- "name": "__common__"
- },
- {
- "doctype": "DocType",
- "name": "Sales Common"
- }
-]
\ No newline at end of file
diff --git a/selling/doctype/sales_order/sales_order.js b/selling/doctype/sales_order/sales_order.js
index bf23b9c..4033870 100644
--- a/selling/doctype/sales_order/sales_order.js
+++ b/selling/doctype/sales_order/sales_order.js
@@ -9,7 +9,7 @@
cur_frm.cscript.sales_team_fname = "sales_team";
-wn.require('app/selling/doctype/sales_common/sales_common.js');
+wn.require('app/selling/sales_common.js');
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
wn.require('app/accounts/doctype/sales_invoice/pos.js');
diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py
index 6dfa3e2..a9ab827 100644
--- a/selling/doctype/sales_order/sales_order.py
+++ b/selling/doctype/sales_order/sales_order.py
@@ -11,8 +11,6 @@
from webnotes import msgprint
from webnotes.model.mapper import get_mapped_doclist
-
-
from controllers.selling_controller import SellingController
class DocType(SellingController):
@@ -26,18 +24,6 @@
self.partner_tname = 'Partner Target Detail'
self.territory_tname = 'Territory Target Detail'
- def get_contact_details(self):
- get_obj('Sales Common').get_contact_details(self,0)
-
- def get_comm_rate(self, sales_partner):
- return get_obj('Sales Common').get_comm_rate(sales_partner, self)
-
- def get_adj_percent(self, arg=''):
- get_obj('Sales Common').get_adj_percent(self)
-
- def get_available_qty(self,args):
- return get_obj('Sales Common').get_available_qty(eval(args))
-
def validate_mandatory(self):
# validate transaction date v/s delivery date
if self.doc.delivery_date:
@@ -124,12 +110,9 @@
self.validate_uom_is_integer("stock_uom", "qty")
self.validate_for_items()
self.validate_warehouse()
- sales_com_obj = get_obj(dt = 'Sales Common')
- sales_com_obj.check_active_sales_items(self)
-
-
- sales_com_obj.validate_max_discount(self,'sales_order_details')
- self.doclist = sales_com_obj.make_packing_list(self,'sales_order_details')
+
+ from stock.doctype.packed_item.packed_item import make_packing_list
+ self.doclist = make_packing_list(self,'sales_order_details')
self.validate_with_previous_doc()
@@ -172,14 +155,14 @@
for quotation in self.doclist.get_distinct_values("prevdoc_docname"):
bean = webnotes.bean("Quotation", quotation)
if bean.doc.docstatus==2:
- webnotes.throw(d.prevdoc_docname + ": " + webnotes._("Quotation is cancelled."))
+ webnotes.throw(quotation + ": " + webnotes._("Quotation is cancelled."))
bean.get_controller().set_status(update=True)
def on_submit(self):
self.update_stock_ledger(update_stock = 1)
- get_obj('Sales Common').check_credit(self,self.doc.grand_total)
+ self.check_credit(self.doc.grand_total)
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.grand_total, self)
@@ -235,21 +218,21 @@
def stop_sales_order(self):
self.check_modified_date()
- self.update_stock_ledger(update_stock = -1,is_stopped = 1)
+ self.update_stock_ledger(-1)
webnotes.conn.set(self.doc, 'status', 'Stopped')
msgprint("""%s: %s has been Stopped. To make transactions against this Sales Order
you need to Unstop it.""" % (self.doc.doctype, self.doc.name))
def unstop_sales_order(self):
self.check_modified_date()
- self.update_stock_ledger(update_stock = 1,is_stopped = 1)
+ self.update_stock_ledger(1)
webnotes.conn.set(self.doc, 'status', 'Submitted')
msgprint("%s: %s has been Unstopped" % (self.doc.doctype, self.doc.name))
- def update_stock_ledger(self, update_stock, is_stopped = 0):
+ def update_stock_ledger(self, update_stock):
from stock.utils import update_bin
- for d in self.get_item_list(is_stopped):
+ for d in self.get_item_list():
if webnotes.conn.get_value("Item", d['item_code'], "is_stock_item") == "Yes":
args = {
"item_code": d['item_code'],
@@ -261,10 +244,6 @@
"is_amended": self.doc.amended_from and 'Yes' or 'No'
}
update_bin(args)
-
-
- def get_item_list(self, is_stopped):
- return get_obj('Sales Common').get_item_list( self, is_stopped)
def on_update(self):
pass
@@ -438,4 +417,4 @@
}
}, target_doclist)
- return [d.fields for d in doclist]
+ return [d.fields for d in doclist]
\ No newline at end of file
diff --git a/selling/doctype/sales_order/sales_order.txt b/selling/doctype/sales_order/sales_order.txt
index c27f8ff..bfbcd94 100644
--- a/selling/doctype/sales_order/sales_order.txt
+++ b/selling/doctype/sales_order/sales_order.txt
@@ -361,7 +361,7 @@
"label": "Packing Details",
"oldfieldname": "packing_details",
"oldfieldtype": "Table",
- "options": "Delivery Note Packing Item",
+ "options": "Packed Item",
"print_hide": 1,
"read_only": 1
},
diff --git a/selling/doctype/sales_common/sales_common.js b/selling/sales_common.js
similarity index 96%
rename from selling/doctype/sales_common/sales_common.js
rename to selling/sales_common.js
index f744faa..ce6b7d6 100644
--- a/selling/doctype/sales_common/sales_common.js
+++ b/selling/sales_common.js
@@ -73,23 +73,15 @@
if(!item.item_code) {
wn.throw("Please enter Item Code to get batch no");
} else {
- if(item.warehouse) {
- return {
- query : "selling.doctype.sales_common.sales_common.get_batch_no",
- filters: {
- 'item_code': item.item_code,
- 'warehouse': item.warehouse,
- 'posting_date': me.frm.doc.posting_date
- }
- }
- } else {
- return{
- query : "selling.doctype.sales_common.sales_common.get_batch_no",
- filters: {
- 'item_code': item.item_code,
- 'posting_date': me.frm.doc.posting_date
- }
- }
+ filters = {
+ 'item_code': item.item_code,
+ 'posting_date': me.frm.doc.posting_date,
+ }
+ if(item.warehouse) filters["warehouse"] = item.warehouse
+
+ return {
+ query : "controllers.queries.get_batch_no",
+ filters: filters
}
}
});
@@ -628,7 +620,7 @@
// Help for Sales BOM items
var set_sales_bom_help = function(doc) {
if(!cur_frm.fields_dict.packing_list) return;
- if (getchildren('Delivery Note Packing Item', doc.name, 'packing_details').length) {
+ if (getchildren('Packed Item', doc.name, 'packing_details').length) {
$(cur_frm.fields_dict.packing_list.row.wrapper).toggle(true);
if (inList(['Delivery Note', 'Sales Invoice'], doc.doctype)) {
diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js
index 29b3e47..0ca1d34 100644
--- a/stock/doctype/delivery_note/delivery_note.js
+++ b/stock/doctype/delivery_note/delivery_note.js
@@ -9,7 +9,7 @@
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
-wn.require('app/selling/doctype/sales_common/sales_common.js');
+wn.require('app/selling/sales_common.js');
wn.require('app/accounts/doctype/sales_invoice/pos.js');
wn.provide("erpnext.stock");
@@ -113,13 +113,6 @@
}
}
-cur_frm.cscript.serial_no = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if (d.serial_no) {
- return get_server_fields('get_serial_details',d.serial_no,'delivery_note_details',doc,cdt,cdn,1);
- }
-}
-
cur_frm.fields_dict['transporter_name'].get_query = function(doc) {
return{
filters: { 'supplier_type': "transporter" }
diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py
index 897c7d4..8d325f4 100644
--- a/stock/doctype/delivery_note/delivery_note.py
+++ b/stock/doctype/delivery_note/delivery_note.py
@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import webnotes
-from webnotes.utils import cstr, flt, cint, add_days
+from webnotes.utils import cstr, flt, cint
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint, _
@@ -42,14 +42,6 @@
def get_portal_page(self):
return "shipment" if self.doc.docstatus==1 else None
-
- def get_contact_details(self):
- return get_obj('Sales Common').get_contact_details(self,0)
-
-
- def get_comm_rate(self, sales_partner):
- """Get Commission rate of Sales Partner"""
- return get_obj('Sales Common').get_comm_rate(sales_partner, self)
def set_actual_qty(self):
for d in getlist(self.doclist, 'delivery_note_details'):
@@ -57,15 +49,6 @@
actual_qty = webnotes.conn.sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (d.item_code, d.warehouse))
d.actual_qty = actual_qty and flt(actual_qty[0][0]) or 0
-
- def get_barcode_details(self, barcode):
- return get_obj('Sales Common').get_barcode_details(barcode)
-
-
- def get_adj_percent(self, arg=''):
- """Re-calculates Basic Rate & amount based on Price List Selected"""
- get_obj('Sales Common').get_adj_percent(self)
-
def so_required(self):
"""check in manage account if sales order required or not"""
if webnotes.conn.get_value("Selling Settings", None, 'so_required') == 'Yes':
@@ -83,15 +66,10 @@
self.so_required()
self.validate_proj_cust()
- sales_com_obj = get_obj(dt = 'Sales Common')
- sales_com_obj.check_stop_sales_order(self)
- sales_com_obj.check_active_sales_items(self)
+ self.check_stop_sales_order("against_sales_order")
self.validate_for_items()
self.validate_warehouse()
- self.validate_uom_is_integer("stock_uom", "qty")
-
- sales_com_obj.validate_max_discount(self, 'delivery_note_details')
-
+ self.validate_uom_is_integer("stock_uom", "qty")
# Set actual qty for each item in selected warehouse
self.update_current_stock()
@@ -169,7 +147,8 @@
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
def on_update(self):
- self.doclist = get_obj('Sales Common').make_packing_list(self,'delivery_note_details')
+ from stock.doctype.packed_item.packed_item import make_packing_list
+ self.doclist = make_packing_list(self, 'delivery_note_details')
def on_submit(self):
self.validate_packed_qty()
@@ -192,8 +171,7 @@
def on_cancel(self):
- sales_com_obj = get_obj(dt = 'Sales Common')
- sales_com_obj.check_stop_sales_order(self)
+ self.check_stop_sales_order("against_sales_order")
self.check_next_docstatus()
self.update_prevdoc_status()
@@ -282,9 +260,6 @@
}
update_bin(args)
- def get_item_list(self):
- return get_obj('Sales Common').get_item_list(self)
-
def credit_limit(self):
"""check credit limit of items in DN Detail which are not fetched from sales order"""
amount, total = 0, 0
@@ -293,7 +268,7 @@
amount += d.amount
if amount != 0:
total = (amount/self.doc.net_total)*self.doc.grand_total
- get_obj('Sales Common').check_credit(self, total)
+ self.check_credit(total)
def get_invoiced_qty_map(delivery_note):
"""returns a map: {dn_detail: invoiced_qty}"""
diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt
index 6834365..037b4fb 100644
--- a/stock/doctype/delivery_note/delivery_note.txt
+++ b/stock/doctype/delivery_note/delivery_note.txt
@@ -355,7 +355,7 @@
"label": "Packing Details",
"oldfieldname": "packing_details",
"oldfieldtype": "Table",
- "options": "Delivery Note Packing Item",
+ "options": "Packed Item",
"print_hide": 1,
"read_only": 1
},
diff --git a/stock/doctype/delivery_note_packing_item/README.md b/stock/doctype/delivery_note_packing_item/README.md
deleted file mode 100644
index 20c343a..0000000
--- a/stock/doctype/delivery_note_packing_item/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Item packed in parent Delivery Note. If shipped Items are of type Sales BOM, then this table contains the exploded list of Items shipped.
\ No newline at end of file
diff --git a/stock/doctype/delivery_note_packing_item/__init__.py b/stock/doctype/delivery_note_packing_item/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/stock/doctype/delivery_note_packing_item/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/doctype/delivery_note_packing_item/delivery_note_packing_item.py b/stock/doctype/delivery_note_packing_item/delivery_note_packing_item.py
deleted file mode 100644
index 26d0f76..0000000
--- a/stock/doctype/delivery_note_packing_item/delivery_note_packing_item.py
+++ /dev/null
@@ -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
-import webnotes
-
-class DocType:
- def __init__(self, d, dl):
- self.doc, self.doclist = d, dl
\ No newline at end of file
diff --git a/stock/doctype/delivery_note_packing_item/delivery_note_packing_item.txt b/stock/doctype/delivery_note_packing_item/delivery_note_packing_item.txt
deleted file mode 100644
index 441b13a..0000000
--- a/stock/doctype/delivery_note_packing_item/delivery_note_packing_item.txt
+++ /dev/null
@@ -1,170 +0,0 @@
-[
- {
- "creation": "2013-02-22 01:28:00",
- "docstatus": 0,
- "modified": "2013-07-10 14:54:08",
- "modified_by": "Administrator",
- "owner": "Administrator"
- },
- {
- "doctype": "DocType",
- "istable": 1,
- "module": "Stock",
- "name": "__common__"
- },
- {
- "doctype": "DocField",
- "name": "__common__",
- "parent": "Delivery Note Packing Item",
- "parentfield": "fields",
- "parenttype": "DocType",
- "permlevel": 0
- },
- {
- "doctype": "DocType",
- "name": "Delivery Note Packing Item"
- },
- {
- "doctype": "DocField",
- "fieldname": "parent_item",
- "fieldtype": "Link",
- "in_list_view": 1,
- "label": "Parent Item",
- "oldfieldname": "parent_item",
- "oldfieldtype": "Link",
- "options": "Item",
- "read_only": 1
- },
- {
- "doctype": "DocField",
- "fieldname": "item_code",
- "fieldtype": "Link",
- "in_filter": 1,
- "in_list_view": 1,
- "label": "Item Code",
- "oldfieldname": "item_code",
- "oldfieldtype": "Link",
- "options": "Item",
- "read_only": 1
- },
- {
- "doctype": "DocField",
- "fieldname": "item_name",
- "fieldtype": "Data",
- "in_filter": 1,
- "in_list_view": 1,
- "label": "Item Name",
- "oldfieldname": "item_name",
- "oldfieldtype": "Data",
- "read_only": 1
- },
- {
- "doctype": "DocField",
- "fieldname": "parent_detail_docname",
- "fieldtype": "Data",
- "hidden": 1,
- "in_list_view": 0,
- "label": "Parent Detail docname",
- "no_copy": 1,
- "oldfieldname": "parent_detail_docname",
- "oldfieldtype": "Data",
- "print_hide": 1,
- "read_only": 1
- },
- {
- "doctype": "DocField",
- "fieldname": "description",
- "fieldtype": "Text",
- "in_list_view": 1,
- "label": "Description",
- "oldfieldname": "description",
- "oldfieldtype": "Text",
- "print_width": "300px",
- "read_only": 1,
- "width": "300px"
- },
- {
- "doctype": "DocField",
- "fieldname": "warehouse",
- "fieldtype": "Link",
- "in_list_view": 1,
- "label": "Warehouse",
- "oldfieldname": "warehouse",
- "oldfieldtype": "Link",
- "options": "Warehouse"
- },
- {
- "doctype": "DocField",
- "fieldname": "qty",
- "fieldtype": "Float",
- "in_list_view": 1,
- "label": "Qty",
- "oldfieldname": "qty",
- "oldfieldtype": "Currency",
- "read_only": 1
- },
- {
- "doctype": "DocField",
- "fieldname": "serial_no",
- "fieldtype": "Text",
- "label": "Serial No"
- },
- {
- "doctype": "DocField",
- "fieldname": "batch_no",
- "fieldtype": "Data",
- "label": "Batch No"
- },
- {
- "doctype": "DocField",
- "fieldname": "actual_qty",
- "fieldtype": "Float",
- "label": "Actual Qty",
- "no_copy": 1,
- "oldfieldname": "actual_qty",
- "oldfieldtype": "Currency",
- "read_only": 1
- },
- {
- "doctype": "DocField",
- "fieldname": "projected_qty",
- "fieldtype": "Float",
- "label": "Projected Qty",
- "no_copy": 1,
- "oldfieldname": "projected_qty",
- "oldfieldtype": "Currency",
- "read_only": 1
- },
- {
- "doctype": "DocField",
- "fieldname": "uom",
- "fieldtype": "Link",
- "label": "UOM",
- "oldfieldname": "uom",
- "oldfieldtype": "Link",
- "options": "UOM",
- "read_only": 1,
- "search_index": 0
- },
- {
- "doctype": "DocField",
- "fieldname": "prevdoc_doctype",
- "fieldtype": "Data",
- "hidden": 1,
- "label": "Prevdoc DocType",
- "oldfieldname": "prevdoc_doctype",
- "oldfieldtype": "Data",
- "print_hide": 1,
- "read_only": 1
- },
- {
- "allow_on_submit": 1,
- "doctype": "DocField",
- "fieldname": "page_break",
- "fieldtype": "Check",
- "label": "Page Break",
- "oldfieldname": "page_break",
- "oldfieldtype": "Check",
- "read_only": 1
- }
-]
\ No newline at end of file
diff --git a/translations/ar.csv b/translations/ar.csv
index 9e075a8..9856580 100644
--- a/translations/ar.csv
+++ b/translations/ar.csv
@@ -814,7 +814,7 @@
Delivery Note Items,ملاحظة عناصر التسليم
Delivery Note Message,ملاحظة تسليم رسالة
Delivery Note No,ملاحظة لا تسليم
-Delivery Note Packing Item,ملاحظة التوصيل التغليف
+Packed Item,ملاحظة التوصيل التغليف
Delivery Note Required,ملاحظة التسليم المطلوبة
Delivery Note Trends,ملاحظة اتجاهات التسليم
Delivery Status,حالة التسليم
diff --git a/translations/de.csv b/translations/de.csv
index ccb2c88..7cf514e 100644
--- a/translations/de.csv
+++ b/translations/de.csv
@@ -814,7 +814,7 @@
Delivery Note Items,Lieferscheinpositionen
Delivery Note Message,Lieferschein Nachricht
Delivery Note No,Lieferschein Nein
-Delivery Note Packing Item,Lieferschein Verpackung Artikel
+Packed Item,Lieferschein Verpackung Artikel
Delivery Note Required,Lieferschein erforderlich
Delivery Note Trends,Lieferschein Trends
Delivery Status,Lieferstatus
diff --git a/translations/el.csv b/translations/el.csv
index 7d429bb..8b604e7 100644
--- a/translations/el.csv
+++ b/translations/el.csv
@@ -827,7 +827,7 @@
Delivery Note Items,Σημείωση Στοιχεία Παράδοσης
Delivery Note Message,Αποστολή μηνύματος Σημείωση
Delivery Note No,Σημείωση παράδοσης αριθ.
-Delivery Note Packing Item,Παράδοση Θέση Συσκευασία Σημείωση
+Packed Item,Παράδοση Θέση Συσκευασία Σημείωση
Delivery Note Required,Σημείωση παράδοσης Απαιτείται
Delivery Note Trends,Τάσεις Σημείωση Παράδοση
Delivery Status,Κατάσταση παράδοσης
diff --git a/translations/es.csv b/translations/es.csv
index d30649d..4ab32b5 100644
--- a/translations/es.csv
+++ b/translations/es.csv
@@ -814,7 +814,7 @@
Delivery Note Items,Artículos de entrega Nota
Delivery Note Message,Entrega de mensajes Nota
Delivery Note No,Entrega Nota No
-Delivery Note Packing Item,Nota de Entrega Embalaje artículo
+Packed Item,Nota de Entrega Embalaje artículo
Delivery Note Required,Nota de entrega requerida
Delivery Note Trends,Tendencias albarán
Delivery Status,Estado de entrega
diff --git a/translations/fr.csv b/translations/fr.csv
index dacdd2f..d9c0d87 100644
--- a/translations/fr.csv
+++ b/translations/fr.csv
@@ -814,7 +814,7 @@
Delivery Note Items,Articles bordereau de livraison
Delivery Note Message,Note Message de livraison
Delivery Note No,Remarque Aucune livraison
-Delivery Note Packing Item,Article d'emballage de livraison Note
+Packed Item,Article d'emballage de livraison Note
Delivery Note Required,Remarque livraison requis
Delivery Note Trends,Bordereau de livraison Tendances
Delivery Status,Delivery Status
diff --git a/translations/hi.csv b/translations/hi.csv
index 6f9576c..8e2fcaf 100644
--- a/translations/hi.csv
+++ b/translations/hi.csv
@@ -814,7 +814,7 @@
Delivery Note Items,डिलिवरी नोट आइटम
Delivery Note Message,डिलिवरी नोट संदेश
Delivery Note No,डिलिवरी नोट
-Delivery Note Packing Item,डिलिवरी नोट पैकिंग आइटम
+Packed Item,डिलिवरी नोट पैकिंग आइटम
Delivery Note Required,डिलिवरी नोट आवश्यक
Delivery Note Trends,डिलिवरी नोट रुझान
Delivery Status,डिलिवरी स्थिति
diff --git a/translations/hr.csv b/translations/hr.csv
index d60f85b..20b5cc7 100644
--- a/translations/hr.csv
+++ b/translations/hr.csv
@@ -814,7 +814,7 @@
Delivery Note Items,Način Napomena Stavke
Delivery Note Message,Otpremnica Poruka
Delivery Note No,Dostava Napomena Ne
-Delivery Note Packing Item,Dostava Napomena Pakiranje artikla
+Packed Item,Dostava Napomena Pakiranje artikla
Delivery Note Required,Dostava Napomena Obavezno
Delivery Note Trends,Otpremnici trendovi
Delivery Status,Status isporuke
diff --git a/translations/it.csv b/translations/it.csv
index c91fc84..e9e2106 100644
--- a/translations/it.csv
+++ b/translations/it.csv
Binary files differ
diff --git a/translations/nl.csv b/translations/nl.csv
index 3cc7152..c9b5aa2 100644
--- a/translations/nl.csv
+++ b/translations/nl.csv
@@ -814,7 +814,7 @@
Delivery Note Items,Levering Opmerking Items
Delivery Note Message,Levering Opmerking Bericht
Delivery Note No,Levering aantekening
-Delivery Note Packing Item,Levering Opmerking Verpakking Item
+Packed Item,Levering Opmerking Verpakking Item
Delivery Note Required,Levering Opmerking Verplicht
Delivery Note Trends,Delivery Note Trends
Delivery Status,Delivery Status
diff --git a/translations/pt-BR.csv b/translations/pt-BR.csv
index 274c7d4..7dfb0a2 100644
--- a/translations/pt-BR.csv
+++ b/translations/pt-BR.csv
@@ -814,7 +814,7 @@
Delivery Note Items,Itens da Guia de Remessa
Delivery Note Message,Mensagem da Guia de Remessa
Delivery Note No,Nº da Guia de Remessa
-Delivery Note Packing Item,Item do Pacote da Guia de Remessa
+Packed Item,Item do Pacote da Guia de Remessa
Delivery Note Required,Guia de Remessa Obrigatória
Delivery Note Trends,Nota de entrega Trends
Delivery Status,Estado da entrega
diff --git a/translations/pt.csv b/translations/pt.csv
index 31d20bc..900d4da 100644
--- a/translations/pt.csv
+++ b/translations/pt.csv
@@ -814,7 +814,7 @@
Delivery Note Items,Nota Itens de entrega
Delivery Note Message,Mensagem Nota de Entrega
Delivery Note No,Nota de Entrega Não
-Delivery Note Packing Item,Entrega do item embalagem Nota
+Packed Item,Entrega do item embalagem Nota
Delivery Note Required,Nota de Entrega Obrigatório
Delivery Note Trends,Nota de entrega Trends
Delivery Status,Estado entrega
diff --git a/translations/sr.csv b/translations/sr.csv
index aa14049..fc9513b 100644
--- a/translations/sr.csv
+++ b/translations/sr.csv
@@ -814,7 +814,7 @@
Delivery Note Items,Достава Напомена Ставке
Delivery Note Message,Испорука Напомена порука
Delivery Note No,Испорука Напомена Не
-Delivery Note Packing Item,Испорука Напомена Паковање јединице
+Packed Item,Испорука Напомена Паковање јединице
Delivery Note Required,Испорука Напомена Обавезно
Delivery Note Trends,Достава Напомена трендови
Delivery Status,Статус испоруке
diff --git a/translations/ta.csv b/translations/ta.csv
index 74cc74b..f21f27b 100644
--- a/translations/ta.csv
+++ b/translations/ta.csv
@@ -814,7 +814,7 @@
Delivery Note Items,டெலிவரி குறிப்பு உருப்படிகள்
Delivery Note Message,டெலிவரி குறிப்பு செய்தி
Delivery Note No,டெலிவரி குறிப்பு இல்லை
-Delivery Note Packing Item,டெலிவரி குறிப்பு தடைக்காப்பு பொருள்
+Packed Item,டெலிவரி குறிப்பு தடைக்காப்பு பொருள்
Delivery Note Required,டெலிவரி குறிப்பு தேவை
Delivery Note Trends,பந்து குறிப்பு போக்குகள்
Delivery Status,விநியோக நிலைமை
diff --git a/translations/th.csv b/translations/th.csv
index 7a461f0..3cf2d9c 100644
--- a/translations/th.csv
+++ b/translations/th.csv
@@ -814,7 +814,7 @@
Delivery Note Items,รายการจัดส่งสินค้าหมายเหตุ
Delivery Note Message,ข้อความหมายเหตุจัดส่งสินค้า
Delivery Note No,หมายเหตุจัดส่งสินค้าไม่มี
-Delivery Note Packing Item,จัดส่งสินค้าบรรจุหมายเหตุ
+Packed Item,จัดส่งสินค้าบรรจุหมายเหตุ
Delivery Note Required,หมายเหตุจัดส่งสินค้าที่จำเป็น
Delivery Note Trends,แนวโน้มหมายเหตุการจัดส่งสินค้า
Delivery Status,สถานะการจัดส่งสินค้า
diff --git a/utilities/repost_stock.py b/utilities/repost_stock.py
index 7359304..9591b31 100644
--- a/utilities/repost_stock.py
+++ b/utilities/repost_stock.py
@@ -53,7 +53,7 @@
from
(
select qty, parent_detail_docname, parent, name
- from `tabDelivery Note Packing Item` dnpi_in
+ from `tabPacked Item` dnpi_in
where item_code = %s and warehouse = %s
and parenttype="Sales Order"
and item_code != parent_item