Skip to content

Commit

Permalink
Improve database restore process and fix image file size calculation.
Browse files Browse the repository at this point in the history
Removed redundant Odoo service restart commands during the database restore process to streamline operations. Added missing @api.depends decorator to the _compute_file_size method in the ImageMixin class to ensure accurate field dependencies.
  • Loading branch information
cbusillo committed Jul 24, 2024
1 parent 3243edf commit 5e6f8cc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 0 additions & 3 deletions init-and-run-odoo-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ sync_from_prod() {
gunzip < "$TEMP_DB_BACKUP" | pg_restore -d "$ODOO_DB" -h "$ODOO_DB_SERVER" -U "$ODOO_USER" --no-owner --role="$ODOO_USER"

echo "Database restore completed."
service odoo stop

$ODOO_SHELL --no-http -u product_connect --stop-after-init
$ODOO_SHELL --no-http -u product_connect <<EOF
from odoo import api, SUPERUSER_ID
Expand All @@ -89,7 +87,6 @@ EOF
rm "$TEMP_DB_BACKUP"

$ODOO_RUN --stop-after-init -u product_connect
service odoo start
}


Expand Down
4 changes: 2 additions & 2 deletions product_connect/mixins/image_mixin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from odoo import models, fields
from odoo import models, fields, api


class ImageMixin(models.AbstractModel):
_name = "image.mixin"
_description = "Image Mixin"
_inherit = "image.mixin"

file_size = fields.Integer(compute="_compute_file_size", store=True, group_operator="sum")

@api.depends("image_1920")
def _compute_file_size(self) -> None:
for record in self:
record.file_size = len(record.image_1920 or b'')
Expand Down

0 comments on commit 5e6f8cc

Please sign in to comment.