-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] tracking_manager: add domain condition for tracking fields
- Loading branch information
Showing
9 changed files
with
117 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,8 @@ Usage | |
|
||
- In setting > models: select a model | ||
- Check "Active" under Custom Tracking. | ||
- Add an optional domain on the field to limit tracking on certain | ||
condition. | ||
- You have two options - 1) manually configure tracked fields one by | ||
one, or 2) determine tracked fields based on a specific domain. | ||
- For 1) manually configure tracked fields one by one | ||
|
@@ -57,14 +59,14 @@ Usage | |
accordingly. | ||
- Click "Update" for the domain to take effect. | ||
|
||
|image| | ||
|model_view| | ||
|
||
- Then select the fields to track | ||
|
||
|image1| | ||
|fields| | ||
|
||
.. |image| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/tracking_manager/static/description/model_view.png | ||
.. |image1| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/tracking_manager/static/description/fields.png | ||
.. |model_view| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/tracking_manager/static/description/model_view.png | ||
.. |fields| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/tracking_manager/static/description/fields.png | ||
|
||
Bug Tracker | ||
=========== | ||
|
@@ -89,6 +91,7 @@ Contributors | |
|
||
- Kévin Roche <[email protected]> | ||
- Sébastien BEAU <[email protected]> | ||
- Christopher Rogos <[email protected]> | ||
|
||
Maintainers | ||
----------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
- Kévin Roche \<<[email protected]>\> | ||
- Sébastien BEAU \<<[email protected]>\> | ||
- Christopher Rogos \<<[email protected]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import test_tracking_manager | ||
from . import test_models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestMailTrack(TransactionCase): | ||
def setUp(self): | ||
super().setUp() | ||
|
||
self.Field = self.env["ir.model.fields"] | ||
self.field_mobile = self.Field.search( | ||
[("model", "=", "res.partner"), ("name", "=", "mobile")], limit=1 | ||
) | ||
self.field_mobile.write({"tracking_domain": "[('is_company', '=', True)]"}) | ||
|
||
def test_mail_track(self): | ||
# arrange | ||
company = self.env.ref("base.res_partner_12") | ||
tracked_fields = {"mobile": {"string": "Mobile", "type": "char"}} | ||
initial_values = {"mobile": "1234"} | ||
|
||
# act | ||
changes, tracking_value_ids = company._mail_track( | ||
tracked_fields, initial_values | ||
) | ||
|
||
# assert | ||
# Check if changes and tracking_value_ids are returned correctly | ||
self.assertEqual(len(changes), 1) | ||
self.assertEqual(len(tracking_value_ids), 1) | ||
|
||
# Check if the field is tracked correctly | ||
tracking_value = tracking_value_ids[0][2] | ||
self.assertEqual(tracking_value["field_id"], self.field_mobile.id) | ||
|
||
def test_mail_track_with_non_matching_domain(self): | ||
# arrange | ||
person = self.env.ref("base.partner_admin") | ||
|
||
tracked_fields = {"mobile": {"string": "Mobile", "type": "char"}} | ||
initial_values = {"mobile": "1234"} | ||
|
||
# act | ||
changes, tracking_value_ids = person._mail_track(tracked_fields, initial_values) | ||
|
||
# assert | ||
# Check if changes and tracking_value_ids are empty when domain does not match | ||
self.assertEqual(len(changes), 0) | ||
self.assertEqual(len(tracking_value_ids), 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters