Merge branch 'hotfix' into get-item-details
This commit is contained in:
commit
921f468950
@ -5,7 +5,7 @@ import frappe
|
||||
from erpnext.hooks import regional_overrides
|
||||
from frappe.utils import getdate
|
||||
|
||||
__version__ = '11.1.4'
|
||||
__version__ = '11.1.5'
|
||||
|
||||
def get_default_company(user=None):
|
||||
'''Get default company for user'''
|
||||
|
@ -60,7 +60,7 @@ def get_booking_dates(doc, item, start_date=None, end_date=None):
|
||||
deferred_account = "deferred_revenue_account" if doc.doctype=="Sales Invoice" else "deferred_expense_account"
|
||||
last_gl_entry, skip = False, False
|
||||
|
||||
booking_end_date = getdate(add_days(today(), -1)) if not end_date else end_date
|
||||
booking_end_date = getdate(add_days(today(), -1) if not end_date else end_date)
|
||||
if booking_end_date < item.service_start_date or \
|
||||
(item.service_stop_date and booking_end_date.month > item.service_stop_date.month):
|
||||
return None, None, None, True
|
||||
@ -71,7 +71,7 @@ def get_booking_dates(doc, item, start_date=None, end_date=None):
|
||||
last_gl_entry = True
|
||||
booking_end_date = item.service_stop_date
|
||||
|
||||
booking_start_date = getdate(add_months(today(), -1)) if not start_date else start_date
|
||||
booking_start_date = getdate(add_months(today(), -1) if not start_date else start_date)
|
||||
booking_start_date = booking_start_date \
|
||||
if booking_start_date > item.service_start_date else item.service_start_date
|
||||
|
||||
@ -113,7 +113,6 @@ def calculate_amount_and_base_amount(doc, item, last_gl_entry, total_days, total
|
||||
group by voucher_detail_no
|
||||
'''.format(total_credit_debit, total_credit_debit_currency),
|
||||
(doc.company, item.get(deferred_account), doc.doctype, doc.name, item.name), as_dict=True)
|
||||
|
||||
already_booked_amount = gl_entries_details[0].total_credit if gl_entries_details else 0
|
||||
base_amount = flt(item.base_net_amount - already_booked_amount, item.precision("base_net_amount"))
|
||||
if account_currency==doc.company_currency:
|
||||
@ -128,15 +127,19 @@ def book_deferred_income_or_expense(doc, start_date=None, end_date=None):
|
||||
# book the expense/income on the last day, but it will be trigger on the 1st of month at 12:00 AM
|
||||
# start_date: 1st of the last month or the start date
|
||||
# end_date: end_date or today-1
|
||||
enable_check = "enable_deferred_revenue" \
|
||||
if doc.doctype=="Sales Invoice" else "enable_deferred_expense"
|
||||
|
||||
gl_entries = []
|
||||
for item in doc.get('items'):
|
||||
if not item.get(enable_check): continue
|
||||
|
||||
skip = False
|
||||
last_gl_entry, booking_start_date, booking_end_date, skip = \
|
||||
get_booking_dates(doc, item, start_date, end_date)
|
||||
|
||||
if skip: continue
|
||||
total_days = date_diff(item.service_end_date, item.service_start_date)
|
||||
total_days = date_diff(item.service_end_date, item.service_start_date) + 1
|
||||
total_booking_days = date_diff(booking_end_date, booking_start_date) + 1
|
||||
|
||||
account_currency = get_account_currency(item.expense_account)
|
||||
@ -175,6 +178,10 @@ def book_deferred_income_or_expense(doc, start_date=None, end_date=None):
|
||||
'project': project
|
||||
}, account_currency)
|
||||
)
|
||||
|
||||
if gl_entries:
|
||||
make_gl_entries(gl_entries, cancel=(doc.docstatus == 2), merge_entries=True)
|
||||
try:
|
||||
make_gl_entries(gl_entries, cancel=(doc.docstatus == 2), merge_entries=True)
|
||||
frappe.db.commit()
|
||||
except:
|
||||
frappe.db.rollback()
|
||||
frappe.log_error(message = frappe.get_traceback(), title = _("Error while processing deferred accounting for {0}").format(doc.name))
|
@ -171,7 +171,7 @@ class PaymentEntry(AccountsController):
|
||||
if not frappe.db.exists(self.party_type, self.party):
|
||||
frappe.throw(_("Invalid {0}: {1}").format(self.party_type, self.party))
|
||||
|
||||
if self.party_account:
|
||||
if self.party_account and self.party_type in ("Customer", "Supplier"):
|
||||
self.validate_account_type(self.party_account,
|
||||
[erpnext.get_party_account_type(self.party_type)])
|
||||
|
||||
@ -689,7 +689,7 @@ def get_party_details(company, party_type, party, date, cost_center=None):
|
||||
|
||||
account_currency = get_account_currency(party_account)
|
||||
account_balance = get_balance_on(party_account, date, cost_center=cost_center)
|
||||
_party_name = "title" if party_type == "Student" else party_type.lower() + "_name"
|
||||
_party_name = "title" if party_type in ("Student", "Shareholder") else party_type.lower() + "_name"
|
||||
party_name = frappe.db.get_value(party_type, party, _party_name)
|
||||
party_balance = get_balance_on(party_type=party_type, party=party, cost_center=cost_center)
|
||||
if party_type in ["Customer", "Supplier"]:
|
||||
|
@ -193,7 +193,7 @@ def get_invoice_po_pr_map(invoice_list):
|
||||
pi_items = frappe.db.sql("""
|
||||
select parent, purchase_order, purchase_receipt, po_detail, project
|
||||
from `tabPurchase Invoice Item`
|
||||
where parent in (%s) and (ifnull(purchase_order, '') != '' or ifnull(purchase_receipt, '') != '')
|
||||
where parent in (%s)
|
||||
""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
|
||||
invoice_po_pr_map = {}
|
||||
|
@ -1812,8 +1812,9 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "company.default_finance_book",
|
||||
"fieldname": "default_finance_book",
|
||||
"fieldtype": "Read Only",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@ -1824,12 +1825,12 @@
|
||||
"label": "Default Finance Book",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "company.default_finance_book",
|
||||
"options": "Finance Book",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -1882,7 +1883,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-01-15 16:12:48.314196",
|
||||
"modified": "2019-02-12 11:29:01.747819",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Assets",
|
||||
"name": "Asset",
|
||||
|
@ -1,12 +1,13 @@
|
||||
{
|
||||
"add_total_row": 0,
|
||||
"add_total_row": 1,
|
||||
"creation": "2018-10-05 16:08:24.156448",
|
||||
"disable_prepared_report": 0,
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 0,
|
||||
"is_standard": "Yes",
|
||||
"modified": "2018-10-05 16:08:33.272201",
|
||||
"modified": "2019-02-12 14:32:29.107109",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Purchase Analytics",
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
@ -55,7 +56,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "item_code",
|
||||
"fieldtype": "Read Only",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@ -71,7 +72,7 @@
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -707,7 +708,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-08-08 13:00:06.260997",
|
||||
"modified": "2019-02-12 11:37:18.713344",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Healthcare",
|
||||
"name": "Clinical Procedure Template",
|
||||
|
@ -19,7 +19,6 @@ frappe.ui.form.on('Employee Advance', {
|
||||
filters: {
|
||||
"root_type": "Asset",
|
||||
"is_group": 0,
|
||||
"account_type": "Payable",
|
||||
"company": frm.doc.company
|
||||
}
|
||||
};
|
||||
|
@ -195,7 +195,7 @@
|
||||
"columns": 0,
|
||||
"fetch_from": "employee.branch",
|
||||
"fieldname": "branch",
|
||||
"fieldtype": "Read Only",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@ -208,11 +208,11 @@
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "branch",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "",
|
||||
"options": "Branch",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -1906,7 +1906,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-01-30 11:28:11.774739",
|
||||
"modified": "2019-02-12 11:24:20.848207",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Salary Slip",
|
||||
|
@ -276,8 +276,8 @@ class ProductionPlan(Document):
|
||||
item_dict[(d.item_code, d.material_request_item, d.warehouse)] = item_details
|
||||
else:
|
||||
item_details.update({
|
||||
"qty":flt(item_dict.get((d.item_code, d.sales_order, d.warehouse),{})
|
||||
.get("qty")) + flt(d.planned_qty)
|
||||
"qty": flt(item_dict.get((d.item_code, d.sales_order, d.warehouse),{})
|
||||
.get("qty")) + (flt(d.planned_qty) - flt(d.ordered_qty))
|
||||
})
|
||||
item_dict[(d.item_code, d.sales_order, d.warehouse)] = item_details
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
{
|
||||
"add_total_row": 0,
|
||||
"add_total_row": 1,
|
||||
"creation": "2018-10-11 19:28:37.085066",
|
||||
"disable_prepared_report": 0,
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 0,
|
||||
"is_standard": "Yes",
|
||||
"letter_head": "",
|
||||
"modified": "2018-10-11 19:28:37.085066",
|
||||
"modified": "2019-02-12 14:32:16.392521",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Production Analytics",
|
||||
|
@ -585,3 +585,4 @@ erpnext.patches.v11_0.rename_additional_salary_component_additional_salary
|
||||
erpnext.patches.v11_0.renamed_from_to_fields_in_project
|
||||
erpnext.patches.v11_0.add_permissions_in_gst_settings
|
||||
erpnext.patches.v11_1.setup_guardian_role
|
||||
execute:frappe.delete_doc('DocType', 'Notification Control')
|
||||
|
@ -66,11 +66,11 @@ class Project(Document):
|
||||
|
||||
def validate(self):
|
||||
self.validate_project_name()
|
||||
self.validate_dates()
|
||||
self.validate_weights()
|
||||
self.sync_tasks()
|
||||
self.tasks = []
|
||||
self.load_tasks()
|
||||
self.validate_dates()
|
||||
self.send_welcome_email()
|
||||
self.update_percent_complete()
|
||||
|
||||
@ -79,6 +79,24 @@ class Project(Document):
|
||||
frappe.throw(_("Project {0} already exists").format(frappe.safe_decode(self.project_name)))
|
||||
|
||||
def validate_dates(self):
|
||||
if self.tasks:
|
||||
for d in self.tasks:
|
||||
if self.expected_start_date:
|
||||
if d.start_date and getdate(d.start_date) < getdate(self.expected_start_date):
|
||||
frappe.throw(_("Start date of task <b>{0}</b> cannot be less than <b>{1}</b> expected start date <b>{2}</b>")
|
||||
.format(d.title, self.name, self.expected_start_date))
|
||||
if d.end_date and getdate(d.end_date) < getdate(self.expected_start_date):
|
||||
frappe.throw(_("End date of task <b>{0}</b> cannot be less than <b>{1}</b> expected start date <b>{2}</b>")
|
||||
.format(d.title, self.name, self.expected_start_date))
|
||||
|
||||
if self.expected_end_date:
|
||||
if d.start_date and getdate(d.start_date) > getdate(self.expected_end_date):
|
||||
frappe.throw(_("Start date of task <b>{0}</b> cannot be greater than <b>{1}</b> expected end date <b>{2}</b>")
|
||||
.format(d.title, self.name, self.expected_end_date))
|
||||
if d.end_date and getdate(d.end_date) > getdate(self.expected_end_date):
|
||||
frappe.throw(_("End date of task <b>{0}</b> cannot be greater than <b>{1}</b> expected end date <b>{2}</b>")
|
||||
.format(d.title, self.name, self.expected_end_date))
|
||||
|
||||
if self.expected_start_date and self.expected_end_date:
|
||||
if getdate(self.expected_end_date) < getdate(self.expected_start_date):
|
||||
frappe.throw(_("Expected End Date can not be less than Expected Start Date"))
|
||||
|
@ -44,12 +44,6 @@ class Task(NestedSet):
|
||||
if self.act_start_date and self.act_end_date and getdate(self.act_start_date) > getdate(self.act_end_date):
|
||||
frappe.throw(_("'Actual Start Date' can not be greater than 'Actual End Date'"))
|
||||
|
||||
if(self.project):
|
||||
if frappe.db.exists("Project", self.project):
|
||||
expected_end_date = frappe.db.get_value("Project", self.project, "expected_end_date")
|
||||
if self.exp_end_date and expected_end_date and getdate(self.exp_end_date) > getdate(expected_end_date) :
|
||||
frappe.throw(_("Expected end date cannot be after Project: <b>'{0}'</b> Expected end date").format(self.project), EndDateCannotBeGreaterThanProjectEndDateError)
|
||||
|
||||
def validate_status(self):
|
||||
if self.status!=self.get_db_value("status") and self.status == "Closed":
|
||||
for d in self.depends_on:
|
||||
|
@ -5,7 +5,7 @@ import frappe
|
||||
import unittest
|
||||
from frappe.utils import getdate, nowdate, add_days
|
||||
|
||||
from erpnext.projects.doctype.task.task import CircularReferenceError, EndDateCannotBeGreaterThanProjectEndDateError
|
||||
from erpnext.projects.doctype.task.task import CircularReferenceError
|
||||
|
||||
class TestTask(unittest.TestCase):
|
||||
def test_circular_reference(self):
|
||||
@ -97,15 +97,6 @@ class TestTask(unittest.TestCase):
|
||||
|
||||
self.assertEqual(frappe.db.get_value("Task", task.name, "status"), "Overdue")
|
||||
|
||||
def test_end_date_validation(self):
|
||||
task_end = create_task("Testing_Enddate_validation", add_days(nowdate(), 35), add_days(nowdate(), 45), save=False)
|
||||
pro = frappe.get_doc("Project", task_end.project)
|
||||
pro.expected_end_date = add_days(nowdate(), 40)
|
||||
pro.save()
|
||||
self.assertRaises(EndDateCannotBeGreaterThanProjectEndDateError, task_end.save)
|
||||
|
||||
|
||||
|
||||
def create_task(subject, start=None, end=None, depends_on=None, project=None, save=True):
|
||||
if not frappe.db.exists("Task", subject):
|
||||
task = frappe.new_doc('Task')
|
||||
|
@ -18,7 +18,7 @@ frappe.ui.form.on("Timesheet", {
|
||||
return{
|
||||
filters: {
|
||||
'project': child.project,
|
||||
'status': ["!=", "Closed"]
|
||||
'status': ["!=", "Cancelled"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
{
|
||||
"add_total_row": 0,
|
||||
"add_total_row": 1,
|
||||
"creation": "2018-09-21 12:46:29.451048",
|
||||
"disable_prepared_report": 0,
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 0,
|
||||
"is_standard": "Yes",
|
||||
"modified": "2018-09-21 12:46:29.451048",
|
||||
"modified": "2019-02-12 14:30:40.043652",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Sales Analytics",
|
||||
|
@ -81,9 +81,9 @@ class MaterialRequest(BuyingController):
|
||||
|
||||
def set_title(self):
|
||||
'''Set title as comma separated list of items'''
|
||||
items = ', '.join([d.item_name for d in self.items][:4])
|
||||
|
||||
self.title = _('{0} for {1}'.format(self.material_request_type, items))[:100]
|
||||
if not self.title:
|
||||
items = ', '.join([d.item_name for d in self.items][:3])
|
||||
self.title = _('{0} Request for {1}').format(self.material_request_type, items)[:100]
|
||||
|
||||
def on_submit(self):
|
||||
# frappe.db.set(self, 'status', 'Submitted')
|
||||
|
@ -293,8 +293,9 @@ class StockEntry(StockController):
|
||||
total_completed_qty = flt(self.fg_completed_qty) + flt(prod_order.produced_qty)
|
||||
completed_qty = d.completed_qty + (allowance_percentage/100 * d.completed_qty)
|
||||
if total_completed_qty > flt(completed_qty):
|
||||
frappe.throw(_("Row #{0}: Operation {1} is not completed for {2} qty of finished goods in Work Order # {3}. Please update operation status via Time Logs")
|
||||
.format(d.idx, d.operation, total_completed_qty, self.work_order), OperationsNotCompleteError)
|
||||
job_card = frappe.db.get_value('Job Card', {'operation_id': d.name}, 'name')
|
||||
frappe.throw(_("Row #{0}: Operation {1} is not completed for {2} qty of finished goods in Work Order # {3}. Please update operation status via Job Card # {4}")
|
||||
.format(d.idx, d.operation, total_completed_qty, self.work_order, job_card), OperationsNotCompleteError)
|
||||
|
||||
def check_duplicate_entry_for_work_order(self):
|
||||
other_ste = [t[0] for t in frappe.db.get_values("Stock Entry", {
|
||||
@ -914,6 +915,11 @@ class StockEntry(StockController):
|
||||
filters={'parent': self.work_order, 'item_code': item_code},
|
||||
fields=["required_qty", "consumed_qty"]
|
||||
)
|
||||
if not req_items:
|
||||
frappe.msgprint(_("Did not found transfered item {0} in Work Order {1}, the item not added in Stock Entry")
|
||||
.format(item_code, self.work_order))
|
||||
continue
|
||||
|
||||
req_qty = flt(req_items[0].required_qty)
|
||||
req_qty_each = flt(req_qty / manufacturing_qty)
|
||||
consumed_qty = flt(req_items[0].consumed_qty)
|
||||
|
@ -259,6 +259,7 @@ class StockReconciliation(StockController):
|
||||
|
||||
def submit(self):
|
||||
if len(self.items) > 100:
|
||||
msgprint(_("The task has been enqueued as a background job. In case there is any issue on processing in background, the system will add a comment about the error on this Stock Reconciliation and revert to the Draft stage"))
|
||||
self.queue_action('submit')
|
||||
else:
|
||||
self._submit()
|
||||
|
@ -1,12 +1,13 @@
|
||||
{
|
||||
"add_total_row": 0,
|
||||
"add_total_row": 1,
|
||||
"creation": "2018-10-08 12:11:32.133020",
|
||||
"disable_prepared_report": 0,
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 0,
|
||||
"is_standard": "Yes",
|
||||
"modified": "2018-10-08 12:18:42.834270",
|
||||
"modified": "2019-02-12 14:32:22.874082",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Stock Analytics",
|
||||
|
Loading…
x
Reference in New Issue
Block a user