mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 06:29:20 +00:00
Merge branch 'version-13-hotfix' into fix-user-unique-cart-hotfix
This commit is contained in:
@@ -439,7 +439,6 @@ class POSInvoice(SalesInvoice):
|
|||||||
self.paid_amount = 0
|
self.paid_amount = 0
|
||||||
|
|
||||||
def set_account_for_mode_of_payment(self):
|
def set_account_for_mode_of_payment(self):
|
||||||
self.payments = [d for d in self.payments if d.amount or d.base_amount or d.default]
|
|
||||||
for pay in self.payments:
|
for pay in self.payments:
|
||||||
if not pay.account:
|
if not pay.account:
|
||||||
pay.account = get_bank_cash_account(pay.mode_of_payment, self.company).get("account")
|
pay.account = get_bank_cash_account(pay.mode_of_payment, self.company).get("account")
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from erpnext.manufacturing.doctype.production_plan.production_plan import (
|
|||||||
get_sales_orders,
|
get_sales_orders,
|
||||||
get_warehouse_list,
|
get_warehouse_list,
|
||||||
)
|
)
|
||||||
|
from erpnext.manufacturing.doctype.work_order.work_order import OverProductionError
|
||||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||||
from erpnext.stock.doctype.item.test_item import create_item
|
from erpnext.stock.doctype.item.test_item import create_item
|
||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
||||||
@@ -466,26 +467,29 @@ class TestProductionPlan(ERPNextTestCase):
|
|||||||
bom = make_bom(item=item, raw_materials=raw_materials)
|
bom = make_bom(item=item, raw_materials=raw_materials)
|
||||||
|
|
||||||
# Create Production Plan
|
# Create Production Plan
|
||||||
pln = create_production_plan(item_code=bom.item, planned_qty=10)
|
pln = create_production_plan(item_code=bom.item, planned_qty=5)
|
||||||
|
|
||||||
# All the created Work Orders
|
# All the created Work Orders
|
||||||
wo_list = []
|
wo_list = []
|
||||||
|
|
||||||
# Create and Submit 1st Work Order for 5 qty
|
# Create and Submit 1st Work Order for 3 qty
|
||||||
create_work_order(item, pln, 5)
|
create_work_order(item, pln, 3)
|
||||||
|
pln.reload()
|
||||||
|
self.assertEqual(pln.po_items[0].ordered_qty, 3)
|
||||||
|
|
||||||
|
# Create and Submit 2nd Work Order for 2 qty
|
||||||
|
create_work_order(item, pln, 2)
|
||||||
pln.reload()
|
pln.reload()
|
||||||
self.assertEqual(pln.po_items[0].ordered_qty, 5)
|
self.assertEqual(pln.po_items[0].ordered_qty, 5)
|
||||||
|
|
||||||
# Create and Submit 2nd Work Order for 3 qty
|
# Overproduction
|
||||||
create_work_order(item, pln, 3)
|
self.assertRaises(OverProductionError, create_work_order, item=item, pln=pln, qty=2)
|
||||||
pln.reload()
|
|
||||||
self.assertEqual(pln.po_items[0].ordered_qty, 8)
|
|
||||||
|
|
||||||
# Cancel 1st Work Order
|
# Cancel 1st Work Order
|
||||||
wo1 = frappe.get_doc("Work Order", wo_list[0])
|
wo1 = frappe.get_doc("Work Order", wo_list[0])
|
||||||
wo1.cancel()
|
wo1.cancel()
|
||||||
pln.reload()
|
pln.reload()
|
||||||
self.assertEqual(pln.po_items[0].ordered_qty, 3)
|
self.assertEqual(pln.po_items[0].ordered_qty, 2)
|
||||||
|
|
||||||
# Cancel 2nd Work Order
|
# Cancel 2nd Work Order
|
||||||
wo2 = frappe.get_doc("Work Order", wo_list[1])
|
wo2 = frappe.get_doc("Work Order", wo_list[1])
|
||||||
|
|||||||
@@ -632,6 +632,21 @@ class WorkOrder(Document):
|
|||||||
if not self.qty > 0:
|
if not self.qty > 0:
|
||||||
frappe.throw(_("Quantity to Manufacture must be greater than 0."))
|
frappe.throw(_("Quantity to Manufacture must be greater than 0."))
|
||||||
|
|
||||||
|
if self.production_plan and self.production_plan_item:
|
||||||
|
qty_dict = frappe.db.get_value("Production Plan Item", self.production_plan_item, ["planned_qty", "ordered_qty"], as_dict=1)
|
||||||
|
|
||||||
|
allowance_qty =flt(frappe.db.get_single_value("Manufacturing Settings",
|
||||||
|
"overproduction_percentage_for_work_order"))/100 * qty_dict.get("planned_qty", 0)
|
||||||
|
|
||||||
|
max_qty = qty_dict.get("planned_qty", 0) + allowance_qty - qty_dict.get("ordered_qty", 0)
|
||||||
|
|
||||||
|
if max_qty < 1:
|
||||||
|
frappe.throw(_("Cannot produce more item for {0}")
|
||||||
|
.format(self.production_item), OverProductionError)
|
||||||
|
elif self.qty > max_qty:
|
||||||
|
frappe.throw(_("Cannot produce more than {0} items for {1}")
|
||||||
|
.format(max_qty, self.production_item), OverProductionError)
|
||||||
|
|
||||||
def validate_transfer_against(self):
|
def validate_transfer_against(self):
|
||||||
if not self.docstatus == 1:
|
if not self.docstatus == 1:
|
||||||
# let user configure operations until they're ready to submit
|
# let user configure operations until they're ready to submit
|
||||||
|
|||||||
@@ -2265,13 +2265,17 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
coupon_code: function() {
|
coupon_code: function() {
|
||||||
var me = this;
|
if (this.frm.doc.coupon_code || this.frm._last_coupon_code) {
|
||||||
frappe.run_serially([
|
// reset pricing rules if coupon code is set or is unset
|
||||||
() => this.frm.doc.ignore_pricing_rule=1,
|
const _ignore_pricing_rule = this.frm.doc.ignore_pricing_rule;
|
||||||
() => me.ignore_pricing_rule(),
|
return frappe.run_serially([
|
||||||
() => this.frm.doc.ignore_pricing_rule=0,
|
() => this.frm.doc.ignore_pricing_rule=1,
|
||||||
() => me.apply_pricing_rule()
|
() => this.frm.trigger('ignore_pricing_rule'),
|
||||||
]);
|
() => this.frm.doc.ignore_pricing_rule=_ignore_pricing_rule,
|
||||||
|
() => this.frm.trigger('apply_pricing_rule'),
|
||||||
|
() => this.frm._last_coupon_code = this.frm.doc.coupon_code
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -304,12 +304,13 @@ erpnext.HierarchyChart = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_child_nodes(node_id) {
|
get_child_nodes(node_id) {
|
||||||
|
let me = this;
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: this.method,
|
method: me.method,
|
||||||
args: {
|
args: {
|
||||||
parent: node_id,
|
parent: node_id,
|
||||||
company: this.company
|
company: me.company
|
||||||
}
|
}
|
||||||
}).then(r => resolve(r.message));
|
}).then(r => resolve(r.message));
|
||||||
});
|
});
|
||||||
@@ -350,12 +351,13 @@ erpnext.HierarchyChart = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_all_nodes() {
|
get_all_nodes() {
|
||||||
|
let me = this;
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: 'erpnext.utilities.hierarchy_chart.get_all_nodes',
|
method: 'erpnext.utilities.hierarchy_chart.get_all_nodes',
|
||||||
args: {
|
args: {
|
||||||
method: this.method,
|
method: me.method,
|
||||||
company: this.company
|
company: me.company
|
||||||
},
|
},
|
||||||
callback: (r) => {
|
callback: (r) => {
|
||||||
resolve(r.message);
|
resolve(r.message);
|
||||||
@@ -427,8 +429,8 @@ erpnext.HierarchyChart = class {
|
|||||||
|
|
||||||
add_connector(parent_id, child_id) {
|
add_connector(parent_id, child_id) {
|
||||||
// using pure javascript for better performance
|
// using pure javascript for better performance
|
||||||
const parent_node = document.querySelector(`#${parent_id}`);
|
const parent_node = document.getElementById(`${parent_id}`);
|
||||||
const child_node = document.querySelector(`#${child_id}`);
|
const child_node = document.getElementById(`${child_id}`);
|
||||||
|
|
||||||
let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
||||||
|
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ erpnext.HierarchyChartMobile = class {
|
|||||||
let me = this;
|
let me = this;
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: this.method,
|
method: me.method,
|
||||||
args: {
|
args: {
|
||||||
parent: node_id,
|
parent: node_id,
|
||||||
company: me.company,
|
company: me.company,
|
||||||
@@ -286,8 +286,8 @@ erpnext.HierarchyChartMobile = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
add_connector(parent_id, child_id) {
|
add_connector(parent_id, child_id) {
|
||||||
const parent_node = document.querySelector(`#${parent_id}`);
|
const parent_node = document.getElementById(`${parent_id}`);
|
||||||
const child_node = document.querySelector(`#${child_id}`);
|
const child_node = document.getElementById(`${child_id}`);
|
||||||
|
|
||||||
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
||||||
|
|
||||||
@@ -518,7 +518,8 @@ erpnext.HierarchyChartMobile = class {
|
|||||||
level.nextAll('li').remove();
|
level.nextAll('li').remove();
|
||||||
|
|
||||||
let node_object = this.nodes[node.id];
|
let node_object = this.nodes[node.id];
|
||||||
let current_node = level.find(`#${node.id}`).detach();
|
let current_node = level.find(`[id="${node.id}"]`).detach();
|
||||||
|
|
||||||
current_node.removeClass('active-child active-path');
|
current_node.removeClass('active-child active-path');
|
||||||
|
|
||||||
node_object.expanded = 0;
|
node_object.expanded = 0;
|
||||||
|
|||||||
@@ -170,17 +170,20 @@ erpnext.PointOfSale.Payment = class {
|
|||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on('POS Invoice', 'coupon_code', (frm) => {
|
frappe.ui.form.on('POS Invoice', 'coupon_code', (frm) => {
|
||||||
if (!frm.doc.ignore_pricing_rule) {
|
if (!frm.doc.ignore_pricing_rule && frm.doc.coupon_code) {
|
||||||
if (frm.doc.coupon_code) {
|
frappe.run_serially([
|
||||||
frappe.run_serially([
|
() => frm.doc.ignore_pricing_rule=1,
|
||||||
() => frm.doc.ignore_pricing_rule=1,
|
() => frm.trigger('ignore_pricing_rule'),
|
||||||
() => frm.trigger('ignore_pricing_rule'),
|
() => frm.doc.ignore_pricing_rule=0,
|
||||||
() => frm.doc.ignore_pricing_rule=0,
|
() => frm.trigger('apply_pricing_rule'),
|
||||||
() => frm.trigger('apply_pricing_rule'),
|
() => frm.save(),
|
||||||
() => frm.save(),
|
() => this.update_totals_section(frm.doc)
|
||||||
() => this.update_totals_section(frm.doc)
|
]);
|
||||||
]);
|
} else if (frm.doc.ignore_pricing_rule && frm.doc.coupon_code) {
|
||||||
}
|
frappe.show_alert({
|
||||||
|
message: __("Ignore Pricing Rule is enabled. Cannot apply coupon code."),
|
||||||
|
indicator: "orange"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -627,6 +627,12 @@ frappe.ui.form.on('Stock Entry Detail', {
|
|||||||
frm.events.set_serial_no(frm, cdt, cdn, () => {
|
frm.events.set_serial_no(frm, cdt, cdn, () => {
|
||||||
frm.events.get_warehouse_details(frm, cdt, cdn);
|
frm.events.get_warehouse_details(frm, cdt, cdn);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// set allow_zero_valuation_rate to 0 if s_warehouse is selected.
|
||||||
|
let item = frappe.get_doc(cdt, cdn);
|
||||||
|
if (item.s_warehouse) {
|
||||||
|
item.allow_zero_valuation_rate = 0;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
t_warehouse: function(frm, cdt, cdn) {
|
t_warehouse: function(frm, cdt, cdn) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
"actions": [],
|
||||||
"autoname": "hash",
|
"autoname": "hash",
|
||||||
"creation": "2013-03-29 18:22:12",
|
"creation": "2022-02-05 00:17:49.860824",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "Other",
|
"document_type": "Other",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
@@ -340,13 +340,13 @@
|
|||||||
"label": "More Information"
|
"label": "More Information"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "allow_zero_valuation_rate",
|
"fieldname": "allow_zero_valuation_rate",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Allow Zero Valuation Rate",
|
"label": "Allow Zero Valuation Rate",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"print_hide": 1
|
"print_hide": 1,
|
||||||
|
"read_only_depends_on": "eval:doc.s_warehouse"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
@@ -556,12 +556,14 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-06-22 16:47:11.268975",
|
"modified": "2022-02-26 00:51:24.963653",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Entry Detail",
|
"name": "Stock Entry Detail",
|
||||||
|
"naming_rule": "Random",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [],
|
"permissions": [],
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "ASC"
|
"sort_order": "ASC",
|
||||||
|
"states": []
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user