Update last purchase rate from the purchase invoice (#12189)

This commit is contained in:
rohitwaghchaure
2017-12-28 16:11:27 +05:30
committed by Nabin Hait
parent 31d7433946
commit fe22686a8f
4 changed files with 27 additions and 14 deletions

View File

@@ -8,7 +8,7 @@ from frappe.utils import flt,cint, cstr, getdate
from erpnext.accounts.party import get_party_details
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.controllers.stock_controller import StockController
@@ -409,6 +409,18 @@ class BuyingController(StockController):
"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):
if not self.schedule_date:
self.schedule_date = min([d.schedule_date for d in self.get("items")])