[Fix] Sales Invoice shows default date while no default mentioned
This commit is contained in:
parent
a09285122f
commit
5d97d89a03
@ -6,7 +6,7 @@ from __future__ import unicode_literals
|
|||||||
import unittest
|
import unittest
|
||||||
import frappe
|
import frappe
|
||||||
import frappe.model
|
import frappe.model
|
||||||
from frappe.utils import cint, flt
|
from frappe.utils import cint, flt, today
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory, \
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory, \
|
||||||
test_records as pr_test_records
|
test_records as pr_test_records
|
||||||
@ -412,8 +412,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
def make_purchase_invoice(**args):
|
def make_purchase_invoice(**args):
|
||||||
pi = frappe.new_doc("Purchase Invoice")
|
pi = frappe.new_doc("Purchase Invoice")
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
if args.posting_date:
|
pi.posting_date = args.posting_date or today()
|
||||||
pi.posting_date = args.posting_date
|
|
||||||
if args.posting_time:
|
if args.posting_time:
|
||||||
pi.posting_time = args.posting_time
|
pi.posting_time = args.posting_time
|
||||||
if args.update_stock:
|
if args.update_stock:
|
||||||
|
@ -955,8 +955,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
def create_sales_invoice(**args):
|
def create_sales_invoice(**args):
|
||||||
si = frappe.new_doc("Sales Invoice")
|
si = frappe.new_doc("Sales Invoice")
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
if args.posting_date:
|
si.posting_date = args.posting_date or nowdate()
|
||||||
si.posting_date = args.posting_date or nowdate()
|
|
||||||
|
|
||||||
si.company = args.company or "_Test Company"
|
si.company = args.company or "_Test Company"
|
||||||
si.customer = args.customer or "_Test Customer"
|
si.customer = args.customer or "_Test Customer"
|
||||||
|
@ -81,10 +81,11 @@ class AccountsController(TransactionBase):
|
|||||||
convert_to_recurring(self, self.get("posting_date") or self.get("transaction_date"))
|
convert_to_recurring(self, self.get("posting_date") or self.get("transaction_date"))
|
||||||
|
|
||||||
def set_missing_values(self, for_validate=False):
|
def set_missing_values(self, for_validate=False):
|
||||||
for fieldname in ["posting_date", "transaction_date"]:
|
if frappe.flags.in_test:
|
||||||
if not self.get(fieldname) and self.meta.get_field(fieldname):
|
for fieldname in ["posting_date","transaction_date"]:
|
||||||
self.set(fieldname, today())
|
if self.meta.get_field(fieldname) and not self.get(fieldname):
|
||||||
break
|
self.set(fieldname, today())
|
||||||
|
break
|
||||||
|
|
||||||
def calculate_taxes_and_totals(self):
|
def calculate_taxes_and_totals(self):
|
||||||
from erpnext.controllers.taxes_and_totals import calculate_taxes_and_totals
|
from erpnext.controllers.taxes_and_totals import calculate_taxes_and_totals
|
||||||
|
@ -87,15 +87,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
var today = get_today(),
|
var today = get_today(),
|
||||||
currency = frappe.defaults.get_user_default("currency");
|
currency = frappe.defaults.get_user_default("currency");
|
||||||
|
|
||||||
$.each(["posting_date", "transaction_date"], function(i, fieldname) {
|
|
||||||
if (me.frm.fields_dict[fieldname] && !me.frm.doc[fieldname] && me.frm[fieldname]) {
|
|
||||||
me.frm.set_value(fieldname, me.frm[fieldname]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$.each({
|
$.each({
|
||||||
posting_date: today,
|
|
||||||
transaction_date: today,
|
|
||||||
currency: currency,
|
currency: currency,
|
||||||
price_list_currency: currency,
|
price_list_currency: currency,
|
||||||
status: "Draft",
|
status: "Draft",
|
||||||
|
@ -7,7 +7,7 @@ import unittest
|
|||||||
import frappe
|
import frappe
|
||||||
import json
|
import json
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
from frappe.utils import cint, nowdate, nowtime, cstr, add_days, flt
|
from frappe.utils import cint, nowdate, nowtime, cstr, add_days, flt, today
|
||||||
from erpnext.stock.stock_ledger import get_previous_sle
|
from erpnext.stock.stock_ledger import get_previous_sle
|
||||||
from erpnext.accounts.utils import get_balance_on
|
from erpnext.accounts.utils import get_balance_on
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
|
||||||
@ -516,8 +516,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
def create_delivery_note(**args):
|
def create_delivery_note(**args):
|
||||||
dn = frappe.new_doc("Delivery Note")
|
dn = frappe.new_doc("Delivery Note")
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
if args.posting_date:
|
dn.posting_date = args.posting_date or today()
|
||||||
dn.posting_date = args.posting_date
|
|
||||||
if args.posting_time:
|
if args.posting_time:
|
||||||
dn.posting_time = args.posting_time
|
dn.posting_time = args.posting_time
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from __future__ import unicode_literals
|
|||||||
import unittest
|
import unittest
|
||||||
import frappe
|
import frappe
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
from frappe.utils import cint, flt, cstr
|
from frappe.utils import cint, flt, cstr, today
|
||||||
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
||||||
|
|
||||||
class TestPurchaseReceipt(unittest.TestCase):
|
class TestPurchaseReceipt(unittest.TestCase):
|
||||||
@ -193,6 +193,7 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
po = create_purchase_order()
|
po = create_purchase_order()
|
||||||
|
|
||||||
pr1 = make_purchase_receipt(po.name)
|
pr1 = make_purchase_receipt(po.name)
|
||||||
|
pr1.posting_date = today()
|
||||||
pr1.posting_time = "10:00"
|
pr1.posting_time = "10:00"
|
||||||
pr1.get("items")[0].received_qty = 2
|
pr1.get("items")[0].received_qty = 2
|
||||||
pr1.get("items")[0].qty = 2
|
pr1.get("items")[0].qty = 2
|
||||||
@ -209,6 +210,7 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
pi2.submit()
|
pi2.submit()
|
||||||
|
|
||||||
pr2 = make_purchase_receipt(po.name)
|
pr2 = make_purchase_receipt(po.name)
|
||||||
|
pr2.posting_date = today()
|
||||||
pr2.posting_time = "08:00"
|
pr2.posting_time = "08:00"
|
||||||
pr2.get("items")[0].received_qty = 5
|
pr2.get("items")[0].received_qty = 5
|
||||||
pr2.get("items")[0].qty = 5
|
pr2.get("items")[0].qty = 5
|
||||||
@ -236,8 +238,7 @@ def set_perpetual_inventory(enable=1):
|
|||||||
def make_purchase_receipt(**args):
|
def make_purchase_receipt(**args):
|
||||||
pr = frappe.new_doc("Purchase Receipt")
|
pr = frappe.new_doc("Purchase Receipt")
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
if args.posting_date:
|
pr.posting_date = args.posting_date or today()
|
||||||
pr.posting_date = args.posting_date
|
|
||||||
if args.posting_time:
|
if args.posting_time:
|
||||||
pr.posting_time = args.posting_time
|
pr.posting_time = args.posting_time
|
||||||
pr.company = args.company or "_Test Company"
|
pr.company = args.company or "_Test Company"
|
||||||
|
Loading…
Reference in New Issue
Block a user