[mapper] purchase cycle

This commit is contained in:
Nabin Hait 2013-07-05 15:23:47 +05:30
parent 44935e4608
commit eb883ee7a3
21 changed files with 390 additions and 823 deletions

View File

@ -1,147 +0,0 @@
[
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-04-03 12:49:42",
"modified_by": "Administrator",
"modified": "2012-04-03 12:49:43"
},
{
"name": "__common__",
"parent": "Delivery Note-Sales Invoice",
"doctype": "Table Mapper Detail",
"parenttype": "DocType Mapper",
"parentfield": "table_mapper_details"
},
{
"name": "__common__",
"parent": "Delivery Note-Sales Invoice",
"doctype": "Field Mapper Detail",
"parenttype": "DocType Mapper",
"parentfield": "field_mapper_details"
},
{
"name": "__common__",
"to_doctype": "Sales Invoice",
"module": "Accounts",
"doctype": "DocType Mapper",
"ref_doc_submitted": 1,
"from_doctype": "Delivery Note"
},
{
"name": "Delivery Note-Sales Invoice",
"doctype": "DocType Mapper"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "qty",
"doctype": "Field Mapper Detail",
"from_field": "eval: obj.basic_rate and (flt(obj.amount) - flt(obj.billed_amt)) / flt(obj.basic_rate) or obj.qty"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "delivery_note",
"doctype": "Field Mapper Detail",
"from_field": "parent"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "dn_detail",
"doctype": "Field Mapper Detail",
"from_field": "name"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "sales_order",
"doctype": "Field Mapper Detail",
"from_field": "prevdoc_docname"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "so_detail",
"doctype": "Field Mapper Detail",
"from_field": "prevdoc_detail_docname"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "amount",
"doctype": "Field Mapper Detail",
"from_field": "eval: flt(obj.amount) - flt(obj.billed_amt)"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "export_amount",
"doctype": "Field Mapper Detail",
"from_field": "eval: (flt(obj.amount) - flt(obj.billed_amt)) * flt(obj.export_rate)/flt(obj.basic_rate)"
},
{
"map": "No",
"match_id": 0,
"to_field": "naming_series",
"doctype": "Field Mapper Detail",
"from_field": "naming_series"
},
{
"map": "No",
"match_id": 3,
"to_field": "incentives",
"doctype": "Field Mapper Detail",
"from_field": "incentives"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "serial_no",
"doctype": "Field Mapper Detail",
"from_field": "serial_no"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "export_rate",
"doctype": "Field Mapper Detail",
"from_field": "export_rate",
"checking_operator": "="
},
{
"match_id": 0,
"doctype": "Table Mapper Detail",
"from_table": "Delivery Note",
"to_table": "Sales Invoice",
"validation_logic": "docstatus=1"
},
{
"match_id": 1,
"to_field": "entries",
"doctype": "Table Mapper Detail",
"from_field": "delivery_note_details",
"from_table": "Delivery Note Item",
"to_table": "Sales Invoice Item",
"validation_logic": "(ifnull(amount, 0) = 0 or amount > ifnull(billed_amt, 0)) and docstatus = 1"
},
{
"match_id": 2,
"to_field": "other_charges",
"doctype": "Table Mapper Detail",
"from_field": "other_charges",
"from_table": "Sales Taxes and Charges",
"to_table": "Sales Taxes and Charges",
"validation_logic": "name is not null"
},
{
"match_id": 3,
"to_field": "sales_team",
"doctype": "Table Mapper Detail",
"from_field": "sales_team",
"from_table": "Sales Team",
"to_table": "Sales Team",
"validation_logic": "name is not null"
}
]

View File

@ -1,149 +0,0 @@
[
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-04-03 12:49:42",
"modified_by": "Administrator",
"modified": "2012-04-03 12:49:42"
},
{
"name": "__common__",
"parent": "Sales Order-Sales Invoice",
"doctype": "Table Mapper Detail",
"parenttype": "DocType Mapper",
"parentfield": "table_mapper_details"
},
{
"name": "__common__",
"parent": "Sales Order-Sales Invoice",
"doctype": "Field Mapper Detail",
"parenttype": "DocType Mapper",
"parentfield": "field_mapper_details"
},
{
"name": "__common__",
"to_doctype": "Sales Invoice",
"module": "Accounts",
"doctype": "DocType Mapper",
"ref_doc_submitted": 1,
"from_doctype": "Sales Order"
},
{
"name": "Sales Order-Sales Invoice",
"doctype": "DocType Mapper"
},
{
"map": "Yes",
"match_id": 0,
"to_field": "customer",
"doctype": "Field Mapper Detail",
"from_field": "customer",
"checking_operator": "="
},
{
"map": "Yes",
"match_id": 1,
"to_field": "qty",
"doctype": "Field Mapper Detail",
"from_field": "eval: obj.basic_rate and (flt(obj.amount) - flt(obj.billed_amt))/flt(obj.basic_rate) or obj.qty"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "sales_order",
"doctype": "Field Mapper Detail",
"from_field": "parent"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "so_detail",
"doctype": "Field Mapper Detail",
"from_field": "name"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "amount",
"doctype": "Field Mapper Detail",
"from_field": "eval:flt(obj.amount) - flt(obj.billed_amt)"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "export_amount",
"doctype": "Field Mapper Detail",
"from_field": "eval: (flt(obj.amount) - flt(obj.billed_amt))* flt(obj.export_rate)/flt(obj.basic_rate)"
},
{
"map": "Yes",
"match_id": 0,
"to_field": "project_name",
"doctype": "Field Mapper Detail",
"from_field": "project_name",
"checking_operator": "="
},
{
"map": "Yes",
"match_id": 1,
"to_field": "warehouse",
"doctype": "Field Mapper Detail",
"from_field": "reserved_warehouse"
},
{
"map": "No",
"match_id": 0,
"to_field": "naming_series",
"doctype": "Field Mapper Detail",
"from_field": "naming_series"
},
{
"map": "No",
"match_id": 3,
"to_field": "incentives",
"doctype": "Field Mapper Detail",
"from_field": "incentives"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "export_rate",
"doctype": "Field Mapper Detail",
"from_field": "export_rate",
"checking_operator": "="
},
{
"match_id": 0,
"doctype": "Table Mapper Detail",
"from_table": "Sales Order",
"to_table": "Sales Invoice",
"validation_logic": "docstatus=1"
},
{
"match_id": 1,
"to_field": "entries",
"doctype": "Table Mapper Detail",
"from_field": "sales_order_detail",
"from_table": "Sales Order Item",
"to_table": "Sales Invoice Item",
"validation_logic": "(ifnull(amount, 0) = 0 or amount > ifnull(billed_amt, 0)) and docstatus = 1"
},
{
"match_id": 2,
"to_field": "other_charges",
"doctype": "Table Mapper Detail",
"from_field": "other_charges",
"from_table": "Sales Taxes and Charges",
"to_table": "Sales Taxes and Charges",
"validation_logic": "name is not null"
},
{
"match_id": 3,
"to_field": "sales_team",
"doctype": "Table Mapper Detail",
"from_field": "sales_team",
"from_table": "Sales Team",
"to_table": "Sales Team",
"validation_logic": "name is not null"
}
]

View File

@ -67,7 +67,23 @@ erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.ext
allocated_amount: function() {
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,
})
}
}
});
// for backward compatibility: combine new and previous states
@ -101,14 +117,6 @@ cur_frm.cscript.is_opening = function(doc, dt, dn) {
if (doc.is_opening == 'Yes') unhide_field('aging_date');
}
cur_frm.cscript.get_items = function(doc, dt, dn) {
var callback = function(r,rt) {
unhide_field(['supplier_address', 'contact_person']);
cur_frm.refresh_fields();
}
$c_obj(make_doclist(dt,dn),'pull_details','',callback);
}
cur_frm.cscript.make_bank_voucher = function() {
wn.call({
method: "accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account",

View File

@ -126,26 +126,6 @@ class DocType(BuyingController):
ret['due_date'] = add_days(cstr(self.doc.posting_date), acc and cint(acc[1]) or 0)
return ret
def pull_details(self):
if self.doc.purchase_receipt_main:
self.validate_duplicate_docname('purchase_receipt')
self.doclist = get_obj('DocType Mapper', 'Purchase Receipt-Purchase Invoice').dt_map('Purchase Receipt', 'Purchase Invoice', self.doc.purchase_receipt_main, self.doc, self.doclist, "[['Purchase Receipt', 'Purchase Invoice'], ['Purchase Receipt Item', 'Purchase Invoice Item'], ['Purchase Taxes and Charges','Purchase Taxes and Charges']]")
elif self.doc.purchase_order_main:
self.validate_duplicate_docname('purchase_order')
self.doclist = get_obj('DocType Mapper', 'Purchase Order-Purchase Invoice').dt_map('Purchase Order', 'Purchase Invoice', self.doc.purchase_order_main, self.doc, self.doclist, "[['Purchase Order', 'Purchase Invoice'],['Purchase Order Item', 'Purchase Invoice Item'], ['Purchase Taxes and Charges','Purchase Taxes and Charges']]")
self.get_expense_account('entries')
ret = self.get_credit_to()
if ret.has_key('credit_to'):
self.doc.credit_to = ret['credit_to']
def get_expense_account(self, doctype):
for d in getlist(self.doclist, doctype):
if d.item_code:
d.fields.update(self.get_default_values(d.fields))
def get_advances(self):
super(DocType, self).get_advances(self.doc.credit_to,

View File

@ -2,7 +2,7 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
"modified": "2013-06-11 16:16:38",
"modified": "2013-07-05 14:40:59",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -30,7 +30,6 @@
"parent": "Purchase Invoice",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1
},
@ -259,7 +258,6 @@
"fieldtype": "Button",
"label": "Get Items",
"oldfieldtype": "Button",
"options": "pull_details",
"read_only": 0
},
{
@ -827,31 +825,13 @@
"read_only": 0,
"reqd": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"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",
"role": "Supplier",
"permlevel": 1,
"role": "Accounts Manager",
"submit": 0,
"write": 0
},
@ -860,6 +840,7 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"role": "Accounts Manager",
"submit": 1,
"write": 1
@ -869,8 +850,44 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"role": "Auditor",
"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
},
{
"doctype": "DocPerm",
"match": "supplier",
"permlevel": 0,
"role": "Supplier"
}
]

View File

@ -1,125 +0,0 @@
[
{
"creation": "2010-08-08 17:09:34",
"docstatus": 0,
"modified": "2013-02-18 13:41:16",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Table Mapper Detail",
"name": "__common__",
"parent": "Material Request-Purchase Order",
"parentfield": "table_mapper_details",
"parenttype": "DocType Mapper"
},
{
"doctype": "Field Mapper Detail",
"name": "__common__",
"parent": "Material Request-Purchase Order",
"parentfield": "field_mapper_details",
"parenttype": "DocType Mapper"
},
{
"doctype": "DocType Mapper",
"from_doctype": "Material Request",
"module": "Buying",
"name": "__common__",
"ref_doc_submitted": 1,
"to_doctype": "Purchase Order"
},
{
"doctype": "DocType Mapper",
"name": "Material Request-Purchase Order"
},
{
"checking_operator": "=",
"doctype": "Field Mapper Detail",
"from_field": "company",
"map": "Yes",
"match_id": 0,
"to_field": "company"
},
{
"doctype": "Field Mapper Detail",
"from_field": "parenttype",
"map": "Yes",
"match_id": 1,
"to_field": "prevdoc_doctype"
},
{
"doctype": "Field Mapper Detail",
"from_field": "parent",
"map": "Yes",
"match_id": 1,
"to_field": "prevdoc_docname"
},
{
"doctype": "Field Mapper Detail",
"from_field": "name",
"map": "Yes",
"match_id": 1,
"to_field": "prevdoc_detail_docname"
},
{
"doctype": "Field Mapper Detail",
"from_field": "uom",
"map": "Yes",
"match_id": 1,
"to_field": "stock_uom"
},
{
"doctype": "Field Mapper Detail",
"from_field": "eval:flt(1)",
"map": "Yes",
"match_id": 1,
"to_field": "conversion_factor"
},
{
"doctype": "Field Mapper Detail",
"from_field": "eval:flt(obj.qty) - flt(obj.ordered_qty)",
"map": "Yes",
"match_id": 1,
"to_field": "stock_qty"
},
{
"doctype": "Field Mapper Detail",
"from_field": "eval:flt(obj.qty) - flt(obj.ordered_qty)",
"map": "Yes",
"match_id": 1,
"to_field": "qty"
},
{
"doctype": "Field Mapper Detail",
"from_field": "schedule_date",
"map": "Yes",
"match_id": 1,
"to_field": "schedule_date"
},
{
"checking_operator": ">=",
"doctype": "Field Mapper Detail",
"from_field": "transaction_date",
"map": "No",
"match_id": 0,
"to_field": "transaction_date"
},
{
"doctype": "Table Mapper Detail",
"from_table": "Material Request",
"match_id": 0,
"reference_key": "prevdoc_docname",
"to_table": "Purchase Order",
"validation_logic": "docstatus = 1"
},
{
"doctype": "Table Mapper Detail",
"from_field": "indent_details",
"from_table": "Material Request Item",
"match_id": 1,
"reference_doctype_key": "prevdoc_doctype",
"to_field": "po_details",
"to_table": "Purchase Order Item",
"validation_logic": "qty > ifnull(ordered_qty,0) and docstatus =1"
}
]

View File

@ -1,90 +0,0 @@
[
{
"creation": "2012-08-06 20:02:53",
"docstatus": 0,
"modified": "2013-02-18 13:41:13",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Table Mapper Detail",
"name": "__common__",
"parent": "Material Request-Supplier Quotation",
"parentfield": "table_mapper_details",
"parenttype": "DocType Mapper"
},
{
"doctype": "Field Mapper Detail",
"name": "__common__",
"parent": "Material Request-Supplier Quotation",
"parentfield": "field_mapper_details",
"parenttype": "DocType Mapper"
},
{
"doctype": "DocType Mapper",
"from_doctype": "Material Request",
"module": "Buying",
"name": "__common__",
"ref_doc_submitted": 1,
"to_doctype": "Supplier Quotation"
},
{
"doctype": "DocType Mapper",
"name": "Material Request-Supplier Quotation"
},
{
"checking_operator": "=",
"doctype": "Field Mapper Detail",
"from_field": "company",
"map": "Yes",
"match_id": 0,
"to_field": "company"
},
{
"doctype": "Field Mapper Detail",
"from_field": "parenttype",
"map": "Yes",
"match_id": 1,
"to_field": "prevdoc_doctype"
},
{
"doctype": "Field Mapper Detail",
"from_field": "parent",
"map": "Yes",
"match_id": 1,
"to_field": "prevdoc_docname"
},
{
"doctype": "Field Mapper Detail",
"from_field": "name",
"map": "Yes",
"match_id": 1,
"to_field": "prevdoc_detail_docname"
},
{
"checking_operator": ">=",
"doctype": "Field Mapper Detail",
"from_field": "transaction_date",
"map": "No",
"match_id": 0,
"to_field": "transaction_date"
},
{
"doctype": "Table Mapper Detail",
"from_table": "Material Request",
"match_id": 0,
"reference_key": "prevdoc_docname",
"to_table": "Supplier Quotation",
"validation_logic": "docstatus = 1"
},
{
"doctype": "Table Mapper Detail",
"from_field": "indent_details",
"from_table": "Material Request Item",
"match_id": 1,
"reference_doctype_key": "prevdoc_doctype",
"to_field": "quotation_items",
"to_table": "Supplier Quotation Item",
"validation_logic": "docstatus =1"
}
]

View File

@ -1,98 +0,0 @@
[
{
"creation": "2011-05-20 10:07:55",
"docstatus": 0,
"modified": "2013-02-20 18:20:27",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Table Mapper Detail",
"name": "__common__",
"parent": "Sales Order-Material Request",
"parentfield": "table_mapper_details",
"parenttype": "DocType Mapper"
},
{
"doctype": "Field Mapper Detail",
"name": "__common__",
"parent": "Sales Order-Material Request",
"parentfield": "field_mapper_details",
"parenttype": "DocType Mapper"
},
{
"doctype": "DocType Mapper",
"from_doctype": "Sales Order",
"module": "Buying",
"name": "__common__",
"ref_doc_submitted": 1,
"to_doctype": "Material Request"
},
{
"doctype": "DocType Mapper",
"name": "Sales Order-Material Request"
},
{
"checking_operator": ">=",
"doctype": "Field Mapper Detail",
"from_field": "transaction_date",
"map": "No",
"match_id": 0,
"to_field": "transaction_date"
},
{
"doctype": "Field Mapper Detail",
"from_field": "eval:\"Purchase\"",
"map": "Yes",
"match_id": 0,
"to_field": "material_request_type"
},
{
"checking_operator": "=",
"doctype": "Field Mapper Detail",
"from_field": "company",
"map": "Yes",
"match_id": 0,
"to_field": "company"
},
{
"doctype": "Field Mapper Detail",
"from_field": "parent",
"map": "Yes",
"match_id": 1,
"to_field": "sales_order_no"
},
{
"doctype": "Field Mapper Detail",
"from_field": "stock_uom",
"map": "Yes",
"match_id": 1,
"to_field": "uom"
},
{
"doctype": "Field Mapper Detail",
"from_field": "reserved_warehouse",
"map": "Yes",
"match_id": 1,
"to_field": "warehouse"
},
{
"doctype": "Table Mapper Detail",
"from_field": "sales_order_details",
"from_table": "Sales Order Item",
"match_id": 1,
"reference_doctype_key": "prevdoc_doctype",
"reference_key": "prevdoc_detail_docname",
"to_field": "indent_details",
"to_table": "Material Request Item",
"validation_logic": "docstatus=1"
},
{
"doctype": "Table Mapper Detail",
"from_table": "Sales Order",
"match_id": 0,
"reference_key": "prevdoc_docname",
"to_table": "Material Request",
"validation_logic": "docstatus = 1"
}
]

View File

@ -30,15 +30,46 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
if(doc.docstatus == 1 && doc.status != 'Stopped'){
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
if(flt(doc.per_received, 2) < 100) cur_frm.add_custom_button('Make Purchase Receipt', cur_frm.cscript['Make Purchase Receipt']);
if(flt(doc.per_billed, 2) < 100) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Purchase Invoice']);
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
if(flt(doc.per_received, 2) < 100)
cur_frm.add_custom_button('Make Purchase Receipt', this.make_purchase_receipt);
if(flt(doc.per_billed, 2) < 100)
cur_frm.add_custom_button('Make Invoice', this.make_purchase_invoice);
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100)
cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
}
if(doc.docstatus == 1 && doc.status == 'Stopped')
cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']);
cur_frm.add_custom_button('Unstop Purchase Order',
cur_frm.cscript['Unstop Purchase Order']);
},
get_items: function() {
wn.model.map_current_doc({
method: "stock.doctype.material_request.material_request.make_purchase_order",
source_name: cur_frm.doc.indent_no,
})
},
make_purchase_receipt: function() {
wn.model.open_mapped_doc({
method: "buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
source_name: cur_frm.doc.name
})
},
make_purchase_invoice: function() {
wn.model.open_mapped_doc({
method: "buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
source_name: cur_frm.doc.name
})
},
get_supplier_quotation_items: function() {
wn.model.map_current_doc({
method: "buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
source_name: cur_frm.doc.supplier_quotation,
})
}
});
// for backward compatibility: combine new and previous states
@ -70,58 +101,14 @@ cur_frm.fields_dict['indent_no'].get_query = function(doc) {
ORDER BY `name` DESC LIMIT 50';
}
//========================= Get Last Purhase Rate =====================================
cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){
$c_obj(make_doclist(doc.doctype, doc.name), 'get_last_purchase_rate', '',
function(r, rt) {
refresh_field(cur_frm.cscript.fname);
var doc = locals[cdt][cdn];
cur_frm.cscript.calc_amount( doc, 2);
}
);
$c_obj(make_doclist(doc.doctype, doc.name), 'get_last_purchase_rate', '', function(r, rt) {
refresh_field(cur_frm.cscript.fname);
var doc = locals[cdt][cdn];
cur_frm.cscript.calc_amount( doc, 2);
});
}
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={
'docs':wn.model.compress([locals['Purchase Receipt'][n]]),
'from_doctype': cur_frm.doc.doctype,
'to_doctype':'Purchase Receipt',
'from_docname':cur_frm.doc.name,
'from_to_list':"[['Purchase Order','Purchase Receipt'],['Purchase Order Item','Purchase Receipt Item'],['Purchase Taxes and Charges','Purchase Taxes and Charges']]"
}, function(r,rt) {
loaddoc('Purchase Receipt', n);
}
);
}
//========================== Make Purchase Invoice =====================================================
cur_frm.cscript['Make Purchase Invoice'] = function() {
n = wn.model.make_new_doc_and_get_name('Purchase Invoice');
$c('dt_map', {
'docs':wn.model.compress([locals['Purchase Invoice'][n]]),
'from_doctype':cur_frm.doc.doctype,
'to_doctype':'Purchase Invoice',
'from_docname': cur_frm.doc.name,
'from_to_list':"[['Purchase Order','Purchase Invoice'],['Purchase Order Item','Purchase Invoice Item'],['Purchase Taxes and Charges','Purchase Taxes and Charges']]"
}, function(r,rt) {
loaddoc('Purchase Invoice', n);
}
);
}
// Stop PURCHASE ORDER
// ==================================================================================================
cur_frm.cscript['Stop Purchase Order'] = function() {
var doc = cur_frm.doc;
var check = confirm("Do you really want to STOP " + doc.name);
@ -133,8 +120,6 @@ cur_frm.cscript['Stop Purchase Order'] = function() {
}
}
// Unstop PURCHASE ORDER
// ==================================================================================================
cur_frm.cscript['Unstop Purchase Order'] = function() {
var doc = cur_frm.doc;
var check = confirm("Do you really want to UNSTOP " + doc.name);
@ -146,7 +131,6 @@ cur_frm.cscript['Unstop Purchase Order'] = function() {
}
}
//****************** For print sales order no and date*************************
cur_frm.pformat.indent_no = function(doc, cdt, cdn){
//function to make row of table

View File

@ -71,17 +71,11 @@ class DocType(BuyingController):
def get_bin_details(self, arg = ''):
return get_obj(dt='Purchase Common').get_bin_details(arg)
def get_supplier_quotation_items(self):
if self.doc.supplier_quotation:
get_obj("DocType Mapper", "Supplier Quotation-Purchase Order").dt_map("Supplier Quotation",
"Purchase Order", self.doc.supplier_quotation, self.doc, self.doclist,
"""[['Supplier Quotation', 'Purchase Order'],
['Supplier Quotation Item', 'Purchase Order Item'],
['Purchase Taxes and Charges', 'Purchase Taxes and Charges']]""")
for d in getlist(self.doclist, 'po_details'):
if d.prevdoc_detail_docname and not d.schedule_date:
d.schedule_date = webnotes.conn.get_value("Material Request Item",
d.prevdoc_detail_docname, "schedule_date")
def get_schedule_dates(self):
for d in getlist(self.doclist, 'po_details'):
if d.prevdoc_detail_docname and not d.schedule_date:
d.schedule_date = webnotes.conn.get_value("Material Request Item",
d.prevdoc_detail_docname, "schedule_date")
def get_last_purchase_rate(self):
get_obj('Purchase Common').get_last_purchase_rate(self)
@ -205,4 +199,84 @@ class DocType(BuyingController):
pass
def get_rate(self,arg):
return get_obj('Purchase Common').get_rate(arg,self)
return get_obj('Purchase Common').get_rate(arg,self)
@webnotes.whitelist()
def make_purchase_receipt(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
def set_missing_values(source, target):
bean = webnotes.bean(target)
bean.run_method("set_missing_values")
def update_item(obj, target, source_parent):
target.conversion_factor = 1
target.qty = flt(obj.qty) - flt(obj.received_qty)
target.stock_qty = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.conversion_factor)
target.import_amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.import_rate)
target.amount = (flt(obj.qty) - flt(obj.received_qty)) * flt(obj.purchase_rate)
doclist = get_mapped_doclist("Purchase Order", source_name, {
"Purchase Order": {
"doctype": "Purchase Receipt",
"validation": {
"docstatus": ["=", 1],
}
},
"Purchase Order Item": {
"doctype": "Purchase Receipt Item",
"field_map": {
"name": "prevdoc_detail_docname",
"parent": "prevdoc_docname",
"parenttype": "prevdoc_doctype",
},
"postprocess": update_item,
"condition": lambda doc: doc.received_qty < doc.qty
},
"Purchase Taxes and Charges": {
"doctype": "Purchase Taxes and Charges",
}
}, target_doclist, set_missing_values)
return [d.fields for d in doclist]
@webnotes.whitelist()
def make_purchase_invoice(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
def set_missing_values(source, target):
bean = webnotes.bean(target)
bean.run_method("set_missing_values")
bean.run_method("set_supplier_defaults")
def update_item(obj, target, source_parent):
target.conversion_factor = 1
target.qty = (flt(obj.amount) - flt(obj.billed_amt)) / flt(obj.purchase_rate)
target.import_amount = (flt(obj.amount) - flt(obj.billed_amt)) / \
flt(source_parent.conversion_rate)
target.amount = flt(obj.amount) - flt(obj.billed_amt)
doclist = get_mapped_doclist("Purchase Order", source_name, {
"Purchase Order": {
"doctype": "Purchase Invoice",
"validation": {
"docstatus": ["=", 1],
}
},
"Purchase Order Item": {
"doctype": "Purchase Invoice Item",
"field_map": {
"name": "po_detail",
"parent": "purchase_order",
"purchase_rate": "rate"
},
"postprocess": update_item,
"condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.amount
},
"Purchase Taxes and Charges": {
"doctype": "Purchase Taxes and Charges",
}
}, target_doclist, set_missing_values)
return [d.fields for d in doclist]

View File

@ -2,7 +2,7 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
"modified": "2013-07-04 18:10:21",
"modified": "2013-07-05 13:02:52",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -267,7 +267,7 @@
"fieldtype": "Float",
"hidden": 0,
"label": "Exchange Rate",
"no_copy": 1,
"no_copy": 0,
"oldfieldname": "conversion_rate",
"oldfieldtype": "Currency",
"print_hide": 1,

View File

@ -19,9 +19,38 @@ from __future__ import unicode_literals
import unittest
import webnotes
import webnotes.defaults
from webnotes.utils import cint
class TestPurchaseOrder(unittest.TestCase):
def test_make_purchase_receipt(self):
from buying.doctype.purchase_order.purchase_order import make_purchase_receipt
po = webnotes.bean(copy=test_records[0]).insert()
self.assertRaises(webnotes.ValidationError, make_purchase_receipt,
po.doc.name)
po = webnotes.bean("Purchase Order", po.doc.name)
po.submit()
pr = make_purchase_receipt(po.doc.name)
self.assertEquals(pr[0]["doctype"], "Purchase Receipt")
self.assertEquals(len(pr), len(test_records[0]))
def test_make_purchase_invocie(self):
from buying.doctype.purchase_order.purchase_order import make_purchase_invoice
po = webnotes.bean(copy=test_records[0]).insert()
self.assertRaises(webnotes.ValidationError, make_purchase_invoice,
po.doc.name)
po = webnotes.bean("Purchase Order", po.doc.name)
po.submit()
pi = make_purchase_invoice(po.doc.name)
self.assertEquals(pi[0]["doctype"], "Purchase Invoice")
self.assertEquals(len(pi), len(test_records[0]))
def test_subcontracting(self):
po = webnotes.bean(copy=test_records[0])
po.insert()

View File

@ -28,33 +28,28 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext
this._super();
if (this.frm.doc.docstatus === 1) {
cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order);
cur_frm.add_custom_button("Make Purchase Order", this.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,
})
},
make_purchase_order: function() {
wn.model.open_mapped_doc({
method: "buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
source_name: cur_frm.doc.name
})
}
});
// for backward compatibility: combine new and previous states
$.extend(cur_frm.cscript, new erpnext.buying.SupplierQuotationController({frm: cur_frm}));
cur_frm.cscript.make_purchase_order = function() {
var new_po_name = wn.model.make_new_doc_and_get_name("Purchase Order");
$c("dt_map", {
"docs": wn.model.compress([locals['Purchase Order'][new_po_name]]),
"from_doctype": cur_frm.doc.doctype,
"to_doctype": "Purchase Order",
"from_docname": cur_frm.doc.name,
"from_to_list": JSON.stringify([['Supplier Quotation', 'Purchase Order'],
['Supplier Quotation Item', 'Purchase Order Item'],
['Purchase Taxes and Charges', 'Purchase Taxes and Charges']]),
}, function(r, rt) { loaddoc("Purchase Order", new_po_name) });
}
cur_frm.cscript.uom = function(doc, cdt, cdn) {
// no need to trigger updation of stock uom, as this field doesn't exist in supplier quotation
}

View File

@ -58,3 +58,41 @@ class DocType(BuyingController):
pc.validate_for_items(self)
pc.get_prevdoc_date(self)
pc.validate_reference_value(self)
@webnotes.whitelist()
def make_purchase_order(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
def set_missing_values(source, target):
bean = webnotes.bean(target)
bean.run_method("set_missing_values")
bean.run_method("get_schedule_dates")
def update_item(obj, target, source_parent):
target.conversion_factor = 1
doclist = get_mapped_doclist("Supplier Quotation", source_name, {
"Supplier Quotation": {
"doctype": "Purchase Order",
"validation": {
"docstatus": ["=", 1],
}
},
"Supplier Quotation Item": {
"doctype": "Purchase Order Item",
"field_map": {
"name": "supplier_quotation_item",
"parent": "supplier_quotation",
"uom": "stock_uom",
"prevdoc_detail_docname": "prevdoc_detail_docname",
"prevdoc_doctype": "prevdoc_doctype",
"prevdoc_docname": "prevdoc_docname",
},
"postprocess": update_item
},
"Purchase Taxes and Charges": {
"doctype": "Purchase Taxes and Charges",
},
}, target_doclist, set_missing_values)
return [d.fields for d in doclist]

View File

@ -450,7 +450,8 @@ def make_sales_invoice(source_name, target_doclist=None):
def update_item(obj, target):
target.export_amount = (flt(obj.amount) - flt(obj.billed_amt))* flt(obj.export_rate)/flt(obj.basic_rate)
target.qty = obj.basic_rate and (flt(obj.amount) - flt(obj.billed_amt))/flt(obj.basic_rate) or obj.qty
target.qty = obj.basic_rate and \
(flt(obj.amount) - flt(obj.billed_amt))/flt(obj.basic_rate) or obj.qty
target.amount = flt(obj.amount) - flt(obj.billed_amt)
def update_accounts(source, target):

View File

@ -37,15 +37,15 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
if(doc.docstatus == 1 && doc.status != 'Stopped'){
if(doc.material_request_type === "Purchase")
cur_frm.add_custom_button("Make Supplier Quotation",
cur_frm.cscript.make_supplier_quotation);
this.make_supplier_quotation);
if(doc.material_request_type === "Transfer" && doc.status === "Submitted")
cur_frm.add_custom_button("Transfer Material", cur_frm.cscript.make_stock_entry);
cur_frm.add_custom_button("Transfer Material", this.make_stock_entry);
if(flt(doc.per_ordered, 2) < 100) {
if(doc.material_request_type === "Purchase")
cur_frm.add_custom_button('Make Purchase Order',
cur_frm.cscript.make_purchase_order);
this.make_purchase_order);
cur_frm.add_custom_button('Stop Material Request',
cur_frm.cscript['Stop Material Request']);

View File

@ -241,19 +241,17 @@ def _update_requested_qty(controller, mr_obj, mr_items):
"posting_date": controller.doc.posting_date,
})
def set_missing_values(source, target):
po = webnotes.bean(target)
po.run_method("set_missing_values")
@webnotes.whitelist()
def make_purchase_order(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
def update_item(obj, target):
def update_item(obj, target, source_parent):
target.conversion_factor = 1
target.qty = flt(obj.qty) - flt(obj.ordered_qty)
def set_missing_values(source, target):
po = webnotes.bean(target)
po.run_method("set_missing_values")
doclist = get_mapped_doclist("Material Request", source_name, {
"Material Request": {
@ -281,10 +279,6 @@ def make_purchase_order(source_name, target_doclist=None):
def make_supplier_quotation(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
def set_missing_values(source, target):
sq = webnotes.bean(target)
sq.run_method("set_missing_values")
doclist = get_mapped_doclist("Material Request", source_name, {
"Material Request": {
"doctype": "Supplier Quotation",
@ -309,7 +303,7 @@ def make_supplier_quotation(source_name, target_doclist=None):
def make_stock_entry(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
def set_purpose(source, target):
def set_purpose(source, target, source_parent):
target[0].purpose = "Material Transfer"
def update_item(source, target):

View File

@ -30,7 +30,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
if(this.frm.doc.docstatus == 1) {
if(flt(this.frm.doc.per_billed, 2) < 100) {
cur_frm.add_custom_button('Make Purchase Invoice',
cur_frm.cscript['Make Purchase Invoice']);
this.make_purchase_invoice);
}
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
}
@ -68,7 +68,8 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
wn.model.round_floats_in(item, ["received_qty", "rejected_qty"]);
if(item.rejected_qty > item.received_qty) {
msgprint(wn._("Error") + ": " + wn._(wn.meta.get_label(item.doctype, "rejected_qty", item.name))
msgprint(wn._("Error") + ": " +
wn._(wn.meta.get_label(item.doctype, "rejected_qty", item.name))
+ " > " + wn._(wn.meta.get_label(item.doctype, "received_qty", item.name)));
item.qty = item.rejected_qty = 0.0;
} else {
@ -77,6 +78,21 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
this.qty(doc, cdt, cdn);
},
make_purchase_invoice: function() {
wn.model.open_mapped_doc({
method: "stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
source_name: cur_frm.doc.name
})
},
pull_purchase_order_details: function() {
wn.model.map_current_doc({
method: "buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
source_name: cur_frm.doc.purchase_order_no,
})
}
});
// for backward compatibility: combine new and previous states
@ -94,17 +110,6 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE supplier = "'+ doc.supplier +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
// Get Purchase Order Button
// -----------------
cur_frm.cscript.pull_purchase_order_details = function(doc, dt, dn) {
$c_obj(make_doclist(dt,dn),'get_po_details','',function(r,rt) {
cur_frm.refresh_fields();
});
}
//================ create new contact ============================================================================
cur_frm.cscript.new_contact = function(){
tn = wn.model.make_new_doc_and_get_name('Contact');
locals['Contact'][tn].is_supplier = 1;
@ -112,15 +117,12 @@ cur_frm.cscript.new_contact = function(){
loaddoc('Contact', tn);
}
// ***************** Get project name *****************
cur_frm.fields_dict['purchase_receipt_details'].grid.get_field('project_name').get_query = function(doc, cdt, cdn) {
return 'SELECT `tabProject`.name FROM `tabProject` \
WHERE `tabProject`.status not in ("Completed", "Cancelled") \
AND `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50';
}
//========================= Overloaded query for link batch_no =============================================================
cur_frm.fields_dict['purchase_receipt_details'].grid.get_field('batch_no').get_query= function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(d.item_code){
@ -139,12 +141,11 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
else
cur_frm.pformat.print_heading = "Purchase Receipt";
}
// ***************** Get Print Heading *****************
cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) {
return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
}
//================================= Purchase Order No Get Query ====================================
cur_frm.fields_dict['purchase_order_no'].get_query = function(doc) {
if (doc.supplier)
return 'SELECT DISTINCT `tabPurchase Order`.`name` FROM `tabPurchase Order` WHERE `tabPurchase Order`.`supplier` = "' +doc.supplier + '" and`tabPurchase Order`.`docstatus` = 1 and `tabPurchase Order`.`status` != "Stopped" and ifnull(`tabPurchase Order`.`per_received`, 0) < 99.99 and `tabPurchase Order`.`currency` = ifnull("' +doc.currency+ '","") and `tabPurchase Order`.company = "'+ doc.company +'" and `tabPurchase Order`.%(key)s LIKE "%s" ORDER BY `tabPurchase Order`.`name` DESC LIMIT 50';
@ -152,36 +153,10 @@ cur_frm.fields_dict['purchase_order_no'].get_query = function(doc) {
return 'SELECT DISTINCT `tabPurchase Order`.`name` FROM `tabPurchase Order` WHERE `tabPurchase Order`.`docstatus` = 1 and `tabPurchase Order`.`company` = "'+ doc.company +'" and `tabPurchase Order`.`status` != "Stopped" and ifnull(`tabPurchase Order`.`per_received`, 0) < 99.99 and `tabPurchase Order`.%(key)s LIKE "%s" ORDER BY `tabPurchase Order`.`name` DESC LIMIT 50';
}
// QA INspection report get_query
//---------------------------------
cur_frm.fields_dict.purchase_receipt_details.grid.get_field("qa_no").get_query = function(doc) {
return 'SELECT `tabQuality Inspection`.name FROM `tabQuality Inspection` WHERE `tabQuality Inspection`.docstatus = 1 AND `tabQuality Inspection`.%(key)s LIKE "%s"';
}
// On Button Click Functions
// ------------------------------------------------------------------------------
// ================================ Make Purchase Invoice ==========================================
cur_frm.cscript['Make Purchase Invoice'] = function() {
n = wn.model.make_new_doc_and_get_name('Purchase Invoice');
$c('dt_map', args={
'docs':wn.model.compress([locals['Purchase Invoice'][n]]),
'from_doctype': cur_frm.doc.doctype,
'to_doctype':'Purchase Invoice',
'from_docname': cur_frm.doc.name,
'from_to_list':"[['Purchase Receipt','Purchase Invoice'],['Purchase Receipt Item','Purchase Invoice Item'],['Purchase Taxes and Charges','Purchase Taxes and Charges']]"
}, function(r,rt) {
loaddoc('Purchase Invoice', n);
}
);
}
//****************** For print sales order no and date*************************
cur_frm.pformat.purchase_order_no = function(doc, cdt, cdn){
//function to make row of table

View File

@ -52,11 +52,6 @@ class DocType(BuyingController):
def get_bin_details(self, arg = ''):
return get_obj(dt='Purchase Common').get_bin_details(arg)
# Pull Purchase Order
def get_po_details(self):
self.validate_prev_docname()
get_obj('DocType Mapper', 'Purchase Order-Purchase Receipt').dt_map('Purchase Order', 'Purchase Receipt', self.doc.purchase_order_no, self.doc, self.doclist, "[['Purchase Order','Purchase Receipt'],['Purchase Order Item', 'Purchase Receipt Item'],['Purchase Taxes and Charges','Purchase Taxes and Charges']]")
# validate if PO has been pulled twice
def validate_prev_docname(self):
for d in getlist(self.doclist, 'purchase_receipt_details'):
@ -64,9 +59,6 @@ class DocType(BuyingController):
msgprint(cstr(self.doc.purchase_order_no) + " Purchase Order details have already been pulled. ")
raise Exception
# validation
#-------------------------------------------------------------------------------------------------------------
# validate accepted and rejected qty
def validate_accepted_rejected_qty(self):
for d in getlist(self.doclist, "purchase_receipt_details"):
@ -333,4 +325,47 @@ class DocType(BuyingController):
total_valuation_amount += flt(item.valuation_rate) * \
flt(item.qty) * flt(item.conversion_factor)
return total_valuation_amount
return total_valuation_amount
@webnotes.whitelist()
def make_purchase_invoice(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
def set_missing_values(source, target):
bean = webnotes.bean(target)
bean.run_method("set_missing_values")
bean.run_method("set_supplier_defaults")
def update_item(obj, target, source_parent):
target.conversion_factor = 1
target.qty = (flt(obj.amount) - flt(obj.billed_amt)) / flt(obj.purchase_rate)
target.import_amount = (flt(obj.amount) - flt(obj.billed_amt)) / \
flt(source_parent.conversion_rate)
target.amount = flt(obj.amount) - flt(obj.billed_amt)
doclist = get_mapped_doclist("Purchase Receipt", source_name, {
"Purchase Receipt": {
"doctype": "Purchase Invoice",
"validation": {
"docstatus": ["=", 1],
}
},
"Purchase Receipt Item": {
"doctype": "Purchase Invoice Item",
"field_map": {
"name": "pr_detail",
"parent": "purchase_receipt",
"prevdoc_detail_docname": "po_detail",
"prevdoc_docname": "purchase_order",
"purchase_rate": "rate"
},
"postprocess": update_item,
"condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.amount
},
"Purchase Taxes and Charges": {
"doctype": "Purchase Taxes and Charges",
}
}, target_doclist, set_missing_values)
return [d.fields for d in doclist]

View File

@ -2,7 +2,7 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
"modified": "2013-06-11 16:16:40",
"modified": "2013-07-05 14:38:03",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -31,7 +31,6 @@
"parent": "Purchase Receipt",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1
},
@ -262,7 +261,6 @@
"fieldtype": "Button",
"label": "Pull Purchase Order Details",
"oldfieldtype": "Button",
"options": "get_po_details",
"print_hide": 1
},
{
@ -869,19 +867,41 @@
"read_only": 1
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"role": "Material Manager",
"submit": 1,
"write": 1
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"role": "Material Manager",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"role": "Material User",
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"role": "Material User",
"submit": 1,
"write": 1
@ -891,13 +911,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": "Purchase User",
"submit": 0
},
{
"doctype": "DocPerm",
"match": "supplier",
"permlevel": 0,
"role": "Supplier"
}
]

View File

@ -22,6 +22,21 @@ import webnotes.defaults
from webnotes.utils import cint
class TestPurchaseReceipt(unittest.TestCase):
def test_make_purchase_invocie(self):
from stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
pr = webnotes.bean(copy=test_records[0]).insert()
self.assertRaises(webnotes.ValidationError, make_purchase_invoice,
pr.doc.name)
pr = webnotes.bean("Purchase Receipt", pr.doc.name)
pr.submit()
pi = make_purchase_invoice(pr.doc.name)
self.assertEquals(pi[0]["doctype"], "Purchase Invoice")
self.assertEquals(len(pi), len(pr.doclist))
def test_purchase_receipt_no_gl_entry(self):
pr = webnotes.bean(copy=test_records[0])
pr.run_method("calculate_taxes_and_totals")