Merge branch 'develop' into rename-job-applicant
This commit is contained in:
commit
a01ebe0a54
@ -364,7 +364,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes"
|
update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes"
|
||||||
|
|
||||||
make_gl_entries(gl_entries, cancel=(self.docstatus == 2),
|
make_gl_entries(gl_entries, cancel=(self.docstatus == 2),
|
||||||
update_outstanding=update_outstanding, merge_entries=False)
|
update_outstanding=update_outstanding, merge_entries=False, from_repost=from_repost)
|
||||||
|
|
||||||
if update_outstanding == "No":
|
if update_outstanding == "No":
|
||||||
update_outstanding_amt(self.credit_to, "Supplier", self.supplier,
|
update_outstanding_amt(self.credit_to, "Supplier", self.supplier,
|
||||||
|
@ -698,7 +698,7 @@ class SalesInvoice(SellingController):
|
|||||||
cint(self.redeem_loyalty_points)) else "Yes"
|
cint(self.redeem_loyalty_points)) else "Yes"
|
||||||
|
|
||||||
make_gl_entries(gl_entries, cancel=(self.docstatus == 2),
|
make_gl_entries(gl_entries, cancel=(self.docstatus == 2),
|
||||||
update_outstanding=update_outstanding, merge_entries=False)
|
update_outstanding=update_outstanding, merge_entries=False, from_repost=from_repost)
|
||||||
|
|
||||||
if update_outstanding == "No":
|
if update_outstanding == "No":
|
||||||
from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt
|
from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import flt, cstr, nowdate, nowtime
|
from frappe.utils import flt, cstr, nowdate, nowtime
|
||||||
from erpnext.stock.utils import update_bin
|
from erpnext.stock.utils import update_bin
|
||||||
from erpnext.stock.stock_ledger import update_entries_after
|
from erpnext.stock.stock_ledger import update_entries_after
|
||||||
|
from erpnext.controllers.stock_controller import update_gl_entries_after
|
||||||
|
|
||||||
def repost(only_actual=False, allow_negative_stock=False, allow_zero_rate=False, only_bin=False):
|
def repost(only_actual=False, allow_negative_stock=False, allow_zero_rate=False, only_bin=False):
|
||||||
"""
|
"""
|
||||||
@ -18,12 +18,16 @@ def repost(only_actual=False, allow_negative_stock=False, allow_zero_rate=False,
|
|||||||
existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock")
|
existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock")
|
||||||
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
|
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
|
||||||
|
|
||||||
for d in frappe.db.sql("""select distinct item_code, warehouse from
|
item_warehouses = frappe.db.sql("""
|
||||||
|
select distinct item_code, warehouse
|
||||||
|
from
|
||||||
(select item_code, warehouse from tabBin
|
(select item_code, warehouse from tabBin
|
||||||
union
|
union
|
||||||
select item_code, warehouse from `tabStock Ledger Entry`) a"""):
|
select item_code, warehouse from `tabStock Ledger Entry`) a
|
||||||
|
""")
|
||||||
|
for d in item_warehouses:
|
||||||
try:
|
try:
|
||||||
repost_stock(d[0], d[1], allow_zero_rate, only_actual, only_bin)
|
repost_stock(d[0], d[1], allow_zero_rate, only_actual, only_bin, allow_negative_stock)
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
except:
|
except:
|
||||||
frappe.db.rollback()
|
frappe.db.rollback()
|
||||||
@ -32,9 +36,11 @@ def repost(only_actual=False, allow_negative_stock=False, allow_zero_rate=False,
|
|||||||
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock)
|
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock)
|
||||||
frappe.db.auto_commit_on_many_writes = 0
|
frappe.db.auto_commit_on_many_writes = 0
|
||||||
|
|
||||||
def repost_stock(item_code, warehouse, allow_zero_rate=False, only_actual=False, only_bin=False):
|
def repost_stock(item_code, warehouse, allow_zero_rate=False,
|
||||||
|
only_actual=False, only_bin=False, allow_negative_stock=False):
|
||||||
|
|
||||||
if not only_bin:
|
if not only_bin:
|
||||||
repost_actual_qty(item_code, warehouse, allow_zero_rate)
|
repost_actual_qty(item_code, warehouse, allow_zero_rate, allow_negative_stock)
|
||||||
|
|
||||||
if item_code and warehouse and not only_actual:
|
if item_code and warehouse and not only_actual:
|
||||||
qty_dict = {
|
qty_dict = {
|
||||||
@ -50,11 +56,8 @@ def repost_stock(item_code, warehouse, allow_zero_rate=False, only_actual=False,
|
|||||||
|
|
||||||
update_bin_qty(item_code, warehouse, qty_dict)
|
update_bin_qty(item_code, warehouse, qty_dict)
|
||||||
|
|
||||||
def repost_actual_qty(item_code, warehouse, allow_zero_rate=False):
|
def repost_actual_qty(item_code, warehouse, allow_zero_rate=False, allow_negative_stock=False): update_entries_after({ "item_code": item_code, "warehouse": warehouse },
|
||||||
try:
|
allow_zero_rate=allow_zero_rate, allow_negative_stock=allow_negative_stock)
|
||||||
update_entries_after({ "item_code": item_code, "warehouse": warehouse }, allow_zero_rate)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_balance_qty_from_sle(item_code, warehouse):
|
def get_balance_qty_from_sle(item_code, warehouse):
|
||||||
balance_qty = frappe.db.sql("""select qty_after_transaction from `tabStock Ledger Entry`
|
balance_qty = frappe.db.sql("""select qty_after_transaction from `tabStock Ledger Entry`
|
||||||
@ -227,39 +230,14 @@ def reset_serial_no_status_and_warehouse(serial_nos=None):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def repost_all_stock_vouchers():
|
def repost_gle_for_stock_transactions(posting_date=None, posting_time=None, for_warehouses=None):
|
||||||
warehouses_with_account = frappe.db.sql_list("""select warehouse from tabAccount
|
frappe.db.auto_commit_on_many_writes = 1
|
||||||
where ifnull(account_type, '') = 'Stock' and (warehouse is not null and warehouse != '')
|
|
||||||
and is_group=0""")
|
|
||||||
|
|
||||||
vouchers = frappe.db.sql("""select distinct voucher_type, voucher_no
|
if not posting_date:
|
||||||
from `tabStock Ledger Entry` sle
|
posting_date = "1900-01-01"
|
||||||
where voucher_type != "Serial No" and sle.warehouse in (%s)
|
if not posting_time:
|
||||||
order by posting_date, posting_time, creation""" %
|
posting_time = "00:00"
|
||||||
', '.join(['%s']*len(warehouses_with_account)), tuple(warehouses_with_account))
|
|
||||||
|
|
||||||
rejected = []
|
update_gl_entries_after(posting_date, posting_time, for_warehouses=for_warehouses)
|
||||||
i = 0
|
|
||||||
for voucher_type, voucher_no in vouchers:
|
|
||||||
i+=1
|
|
||||||
print(i, "/", len(vouchers), voucher_type, voucher_no)
|
|
||||||
try:
|
|
||||||
for dt in ["Stock Ledger Entry", "GL Entry"]:
|
|
||||||
frappe.db.sql("""delete from `tab%s` where voucher_type=%s and voucher_no=%s"""%
|
|
||||||
(dt, '%s', '%s'), (voucher_type, voucher_no))
|
|
||||||
|
|
||||||
doc = frappe.get_doc(voucher_type, voucher_no)
|
frappe.db.auto_commit_on_many_writes = 0
|
||||||
if voucher_type=="Stock Entry" and doc.purpose in ["Manufacture", "Repack"]:
|
|
||||||
doc.calculate_rate_and_amount(force=1)
|
|
||||||
elif voucher_type=="Purchase Receipt" and doc.is_subcontracted == "Yes":
|
|
||||||
doc.validate()
|
|
||||||
|
|
||||||
doc.update_stock_ledger()
|
|
||||||
doc.make_gl_entries(repost_future_gle=False)
|
|
||||||
frappe.db.commit()
|
|
||||||
except Exception:
|
|
||||||
print(frappe.get_traceback())
|
|
||||||
rejected.append([voucher_type, voucher_no])
|
|
||||||
frappe.db.rollback()
|
|
||||||
|
|
||||||
print(rejected)
|
|
||||||
|
@ -1,3 +1,18 @@
|
|||||||
{% set domains = frappe.get_doc("Domain Settings").active_domains %}
|
{% set domains = frappe.get_doc("Domain Settings").active_domains %}
|
||||||
|
{% set links = {
|
||||||
|
'Manufacturing': '/manufacturing',
|
||||||
|
'Services': '/services',
|
||||||
|
'Retail': '/retail',
|
||||||
|
'Distribution': '/distribution',
|
||||||
|
'Non Profit': '/non-profit',
|
||||||
|
'Education': '/education',
|
||||||
|
'Healthcare': '/healthcare',
|
||||||
|
'Agriculture': '/agriculture',
|
||||||
|
'Hospitality': ''
|
||||||
|
} %}
|
||||||
|
{% set link = '' %}
|
||||||
|
{% if domains %}
|
||||||
|
{% set link = links[domains[0].domain] %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<a href="https://erpnext.com?source=website_footer" target="_blank" class="text-muted">Powered by ERPNext - ERP Software {{ ('for ' + domains[0].domain + ' Companies') if domains else '' }}</a>
|
<a href="https://erpnext.com{{ link }}?source=website_footer" target="_blank" class="text-muted">Powered by ERPNext - {{ '' if domains else 'Open Source' }} ERP Software {{ ('for ' + domains[0].domain + ' Companies') if domains else '' }}</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user