Merge branch 'master' into develop
This commit is contained in:
commit
3b3ab4d574
@ -4,7 +4,7 @@ import inspect
|
|||||||
import frappe
|
import frappe
|
||||||
from erpnext.hooks import regional_overrides
|
from erpnext.hooks import regional_overrides
|
||||||
|
|
||||||
__version__ = '8.8.5'
|
__version__ = '8.8.6'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
|||||||
@ -18,7 +18,7 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
|
|||||||
aii_account_map = get_aii_accounts()
|
aii_account_map = get_aii_accounts()
|
||||||
if item_list:
|
if item_list:
|
||||||
itemised_tax, tax_columns = get_tax_accounts(item_list, columns,
|
itemised_tax, tax_columns = get_tax_accounts(item_list, columns,
|
||||||
tax_doctype="Purchase Taxes and Charges")
|
doctype="Purchase Invoice", tax_doctype="Purchase Taxes and Charges")
|
||||||
|
|
||||||
columns.append({
|
columns.append({
|
||||||
"fieldname": "currency",
|
"fieldname": "currency",
|
||||||
|
|||||||
@ -139,7 +139,7 @@ def get_delivery_notes_against_sales_order(item_list):
|
|||||||
|
|
||||||
return so_dn_map
|
return so_dn_map
|
||||||
|
|
||||||
def get_tax_accounts(item_list, columns, tax_doctype="Sales Taxes and Charges"):
|
def get_tax_accounts(item_list, columns, doctype="Sales Invoice", tax_doctype="Sales Taxes and Charges"):
|
||||||
import json
|
import json
|
||||||
item_row_map = {}
|
item_row_map = {}
|
||||||
tax_columns = []
|
tax_columns = []
|
||||||
@ -155,11 +155,12 @@ def get_tax_accounts(item_list, columns, tax_doctype="Sales Taxes and Charges"):
|
|||||||
charge_type, base_tax_amount_after_discount_amount
|
charge_type, base_tax_amount_after_discount_amount
|
||||||
from `tab%s`
|
from `tab%s`
|
||||||
where
|
where
|
||||||
parenttype = 'Sales Invoice' and docstatus = 1
|
parenttype = %s and docstatus = 1
|
||||||
and (description is not null and description != '')
|
and (description is not null and description != '')
|
||||||
and parent in (%s)
|
and parent in (%s)
|
||||||
order by description
|
order by description
|
||||||
""" % (tax_doctype, ', '.join(['%s']*len(invoice_item_row))), tuple(invoice_item_row.keys()))
|
""" % (tax_doctype, '%s', ', '.join(['%s']*len(invoice_item_row))),
|
||||||
|
tuple([doctype] + invoice_item_row.keys()))
|
||||||
|
|
||||||
for parent, description, item_wise_tax_detail, charge_type, tax_amount in tax_details:
|
for parent, description, item_wise_tax_detail, charge_type, tax_amount in tax_details:
|
||||||
if description not in tax_columns and tax_amount:
|
if description not in tax_columns and tax_amount:
|
||||||
|
|||||||
@ -6,9 +6,10 @@ from __future__ import unicode_literals
|
|||||||
import unittest
|
import unittest
|
||||||
import frappe, erpnext
|
import frappe, erpnext
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
from frappe.utils import cint, flt, cstr, today
|
from frappe.utils import cint, flt, cstr, today, random_string
|
||||||
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
||||||
from erpnext import set_perpetual_inventory
|
from erpnext import set_perpetual_inventory
|
||||||
|
from erpnext.stock.doctype.serial_no.serial_no import SerialNoDuplicateError
|
||||||
from erpnext.accounts.doctype.account.test_account import get_inventory_account
|
from erpnext.accounts.doctype.account.test_account import get_inventory_account
|
||||||
|
|
||||||
class TestPurchaseReceipt(unittest.TestCase):
|
class TestPurchaseReceipt(unittest.TestCase):
|
||||||
@ -251,6 +252,27 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
self.assertEqual(pr2.per_billed, 80)
|
self.assertEqual(pr2.per_billed, 80)
|
||||||
self.assertEqual(pr2.status, "To Bill")
|
self.assertEqual(pr2.status, "To Bill")
|
||||||
|
|
||||||
|
def test_not_accept_duplicate_serial_no(self):
|
||||||
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
||||||
|
from erpnext.stock.doctype.item.test_item import make_item
|
||||||
|
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
||||||
|
|
||||||
|
item_code = frappe.db.get_value('Item', {'has_serial_no': 1})
|
||||||
|
if not item_code:
|
||||||
|
item = make_item("Test Serial Item 1", dict(has_serial_no = 1))
|
||||||
|
item_code = item.name
|
||||||
|
|
||||||
|
serial_no = random_string(5)
|
||||||
|
make_purchase_receipt(item_code=item_code, qty=1, serial_no=serial_no)
|
||||||
|
create_delivery_note(item_code=item_code, qty=1, serial_no=serial_no)
|
||||||
|
|
||||||
|
pr = make_purchase_receipt(item_code=item_code, qty=1, serial_no=serial_no, do_not_submit=True)
|
||||||
|
self.assertRaises(SerialNoDuplicateError, pr.submit)
|
||||||
|
|
||||||
|
se = make_stock_entry(item_code=item_code, target="_Test Warehouse - _TC", qty=1,
|
||||||
|
serial_no=serial_no, basic_rate=100, do_not_submit=True)
|
||||||
|
self.assertRaises(SerialNoDuplicateError, se.submit)
|
||||||
|
|
||||||
def get_gl_entries(voucher_type, voucher_no):
|
def get_gl_entries(voucher_type, voucher_no):
|
||||||
return frappe.db.sql("""select account, debit, credit
|
return frappe.db.sql("""select account, debit, credit
|
||||||
from `tabGL Entry` where voucher_type=%s and voucher_no=%s
|
from `tabGL Entry` where voucher_type=%s and voucher_no=%s
|
||||||
|
|||||||
@ -213,7 +213,7 @@ def validate_serial_no(sle, item_det):
|
|||||||
frappe.throw(_("Serial No {0} does not belong to Item {1}").format(serial_no,
|
frappe.throw(_("Serial No {0} does not belong to Item {1}").format(serial_no,
|
||||||
sle.item_code), SerialNoItemError)
|
sle.item_code), SerialNoItemError)
|
||||||
|
|
||||||
if sr.warehouse and sle.actual_qty > 0:
|
if sle.actual_qty > 0 and has_duplicate_serial_no(sr, sle):
|
||||||
frappe.throw(_("Serial No {0} has already been received").format(serial_no),
|
frappe.throw(_("Serial No {0} has already been received").format(serial_no),
|
||||||
SerialNoDuplicateError)
|
SerialNoDuplicateError)
|
||||||
|
|
||||||
@ -234,6 +234,21 @@ def validate_serial_no(sle, item_det):
|
|||||||
frappe.throw(_("Serial Nos Required for Serialized Item {0}").format(sle.item_code),
|
frappe.throw(_("Serial Nos Required for Serialized Item {0}").format(sle.item_code),
|
||||||
SerialNoRequiredError)
|
SerialNoRequiredError)
|
||||||
|
|
||||||
|
def has_duplicate_serial_no(sn, sle):
|
||||||
|
if sn.warehouse:
|
||||||
|
return True
|
||||||
|
|
||||||
|
status = False
|
||||||
|
if sn.purchase_document_no:
|
||||||
|
if sle.voucher_type in ['Purchase Receipt', 'Stock Entry']:
|
||||||
|
status = True
|
||||||
|
|
||||||
|
if status and sle.voucher_type == 'Stock Entry' and \
|
||||||
|
frappe.db.get_value('Stock Entry', sle.voucher_no, 'purpose') != 'Material Receipt':
|
||||||
|
status = False
|
||||||
|
|
||||||
|
return status
|
||||||
|
|
||||||
def allow_serial_nos_with_different_item(sle_serial_no, sle):
|
def allow_serial_nos_with_different_item(sle_serial_no, sle):
|
||||||
"""
|
"""
|
||||||
Allows same serial nos for raw materials and finished goods
|
Allows same serial nos for raw materials and finished goods
|
||||||
|
|||||||
@ -395,7 +395,8 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
def test_serial_item_error(self):
|
def test_serial_item_error(self):
|
||||||
se, serial_nos = self.test_serial_by_series()
|
se, serial_nos = self.test_serial_by_series()
|
||||||
make_serialized_item("_Test Serialized Item", "ABCD\nEFGH")
|
if not frappe.db.exists('Serial No', 'ABCD'):
|
||||||
|
make_serialized_item("_Test Serialized Item", "ABCD\nEFGH")
|
||||||
|
|
||||||
se = frappe.copy_doc(test_records[0])
|
se = frappe.copy_doc(test_records[0])
|
||||||
se.purpose = "Material Transfer"
|
se.purpose = "Material Transfer"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user