[Cleanup] Sales Common deprecated
This commit is contained in:
parent
d05a3b3b5c
commit
d1fd1e2d89
@ -11,7 +11,7 @@ cur_frm.pformat.print_heading = 'Invoice';
|
||||
|
||||
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");
|
||||
|
@ -48,11 +48,7 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
|
||||
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 send_notification(new_rv):
|
||||
|
||||
def notify_errors(inv, owner):
|
||||
import webnotes
|
||||
import website
|
||||
|
||||
exception_msg = """
|
||||
Dear User,
|
||||
|
@ -174,4 +174,36 @@ def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len,
|
||||
"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) })
|
||||
}, { "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})
|
@ -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 @@ class SellingController(StockController):
|
||||
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 @@ class SellingController(StockController):
|
||||
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)
|
@ -99,7 +99,6 @@ class StockController(AccountsController):
|
||||
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:
|
||||
|
@ -72,7 +72,7 @@ class DocType:
|
||||
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 @@ class DocType:
|
||||
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)
|
||||
|
@ -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 @@ def execute():
|
||||
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()
|
||||
webnotes.bean("Sales Invoice", d[0]).run_method("update_qty")
|
@ -226,4 +226,6 @@ patch_list = [
|
||||
"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')",
|
||||
]
|
@ -6,7 +6,6 @@ import webnotes
|
||||
|
||||
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 @@ class DocType(TransactionBase):
|
||||
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
|
||||
|
@ -59,16 +59,6 @@ class DocType(TransactionBase):
|
||||
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()
|
||||
|
||||
|
@ -10,7 +10,7 @@ cur_frm.cscript.sales_team_fname = "sales_team";
|
||||
|
||||
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({
|
||||
|
@ -19,46 +19,10 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
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)
|
||||
|
@ -1 +0,0 @@
|
||||
Common scripts used in Sales Cycle.
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -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})
|
@ -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"
|
||||
}
|
||||
]
|
@ -9,7 +9,7 @@ cur_frm.cscript.other_fname = "other_charges";
|
||||
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');
|
||||
|
@ -11,8 +11,6 @@ from webnotes.model.code import get_obj
|
||||
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 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
|
||||
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 @@ class DocType(SellingController):
|
||||
"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 @@ def make_maintenance_visit(source_name, target_doclist=None):
|
||||
}
|
||||
}, target_doclist)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
return [d.fields for d in doclist]
|
@ -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
|
||||
},
|
||||
|
@ -73,23 +73,15 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
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 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
// 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)) {
|
@ -9,7 +9,7 @@ cur_frm.cscript.sales_team_fname = "sales_team";
|
||||
|
||||
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.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {
|
||||
}
|
||||
}
|
||||
|
||||
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" }
|
||||
|
@ -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 @@ class DocType(SellingController):
|
||||
|
||||
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 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
|
||||
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 @@ class DocType(SellingController):
|
||||
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 @@ class DocType(SellingController):
|
||||
|
||||
|
||||
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 @@ class DocType(SellingController):
|
||||
}
|
||||
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 @@ class DocType(SellingController):
|
||||
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}"""
|
||||
|
@ -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
|
||||
},
|
||||
|
@ -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.
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -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
|
@ -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
|
||||
}
|
||||
]
|
@ -814,7 +814,7 @@ Delivery Note Item,ملاحظة تسليم السلعة
|
||||
Delivery Note Items,ملاحظة عناصر التسليم
|
||||
Delivery Note Message,ملاحظة تسليم رسالة
|
||||
Delivery Note No,ملاحظة لا تسليم
|
||||
Delivery Note Packing Item,ملاحظة التوصيل التغليف
|
||||
Packed Item,ملاحظة التوصيل التغليف
|
||||
Delivery Note Required,ملاحظة التسليم المطلوبة
|
||||
Delivery Note Trends,ملاحظة اتجاهات التسليم
|
||||
Delivery Status,حالة التسليم
|
||||
|
|
@ -814,7 +814,7 @@ Delivery Note Item,Lieferscheinposition
|
||||
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
|
||||
|
|
@ -827,7 +827,7 @@ Delivery Note Item,Αποστολή στοιχείων Σημείωση
|
||||
Delivery Note Items,Σημείωση Στοιχεία Παράδοσης
|
||||
Delivery Note Message,Αποστολή μηνύματος Σημείωση
|
||||
Delivery Note No,Σημείωση παράδοσης αριθ.
|
||||
Delivery Note Packing Item,Παράδοση Θέση Συσκευασία Σημείωση
|
||||
Packed Item,Παράδοση Θέση Συσκευασία Σημείωση
|
||||
Delivery Note Required,Σημείωση παράδοσης Απαιτείται
|
||||
Delivery Note Trends,Τάσεις Σημείωση Παράδοση
|
||||
Delivery Status,Κατάσταση παράδοσης
|
||||
|
|
@ -814,7 +814,7 @@ Delivery Note Item,Nota de entrega del artículo
|
||||
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
|
||||
|
|
@ -814,7 +814,7 @@ Delivery Note Item,Point de Livraison
|
||||
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
|
||||
|
|
@ -814,7 +814,7 @@ Delivery Note Item,डिलिवरी नोट आइटम
|
||||
Delivery Note Items,डिलिवरी नोट आइटम
|
||||
Delivery Note Message,डिलिवरी नोट संदेश
|
||||
Delivery Note No,डिलिवरी नोट
|
||||
Delivery Note Packing Item,डिलिवरी नोट पैकिंग आइटम
|
||||
Packed Item,डिलिवरी नोट पैकिंग आइटम
|
||||
Delivery Note Required,डिलिवरी नोट आवश्यक
|
||||
Delivery Note Trends,डिलिवरी नोट रुझान
|
||||
Delivery Status,डिलिवरी स्थिति
|
||||
|
|
@ -814,7 +814,7 @@ Delivery Note Item,Otpremnica artikla
|
||||
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
|
||||
|
|
@ -822,7 +822,7 @@ Delivery Note Item,Nota articolo Consegna
|
||||
Delivery Note Items,Nota Articoli Consegna
|
||||
Delivery Note Message,Nota Messaggio Consegna
|
||||
Delivery Note No,Nota Consegna N.
|
||||
Delivery Note Packing Item,Nota Consegna Imballaggio articolo
|
||||
Packed Item,Nota Consegna Imballaggio articolo
|
||||
Delivery Note Required,Nota Consegna Richiesta
|
||||
Delivery Note Trends,Nota Consegna Tendenza
|
||||
Delivery Status,Stato Consegna
|
||||
|
|
@ -814,7 +814,7 @@ Delivery Note Item,Levering Note Item
|
||||
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
|
||||
|
|
@ -814,7 +814,7 @@ Delivery Note Item,Item da Guia de Remessa
|
||||
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
|
||||
|
|
@ -814,7 +814,7 @@ Delivery Note Item,Item Nota de Entrega
|
||||
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
|
||||
|
|
@ -814,7 +814,7 @@ Delivery Note Item,Испорука Напомена Ставка
|
||||
Delivery Note Items,Достава Напомена Ставке
|
||||
Delivery Note Message,Испорука Напомена порука
|
||||
Delivery Note No,Испорука Напомена Не
|
||||
Delivery Note Packing Item,Испорука Напомена Паковање јединице
|
||||
Packed Item,Испорука Напомена Паковање јединице
|
||||
Delivery Note Required,Испорука Напомена Обавезно
|
||||
Delivery Note Trends,Достава Напомена трендови
|
||||
Delivery Status,Статус испоруке
|
||||
|
|
@ -814,7 +814,7 @@ Delivery Note Item,டெலிவரி குறிப்பு பொர
|
||||
Delivery Note Items,டெலிவரி குறிப்பு உருப்படிகள்
|
||||
Delivery Note Message,டெலிவரி குறிப்பு செய்தி
|
||||
Delivery Note No,டெலிவரி குறிப்பு இல்லை
|
||||
Delivery Note Packing Item,டெலிவரி குறிப்பு தடைக்காப்பு பொருள்
|
||||
Packed Item,டெலிவரி குறிப்பு தடைக்காப்பு பொருள்
|
||||
Delivery Note Required,டெலிவரி குறிப்பு தேவை
|
||||
Delivery Note Trends,பந்து குறிப்பு போக்குகள்
|
||||
Delivery Status,விநியோக நிலைமை
|
||||
|
|
@ -814,7 +814,7 @@ Delivery Note Item,รายการจัดส่งสินค้าหม
|
||||
Delivery Note Items,รายการจัดส่งสินค้าหมายเหตุ
|
||||
Delivery Note Message,ข้อความหมายเหตุจัดส่งสินค้า
|
||||
Delivery Note No,หมายเหตุจัดส่งสินค้าไม่มี
|
||||
Delivery Note Packing Item,จัดส่งสินค้าบรรจุหมายเหตุ
|
||||
Packed Item,จัดส่งสินค้าบรรจุหมายเหตุ
|
||||
Delivery Note Required,หมายเหตุจัดส่งสินค้าที่จำเป็น
|
||||
Delivery Note Trends,แนวโน้มหมายเหตุการจัดส่งสินค้า
|
||||
Delivery Status,สถานะการจัดส่งสินค้า
|
||||
|
|
@ -53,7 +53,7 @@ def get_reserved_qty(item_code, warehouse):
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user