mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
Merge branch 'develop' into handle_large_outstanding_invoices_code_refactored
This commit is contained in:
@@ -8,6 +8,10 @@ frappe.ui.form.on("POS Profile", "onload", function(frm) {
|
|||||||
return { filters: { selling: 1 } };
|
return { filters: { selling: 1 } };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("tc_name", function() {
|
||||||
|
return { filters: { selling: 1 } };
|
||||||
|
});
|
||||||
|
|
||||||
erpnext.queries.setup_queries(frm, "Warehouse", function() {
|
erpnext.queries.setup_queries(frm, "Warehouse", function() {
|
||||||
return erpnext.queries.warehouse(frm.doc);
|
return erpnext.queries.warehouse(frm.doc);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -337,7 +337,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
if not self.is_return:
|
if not self.is_return:
|
||||||
self.update_against_document_in_jv()
|
self.update_against_document_in_jv()
|
||||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||||
self.update_billing_status_in_pr()
|
|
||||||
|
self.update_billing_status_in_pr()
|
||||||
|
|
||||||
# Updating stock ledger should always be called after updating prevdoc status,
|
# Updating stock ledger should always be called after updating prevdoc status,
|
||||||
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
||||||
@@ -485,9 +486,13 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"credit": flt(item.rm_supp_cost)
|
"credit": flt(item.rm_supp_cost)
|
||||||
}, warehouse_account[self.supplier_warehouse]["account_currency"], item=item))
|
}, warehouse_account[self.supplier_warehouse]["account_currency"], item=item))
|
||||||
elif not item.is_fixed_asset or (item.is_fixed_asset and is_cwip_accounting_disabled()):
|
elif not item.is_fixed_asset or (item.is_fixed_asset and is_cwip_accounting_disabled()):
|
||||||
|
|
||||||
|
expense_account = (item.expense_account
|
||||||
|
if (not item.enable_deferred_expense or self.is_return) else item.deferred_expense_account)
|
||||||
|
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": item.expense_account if not item.enable_deferred_expense else item.deferred_expense_account,
|
"account": expense_account,
|
||||||
"against": self.supplier,
|
"against": self.supplier,
|
||||||
"debit": flt(item.base_net_amount, item.precision("base_net_amount")),
|
"debit": flt(item.base_net_amount, item.precision("base_net_amount")),
|
||||||
"debit_in_account_currency": (flt(item.base_net_amount,
|
"debit_in_account_currency": (flt(item.base_net_amount,
|
||||||
@@ -770,7 +775,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
if not self.is_return:
|
if not self.is_return:
|
||||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||||
self.update_billing_status_in_pr()
|
|
||||||
|
self.update_billing_status_in_pr()
|
||||||
|
|
||||||
# Updating stock ledger should always be called after updating prevdoc status,
|
# Updating stock ledger should always be called after updating prevdoc status,
|
||||||
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
||||||
|
|||||||
@@ -784,10 +784,13 @@ class SalesInvoice(SellingController):
|
|||||||
asset.db_set("disposal_date", self.posting_date)
|
asset.db_set("disposal_date", self.posting_date)
|
||||||
asset.set_status("Sold" if self.docstatus==1 else None)
|
asset.set_status("Sold" if self.docstatus==1 else None)
|
||||||
else:
|
else:
|
||||||
account_currency = get_account_currency(item.income_account)
|
income_account = (item.income_account
|
||||||
|
if (not item.enable_deferred_revenue or self.is_return) else item.deferred_revenue_account)
|
||||||
|
|
||||||
|
account_currency = get_account_currency(income_account)
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": item.income_account if not item.enable_deferred_revenue else item.deferred_revenue_account,
|
"account": income_account,
|
||||||
"against": self.customer,
|
"against": self.customer,
|
||||||
"credit": flt(item.base_net_amount, item.precision("base_net_amount")),
|
"credit": flt(item.base_net_amount, item.precision("base_net_amount")),
|
||||||
"credit_in_account_currency": (flt(item.base_net_amount, item.precision("base_net_amount"))
|
"credit_in_account_currency": (flt(item.base_net_amount, item.precision("base_net_amount"))
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ class StatusUpdater(Document):
|
|||||||
frappe.db.sql("""update `tab%(target_parent_dt)s`
|
frappe.db.sql("""update `tab%(target_parent_dt)s`
|
||||||
set %(target_parent_field)s = round(
|
set %(target_parent_field)s = round(
|
||||||
ifnull((select
|
ifnull((select
|
||||||
ifnull(sum(if(%(target_ref_field)s > %(target_field)s, abs(%(target_field)s), abs(%(target_ref_field)s))), 0)
|
ifnull(sum(if(abs(%(target_ref_field)s) > abs(%(target_field)s), abs(%(target_field)s), abs(%(target_ref_field)s))), 0)
|
||||||
/ sum(abs(%(target_ref_field)s)) * 100
|
/ sum(abs(%(target_ref_field)s)) * 100
|
||||||
from `tab%(target_dt)s` where parent="%(name)s" having sum(abs(%(target_ref_field)s)) > 0), 0), 6)
|
from `tab%(target_dt)s` where parent="%(name)s" having sum(abs(%(target_ref_field)s)) > 0), 0), 6)
|
||||||
%(update_modified)s
|
%(update_modified)s
|
||||||
|
|||||||
@@ -4,6 +4,12 @@
|
|||||||
frappe.provide("erpnext.job_offer");
|
frappe.provide("erpnext.job_offer");
|
||||||
|
|
||||||
frappe.ui.form.on("Job Offer", {
|
frappe.ui.form.on("Job Offer", {
|
||||||
|
onload: function (frm) {
|
||||||
|
frm.set_query("select_terms", function() {
|
||||||
|
return { filters: { hr: 1 } };
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
select_terms: function (frm) {
|
select_terms: function (frm) {
|
||||||
erpnext.utils.get_terms(frm.doc.select_terms, frm.doc, function (r) {
|
erpnext.utils.get_terms(frm.doc.select_terms, frm.doc, function (r) {
|
||||||
if (!r.exc) {
|
if (!r.exc) {
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('Blanket Order', {
|
frappe.ui.form.on('Blanket Order', {
|
||||||
|
onload: function(frm) {
|
||||||
|
frm.trigger('set_tc_name_filter');
|
||||||
|
},
|
||||||
|
|
||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
frm.add_fetch("customer", "customer_name", "customer_name");
|
frm.add_fetch("customer", "customer_name", "customer_name");
|
||||||
frm.add_fetch("supplier", "supplier_name", "supplier_name");
|
frm.add_fetch("supplier", "supplier_name", "supplier_name");
|
||||||
@@ -44,4 +48,23 @@ frappe.ui.form.on('Blanket Order', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
set_tc_name_filter: function(frm) {
|
||||||
|
if (frm.doc.blanket_order_type === 'Selling') {
|
||||||
|
frm.set_query("tc_name", function() {
|
||||||
|
return { filters: { selling: 1 } };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (frm.doc.blanket_order_type === 'Purchasing') {
|
||||||
|
frm.set_query("tc_name", function() {
|
||||||
|
return { filters: { buying: 1 } };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
blanket_order_type: function (frm) {
|
||||||
|
frm.trigger('set_tc_name_filter');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -616,3 +616,4 @@ erpnext.patches.v12_0.set_quotation_status
|
|||||||
erpnext.patches.v12_0.set_priority_for_support
|
erpnext.patches.v12_0.set_priority_for_support
|
||||||
erpnext.patches.v12_0.delete_priority_property_setter
|
erpnext.patches.v12_0.delete_priority_property_setter
|
||||||
erpnext.patches.v12_0.update_due_date_in_gle
|
erpnext.patches.v12_0.update_due_date_in_gle
|
||||||
|
erpnext.patches.v12_0.add_default_buying_selling_terms_in_company
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Copyright (c) 2019, Frappe and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
from frappe.model.utils.rename_field import rename_field
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doc("setup", "doctype", "company")
|
||||||
|
if frappe.db.has_column('Company', 'default_terms'):
|
||||||
|
rename_field('Company', "default_terms", "default_selling_terms")
|
||||||
|
|
||||||
|
for company in frappe.get_all("Company", ["name", "default_selling_terms", "default_buying_terms"]):
|
||||||
|
if company.default_selling_terms and not company.default_buying_terms:
|
||||||
|
frappe.db.set_value("Company", company.name, "default_buying_terms", company.default_selling_terms)
|
||||||
|
|
||||||
|
frappe.reload_doc("setup", "doctype", "terms_and_conditions")
|
||||||
|
frappe.db.sql("update `tabTerms and Conditions` set selling=1, buying=1, hr=1")
|
||||||
@@ -61,6 +61,14 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.frm.fields_dict.tc_name) {
|
||||||
|
this.frm.set_query("tc_name", function() {
|
||||||
|
return{
|
||||||
|
filters: { 'buying': 1 }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
me.frm.set_query('supplier', erpnext.queries.supplier);
|
me.frm.set_query('supplier', erpnext.queries.supplier);
|
||||||
me.frm.set_query('contact_person', erpnext.queries.contact_query);
|
me.frm.set_query('contact_person', erpnext.queries.contact_query);
|
||||||
me.frm.set_query('supplier_address', erpnext.queries.address_query);
|
me.frm.set_query('supplier_address', erpnext.queries.address_query);
|
||||||
|
|||||||
@@ -585,8 +585,17 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
me.frm.set_value("letter_head", company_doc.default_letter_head);
|
me.frm.set_value("letter_head", company_doc.default_letter_head);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (company_doc.default_terms && me.frm.doc.doctype != "Purchase Invoice" && frappe.meta.has_field(me.frm.doc.doctype, "tc_name")) {
|
let selling_doctypes_for_tc = ["Sales Invoice", "Quotation", "Sales Order", "Delivery Note"];
|
||||||
me.frm.set_value("tc_name", company_doc.default_terms);
|
if (company_doc.default_selling_terms && frappe.meta.has_field(me.frm.doc.doctype, "tc_name") &&
|
||||||
|
selling_doctypes_for_tc.indexOf(me.frm.doc.doctype) != -1) {
|
||||||
|
me.frm.set_value("tc_name", company_doc.default_selling_terms);
|
||||||
|
}
|
||||||
|
let buying_doctypes_for_tc = ["Request for Quotation", "Supplier Quotation", "Purchase Order",
|
||||||
|
"Material Request", "Purchase Receipt"];
|
||||||
|
// Purchase Invoice is excluded as per issue #3345
|
||||||
|
if (company_doc.default_buying_terms && frappe.meta.has_field(me.frm.doc.doctype, "tc_name") &&
|
||||||
|
buying_doctypes_for_tc.indexOf(me.frm.doc.doctype) != -1) {
|
||||||
|
me.frm.set_value("tc_name", company_doc.default_buying_terms);
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.run_serially([
|
frappe.run_serially([
|
||||||
|
|||||||
@@ -59,6 +59,12 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.frm.fields_dict.tc_name) {
|
||||||
|
this.frm.set_query("tc_name", function() {
|
||||||
|
return { filters: { selling: 1 } };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if(!this.frm.fields_dict["items"]) {
|
if(!this.frm.fields_dict["items"]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -145,6 +151,11 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
discount_amount: function(doc, cdt, cdn) {
|
discount_amount: function(doc, cdt, cdn) {
|
||||||
|
|
||||||
|
if(doc.name === cdn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var item = frappe.get_doc(cdt, cdn);
|
var item = frappe.get_doc(cdt, cdn);
|
||||||
item.discount_percentage = 0.0;
|
item.discount_percentage = 0.0;
|
||||||
this.apply_discount_on_item(doc, cdt, cdn, 'discount_amount');
|
this.apply_discount_on_item(doc, cdt, cdn, 'discount_amount');
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ frappe.ui.form.on("Company", {
|
|||||||
filters: {"is_group": 1}
|
filters: {"is_group": 1}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("default_selling_terms", function() {
|
||||||
|
return { filters: { selling: 1 } };
|
||||||
|
});
|
||||||
|
|
||||||
|
frm.set_query("default_buying_terms", function() {
|
||||||
|
return { filters: { buying: 1 } };
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
company_name: function(frm) {
|
company_name: function(frm) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,288 +1,142 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
|
||||||
"allow_guest_to_view": 0,
|
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
"autoname": "field:title",
|
"autoname": "field:title",
|
||||||
"beta": 0,
|
|
||||||
"creation": "2013-01-10 16:34:24",
|
"creation": "2013-01-10 16:34:24",
|
||||||
"custom": 0,
|
|
||||||
"description": "Standard Terms and Conditions that can be added to Sales and Purchases.\n\nExamples:\n\n1. Validity of the offer.\n1. Payment Terms (In Advance, On Credit, part advance etc).\n1. What is extra (or payable by the Customer).\n1. Safety / usage warning.\n1. Warranty if any.\n1. Returns Policy.\n1. Terms of shipping, if applicable.\n1. Ways of addressing disputes, indemnity, liability, etc.\n1. Address and Contact of your Company.",
|
"description": "Standard Terms and Conditions that can be added to Sales and Purchases.\n\nExamples:\n\n1. Validity of the offer.\n1. Payment Terms (In Advance, On Credit, part advance etc).\n1. What is extra (or payable by the Customer).\n1. Safety / usage warning.\n1. Warranty if any.\n1. Returns Policy.\n1. Terms of shipping, if applicable.\n1. Ways of addressing disputes, indemnity, liability, etc.\n1. Address and Contact of your Company.",
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "Setup",
|
"document_type": "Setup",
|
||||||
"editable_grid": 0,
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"title",
|
||||||
|
"disabled",
|
||||||
|
"applicable_modules_section",
|
||||||
|
"selling",
|
||||||
|
"buying",
|
||||||
|
"hr",
|
||||||
|
"section_break_7",
|
||||||
|
"terms",
|
||||||
|
"terms_and_conditions_help"
|
||||||
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "title",
|
"fieldname": "title",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Title",
|
"label": "Title",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "title",
|
"oldfieldname": "title",
|
||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 1
|
"unique": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"default": "0",
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "disabled",
|
"fieldname": "disabled",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
"label": "Disabled"
|
||||||
"label": "Disabled",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"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
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_in_quick_entry": 1,
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "terms",
|
"fieldname": "terms",
|
||||||
"fieldtype": "Text Editor",
|
"fieldtype": "Text Editor",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 1,
|
"in_global_search": 1,
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Terms and Conditions",
|
"label": "Terms and Conditions",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "terms",
|
"oldfieldname": "terms",
|
||||||
"oldfieldtype": "Text Editor",
|
"oldfieldtype": "Text Editor"
|
||||||
"permlevel": 0,
|
|
||||||
"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
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "terms_and_conditions_help",
|
"fieldname": "terms_and_conditions_help",
|
||||||
"fieldtype": "HTML",
|
"fieldtype": "HTML",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Terms and Conditions Help",
|
"label": "Terms and Conditions Help",
|
||||||
"length": 0,
|
"options": "<h4>Standard Terms and Conditions Example</h4>\n\n<pre>Delivery Terms for Order number {{ name }}\n\n-Order Date : {{ transaction_date }} \n-Expected Delivery Date : {{ delivery_date }}\n</pre>\n\n<h4>How to get fieldnames</h4>\n\n<p>The fieldnames you can use in your email template are the fields in the document from which you are sending the email. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)</p>\n\n<h4>Templating</h4>\n\n<p>Templates are compiled using the Jinja Templating Langauge. To learn more about Jinja, <a class=\"strong\" href=\"http://jinja.pocoo.org/docs/dev/templates/\">read this documentation.</a></p>"
|
||||||
"no_copy": 0,
|
},
|
||||||
"options": "<h4>Standard Terms and Conditions Example</h4>\n\n<pre>Delivery Terms for Order number {{ name }}\n\n-Order Date : {{ transaction_date }} \n-Expected Delivery Date : {{ delivery_date }}\n</pre>\n\n<h4>How to get fieldnames</h4>\n\n<p>The fieldnames you can use in your email template are the fields in the document from which you are sending the email. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)</p>\n\n<h4>Templating</h4>\n\n<p>Templates are compiled using the Jinja Templating Langauge. To learn more about Jinja, <a class=\"strong\" href=\"http://jinja.pocoo.org/docs/dev/templates/\">read this documentation.</a></p>",
|
{
|
||||||
"permlevel": 0,
|
"fieldname": "applicable_modules_section",
|
||||||
"precision": "",
|
"fieldtype": "Section Break",
|
||||||
"print_hide": 0,
|
"label": "Applicable Modules"
|
||||||
"print_hide_if_no_value": 0,
|
},
|
||||||
"read_only": 0,
|
{
|
||||||
"remember_last_selected_value": 0,
|
"default": "1",
|
||||||
"report_hide": 0,
|
"fieldname": "selling",
|
||||||
"reqd": 0,
|
"fieldtype": "Check",
|
||||||
"search_index": 0,
|
"label": "Selling"
|
||||||
"set_only_once": 0,
|
},
|
||||||
"translatable": 0,
|
{
|
||||||
"unique": 0
|
"default": "1",
|
||||||
|
"fieldname": "buying",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Buying"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "hr",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "HR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_7",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
|
||||||
"hide_heading": 0,
|
|
||||||
"hide_toolbar": 0,
|
|
||||||
"icon": "icon-legal",
|
"icon": "icon-legal",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"image_view": 0,
|
"modified": "2019-07-04 13:31:30.393425",
|
||||||
"in_create": 0,
|
|
||||||
"is_submittable": 0,
|
|
||||||
"issingle": 0,
|
|
||||||
"istable": 0,
|
|
||||||
"max_attachments": 0,
|
|
||||||
"modified": "2018-08-29 06:36:33.131473",
|
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "Terms and Conditions",
|
"name": "Terms and Conditions",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 1,
|
"import": 1,
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "Sales Master Manager",
|
"role": "Sales Master Manager",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"email": 0,
|
|
||||||
"export": 0,
|
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 0,
|
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 0,
|
"role": "Sales User"
|
||||||
"role": "Sales User",
|
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 0,
|
|
||||||
"submit": 0,
|
|
||||||
"write": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"email": 0,
|
|
||||||
"export": 0,
|
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 0,
|
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 0,
|
"role": "Purchase User"
|
||||||
"role": "Purchase User",
|
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 0,
|
|
||||||
"submit": 0,
|
|
||||||
"write": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 0,
|
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "System Manager",
|
"role": "System Manager",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 0,
|
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "Accounts User",
|
"role": "Accounts User",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"email": 0,
|
|
||||||
"export": 0,
|
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 0,
|
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 0,
|
"role": "Stock User"
|
||||||
"role": "Stock User",
|
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 0,
|
|
||||||
"submit": 0,
|
|
||||||
"write": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
"read_only": 0,
|
|
||||||
"read_only_onload": 0,
|
|
||||||
"show_name_in_global_search": 1,
|
"show_name_in_global_search": 1,
|
||||||
"sort_order": "ASC",
|
"sort_field": "modified",
|
||||||
"track_changes": 0,
|
"sort_order": "ASC"
|
||||||
"track_seen": 0,
|
|
||||||
"track_views": 0
|
|
||||||
}
|
}
|
||||||
@@ -3,9 +3,11 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe import _, throw
|
||||||
import json
|
import json
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils.jinja import validate_template
|
from frappe.utils.jinja import validate_template
|
||||||
|
from frappe.utils import cint
|
||||||
|
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
|
||||||
@@ -13,6 +15,8 @@ class TermsandConditions(Document):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
if self.terms:
|
if self.terms:
|
||||||
validate_template(self.terms)
|
validate_template(self.terms)
|
||||||
|
if not cint(self.buying) and not cint(self.selling) and not cint(self.hr) and not cint(self.disabled):
|
||||||
|
throw(_("At least one of the Applicable Modules should be selected"))
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_terms_and_conditions(template_name, doc):
|
def get_terms_and_conditions(template_name, doc):
|
||||||
|
|||||||
@@ -251,11 +251,13 @@ def _get_cart_quotation(party=None):
|
|||||||
if quotation:
|
if quotation:
|
||||||
qdoc = frappe.get_doc("Quotation", quotation[0].name)
|
qdoc = frappe.get_doc("Quotation", quotation[0].name)
|
||||||
else:
|
else:
|
||||||
|
[company, price_list] = frappe.db.get_value("Shopping Cart Settings", None, ["company", "price_list"])
|
||||||
qdoc = frappe.get_doc({
|
qdoc = frappe.get_doc({
|
||||||
"doctype": "Quotation",
|
"doctype": "Quotation",
|
||||||
"naming_series": get_shopping_cart_settings().quotation_series or "QTN-CART-",
|
"naming_series": get_shopping_cart_settings().quotation_series or "QTN-CART-",
|
||||||
"quotation_to": party.doctype,
|
"quotation_to": party.doctype,
|
||||||
"company": frappe.db.get_value("Shopping Cart Settings", None, "company"),
|
"company": company,
|
||||||
|
"selling_price_list": price_list,
|
||||||
"order_type": "Shopping Cart",
|
"order_type": "Shopping Cart",
|
||||||
"status": "Draft",
|
"status": "Draft",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ def boot_session(bootinfo):
|
|||||||
FROM `tabCompany`
|
FROM `tabCompany`
|
||||||
LIMIT 1""") and 'Yes' or 'No'
|
LIMIT 1""") and 'Yes' or 'No'
|
||||||
|
|
||||||
bootinfo.docs += frappe.db.sql("""select name, default_currency, cost_center, default_terms,
|
bootinfo.docs += frappe.db.sql("""select name, default_currency, cost_center, default_selling_terms, default_buying_terms,
|
||||||
default_letter_head, default_bank_account, enable_perpetual_inventory, country from `tabCompany`""",
|
default_letter_head, default_bank_account, enable_perpetual_inventory, country from `tabCompany`""",
|
||||||
as_dict=1, update={"doctype":":Company"})
|
as_dict=1, update={"doctype":":Company"})
|
||||||
|
|
||||||
|
|||||||
@@ -77,8 +77,34 @@ frappe.ui.form.on("Delivery Note", {
|
|||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
print_without_amount: function(frm) {
|
print_without_amount: function(frm) {
|
||||||
erpnext.stock.delivery_note.set_print_hide(frm.doc);
|
erpnext.stock.delivery_note.set_print_hide(frm.doc);
|
||||||
|
},
|
||||||
|
|
||||||
|
refresh: function(frm) {
|
||||||
|
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
|
||||||
|
frm.add_custom_button(__('Credit Note'), function() {
|
||||||
|
frappe.confirm(__("Are you sure you want to make credit note?"),
|
||||||
|
function() {
|
||||||
|
frm.trigger("make_credit_note");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, __('Create'));
|
||||||
|
|
||||||
|
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
make_credit_note: function(frm) {
|
||||||
|
frm.call({
|
||||||
|
method: "make_return_invoice",
|
||||||
|
doc: frm.doc,
|
||||||
|
freeze: true,
|
||||||
|
callback: function() {
|
||||||
|
frm.reload_doc();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -333,7 +333,10 @@ class DeliveryNote(SellingController):
|
|||||||
return_invoice.is_return = True
|
return_invoice.is_return = True
|
||||||
return_invoice.save()
|
return_invoice.save()
|
||||||
return_invoice.submit()
|
return_invoice.submit()
|
||||||
frappe.msgprint(_("Credit Note {0} has been created automatically").format(return_invoice.name))
|
|
||||||
|
credit_note_link = frappe.utils.get_link_to_form('Sales Invoice', return_invoice.name)
|
||||||
|
|
||||||
|
frappe.msgprint(_("Credit Note {0} has been created automatically").format(credit_note_link))
|
||||||
except:
|
except:
|
||||||
frappe.throw(_("Could not create Credit Note automatically, please uncheck 'Issue Credit Note' and submit again"))
|
frappe.throw(_("Could not create Credit Note automatically, please uncheck 'Issue Credit Note' and submit again"))
|
||||||
|
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ class Item(WebsiteGenerator):
|
|||||||
self.validate_item_defaults()
|
self.validate_item_defaults()
|
||||||
self.validate_customer_provided_part()
|
self.validate_customer_provided_part()
|
||||||
self.update_defaults_from_item_group()
|
self.update_defaults_from_item_group()
|
||||||
|
self.validate_auto_reorder_enabled_in_stock_settings()
|
||||||
self.cant_change()
|
self.cant_change()
|
||||||
|
|
||||||
if not self.get("__islocal"):
|
if not self.get("__islocal"):
|
||||||
@@ -859,6 +860,12 @@ class Item(WebsiteGenerator):
|
|||||||
filters={"production_item": self.name, "docstatus": 1}):
|
filters={"production_item": self.name, "docstatus": 1}):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def validate_auto_reorder_enabled_in_stock_settings(self):
|
||||||
|
if self.reorder_levels:
|
||||||
|
enabled = frappe.db.get_single_value('Stock Settings', 'auto_indent')
|
||||||
|
if not enabled:
|
||||||
|
frappe.msgprint(msg=_("You have to enable auto re-order in Stock Settings to maintain re-order levels."), title=_("Enable Auto Re-Order"), indicator="orange")
|
||||||
|
|
||||||
def get_timeline_data(doctype, name):
|
def get_timeline_data(doctype, name):
|
||||||
'''returns timeline data based on stock ledger entry'''
|
'''returns timeline data based on stock ledger entry'''
|
||||||
out = {}
|
out = {}
|
||||||
|
|||||||
@@ -370,19 +370,20 @@ def make_purchase_order_based_on_supplier(source_name, target_doc=None):
|
|||||||
def get_material_requests_based_on_supplier(supplier):
|
def get_material_requests_based_on_supplier(supplier):
|
||||||
supplier_items = [d.parent for d in frappe.db.get_all("Item Default",
|
supplier_items = [d.parent for d in frappe.db.get_all("Item Default",
|
||||||
{"default_supplier": supplier}, 'parent')]
|
{"default_supplier": supplier}, 'parent')]
|
||||||
if supplier_items:
|
if not supplier_items:
|
||||||
material_requests = frappe.db.sql_list("""select distinct mr.name
|
frappe.throw(_("{0} is not the default supplier for any items.".format(supplier)))
|
||||||
from `tabMaterial Request` mr, `tabMaterial Request Item` mr_item
|
|
||||||
where mr.name = mr_item.parent
|
material_requests = frappe.db.sql_list("""select distinct mr.name
|
||||||
and mr_item.item_code in (%s)
|
from `tabMaterial Request` mr, `tabMaterial Request Item` mr_item
|
||||||
and mr.material_request_type = 'Purchase'
|
where mr.name = mr_item.parent
|
||||||
and mr.per_ordered < 99.99
|
and mr_item.item_code in (%s)
|
||||||
and mr.docstatus = 1
|
and mr.material_request_type = 'Purchase'
|
||||||
and mr.status != 'Stopped'
|
and mr.per_ordered < 99.99
|
||||||
order by mr_item.item_code ASC""" % ', '.join(['%s']*len(supplier_items)),
|
and mr.docstatus = 1
|
||||||
tuple(supplier_items))
|
and mr.status != 'Stopped'
|
||||||
else:
|
order by mr_item.item_code ASC""" % ', '.join(['%s']*len(supplier_items)),
|
||||||
material_requests = []
|
tuple(supplier_items))
|
||||||
|
|
||||||
return material_requests, supplier_items
|
return material_requests, supplier_items
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
|||||||
@@ -38,6 +38,29 @@ frappe.ui.form.on("Purchase Receipt", {
|
|||||||
if(frm.doc.company) {
|
if(frm.doc.company) {
|
||||||
frm.trigger("toggle_display_account_head");
|
frm.trigger("toggle_display_account_head");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
|
||||||
|
frm.add_custom_button(__('Debit Note'), function() {
|
||||||
|
frappe.confirm(__("Are you sure you want to make debit note?"),
|
||||||
|
function() {
|
||||||
|
frm.trigger("make_debit_note");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, __('Create'));
|
||||||
|
|
||||||
|
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
make_debit_note: function(frm) {
|
||||||
|
frm.call({
|
||||||
|
method: "make_return_invoice",
|
||||||
|
doc: frm.doc,
|
||||||
|
freeze: true,
|
||||||
|
callback: function() {
|
||||||
|
frm.reload_doc();
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
company: function(frm) {
|
company: function(frm) {
|
||||||
|
|||||||
@@ -387,6 +387,16 @@ class PurchaseReceipt(BuyingController):
|
|||||||
|
|
||||||
self.load_from_db()
|
self.load_from_db()
|
||||||
|
|
||||||
|
def make_return_invoice(self):
|
||||||
|
return_invoice = make_purchase_invoice(self.name)
|
||||||
|
return_invoice.is_return = True
|
||||||
|
return_invoice.save()
|
||||||
|
return_invoice.submit()
|
||||||
|
|
||||||
|
debit_note_link = frappe.utils.get_link_to_form('Purchase Invoice', return_invoice.name)
|
||||||
|
|
||||||
|
frappe.msgprint(_("Debit Note {0} has been created automatically").format(debit_note_link))
|
||||||
|
|
||||||
def update_billed_amount_based_on_po(po_detail, update_modified=True):
|
def update_billed_amount_based_on_po(po_detail, update_modified=True):
|
||||||
# Billed against Sales Order directly
|
# Billed against Sales Order directly
|
||||||
billed_against_po = frappe.db.sql("""select sum(amount) from `tabPurchase Invoice Item`
|
billed_against_po = frappe.db.sql("""select sum(amount) from `tabPurchase Invoice Item`
|
||||||
|
|||||||
Reference in New Issue
Block a user