mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 17:04:47 +00:00
[get_query] to server side
This commit is contained in:
@@ -51,7 +51,38 @@ erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.ext
|
||||
wn.set_route("general-ledger");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if(doc.docstatus===0) {
|
||||
cur_frm.add_custom_button(wn._('From Purchase Order'),
|
||||
function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
|
||||
source_doctype: "Purchase Order",
|
||||
get_query_filters: {
|
||||
supplier: cur_frm.doc.supplier || undefined,
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_billed: ["<", 99.99],
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
cur_frm.add_custom_button(wn._('From Purchase Receipt'),
|
||||
function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
|
||||
source_doctype: "Purchase Receipt",
|
||||
get_query_filters: {
|
||||
supplier: cur_frm.doc.supplier || undefined,
|
||||
docstatus: 1,
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.is_opening(doc);
|
||||
},
|
||||
|
||||
@@ -68,22 +99,11 @@ erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.ext
|
||||
this.calculate_total_advance("Purchase Invoice", "advance_allocation_details");
|
||||
this.frm.refresh_fields();
|
||||
},
|
||||
|
||||
get_items: function() {
|
||||
if(doc.purchase_order_main) {
|
||||
wn.model.map_current_doc({
|
||||
method: "buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
|
||||
source_name: cur_frm.doc.purchase_order_main,
|
||||
})
|
||||
}
|
||||
else if(doc.purchase_receipt_main) {
|
||||
wn.model.map_current_doc({
|
||||
method: "selling.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
|
||||
source_name: cur_frm.doc.purchase_receipt_main,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tc_name: function() {
|
||||
this.get_terms();
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
|
||||
@@ -43,17 +43,6 @@ class DocType(BuyingController):
|
||||
'target_ref_field': 'import_amount',
|
||||
'source_field': 'import_amount',
|
||||
'percent_join_field': 'purchase_order',
|
||||
},
|
||||
{
|
||||
'source_dt': 'Purchase Invoice Item',
|
||||
'target_dt': 'Purchase Receipt Item',
|
||||
'join_field': 'pr_detail',
|
||||
'target_field': 'billed_amt',
|
||||
'target_parent_dt': 'Purchase Receipt',
|
||||
'target_parent_field': 'per_billed',
|
||||
'target_ref_field': 'import_amount',
|
||||
'source_field': 'import_amount',
|
||||
'percent_join_field': 'purchase_receipt',
|
||||
}]
|
||||
|
||||
def validate(self):
|
||||
@@ -65,7 +54,6 @@ class DocType(BuyingController):
|
||||
self.check_conversion_rate()
|
||||
self.validate_bill_no_date()
|
||||
self.validate_bill_no()
|
||||
self.validate_reference_value()
|
||||
self.validate_credit_acc()
|
||||
self.clear_unallocated_advances("Purchase Invoice Advance", "advance_allocation_details")
|
||||
self.check_for_acc_head_of_supplier()
|
||||
@@ -244,12 +232,9 @@ class DocType(BuyingController):
|
||||
msgprint("Supplier name %s do not match with supplier name of %s %s." %(self.doc.supplier,cstr(d.purchase_receipt)))
|
||||
raise Exception , " Validation Error "
|
||||
|
||||
# Validate values with reference document
|
||||
#----------------------------------------
|
||||
def validate_reference_value(self):
|
||||
get_obj('DocType Mapper', 'Purchase Order-Purchase Invoice', with_children = 1).validate_reference_value(self, self.doc.name)
|
||||
|
||||
|
||||
pass
|
||||
|
||||
# Validate PO and PR
|
||||
# -------------------
|
||||
def validate_po_pr(self, d):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-21 16:16:39",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:51:53",
|
||||
"modified": "2013-07-08 18:03:17",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -31,6 +31,7 @@
|
||||
"parent": "Purchase Invoice",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1
|
||||
},
|
||||
@@ -212,12 +213,6 @@
|
||||
"options": "Purchase Invoice Item",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break0",
|
||||
"fieldtype": "Section Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "recalculate",
|
||||
@@ -226,44 +221,6 @@
|
||||
"oldfieldtype": "Button",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_17",
|
||||
"fieldtype": "Section Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Select Items from Purchase Order",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "purchase_order_main",
|
||||
"fieldtype": "Link",
|
||||
"label": "Purchase Order",
|
||||
"oldfieldname": "purchase_order_main",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Purchase Order",
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Select Items from Purchase Receipt",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "purchase_receipt_main",
|
||||
"fieldtype": "Link",
|
||||
"label": "Purchase Receipt",
|
||||
"oldfieldname": "purchase_receipt_main",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Purchase Receipt",
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "get_items",
|
||||
"fieldtype": "Button",
|
||||
"label": "Get Items",
|
||||
"oldfieldtype": "Button",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "currency_price_list",
|
||||
@@ -694,12 +651,6 @@
|
||||
"options": "Terms and Conditions",
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "get_terms",
|
||||
"fieldtype": "Button",
|
||||
"label": "Get Terms and Conditions"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "terms",
|
||||
@@ -836,69 +787,50 @@
|
||||
"read_only": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "Accounts Manager",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Accounts Manager",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "Accounts User",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "Purchase User",
|
||||
"submit": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Purchase User",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Accounts User",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Purchase User",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"match": "supplier",
|
||||
"permlevel": 0,
|
||||
"role": "Supplier"
|
||||
"role": "Supplier",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Accounts Manager",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Auditor",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
}
|
||||
]
|
||||
@@ -66,8 +66,44 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
if(doc.outstanding_amount!=0)
|
||||
cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
|
||||
}
|
||||
|
||||
if (this.frm.doc.docstatus===0) {
|
||||
cur_frm.add_custom_button(wn._('From Sales Order'),
|
||||
function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "selling.doctype.sales_order.sales_order.make_sales_invoice",
|
||||
source_doctype: "Sales Order",
|
||||
get_query_filters: {
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_billed: ["<", 99.99],
|
||||
customer: cur_frm.doc.customer || undefined,
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
cur_frm.add_custom_button(wn._('From Delivery Note'),
|
||||
function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
||||
source_doctype: "Delivery Note",
|
||||
get_query_filters: {
|
||||
docstatus: 1,
|
||||
customer: cur_frm.doc.customer || undefined,
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.hide_fields(doc, dt, dn);
|
||||
},
|
||||
|
||||
tc_name: function() {
|
||||
this.get_terms();
|
||||
},
|
||||
|
||||
is_pos: function() {
|
||||
if(cint(this.frm.doc.is_pos)) {
|
||||
@@ -122,9 +158,8 @@ $.extend(cur_frm.cscript, new erpnext.accounts.SalesInvoiceController({frm: cur_
|
||||
// Hide Fields
|
||||
// ------------
|
||||
cur_frm.cscript.hide_fields = function(doc, cdt, cdn) {
|
||||
par_flds = ['project_name', 'due_date', 'sales_order_main',
|
||||
'delivery_note_main', 'get_items', 'is_opening', 'conversion_rate',
|
||||
'source', 'cancel_reason', 'total_advance', 'gross_profit',
|
||||
par_flds = ['project_name', 'due_date', 'is_opening', 'conversion_rate',
|
||||
'source', 'total_advance', 'gross_profit',
|
||||
'gross_profit_percent', 'get_advances_received',
|
||||
'advance_adjustment_details', 'sales_partner', 'commission_rate',
|
||||
'total_commission', 'advances'];
|
||||
@@ -190,41 +225,14 @@ cur_frm.cscript.is_opening = function(doc, dt, dn) {
|
||||
if (doc.is_opening == 'Yes') unhide_field('aging_date');
|
||||
}
|
||||
|
||||
// Get Items based on SO or DN Selected
|
||||
cur_frm.cscript.get_items = function(doc, dt, dn) {
|
||||
if(doc.delivery_note_main) {
|
||||
wn.model.map_current_doc({
|
||||
method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
||||
source_name: cur_frm.doc.delivery_note_main,
|
||||
})
|
||||
}
|
||||
else if(doc.sales_order_main) {
|
||||
wn.model.map_current_doc({
|
||||
method: "selling.doctype.sales_order.sales_order.make_sales_invoice",
|
||||
source_name: cur_frm.doc.sales_order_main,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Make Delivery Note Button
|
||||
//-----------------------------
|
||||
|
||||
cur_frm.cscript['Make Delivery Note'] = function() {
|
||||
|
||||
var doc = cur_frm.doc
|
||||
n = wn.model.make_new_doc_and_get_name('Delivery Note');
|
||||
$c('dt_map', args={
|
||||
'docs':wn.model.compress([locals['Delivery Note'][n]]),
|
||||
'from_doctype':doc.doctype,
|
||||
'to_doctype':'Delivery Note',
|
||||
'from_docname':doc.name,
|
||||
'from_to_list':"[['Sales Invoice','Delivery Note'],['Sales Invoice Item','Delivery Note Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]"
|
||||
}, function(r,rt) {
|
||||
loaddoc('Delivery Note', n);
|
||||
}
|
||||
);
|
||||
wn.model.open_mapped_doc({
|
||||
method: "accounts.doctype.sales_invoice.sales_invoice.make_delivery_note",
|
||||
source_name: cur_frm.doc.name
|
||||
})
|
||||
}
|
||||
|
||||
cur_frm.cscript.make_bank_voucher = function() {
|
||||
@@ -399,8 +407,6 @@ cur_frm.fields_dict.delivery_note_main.get_query = function(doc) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
cur_frm.cscript.income_account = function(doc, cdt, cdn){
|
||||
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "income_account");
|
||||
}
|
||||
|
||||
@@ -51,20 +51,6 @@ class DocType(SellingController):
|
||||
'percent_join_field': 'sales_order',
|
||||
'status_field': 'billing_status',
|
||||
'keyword': 'Billed'
|
||||
},
|
||||
{
|
||||
'source_dt': 'Sales Invoice Item',
|
||||
'target_dt': 'Delivery Note Item',
|
||||
'join_field': 'dn_detail',
|
||||
'target_field': 'billed_amt',
|
||||
'target_parent_dt': 'Delivery Note',
|
||||
'target_parent_field': 'per_billed',
|
||||
'target_ref_field': 'export_amount',
|
||||
'source_field': 'export_amount',
|
||||
'percent_join_field': 'delivery_note',
|
||||
'status_field': 'billing_status',
|
||||
'keyword': 'Billed',
|
||||
'no_tolerance': True,
|
||||
}]
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:05",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:54:19",
|
||||
"modified": "2013-07-08 17:05:43",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -350,52 +350,6 @@
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break0",
|
||||
"fieldtype": "Section Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Select Items from Sales Order",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sales_order_main",
|
||||
"fieldtype": "Link",
|
||||
"label": "Sales Order",
|
||||
"oldfieldname": "sales_order_main",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Sales Order",
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Select Items from Delivery Note",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "delivery_note_main",
|
||||
"fieldtype": "Link",
|
||||
"label": "Delivery Note",
|
||||
"oldfieldname": "delivery_note_main",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Delivery Note",
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "get_items",
|
||||
"fieldtype": "Button",
|
||||
"label": "Get Items",
|
||||
"oldfieldtype": "Button",
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "col_break25",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "net_total_export",
|
||||
@@ -789,25 +743,6 @@
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_71",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "get_terms",
|
||||
"fieldtype": "Button",
|
||||
"label": "Get Terms and Conditions",
|
||||
"oldfieldtype": "Button",
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_73",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "terms",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-02-25 10:38:57",
|
||||
"creation": "2013-05-02 15:20:25",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-01 11:56:43",
|
||||
"modified": "2013-07-08 11:08:23",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,7 +10,7 @@
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"name": "__common__",
|
||||
"query": "select \n `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n`tabDelivery Note`.`status` as \"Status\",\n `tabDelivery Note`.`posting_date` as \"Date:Date\",\n `tabDelivery Note`.`project_name` as \"Project\",\n `tabDelivery Note Item`.item_code as \"Item:Link/Item:120\",\n `tabDelivery Note Item`.amount as \"Amount:Currency:110\",\n (`tabDelivery Note Item`.billed_amt * ifnull(`tabDelivery Note`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabDelivery Note Item`.amount,0) - (ifnull(`tabDelivery Note Item`.billed_amt,0) * ifnull(`tabDelivery Note`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabDelivery Note Item`.item_name as \"Item Name::150\",\n `tabDelivery Note Item`.description as \"Description:Data:200\"\nfrom\n `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n `tabDelivery Note Item`.`parent` = `tabDelivery Note`.`name`\n and `tabDelivery Note`.docstatus = 1\n and `tabDelivery Note`.status != \"Stopped\"\n and ifnull(`tabDelivery Note Item`.billed_amt,0) < ifnull(`tabDelivery Note Item`.export_amount,0)\norder by `tabDelivery Note`.posting_date asc",
|
||||
"query": "select \n `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n`tabDelivery Note`.`status` as \"Status\",\n `tabDelivery Note`.`posting_date` as \"Date:Date\",\n `tabDelivery Note`.`project_name` as \"Project\",\n `tabDelivery Note Item`.item_code as \"Item:Link/Item:120\",\n `tabDelivery Note Item`.amount as \"Amount:Currency:110\",\n (`tabDelivery Note Item`.billed_amt * ifnull(`tabDelivery Note`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabDelivery Note Item`.amount,0) - (ifnull(`tabDelivery Note Item`.billed_amt,0) * ifnull(`tabDelivery Note`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabDelivery Note Item`.item_name as \"Item Name::150\",\n `tabDelivery Note Item`.description as \"Description:Data:200\",\n `tabDelivery Note Item`.prevdoc_docname as \"Sales Order:Link/Sales Order:120\",\n `tabDelivery Note Item`.prevdoc_date as \"SO Date:Date:100\",\n `tabDelivery Note`.address_display as \"Customer Address::150\"\nfrom\n `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n `tabDelivery Note Item`.`parent` = `tabDelivery Note`.`name`\n and `tabDelivery Note`.docstatus = 1\n and `tabDelivery Note`.status != \"Stopped\"\n and ifnull(`tabDelivery Note Item`.billed_amt,0) < ifnull(`tabDelivery Note Item`.export_amount,0)\norder by `tabDelivery Note`.posting_date asc",
|
||||
"ref_doctype": "Sales Invoice",
|
||||
"report_name": "Delivered Items To Be Billed",
|
||||
"report_type": "Query Report"
|
||||
|
||||
Reference in New Issue
Block a user