mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 18:04:46 +00:00
Merge branch 'v12-pre-release' into version-12
This commit is contained in:
@@ -5,7 +5,7 @@ import frappe
|
|||||||
from erpnext.hooks import regional_overrides
|
from erpnext.hooks import regional_overrides
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
|
|
||||||
__version__ = '12.9.1'
|
__version__ = '12.9.2'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint, flt
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
@@ -11,11 +11,11 @@ from frappe.model.document import Document
|
|||||||
class AppraisalTemplate(Document):
|
class AppraisalTemplate(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.check_total_points()
|
self.check_total_points()
|
||||||
|
|
||||||
def check_total_points(self):
|
def check_total_points(self):
|
||||||
total_points = 0
|
total_points = 0
|
||||||
for d in self.get("goals"):
|
for d in self.get("goals"):
|
||||||
total_points += int(d.per_weightage or 0)
|
total_points += flt(d.per_weightage)
|
||||||
|
|
||||||
if cint(total_points) != 100:
|
if cint(total_points) != 100:
|
||||||
frappe.throw(_("Sum of points for all goals should be 100. It is {0}").format(total_points))
|
frappe.throw(_("Sum of points for all goals should be 100. It is {0}").format(total_points))
|
||||||
|
|||||||
@@ -665,5 +665,5 @@ erpnext.patches.v13_0.move_tax_slabs_from_payroll_period_to_income_tax_slab #123
|
|||||||
erpnext.patches.v12_0.remove_duplicate_leave_ledger_entries
|
erpnext.patches.v12_0.remove_duplicate_leave_ledger_entries
|
||||||
execute:frappe.delete_doc_if_exists("Page", "appointment-analytic")
|
execute:frappe.delete_doc_if_exists("Page", "appointment-analytic")
|
||||||
erpnext.patches.v12_0.unset_customer_supplier_based_on_type_of_item_price
|
erpnext.patches.v12_0.unset_customer_supplier_based_on_type_of_item_price
|
||||||
erpnext.patches.v12_0.set_serial_no_status
|
erpnext.patches.v12_0.set_serial_no_status #2020-05-21
|
||||||
erpnext.patches.v12_0.update_price_list_currency_in_bom
|
erpnext.patches.v12_0.update_price_list_currency_in_bom
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import frappe
|
|||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
"""Delete duplicate leave ledger entries of type allocation created."""
|
"""Delete duplicate leave ledger entries of type allocation created."""
|
||||||
|
frappe.reload_doc('hr', 'doctype', 'leave_ledger_entry')
|
||||||
if not frappe.db.a_row_exists("Leave Ledger Entry"):
|
if not frappe.db.a_row_exists("Leave Ledger Entry"):
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -14,31 +15,32 @@ def execute():
|
|||||||
|
|
||||||
def get_duplicate_records():
|
def get_duplicate_records():
|
||||||
"""Fetch all but one duplicate records from the list of expired leave allocation."""
|
"""Fetch all but one duplicate records from the list of expired leave allocation."""
|
||||||
return frappe.db.sql_list("""
|
return frappe.db.sql("""
|
||||||
WITH duplicate_records AS
|
SELECT name, employee, transaction_name, leave_type, is_carry_forward, from_date, to_date
|
||||||
(SELECT
|
FROM `tabLeave Ledger Entry`
|
||||||
name, transaction_name, is_carry_forward,
|
WHERE
|
||||||
ROW_NUMBER() over(partition by transaction_name order by creation)as row
|
transaction_type = 'Leave Allocation'
|
||||||
FROM `tabLeave Ledger Entry` l
|
AND docstatus = 1
|
||||||
WHERE (EXISTS
|
AND is_expired = 1
|
||||||
(SELECT name
|
GROUP BY
|
||||||
FROM `tabLeave Ledger Entry`
|
employee, transaction_name, leave_type, is_carry_forward, from_date, to_date
|
||||||
WHERE
|
HAVING
|
||||||
transaction_name = l.transaction_name
|
count(name) > 1
|
||||||
AND transaction_type = 'Leave Allocation'
|
ORDER BY
|
||||||
AND name <> l.name
|
creation
|
||||||
AND employee = l.employee
|
|
||||||
AND docstatus = 1
|
|
||||||
AND leave_type = l.leave_type
|
|
||||||
AND is_carry_forward=l.is_carry_forward
|
|
||||||
AND to_date = l.to_date
|
|
||||||
AND from_date = l.from_date
|
|
||||||
AND is_expired = 1
|
|
||||||
)))
|
|
||||||
SELECT name FROM duplicate_records WHERE row > 1
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
def delete_duplicate_ledger_entries(duplicate_records_list):
|
def delete_duplicate_ledger_entries(duplicate_records_list):
|
||||||
"""Delete duplicate leave ledger entries."""
|
"""Delete duplicate leave ledger entries."""
|
||||||
if not duplicate_records_list: return
|
if not duplicate_records_list: return
|
||||||
frappe.db.sql('''DELETE FROM `tabLeave Ledger Entry` WHERE name in %s''', ((tuple(duplicate_records_list)), ))
|
for d in duplicate_records_list:
|
||||||
|
frappe.db.sql('''
|
||||||
|
DELETE FROM `tabLeave Ledger Entry`
|
||||||
|
WHERE name != %s
|
||||||
|
AND employee = %s
|
||||||
|
AND transaction_name = %s
|
||||||
|
AND leave_type = %s
|
||||||
|
AND is_carry_forward = %s
|
||||||
|
AND from_date = %s
|
||||||
|
AND to_date = %s
|
||||||
|
''', tuple(d))
|
||||||
|
|||||||
@@ -5,13 +5,22 @@ from frappe.utils import getdate, nowdate
|
|||||||
def execute():
|
def execute():
|
||||||
frappe.reload_doc('stock', 'doctype', 'serial_no')
|
frappe.reload_doc('stock', 'doctype', 'serial_no')
|
||||||
|
|
||||||
for serial_no in frappe.db.sql("""select name, delivery_document_type, warranty_expiry_date from `tabSerial No`
|
serial_no_list = frappe.db.sql("""select name, delivery_document_type, warranty_expiry_date, warehouse from `tabSerial No`
|
||||||
where (status is NULL OR status='')""", as_dict = 1):
|
where (status is NULL OR status='')""", as_dict = 1)
|
||||||
|
if len(serial_no_list) > 20000:
|
||||||
|
frappe.db.auto_commit_on_many_writes = True
|
||||||
|
|
||||||
|
for serial_no in serial_no_list:
|
||||||
if serial_no.get("delivery_document_type"):
|
if serial_no.get("delivery_document_type"):
|
||||||
status = "Delivered"
|
status = "Delivered"
|
||||||
elif serial_no.get("warranty_expiry_date") and getdate(serial_no.get("warranty_expiry_date")) <= getdate(nowdate()):
|
elif serial_no.get("warranty_expiry_date") and getdate(serial_no.get("warranty_expiry_date")) <= getdate(nowdate()):
|
||||||
status = "Expired"
|
status = "Expired"
|
||||||
|
elif not serial_no.get("warehouse"):
|
||||||
|
status = "Inactive"
|
||||||
else:
|
else:
|
||||||
status = "Active"
|
status = "Active"
|
||||||
|
|
||||||
frappe.db.set_value("Serial No", serial_no.get("name"), "status", status)
|
frappe.db.set_value("Serial No", serial_no.get("name"), "status", status)
|
||||||
|
|
||||||
|
if frappe.db.auto_commit_on_many_writes:
|
||||||
|
frappe.db.auto_commit_on_many_writes = False
|
||||||
|
|||||||
@@ -1,15 +1,29 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
invalid_selling_item_price = frappe.db.sql(
|
"""
|
||||||
"""SELECT name FROM `tabItem Price` WHERE selling = 1 and buying = 0 and (supplier IS NOT NULL or supplier = '')"""
|
set proper customer and supplier details for item price
|
||||||
)
|
based on selling and buying values
|
||||||
invalid_buying_item_price = frappe.db.sql(
|
"""
|
||||||
"""SELECT name FROM `tabItem Price` WHERE selling = 0 and buying = 1 and (customer IS NOT NULL or customer = '')"""
|
|
||||||
)
|
# update for selling
|
||||||
docs_to_modify = invalid_buying_item_price + invalid_selling_item_price
|
frappe.db.sql(
|
||||||
for d in docs_to_modify:
|
"""UPDATE `tabItem Price` ip, `tabPrice List` pl
|
||||||
# saving the doc will auto reset invalid customer/supplier field
|
SET ip.`reference` = ip.`customer`, ip.`supplier` = NULL
|
||||||
doc = frappe.get_doc("Item Price", d[0])
|
WHERE ip.`selling` = 1
|
||||||
doc.save()
|
AND ip.`buying` = 0
|
||||||
|
AND (ip.`supplier` IS NOT NULL OR ip.`supplier` = '')
|
||||||
|
AND ip.`price_list` = pl.`name`
|
||||||
|
AND pl.`enabled` = 1""")
|
||||||
|
|
||||||
|
# update for buying
|
||||||
|
frappe.db.sql(
|
||||||
|
"""UPDATE `tabItem Price` ip, `tabPrice List` pl
|
||||||
|
SET ip.`reference` = ip.`supplier`, ip.`customer` = NULL
|
||||||
|
WHERE ip.`selling` = 0
|
||||||
|
AND ip.`buying` = 1
|
||||||
|
AND (ip.`customer` IS NOT NULL OR ip.`customer` = '')
|
||||||
|
AND ip.`price_list` = pl.`name`
|
||||||
|
AND pl.`enabled` = 1""")
|
||||||
|
|||||||
@@ -420,14 +420,14 @@
|
|||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Status",
|
"label": "Status",
|
||||||
"options": "\nActive\nDelivered\nExpired",
|
"options": "\nActive\nInactive\nDelivered\nExpired",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-barcode",
|
"icon": "fa fa-barcode",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-04-08 13:29:58.517772",
|
"modified": "2020-05-21 19:29:58.517772",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Serial No",
|
"name": "Serial No",
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ class SerialNo(StockController):
|
|||||||
self.status = "Delivered"
|
self.status = "Delivered"
|
||||||
elif self.warranty_expiry_date and getdate(self.warranty_expiry_date) <= getdate(nowdate()):
|
elif self.warranty_expiry_date and getdate(self.warranty_expiry_date) <= getdate(nowdate()):
|
||||||
self.status = "Expired"
|
self.status = "Expired"
|
||||||
|
elif not self.warehouse:
|
||||||
|
self.status = "Inactive"
|
||||||
else:
|
else:
|
||||||
self.status = "Active"
|
self.status = "Active"
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ frappe.listview_settings['Serial No'] = {
|
|||||||
return [__("Delivered"), "green", "delivery_document_type,is,set"];
|
return [__("Delivered"), "green", "delivery_document_type,is,set"];
|
||||||
} else if (doc.warranty_expiry_date && frappe.datetime.get_diff(doc.warranty_expiry_date, frappe.datetime.nowdate()) <= 0) {
|
} else if (doc.warranty_expiry_date && frappe.datetime.get_diff(doc.warranty_expiry_date, frappe.datetime.nowdate()) <= 0) {
|
||||||
return [__("Expired"), "red", "warranty_expiry_date,not in,|warranty_expiry_date,<=,Today|delivery_document_type,is,not set"];
|
return [__("Expired"), "red", "warranty_expiry_date,not in,|warranty_expiry_date,<=,Today|delivery_document_type,is,not set"];
|
||||||
|
} else if (!doc.warehouse) {
|
||||||
|
return [__("Inactive"), "grey", "warehouse,is,not set"];
|
||||||
} else {
|
} else {
|
||||||
return [__("Active"), "green", "delivery_document_type,is,not set"];
|
return [__("Active"), "green", "delivery_document_type,is,not set"];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user