Repository: WeblateOrg/weblate

Issue:
Checking "Needs editing" on a translated entry trigger "Has been translated" warning 
**Describe the bug**

After an entry has been already translated (even if it's already marked as "Need editing"), if the translation is modified and the user adds (or keeps) the "Need editing" checked, it will trigger the warning "Has been translated".

I think it shouldn't trigger that warning at least, the message is misleading and in any case the report already marks the entry that needs editing as red.

**To Reproduce the bug**

1. Go to an entry for a component (.po in my case)
2. Translate for the first time the entry and click Save.
3. Go to that entry again, click on "Needs editing" and then Save.
4. The warning will appear.

**Expected behavior**

This specific warning shouldn't show every time a translation is made and Needs editing is there. It's not a warning and the user is already marking as needing some action.

**Additional context**

See also #2935



Discussion:
The original intention of this check was to catch things that were discarded in the repo (see https://github.com/WeblateOrg/weblate/issues/1232), so it kind of makes sense to skip intentional edits in Weblate...
I get this check also when I add a component to a project (and this component has been at other project as well). I apply the tool Automatic translation. The check appears, see the screenshot:

![image](https://user-images.githubusercontent.com/70368530/230061049-20daa435-2c4c-4315-b024-56275ad61abb.png)


Resolving patch:
diff --git a/weblate/checks/consistency.py b/weblate/checks/consistency.py
--- a/weblate/checks/consistency.py
+++ b/weblate/checks/consistency.py
@@ -146,6 +146,23 @@ def get_description(self, check_obj):
             return super().get_description(check_obj)
         return _('Previous translation was "%s".') % target
 
+    def should_skip_change(self, change, unit):
+        from weblate.trans.models import Change
+
+        # Skip automatic translation entries adding needs editing string
+        return (
+            change.action == Change.ACTION_AUTO
+            and change.details.get("state", STATE_TRANSLATED) < STATE_TRANSLATED
+        )
+
+    @staticmethod
+    def should_break_changes(change):
+        from weblate.trans.models import Change
+
+        # Stop changes processin on source string change or on
+        # intentional marking as needing edit
+        return change.action in (Change.ACTION_SOURCE_CHANGE, Change.ACTION_MARKED_EDIT)
+
     def check_target_unit(self, sources, targets, unit):
         if unit.translated:
             return False
@@ -159,11 +176,13 @@ def check_target_unit(self, sources, targets, unit):
 
         changes = unit.change_set.filter(action__in=Change.ACTIONS_CONTENT).order()
 
-        for action, target in changes.values_list("action", "target"):
-            if action == Change.ACTION_SOURCE_CHANGE:
+        for change in changes:
+            if self.should_break_changes(change):
                 break
-            if target and target != unit.target:
-                return target
+            if self.should_skip_change(change, unit):
+                continue
+            if change.target and change.target != unit.target:
+                return change.target
 
         return False
 
@@ -201,7 +220,9 @@ def check_component(self, component):
 
         for unit in units:
             for change in unit.recent_consistency_changes:
-                if change.action == Change.ACTION_SOURCE_CHANGE:
+                if self.should_break_changes(change):
                     break
+                if self.should_skip_change(change, unit):
+                    continue
                 if change.target:
                     yield unit


Test patch:
diff --git a/weblate/trans/tests/test_edit.py b/weblate/trans/tests/test_edit.py
--- a/weblate/trans/tests/test_edit.py
+++ b/weblate/trans/tests/test_edit.py
@@ -109,10 +109,10 @@ def test_fuzzy(self):
         self.assertEqual(unit.target, self.target)
         self.assertFalse(unit.has_failing_check)
 
-        # Should have was translated check
+        # Should not have was translated check
         self.edit_unit(self.source, "")
         unit = self.get_unit(source=self.source)
-        self.assertTrue(unit.has_failing_check)
+        self.assertFalse(unit.has_failing_check)
 
     def add_unit(self, key, force_source: bool = False):
         if force_source or self.component.has_template():