mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-18 20:49:19 +00:00
Merge branch 'version-13-hotfix' into redisearch-app-install-v13
This commit is contained in:
@@ -2,6 +2,17 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Contract", {
|
frappe.ui.form.on("Contract", {
|
||||||
|
onload: function(frm) {
|
||||||
|
frappe.db.get_value(
|
||||||
|
"Selling Settings",
|
||||||
|
"Selling Settings",
|
||||||
|
"contract_naming_by",
|
||||||
|
(r) => {
|
||||||
|
frm.toggle_display("naming_series", r.contract_naming_by === "Naming Series");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
contract_template: function (frm) {
|
contract_template: function (frm) {
|
||||||
if (frm.doc.contract_template) {
|
if (frm.doc.contract_template) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
"actions": [],
|
"actions": [],
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
|
"autoname": "naming_series:",
|
||||||
"creation": "2018-04-12 06:32:04.582486",
|
"creation": "2018-04-12 06:32:04.582486",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
|
"naming_series",
|
||||||
"party_type",
|
"party_type",
|
||||||
"is_signed",
|
"is_signed",
|
||||||
"cb_party",
|
"cb_party",
|
||||||
@@ -244,11 +246,20 @@
|
|||||||
"fieldname": "authorised_by_section",
|
"fieldname": "authorised_by_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Authorised By"
|
"label": "Authorised By"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "naming_series",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Naming Series",
|
||||||
|
"no_copy": 1,
|
||||||
|
"options": "CRM-CONTR-.YYYY.-",
|
||||||
|
"reqd": 1,
|
||||||
|
"set_only_once": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-12-07 11:15:58.385521",
|
"modified": "2022-03-28 10:22:11.156658",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "CRM",
|
"module": "CRM",
|
||||||
"name": "Contract",
|
"name": "Contract",
|
||||||
|
|||||||
@@ -5,22 +5,32 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.model.naming import set_name_by_naming_series
|
||||||
from frappe.utils import getdate, nowdate
|
from frappe.utils import getdate, nowdate
|
||||||
|
|
||||||
|
|
||||||
class Contract(Document):
|
class Contract(Document):
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
name = self.party_name
|
if frappe.db.get_single_value("Selling Settings", "contract_naming_by") == "Naming Series":
|
||||||
|
set_name_by_naming_series(self)
|
||||||
|
|
||||||
if self.contract_template:
|
else:
|
||||||
name += " - {} Agreement".format(self.contract_template)
|
name = self.party_name
|
||||||
|
|
||||||
# If identical, append contract name with the next number in the iteration
|
if self.contract_template:
|
||||||
if frappe.db.exists("Contract", name):
|
name = f"{name} - {self.contract_template} Agreement"
|
||||||
count = len(frappe.get_all("Contract", filters={"name": ["like", "%{}%".format(name)]}))
|
|
||||||
name = "{} - {}".format(name, count)
|
|
||||||
|
|
||||||
self.name = _(name)
|
# If identical, append contract name with the next number in the iteration
|
||||||
|
if frappe.db.exists("Contract", name):
|
||||||
|
count = frappe.db.count(
|
||||||
|
"Contract",
|
||||||
|
filters={
|
||||||
|
"name": ("like", f"%{name}%"),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
name = f"{name} - {count}"
|
||||||
|
|
||||||
|
self.name = _(name)
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_dates()
|
self.validate_dates()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div class="web-list-item transaction-list-item">
|
<div class="web-list-item transaction-list-item">
|
||||||
{% set today = frappe.utils.getdate(frappe.utils.nowdate()) %}
|
{% set today = frappe.utils.getdate(frappe.utils.nowdate()) %}
|
||||||
<a href = "{{ doc.route }}/" class="no-underline">
|
<a href = "{{ doc.route }}" class="no-underline">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-4 bold">
|
<div class="col-sm-4 bold">
|
||||||
<span class="indicator
|
<span class="indicator
|
||||||
|
|||||||
@@ -735,9 +735,9 @@ def get_number_of_leave_days(
|
|||||||
(Based on the include_holiday setting in Leave Type)"""
|
(Based on the include_holiday setting in Leave Type)"""
|
||||||
number_of_days = 0
|
number_of_days = 0
|
||||||
if cint(half_day) == 1:
|
if cint(half_day) == 1:
|
||||||
if from_date == to_date:
|
if getdate(from_date) == getdate(to_date):
|
||||||
number_of_days = 0.5
|
number_of_days = 0.5
|
||||||
elif half_day_date and half_day_date <= to_date:
|
elif half_day_date and getdate(from_date) <= getdate(half_day_date) <= getdate(to_date):
|
||||||
number_of_days = date_diff(to_date, from_date) + 0.5
|
number_of_days = date_diff(to_date, from_date) + 0.5
|
||||||
else:
|
else:
|
||||||
number_of_days = date_diff(to_date, from_date) + 1
|
number_of_days = date_diff(to_date, from_date) + 1
|
||||||
|
|||||||
@@ -205,7 +205,12 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
# creates separate leave ledger entries
|
# creates separate leave ledger entries
|
||||||
frappe.delete_doc_if_exists("Leave Type", "Test Leave Validation", force=1)
|
frappe.delete_doc_if_exists("Leave Type", "Test Leave Validation", force=1)
|
||||||
leave_type = frappe.get_doc(
|
leave_type = frappe.get_doc(
|
||||||
dict(leave_type_name="Test Leave Validation", doctype="Leave Type", allow_negative=True)
|
dict(
|
||||||
|
leave_type_name="Test Leave Validation",
|
||||||
|
doctype="Leave Type",
|
||||||
|
allow_negative=True,
|
||||||
|
include_holiday=True,
|
||||||
|
)
|
||||||
).insert()
|
).insert()
|
||||||
|
|
||||||
employee = get_employee()
|
employee = get_employee()
|
||||||
@@ -217,8 +222,14 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
# application across allocations
|
# application across allocations
|
||||||
|
|
||||||
# CASE 1: from date has no allocation, to date has an allocation / both dates have allocation
|
# CASE 1: from date has no allocation, to date has an allocation / both dates have allocation
|
||||||
|
start_date = add_days(year_start, -10)
|
||||||
application = make_leave_application(
|
application = make_leave_application(
|
||||||
employee.name, add_days(year_start, -10), add_days(year_start, 3), leave_type.name
|
employee.name,
|
||||||
|
start_date,
|
||||||
|
add_days(year_start, 3),
|
||||||
|
leave_type.name,
|
||||||
|
half_day=1,
|
||||||
|
half_day_date=start_date,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2 separate leave ledger entries
|
# 2 separate leave ledger entries
|
||||||
@@ -827,6 +838,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
leave_type_name="_Test_CF_leave_expiry",
|
leave_type_name="_Test_CF_leave_expiry",
|
||||||
is_carry_forward=1,
|
is_carry_forward=1,
|
||||||
expire_carry_forwarded_leaves_after_days=90,
|
expire_carry_forwarded_leaves_after_days=90,
|
||||||
|
include_holiday=True,
|
||||||
)
|
)
|
||||||
leave_type.submit()
|
leave_type.submit()
|
||||||
|
|
||||||
@@ -839,6 +851,8 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
leave_type=leave_type.name,
|
leave_type=leave_type.name,
|
||||||
from_date=add_days(nowdate(), -3),
|
from_date=add_days(nowdate(), -3),
|
||||||
to_date=add_days(nowdate(), 7),
|
to_date=add_days(nowdate(), 7),
|
||||||
|
half_day=1,
|
||||||
|
half_day_date=add_days(nowdate(), -3),
|
||||||
description="_Test Reason",
|
description="_Test Reason",
|
||||||
company="_Test Company",
|
company="_Test Company",
|
||||||
docstatus=1,
|
docstatus=1,
|
||||||
@@ -854,7 +868,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
self.assertEqual(len(leave_ledger_entry), 2)
|
self.assertEqual(len(leave_ledger_entry), 2)
|
||||||
self.assertEqual(leave_ledger_entry[0].employee, leave_application.employee)
|
self.assertEqual(leave_ledger_entry[0].employee, leave_application.employee)
|
||||||
self.assertEqual(leave_ledger_entry[0].leave_type, leave_application.leave_type)
|
self.assertEqual(leave_ledger_entry[0].leave_type, leave_application.leave_type)
|
||||||
self.assertEqual(leave_ledger_entry[0].leaves, -9)
|
self.assertEqual(leave_ledger_entry[0].leaves, -8.5)
|
||||||
self.assertEqual(leave_ledger_entry[1].leaves, -2)
|
self.assertEqual(leave_ledger_entry[1].leaves, -2)
|
||||||
|
|
||||||
def test_leave_application_creation_after_expiry(self):
|
def test_leave_application_creation_after_expiry(self):
|
||||||
|
|||||||
@@ -747,5 +747,8 @@ def calculate_amounts(against_loan, posting_date, payment_type=""):
|
|||||||
amounts["payable_principal_amount"] = amounts["pending_principal_amount"]
|
amounts["payable_principal_amount"] = amounts["pending_principal_amount"]
|
||||||
amounts["interest_amount"] += amounts["unaccrued_interest"]
|
amounts["interest_amount"] += amounts["unaccrued_interest"]
|
||||||
amounts["payable_amount"] = amounts["payable_principal_amount"] + amounts["interest_amount"]
|
amounts["payable_amount"] = amounts["payable_principal_amount"] + amounts["interest_amount"]
|
||||||
|
amounts["payable_amount"] = (
|
||||||
|
amounts["payable_principal_amount"] + amounts["interest_amount"] + amounts["penalty_amount"]
|
||||||
|
)
|
||||||
|
|
||||||
return amounts
|
return amounts
|
||||||
|
|||||||
@@ -1294,7 +1294,16 @@ def create_additional_salary(employee, payroll_period, amount):
|
|||||||
return salary_date
|
return salary_date
|
||||||
|
|
||||||
|
|
||||||
def make_leave_application(employee, from_date, to_date, leave_type, company=None, submit=True):
|
def make_leave_application(
|
||||||
|
employee,
|
||||||
|
from_date,
|
||||||
|
to_date,
|
||||||
|
leave_type,
|
||||||
|
company=None,
|
||||||
|
half_day=False,
|
||||||
|
half_day_date=None,
|
||||||
|
submit=True,
|
||||||
|
):
|
||||||
leave_application = frappe.get_doc(
|
leave_application = frappe.get_doc(
|
||||||
dict(
|
dict(
|
||||||
doctype="Leave Application",
|
doctype="Leave Application",
|
||||||
@@ -1302,6 +1311,8 @@ def make_leave_application(employee, from_date, to_date, leave_type, company=Non
|
|||||||
leave_type=leave_type,
|
leave_type=leave_type,
|
||||||
from_date=from_date,
|
from_date=from_date,
|
||||||
to_date=to_date,
|
to_date=to_date,
|
||||||
|
half_day=half_day,
|
||||||
|
half_day_date=half_day_date,
|
||||||
company=company or erpnext.get_default_company() or "_Test Company",
|
company=company or erpnext.get_default_company() or "_Test Company",
|
||||||
status="Approved",
|
status="Approved",
|
||||||
leave_approver="test@example.com",
|
leave_approver="test@example.com",
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
"territory",
|
"territory",
|
||||||
"crm_settings_section",
|
"crm_settings_section",
|
||||||
"campaign_naming_by",
|
"campaign_naming_by",
|
||||||
|
"contract_naming_by",
|
||||||
"default_valid_till",
|
"default_valid_till",
|
||||||
"column_break_9",
|
"column_break_9",
|
||||||
"close_opportunity_after_days",
|
"close_opportunity_after_days",
|
||||||
@@ -29,7 +30,6 @@
|
|||||||
"so_required",
|
"so_required",
|
||||||
"dn_required",
|
"dn_required",
|
||||||
"sales_update_frequency",
|
"sales_update_frequency",
|
||||||
"column_break_5",
|
|
||||||
"allow_multiple_items",
|
"allow_multiple_items",
|
||||||
"allow_against_multiple_purchase_orders",
|
"allow_against_multiple_purchase_orders",
|
||||||
"hide_tax_id"
|
"hide_tax_id"
|
||||||
@@ -193,6 +193,12 @@
|
|||||||
"fieldname": "sales_transactions_settings_section",
|
"fieldname": "sales_transactions_settings_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Transaction Settings"
|
"label": "Transaction Settings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "contract_naming_by",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Contract Naming By",
|
||||||
|
"options": "Party Name\nNaming Series"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-cog",
|
"icon": "fa fa-cog",
|
||||||
@@ -200,7 +206,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-09-14 22:05:06.139820",
|
"modified": "2022-03-28 12:18:06.768403",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Selling Settings",
|
"name": "Selling Settings",
|
||||||
@@ -219,4 +225,4 @@
|
|||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
@@ -1,109 +1,42 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
"actions": [],
|
||||||
"allow_events_in_timeline": 0,
|
"autoname": "hash",
|
||||||
"allow_guest_to_view": 0,
|
"creation": "2022-02-11 11:26:22.155183",
|
||||||
"allow_import": 0,
|
"doctype": "DocType",
|
||||||
"allow_rename": 0,
|
"engine": "InnoDB",
|
||||||
"autoname": "field:barcode",
|
"field_order": [
|
||||||
"beta": 0,
|
"barcode",
|
||||||
"creation": "2017-12-09 18:54:50.562438",
|
"barcode_type"
|
||||||
"custom": 0,
|
],
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "DocType",
|
|
||||||
"document_type": "",
|
|
||||||
"editable_grid": 1,
|
|
||||||
"engine": "InnoDB",
|
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"fieldname": "barcode",
|
||||||
"allow_in_quick_entry": 0,
|
"fieldtype": "Data",
|
||||||
"allow_on_submit": 0,
|
"in_global_search": 1,
|
||||||
"bold": 0,
|
"in_list_view": 1,
|
||||||
"collapsible": 0,
|
"label": "Barcode",
|
||||||
"columns": 0,
|
"no_copy": 1,
|
||||||
"fieldname": "barcode",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 1,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Barcode",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 1
|
"unique": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"fieldname": "barcode_type",
|
||||||
"allow_in_quick_entry": 0,
|
"fieldtype": "Select",
|
||||||
"allow_on_submit": 0,
|
"in_list_view": 1,
|
||||||
"bold": 0,
|
"label": "Barcode Type",
|
||||||
"collapsible": 0,
|
"options": "\nEAN\nUPC-A"
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "barcode_type",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Barcode Type",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "\nEAN\nUPC-A",
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
"istable": 1,
|
||||||
"hide_heading": 0,
|
"links": [],
|
||||||
"hide_toolbar": 0,
|
"modified": "2022-04-01 05:54:27.314030",
|
||||||
"idx": 0,
|
"modified_by": "Administrator",
|
||||||
"image_view": 0,
|
"module": "Stock",
|
||||||
"in_create": 0,
|
"name": "Item Barcode",
|
||||||
"is_submittable": 0,
|
"naming_rule": "Random",
|
||||||
"issingle": 0,
|
"owner": "Administrator",
|
||||||
"istable": 1,
|
"permissions": [],
|
||||||
"max_attachments": 0,
|
"sort_field": "modified",
|
||||||
"modified": "2018-11-13 06:03:09.814357",
|
"sort_order": "DESC",
|
||||||
"modified_by": "Administrator",
|
"states": [],
|
||||||
"module": "Stock",
|
"track_changes": 1
|
||||||
"name": "Item Barcode",
|
|
||||||
"name_case": "",
|
|
||||||
"owner": "Administrator",
|
|
||||||
"permissions": [],
|
|
||||||
"quick_entry": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"read_only_onload": 0,
|
|
||||||
"show_name_in_global_search": 0,
|
|
||||||
"sort_field": "modified",
|
|
||||||
"sort_order": "DESC",
|
|
||||||
"track_changes": 1,
|
|
||||||
"track_seen": 0,
|
|
||||||
"track_views": 0
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user