Merge pull request #1900 from anandpdoshi/anand-july-7
Fix in Purchase Order and Re-order Item
This commit is contained in:
commit
0da9060a80
@ -184,7 +184,7 @@ def update_against_doc(d, jv_obj):
|
||||
ch = jv_obj.append("entries")
|
||||
ch.account = d['account']
|
||||
ch.cost_center = cstr(jvd[0][0])
|
||||
ch.balance = cstr(jvd[0][1])
|
||||
ch.balance = flt(jvd[0][1])
|
||||
ch.set(d['dr_or_cr'], flt(d['unadjusted_amt']) - flt(d['allocated_amt']))
|
||||
ch.set(d['dr_or_cr']== 'debit' and 'credit' or 'debit', 0)
|
||||
ch.against_account = cstr(jvd[0][2])
|
||||
|
@ -66,7 +66,7 @@ class PurchaseOrder(BuyingController):
|
||||
itemwise_min_order_qty = frappe._dict(frappe.db.sql("select name, min_order_qty from tabItem"))
|
||||
|
||||
for d in self.get("po_details"):
|
||||
if flt(d.qty) < flt(itemwise_min_order_qty.get(d.item_code)):
|
||||
if flt(d.stock_qty) < flt(itemwise_min_order_qty.get(d.item_code)):
|
||||
frappe.throw(_("Row #{0}: Ordered qty can not less than item's minimum order qty (defined in item master).").format(d.idx))
|
||||
|
||||
def get_schedule_dates(self):
|
||||
|
@ -19,6 +19,7 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
||||
self.name = self.item_group_name
|
||||
|
||||
def validate(self):
|
||||
WebsiteGenerator.validate(self)
|
||||
if not self.parent_website_route:
|
||||
if frappe.db.get_value("Item Group", self.parent_item_group, "show_in_website"):
|
||||
self.parent_website_route = frappe.get_website_route("Item Group",
|
||||
|
@ -14,6 +14,7 @@ class SalesPartner(WebsiteGenerator):
|
||||
self.name = self.partner_name
|
||||
|
||||
def validate(self):
|
||||
super(SalesPartner, self).validate()
|
||||
if self.partner_website and not self.partner_website.startswith("http"):
|
||||
self.partner_website = "http://" + self.partner_website
|
||||
|
||||
|
@ -30,6 +30,8 @@ class Item(WebsiteGenerator):
|
||||
self.name = self.item_code
|
||||
|
||||
def validate(self):
|
||||
super(Item, self).validate()
|
||||
|
||||
if not self.stock_uom:
|
||||
msgprint(_("Please enter default Unit of Measure"), raise_exception=1)
|
||||
if self.image and not self.website_image:
|
||||
|
@ -7,6 +7,7 @@ import json
|
||||
from frappe.utils import flt, cstr, nowdate, add_days, cint
|
||||
from frappe.defaults import get_global_default
|
||||
from frappe.utils.email_lib import sendmail
|
||||
from erpnext.accounts.utils import get_fiscal_year, FiscalYearError
|
||||
|
||||
class InvalidWarehouseCompany(frappe.ValidationError): pass
|
||||
|
||||
@ -222,15 +223,30 @@ def reorder_item():
|
||||
})
|
||||
)
|
||||
|
||||
create_material_request(material_requests)
|
||||
if material_requests:
|
||||
create_material_request(material_requests)
|
||||
|
||||
def create_material_request(material_requests):
|
||||
""" Create indent on reaching reorder level """
|
||||
mr_list = []
|
||||
defaults = frappe.defaults.get_defaults()
|
||||
exceptions_list = []
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
current_fiscal_year = get_fiscal_year(nowdate())[0] or defaults.fiscal_year
|
||||
|
||||
def _log_exception():
|
||||
if frappe.local.message_log:
|
||||
exceptions_list.extend(frappe.local.message_log)
|
||||
frappe.local.message_log = []
|
||||
else:
|
||||
exceptions_list.append(frappe.get_traceback())
|
||||
|
||||
try:
|
||||
current_fiscal_year = get_fiscal_year(nowdate())[0] or defaults.fiscal_year
|
||||
|
||||
except FiscalYearError:
|
||||
_log_exception()
|
||||
notify_errors(exceptions_list)
|
||||
return
|
||||
|
||||
for request_type in material_requests:
|
||||
for company in material_requests[request_type]:
|
||||
try:
|
||||
@ -266,11 +282,7 @@ def create_material_request(material_requests):
|
||||
mr_list.append(mr)
|
||||
|
||||
except:
|
||||
if frappe.local.message_log:
|
||||
exceptions_list.append([] + frappe.local.message_log)
|
||||
frappe.local.message_log = []
|
||||
else:
|
||||
exceptions_list.append(frappe.get_traceback())
|
||||
_log_exception()
|
||||
|
||||
if mr_list:
|
||||
if getattr(frappe.local, "reorder_email_notify", None) is None:
|
||||
@ -307,16 +319,16 @@ def notify_errors(exceptions_list):
|
||||
subject = "[Important] [ERPNext] Error(s) while creating Material Requests based on Re-order Levels"
|
||||
msg = """Dear System Manager,
|
||||
|
||||
An error occured for certain Items while creating Material Requests based on Re-order level.
|
||||
An error occured for certain Items while creating Material Requests based on Re-order level.
|
||||
|
||||
Please rectify these issues:
|
||||
---
|
||||
|
||||
%s
|
||||
|
||||
---
|
||||
Regards,
|
||||
Administrator""" % ("\n\n".join(["\n".join(msg) for msg in exceptions_list]),)
|
||||
Please rectify these issues:
|
||||
---
|
||||
<pre>
|
||||
%s
|
||||
</pre>
|
||||
---
|
||||
Regards,
|
||||
Administrator""" % ("\n\n".join(exceptions_list),)
|
||||
|
||||
from frappe.utils.user import get_system_managers
|
||||
sendmail(get_system_managers(), subject=subject, msg=msg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user