fix: Setting to toggle customer and supplier warehouse for inter warehouse transfer (#21142)

* fix: Setting to toggle customer and supplier warehouse for inter warehouse transfer

* fix: Use cint
This commit is contained in:
Deepesh Garg 2020-04-06 10:23:06 +05:30 committed by GitHub
parent 1958749382
commit aa775f87b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 97 additions and 803 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,8 @@ import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils.html_utils import clean_html
from frappe.utils import cint
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
class StockSettings(Document):
def validate(self):
@ -61,6 +63,15 @@ class StockSettings(Document):
# changed to text
frappe.enqueue('erpnext.stock.doctype.stock_settings.stock_settings.clean_all_descriptions', now=frappe.flags.in_test)
def on_update(self):
self.toggle_warehouse_field_for_inter_warehouse_transfer()
def toggle_warehouse_field_for_inter_warehouse_transfer(self):
make_property_setter("Sales Invoice Item", "target_warehouse", "hidden", 1 - cint(self.allow_from_dn), "Check")
make_property_setter("Delivery Note Item", "target_warehouse", "hidden", 1 - cint(self.allow_from_dn), "Check")
make_property_setter("Purchase Invoice Item", "from_warehouse", "hidden", 1 - cint(self.allow_from_pr), "Check")
make_property_setter("Purchase Receipt Item", "from_warehouse", "hidden", 1 - cint(self.allow_from_pr), "Check")
def clean_all_descriptions():
for item in frappe.get_all('Item', ['name', 'description']):