mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 15:39:20 +00:00
feat: configurable Contract naming
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,27 @@
|
|||||||
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 += " - {} Agreement".format(self.contract_template)
|
||||||
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 = len(frappe.get_all("Contract", filters={"name": ["like", "%{}%".format(name)]}))
|
||||||
|
name = "{} - {}".format(name, count)
|
||||||
|
|
||||||
|
self.name = _(name)
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_dates()
|
self.validate_dates()
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user