mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-31 10:52:41 +02: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 frappe.utils import getdate
|
||||
|
||||
__version__ = '12.9.1'
|
||||
__version__ = '12.9.2'
|
||||
|
||||
def get_default_company(user=None):
|
||||
'''Get default company for user'''
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cint
|
||||
from frappe.utils import cint, flt
|
||||
from frappe import _
|
||||
|
||||
from frappe.model.document import Document
|
||||
@@ -11,11 +11,11 @@ from frappe.model.document import Document
|
||||
class AppraisalTemplate(Document):
|
||||
def validate(self):
|
||||
self.check_total_points()
|
||||
|
||||
def check_total_points(self):
|
||||
|
||||
def check_total_points(self):
|
||||
total_points = 0
|
||||
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:
|
||||
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
|
||||
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.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
|
||||
|
||||
@@ -6,6 +6,7 @@ import frappe
|
||||
|
||||
def execute():
|
||||
"""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"):
|
||||
return
|
||||
|
||||
@@ -14,31 +15,32 @@ def execute():
|
||||
|
||||
def get_duplicate_records():
|
||||
"""Fetch all but one duplicate records from the list of expired leave allocation."""
|
||||
return frappe.db.sql_list("""
|
||||
WITH duplicate_records AS
|
||||
(SELECT
|
||||
name, transaction_name, is_carry_forward,
|
||||
ROW_NUMBER() over(partition by transaction_name order by creation)as row
|
||||
FROM `tabLeave Ledger Entry` l
|
||||
WHERE (EXISTS
|
||||
(SELECT name
|
||||
FROM `tabLeave Ledger Entry`
|
||||
WHERE
|
||||
transaction_name = l.transaction_name
|
||||
AND transaction_type = 'Leave Allocation'
|
||||
AND name <> l.name
|
||||
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
|
||||
return frappe.db.sql("""
|
||||
SELECT name, employee, transaction_name, leave_type, is_carry_forward, from_date, to_date
|
||||
FROM `tabLeave Ledger Entry`
|
||||
WHERE
|
||||
transaction_type = 'Leave Allocation'
|
||||
AND docstatus = 1
|
||||
AND is_expired = 1
|
||||
GROUP BY
|
||||
employee, transaction_name, leave_type, is_carry_forward, from_date, to_date
|
||||
HAVING
|
||||
count(name) > 1
|
||||
ORDER BY
|
||||
creation
|
||||
""")
|
||||
|
||||
def delete_duplicate_ledger_entries(duplicate_records_list):
|
||||
"""Delete duplicate leave ledger entries."""
|
||||
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():
|
||||
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`
|
||||
where (status is NULL OR status='')""", as_dict = 1):
|
||||
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)
|
||||
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"):
|
||||
status = "Delivered"
|
||||
elif serial_no.get("warranty_expiry_date") and getdate(serial_no.get("warranty_expiry_date")) <= getdate(nowdate()):
|
||||
status = "Expired"
|
||||
elif not serial_no.get("warehouse"):
|
||||
status = "Inactive"
|
||||
else:
|
||||
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
|
||||
import frappe
|
||||
|
||||
|
||||
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 = '')"""
|
||||
)
|
||||
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 = '')"""
|
||||
)
|
||||
docs_to_modify = invalid_buying_item_price + invalid_selling_item_price
|
||||
for d in docs_to_modify:
|
||||
# saving the doc will auto reset invalid customer/supplier field
|
||||
doc = frappe.get_doc("Item Price", d[0])
|
||||
doc.save()
|
||||
"""
|
||||
set proper customer and supplier details for item price
|
||||
based on selling and buying values
|
||||
"""
|
||||
|
||||
# update for selling
|
||||
frappe.db.sql(
|
||||
"""UPDATE `tabItem Price` ip, `tabPrice List` pl
|
||||
SET ip.`reference` = ip.`customer`, ip.`supplier` = NULL
|
||||
WHERE ip.`selling` = 1
|
||||
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",
|
||||
"in_standard_filter": 1,
|
||||
"label": "Status",
|
||||
"options": "\nActive\nDelivered\nExpired",
|
||||
"options": "\nActive\nInactive\nDelivered\nExpired",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-barcode",
|
||||
"idx": 1,
|
||||
"links": [],
|
||||
"modified": "2020-04-08 13:29:58.517772",
|
||||
"modified": "2020-05-21 19:29:58.517772",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Serial No",
|
||||
|
||||
@@ -42,6 +42,8 @@ class SerialNo(StockController):
|
||||
self.status = "Delivered"
|
||||
elif self.warranty_expiry_date and getdate(self.warranty_expiry_date) <= getdate(nowdate()):
|
||||
self.status = "Expired"
|
||||
elif not self.warehouse:
|
||||
self.status = "Inactive"
|
||||
else:
|
||||
self.status = "Active"
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ frappe.listview_settings['Serial No'] = {
|
||||
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) {
|
||||
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 {
|
||||
return [__("Active"), "green", "delivery_document_type,is,not set"];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user