Files
sure/app/models/rule/action_executor/set_transaction_name.rb
Augusto Xavier 09dc428136 fix(rules): make explicit re-apply override locked attributes (#2273)
When a rule is re-applied from the UI, RulesController passes
ignore_attribute_locks: true, but Enrichable#enrich_attributes still
rejected locked attributes unconditionally, so locked (manually edited
or import-locked) transactions were silently skipped and reported as
blocked.

Thread the flag through enrich_attribute/enrich_attributes as a new
ignore_locks keyword (default false, so provider syncs and AI
enrichment keep respecting locks) and pass it from the six synchronous
rule action executors.

Fixes #2051
2026-06-15 22:12:24 +02:00

33 lines
876 B
Ruby

class Rule::ActionExecutor::SetTransactionName < Rule::ActionExecutor
def type
"text"
end
def options
nil
end
def execute(transaction_scope, value: nil, ignore_attribute_locks: false, rule_run: nil)
return 0 if value.blank?
scope = transaction_scope.with_entry
unless ignore_attribute_locks
# Filter by entry's locked_attributes, not transaction's
# Since name is on Entry, not Transaction, we need to check entries.locked_attributes
scope = scope.where.not(
Arel.sql("entries.locked_attributes ? 'name'")
)
end
count_modified_resources(scope) do |txn|
# enrich_attribute returns true if the entry was actually modified, false otherwise
txn.entry.enrich_attribute(
:name,
value,
source: "rule",
ignore_locks: ignore_attribute_locks
)
end
end
end