mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
Merge pull request #48111 from sagarvora/use-frappe.in_test
This commit is contained in:
@@ -42,3 +42,6 @@ a308792ee7fda18a681e9181f4fd00b36385bc23
|
|||||||
# noisy typing refactoring of get_item_details
|
# noisy typing refactoring of get_item_details
|
||||||
7b7211ac79c248a79ba8a999ff34e734d874c0ae
|
7b7211ac79c248a79ba8a999ff34e734d874c0ae
|
||||||
d827ed21adc7b36047e247cbb0dc6388d048a7f9
|
d827ed21adc7b36047e247cbb0dc6388d048a7f9
|
||||||
|
|
||||||
|
# `frappe.flags.in_test` => `frappe.in_test`
|
||||||
|
7a482a69985c952de0e8193c9d4e086aee65ee6d
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ def get_company_currency(company):
|
|||||||
|
|
||||||
def set_perpetual_inventory(enable=1, company=None):
|
def set_perpetual_inventory(enable=1, company=None):
|
||||||
if not company:
|
if not company:
|
||||||
company = "_Test Company" if frappe.flags.in_test else get_default_company()
|
company = "_Test Company" if frappe.in_test else get_default_company()
|
||||||
|
|
||||||
company = frappe.get_doc("Company", company)
|
company = frappe.get_doc("Company", company)
|
||||||
company.enable_perpetual_inventory = enable
|
company.enable_perpetual_inventory = enable
|
||||||
@@ -77,7 +77,7 @@ def encode_company_abbr(name, company=None, abbr=None):
|
|||||||
|
|
||||||
def is_perpetual_inventory_enabled(company):
|
def is_perpetual_inventory_enabled(company):
|
||||||
if not company:
|
if not company:
|
||||||
company = "_Test Company" if frappe.flags.in_test else get_default_company()
|
company = "_Test Company" if frappe.in_test else get_default_company()
|
||||||
|
|
||||||
if not hasattr(frappe.local, "enable_perpetual_inventory"):
|
if not hasattr(frappe.local, "enable_perpetual_inventory"):
|
||||||
frappe.local.enable_perpetual_inventory = {}
|
frappe.local.enable_perpetual_inventory = {}
|
||||||
|
|||||||
@@ -526,7 +526,7 @@ def make_gl_entries(
|
|||||||
make_gl_entries(gl_entries, cancel=(doc.docstatus == 2), merge_entries=True)
|
make_gl_entries(gl_entries, cancel=(doc.docstatus == 2), merge_entries=True)
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if frappe.flags.in_test:
|
if frappe.in_test:
|
||||||
doc.log_error(f"Error while processing deferred accounting for Invoice {doc.name}")
|
doc.log_error(f"Error while processing deferred accounting for Invoice {doc.name}")
|
||||||
raise e
|
raise e
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -602,7 +602,7 @@ def _ensure_idle_system():
|
|||||||
# 1. Correctness: It's next to impossible to ensure that renamed account is not being used *right now*.
|
# 1. Correctness: It's next to impossible to ensure that renamed account is not being used *right now*.
|
||||||
# 2. Performance: Renaming requires locking out many tables entirely and severely degrades performance.
|
# 2. Performance: Renaming requires locking out many tables entirely and severely degrades performance.
|
||||||
|
|
||||||
if frappe.flags.in_test:
|
if frappe.in_test:
|
||||||
return
|
return
|
||||||
|
|
||||||
last_gl_update = None
|
last_gl_update = None
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class AccountingDimension(Document):
|
|||||||
frappe.throw(_("Company {0} is added more than once").format(frappe.bold(default.company)))
|
frappe.throw(_("Company {0} is added more than once").format(frappe.bold(default.company)))
|
||||||
|
|
||||||
def after_insert(self):
|
def after_insert(self):
|
||||||
if frappe.flags.in_test:
|
if frappe.in_test:
|
||||||
make_dimension_in_accounting_doctypes(doc=self)
|
make_dimension_in_accounting_doctypes(doc=self)
|
||||||
else:
|
else:
|
||||||
frappe.enqueue(
|
frappe.enqueue(
|
||||||
@@ -91,7 +91,7 @@ class AccountingDimension(Document):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
if frappe.flags.in_test:
|
if frappe.in_test:
|
||||||
delete_accounting_dimension(doc=self)
|
delete_accounting_dimension(doc=self)
|
||||||
else:
|
else:
|
||||||
frappe.enqueue(delete_accounting_dimension, doc=self, queue="long", enqueue_after_commit=True)
|
frappe.enqueue(delete_accounting_dimension, doc=self, queue="long", enqueue_after_commit=True)
|
||||||
@@ -213,7 +213,7 @@ def delete_accounting_dimension(doc):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def disable_dimension(doc):
|
def disable_dimension(doc):
|
||||||
if frappe.flags.in_test:
|
if frappe.in_test:
|
||||||
toggle_disabling(doc=doc)
|
toggle_disabling(doc=doc)
|
||||||
else:
|
else:
|
||||||
frappe.enqueue(toggle_disabling, doc=doc)
|
frappe.enqueue(toggle_disabling, doc=doc)
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class BankStatementImport(DataImport):
|
|||||||
from frappe.utils.background_jobs import is_job_enqueued
|
from frappe.utils.background_jobs import is_job_enqueued
|
||||||
from frappe.utils.scheduler import is_scheduler_inactive
|
from frappe.utils.scheduler import is_scheduler_inactive
|
||||||
|
|
||||||
run_now = frappe.flags.in_test or frappe.conf.developer_mode
|
run_now = frappe.in_test or frappe.conf.developer_mode
|
||||||
if is_scheduler_inactive() and not run_now:
|
if is_scheduler_inactive() and not run_now:
|
||||||
frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Scheduler Inactive"))
|
frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Scheduler Inactive"))
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class CurrencyExchangeSettings(Document):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_parameters_and_result()
|
self.set_parameters_and_result()
|
||||||
if frappe.flags.in_test or frappe.flags.in_install or frappe.flags.in_setup_wizard:
|
if frappe.in_test or frappe.flags.in_install or frappe.flags.in_setup_wizard:
|
||||||
return
|
return
|
||||||
response, value = self.validate_parameters()
|
response, value = self.validate_parameters()
|
||||||
self.validate_result(response, value)
|
self.validate_result(response, value)
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ def check_duplicate_fiscal_year(doc):
|
|||||||
)
|
)
|
||||||
for fiscal_year, ysd, yed in year_start_end_dates:
|
for fiscal_year, ysd, yed in year_start_end_dates:
|
||||||
if (getdate(doc.year_start_date) == ysd and getdate(doc.year_end_date) == yed) and (
|
if (getdate(doc.year_start_date) == ysd and getdate(doc.year_end_date) == yed) and (
|
||||||
not frappe.flags.in_test
|
not frappe.in_test
|
||||||
):
|
):
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_(
|
_(
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class LedgerMerge(Document):
|
|||||||
from frappe.utils.background_jobs import enqueue
|
from frappe.utils.background_jobs import enqueue
|
||||||
from frappe.utils.scheduler import is_scheduler_inactive
|
from frappe.utils.scheduler import is_scheduler_inactive
|
||||||
|
|
||||||
if is_scheduler_inactive() and not frappe.flags.in_test:
|
if is_scheduler_inactive() and not frappe.in_test:
|
||||||
frappe.throw(_("Scheduler is inactive. Cannot merge accounts."), title=_("Scheduler Inactive"))
|
frappe.throw(_("Scheduler is inactive. Cannot merge accounts."), title=_("Scheduler Inactive"))
|
||||||
|
|
||||||
job_id = f"ledger_merge::{self.name}"
|
job_id = f"ledger_merge::{self.name}"
|
||||||
@@ -47,7 +47,7 @@ class LedgerMerge(Document):
|
|||||||
event="ledger_merge",
|
event="ledger_merge",
|
||||||
job_id=job_id,
|
job_id=job_id,
|
||||||
docname=self.name,
|
docname=self.name,
|
||||||
now=frappe.conf.developer_mode or frappe.flags.in_test,
|
now=frappe.conf.developer_mode or frappe.in_test,
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ class OpeningInvoiceCreationTool(Document):
|
|||||||
else:
|
else:
|
||||||
from frappe.utils.scheduler import is_scheduler_inactive
|
from frappe.utils.scheduler import is_scheduler_inactive
|
||||||
|
|
||||||
if is_scheduler_inactive() and not frappe.flags.in_test:
|
if is_scheduler_inactive() and not frappe.in_test:
|
||||||
frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Scheduler Inactive"))
|
frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Scheduler Inactive"))
|
||||||
|
|
||||||
job_id = f"opening_invoice::{self.name}"
|
job_id = f"opening_invoice::{self.name}"
|
||||||
@@ -242,7 +242,7 @@ class OpeningInvoiceCreationTool(Document):
|
|||||||
event="opening_invoice_creation",
|
event="opening_invoice_creation",
|
||||||
job_id=job_id,
|
job_id=job_id,
|
||||||
invoices=invoices,
|
invoices=invoices,
|
||||||
now=frappe.conf.developer_mode or frappe.flags.in_test,
|
now=frappe.conf.developer_mode or frappe.in_test,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ def split_invoices_by_accounting_dimension(pos_invoices):
|
|||||||
|
|
||||||
def consolidate_pos_invoices(pos_invoices=None, closing_entry=None):
|
def consolidate_pos_invoices(pos_invoices=None, closing_entry=None):
|
||||||
invoices = pos_invoices or (closing_entry and closing_entry.get("pos_invoices"))
|
invoices = pos_invoices or (closing_entry and closing_entry.get("pos_invoices"))
|
||||||
if frappe.flags.in_test and not invoices:
|
if frappe.in_test and not invoices:
|
||||||
invoices = get_all_unconsolidated_invoices()
|
invoices = get_all_unconsolidated_invoices()
|
||||||
|
|
||||||
invoice_by_customer = get_invoice_customer_map(invoices)
|
invoice_by_customer = get_invoice_customer_map(invoices)
|
||||||
@@ -655,7 +655,7 @@ def enqueue_job(job, **kwargs):
|
|||||||
timeout=10000,
|
timeout=10000,
|
||||||
event="processing_merge_logs",
|
event="processing_merge_logs",
|
||||||
job_id=job_id,
|
job_id=job_id,
|
||||||
now=frappe.conf.developer_mode or frappe.flags.in_test,
|
now=frappe.conf.developer_mode or frappe.in_test,
|
||||||
)
|
)
|
||||||
|
|
||||||
if job == create_merge_logs:
|
if job == create_merge_logs:
|
||||||
@@ -667,7 +667,7 @@ def enqueue_job(job, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def check_scheduler_status():
|
def check_scheduler_status():
|
||||||
if is_scheduler_inactive() and not frappe.flags.in_test:
|
if is_scheduler_inactive() and not frappe.in_test:
|
||||||
frappe.throw(_("Scheduler is inactive. Cannot enqueue job."), title=_("Scheduler Inactive"))
|
frappe.throw(_("Scheduler is inactive. Cannot enqueue job."), title=_("Scheduler Inactive"))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1480,7 +1480,7 @@ def repost_gle_for_stock_vouchers(
|
|||||||
else:
|
else:
|
||||||
_delete_accounting_ledger_entries(voucher_type, voucher_no)
|
_delete_accounting_ledger_entries(voucher_type, voucher_no)
|
||||||
|
|
||||||
if not frappe.flags.in_test:
|
if not frappe.in_test:
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
if repost_doc:
|
if repost_doc:
|
||||||
|
|||||||
@@ -654,7 +654,7 @@ class AccountsController(TransactionBase):
|
|||||||
self.base_paid_amount = 0
|
self.base_paid_amount = 0
|
||||||
|
|
||||||
def set_missing_values(self, for_validate=False):
|
def set_missing_values(self, for_validate=False):
|
||||||
if frappe.flags.in_test:
|
if frappe.in_test:
|
||||||
for fieldname in ["posting_date", "transaction_date"]:
|
for fieldname in ["posting_date", "transaction_date"]:
|
||||||
if self.meta.get_field(fieldname) and not self.get(fieldname):
|
if self.meta.get_field(fieldname) and not self.get(fieldname):
|
||||||
self.set(fieldname, today())
|
self.set(fieldname, today())
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ def enqueue_multiple_variant_creation(item, args, use_template_image=False):
|
|||||||
item=item,
|
item=item,
|
||||||
args=args,
|
args=args,
|
||||||
use_template_image=use_template_image,
|
use_template_image=use_template_image,
|
||||||
now=frappe.flags.in_test,
|
now=frappe.in_test,
|
||||||
)
|
)
|
||||||
return "queued"
|
return "queued"
|
||||||
|
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ class StockController(AccountsController):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# To handle test cases
|
# To handle test cases
|
||||||
if frappe.flags.in_test and frappe.flags.use_serial_and_batch_fields:
|
if frappe.in_test and frappe.flags.use_serial_and_batch_fields:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not table_name:
|
if not table_name:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ def validate_webhooks_request(doctype, hmac_key, secret_key="secret"):
|
|||||||
def innerfn(fn):
|
def innerfn(fn):
|
||||||
settings = frappe.get_doc(doctype)
|
settings = frappe.get_doc(doctype)
|
||||||
|
|
||||||
if frappe.request and settings and settings.get(secret_key) and not frappe.flags.in_test:
|
if frappe.request and settings and settings.get(secret_key) and not frappe.in_test:
|
||||||
sig = base64.b64encode(
|
sig = base64.b64encode(
|
||||||
hmac.new(
|
hmac.new(
|
||||||
settings.get(secret_key).encode("utf8"), frappe.request.data, hashlib.sha256
|
settings.get(secret_key).encode("utf8"), frappe.request.data, hashlib.sha256
|
||||||
|
|||||||
@@ -1302,7 +1302,7 @@ def validate_bom_no(item, bom_no):
|
|||||||
if not bom.is_active:
|
if not bom.is_active:
|
||||||
frappe.throw(_("BOM {0} must be active").format(bom_no))
|
frappe.throw(_("BOM {0} must be active").format(bom_no))
|
||||||
if bom.docstatus != 1:
|
if bom.docstatus != 1:
|
||||||
if not getattr(frappe.flags, "in_test", False):
|
if not frappe.in_test:
|
||||||
frappe.throw(_("BOM {0} must be submitted").format(bom_no))
|
frappe.throw(_("BOM {0} must be submitted").format(bom_no))
|
||||||
if item:
|
if item:
|
||||||
rm_item_exists = False
|
rm_item_exists = False
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class BOMUpdateLog(Document):
|
|||||||
doc=self,
|
doc=self,
|
||||||
boms=boms,
|
boms=boms,
|
||||||
timeout=40000,
|
timeout=40000,
|
||||||
now=frappe.flags.in_test,
|
now=frappe.in_test,
|
||||||
enqueue_after_commit=True,
|
enqueue_after_commit=True,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -116,7 +116,7 @@ class BOMUpdateLog(Document):
|
|||||||
method="erpnext.manufacturing.doctype.bom_update_log.bom_update_log.process_boms_cost_level_wise",
|
method="erpnext.manufacturing.doctype.bom_update_log.bom_update_log.process_boms_cost_level_wise",
|
||||||
queue="long",
|
queue="long",
|
||||||
update_doc=self,
|
update_doc=self,
|
||||||
now=frappe.flags.in_test,
|
now=frappe.in_test,
|
||||||
enqueue_after_commit=True,
|
enqueue_after_commit=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ def run_replace_bom_job(
|
|||||||
try:
|
try:
|
||||||
doc.db_set("status", "In Progress")
|
doc.db_set("status", "In Progress")
|
||||||
|
|
||||||
if not frappe.flags.in_test:
|
if not frappe.in_test:
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
frappe.db.auto_commit_on_many_writes = 1
|
frappe.db.auto_commit_on_many_writes = 1
|
||||||
@@ -141,7 +141,7 @@ def run_replace_bom_job(
|
|||||||
finally:
|
finally:
|
||||||
frappe.db.auto_commit_on_many_writes = 0
|
frappe.db.auto_commit_on_many_writes = 0
|
||||||
|
|
||||||
if not frappe.flags.in_test:
|
if not frappe.in_test:
|
||||||
frappe.db.commit() # nosemgrep
|
frappe.db.commit() # nosemgrep
|
||||||
|
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ def queue_bom_cost_jobs(current_boms_list: list[str], update_doc: "BOMUpdateLog"
|
|||||||
bom_list=boms_to_process,
|
bom_list=boms_to_process,
|
||||||
batch_name=batch_row.name,
|
batch_name=batch_row.name,
|
||||||
queue="long",
|
queue="long",
|
||||||
now=frappe.flags.in_test,
|
now=frappe.in_test,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ def update_cost_in_level(doc: "BOMUpdateLog", bom_list: list[str], batch_name: i
|
|||||||
except Exception:
|
except Exception:
|
||||||
handle_exception(doc)
|
handle_exception(doc)
|
||||||
finally:
|
finally:
|
||||||
if not frappe.flags.in_test:
|
if not frappe.in_test:
|
||||||
frappe.db.commit() # nosemgrep
|
frappe.db.commit() # nosemgrep
|
||||||
|
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ def update_cost_in_boms(bom_list: list[str]) -> None:
|
|||||||
bom_doc.calculate_cost(save_updates=True, update_hour_rate=True)
|
bom_doc.calculate_cost(save_updates=True, update_hour_rate=True)
|
||||||
bom_doc.db_update()
|
bom_doc.db_update()
|
||||||
|
|
||||||
if (index % 50 == 0) and not frappe.flags.in_test:
|
if (index % 50 == 0) and not frappe.in_test:
|
||||||
frappe.db.commit() # nosemgrep
|
frappe.db.commit() # nosemgrep
|
||||||
|
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ def set_values_in_log(log_name: str, values: dict[str, Any], commit: bool = Fals
|
|||||||
query = query.set(key, value)
|
query = query.set(key, value)
|
||||||
query.run()
|
query.run()
|
||||||
|
|
||||||
if commit and not frappe.flags.in_test:
|
if commit and not frappe.in_test:
|
||||||
frappe.db.commit() # nosemgrep
|
frappe.db.commit() # nosemgrep
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class Task(NestedSet):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def validate_parent_project_dates(self):
|
def validate_parent_project_dates(self):
|
||||||
if not self.project or frappe.flags.in_test:
|
if not self.project or frappe.in_test:
|
||||||
return
|
return
|
||||||
|
|
||||||
if project_end_date := frappe.db.get_value("Project", self.project, "expected_end_date"):
|
if project_end_date := frappe.db.get_value("Project", self.project, "expected_end_date"):
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class VATAuditReport:
|
|||||||
self.sa_vat_accounts = frappe.get_all(
|
self.sa_vat_accounts = frappe.get_all(
|
||||||
"South Africa VAT Account", filters={"parent": self.filters.company}, pluck="account"
|
"South Africa VAT Account", filters={"parent": self.filters.company}, pluck="account"
|
||||||
)
|
)
|
||||||
if not self.sa_vat_accounts and not frappe.flags.in_test and not frappe.flags.in_migrate:
|
if not self.sa_vat_accounts and not frappe.in_test and not frappe.flags.in_migrate:
|
||||||
link_to_settings = get_link_to_form(
|
link_to_settings = get_link_to_form(
|
||||||
"South Africa VAT Settings", "", label="South Africa VAT Settings"
|
"South Africa VAT Settings", "", label="South Africa VAT Settings"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ def get_tax_accounts(company):
|
|||||||
tax_accounts_dict = frappe._dict()
|
tax_accounts_dict = frappe._dict()
|
||||||
tax_accounts_list = frappe.get_all("UAE VAT Account", filters={"parent": company}, fields=["Account"])
|
tax_accounts_list = frappe.get_all("UAE VAT Account", filters={"parent": company}, fields=["Account"])
|
||||||
|
|
||||||
if not tax_accounts_list and not frappe.flags.in_test:
|
if not tax_accounts_list and not frappe.in_test:
|
||||||
frappe.throw(_('Please set Vat Accounts for Company: "{0}" in UAE VAT Settings').format(company))
|
frappe.throw(_('Please set Vat Accounts for Company: "{0}" in UAE VAT Settings').format(company))
|
||||||
for tax_account in tax_accounts_list:
|
for tax_account in tax_accounts_list:
|
||||||
for _account, name in tax_account.items():
|
for _account, name in tax_account.items():
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class ItemGroup(NestedSet):
|
|||||||
# end: auto-generated types
|
# end: auto-generated types
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not self.parent_item_group and not frappe.flags.in_test:
|
if not self.parent_item_group and not frappe.in_test:
|
||||||
if frappe.db.exists("Item Group", _("All Item Groups")):
|
if frappe.db.exists("Item Group", _("All Item Groups")):
|
||||||
self.parent_item_group = _("All Item Groups")
|
self.parent_item_group = _("All Item Groups")
|
||||||
self.validate_item_group_defaults()
|
self.validate_item_group_defaults()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ def get_warehouse_account_map(company=None):
|
|||||||
)
|
)
|
||||||
warehouse_account_map = frappe.flags.warehouse_account_map
|
warehouse_account_map = frappe.flags.warehouse_account_map
|
||||||
|
|
||||||
if not warehouse_account_map or not company_warehouse_account_map or frappe.flags.in_test:
|
if not warehouse_account_map or not company_warehouse_account_map or frappe.in_test:
|
||||||
warehouse_account = frappe._dict()
|
warehouse_account = frappe._dict()
|
||||||
|
|
||||||
filters = {}
|
filters = {}
|
||||||
|
|||||||
@@ -773,7 +773,7 @@ class Item(Document):
|
|||||||
"erpnext.stock.doctype.item.item.update_variants",
|
"erpnext.stock.doctype.item.item.update_variants",
|
||||||
variants=variants,
|
variants=variants,
|
||||||
template=self,
|
template=self,
|
||||||
now=frappe.flags.in_test,
|
now=frappe.in_test,
|
||||||
timeout=600,
|
timeout=600,
|
||||||
enqueue_after_commit=True,
|
enqueue_after_commit=True,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ class RepostItemValuation(Document):
|
|||||||
These flags are useful for asserting real time behaviour like quantity updates.
|
These flags are useful for asserting real time behaviour like quantity updates.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not frappe.flags.in_test:
|
if not frappe.in_test:
|
||||||
return
|
return
|
||||||
if self.flags.dont_run_in_test or frappe.flags.dont_execute_stock_reposts:
|
if self.flags.dont_run_in_test or frappe.flags.dont_execute_stock_reposts:
|
||||||
return
|
return
|
||||||
@@ -276,7 +276,7 @@ def repost(doc):
|
|||||||
frappe.db.MAX_WRITES_PER_TRANSACTION *= 4
|
frappe.db.MAX_WRITES_PER_TRANSACTION *= 4
|
||||||
|
|
||||||
doc.set_status("In Progress")
|
doc.set_status("In Progress")
|
||||||
if not frappe.flags.in_test:
|
if not frappe.in_test:
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
if doc.recreate_stock_ledgers:
|
if doc.recreate_stock_ledgers:
|
||||||
@@ -290,7 +290,7 @@ def repost(doc):
|
|||||||
remove_attached_file(doc.name)
|
remove_attached_file(doc.name)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if frappe.flags.in_test:
|
if frappe.in_test:
|
||||||
# Don't silently fail in tests,
|
# Don't silently fail in tests,
|
||||||
# there is no reason for reposts to fail in CI
|
# there is no reason for reposts to fail in CI
|
||||||
raise
|
raise
|
||||||
@@ -329,7 +329,7 @@ def repost(doc):
|
|||||||
notify_error_to_stock_managers(doc, message)
|
notify_error_to_stock_managers(doc, message)
|
||||||
doc.set_status("Failed")
|
doc.set_status("Failed")
|
||||||
finally:
|
finally:
|
||||||
if not frappe.flags.in_test:
|
if not frappe.in_test:
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class SerialandBatchBundle(Document):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.allow_existing_serial_nos()
|
self.allow_existing_serial_nos()
|
||||||
if not self.flags.ignore_validate_serial_batch or frappe.flags.in_test:
|
if not self.flags.ignore_validate_serial_batch or frappe.in_test:
|
||||||
self.validate_serial_nos_duplicate()
|
self.validate_serial_nos_duplicate()
|
||||||
self.check_future_entries_exists()
|
self.check_future_entries_exists()
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ def make_stock_entry(**args):
|
|||||||
args.company = frappe.db.get_value("Warehouse", args.target, "company")
|
args.company = frappe.db.get_value("Warehouse", args.target, "company")
|
||||||
|
|
||||||
# set vales from test
|
# set vales from test
|
||||||
if frappe.flags.in_test:
|
if frappe.in_test:
|
||||||
if not args.company:
|
if not args.company:
|
||||||
args.company = "_Test Company"
|
args.company = "_Test Company"
|
||||||
if not args.item:
|
if not args.item:
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ class StockLedgerEntry(Document):
|
|||||||
self.check_stock_frozen_date()
|
self.check_stock_frozen_date()
|
||||||
|
|
||||||
# Added to handle few test cases where serial_and_batch_bundles are not required
|
# Added to handle few test cases where serial_and_batch_bundles are not required
|
||||||
if frappe.flags.in_test and frappe.flags.ignore_serial_batch_bundle_validation:
|
if frappe.in_test and frappe.flags.ignore_serial_batch_bundle_validation:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.get("via_landed_cost_voucher"):
|
if not self.get("via_landed_cost_voucher"):
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class StockSettings(Document):
|
|||||||
# changed to text
|
# changed to text
|
||||||
frappe.enqueue(
|
frappe.enqueue(
|
||||||
"erpnext.stock.doctype.stock_settings.stock_settings.clean_all_descriptions",
|
"erpnext.stock.doctype.stock_settings.stock_settings.clean_all_descriptions",
|
||||||
now=frappe.flags.in_test,
|
now=frappe.in_test,
|
||||||
enqueue_after_commit=True,
|
enqueue_after_commit=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ class StockSettings(Document):
|
|||||||
self.auto_reserve_stock = 0
|
self.auto_reserve_stock = 0
|
||||||
|
|
||||||
# Skip validation for tests
|
# Skip validation for tests
|
||||||
if frappe.flags.in_test:
|
if frappe.in_test:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Change in value of `Allow Negative Stock`
|
# Change in value of `Allow Negative Stock`
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ def update_args_in_repost_item_valuation(doc, index, args, distinct_item_warehou
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if not frappe.flags.in_test:
|
if not frappe.in_test:
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
frappe.publish_realtime(
|
frappe.publish_realtime(
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class SubcontractingReceipt(SubcontractingController):
|
|||||||
|
|
||||||
super().validate()
|
super().validate()
|
||||||
|
|
||||||
if self.is_new() and self.get("_action") == "save" and not frappe.flags.in_test:
|
if self.is_new() and self.get("_action") == "save" and not frappe.in_test:
|
||||||
self.get_scrap_items()
|
self.get_scrap_items()
|
||||||
|
|
||||||
self.set_missing_values()
|
self.set_missing_values()
|
||||||
|
|||||||
Reference in New Issue
Block a user