[cleanup] contextual buttons in sales & purchase and fix rate setting in opp -> quotation and material request -> purchase order
This commit is contained in:
parent
2e3d2b8426
commit
b46069d44b
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
"allow_copy": 0,
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 0,
|
"allow_rename": 1,
|
||||||
"autoname": "PRULE.#####",
|
"autoname": "field:title",
|
||||||
"creation": "2014-02-21 15:02:51",
|
"creation": "2014-02-21 15:02:51",
|
||||||
"custom": 0,
|
"custom": 0,
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
@ -24,6 +24,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -47,6 +48,7 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
@ -71,6 +73,7 @@
|
|||||||
"options": "\nItem Code\nItem Group\nBrand",
|
"options": "\nItem Code\nItem Group\nBrand",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
@ -95,6 +98,7 @@
|
|||||||
"options": "Item",
|
"options": "Item",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -119,6 +123,7 @@
|
|||||||
"options": "Brand",
|
"options": "Brand",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -143,6 +148,7 @@
|
|||||||
"options": "Item Group",
|
"options": "Item Group",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -165,6 +171,7 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -189,6 +196,7 @@
|
|||||||
"options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20",
|
"options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -211,6 +219,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -233,6 +242,7 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -255,6 +265,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -277,6 +288,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -299,6 +311,7 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -323,6 +336,7 @@
|
|||||||
"options": "\nCustomer\nCustomer Group\nTerritory\nSales Partner\nCampaign\nSupplier\nSupplier Type",
|
"options": "\nCustomer\nCustomer Group\nTerritory\nSales Partner\nCampaign\nSupplier\nSupplier Type",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -347,6 +361,7 @@
|
|||||||
"options": "Customer",
|
"options": "Customer",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -371,6 +386,7 @@
|
|||||||
"options": "Customer Group",
|
"options": "Customer Group",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -395,6 +411,7 @@
|
|||||||
"options": "Territory",
|
"options": "Territory",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -419,6 +436,7 @@
|
|||||||
"options": "Sales Partner",
|
"options": "Sales Partner",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -443,6 +461,7 @@
|
|||||||
"options": "Campaign",
|
"options": "Campaign",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -467,6 +486,7 @@
|
|||||||
"options": "Supplier",
|
"options": "Supplier",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -491,6 +511,7 @@
|
|||||||
"options": "Supplier Type",
|
"options": "Supplier Type",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -513,6 +534,7 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -535,6 +557,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -557,6 +580,7 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -579,6 +603,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -601,6 +626,7 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -624,6 +650,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -646,6 +673,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -667,6 +695,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -690,6 +719,7 @@
|
|||||||
"options": "Company",
|
"options": "Company",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -712,6 +742,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -736,6 +767,7 @@
|
|||||||
"options": "\nPrice\nDiscount Percentage",
|
"options": "\nPrice\nDiscount Percentage",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
@ -757,6 +789,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -780,6 +813,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -803,6 +837,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -827,6 +862,7 @@
|
|||||||
"options": "Price List",
|
"options": "Price List",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -850,6 +886,7 @@
|
|||||||
"options": "Simple",
|
"options": "Simple",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -872,6 +909,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -890,7 +928,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2015-11-16 06:29:51.958974",
|
"modified": "2016-01-15 04:05:11.633824",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Pricing Rule",
|
"name": "Pricing Rule",
|
||||||
@ -1001,5 +1039,5 @@
|
|||||||
"read_only_onload": 0,
|
"read_only_onload": 0,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"title_field": "title"
|
"title_field": ""
|
||||||
}
|
}
|
@ -76,7 +76,7 @@ class PricingRule(Document):
|
|||||||
def apply_pricing_rule(args):
|
def apply_pricing_rule(args):
|
||||||
"""
|
"""
|
||||||
args = {
|
args = {
|
||||||
"item_list": [{"doctype": "", "name": "", "item_code": "", "brand": "", "item_group": ""}, ...],
|
"items": [{"doctype": "", "name": "", "item_code": "", "brand": "", "item_group": ""}, ...],
|
||||||
"customer": "something",
|
"customer": "something",
|
||||||
"customer_group": "something",
|
"customer_group": "something",
|
||||||
"territory": "something",
|
"territory": "something",
|
||||||
@ -101,14 +101,10 @@ def apply_pricing_rule(args):
|
|||||||
# list of dictionaries
|
# list of dictionaries
|
||||||
out = []
|
out = []
|
||||||
|
|
||||||
if args.get("parenttype") == "Material Request": return out
|
if args.get("doctype") == "Material Request": return out
|
||||||
|
|
||||||
if not args.transaction_type:
|
item_list = args.get("items")
|
||||||
args.transaction_type = "buying" if frappe.get_meta(args.parenttype).get_field("supplier") \
|
args.pop("items")
|
||||||
else "selling"
|
|
||||||
|
|
||||||
item_list = args.get("item_list")
|
|
||||||
args.pop("item_list")
|
|
||||||
|
|
||||||
for item in item_list:
|
for item in item_list:
|
||||||
args_copy = copy.deepcopy(args)
|
args_copy = copy.deepcopy(args)
|
||||||
@ -184,9 +180,12 @@ def get_pricing_rules(args):
|
|||||||
|
|
||||||
|
|
||||||
conditions = ""
|
conditions = ""
|
||||||
|
values = {"item_code": args.get("item_code"), "brand": args.get("brand")}
|
||||||
|
|
||||||
for field in ["company", "customer", "supplier", "supplier_type", "campaign", "sales_partner"]:
|
for field in ["company", "customer", "supplier", "supplier_type", "campaign", "sales_partner"]:
|
||||||
if args.get(field):
|
if args.get(field):
|
||||||
conditions += " and ifnull("+field+", '') in (%("+field+")s, '')"
|
conditions += " and ifnull("+field+", '') in (%("+field+")s, '')"
|
||||||
|
values[field] = args.get(field)
|
||||||
else:
|
else:
|
||||||
conditions += " and ifnull("+field+", '') = ''"
|
conditions += " and ifnull("+field+", '') = ''"
|
||||||
|
|
||||||
@ -194,12 +193,15 @@ def get_pricing_rules(args):
|
|||||||
group_condition = _get_tree_conditions(parenttype)
|
group_condition = _get_tree_conditions(parenttype)
|
||||||
if group_condition:
|
if group_condition:
|
||||||
conditions += " and " + group_condition
|
conditions += " and " + group_condition
|
||||||
|
|
||||||
if not args.price_list: args.price_list = None
|
if not args.price_list: args.price_list = None
|
||||||
conditions += " and ifnull(for_price_list, '') in (%(price_list)s, '')"
|
conditions += " and ifnull(for_price_list, '') in (%(price_list)s, '')"
|
||||||
|
values["price_list"] = args.get("price_list")
|
||||||
|
|
||||||
if args.get("transaction_date"):
|
if args.get("transaction_date"):
|
||||||
conditions += """ and %(transaction_date)s between ifnull(valid_from, '2000-01-01')
|
conditions += """ and %(transaction_date)s between ifnull(valid_from, '2000-01-01')
|
||||||
and ifnull(valid_upto, '2500-12-31')"""
|
and ifnull(valid_upto, '2500-12-31')"""
|
||||||
|
values['transaction_date'] = args.get('transaction_date')
|
||||||
|
|
||||||
item_group_condition = _get_tree_conditions("Item Group", False)
|
item_group_condition = _get_tree_conditions("Item Group", False)
|
||||||
if item_group_condition: item_group_condition = " or " + item_group_condition
|
if item_group_condition: item_group_condition = " or " + item_group_condition
|
||||||
@ -210,7 +212,8 @@ def get_pricing_rules(args):
|
|||||||
and {transaction_type} = 1 {conditions}
|
and {transaction_type} = 1 {conditions}
|
||||||
order by priority desc, name desc""".format(
|
order by priority desc, name desc""".format(
|
||||||
item_group_condition=item_group_condition,
|
item_group_condition=item_group_condition,
|
||||||
transaction_type=args.transaction_type, conditions=conditions), args, as_dict=1)
|
transaction_type= "selling" if (args.customer or args.lead) else "buying",
|
||||||
|
conditions=conditions), values, as_dict=1)
|
||||||
|
|
||||||
def filter_pricing_rules(args, pricing_rules):
|
def filter_pricing_rules(args, pricing_rules):
|
||||||
# filter for qty
|
# filter for qty
|
||||||
|
@ -36,7 +36,6 @@ class TestPricingRule(unittest.TestCase):
|
|||||||
"price_list_currency": "_Test Currency",
|
"price_list_currency": "_Test Currency",
|
||||||
"plc_conversion_rate": 1,
|
"plc_conversion_rate": 1,
|
||||||
"order_type": "Sales",
|
"order_type": "Sales",
|
||||||
"transaction_type": "selling",
|
|
||||||
"customer": "_Test Customer",
|
"customer": "_Test Customer",
|
||||||
"doctype": "Sales Order Item",
|
"doctype": "Sales Order Item",
|
||||||
"name": None
|
"name": None
|
||||||
|
@ -44,7 +44,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
}, __("Get items from"));
|
||||||
|
|
||||||
cur_frm.add_custom_button(__('Purchase Receipt'), function() {
|
cur_frm.add_custom_button(__('Purchase Receipt'), function() {
|
||||||
frappe.model.map_current_doc({
|
frappe.model.map_current_doc({
|
||||||
@ -57,7 +57,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
}, __("Get items from"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -77,7 +77,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
|||||||
me.apply_pricing_rule();
|
me.apply_pricing_rule();
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
credit_to: function() {
|
credit_to: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
if(this.frm.doc.credit_to) {
|
if(this.frm.doc.credit_to) {
|
||||||
|
@ -50,13 +50,13 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
if(doc.update_stock) this.show_stock_ledger();
|
if(doc.update_stock) this.show_stock_ledger();
|
||||||
|
|
||||||
if(doc.docstatus==1 && !doc.is_return) {
|
if(doc.docstatus==1 && !doc.is_return) {
|
||||||
|
|
||||||
var is_delivered_by_supplier = false;
|
var is_delivered_by_supplier = false;
|
||||||
|
|
||||||
is_delivered_by_supplier = cur_frm.doc.items.some(function(item){
|
is_delivered_by_supplier = cur_frm.doc.items.some(function(item){
|
||||||
return item.is_delivered_by_supplier ? true : false;
|
return item.is_delivered_by_supplier ? true : false;
|
||||||
})
|
})
|
||||||
|
|
||||||
cur_frm.add_custom_button(doc.update_stock ? __('Sales Return') : __('Credit Note'),
|
cur_frm.add_custom_button(doc.update_stock ? __('Sales Return') : __('Credit Note'),
|
||||||
this.make_sales_return, __("Make"));
|
this.make_sales_return, __("Make"));
|
||||||
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
||||||
@ -70,12 +70,12 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(!from_delivery_note && !is_delivered_by_supplier) {
|
if(!from_delivery_note && !is_delivered_by_supplier) {
|
||||||
cur_frm.add_custom_button(__('Delivery'), cur_frm.cscript['Make Delivery Note'], __("Make"));
|
cur_frm.add_custom_button(__('Delivery'), cur_frm.cscript['Delivery Note'], __("Make"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.outstanding_amount!=0 && !cint(doc.is_return)) {
|
if(doc.outstanding_amount!=0 && !cint(doc.is_return)) {
|
||||||
cur_frm.add_custom_button(__('Make Payment Request'), this.make_payment_request, __("Make"));
|
cur_frm.add_custom_button(__('Payment Request'), this.make_payment_request, __("Make"));
|
||||||
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry, __("Make"));
|
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry, __("Make"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
},
|
},
|
||||||
|
|
||||||
sales_order_btn: function() {
|
sales_order_btn: function() {
|
||||||
this.$sales_order_btn = cur_frm.add_custom_button(__('From Sales Order'),
|
this.$sales_order_btn = cur_frm.add_custom_button(__('Sales Order'),
|
||||||
function() {
|
function() {
|
||||||
frappe.model.map_current_doc({
|
frappe.model.map_current_doc({
|
||||||
method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
|
method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
|
||||||
@ -119,11 +119,11 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("From"));
|
}, __("Get items from"));
|
||||||
},
|
},
|
||||||
|
|
||||||
delivery_note_btn: function() {
|
delivery_note_btn: function() {
|
||||||
this.$delivery_note_btn = cur_frm.add_custom_button(__('From Delivery Note'),
|
this.$delivery_note_btn = cur_frm.add_custom_button(__('Delivery Note'),
|
||||||
function() {
|
function() {
|
||||||
frappe.model.map_current_doc({
|
frappe.model.map_current_doc({
|
||||||
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
||||||
@ -139,7 +139,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, __("From"));
|
}, __("Get items from"));
|
||||||
},
|
},
|
||||||
|
|
||||||
tc_name: function() {
|
tc_name: function() {
|
||||||
|
@ -169,7 +169,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
var me = this;
|
var me = this;
|
||||||
this.frm.add_custom_button(__("Product Bundle"), function() {
|
this.frm.add_custom_button(__("Product Bundle"), function() {
|
||||||
erpnext.buying.get_items_from_product_bundle(me.frm);
|
erpnext.buying.get_items_from_product_bundle(me.frm);
|
||||||
}, __("From"));
|
}, __("Get items from"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.set_df_property("drop_ship", "hidden", !is_drop_ship);
|
cur_frm.set_df_property("drop_ship", "hidden", !is_drop_ship);
|
||||||
|
|
||||||
if(doc.docstatus == 1 && !in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
|
if(doc.docstatus == 1 && !in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
|
||||||
if (this.frm.has_perm("submit")) {
|
if (this.frm.has_perm("submit")) {
|
||||||
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) {
|
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) {
|
||||||
@ -47,25 +47,23 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
cur_frm.add_custom_button(__('Close'), this.close_purchase_order, __("Status"));
|
cur_frm.add_custom_button(__('Close'), this.close_purchase_order, __("Status"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(is_drop_ship && doc.status!="Delivered"){
|
if(is_drop_ship && doc.status!="Delivered"){
|
||||||
cur_frm.add_custom_button(__('Delivered'),
|
cur_frm.add_custom_button(__('Delivered'),
|
||||||
this.delivered_by_supplier, __("Status"));
|
this.delivered_by_supplier, __("Status"));
|
||||||
|
|
||||||
cur_frm.page.set_inner_btn_group_as_primary(__("Status"));
|
cur_frm.page.set_inner_btn_group_as_primary(__("Status"));
|
||||||
}
|
}
|
||||||
} else if(doc.docstatus===0) {
|
} else if(doc.docstatus===0) {
|
||||||
cur_frm.add_custom_button(__('Get Last Purchase Rate'), this.get_last_purchase_rate);
|
|
||||||
|
|
||||||
cur_frm.cscript.add_from_mappers();
|
cur_frm.cscript.add_from_mappers();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.docstatus == 1 && in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
|
if(doc.docstatus == 1 && in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
|
||||||
if (this.frm.has_perm("submit")) {
|
if (this.frm.has_perm("submit")) {
|
||||||
cur_frm.add_custom_button(__('Re-open'), this.unstop_purchase_order, __("Status"));
|
cur_frm.add_custom_button(__('Re-open'), this.unstop_purchase_order, __("Status"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.docstatus == 1 && !in_list(["Stopped", "Closed"], doc.status)) {
|
if(doc.docstatus == 1 && !in_list(["Stopped", "Closed"], doc.status)) {
|
||||||
if(flt(doc.per_received, 2) < 100 && allow_receipt) {
|
if(flt(doc.per_received, 2) < 100 && allow_receipt) {
|
||||||
cur_frm.add_custom_button(__('Receive'), this.make_purchase_receipt, __("Make"));
|
cur_frm.add_custom_button(__('Receive'), this.make_purchase_receipt, __("Make"));
|
||||||
@ -79,15 +77,25 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
if(flt(doc.per_billed, 2) < 100)
|
if(flt(doc.per_billed, 2) < 100)
|
||||||
cur_frm.add_custom_button(__('Invoice'),
|
cur_frm.add_custom_button(__('Invoice'),
|
||||||
this.make_purchase_invoice, __("Make"));
|
this.make_purchase_invoice, __("Make"));
|
||||||
|
|
||||||
if(flt(doc.per_billed)==0 && doc.status != "Delivered") {
|
if(flt(doc.per_billed)==0 && doc.status != "Delivered") {
|
||||||
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry, __("Make"));
|
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry, __("Make"));
|
||||||
}
|
}
|
||||||
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get_items_from_open_material_requests: function() {
|
||||||
|
frappe.model.map_current_doc({
|
||||||
|
method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order_based_on_supplier",
|
||||||
|
source_name: this.frm.doc.supplier,
|
||||||
|
get_query_filters: {
|
||||||
|
docstatus: ["!=", 2],
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
make_stock_entry: function() {
|
make_stock_entry: function() {
|
||||||
var items = $.map(cur_frm.doc.items, function(d) { return d.bom ? d.item_code : false; });
|
var items = $.map(cur_frm.doc.items, function(d) { return d.bom ? d.item_code : false; });
|
||||||
var me = this;
|
var me = this;
|
||||||
@ -144,7 +152,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("From"));
|
}, __("Add items from"));
|
||||||
|
|
||||||
cur_frm.add_custom_button(__('Supplier Quotation'),
|
cur_frm.add_custom_button(__('Supplier Quotation'),
|
||||||
function() {
|
function() {
|
||||||
@ -157,18 +165,8 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("From"));
|
}, __("Add items from"));
|
||||||
|
|
||||||
cur_frm.add_custom_button(__('Supplier'),
|
|
||||||
function() {
|
|
||||||
frappe.model.map_current_doc({
|
|
||||||
method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order_based_on_supplier",
|
|
||||||
source_doctype: "Supplier",
|
|
||||||
get_query_filters: {
|
|
||||||
docstatus: ["!=", 2],
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, __("For"));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
tc_name: function() {
|
tc_name: function() {
|
||||||
@ -209,12 +207,13 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
delivered_by_supplier: function(){
|
delivered_by_supplier: function(){
|
||||||
cur_frm.cscript.update_status('Deliver', 'Delivered')
|
cur_frm.cscript.update_status('Deliver', 'Delivered')
|
||||||
},
|
},
|
||||||
|
|
||||||
get_last_purchase_rate: function() {
|
get_last_purchase_rate: function() {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
"method": "get_last_purchase_rate",
|
"method": "get_last_purchase_rate",
|
||||||
"doc": cur_frm.doc,
|
"doc": cur_frm.doc,
|
||||||
callback: function(r, rt) {
|
callback: function(r, rt) {
|
||||||
|
cur_frm.dirty();
|
||||||
cur_frm.cscript.calculate_taxes_and_totals();
|
cur_frm.cscript.calculate_taxes_and_totals();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -267,54 +266,12 @@ cur_frm.fields_dict['items'].grid.get_field('bom').get_query = function(doc, cdt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.pformat.indent_no = function(doc, cdt, cdn){
|
|
||||||
//function to make row of table
|
|
||||||
|
|
||||||
var make_row = function(title,val1, val2, bold){
|
|
||||||
var bstart = '<b>'; var bend = '</b>';
|
|
||||||
|
|
||||||
return '<tr><td style="width:39%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
|
|
||||||
+'<td style="width:61%;text-align:left;">'+val1+(val2?' ('+dateutil.str_to_user(val2)+')':'')+'</td>'
|
|
||||||
+'</tr>'
|
|
||||||
}
|
|
||||||
|
|
||||||
out ='';
|
|
||||||
|
|
||||||
var cl = doc.items || [];
|
|
||||||
|
|
||||||
// outer table
|
|
||||||
var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 50%"></td><td>';
|
|
||||||
|
|
||||||
// main table
|
|
||||||
out +='<table class="noborder" style="width:100%">';
|
|
||||||
|
|
||||||
// add rows
|
|
||||||
if(cl.length){
|
|
||||||
prevdoc_list = new Array();
|
|
||||||
for(var i=0;i<cl.length;i++){
|
|
||||||
if(cl[i].prevdoc_doctype == 'Material Request' && cl[i].prevdoc_docname && prevdoc_list.indexOf(cl[i].prevdoc_docname) == -1) {
|
|
||||||
prevdoc_list.push(cl[i].prevdoc_docname);
|
|
||||||
if(prevdoc_list.length ==1)
|
|
||||||
out += make_row(cl[i].prevdoc_doctype, cl[i].prevdoc_docname, null,0);
|
|
||||||
else
|
|
||||||
out += make_row('', cl[i].prevdoc_docname,null,0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out +='</table></td></tr></table></div>';
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||||
if(cint(frappe.boot.notification_settings.purchase_order)) {
|
if(cint(frappe.boot.notification_settings.purchase_order)) {
|
||||||
cur_frm.email_doc(frappe.boot.notification_settings.purchase_order_message);
|
cur_frm.email_doc(frappe.boot.notification_settings.purchase_order_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.schedule_date = function(doc, cdt, cdn) {
|
cur_frm.cscript.schedule_date = function(doc, cdt, cdn) {
|
||||||
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "items", "schedule_date");
|
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "items", "schedule_date");
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,31 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"depends_on": "eval:doc.supplier && doc.docstatus===0 && !(doc.items && doc.items.length)",
|
||||||
|
"fieldname": "get_items_from_open_material_requests",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Get Items from Open Material Requests",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -847,6 +872,31 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"depends_on": "eval:doc.docstatus===0 && (doc.items && doc.items.length)",
|
||||||
|
"fieldname": "get_last_purchase_rate",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Get last purchase rate",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -2458,7 +2508,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2015-12-17 16:18:39.096762",
|
"modified": "2016-01-15 04:13:35.179163",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order",
|
"name": "Purchase Order",
|
||||||
|
@ -1,24 +1,44 @@
|
|||||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
frappe.ui.form.on("Supplier", {
|
||||||
cur_frm.cscript.make_dashboard(doc);
|
refresh: function(frm) {
|
||||||
|
frm.cscript.make_dashboard(frm.doc);
|
||||||
|
|
||||||
if(frappe.defaults.get_default("supp_master_name")!="Naming Series") {
|
if(frappe.defaults.get_default("supp_master_name")!="Naming Series") {
|
||||||
cur_frm.toggle_display("naming_series", false);
|
frm.toggle_display("naming_series", false);
|
||||||
} else {
|
} else {
|
||||||
erpnext.toggle_naming_series();
|
erpnext.toggle_naming_series();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.__islocal){
|
if(frm.doc.__islocal){
|
||||||
hide_field(['address_html','contact_html']);
|
hide_field(['address_html','contact_html']);
|
||||||
erpnext.utils.clear_address_and_contact(cur_frm);
|
erpnext.utils.clear_address_and_contact(frm);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
unhide_field(['address_html','contact_html']);
|
unhide_field(['address_html','contact_html']);
|
||||||
erpnext.utils.render_address_and_contact(cur_frm)
|
erpnext.utils.render_address_and_contact(frm);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
frm.events.add_custom_buttons(frm);
|
||||||
|
},
|
||||||
|
add_custom_buttons: function(frm) {
|
||||||
|
["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"].forEach(function(doctype, i) {
|
||||||
|
if(frappe.model.can_read(doctype)) {
|
||||||
|
frm.add_custom_button(__(doctype), function() {
|
||||||
|
frappe.route_options = {"supplier": frm.doc.name};
|
||||||
|
frappe.set_route("List", doctype);
|
||||||
|
}, __("View"));
|
||||||
|
}
|
||||||
|
if(frappe.model.can_create(doctype)) {
|
||||||
|
frm.add_custom_button(__(doctype), function() {
|
||||||
|
frappe.route_options = {"supplier": frm.doc.name};
|
||||||
|
new_doc(doctype);
|
||||||
|
}, __("Make"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
cur_frm.cscript.make_dashboard = function(doc) {
|
cur_frm.cscript.make_dashboard = function(doc) {
|
||||||
cur_frm.dashboard.reset();
|
cur_frm.dashboard.reset();
|
||||||
|
@ -27,7 +27,7 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("From"));
|
}, __("Get items from"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ def get_data():
|
|||||||
{
|
{
|
||||||
"type": "help",
|
"type": "help",
|
||||||
"label": _("Product Bundle"),
|
"label": _("Product Bundle"),
|
||||||
"youtube_id": "yk-7kPrRyRRc"
|
"youtube_id": "yk3kPrRyRRc"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "help",
|
"type": "help",
|
||||||
|
@ -133,13 +133,13 @@ class AccountsController(TransactionBase):
|
|||||||
def set_missing_item_details(self):
|
def set_missing_item_details(self):
|
||||||
"""set missing item values"""
|
"""set missing item values"""
|
||||||
from erpnext.stock.get_item_details import get_item_details
|
from erpnext.stock.get_item_details import get_item_details
|
||||||
|
|
||||||
if self.doctype == "Purchase Invoice":
|
if self.doctype == "Purchase Invoice":
|
||||||
auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
|
auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
|
||||||
|
|
||||||
if auto_accounting_for_stock:
|
if auto_accounting_for_stock:
|
||||||
stock_not_billed_account = self.get_company_default("stock_received_but_not_billed")
|
stock_not_billed_account = self.get_company_default("stock_received_but_not_billed")
|
||||||
|
|
||||||
stock_items = self.get_stock_items()
|
stock_items = self.get_stock_items()
|
||||||
|
|
||||||
if hasattr(self, "items"):
|
if hasattr(self, "items"):
|
||||||
@ -151,6 +151,10 @@ class AccountsController(TransactionBase):
|
|||||||
if item.get("item_code"):
|
if item.get("item_code"):
|
||||||
args = parent_dict.copy()
|
args = parent_dict.copy()
|
||||||
args.update(item.as_dict())
|
args.update(item.as_dict())
|
||||||
|
|
||||||
|
args["doctype"] = parent_dict.get("doctype")
|
||||||
|
args["name"] = parent_dict.get("name")
|
||||||
|
|
||||||
if not args.get("transaction_date"):
|
if not args.get("transaction_date"):
|
||||||
args["transaction_date"] = args.get("posting_date")
|
args["transaction_date"] = args.get("posting_date")
|
||||||
|
|
||||||
@ -178,13 +182,13 @@ class AccountsController(TransactionBase):
|
|||||||
if item.price_list_rate:
|
if item.price_list_rate:
|
||||||
item.rate = flt(item.price_list_rate *
|
item.rate = flt(item.price_list_rate *
|
||||||
(1.0 - (flt(item.discount_percentage) / 100.0)), item.precision("rate"))
|
(1.0 - (flt(item.discount_percentage) / 100.0)), item.precision("rate"))
|
||||||
|
|
||||||
if self.doctype == "Purchase Invoice":
|
if self.doctype == "Purchase Invoice":
|
||||||
if auto_accounting_for_stock and item.item_code in stock_items \
|
if auto_accounting_for_stock and item.item_code in stock_items \
|
||||||
and self.is_opening == 'No' \
|
and self.is_opening == 'No' \
|
||||||
and (not item.po_detail or not frappe.db.get_value("Purchase Order Item",
|
and (not item.po_detail or not frappe.db.get_value("Purchase Order Item",
|
||||||
item.po_detail, "delivered_by_supplier")):
|
item.po_detail, "delivered_by_supplier")):
|
||||||
|
|
||||||
item.expense_account = stock_not_billed_account
|
item.expense_account = stock_not_billed_account
|
||||||
item.cost_center = None
|
item.cost_center = None
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({
|
|||||||
if(!this.frm.doc.__islocal && this.frm.doc.__onload && !this.frm.doc.__onload.is_customer) {
|
if(!this.frm.doc.__islocal && this.frm.doc.__onload && !this.frm.doc.__onload.is_customer) {
|
||||||
this.frm.add_custom_button(__("Customer"), this.create_customer, __("Make"));
|
this.frm.add_custom_button(__("Customer"), this.create_customer, __("Make"));
|
||||||
this.frm.add_custom_button(__("Opportunity"), this.create_opportunity, __("Make"));
|
this.frm.add_custom_button(__("Opportunity"), this.create_opportunity, __("Make"));
|
||||||
this.frm.add_custom_button(__("Make Quotation"), this.make_quotation, __("Make"));
|
this.frm.add_custom_button(__("Quotation"), this.make_quotation, __("Make"));
|
||||||
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({
|
|||||||
frm: cur_frm
|
frm: cur_frm
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
make_quotation: function() {
|
make_quotation: function() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.crm.doctype.lead.lead.make_quotation",
|
method: "erpnext.crm.doctype.lead.lead.make_quotation",
|
||||||
|
@ -92,13 +92,13 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
}, __("Status"));
|
}, __("Status"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.status!=="Lost") {
|
if(doc.status!=="Lost") {
|
||||||
if(doc.status!=="Quotation") {
|
if(doc.status!=="Quotation") {
|
||||||
cur_frm.add_custom_button(__('Opportunity Lost'),
|
cur_frm.add_custom_button(__('Lost'),
|
||||||
cur_frm.cscript['Declare Opportunity Lost'], __("Mark"));
|
cur_frm.cscript['Declare Opportunity Lost'], __("Status"));
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.add_custom_button(__('Quotation'),cur_frm.cscript.create_quotation, __("Make"));
|
cur_frm.add_custom_button(__('Quotation'),cur_frm.cscript.create_quotation, __("Make"));
|
||||||
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ from frappe.model.mapper import get_mapped_doc
|
|||||||
from erpnext.setup.utils import get_exchange_rate
|
from erpnext.setup.utils import get_exchange_rate
|
||||||
from erpnext.utilities.transaction_base import TransactionBase
|
from erpnext.utilities.transaction_base import TransactionBase
|
||||||
from erpnext.accounts.party import get_party_account_currency
|
from erpnext.accounts.party import get_party_account_currency
|
||||||
|
from erpnext.stock.get_item_details import apply_price_list
|
||||||
|
|
||||||
subject_field = "title"
|
subject_field = "title"
|
||||||
sender_field = "contact_email"
|
sender_field = "contact_email"
|
||||||
@ -192,6 +193,8 @@ def make_quotation(source_name, target_doc=None):
|
|||||||
quotation.currency = party_account_currency or company_currency
|
quotation.currency = party_account_currency or company_currency
|
||||||
quotation.conversion_rate = exchange_rate
|
quotation.conversion_rate = exchange_rate
|
||||||
|
|
||||||
|
quotation.update(apply_price_list(quotation.as_dict(), as_doc = True))
|
||||||
|
|
||||||
quotation.run_method("set_missing_values")
|
quotation.run_method("set_missing_values")
|
||||||
quotation.run_method("calculate_taxes_and_totals")
|
quotation.run_method("calculate_taxes_and_totals")
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ erpnext.production_order = {
|
|||||||
set_custom_buttons: function(frm) {
|
set_custom_buttons: function(frm) {
|
||||||
var doc = frm.doc;
|
var doc = frm.doc;
|
||||||
if (doc.docstatus === 1) {
|
if (doc.docstatus === 1) {
|
||||||
frm.add_custom_button(__("Show Stock Entries"), function() {
|
frm.add_custom_button(__("Stock Entries"), function() {
|
||||||
frappe.route_options = {
|
frappe.route_options = {
|
||||||
production_order: frm.doc.name
|
production_order: frm.doc.name
|
||||||
}
|
}
|
||||||
@ -76,12 +76,12 @@ erpnext.production_order = {
|
|||||||
|
|
||||||
// opertions
|
// opertions
|
||||||
if ((doc.operations || []).length) {
|
if ((doc.operations || []).length) {
|
||||||
frm.add_custom_button(__('Show Time Logs'), function() {
|
frm.add_custom_button(__('Time Logs'), function() {
|
||||||
frappe.route_options = {"production_order": frm.doc.name};
|
frappe.route_options = {"production_order": frm.doc.name};
|
||||||
frappe.set_route("List", "Time Log");
|
frappe.set_route("List", "Time Log");
|
||||||
}, __("View"));
|
}, __("View"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flt(doc.material_transferred_for_manufacturing) < flt(doc.qty)) {
|
if (flt(doc.material_transferred_for_manufacturing) < flt(doc.qty)) {
|
||||||
frm.add_custom_button(__('Transfer Materials for Manufacture'),
|
frm.add_custom_button(__('Transfer Materials for Manufacture'),
|
||||||
cur_frm.cscript['Transfer Raw Materials'], __("Stock Entry"));
|
cur_frm.cscript['Transfer Raw Materials'], __("Stock Entry"));
|
||||||
|
@ -559,7 +559,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
apply_pricing_rule: function(item, calculate_taxes_and_totals) {
|
apply_pricing_rule: function(item, calculate_taxes_and_totals) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var args = this._get_args(item);
|
var args = this._get_args(item);
|
||||||
if (!(args.item_list && args.item_list.length)) {
|
if (!(args.items && args.items.length)) {
|
||||||
if(calculate_taxes_and_totals) me.calculate_taxes_and_totals();
|
if(calculate_taxes_and_totals) me.calculate_taxes_and_totals();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -579,7 +579,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
_get_args: function(item) {
|
_get_args: function(item) {
|
||||||
var me = this;
|
var me = this;
|
||||||
return {
|
return {
|
||||||
"item_list": this._get_item_list(item),
|
"items": this._get_item_list(item),
|
||||||
"customer": me.frm.doc.customer,
|
"customer": me.frm.doc.customer,
|
||||||
"customer_group": me.frm.doc.customer_group,
|
"customer_group": me.frm.doc.customer_group,
|
||||||
"territory": me.frm.doc.territory,
|
"territory": me.frm.doc.territory,
|
||||||
@ -595,8 +595,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
"campaign": me.frm.doc.campaign,
|
"campaign": me.frm.doc.campaign,
|
||||||
"sales_partner": me.frm.doc.sales_partner,
|
"sales_partner": me.frm.doc.sales_partner,
|
||||||
"ignore_pricing_rule": me.frm.doc.ignore_pricing_rule,
|
"ignore_pricing_rule": me.frm.doc.ignore_pricing_rule,
|
||||||
"parenttype": me.frm.doc.doctype,
|
"doctype": me.frm.doc.doctype,
|
||||||
"parent": me.frm.doc.name
|
"name": me.frm.doc.name
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -654,7 +654,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
apply_price_list: function(item) {
|
apply_price_list: function(item) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var args = this._get_args(item);
|
var args = this._get_args(item);
|
||||||
if (!((args.item_list && args.item_list.length) || args.price_list)) {
|
if (!((args.items && args.items.length) || args.price_list)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,7 +668,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
me.frm.set_value("plc_conversion_rate", r.message.parent.plc_conversion_rate);
|
me.frm.set_value("plc_conversion_rate", r.message.parent.plc_conversion_rate);
|
||||||
me.in_apply_price_list = false;
|
me.in_apply_price_list = false;
|
||||||
|
|
||||||
if(args.item_list.length) {
|
if(args.items.length) {
|
||||||
me._set_values_for_item_list(r.message.children);
|
me._set_values_for_item_list(r.message.children);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,50 @@
|
|||||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Customer", "refresh", function(frm) {
|
frappe.ui.form.on("Customer", {
|
||||||
cur_frm.cscript.setup_dashboard(frm.doc);
|
refresh: function(frm) {
|
||||||
|
frm.cscript.setup_dashboard(frm.doc);
|
||||||
|
|
||||||
if(frappe.defaults.get_default("cust_master_name")!="Naming Series") {
|
if(frappe.defaults.get_default("cust_master_name")!="Naming Series") {
|
||||||
frm.toggle_display("naming_series", false);
|
frm.toggle_display("naming_series", false);
|
||||||
} else {
|
} else {
|
||||||
erpnext.toggle_naming_series();
|
erpnext.toggle_naming_series();
|
||||||
|
}
|
||||||
|
|
||||||
|
frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal);
|
||||||
|
|
||||||
|
if(!frm.doc.__islocal) {
|
||||||
|
erpnext.utils.render_address_and_contact(frm);
|
||||||
|
} else {
|
||||||
|
erpnext.utils.clear_address_and_contact(frm);
|
||||||
|
}
|
||||||
|
|
||||||
|
var grid = cur_frm.get_field("sales_team").grid;
|
||||||
|
grid.set_column_disp("allocated_amount", false);
|
||||||
|
grid.set_column_disp("incentives", false);
|
||||||
|
|
||||||
|
frm.events.add_custom_buttons(frm);
|
||||||
|
},
|
||||||
|
add_custom_buttons: function(frm) {
|
||||||
|
["Opportunity", "Quotation", "Sales Order", "Delivery Note", "Sales Invoice"].forEach(function(doctype, i) {
|
||||||
|
if(frappe.model.can_read(doctype)) {
|
||||||
|
frm.add_custom_button(__(doctype), function() {
|
||||||
|
frappe.route_options = {"customer": frm.doc.name};
|
||||||
|
frappe.set_route("List", doctype);
|
||||||
|
}, __("View"));
|
||||||
|
}
|
||||||
|
if(frappe.model.can_create(doctype)) {
|
||||||
|
frm.add_custom_button(__(doctype), function() {
|
||||||
|
frappe.route_options = {"customer": frm.doc.name};
|
||||||
|
new_doc(doctype);
|
||||||
|
}, __("Make"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
validate: function(frm) {
|
||||||
|
if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal);
|
|
||||||
|
|
||||||
if(!frm.doc.__islocal) {
|
|
||||||
erpnext.utils.render_address_and_contact(frm);
|
|
||||||
} else {
|
|
||||||
erpnext.utils.clear_address_and_contact(frm);
|
|
||||||
}
|
|
||||||
|
|
||||||
var grid = cur_frm.get_field("sales_team").grid;
|
|
||||||
grid.set_column_disp("allocated_amount", false);
|
|
||||||
grid.set_column_disp("incentives", false);
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||||
cur_frm.cscript.load_defaults(doc, dt, dn);
|
cur_frm.cscript.load_defaults(doc, dt, dn);
|
||||||
@ -39,10 +61,6 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) {
|
|||||||
cur_frm.add_fetch('lead_name', 'company_name', 'customer_name');
|
cur_frm.add_fetch('lead_name', 'company_name', 'customer_name');
|
||||||
cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
|
cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
|
||||||
|
|
||||||
cur_frm.cscript.validate = function(doc, dt, dn) {
|
|
||||||
if(doc.lead_name) frappe.model.clear_doc("Lead", doc.lead_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.setup_dashboard = function(doc) {
|
cur_frm.cscript.setup_dashboard = function(doc) {
|
||||||
cur_frm.dashboard.reset(doc);
|
cur_frm.dashboard.reset(doc);
|
||||||
if(doc.__islocal)
|
if(doc.__islocal)
|
||||||
|
@ -20,16 +20,16 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
|||||||
if(doc.docstatus == 1 && doc.status!=='Lost') {
|
if(doc.docstatus == 1 && doc.status!=='Lost') {
|
||||||
cur_frm.add_custom_button(__('Sales Order'),
|
cur_frm.add_custom_button(__('Sales Order'),
|
||||||
cur_frm.cscript['Make Sales Order'], __("Make"));
|
cur_frm.cscript['Make Sales Order'], __("Make"));
|
||||||
|
|
||||||
if(doc.status!=="Ordered") {
|
if(doc.status!=="Ordered") {
|
||||||
cur_frm.add_custom_button(__('Lost'),
|
cur_frm.add_custom_button(__('Lost'),
|
||||||
cur_frm.cscript['Declare Order Lost'], __("Mark"));
|
cur_frm.cscript['Declare Order Lost'], __("Status"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.frm.doc.docstatus===0) {
|
if (this.frm.doc.docstatus===0) {
|
||||||
cur_frm.add_custom_button(__('From Opportunity'),
|
cur_frm.add_custom_button(__('Opportunity'),
|
||||||
function() {
|
function() {
|
||||||
frappe.model.map_current_doc({
|
frappe.model.map_current_doc({
|
||||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_quotation",
|
method: "erpnext.crm.doctype.opportunity.opportunity.make_quotation",
|
||||||
@ -42,7 +42,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("From"), "btn-default");
|
}, __("Get items from"), "btn-default");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.toggle_reqd_lead_customer();
|
this.toggle_reqd_lead_customer();
|
||||||
|
@ -88,13 +88,13 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
|||||||
} else {
|
} else {
|
||||||
if (this.frm.has_perm("submit")) {
|
if (this.frm.has_perm("submit")) {
|
||||||
// un-stop
|
// un-stop
|
||||||
cur_frm.add_custom_button(__('Re-open'), cur_frm.cscript['Unstop Sales Order']);
|
cur_frm.add_custom_button(__('Re-open'), cur_frm.cscript['Unstop Sales Order'], __("Status"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.frm.doc.docstatus===0) {
|
if (this.frm.doc.docstatus===0) {
|
||||||
cur_frm.add_custom_button(__('From Quotation'),
|
cur_frm.add_custom_button(__('Quotation'),
|
||||||
function() {
|
function() {
|
||||||
frappe.model.map_current_doc({
|
frappe.model.map_current_doc({
|
||||||
method: "erpnext.selling.doctype.quotation.quotation.make_sales_order",
|
method: "erpnext.selling.doctype.quotation.quotation.make_sales_order",
|
||||||
@ -107,7 +107,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
}, __("Get items from"));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.order_type(doc);
|
this.order_type(doc);
|
||||||
|
@ -21,8 +21,11 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
|||||||
cur_frm.add_custom_button(__('Packing Slip'),
|
cur_frm.add_custom_button(__('Packing Slip'),
|
||||||
cur_frm.cscript['Make Packing Slip'], __("Make"));
|
cur_frm.cscript['Make Packing Slip'], __("Make"));
|
||||||
}
|
}
|
||||||
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
|
||||||
|
if (!doc.__islocal && doc.docstatus==1) {
|
||||||
|
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
||||||
|
}
|
||||||
|
|
||||||
if (this.frm.doc.docstatus===0) {
|
if (this.frm.doc.docstatus===0) {
|
||||||
cur_frm.add_custom_button(__('Sales Order'),
|
cur_frm.add_custom_button(__('Sales Order'),
|
||||||
function() {
|
function() {
|
||||||
@ -38,7 +41,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("From"));
|
}, __("Get items from"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,6 @@ class TestItem(unittest.TestCase):
|
|||||||
"price_list_currency": "_Test Currency",
|
"price_list_currency": "_Test Currency",
|
||||||
"plc_conversion_rate": 1,
|
"plc_conversion_rate": 1,
|
||||||
"order_type": "Sales",
|
"order_type": "Sales",
|
||||||
"transaction_type": "selling"
|
|
||||||
})
|
})
|
||||||
|
|
||||||
for key, value in to_check.iteritems():
|
for key, value in to_check.iteritems():
|
||||||
|
@ -34,23 +34,28 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(doc.docstatus == 1 && doc.status != 'Stopped') {
|
if(doc.docstatus == 1 && doc.status != 'Stopped') {
|
||||||
if(doc.material_request_type === "Purchase")
|
|
||||||
cur_frm.add_custom_button(__("Make Supplier Quotation"),
|
|
||||||
this.make_supplier_quotation, __("Make"));
|
|
||||||
|
|
||||||
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
|
||||||
|
|
||||||
if(flt(doc.per_ordered, 2) < 100) {
|
if(flt(doc.per_ordered, 2) < 100) {
|
||||||
|
// make
|
||||||
if(doc.material_request_type === "Material Transfer" && doc.status === "Submitted")
|
if(doc.material_request_type === "Material Transfer" && doc.status === "Submitted")
|
||||||
cur_frm.add_custom_button(__("Transfer Material"), this.make_stock_entry, __("Make"));
|
cur_frm.add_custom_button(__("Transfer Material"),
|
||||||
|
this.make_stock_entry, __("Make"));
|
||||||
|
|
||||||
if(doc.material_request_type === "Material Issue" && doc.status === "Submitted")
|
if(doc.material_request_type === "Material Issue" && doc.status === "Submitted")
|
||||||
cur_frm.add_custom_button(__("Issue Material"), this.make_stock_entry, __("Make"));
|
cur_frm.add_custom_button(__("Issue Material"),
|
||||||
|
this.make_stock_entry, __("Make"));
|
||||||
|
|
||||||
if(doc.material_request_type === "Purchase")
|
if(doc.material_request_type === "Purchase")
|
||||||
cur_frm.add_custom_button(__('Make Purchase Order'),
|
cur_frm.add_custom_button(__('Purchase Order'),
|
||||||
this.make_purchase_order, __("Make"));
|
this.make_purchase_order, __("Make"));
|
||||||
|
|
||||||
|
if(doc.material_request_type === "Purchase")
|
||||||
|
cur_frm.add_custom_button(__("Supplier Quotation"),
|
||||||
|
this.make_supplier_quotation, __("Make"));
|
||||||
|
|
||||||
|
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
|
||||||
|
|
||||||
|
// stop
|
||||||
cur_frm.add_custom_button(__('Stop'),
|
cur_frm.add_custom_button(__('Stop'),
|
||||||
cur_frm.cscript['Stop Material Request'], __("Status"));
|
cur_frm.cscript['Stop Material Request'], __("Status"));
|
||||||
|
|
||||||
@ -70,7 +75,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("From"));
|
}, __("Get items from"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||||
|
@ -11,7 +11,7 @@ from frappe.utils import cstr, flt, getdate
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
|
from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
|
||||||
|
from erpnext.stock.get_item_details import apply_price_list
|
||||||
from erpnext.controllers.buying_controller import BuyingController
|
from erpnext.controllers.buying_controller import BuyingController
|
||||||
|
|
||||||
|
|
||||||
@ -182,6 +182,10 @@ def update_item(obj, target, source_parent):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_purchase_order(source_name, target_doc=None):
|
def make_purchase_order(source_name, target_doc=None):
|
||||||
|
def postprocess(source, target_doc):
|
||||||
|
target_doc.update(apply_price_list(target_doc.as_dict(), as_doc = True))
|
||||||
|
set_missing_values(source, target_doc)
|
||||||
|
|
||||||
doclist = get_mapped_doc("Material Request", source_name, {
|
doclist = get_mapped_doc("Material Request", source_name, {
|
||||||
"Material Request": {
|
"Material Request": {
|
||||||
"doctype": "Purchase Order",
|
"doctype": "Purchase Order",
|
||||||
@ -202,7 +206,7 @@ def make_purchase_order(source_name, target_doc=None):
|
|||||||
"postprocess": update_item,
|
"postprocess": update_item,
|
||||||
"condition": lambda doc: doc.ordered_qty < doc.qty
|
"condition": lambda doc: doc.ordered_qty < doc.qty
|
||||||
}
|
}
|
||||||
}, target_doc, set_missing_values)
|
}, target_doc, postprocess)
|
||||||
|
|
||||||
return doclist
|
return doclist
|
||||||
|
|
||||||
@ -218,11 +222,13 @@ def make_purchase_order_based_on_supplier(source_name, target_doc=None):
|
|||||||
|
|
||||||
def postprocess(source, target_doc):
|
def postprocess(source, target_doc):
|
||||||
target_doc.supplier = source_name
|
target_doc.supplier = source_name
|
||||||
set_missing_values(source, target_doc)
|
|
||||||
target_doc.set("items", [d for d in target_doc.get("items")
|
target_doc.set("items", [d for d in target_doc.get("items")
|
||||||
if d.get("item_code") in supplier_items and d.get("qty") > 0])
|
if d.get("item_code") in supplier_items and d.get("qty") > 0])
|
||||||
|
|
||||||
return target_doc
|
target_doc.update(apply_price_list(target_doc.as_dict(), as_doc = True))
|
||||||
|
|
||||||
|
set_missing_values(source, target_doc)
|
||||||
|
|
||||||
for mr in material_requests:
|
for mr in material_requests:
|
||||||
target_doc = get_mapped_doc("Material Request", mr, {
|
target_doc = get_mapped_doc("Material Request", mr, {
|
||||||
@ -264,6 +270,10 @@ def get_material_requests_based_on_supplier(supplier):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_supplier_quotation(source_name, target_doc=None):
|
def make_supplier_quotation(source_name, target_doc=None):
|
||||||
|
def postprocess(source, target_doc):
|
||||||
|
target_doc.update(apply_price_list(target_doc.as_dict(), as_doc = True))
|
||||||
|
set_missing_values(source, target_doc)
|
||||||
|
|
||||||
doclist = get_mapped_doc("Material Request", source_name, {
|
doclist = get_mapped_doc("Material Request", source_name, {
|
||||||
"Material Request": {
|
"Material Request": {
|
||||||
"doctype": "Supplier Quotation",
|
"doctype": "Supplier Quotation",
|
||||||
@ -280,7 +290,7 @@ def make_supplier_quotation(source_name, target_doc=None):
|
|||||||
"parenttype": "prevdoc_doctype"
|
"parenttype": "prevdoc_doctype"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, target_doc, set_missing_values)
|
}, target_doc, postprocess)
|
||||||
|
|
||||||
return doclist
|
return doclist
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("From"));
|
}, __("Get items from"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.frm.doc.docstatus == 1 && this.frm.doc.status!="Closed") {
|
if(this.frm.doc.docstatus == 1 && this.frm.doc.status!="Closed") {
|
||||||
|
@ -644,7 +644,7 @@
|
|||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Get Current Stock",
|
"label": "Get current stock",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"oldfieldtype": "Button",
|
"oldfieldtype": "Button",
|
||||||
@ -2302,7 +2302,7 @@
|
|||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"menu_index": 0,
|
"menu_index": 0,
|
||||||
"modified": "2015-12-30 18:15:06.678001",
|
"modified": "2016-01-15 04:14:16.311445",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Purchase Receipt",
|
"name": "Purchase Receipt",
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -21,14 +21,13 @@ def get_item_details(args):
|
|||||||
"selling_price_list": None,
|
"selling_price_list": None,
|
||||||
"price_list_currency": None,
|
"price_list_currency": None,
|
||||||
"plc_conversion_rate": 1.0,
|
"plc_conversion_rate": 1.0,
|
||||||
"parenttype": "",
|
"doctype": "",
|
||||||
"parent": "",
|
"name": "",
|
||||||
"supplier": None,
|
"supplier": None,
|
||||||
"transaction_date": None,
|
"transaction_date": None,
|
||||||
"conversion_rate": 1.0,
|
"conversion_rate": 1.0,
|
||||||
"buying_price_list": None,
|
"buying_price_list": None,
|
||||||
"is_subcontracted": "Yes" / "No",
|
"is_subcontracted": "Yes" / "No",
|
||||||
"transaction_type": "selling",
|
|
||||||
"ignore_pricing_rule": 0/1
|
"ignore_pricing_rule": 0/1
|
||||||
"project_name": ""
|
"project_name": ""
|
||||||
}
|
}
|
||||||
@ -49,7 +48,7 @@ def get_item_details(args):
|
|||||||
|
|
||||||
get_price_list_rate(args, item_doc, out)
|
get_price_list_rate(args, item_doc, out)
|
||||||
|
|
||||||
if args.transaction_type == "selling" and cint(args.is_pos):
|
if args.customer and cint(args.is_pos):
|
||||||
out.update(get_pos_profile_item_details(args.company, args))
|
out.update(get_pos_profile_item_details(args.company, args))
|
||||||
|
|
||||||
# update args with out, if key or value not exists
|
# update args with out, if key or value not exists
|
||||||
@ -59,7 +58,7 @@ def get_item_details(args):
|
|||||||
|
|
||||||
out.update(get_pricing_rule_for_item(args))
|
out.update(get_pricing_rule_for_item(args))
|
||||||
|
|
||||||
if args.get("parenttype") in ("Sales Invoice", "Delivery Note"):
|
if args.get("doctype") in ("Sales Invoice", "Delivery Note"):
|
||||||
if item_doc.has_serial_no == 1 and not args.serial_no:
|
if item_doc.has_serial_no == 1 and not args.serial_no:
|
||||||
out.serial_no = get_serial_nos_by_fifo(args, item_doc)
|
out.serial_no = get_serial_nos_by_fifo(args, item_doc)
|
||||||
|
|
||||||
@ -78,13 +77,6 @@ def process_args(args):
|
|||||||
|
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|
||||||
if not args.get("transaction_type"):
|
|
||||||
if args.get("parenttype")=="Material Request" or \
|
|
||||||
frappe.get_meta(args.get("parenttype")).get_field("supplier"):
|
|
||||||
args.transaction_type = "buying"
|
|
||||||
else:
|
|
||||||
args.transaction_type = "selling"
|
|
||||||
|
|
||||||
if not args.get("price_list"):
|
if not args.get("price_list"):
|
||||||
args.price_list = args.get("selling_price_list") or args.get("buying_price_list")
|
args.price_list = args.get("selling_price_list") or args.get("buying_price_list")
|
||||||
|
|
||||||
@ -115,7 +107,7 @@ def validate_item_details(args, item):
|
|||||||
from erpnext.stock.doctype.item.item import validate_end_of_life
|
from erpnext.stock.doctype.item.item import validate_end_of_life
|
||||||
validate_end_of_life(item.name, item.end_of_life, item.disabled)
|
validate_end_of_life(item.name, item.end_of_life, item.disabled)
|
||||||
|
|
||||||
if args.transaction_type == "selling":
|
if args.customer or args.doctype=="Opportunity":
|
||||||
# validate if sales item or service item
|
# validate if sales item or service item
|
||||||
if args.get("order_type") == "Maintenance":
|
if args.get("order_type") == "Maintenance":
|
||||||
if item.is_service_item != 1:
|
if item.is_service_item != 1:
|
||||||
@ -127,7 +119,7 @@ def validate_item_details(args, item):
|
|||||||
if cint(item.has_variants):
|
if cint(item.has_variants):
|
||||||
throw(_("Item {0} is a template, please select one of its variants").format(item.name))
|
throw(_("Item {0} is a template, please select one of its variants").format(item.name))
|
||||||
|
|
||||||
elif args.transaction_type == "buying" and args.parenttype != "Material Request":
|
elif args.supplier and args.doctype != "Material Request":
|
||||||
# validate if purchase item or subcontracted item
|
# validate if purchase item or subcontracted item
|
||||||
if item.is_purchase_item != 1:
|
if item.is_purchase_item != 1:
|
||||||
throw(_("Item {0} must be a Purchase Item").format(item.name))
|
throw(_("Item {0} must be a Purchase Item").format(item.name))
|
||||||
@ -160,7 +152,7 @@ def get_basic_details(args, item):
|
|||||||
"item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in
|
"item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in
|
||||||
item.get("taxes")))),
|
item.get("taxes")))),
|
||||||
"uom": item.stock_uom,
|
"uom": item.stock_uom,
|
||||||
"min_order_qty": flt(item.min_order_qty) if args.parenttype == "Material Request" else "",
|
"min_order_qty": flt(item.min_order_qty) if args.doctype == "Material Request" else "",
|
||||||
"conversion_factor": 1.0,
|
"conversion_factor": 1.0,
|
||||||
"qty": args.qty or 1.0,
|
"qty": args.qty or 1.0,
|
||||||
"stock_qty": 1.0,
|
"stock_qty": 1.0,
|
||||||
@ -201,7 +193,7 @@ def get_default_expense_account(args, item):
|
|||||||
|
|
||||||
def get_default_cost_center(args, item):
|
def get_default_cost_center(args, item):
|
||||||
return (frappe.db.get_value("Project", args.get("project_name"), "cost_center")
|
return (frappe.db.get_value("Project", args.get("project_name"), "cost_center")
|
||||||
or (item.selling_cost_center if args.get("transaction_type") == "selling" else item.buying_cost_center)
|
or (item.selling_cost_center if args.get("customer") else item.buying_cost_center)
|
||||||
or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
|
or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
|
||||||
or args.get("cost_center"))
|
or args.get("cost_center"))
|
||||||
|
|
||||||
@ -212,10 +204,13 @@ def get_price_list_rate(args, item_doc, out):
|
|||||||
validate_price_list(args)
|
validate_price_list(args)
|
||||||
validate_conversion_rate(args, meta)
|
validate_conversion_rate(args, meta)
|
||||||
|
|
||||||
price_list_rate = get_price_list_rate_for(args, item_doc.name)
|
price_list_rate = get_price_list_rate_for(args.price_list, item_doc.name)
|
||||||
if not price_list_rate and item_doc.variant_of:
|
|
||||||
price_list_rate = get_price_list_rate_for(args, item_doc.variant_of)
|
|
||||||
|
|
||||||
|
# variant
|
||||||
|
if not price_list_rate and item_doc.variant_of:
|
||||||
|
price_list_rate = get_price_list_rate_for(args.price_list, item_doc.variant_of)
|
||||||
|
|
||||||
|
# insert in database
|
||||||
if not price_list_rate:
|
if not price_list_rate:
|
||||||
if args.price_list and args.rate:
|
if args.price_list and args.rate:
|
||||||
insert_item_price(args)
|
insert_item_price(args)
|
||||||
@ -224,10 +219,10 @@ def get_price_list_rate(args, item_doc, out):
|
|||||||
out.price_list_rate = flt(price_list_rate) * flt(args.plc_conversion_rate) \
|
out.price_list_rate = flt(price_list_rate) * flt(args.plc_conversion_rate) \
|
||||||
/ flt(args.conversion_rate)
|
/ flt(args.conversion_rate)
|
||||||
|
|
||||||
if not out.price_list_rate and args.transaction_type == "buying":
|
if not out.price_list_rate and args.supplier:
|
||||||
from erpnext.stock.doctype.item.item import get_last_purchase_details
|
from erpnext.stock.doctype.item.item import get_last_purchase_details
|
||||||
out.update(get_last_purchase_details(item_doc.name,
|
out.update(get_last_purchase_details(item_doc.name,
|
||||||
args.parent, args.conversion_rate))
|
args.name, args.conversion_rate))
|
||||||
|
|
||||||
def insert_item_price(args):
|
def insert_item_price(args):
|
||||||
"""Insert Item Price if Price List and Price List Rate are specified and currency is the same"""
|
"""Insert Item Price if Price List and Price List Rate are specified and currency is the same"""
|
||||||
@ -249,14 +244,14 @@ def insert_item_price(args):
|
|||||||
frappe.msgprint(_("Item Price added for {0} in Price List {1}").format(args.item_code,
|
frappe.msgprint(_("Item Price added for {0} in Price List {1}").format(args.item_code,
|
||||||
args.price_list))
|
args.price_list))
|
||||||
|
|
||||||
def get_price_list_rate_for(args, item_code):
|
def get_price_list_rate_for(price_list, item_code):
|
||||||
return frappe.db.get_value("Item Price",
|
return frappe.db.get_value("Item Price",
|
||||||
{"price_list": args.price_list, "item_code": item_code}, "price_list_rate")
|
{"price_list": price_list, "item_code": item_code}, "price_list_rate")
|
||||||
|
|
||||||
def validate_price_list(args):
|
def validate_price_list(args):
|
||||||
if args.get("price_list"):
|
if args.get("price_list"):
|
||||||
if not frappe.db.get_value("Price List",
|
if not frappe.db.get_value("Price List",
|
||||||
{"name": args.price_list, args.transaction_type: 1, "enabled": 1}):
|
{"name": args.price_list, "selling" if (args.customer or args.lead) else "buying": 1, "enabled": 1}):
|
||||||
throw(_("Price List {0} is disabled").format(args.price_list))
|
throw(_("Price List {0} is disabled").format(args.price_list))
|
||||||
else:
|
else:
|
||||||
throw(_("Price List not selected"))
|
throw(_("Price List not selected"))
|
||||||
@ -288,7 +283,7 @@ def validate_conversion_rate(args, meta):
|
|||||||
frappe._dict({"fields": args})))
|
frappe._dict({"fields": args})))
|
||||||
|
|
||||||
def get_party_item_code(args, item_doc, out):
|
def get_party_item_code(args, item_doc, out):
|
||||||
if args.transaction_type == "selling":
|
if args.customer:
|
||||||
customer_item_code = item_doc.get("customer_items", {"customer_name": args.customer})
|
customer_item_code = item_doc.get("customer_items", {"customer_name": args.customer})
|
||||||
out.customer_item_code = customer_item_code[0].ref_code if customer_item_code else None
|
out.customer_item_code = customer_item_code[0].ref_code if customer_item_code else None
|
||||||
else:
|
else:
|
||||||
@ -369,21 +364,27 @@ def get_batch_qty(batch_no,warehouse,item_code):
|
|||||||
return {'actual_batch_qty': actual_batch_qty}
|
return {'actual_batch_qty': actual_batch_qty}
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def apply_price_list(args):
|
def apply_price_list(args, as_doc=False):
|
||||||
"""
|
"""Apply pricelist on a document-like dict object and return as
|
||||||
|
{'parent': dict, 'children': list}
|
||||||
|
|
||||||
|
:param args: See below
|
||||||
|
:param as_doc: Updates value in the passed dict
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
"item_list": [{"doctype": "", "name": "", "item_code": "", "brand": "", "item_group": ""}, ...],
|
"doctype": "",
|
||||||
|
"name": "",
|
||||||
|
"items": [{"doctype": "", "name": "", "item_code": "", "brand": "", "item_group": ""}, ...],
|
||||||
"conversion_rate": 1.0,
|
"conversion_rate": 1.0,
|
||||||
"selling_price_list": None,
|
"selling_price_list": None,
|
||||||
"price_list_currency": None,
|
"price_list_currency": None,
|
||||||
"plc_conversion_rate": 1.0,
|
"plc_conversion_rate": 1.0,
|
||||||
"parenttype": "",
|
"doctype": "",
|
||||||
"parent": "",
|
"name": "",
|
||||||
"supplier": None,
|
"supplier": None,
|
||||||
"transaction_date": None,
|
"transaction_date": None,
|
||||||
"conversion_rate": 1.0,
|
"conversion_rate": 1.0,
|
||||||
"buying_price_list": None,
|
"buying_price_list": None,
|
||||||
"transaction_type": "selling",
|
|
||||||
"ignore_pricing_rule": 0/1
|
"ignore_pricing_rule": 0/1
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@ -392,10 +393,8 @@ def apply_price_list(args):
|
|||||||
parent = get_price_list_currency_and_exchange_rate(args)
|
parent = get_price_list_currency_and_exchange_rate(args)
|
||||||
children = []
|
children = []
|
||||||
|
|
||||||
if "item_list" in args:
|
if "items" in args:
|
||||||
item_list = args.get("item_list")
|
item_list = args.get("items")
|
||||||
del args["item_list"]
|
|
||||||
|
|
||||||
args.update(parent)
|
args.update(parent)
|
||||||
|
|
||||||
for item in item_list:
|
for item in item_list:
|
||||||
@ -404,16 +403,31 @@ def apply_price_list(args):
|
|||||||
item_details = apply_price_list_on_item(args_copy)
|
item_details = apply_price_list_on_item(args_copy)
|
||||||
children.append(item_details)
|
children.append(item_details)
|
||||||
|
|
||||||
return {
|
if as_doc:
|
||||||
"parent": parent,
|
args.price_list_currency = parent.price_list_currency
|
||||||
"children": children
|
args.plc_conversion_rate = parent.plc_conversion_rate
|
||||||
}
|
if args.get('items'):
|
||||||
|
for i, item in enumerate(args.get('items')):
|
||||||
|
for fieldname in children[i]:
|
||||||
|
# if the field exists in the original doc
|
||||||
|
# update the value
|
||||||
|
if fieldname in item and fieldname not in ("name", "doctype"):
|
||||||
|
item[fieldname] = children[i][fieldname]
|
||||||
|
|
||||||
|
return args
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
"parent": parent,
|
||||||
|
"children": children
|
||||||
|
}
|
||||||
|
|
||||||
def apply_price_list_on_item(args):
|
def apply_price_list_on_item(args):
|
||||||
item_details = frappe._dict()
|
item_details = frappe._dict()
|
||||||
item_doc = frappe.get_doc("Item", args.item_code)
|
item_doc = frappe.get_doc("Item", args.item_code)
|
||||||
get_price_list_rate(args, item_doc, item_details)
|
get_price_list_rate(args, item_doc, item_details)
|
||||||
|
|
||||||
item_details.update(get_pricing_rule_for_item(args))
|
item_details.update(get_pricing_rule_for_item(args))
|
||||||
|
|
||||||
return item_details
|
return item_details
|
||||||
|
|
||||||
def get_price_list_currency(price_list):
|
def get_price_list_currency(price_list):
|
||||||
@ -437,10 +451,10 @@ def get_price_list_currency_and_exchange_rate(args):
|
|||||||
and price_list_currency != args.price_list_currency):
|
and price_list_currency != args.price_list_currency):
|
||||||
plc_conversion_rate = get_exchange_rate(price_list_currency, args.currency) or plc_conversion_rate
|
plc_conversion_rate = get_exchange_rate(price_list_currency, args.currency) or plc_conversion_rate
|
||||||
|
|
||||||
return {
|
return frappe._dict({
|
||||||
"price_list_currency": price_list_currency,
|
"price_list_currency": price_list_currency,
|
||||||
"plc_conversion_rate": plc_conversion_rate
|
"plc_conversion_rate": plc_conversion_rate
|
||||||
}
|
})
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_default_bom(item_code=None):
|
def get_default_bom(item_code=None):
|
||||||
|
@ -28,7 +28,7 @@ erpnext.support.MaintenanceSchedule = frappe.ui.form.Controller.extend({
|
|||||||
company: me.frm.doc.company
|
company: me.frm.doc.company
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, __("From"));
|
}, __("Get items from"));
|
||||||
} else if (this.frm.doc.docstatus === 1) {
|
} else if (this.frm.doc.docstatus === 1) {
|
||||||
this.frm.add_custom_button(__("Make Maintenance Visit"), function() {
|
this.frm.add_custom_button(__("Make Maintenance Visit"), function() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
|
@ -26,7 +26,7 @@ erpnext.support.MaintenanceVisit = frappe.ui.form.Controller.extend({
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("From"));
|
}, __("Get items from"));
|
||||||
cur_frm.add_custom_button(__('Warranty Claim'),
|
cur_frm.add_custom_button(__('Warranty Claim'),
|
||||||
function() {
|
function() {
|
||||||
frappe.model.map_current_doc({
|
frappe.model.map_current_doc({
|
||||||
@ -38,7 +38,7 @@ erpnext.support.MaintenanceVisit = frappe.ui.form.Controller.extend({
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("From"));
|
}, __("Get items from"));
|
||||||
cur_frm.add_custom_button(__('Sales Order'),
|
cur_frm.add_custom_button(__('Sales Order'),
|
||||||
function() {
|
function() {
|
||||||
frappe.model.map_current_doc({
|
frappe.model.map_current_doc({
|
||||||
@ -51,7 +51,7 @@ erpnext.support.MaintenanceVisit = frappe.ui.form.Controller.extend({
|
|||||||
company: cur_frm.doc.company
|
company: cur_frm.doc.company
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, __("From"));
|
}, __("Get items from"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user