mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
[feature] Ability to set UOM as Integer-only and related validations.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-01-10 16:34:25",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 18:32:13",
|
||||
"modified": "2013-07-25 16:36:35",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -146,11 +146,12 @@
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_uom",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Link",
|
||||
"in_filter": 1,
|
||||
"label": "UOM",
|
||||
"oldfieldname": "stock_uom",
|
||||
"oldfieldtype": "Data",
|
||||
"options": "UOM",
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
|
||||
@@ -99,6 +99,7 @@ class DocType(SellingController):
|
||||
sales_com_obj.get_prevdoc_date(self)
|
||||
self.validate_for_items()
|
||||
self.validate_warehouse()
|
||||
self.validate_uom_is_integer("stock_uom", "qty")
|
||||
|
||||
sales_com_obj.validate_max_discount(self, 'delivery_note_details')
|
||||
sales_com_obj.check_conversion_rate(self)
|
||||
|
||||
@@ -141,7 +141,7 @@ test_records = [
|
||||
"export_rate": 100.0,
|
||||
"amount": 500.0,
|
||||
"warehouse": "_Test Warehouse - _TC",
|
||||
"stock_uom": "No."
|
||||
"stock_uom": "_Test UOM"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-04-22 13:15:44",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 14:54:07",
|
||||
"modified": "2013-07-25 16:37:09",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -111,11 +111,12 @@
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_uom",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 0,
|
||||
"label": "UOM",
|
||||
"oldfieldname": "stock_uom",
|
||||
"oldfieldtype": "Data",
|
||||
"options": "UOM",
|
||||
"print_hide": 0,
|
||||
"print_width": "50px",
|
||||
"read_only": 1,
|
||||
|
||||
@@ -60,6 +60,7 @@ class DocType(BuyingController):
|
||||
super(DocType, self).validate()
|
||||
|
||||
self.validate_schedule_date()
|
||||
self.validate_uom_is_integer("uom", "qty")
|
||||
|
||||
if not self.doc.status:
|
||||
self.doc.status = "Draft"
|
||||
|
||||
@@ -37,6 +37,10 @@ class DocType:
|
||||
self.validate_case_nos()
|
||||
self.validate_qty()
|
||||
|
||||
from utilities.transaction_base import validate_uom_is_integer
|
||||
validate_uom_is_integer(self.doclist, "stock_uom", "qty")
|
||||
validate_uom_is_integer(self.doclist, "weight_uom", "net_weight")
|
||||
|
||||
def validate_delivery_note(self):
|
||||
"""
|
||||
Validates if delivery note has status as draft
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-04-08 13:10:16",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 14:54:11",
|
||||
"modified": "2013-07-25 16:37:30",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -61,9 +61,10 @@
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_uom",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 0,
|
||||
"label": "UOM",
|
||||
"options": "UOM",
|
||||
"print_width": "100px",
|
||||
"read_only": 1,
|
||||
"width": "100px"
|
||||
|
||||
@@ -120,7 +120,10 @@ class DocType(BuyingController):
|
||||
|
||||
self.validate_with_previous_doc()
|
||||
self.validate_accepted_rejected_qty()
|
||||
self.validate_inspection() # Validate Inspection
|
||||
self.validate_inspection()
|
||||
self.validate_uom_is_integer("uom", ["qty", "received_qty"])
|
||||
self.validate_uom_is_integer("stock_uom", "stock_qty")
|
||||
|
||||
get_obj('Stock Ledger').validate_serial_no(self, 'purchase_receipt_details')
|
||||
self.validate_challan_no()
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:10",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 14:54:16",
|
||||
"modified": "2013-07-25 16:30:24",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -267,11 +267,12 @@
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_uom",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 0,
|
||||
"label": "Stock UOM",
|
||||
"oldfieldname": "stock_uom",
|
||||
"oldfieldtype": "Data",
|
||||
"options": "UOM",
|
||||
"print_hide": 1,
|
||||
"print_width": "100px",
|
||||
"read_only": 1,
|
||||
|
||||
@@ -49,6 +49,9 @@ class DocType(StockController):
|
||||
get_obj('Production Order', self.doc.production_order) or None
|
||||
|
||||
self.validate_item()
|
||||
self.validate_uom_is_integer("uom", "qty")
|
||||
self.validate_uom_is_integer("stock_uom", "transfer_qty")
|
||||
|
||||
self.validate_warehouse(pro_obj)
|
||||
self.validate_production_order(pro_obj)
|
||||
self.get_stock_and_rate()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-01-29 19:25:42",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 18:34:09",
|
||||
"modified": "2013-07-25 16:39:10",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -181,10 +181,11 @@
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_uom",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Link",
|
||||
"label": "Stock UOM",
|
||||
"oldfieldname": "stock_uom",
|
||||
"oldfieldtype": "Data",
|
||||
"options": "UOM",
|
||||
"print_width": "150px",
|
||||
"read_only": 1,
|
||||
"width": "150px"
|
||||
|
||||
@@ -17,15 +17,13 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cstr, flt, now
|
||||
from webnotes.utils import cstr, flt, now, cint
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.bean import copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl=[]):
|
||||
@@ -97,7 +95,8 @@ class DocType:
|
||||
def update_stock_uom(self):
|
||||
# validate mandatory
|
||||
self.validate_mandatory()
|
||||
|
||||
self.validate_uom_integer_type()
|
||||
|
||||
# update item master
|
||||
self.update_item_master()
|
||||
|
||||
@@ -108,6 +107,19 @@ class DocType:
|
||||
self.update_bin()
|
||||
|
||||
get_obj("Item", self.doc.item_code).on_update()
|
||||
|
||||
def validate_uom_integer_type(self):
|
||||
current_is_integer = webnotes.conn.get_value("UOM", self.doc.current_stock_uom, "must_be_whole_number")
|
||||
new_is_integer = webnotes.conn.get_value("UOM", self.doc.new_stock_uom, "must_be_whole_number")
|
||||
|
||||
if current_is_integer and not new_is_integer:
|
||||
webnotes.msgprint("New UOM must be of type Whole Number", raise_exception=True)
|
||||
|
||||
if not current_is_integer and new_is_integer:
|
||||
webnotes.msgprint("New UOM must NOT be of type Whole Number", raise_exception=True)
|
||||
|
||||
if current_is_integer and new_is_integer and cint(self.doc.conversion_factor)!=self.doc.conversion_factor:
|
||||
webnotes.msgprint("Conversion Factor cannot be fraction", raise_exception=True)
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_stock_uom(item_code):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-01-10 16:34:30",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:56:45",
|
||||
"modified": "2013-07-25 17:39:14",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -62,6 +62,12 @@
|
||||
"label": "New Stock UOM",
|
||||
"options": "UOM"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "conversion_factor",
|
||||
"fieldtype": "Float",
|
||||
"label": "Conversion Factor"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "update",
|
||||
@@ -69,12 +75,6 @@
|
||||
"label": "Update",
|
||||
"options": "update_stock_uom"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "conversion_factor",
|
||||
"fieldtype": "Float",
|
||||
"label": "Conversion Factor"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Material Master Manager"
|
||||
|
||||
Reference in New Issue
Block a user