Repository navigation
[18.0][FIX] Show relations of archived media and images #676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
simahawk
wants to merge
6
commits into
OCA:18.0
Choose a base branch
from
camptocamp:18-fix-archived-relations
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+158
−25
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6aed745
[IMP] storage_file: show archived files
simahawk 069d717
[FIX] storage_image: do not hide relations of archived images
simahawk 1c2a538
[FIX] storage_image_product: show relations of archived images
simahawk 4817a15
[FIX] storage_media_product: show relations of archived media
simahawk 04962c3
[IMP] storage_image: label the image active field of relations
simahawk 2522234
[IMP] storage_media_product: label the media active field
simahawk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,5 +1,7 @@ | ||
| # Copyright 2018 Akretion (http://www.akretion.com). | ||
| # @author Sébastien BEAU <sebastien.beau@akretion.com> | ||
| # Copyright 2026 Camptocamp SA | ||
| # @author Simone Orsi <simone.orsi@camptocamp.com> | ||
| # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
|
||
| from odoo import api, fields, models | ||
|
|
@@ -66,7 +68,12 @@ class ProductMediaRelation(models.Model): | |
| url_path = fields.Char(related="media_id.url_path", readonly=True) | ||
| media_type_id = fields.Many2one(related="media_id.media_type_id", readonly=True) | ||
| is_public = fields.Boolean(related="media_id.file_id.is_public", readonly=True) | ||
| active = fields.Boolean(related="media_id.active", readonly=True) | ||
| # Gray out the relations of archived media. | ||
| # NOTE: do not call this field `active`, it would hide the relations | ||
| # (eg: on the product) and we want to display them anyway. | ||
| media_active = fields.Boolean( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question as for https://github.com/OCA/storage/pull/676/changes#r4381756871 |
||
| related="media_id.active", string="Media Active", readonly=True | ||
| ) | ||
|
|
||
| @api.depends("media_id", "product_tmpl_id.attribute_line_ids.value_ids") | ||
| def _compute_available_attribute(self): | ||
|
|
||
This file contains hidden or 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 @@ | ||
| from . import test_product_media |
This file contains hidden or 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,36 @@ | ||
| # Copyright 2026 Camptocamp SA | ||
| # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
|
||
| import base64 | ||
|
|
||
| from odoo.tests import Form | ||
|
|
||
| from odoo.addons.component.tests.common import TransactionComponentCase | ||
|
|
||
|
|
||
| class TestProductMedia(TransactionComponentCase): | ||
| @classmethod | ||
| def setUpClass(cls): | ||
| super().setUpClass() | ||
| cls.media = cls.env["storage.media"].create( | ||
| {"name": "doc.txt", "data": base64.b64encode(b"doc")} | ||
| ) | ||
| cls.product = cls.env["product.product"].create({"name": "Media product"}) | ||
| cls.relation = cls.env["product.media.relation"].create( | ||
| { | ||
| "media_id": cls.media.id, | ||
| "product_tmpl_id": cls.product.product_tmpl_id.id, | ||
| } | ||
| ) | ||
|
|
||
| def test_archived_relation_listed_on_template(self): | ||
| product_tmpl = self.product.product_tmpl_id | ||
| view = "storage_media_product.product_template_only_form_view" | ||
| self.media.active = False | ||
| self.assertFalse(self.relation.media_active) | ||
| self.assertEqual(len(Form(product_tmpl, view=view).media_ids), 1) | ||
|
|
||
| def test_archived_relation_listed_on_variant(self): | ||
| view = "storage_media_product.product_normal_form_view" | ||
| self.media.active = False | ||
| self.assertEqual(len(Form(self.product, view=view).variant_media_ids), 1) |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change:
searchwill return more records than expectedWouldn't it be better to keep using
activefield and just make the view list show archived fields?