mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 19:49:18 +00:00
[mapper] material request - PO/supp quote/stock entry
This commit is contained in:
@@ -83,7 +83,13 @@ cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){
|
||||
|
||||
}
|
||||
|
||||
//========================= Make Purchase Receipt =======================================================
|
||||
cur_frm.cscript.get_items = function(doc, dt, dn) {
|
||||
wn.model.map_current_doc({
|
||||
method: "stock.doctype.material_request.material_request.make_purchase_order",
|
||||
source_name: cur_frm.doc.indent_no,
|
||||
})
|
||||
}
|
||||
|
||||
cur_frm.cscript['Make Purchase Receipt'] = function() {
|
||||
n = wn.model.make_new_doc_and_get_name('Purchase Receipt');
|
||||
$c('dt_map', args={
|
||||
|
||||
@@ -21,7 +21,6 @@ from webnotes.utils import cstr, flt
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
from buying.utils import get_last_purchase_details
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
@@ -72,24 +71,6 @@ class DocType(BuyingController):
|
||||
def get_bin_details(self, arg = ''):
|
||||
return get_obj(dt='Purchase Common').get_bin_details(arg)
|
||||
|
||||
# Pull Material Request
|
||||
def get_indent_details(self):
|
||||
if self.doc.indent_no:
|
||||
get_obj('DocType Mapper','Material Request-Purchase Order').dt_map('Material Request','Purchase Order',self.doc.indent_no, self.doc, self.doclist, "[['Material Request','Purchase Order'],['Material Request Item', 'Purchase Order Item']]")
|
||||
for d in getlist(self.doclist, 'po_details'):
|
||||
if d.item_code and not d.purchase_rate:
|
||||
last_purchase_details = get_last_purchase_details(d.item_code, self.doc.name)
|
||||
if last_purchase_details:
|
||||
conversion_factor = d.conversion_factor or 1.0
|
||||
conversion_rate = self.doc.fields.get('conversion_rate') or 1.0
|
||||
d.purchase_ref_rate = last_purchase_details['purchase_ref_rate'] * conversion_factor
|
||||
d.discount_rate = last_purchase_details['discount_rate']
|
||||
d.purchase_rate = last_purchase_details['purchase_rate'] * conversion_factor
|
||||
d.import_ref_rate = d.purchase_ref_rate / conversion_rate
|
||||
d.import_rate = d.purchase_rate / conversion_rate
|
||||
else:
|
||||
d.purchase_ref_rate = d.discount_rate = d.purchase_rate = d.import_ref_rate = d.import_rate = 0.0
|
||||
|
||||
def get_supplier_quotation_items(self):
|
||||
if self.doc.supplier_quotation:
|
||||
get_obj("DocType Mapper", "Supplier Quotation-Purchase Order").dt_map("Supplier Quotation",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-21 16:16:39",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-04 10:48:54",
|
||||
"modified": "2013-07-04 18:10:21",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -31,7 +31,6 @@
|
||||
"parent": "Purchase Order",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1
|
||||
},
|
||||
@@ -208,7 +207,6 @@
|
||||
"label": "Get Items",
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Button",
|
||||
"options": "get_indent_details",
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
@@ -789,15 +787,37 @@
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "Material User",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Material User",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "Purchase Manager",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Purchase Manager",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
@@ -807,13 +827,24 @@
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Purchase User",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "All",
|
||||
"submit": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"match": "supplier",
|
||||
"permlevel": 0,
|
||||
"role": "Supplier"
|
||||
}
|
||||
]
|
||||
@@ -31,6 +31,12 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext
|
||||
cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order);
|
||||
}
|
||||
},
|
||||
get_items: function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "stock.doctype.material_request.material_request.make_supplier_quotation",
|
||||
source_name: cur_frm.doc.indent_no,
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.model.code import get_obj
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
from controllers.buying_controller import BuyingController
|
||||
class DocType(BuyingController):
|
||||
@@ -49,19 +48,6 @@ class DocType(BuyingController):
|
||||
|
||||
def on_trash(self):
|
||||
pass
|
||||
|
||||
def get_indent_details(self):
|
||||
if self.doc.indent_no:
|
||||
mapper = get_obj("DocType Mapper", "Material Request-Supplier Quotation")
|
||||
mapper.dt_map("Material Request", "Supplier Quotation", self.doc.indent_no,
|
||||
self.doc, self.doclist, """[['Material Request', 'Supplier Quotation'],
|
||||
['Material Request Item', 'Supplier Quotation Item']]""")
|
||||
|
||||
from webnotes.model.bean import getlist
|
||||
for d in getlist(self.doclist, self.fname):
|
||||
if d.item_code and not d.purchase_rate:
|
||||
d.purchase_ref_rate = d.discount_rate = d.purchase_rate = 0.0
|
||||
d.import_ref_rate = d.import_rate = 0.0
|
||||
|
||||
def validate_fiscal_year(self):
|
||||
get_obj(dt = 'Purchase Common').validate_fiscal_year( \
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-21 16:16:45",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-04 10:51:05",
|
||||
"modified": "2013-07-04 18:47:51",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -31,7 +31,6 @@
|
||||
"parent": "Supplier Quotation",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1
|
||||
},
|
||||
@@ -191,8 +190,7 @@
|
||||
"fieldtype": "Button",
|
||||
"hidden": 0,
|
||||
"label": "Get Items",
|
||||
"oldfieldtype": "Button",
|
||||
"options": "get_indent_details"
|
||||
"oldfieldtype": "Button"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -644,6 +642,7 @@
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Manufacturing Manager",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
@@ -653,6 +652,7 @@
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Purchase Manager",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
@@ -662,6 +662,7 @@
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Purchase User",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
@@ -671,6 +672,7 @@
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Material User",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
@@ -680,8 +682,19 @@
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Supplier",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "All",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user