Update last purchase rate from the purchase invoice (#12189)
This commit is contained in:
parent
31d7433946
commit
fe22686a8f
@ -277,6 +277,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
.format(item.purchase_receipt))
|
.format(item.purchase_receipt))
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
|
super(PurchaseInvoice, self).on_submit()
|
||||||
|
|
||||||
self.check_prev_docstatus()
|
self.check_prev_docstatus()
|
||||||
self.update_status_updater_args()
|
self.update_status_updater_args()
|
||||||
|
|
||||||
@ -606,6 +608,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
))
|
))
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
|
super(PurchaseInvoice, self).on_cancel()
|
||||||
|
|
||||||
self.check_for_closed_status()
|
self.check_for_closed_status()
|
||||||
|
|
||||||
self.update_status_updater_args()
|
self.update_status_updater_args()
|
||||||
|
|||||||
@ -11,8 +11,7 @@ from erpnext.controllers.buying_controller import BuyingController
|
|||||||
from erpnext.stock.doctype.item.item import get_last_purchase_details
|
from erpnext.stock.doctype.item.item import get_last_purchase_details
|
||||||
from erpnext.stock.stock_balance import update_bin_qty, get_ordered_qty
|
from erpnext.stock.stock_balance import update_bin_qty, get_ordered_qty
|
||||||
from frappe.desk.notifications import clear_doctype_notifications
|
from frappe.desk.notifications import clear_doctype_notifications
|
||||||
from erpnext.buying.utils import (validate_for_items, check_for_closed_status,
|
from erpnext.buying.utils import validate_for_items, check_for_closed_status
|
||||||
update_last_purchase_rate)
|
|
||||||
|
|
||||||
|
|
||||||
form_grid_templates = {
|
form_grid_templates = {
|
||||||
@ -189,6 +188,8 @@ class PurchaseOrder(BuyingController):
|
|||||||
clear_doctype_notifications(self)
|
clear_doctype_notifications(self)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
|
super(PurchaseOrder, self).on_submit()
|
||||||
|
|
||||||
if self.is_against_so():
|
if self.is_against_so():
|
||||||
self.update_status_updater()
|
self.update_status_updater()
|
||||||
|
|
||||||
@ -199,9 +200,9 @@ class PurchaseOrder(BuyingController):
|
|||||||
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
|
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
|
||||||
self.company, self.base_grand_total)
|
self.company, self.base_grand_total)
|
||||||
|
|
||||||
update_last_purchase_rate(self, is_submit = 1)
|
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
|
super(PurchaseOrder, self).on_cancel()
|
||||||
|
|
||||||
if self.is_against_so():
|
if self.is_against_so():
|
||||||
self.update_status_updater()
|
self.update_status_updater()
|
||||||
|
|
||||||
@ -218,8 +219,6 @@ class PurchaseOrder(BuyingController):
|
|||||||
self.update_requested_qty()
|
self.update_requested_qty()
|
||||||
self.update_ordered_qty()
|
self.update_ordered_qty()
|
||||||
|
|
||||||
update_last_purchase_rate(self, is_submit = 0)
|
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from frappe.utils import flt,cint, cstr, getdate
|
|||||||
|
|
||||||
from erpnext.accounts.party import get_party_details
|
from erpnext.accounts.party import get_party_details
|
||||||
from erpnext.stock.get_item_details import get_conversion_factor
|
from erpnext.stock.get_item_details import get_conversion_factor
|
||||||
from erpnext.buying.utils import validate_for_items
|
from erpnext.buying.utils import validate_for_items, update_last_purchase_rate
|
||||||
from erpnext.stock.stock_ledger import get_valuation_rate
|
from erpnext.stock.stock_ledger import get_valuation_rate
|
||||||
|
|
||||||
from erpnext.controllers.stock_controller import StockController
|
from erpnext.controllers.stock_controller import StockController
|
||||||
@ -409,6 +409,18 @@ class BuyingController(StockController):
|
|||||||
"actual_qty": -1*flt(d.consumed_qty),
|
"actual_qty": -1*flt(d.consumed_qty),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
def on_submit(self):
|
||||||
|
if self.get('is_return'):
|
||||||
|
return
|
||||||
|
|
||||||
|
update_last_purchase_rate(self, is_submit = 1)
|
||||||
|
|
||||||
|
def on_cancel(self):
|
||||||
|
if self.get('is_return'):
|
||||||
|
return
|
||||||
|
|
||||||
|
update_last_purchase_rate(self, is_submit = 0)
|
||||||
|
|
||||||
def validate_schedule_date(self):
|
def validate_schedule_date(self):
|
||||||
if not self.schedule_date:
|
if not self.schedule_date:
|
||||||
self.schedule_date = min([d.schedule_date for d in self.get("items")])
|
self.schedule_date = min([d.schedule_date for d in self.get("items")])
|
||||||
|
|||||||
@ -12,7 +12,7 @@ from frappe.utils import getdate
|
|||||||
from erpnext.controllers.buying_controller import BuyingController
|
from erpnext.controllers.buying_controller import BuyingController
|
||||||
from erpnext.accounts.utils import get_account_currency
|
from erpnext.accounts.utils import get_account_currency
|
||||||
from frappe.desk.notifications import clear_doctype_notifications
|
from frappe.desk.notifications import clear_doctype_notifications
|
||||||
from erpnext.buying.utils import check_for_closed_status, update_last_purchase_rate
|
from erpnext.buying.utils import check_for_closed_status
|
||||||
|
|
||||||
form_grid_templates = {
|
form_grid_templates = {
|
||||||
"items": "templates/form_grid/item_grid.html"
|
"items": "templates/form_grid/item_grid.html"
|
||||||
@ -111,6 +111,8 @@ class PurchaseReceipt(BuyingController):
|
|||||||
|
|
||||||
# on submit
|
# on submit
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
|
super(PurchaseReceipt, self).on_submit()
|
||||||
|
|
||||||
# Check for Approving Authority
|
# Check for Approving Authority
|
||||||
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
|
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
|
||||||
self.company, self.base_grand_total)
|
self.company, self.base_grand_total)
|
||||||
@ -119,9 +121,6 @@ class PurchaseReceipt(BuyingController):
|
|||||||
if self.per_billed < 100:
|
if self.per_billed < 100:
|
||||||
self.update_billing_status()
|
self.update_billing_status()
|
||||||
|
|
||||||
if not self.is_return:
|
|
||||||
update_last_purchase_rate(self, 1)
|
|
||||||
|
|
||||||
# Updating stock ledger should always be called after updating prevdoc status,
|
# Updating stock ledger should always be called after updating prevdoc status,
|
||||||
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
||||||
self.update_stock_ledger()
|
self.update_stock_ledger()
|
||||||
@ -140,6 +139,8 @@ class PurchaseReceipt(BuyingController):
|
|||||||
frappe.throw(_("Purchase Invoice {0} is already submitted").format(self.submit_rv[0][0]))
|
frappe.throw(_("Purchase Invoice {0} is already submitted").format(self.submit_rv[0][0]))
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
|
super(PurchaseReceipt, self).on_cancel()
|
||||||
|
|
||||||
self.check_for_closed_status()
|
self.check_for_closed_status()
|
||||||
# Check if Purchase Invoice has been submitted against current Purchase Order
|
# Check if Purchase Invoice has been submitted against current Purchase Order
|
||||||
submitted = frappe.db.sql("""select t1.name
|
submitted = frappe.db.sql("""select t1.name
|
||||||
@ -152,9 +153,6 @@ class PurchaseReceipt(BuyingController):
|
|||||||
self.update_prevdoc_status()
|
self.update_prevdoc_status()
|
||||||
self.update_billing_status()
|
self.update_billing_status()
|
||||||
|
|
||||||
if not self.is_return:
|
|
||||||
update_last_purchase_rate(self, 0)
|
|
||||||
|
|
||||||
# Updating stock ledger should always be called after updating prevdoc status,
|
# Updating stock ledger should always be called after updating prevdoc status,
|
||||||
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
||||||
self.update_stock_ledger()
|
self.update_stock_ledger()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user