Skip to content

Commit

Permalink
Refactor attachment field and add product_variant_id to product i…
Browse files Browse the repository at this point in the history
…mage view.

Consolidate `attachment` field definition for readability in `image_mixin.py`. Add `product_variant_id` field to the tree view in `product_image_views.xml` to improve functionality.
  • Loading branch information
cbusillo committed Jul 25, 2024
1 parent 0ae7a09 commit eea4243
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 2 additions & 4 deletions product_connect/mixins/image_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ class ImageMixin(models.AbstractModel):
_description = "Image Mixin"
_inherit = "image.mixin"

attachment = fields.Many2one(
"ir.attachment", compute="_compute_attachment", store=True
)
image_1920_file_size = fields.Integer(related="attachment.file_size", store=True)
attachment = fields.Many2one("ir.attachment", compute="_compute_attachment", store=True)
image_1920_file_size = fields.Integer(related="attachment.file_size", store=True, group_operator="sum")

@api.depends("attachment")
def _compute_attachment(self) -> None:
Expand Down
1 change: 1 addition & 0 deletions product_connect/views/product_image_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<field name="name"/>
<field name="image_1920_file_size"/>
<field name="image_1920" widget="image_upload"/>
<field name="product_tmpl_id"/>
<button name="action_open_full_image" type="object" string="View Full Image" class="btn btn-primary"/>
</tree>
</field>
Expand Down

0 comments on commit eea4243

Please sign in to comment.