diff options
| author | Xavier Morel <xmo@odoo.com> | 2018-12-06 10:46:57 +0000 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2018-12-07 13:37:34 +0000 |
| commit | 66f0e26f6f3f2155fcfcc55e84f2e76cbfdb2c1d (patch) | |
| tree | 7dbd4cbc827e8455eb4d8bd4013003b8069fc448 /addons | |
| parent | 299f9f1eb06f9df950df1dc02e368caa9b3a9871 (diff) | |
[CHG] *: make binary fields default to attachment=True
Check that it makes custom binary fields into attachment as that's the
main reason for the change: when users create binary fields via Studio,
they're necessarily db-stored (as the interface doesn't allow altering
the attachment attribute and it's unclear how we'd handle users
switching it on/off every time), which significantly bloats their
database (and burns storage & backup space), especially as the primary
use case for binary fields is adding images and documents to records.
* check that binary fields are properly created as attachment=True
* add attachment=False on fields where that seems relevant (most but not
all of the fields previously using the default)
* remove occurrences of attachment=True
closes odoo/odoo#29308
Diffstat (limited to 'addons')
19 files changed, 39 insertions, 42 deletions
diff --git a/addons/account_bank_statement_import/account_bank_statement_import.py b/addons/account_bank_statement_import/account_bank_statement_import.py index 6fb102104c5..652080c8416 100644 --- a/addons/account_bank_statement_import/account_bank_statement_import.py +++ b/addons/account_bank_statement_import/account_bank_statement_import.py @@ -25,7 +25,7 @@ class AccountBankStatementImport(models.TransientModel): _name = 'account.bank.statement.import' _description = 'Import Bank Statement' - data_file = fields.Binary(string='Bank Statement File', required=True, help='Get you bank statements in electronic format from your bank and select them here.') + data_file = fields.Binary(string='Bank Statement File', attachment=False, required=True, help='Get you bank statements in electronic format from your bank and select them here.') filename = fields.Char() @api.multi diff --git a/addons/base_import/models/base_import.py b/addons/base_import/models/base_import.py index 5e75af21f91..ff44294e40b 100644 --- a/addons/base_import/models/base_import.py +++ b/addons/base_import/models/base_import.py @@ -113,7 +113,7 @@ class Import(models.TransientModel): _transient_max_hours = 12.0 res_model = fields.Char('Model') - file = fields.Binary('File', help="File to check and/or import, raw binary (not base64)") + file = fields.Binary('File', help="File to check and/or import, raw binary (not base64)", attachment=False) file_name = fields.Char('File Name') file_type = fields.Char('File Type') diff --git a/addons/base_import_module/models/base_import_module.py b/addons/base_import_module/models/base_import_module.py index b678a4fe0f0..9a855384052 100644 --- a/addons/base_import_module/models/base_import_module.py +++ b/addons/base_import_module/models/base_import_module.py @@ -9,7 +9,7 @@ class BaseImportModule(models.TransientModel): _name = "base.import.module" _description = "Import Module" - module_file = fields.Binary(string='Module .ZIP file', required=True) + module_file = fields.Binary(string='Module .ZIP file', required=True, attachment=False) state = fields.Selection([('init', 'init'), ('done', 'done')], string='Status', readonly=True, default='init') import_message = fields.Char() force = fields.Boolean(string='Force init', help="Force init mode even if installed. (will update `noupdate='1'` records)") diff --git a/addons/fleet/models/fleet_vehicle_model.py b/addons/fleet/models/fleet_vehicle_model.py index ded926fc2a0..18dea8f0a95 100644 --- a/addons/fleet/models/fleet_vehicle_model.py +++ b/addons/fleet/models/fleet_vehicle_model.py @@ -41,13 +41,13 @@ class FleetVehicleModelBrand(models.Model): _order = 'name asc' name = fields.Char('Make', required=True) - image = fields.Binary("Logo", attachment=True, + image = fields.Binary("Logo", help="This field holds the image used as logo for the brand, limited to 1024x1024px.") - image_medium = fields.Binary("Medium-sized image", attachment=True, + image_medium = fields.Binary("Medium-sized image", help="Medium-sized logo of the brand. It is automatically " "resized as a 128x128px image, with aspect ratio preserved. " "Use this field in form views or some kanban views.") - image_small = fields.Binary("Small-sized image", attachment=True, + image_small = fields.Binary("Small-sized image", help="Small-sized logo of the brand. It is automatically " "resized as a 64x64px image, with aspect ratio preserved. " "Use this field anywhere a small image is required.") diff --git a/addons/gamification/models/badge.py b/addons/gamification/models/badge.py index 6686b29fee5..cf750aaa5f2 100644 --- a/addons/gamification/models/badge.py +++ b/addons/gamification/models/badge.py @@ -66,7 +66,7 @@ class GamificationBadge(models.Model): name = fields.Char('Badge', required=True, translate=True) active = fields.Boolean('Active', default=True) description = fields.Text('Description', translate=True) - image = fields.Binary("Image", attachment=True, help="This field holds the image used for the badge, limited to 256x256") + image = fields.Binary("Image", help="This field holds the image used for the badge, limited to 256x256") rule_auth = fields.Selection([ ('everyone', 'Everyone'), diff --git a/addons/hr/models/hr.py b/addons/hr/models/hr.py index 27fd8ae6962..353920a9695 100644 --- a/addons/hr/models/hr.py +++ b/addons/hr/models/hr.py @@ -168,15 +168,15 @@ class Employee(models.Model): # image: all image fields are base64 encoded and PIL-supported image = fields.Binary( - "Photo", default=_default_image, attachment=True, + "Photo", default=_default_image, help="This field holds the image used as photo for the employee, limited to 1024x1024px.") image_medium = fields.Binary( - "Medium-sized photo", attachment=True, + "Medium-sized photo", help="Medium-sized photo of the employee. It is automatically " "resized as a 128x128px image, with aspect ratio preserved. " "Use this field in form views or some kanban views.") image_small = fields.Binary( - "Small-sized photo", attachment=True, + "Small-sized photo", help="Small-sized photo of the employee. It is automatically " "resized as a 64x64px image, with aspect ratio preserved. " "Use this field anywhere a small image is required.") diff --git a/addons/im_livechat/models/im_livechat_channel.py b/addons/im_livechat/models/im_livechat_channel.py index a5c187a1067..e0aefadecb1 100644 --- a/addons/im_livechat/models/im_livechat_channel.py +++ b/addons/im_livechat/models/im_livechat_channel.py @@ -43,13 +43,13 @@ class ImLivechatChannel(models.Model): nbr_channel = fields.Integer('Number of conversation', compute='_compute_nbr_channel', store=False, readonly=True) # images fields - image = fields.Binary('Image', default=_default_image, attachment=True, + image = fields.Binary('Image', default=_default_image, help="This field holds the image used as photo for the group, limited to 1024x1024px.") - image_medium = fields.Binary('Medium', attachment=True, + image_medium = fields.Binary('Medium', help="Medium-sized photo of the group. It is automatically "\ "resized as a 128x128px image, with aspect ratio preserved. "\ "Use this field in form views or some kanban views.") - image_small = fields.Binary('Thumbnail', attachment=True, + image_small = fields.Binary('Thumbnail', help="Small-sized photo of the group. It is automatically "\ "resized as a 64x64px image, with aspect ratio preserved. "\ "Use this field anywhere a small image is required.") diff --git a/addons/l10n_fr_fec/wizard/account_fr_fec.py b/addons/l10n_fr_fec/wizard/account_fr_fec.py index be79824967a..bf18ff184ad 100644 --- a/addons/l10n_fr_fec/wizard/account_fr_fec.py +++ b/addons/l10n_fr_fec/wizard/account_fr_fec.py @@ -17,7 +17,7 @@ class AccountFrFec(models.TransientModel): date_from = fields.Date(string='Start Date', required=True) date_to = fields.Date(string='End Date', required=True) - fec_data = fields.Binary('FEC File', readonly=True) + fec_data = fields.Binary('FEC File', readonly=True, attachment=False) filename = fields.Char(string='Filename', size=256, readonly=True) export_type = fields.Selection([ ('official', 'Official FEC report (posted entries only)'), diff --git a/addons/lunch/models/lunch_product.py b/addons/lunch/models/lunch_product.py index af3d25df7d7..b9334aba260 100644 --- a/addons/lunch/models/lunch_product.py +++ b/addons/lunch/models/lunch_product.py @@ -61,15 +61,15 @@ class LunchProduct(models.Model): # image: all image fields are base64 encoded and PIL-supported image = fields.Binary( - "Image", attachment=True, + "Image", help="This field holds the image used as image for the product, limited to 1024x1024px.") image_medium = fields.Binary( - "Medium-sized image", attachment=True, + "Medium-sized image", help="Medium-sized image of the product. It is automatically " "resized as a 128x128px image, with aspect ratio preserved, " "only when the image exceeds one of those sizes. Use this field in form views or some kanban views.") image_small = fields.Binary( - "Small-sized image", attachment=True, + "Small-sized image", help="Small-sized image of the product. It is automatically " "resized as a 64x64px image, with aspect ratio preserved. " "Use this field anywhere a small image is required.") diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index f7384a87b8f..71e42eee3ff 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -101,13 +101,13 @@ class Channel(models.Model): "Note that they will be able to manage their subscription manually " "if necessary.") # image: all image fields are base64 encoded and PIL-supported - image = fields.Binary("Photo", default=_get_default_image, attachment=True, + image = fields.Binary("Photo", default=_get_default_image, help="This field holds the image used as photo for the group, limited to 1024x1024px.") - image_medium = fields.Binary('Medium-sized photo', attachment=True, + image_medium = fields.Binary('Medium-sized photo', help="Medium-sized photo of the group. It is automatically " "resized as a 128x128px image, with aspect ratio preserved. " "Use this field in form views or some kanban views.") - image_small = fields.Binary('Small-sized photo', attachment=True, + image_small = fields.Binary('Small-sized photo', help="Small-sized photo of the group. It is automatically " "resized as a 64x64px image, with aspect ratio preserved. " "Use this field anywhere a small image is required.") diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 90d9177ff58..6918f80584f 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -150,15 +150,14 @@ class PaymentAcquirer(models.Model): module_state = fields.Selection(selection=ir_module.STATES, string='Installation State', related='module_id.state', readonly=False) image = fields.Binary( - "Image", attachment=True, - help="This field holds the image used for this provider, limited to 1024x1024px") + "Image", help="This field holds the image used for this provider, limited to 1024x1024px") image_medium = fields.Binary( - "Medium-sized image", attachment=True, + "Medium-sized image", help="Medium-sized image of this provider. It is automatically " "resized as a 128x128px image, with aspect ratio preserved. " "Use this field in form views or some kanban views.") image_small = fields.Binary( - "Small-sized image", attachment=True, + "Small-sized image", help="Small-sized image of this provider. It is automatically " "resized as a 64x64px image, with aspect ratio preserved. " "Use this field anywhere a small image is required.") @@ -502,8 +501,7 @@ class PaymentIcon(models.Model): name = fields.Char(string='Name') acquirer_ids = fields.Many2many('payment.acquirer', string="Acquirers", help="List of Acquirers supporting this payment icon.") image = fields.Binary( - "Image", attachment=True, - help="This field holds the image used for this payment icon, limited to 1024x1024px") + "Image", help="This field holds the image used for this payment icon, limited to 1024x1024px") image_payment_form = fields.Binary( "Image displayed on the payment form", attachment=True) diff --git a/addons/point_of_sale/models/pos_category.py b/addons/point_of_sale/models/pos_category.py index c5741486794..8b7d69f43ff 100644 --- a/addons/point_of_sale/models/pos_category.py +++ b/addons/point_of_sale/models/pos_category.py @@ -20,13 +20,13 @@ class PosCategory(models.Model): # thumbnails for categories. However if we have a thumbnail for at least one # category, then we display a default image on the other, so that the # buttons have consistent styling. - image = fields.Binary(attachment=True, + image = fields.Binary( help="This field holds the image used as image for the cateogry, limited to 1024x1024px.") - image_medium = fields.Binary(string="Medium-sized image", attachment=True, + image_medium = fields.Binary(string="Medium-sized image", help="Medium-sized image of the category. It is automatically " "resized as a 128x128px image, with aspect ratio preserved. " "Use this field in form views or some kanban views.") - image_small = fields.Binary(string="Small-sized image", attachment=True, + image_small = fields.Binary(string="Small-sized image", help="Small-sized image of the category. It is automatically " "resized as a 64x64px image, with aspect ratio preserved. " "Use this field anywhere a small image is required.") diff --git a/addons/pos_restaurant/models/pos_restaurant.py b/addons/pos_restaurant/models/pos_restaurant.py index 7530b774c6b..ea5c3a04d5b 100644 --- a/addons/pos_restaurant/models/pos_restaurant.py +++ b/addons/pos_restaurant/models/pos_restaurant.py @@ -11,7 +11,7 @@ class RestaurantFloor(models.Model): name = fields.Char('Floor Name', required=True, help='An internal identification of the restaurant floor') pos_config_id = fields.Many2one('pos.config', string='Point of Sale') - background_image = fields.Binary('Background Image', attachment=True, help='A background image used to display a floor layout in the point of sale interface') + background_image = fields.Binary('Background Image', help='A background image used to display a floor layout in the point of sale interface') background_color = fields.Char('Background Color', help='The background color of the floor layout, (must be specified in a html-compatible format)', default='rgb(210, 210, 210)') table_ids = fields.One2many('restaurant.table', 'floor_id', string='Tables', help='The list of tables in this floor') sequence = fields.Integer('Sequence', help='Used to sort Floors', default=1) diff --git a/addons/product/models/product.py b/addons/product/models/product.py index c9b31fa57dc..5cf5d37fff4 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -114,7 +114,7 @@ class ProductProduct(models.Model): 'product.template.attribute.value', string='Template Attribute Values', compute="_compute_product_template_attribute_value_ids") # image: all image fields are base64 encoded and PIL-supported image_variant = fields.Binary( - "Variant Image", attachment=True, + "Variant Image", help="This field holds the image used as image for the product variant, limited to 1024x1024px.") image = fields.Binary( "Big-sized image", compute='_compute_images', inverse='_set_image', diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index 441c92da00f..4179cc19ffb 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -135,15 +135,14 @@ class ProductTemplate(models.Model): # image: all image fields are base64 encoded and PIL-supported image = fields.Binary( - "Image", attachment=True, - help="This field holds the image used as image for the product, limited to 1024x1024px.") + "Image", help="This field holds the image used as image for the product, limited to 1024x1024px.") image_medium = fields.Binary( - "Medium-sized image", attachment=True, + "Medium-sized image", help="Medium-sized image of the product. It is automatically " "resized as a 128x128px image, with aspect ratio preserved, " "only when the image exceeds one of those sizes. Use this field in form views or some kanban views.") image_small = fields.Binary( - "Small-sized image", attachment=True, + "Small-sized image", help="Small-sized image of the product. It is automatically " "resized as a 64x64px image, with aspect ratio preserved. " "Use this field anywhere a small image is required.") diff --git a/addons/web_editor/models/test_models.py b/addons/web_editor/models/test_models.py index f5eb7e86f64..d5ef48dc2af 100644 --- a/addons/web_editor/models/test_models.py +++ b/addons/web_editor/models/test_models.py @@ -16,7 +16,7 @@ class ConverterTest(models.Model): float = fields.Float() numeric = fields.Float(digits=(16, 2)) many2one = fields.Many2one('web_editor.converter.test.sub') - binary = fields.Binary() + binary = fields.Binary(attachment=False) date = fields.Date() datetime = fields.Datetime() selection = fields.Selection([ diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 0a99b8ef8eb..682220e126a 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -86,7 +86,7 @@ class Website(models.Model): social_youtube = fields.Char('Youtube Account', default=_default_social_youtube) social_googleplus = fields.Char('Google+ Account', default=_default_social_googleplus) social_instagram = fields.Char('Instagram Account', default=_default_social_instagram) - social_default_image = fields.Binary(string="Default Social Share Image", attachment=True, help="If set, replaces the company logo as the default social share image.") + social_default_image = fields.Binary(string="Default Social Share Image", help="If set, replaces the company logo as the default social share image.") google_analytics_key = fields.Char('Google Analytics Key') google_management_client_id = fields.Char('Google Client ID') diff --git a/addons/website_event_track/models/event_track.py b/addons/website_event_track/models/event_track.py index 1c4758d50af..23df5bbac3e 100644 --- a/addons/website_event_track/models/event_track.py +++ b/addons/website_event_track/models/event_track.py @@ -88,7 +88,7 @@ class Track(models.Model): ('0', 'Low'), ('1', 'Medium'), ('2', 'High'), ('3', 'Highest')], 'Priority', required=True, default='1') - image = fields.Binary('Image', related='partner_id.image_medium', store=True, attachment=True, readonly=False) + image = fields.Binary('Image', related='partner_id.image_medium', store=True, readonly=False) @api.multi @api.depends('name') @@ -210,4 +210,4 @@ class Sponsor(models.Model): partner_id = fields.Many2one('res.partner', 'Sponsor/Customer', required=True) url = fields.Char('Sponsor Website') sequence = fields.Integer('Sequence', store=True, related='sponsor_type_id.sequence', readonly=False) - image_medium = fields.Binary(string='Logo', related='partner_id.image_medium', store=True, attachment=True, readonly=False) + image_medium = fields.Binary(string='Logo', related='partner_id.image_medium', store=True, readonly=False) diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py index 06e9bc8595f..d9a2f9db452 100644 --- a/addons/website_sale/models/product.py +++ b/addons/website_sale/models/product.py @@ -66,13 +66,13 @@ class ProductPublicCategory(models.Model): # category, then we display a default image on the other, so that the # buttons have consistent styling. # In this case, the default image is set by the js code. - image = fields.Binary(attachment=True, help="This field holds the image used as image for the category, limited to 1024x1024px.") + image = fields.Binary(help="This field holds the image used as image for the category, limited to 1024x1024px.") website_description = fields.Html('Category Description', sanitize_attributes=False, translate=html_translate) - image_medium = fields.Binary(string='Medium-sized image', attachment=True, + image_medium = fields.Binary(string='Medium-sized image', help="Medium-sized image of the category. It is automatically " "resized as a 128x128px image, with aspect ratio preserved. " "Use this field in form views or some kanban views.") - image_small = fields.Binary(string='Small-sized image', attachment=True, + image_small = fields.Binary(string='Small-sized image', help="Small-sized image of the category. It is automatically " "resized as a 64x64px image, with aspect ratio preserved. " "Use this field anywhere a small image is required.") |
