[minor] minor fixes along with the codacy

This commit is contained in:
Manas Solanki 2018-05-29 12:56:14 +05:30 committed by Nabin Hait
parent e5e87f7137
commit 2df1b31707
9 changed files with 45 additions and 54 deletions

View File

@ -345,13 +345,13 @@ class StockController(AccountsController):
def update_blanket_order(self, cancel=False):
for item in self.items:
if item.blanket_order:
ordered_qty, doc_name = frappe.db.get_value("Blanket Order Item", {"parent": item.blanket_order}, ["ordered_qty", "name"])
ordered_quantity, doc_name = frappe.db.get_value("Blanket Order Item", {"parent": item.blanket_order}, ["ordered_quantity", "name"])
if not cancel:
ordered_qty = ordered_qty + item.qty
ordered_quantity = ordered_quantity + item.qty
else:
ordered_qty = ordered_qty - item.qty
ordered_qty = flt(ordered_qty, item.precision("qty"))
frappe.db.set_value("Blanket Order Item", doc_name, "ordered_qty", ordered_qty)
ordered_quantity = ordered_quantity - item.qty
ordered_quantity = flt(ordered_quantity, item.precision("qty"))
frappe.db.set_value("Blanket Order Item", doc_name, "ordered_quantity", ordered_quantity)
def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for_items=None,

View File

@ -2,6 +2,11 @@
// For license information, please see license.txt
frappe.ui.form.on('Blanket Order', {
setup: function(frm) {
frm.add_fetch("customer", "customer_name", "customer_name");
frm.add_fetch("supplier", "supplier_name", "supplier_name");
},
refresh: function(frm) {
if (frm.doc.customer && frm.doc.docstatus === 1) {
frm.add_custom_button(__('View Orders'), function() {

View File

@ -175,7 +175,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "order_type",
"fieldname": "blanket_order_type",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
@ -207,7 +207,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.order_type == \"Selling\"",
"depends_on": "eval:doc.blanket_order_type == \"Selling\"",
"fieldname": "customer",
"fieldtype": "Link",
"hidden": 0,
@ -240,7 +240,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.order_type == \"Selling\"",
"depends_on": "eval:doc.blanket_order_type == \"Selling\"",
"fieldname": "customer_name",
"fieldtype": "Data",
"hidden": 0,
@ -273,7 +273,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.order_type == \"Purchasing\"",
"depends_on": "eval:doc.blanket_order_type == \"Purchasing\"",
"fieldname": "supplier",
"fieldtype": "Link",
"hidden": 0,
@ -306,7 +306,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.order_type == \"Purchasing\"",
"depends_on": "eval:doc.blanket_order_type == \"Purchasing\"",
"fieldname": "supplier_name",
"fieldtype": "Data",
"hidden": 0,
@ -437,7 +437,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-28 05:56:05.922333",
"modified": "2018-05-29 02:51:44.752511",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Blanket Order",
@ -467,7 +467,7 @@
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"search_fields": "order_type, to_date",
"search_fields": "blanket_order_type, to_date",
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",

View File

@ -6,6 +6,7 @@ from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
from erpnext.stock.doctype.item.item import get_item_defaults
class BlanketOrder(Document):
@ -14,7 +15,14 @@ class BlanketOrder(Document):
@frappe.whitelist()
def make_sales_order(source_name):
return get_mapped_doc("Blanket Order", source_name, {
def update_item(source, target, source_parent):
item = get_item_defaults(target.item_code, source_parent.company)
if item:
target.item_name = item.get("item_name")
target.description = item.get("description")
target.uom = item.get("stock_uom")
target_doc = get_mapped_doc("Blanket Order", source_name, {
"Blanket Order": {
"doctype": "Sales Order"
},
@ -23,13 +31,23 @@ def make_sales_order(source_name):
"field_map": {
"rate": "blanket_order_rate",
"parent": "blanket_order"
}
},
"postprocess": update_item
}
})
return target_doc
@frappe.whitelist()
def make_purchase_order(source_name):
return get_mapped_doc("Blanket Order", source_name, {
def update_item(source, target, source_parent):
item = get_item_defaults(target.item_code, source_parent.company)
if item:
target.item_name = item.get("item_name")
target.description = item.get("description")
target.uom = item.get("stock_uom")
target.warehouse = item.get("default_warehouse")
target_doc = get_mapped_doc("Blanket Order", source_name, {
"Blanket Order": {
"doctype": "Purchase Order"
},
@ -38,6 +56,8 @@ def make_purchase_order(source_name):
"field_map": {
"rate": "blanket_order_rate",
"parent": "blanket_order"
}
},
"postprocess": update_item
}
})
return target_doc

View File

@ -1,23 +0,0 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Blanket Order", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Blanket Order
() => frappe.tests.make('Blanket Order', [
// values to be set
{key: 'value'}
]),
() => {
assert.equal(cur_frm.doc.key, 'value');
},
() => done()
]);
});

View File

@ -1,10 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import frappe
import unittest
class TestBlanketOrder(unittest.TestCase):
pass

View File

@ -174,7 +174,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "ordered_qty",
"fieldname": "ordered_quantity",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
@ -183,7 +183,7 @@
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Ordered Qty",
"label": "Ordered Quantity",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -271,7 +271,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-05-24 07:59:20.537580",
"modified": "2018-05-29 02:39:25.564967",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Blanket Order Item",

View File

@ -3,7 +3,6 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class BlanketOrderItem(Document):

View File

@ -1343,7 +1343,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
},
callback: function(r) {
if (!r.message) {
frappe.throw(__("Invalid Blanket Order for the selected Customer and Item"))
frappe.throw(__("Invalid Blanket Order for the selected Customer and Item"));
} else {
frappe.run_serially([
() => frappe.model.set_value(cdt, cdn, "blanket_order_rate", r.message.blanket_order_rate),