diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index a59a00f0e8da62e23eb57132f615d59825e00b08..11e539aa60bad4fba205c35fadf3a1e66c87f95e 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -103,7 +103,7 @@ <span t-esc="record.name.value"/> </div> <div class="col-2 text-right"> - <img t-att-src="kanban_image('res.partner', 'image_small', record.partner_id.raw_value)" t-att-title="record.partner_id.value" t-att-alt="record.partner_id.value" width="24" height="24" class="oe_kanban_avatar"/> + <img t-att-src="kanban_image('res.partner', 'image_64', record.partner_id.raw_value)" t-att-title="record.partner_id.value" t-att-alt="record.partner_id.value" width="24" height="24" class="oe_kanban_avatar"/> </div> </div> </div> diff --git a/addons/account/views/account_portal_templates.xml b/addons/account/views/account_portal_templates.xml index 25cd8c84e34750404675f3d9e70c9cfe2367df90..e4705746870ba86efc364a18cb7f1db75490e50f 100644 --- a/addons/account/views/account_portal_templates.xml +++ b/addons/account/views/account_portal_templates.xml @@ -108,7 +108,7 @@ <div class="small mb-1"><strong class="text-muted">Salesperson</strong></div> <div class="row"> <div class="col flex-grow-0 pr-2"> - <img t-if="invoice.invoice_user_id.image" class="rounded-circle mt-1 o_portal_contact_img" t-att-src="image_data_uri(invoice.invoice_user_id.image)" alt="Contact"/> + <img t-if="invoice.invoice_user_id.image_1024" class="rounded-circle mt-1 o_portal_contact_img" t-att-src="image_data_uri(invoice.invoice_user_id.image_1024)" alt="Contact"/> <img t-else="" class="rounded-circle mt-1 o_portal_contact_img" src="/web/static/src/img/user_menu_avatar.png" alt="Contact"/> </div> <div class="col pl-0"> diff --git a/addons/account_analytic_default/views/account_analytic_default_view.xml b/addons/account_analytic_default/views/account_analytic_default_view.xml index f86ba13a513c957609faf789fbc6d413a7657cb0..ab568e3cd960dc6da497410dec75be583f5267dd 100644 --- a/addons/account_analytic_default/views/account_analytic_default_view.xml +++ b/addons/account_analytic_default/views/account_analytic_default_view.xml @@ -59,7 +59,7 @@ <div t-attf-class="oe_kanban_card oe_kanban_global_click"> <div> <strong><span><field name="analytic_id"/></span></strong> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> </div> <div t-if="record.date_start.value"><i class="fa fa-calendar"></i> From <field name="date_start"/> <t t-if="record.date_stop.value">to <field name="date_stop"/></t></div> <div t-if="record.product_id.value"><strong>Product</strong> <field name="product_id"/> </div> diff --git a/addons/calendar/views/calendar_views.xml b/addons/calendar/views/calendar_views.xml index ff19273d798e9149710cf5e5fee7542226d14cec..e6845169f793c5f2aafec331139e30c02fbeda24 100644 --- a/addons/calendar/views/calendar_views.xml +++ b/addons/calendar/views/calendar_views.xml @@ -275,7 +275,7 @@ event_limit="3" color="partner_id"> <field name="name"/> - <field name="partner_ids" write_model="calendar.contacts" write_field="partner_id" avatar_field="image_small"/> + <field name="partner_ids" write_model="calendar.contacts" write_field="partner_id" avatar_field="image_64"/> <field name="is_highlighted" invisible="1"/> </calendar> </field> diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index d033a750ed20b59220f2f7ca0979f47fdb7eccad..cbc347a66757631269c0efd048cadc481e12d97d 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -532,7 +532,7 @@ class Lead(models.Model): 'effect': { 'fadeout': 'slow', 'message': message, - 'img_url': '/web/image/%s/%s/image' % (self.team_id.user_id._name, self.team_id.user_id.id) if self.team_id.user_id.image else '/web/static/src/img/smile.svg', + 'img_url': '/web/image/%s/%s/image_1024' % (self.team_id.user_id._name, self.team_id.user_id.id) if self.team_id.user_id.image_1024 else '/web/static/src/img/smile.svg', 'type': 'rainbow_man', } } diff --git a/addons/crm/views/crm_lead_views.xml b/addons/crm/views/crm_lead_views.xml index a10ba85000fbc1fc6b4f055d276a2742ad71f6fe..56822dfe6c3fc0dd2e60d08a482ef07b8c500ba2 100644 --- a/addons/crm/views/crm_lead_views.xml +++ b/addons/crm/views/crm_lead_views.xml @@ -247,7 +247,7 @@ </div> </div> <div class="oe_kanban_bottom_right"> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> </div> </div> </div> @@ -355,7 +355,7 @@ <field name="company_currency"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value"/> + <img t-att-src="activity_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value"/> <div> <field name="name" display="full"/> <field name="planned_revenue" widget="monetary" display="full" muted="1"/> @@ -424,7 +424,7 @@ <field name="activity_ids" widget="kanban_activity"/> </div> <div class="oe_kanban_bottom_right"> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar"/> </div> </div> </div> diff --git a/addons/event_sale/models/event.py b/addons/event_sale/models/event.py index ba407dc8f6049b22c798197032da82374ab05df7..98485e5dd1d7dadd82f05a9345280168e7de690d 100644 --- a/addons/event_sale/models/event.py +++ b/addons/event_sale/models/event.py @@ -239,8 +239,8 @@ class EventRegistration(models.Model): def summary(self): res = super(EventRegistration, self).summary() - if self.event_ticket_id.product_id.image_medium: - res['image'] = '/web/image/product.product/%s/image_medium' % self.event_ticket_id.product_id.id + if self.event_ticket_id.product_id.image_128: + res['image'] = '/web/image/product.product/%s/image_128' % self.event_ticket_id.product_id.id information = res.setdefault('information', {}) information.append((_('Name'), self.name)) information.append((_('Ticket'), self.event_ticket_id.name or _('None'))) diff --git a/addons/fleet/data/fleet_cars_data.xml b/addons/fleet/data/fleet_cars_data.xml index c2f4c011ddc1557fba5aaefe7f484ead57ea838c..a3ca54750df976761360d1812b3f86d742c708b3 100644 --- a/addons/fleet/data/fleet_cars_data.xml +++ b/addons/fleet/data/fleet_cars_data.xml @@ -2,267 +2,267 @@ <odoo> <record id="brand_abarth" model="fleet.vehicle.model.brand"> <field name="name">Abarth</field> - <field name="image" type="base64" file="fleet/static/img/brand_abarth-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_abarth-image.png"/> </record> <record id="brand_acura" model="fleet.vehicle.model.brand"> <field name="name">Acura</field> - <field name="image" type="base64" file="fleet/static/img/brand_acura-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_acura-image.png"/> </record> <record id="brand_alfa" model="fleet.vehicle.model.brand"> <field name="name">Alfa</field> - <field name="image" type="base64" file="fleet/static/img/brand_alfa-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_alfa-image.png"/> </record> <record id="brand_audi" model="fleet.vehicle.model.brand"> <field name="name">Audi</field> - <field name="image" type="base64" file="fleet/static/img/brand_audi-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_audi-image.png"/> </record> <record id="brand_austin" model="fleet.vehicle.model.brand"> <field name="name">Austin</field> - <field name="image" type="base64" file="fleet/static/img/brand_austin-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_austin-image.png"/> </record> <record id="brand_bentley" model="fleet.vehicle.model.brand"> <field name="name">Bentley</field> - <field name="image" type="base64" file="fleet/static/img/brand_bentley-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_bentley-image.png"/> </record> <record id="brand_bmw" model="fleet.vehicle.model.brand"> <field name="name">Bmw</field> - <field name="image" type="base64" file="fleet/static/img/brand_bmw-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_bmw-image.png"/> </record> <record id="brand_bugatti" model="fleet.vehicle.model.brand"> <field name="name">Bugatti</field> - <field name="image" type="base64" file="fleet/static/img/brand_bugatti-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_bugatti-image.png"/> </record> <record id="brand_buick" model="fleet.vehicle.model.brand"> <field name="name">Buick</field> - <field name="image" type="base64" file="fleet/static/img/brand_buick-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_buick-image.png"/> </record> <record id="brand_byd" model="fleet.vehicle.model.brand"> <field name="name">Byd</field> - <field name="image" type="base64" file="fleet/static/img/brand_byd-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_byd-image.png"/> </record> <record id="brand_cadillac" model="fleet.vehicle.model.brand"> <field name="name">Cadillac</field> - <field name="image" type="base64" file="fleet/static/img/brand_cadillac-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_cadillac-image.png"/> </record> <record id="brand_chevrolet" model="fleet.vehicle.model.brand"> <field name="name">Chevrolet</field> - <field name="image" type="base64" file="fleet/static/img/brand_chevrolet-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_chevrolet-image.png"/> </record> <record id="brand_chrysler" model="fleet.vehicle.model.brand"> <field name="name">Chrysler</field> - <field name="image" type="base64" file="fleet/static/img/brand_chrysler-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_chrysler-image.png"/> </record> <record id="brand_citroen" model="fleet.vehicle.model.brand"> <field name="name">Citroen</field> - <field name="image" type="base64" file="fleet/static/img/brand_citroen-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_citroen-image.png"/> </record> <record id="brand_corre_la_licorne" model="fleet.vehicle.model.brand"> <field name="name">Corre La Licorne</field> - <field name="image" type="base64" file="fleet/static/img/brand_corre-la-licorne-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_corre-la-licorne-image.png"/> </record> <record id="brand_daewoo" model="fleet.vehicle.model.brand"> <field name="name">Daewoo</field> - <field name="image" type="base64" file="fleet/static/img/brand_daewoo-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_daewoo-image.png"/> </record> <record id="brand_dodge" model="fleet.vehicle.model.brand"> <field name="name">Dodge</field> - <field name="image" type="base64" file="fleet/static/img/brand_dodge-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_dodge-image.png"/> </record> <record id="brand_ferrari" model="fleet.vehicle.model.brand"> <field name="name">Ferrari</field> - <field name="image" type="base64" file="fleet/static/img/brand_ferrari-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_ferrari-image.png"/> </record> <record id="brand_fiat" model="fleet.vehicle.model.brand"> <field name="name">Fiat</field> - <field name="image" type="base64" file="fleet/static/img/brand_fiat-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_fiat-image.png"/> </record> <record id="brand_ford" model="fleet.vehicle.model.brand"> <field name="name">Ford</field> - <field name="image" type="base64" file="fleet/static/img/brand_ford-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_ford-image.png"/> </record> <record id="brand_holden" model="fleet.vehicle.model.brand"> <field name="name">Holden</field> - <field name="image" type="base64" file="fleet/static/img/brand_holden-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_holden-image.png"/> </record> <record id="brand_honda" model="fleet.vehicle.model.brand"> <field name="name">Honda</field> - <field name="image" type="base64" file="fleet/static/img/brand_honda-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_honda-image.png"/> </record> <record id="brand_hyundai" model="fleet.vehicle.model.brand"> <field name="name">Hyundai</field> - <field name="image" type="base64" file="fleet/static/img/brand_hyundai-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_hyundai-image.png"/> </record> <record id="brand_infiniti" model="fleet.vehicle.model.brand"> <field name="name">Infiniti</field> - <field name="image" type="base64" file="fleet/static/img/brand_infiniti-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_infiniti-image.png"/> </record> <record id="brand_isuzu" model="fleet.vehicle.model.brand"> <field name="name">Isuzu</field> - <field name="image" type="base64" file="fleet/static/img/brand_isuzu-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_isuzu-image.png"/> </record> <record id="brand_jaguar" model="fleet.vehicle.model.brand"> <field name="name">Jaguar</field> - <field name="image" type="base64" file="fleet/static/img/brand_jaguar-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_jaguar-image.png"/> </record> <record id="brand_jeep" model="fleet.vehicle.model.brand"> <field name="name">Jeep</field> - <field name="image" type="base64" file="fleet/static/img/brand_jeep-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_jeep-image.png"/> </record> <record id="brand_kia" model="fleet.vehicle.model.brand"> <field name="name">Kia</field> - <field name="image" type="base64" file="fleet/static/img/brand_kia-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_kia-image.png"/> </record> <record id="brand_koenigsegg" model="fleet.vehicle.model.brand"> <field name="name">Koenigsegg</field> - <field name="image" type="base64" file="fleet/static/img/brand_koenigsegg-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_koenigsegg-image.png"/> </record> <record id="brand_lagonda" model="fleet.vehicle.model.brand"> <field name="name">Lagonda</field> - <field name="image" type="base64" file="fleet/static/img/brand_lagonda-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_lagonda-image.png"/> </record> <record id="brand_lamborghini" model="fleet.vehicle.model.brand"> <field name="name">Lamborghini</field> - <field name="image" type="base64" file="fleet/static/img/brand_lamborghini-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_lamborghini-image.png"/> </record> <record id="brand_lancia" model="fleet.vehicle.model.brand"> <field name="name">Lancia</field> - <field name="image" type="base64" file="fleet/static/img/brand_lancia-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_lancia-image.png"/> </record> <record id="brand_land_rover" model="fleet.vehicle.model.brand"> <field name="name">Land Rover</field> - <field name="image" type="base64" file="fleet/static/img/brand_land-rover-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_land-rover-image.png"/> </record> <record id="brand_lexus" model="fleet.vehicle.model.brand"> <field name="name">Lexus</field> - <field name="image" type="base64" file="fleet/static/img/brand_lexus-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_lexus-image.png"/> </record> <record id="brand_lincoln" model="fleet.vehicle.model.brand"> <field name="name">Lincoln</field> - <field name="image" type="base64" file="fleet/static/img/brand_lincoln-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_lincoln-image.png"/> </record> <record id="brand_lotus" model="fleet.vehicle.model.brand"> <field name="name">Lotus</field> - <field name="image" type="base64" file="fleet/static/img/brand_lotus-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_lotus-image.png"/> </record> <record id="brand_maserati" model="fleet.vehicle.model.brand"> <field name="name">Maserati</field> - <field name="image" type="base64" file="fleet/static/img/brand_maserati-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_maserati-image.png"/> </record> <record id="brand_maybach" model="fleet.vehicle.model.brand"> <field name="name">Maybach</field> - <field name="image" type="base64" file="fleet/static/img/brand_maybach-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_maybach-image.png"/> </record> <record id="brand_mazda" model="fleet.vehicle.model.brand"> <field name="name">Mazda</field> - <field name="image" type="base64" file="fleet/static/img/brand_mazda-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_mazda-image.png"/> </record> <record id="brand_mercedes" model="fleet.vehicle.model.brand"> <field name="name">Mercedes</field> - <field name="image" type="base64" file="fleet/static/img/brand_mercedes-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_mercedes-image.png"/> </record> <record id="brand_mg" model="fleet.vehicle.model.brand"> <field name="name">Mg</field> - <field name="image" type="base64" file="fleet/static/img/brand_mg-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_mg-image.png"/> </record> <record id="brand_mini" model="fleet.vehicle.model.brand"> <field name="name">Mini</field> - <field name="image" type="base64" file="fleet/static/img/brand_mini-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_mini-image.png"/> </record> <record id="brand_mitsubishi" model="fleet.vehicle.model.brand"> <field name="name">Mitsubishi</field> - <field name="image" type="base64" file="fleet/static/img/brand_mitsubishi-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_mitsubishi-image.png"/> </record> <record id="brand_morgan" model="fleet.vehicle.model.brand"> <field name="name">Morgan</field> - <field name="image" type="base64" file="fleet/static/img/brand_morgan-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_morgan-image.png"/> </record> <record id="brand_nissan" model="fleet.vehicle.model.brand"> <field name="name">Nissan</field> - <field name="image" type="base64" file="fleet/static/img/brand_nissan-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_nissan-image.png"/> </record> <record id="brand_oldsmobile" model="fleet.vehicle.model.brand"> <field name="name">Oldsmobile</field> - <field name="image" type="base64" file="fleet/static/img/brand_oldsmobile-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_oldsmobile-image.png"/> </record> <record id="brand_opel" model="fleet.vehicle.model.brand"> <field name="name">Opel</field> - <field name="image" type="base64" file="fleet/static/img/brand_opel-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_opel-image.png"/> </record> <record id="brand_peugeot" model="fleet.vehicle.model.brand"> <field name="name">Peugeot</field> - <field name="image" type="base64" file="fleet/static/img/brand_peugeot-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_peugeot-image.png"/> </record> <record id="brand_pontiac" model="fleet.vehicle.model.brand"> <field name="name">Pontiac</field> - <field name="image" type="base64" file="fleet/static/img/brand_pontiac-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_pontiac-image.png"/> </record> <record id="brand_porsche" model="fleet.vehicle.model.brand"> <field name="name">Porsche</field> - <field name="image" type="base64" file="fleet/static/img/brand_porsche-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_porsche-image.png"/> </record> <record id="brand_rambler" model="fleet.vehicle.model.brand"> <field name="name">Rambler</field> - <field name="image" type="base64" file="fleet/static/img/brand_rambler-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_rambler-image.png"/> </record> <record id="brand_renault" model="fleet.vehicle.model.brand"> <field name="name">Renault</field> - <field name="image" type="base64" file="fleet/static/img/brand_renault-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_renault-image.png"/> </record> <record id="brand_rolls-royce" model="fleet.vehicle.model.brand"> <field name="name">Rolls-Royce</field> - <field name="image" type="base64" file="fleet/static/img/brand_rolls-royce-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_rolls-royce-image.png"/> </record> <record id="brand_saab" model="fleet.vehicle.model.brand"> <field name="name">Saab</field> - <field name="image" type="base64" file="fleet/static/img/brand_saab-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_saab-image.png"/> </record> <record id="brand_scion" model="fleet.vehicle.model.brand"> <field name="name">Scion</field> - <field name="image" type="base64" file="fleet/static/img/brand_scion-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_scion-image.png"/> </record> <record id="brand_skoda" model="fleet.vehicle.model.brand"> <field name="name">Skoda</field> - <field name="image" type="base64" file="fleet/static/img/brand_skoda-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_skoda-image.png"/> </record> <record id="brand_smart" model="fleet.vehicle.model.brand"> <field name="name">Smart</field> - <field name="image" type="base64" file="fleet/static/img/brand_smart-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_smart-image.png"/> </record> <record id="brand_steyr" model="fleet.vehicle.model.brand"> <field name="name">Steyr</field> - <field name="image" type="base64" file="fleet/static/img/brand_steyr-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_steyr-image.png"/> </record> <record id="brand_subaru" model="fleet.vehicle.model.brand"> <field name="name">Subaru</field> - <field name="image" type="base64" file="fleet/static/img/brand_subaru-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_subaru-image.png"/> </record> <record id="brand_tesla_motors" model="fleet.vehicle.model.brand"> <field name="name">Tesla Motors</field> - <field name="image" type="base64" file="fleet/static/img/brand_tesla-motors-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_tesla-motors-image.png"/> </record> <record id="brand_toyota" model="fleet.vehicle.model.brand"> <field name="name">Toyota</field> - <field name="image" type="base64" file="fleet/static/img/brand_toyota-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_toyota-image.png"/> </record> <record id="brand_trabant" model="fleet.vehicle.model.brand"> <field name="name">Trabant</field> - <field name="image" type="base64" file="fleet/static/img/brand_trabant-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_trabant-image.png"/> </record> <record id="brand_volkswagen" model="fleet.vehicle.model.brand"> <field name="name">Volkswagen</field> - <field name="image" type="base64" file="fleet/static/img/brand_volkswagen-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_volkswagen-image.png"/> </record> <record id="brand_volvo" model="fleet.vehicle.model.brand"> <field name="name">Volvo</field> - <field name="image" type="base64" file="fleet/static/img/brand_volvo-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_volvo-image.png"/> </record> <record id="brand_willys" model="fleet.vehicle.model.brand"> <field name="name">Willys</field> - <field name="image" type="base64" file="fleet/static/img/brand_willys-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_willys-image.png"/> </record> <record id="brand_suzuki" model="fleet.vehicle.model.brand"> <field name="name">Suzuki</field> - <field name="image" type="base64" file="fleet/static/img/brand_suzuki-image.png"/> + <field name="image_128" type="base64" file="fleet/static/img/brand_suzuki-image.png"/> </record> <record id="model_corsa" model="fleet.vehicle.model"> <field name="name">Corsa</field> diff --git a/addons/fleet/models/fleet_vehicle.py b/addons/fleet/models/fleet_vehicle.py index 3a713a0140e2443dc2d471e24137d8a01057689c..ce22e580d7c7f1ef578d836a4036dd81a3385cb1 100644 --- a/addons/fleet/models/fleet_vehicle.py +++ b/addons/fleet/models/fleet_vehicle.py @@ -72,9 +72,7 @@ class FleetVehicle(models.Model): horsepower_tax = fields.Float('Horsepower Taxation') power = fields.Integer('Power', help='Power in kW of the vehicle') co2 = fields.Float('CO2 Emissions', help='CO2 emissions of the vehicle') - image = fields.Binary(related='model_id.image', string="Logo", readonly=False) - image_medium = fields.Binary(related='model_id.image_medium', string="Logo (medium)", readonly=False) - image_small = fields.Binary(related='model_id.image_small', string="Logo (small)", readonly=False) + image_128 = fields.Image(related='model_id.image_128', readonly=False) contract_renewal_due_soon = fields.Boolean(compute='_compute_contract_reminder', search='_search_contract_renewal_due_soon', string='Has Contracts to renew', multi='contract_info') contract_renewal_overdue = fields.Boolean(compute='_compute_contract_reminder', search='_search_get_overdue_contract_reminder', @@ -203,13 +201,6 @@ class FleetVehicle(models.Model): res.append(('id', search_operator, res_ids)) return res - @api.onchange('model_id') - def _onchange_model(self): - if self.model_id: - self.image_medium = self.model_id.image - else: - self.image_medium = False - @api.model def create(self, vals): res = super(FleetVehicle, self).create(vals) diff --git a/addons/fleet/models/fleet_vehicle_model.py b/addons/fleet/models/fleet_vehicle_model.py index e945da2ac71f5536918141396591baa578725974..ab6981c760054b28d252a551019eea5ad5b47959 100644 --- a/addons/fleet/models/fleet_vehicle_model.py +++ b/addons/fleet/models/fleet_vehicle_model.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models, tools +from odoo import api, fields, models class FleetVehicleModel(models.Model): @@ -14,9 +14,7 @@ class FleetVehicleModel(models.Model): vendors = fields.Many2many('res.partner', 'fleet_vehicle_model_vendors', 'model_id', 'partner_id', string='Vendors') manager_id = fields.Many2one('res.users', 'Fleet Manager', default=lambda self: self.env.uid, domain=lambda self: [('groups_id', 'in', self.env.ref('fleet.fleet_group_manager').id)]) - image = fields.Binary(related='brand_id.image', string="Logo", readonly=False) - image_medium = fields.Binary(related='brand_id.image_medium', string="Logo (medium)", readonly=False) - image_small = fields.Binary(related='brand_id.image_small', string="Logo (small)", readonly=False) + image_128 = fields.Image(related='brand_id.image_128', readonly=False) @api.depends('name', 'brand_id') def name_get(self): @@ -28,13 +26,6 @@ class FleetVehicleModel(models.Model): res.append((record.id, name)) return res - @api.onchange('brand_id') - def _onchange_brand(self): - if self.brand_id: - self.image_medium = self.brand_id.image - else: - self.image_medium = False - class FleetVehicleModelBrand(models.Model): _name = 'fleet.vehicle.model.brand' @@ -42,23 +33,4 @@ class FleetVehicleModelBrand(models.Model): _order = 'name asc' name = fields.Char('Make', required=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", - 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", - 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.") - - @api.model_create_multi - def create(self, vals_list): - for vals in vals_list: - tools.image_resize_images(vals) - return super(FleetVehicleModelBrand, self).create(vals_list) - - def write(self, vals): - tools.image_resize_images(vals) - return super(FleetVehicleModelBrand, self).write(vals) + image_128 = fields.Image("Logo", max_width=128, max_height=128) diff --git a/addons/fleet/views/fleet_vehicle_cost_views.xml b/addons/fleet/views/fleet_vehicle_cost_views.xml index a21159c36111c7b98c28d788e4e8c9be7c855aa0..211c1910020a78a47575f99f95d79eed5a15b940 100644 --- a/addons/fleet/views/fleet_vehicle_cost_views.xml +++ b/addons/fleet/views/fleet_vehicle_cost_views.xml @@ -365,7 +365,7 @@ <field name="purchaser_id"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('res.partner', 'image_small', record.purchaser_id.raw_value)" t-att-title="record.purchaser_id.value" t-att-alt="record.purchaser_id.value"/> + <img t-att-src="activity_image('res.partner', 'image_64', record.purchaser_id.raw_value)" t-att-title="record.purchaser_id.value" t-att-alt="record.purchaser_id.value"/> <div> <field name="vehicle_id" display="full"/> <field name="cost_subtype_id" muted="1" display="full"/> diff --git a/addons/fleet/views/fleet_vehicle_model_views.xml b/addons/fleet/views/fleet_vehicle_model_views.xml index ecb8741ec98738c610b470855c66945afe7dc609..862d8eb111f41a86aef962cced625d945ceb0f75 100644 --- a/addons/fleet/views/fleet_vehicle_model_views.xml +++ b/addons/fleet/views/fleet_vehicle_model_views.xml @@ -6,7 +6,7 @@ <field name="arch" type="xml"> <form string="Model"> <sheet> - <field name="image_medium" widget='image' class="oe_avatar"/> + <field name="image_128" widget='image' class="oe_avatar"/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1> @@ -106,7 +106,7 @@ <sheet> <group> <div> - <field name="image_medium" widget="image" class="oe_avatar"/> + <field name="image_128" widget="image" class="oe_avatar"/> <label for="name" class="oe_edit_only"/> <h1> <field name="name"/> @@ -125,12 +125,11 @@ <kanban> <field name="id"/> <field name="name" /> - <field name="image" /> <templates> <t t-name="kanban-box"> <div class="oe_kanban_vignette oe_semantic_html_override"> <a type="open" href="#" class="o_kanban_image oe_kanban_action"> - <img alt="Open" t-att-src="kanban_image('fleet.vehicle.model.brand', 'image_small', record.id.raw_value)" class="img-fluid" style="width:100px;"/> + <img alt="Open" t-att-src="kanban_image('fleet.vehicle.model.brand', 'image_128', record.id.raw_value)" class="img-fluid" style="width:100px;"/> </a> <div class="oe_kanban_details"> <h4 class="oe_partner_heading"> diff --git a/addons/fleet/views/fleet_vehicle_views.xml b/addons/fleet/views/fleet_vehicle_views.xml index 8c3c609034071248ede524810dc37f5a8ad74084..68616c60855e6bca1c9b34c577d83495830a6056 100644 --- a/addons/fleet/views/fleet_vehicle_views.xml +++ b/addons/fleet/views/fleet_vehicle_views.xml @@ -60,7 +60,7 @@ <field name="odometer_count" widget="statinfo" string="Odometer"/> </button> </div> - <field name="image_medium" widget='image' class="oe_avatar"/> + <field name="image_128" widget='image' class="oe_avatar"/> <div class="oe_title"> <label for="model_id" class="oe_edit_only"/> <h1> @@ -210,7 +210,6 @@ <field name="location" /> <field name="state_id" /> <field name="id" /> - <field name="image" /> <field name="tag_ids" /> <field name="contract_renewal_due_soon" /> <field name="contract_renewal_overdue" /> @@ -225,7 +224,7 @@ <t t-name="kanban-box"> <div class="oe_kanban_global_click"> <div class="o_kanban_image"> - <img t-att-src="kanban_image('fleet.vehicle', 'image_small', record.id.raw_value)" alt="Vehicle"/> + <img t-att-src="kanban_image('fleet.vehicle', 'image_128', record.id.raw_value)" alt="Vehicle"/> </div> <div class="oe_kanban_details"> <strong class="o_kanban_record_title"> @@ -279,7 +278,7 @@ <field name="id"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('fleet.vehicle', 'image_small', record.id.raw_value)" role="img" t-att-title="record.id.value" t-att-alt="record.id.value"/> + <img t-att-src="activity_image('fleet.vehicle', 'image_128', record.id.raw_value)" role="img" t-att-title="record.id.value" t-att-alt="record.id.value"/> <div> <field name="license_plate"/> : <field name="model_id"/> </div> diff --git a/addons/gamification/data/badge.xml b/addons/gamification/data/badge.xml index 06476e98066b0ecd2c6a631d7a10393d59f22fbe..696e3fabec709c5d64ffd5bda40502efb8b22b55 100644 --- a/addons/gamification/data/badge.xml +++ b/addons/gamification/data/badge.xml @@ -5,21 +5,21 @@ <field name="name">Good Job</field> <field name="description">You did great at your job.</field> <field name="rule_auth">everyone</field> - <field name="image" type="base64" file="gamification/static/img/badge_good_job-image.png"/> + <field name="image_1920" type="base64" file="gamification/static/img/badge_good_job-image.png"/> </record> <record id="badge_problem_solver" model="gamification.badge"> <field name="name">Problem Solver</field> <field name="description">No one can solve challenges like you do.</field> <field name="rule_auth">everyone</field> - <field name="image" type="base64" file="gamification/static/img/badge_problem_solver-image.png"/> + <field name="image_1920" type="base64" file="gamification/static/img/badge_problem_solver-image.png"/> </record> <record id="badge_hidden" model="gamification.badge"> <field name="name">Hidden</field> <field name="description">You have found the hidden badge</field> <field name="rule_auth">nobody</field> - <field name="image" type="base64" file="gamification/static/img/badge_hidden-image.png"/> + <field name="image_1920" type="base64" file="gamification/static/img/badge_hidden-image.png"/> <field name="active" eval="False" /> </record> @@ -29,7 +29,7 @@ <field name="rule_auth">everyone</field> <field name="rule_max">True</field> <field name="rule_max_number">2</field> - <field name="image" type="base64" file="gamification/static/img/badge_idea-image.png"/> + <field name="image_1920" type="base64" file="gamification/static/img/badge_idea-image.png"/> </record> <record id="email_template_badge_received" model="mail.template"> @@ -71,7 +71,7 @@ <table cellspacing="0" cellpadding="0" border="0" style="width: 560px; margin-top: 5px;"> <tbody><tr> <td valign="center"> - <img src="/web/image/gamification.badge/${object.badge_id.id}/image/80x80" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${user.company_id.name}"/> + <img src="/web/image/gamification.badge/${object.badge_id.id}/image_128/80x80" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${user.company_id.name}"/> </td> <td valign="center"> <cite>${object.badge_id.description}</cite> diff --git a/addons/gamification/data/gamification_karma_rank_data.xml b/addons/gamification/data/gamification_karma_rank_data.xml index 5eba07b1a3d75788e211eb888bf7f8ac88b2a30c..e0ef1320a4eedf356d475b64758d56860b17d4c8 100644 --- a/addons/gamification/data/gamification_karma_rank_data.xml +++ b/addons/gamification/data/gamification_karma_rank_data.xml @@ -19,7 +19,7 @@ </div> </field> <field name="karma_min">1</field> - <field name="image" type="base64" file="gamification/static/img/rank_newbie_badge.svg"/> + <field name="image_1920" type="base64" file="gamification/static/img/rank_newbie_badge.svg"/> </record> <record id="rank_student" model="gamification.karma.rank"> @@ -32,7 +32,7 @@ </div> </field> <field name="karma_min">100</field> - <field name="image" type="base64" file="gamification/static/img/rank_student_badge.svg"/> + <field name="image_1920" type="base64" file="gamification/static/img/rank_student_badge.svg"/> </record> <record id="rank_bachelor" model="gamification.karma.rank"> @@ -45,7 +45,7 @@ </div> </field> <field name="karma_min">500</field> - <field name="image" type="base64" file="gamification/static/img/rank_bachelor_badge.svg"/> + <field name="image_1920" type="base64" file="gamification/static/img/rank_bachelor_badge.svg"/> </record> <record id="rank_master" model="gamification.karma.rank"> @@ -58,7 +58,7 @@ </div> </field> <field name="karma_min">2000</field> - <field name="image" type="base64" file="gamification/static/img/rank_master_badge.svg"/> + <field name="image_1920" type="base64" file="gamification/static/img/rank_master_badge.svg"/> </record> <record id="rank_doctor" model="gamification.karma.rank"> @@ -71,6 +71,6 @@ </div> </field> <field name="karma_min">10000</field> - <field name="image" type="base64" file="gamification/static/img/rank_doctor_badge.svg"/> + <field name="image_1920" type="base64" file="gamification/static/img/rank_doctor_badge.svg"/> </record> </data></odoo> diff --git a/addons/gamification/data/goal_base.xml b/addons/gamification/data/goal_base.xml index bb43e81b8f29b894775f396baa3f24c1c7d45847..a09b588e237cccdf30e2793ad1f6ca9415da8d2b 100644 --- a/addons/gamification/data/goal_base.xml +++ b/addons/gamification/data/goal_base.xml @@ -145,7 +145,7 @@ Thank you, <div style="height:${heightA}px;"> ${extra_div | safe} <div style="height:55px;"> - <img style="margin-bottom:5px;width:50px;height:50px;border-radius:50%;" t-att-src="image_data_uri(object.env['res.users'].browse(goal['user_id']).partner_id.image_small)" alt="${goal['name']}"/> + <img style="margin-bottom:5px;width:50px;height:50px;border-radius:50%;" t-att-src="image_data_uri(object.env['res.users'].browse(goal['user_id']).partner_id.image_64)" alt="${goal['name']}"/> </div> <div align="center" style ="color:${bgColor};height:20px"> ${goal['name']} diff --git a/addons/gamification/models/badge.py b/addons/gamification/models/badge.py index fc93ffb80413ce91a840931082fe9484443ddd54..d1ea4c4cc9636bfb6d5b98b94d53c64161e28797 100644 --- a/addons/gamification/models/badge.py +++ b/addons/gamification/models/badge.py @@ -4,7 +4,7 @@ import logging from datetime import date -from odoo import api, tools, fields, models, _, exceptions +from odoo import api, fields, models, _, exceptions _logger = logging.getLogger(__name__) @@ -65,22 +65,11 @@ class GamificationBadge(models.Model): _name = 'gamification.badge' _description = 'Gamification Badge' - _inherit = ['mail.thread'] + _inherit = ['mail.thread', 'image.mixin'] name = fields.Char('Badge', required=True, translate=True) active = fields.Boolean('Active', default=True) description = fields.Text('Description', translate=True) - image = fields.Binary("Image", help="This field holds the image used for the badge.") - image_medium = fields.Binary( - "Medium-sized badge image", - help="Medium-sized image of the badge. 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 badge image", - help="Small-sized image of the badge. It is automatically " - "resized as a 64x64px image, with aspect ratio preserved. " - "Use this field anywhere a small image is required.") level = fields.Selection([ ('bronze', 'Bronze'), ('silver', 'Silver'), ('gold', 'Gold')], string='Forum Badge Level', default='bronze') @@ -137,16 +126,6 @@ class GamificationBadge(models.Model): "Remaining Sending Allowed", compute='_remaining_sending_calc', help="If a maximum is set") - @api.model_create_multi - def create(self, values_list): - for vals in values_list: - tools.image_resize_images(vals) - return super(GamificationBadge, self).create(values_list) - - def write(self, vals): - tools.image_resize_images(vals) - return super(GamificationBadge, self).write(vals) - @api.depends('owner_ids') def _get_owners_info(self): """Return: diff --git a/addons/gamification/models/gamification_karma_rank.py b/addons/gamification/models/gamification_karma_rank.py index f88712f3c44060ad011fba50522200c4e70ad294..65b0d8d21778c78acd573f9ecb7d3ef248df58d5 100644 --- a/addons/gamification/models/gamification_karma_rank.py +++ b/addons/gamification/models/gamification_karma_rank.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, tools, fields, models, exceptions, http +from odoo import api, fields, models, exceptions from odoo.tools.translate import html_translate @@ -24,6 +24,7 @@ class Http(models.AbstractModel): class KarmaRank(models.Model): _name = 'gamification.karma.rank' _description = 'Rank based on karma' + _inherit = 'image.mixin' _order = 'karma_min' name = fields.Text(string='Rank Name', translate=True, required=True) @@ -33,22 +34,9 @@ class KarmaRank(models.Model): help="Motivational phrase to reach this rank") karma_min = fields.Integer(string='Required Karma', help='Minimum karma needed to reach this rank') user_ids = fields.One2many('res.users', 'rank_id', string='Users', help="Users having this rank") - image = fields.Binary('Rank Icon') - image_medium = fields.Binary( - "Medium-sized rank icon", - help="Medium-sized icon of the rank. 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 rank icon", - help="Small-sized icon of the rank. It is automatically " - "resized as a 64x64px image, with aspect ratio preserved. " - "Use this field anywhere a small image is required.") @api.model_create_multi def create(self, values_list): - for vals in values_list: - tools.image_resize_images(vals) res = super(KarmaRank, self).create(values_list) users = self.env['res.users'].sudo().search([('karma', '>', 0)]) users._recompute_rank() @@ -60,7 +48,6 @@ class KarmaRank(models.Model): low = min(vals['karma_min'], self.karma_min) high = max(vals['karma_min'], self.karma_min) - tools.image_resize_images(vals) res = super(KarmaRank, self).write(vals) if 'karma_min' in vals: diff --git a/addons/gamification/views/badge.xml b/addons/gamification/views/badge.xml index 674f64208aa480e421292172adfd4d8945620c99..d0980d3e0b7abfa86e2eb27f0d18e6cb6d280fb9 100644 --- a/addons/gamification/views/badge.xml +++ b/addons/gamification/views/badge.xml @@ -40,7 +40,7 @@ <sheet> <widget name="web_ribbon" text="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/> <div class="oe_button_box" name="button_box"/> - <field name="image" widget='image' class="oe_avatar"/> + <field name="image_1920" widget="image" class="oe_avatar" options="{'preview_image': 'image_128'}"/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1> @@ -102,7 +102,6 @@ <field name="id"/> <field name="name"/> <field name="description"/> - <field name="image"/> <field name="stat_my"/> <field name="stat_count"/> <field name="stat_this_month"/> @@ -114,7 +113,7 @@ <t t-name="kanban-box"> <div t-attf-class="o_kanban_gamification oe_kanban_global_click #{record.stat_my.raw_value ? 'oe_kanban_color_5' : 'oe_kanban_color_white'}"> <div class="o_kanban_image"> - <img t-att-src="kanban_image('gamification.badge', 'image', record.id.raw_value)" t-att-title="record.name.value" t-att-alt="record.name.value"/> + <img t-att-src="kanban_image('gamification.badge', 'image_1024', record.id.raw_value)" t-att-title="record.name.value" t-att-alt="record.name.value"/> </div> <div class="oe_kanban_details"> <strong class="o_kanban_record_title"><field name="name"/></strong> @@ -135,7 +134,7 @@ <em><field name="description"/></em> <div> <t t-foreach="record.unique_owner_ids.raw_value.slice(0,11)" t-as="owner"> - <img width="24" height="24" class="oe_kanban_avatar" t-att-src="kanban_image('res.users', 'image_small', owner)" t-att-data-member_id="owner" alt="Owner"/> + <img width="24" height="24" class="oe_kanban_avatar" t-att-src="kanban_image('res.users', 'image_64', owner)" t-att-data-member_id="owner" alt="Owner"/> </t> </div> </div> @@ -168,7 +167,7 @@ <div class="oe_kanban_card oe_kanban_global_click oe_kanban_badge oe_kanban_color_white o_kanban_gamification"> <div class="o_kanban_content"> <div class="o_kanban_image"> - <a type="open"><img t-att-src="kanban_image('gamification.badge', 'image', record.badge_id.raw_value)" t-att-title="record.badge_name.value" t-att-alt="record.badge_name.value" /></a> + <a type="open"><img t-att-src="kanban_image('gamification.badge', 'image_1024', record.badge_id.raw_value)" t-att-title="record.badge_name.value" t-att-alt="record.badge_name.value" /></a> </div> <div class="oe_kanban_details"> <h4 class="mt0 mb0"> diff --git a/addons/gamification/views/challenge.xml b/addons/gamification/views/challenge.xml index a5f9f4fe2ee2bf1bc6cea833e3d80966e9b1ecf5..745a9b5204c4eadae1ab3be6283ea16f1b1be2fd 100644 --- a/addons/gamification/views/challenge.xml +++ b/addons/gamification/views/challenge.xml @@ -158,7 +158,7 @@ </div> </strong> <t t-foreach="record.user_ids.raw_value.slice(0,11)" t-as="member"> - <img class="o_kanban_badge_avatars" t-att-src="kanban_image('res.users', 'image_small', member)" t-att-data-member_id="member" alt="Member"/> + <img class="o_kanban_badge_avatars" t-att-src="kanban_image('res.users', 'image_64', member)" t-att-data-member_id="member" alt="Member"/> </t> </div> </div> diff --git a/addons/gamification/views/gamification_karma_rank_views.xml b/addons/gamification/views/gamification_karma_rank_views.xml index f728cff538e85de3d72e371fb3738b81bfd027b4..fc0205794b5d82d17a106071091935fb51168170 100644 --- a/addons/gamification/views/gamification_karma_rank_views.xml +++ b/addons/gamification/views/gamification_karma_rank_views.xml @@ -47,7 +47,7 @@ <form string="Rank"> <sheet> <div class="oe_button_box" name="button_box"/> - <field name="image" widget='image' class="oe_avatar"/> + <field name="image_1920" widget="image" class="oe_avatar" options="{'preview_image': 'image_128'}"/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1> diff --git a/addons/gamification/views/goal.xml b/addons/gamification/views/goal.xml index 9af36db1948988d5f8453b9065dc30162df2697e..f571e28a4ecacf9673bed114dc6db9d42b8199fb 100644 --- a/addons/gamification/views/goal.xml +++ b/addons/gamification/views/goal.xml @@ -150,7 +150,7 @@ <div class="o_kanban_content"> <p><strong><h4 class="oe_goal_name text-center" tooltip="kanban-tooltip"><field name="definition_id" /></h4></strong></p> <div class="float-left"> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" /> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" /> </div> <field name="user_id" /> <div class="o_goal_state_block"> diff --git a/addons/gamification/views/mail_templates.xml b/addons/gamification/views/mail_templates.xml index fda8a66f9a4efc8779092c4c056514e01c7d8a93..4f589833bf16c58c29d8dac25732f53016999b48 100644 --- a/addons/gamification/views/mail_templates.xml +++ b/addons/gamification/views/mail_templates.xml @@ -32,7 +32,7 @@ </td> <td style="padding:15px 20px 10px 20px;"> <p style="text-align: center;"> - <img src="/web/image/gamification.karma.rank/${object.rank_id.id}/image_medium"/> + <img src="/web/image/gamification.karma.rank/${object.rank_id.id}/image_128"/> </p> </td> </tr> diff --git a/addons/google_calendar/static/tests/google_calendar_tests.js b/addons/google_calendar/static/tests/google_calendar_tests.js index 76aaa65411b2042819569d84c8e6c10a3331c2c9..0470d95d730027abfd147bdc510ac4d0c31e2263 100644 --- a/addons/google_calendar/static/tests/google_calendar_tests.js +++ b/addons/google_calendar/static/tests/google_calendar_tests.js @@ -39,7 +39,7 @@ QUnit.module('Google Calendar', { id: {string: "ID", type: "integer"}, display_name: {string: "Displayed name", type: "char"}, partner_id: {string: "partner", type: "many2one", relation: 'partner'}, - image: {string: "image", type: "integer"}, + image_1920: {string: "image", type: "integer"}, }, records: [ {id: 4, display_name: "user 4", partner_id: 4}, @@ -49,10 +49,10 @@ QUnit.module('Google Calendar', { fields: { id: {string: "ID", type: "integer"}, display_name: {string: "Displayed name", type: "char"}, - image: {string: "image", type: "integer"}, + image_1920: {string: "image", type: "integer"}, }, records: [ - {id: 4, display_name: "partner 4", image: 'DDD'} + {id: 4, display_name: "partner 4", image_1920: 'DDD'} ] }, filter_partner: { diff --git a/addons/hr/data/hr_data.xml b/addons/hr/data/hr_data.xml index 8c70cef3e68f82958e85fe163cf80077284eef79..41e343de6d4e43275ee99e41316774c19d1f9343 100644 --- a/addons/hr/data/hr_data.xml +++ b/addons/hr/data/hr_data.xml @@ -15,7 +15,7 @@ <field name="user_id" ref="base.user_admin"/> <field name="address_id" ref="base.partner_admin"/> <field name="address_home_id" ref="base.partner_admin"/> - <field name="image" eval="obj(ref('base.partner_admin')).image" model="res.partner"/> + <field name="image_1920" eval="obj(ref('base.partner_admin')).image_1920" model="res.partner"/> </record> <record id="onboarding_setup_it_materials" model="hr.plan.activity.type"> diff --git a/addons/hr/data/hr_demo.xml b/addons/hr/data/hr_demo.xml index a713638b1fa7481066ab1d902c4d8867b04d87ab..b6f039b140c9a4b08ea41f7aa85998aa776ed9fa 100644 --- a/addons/hr/data/hr_demo.xml +++ b/addons/hr/data/hr_demo.xml @@ -154,7 +154,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(376)-310-7863</field> <field name="work_email">ronnie.hart87@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_al-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_al-image.jpg"/> </record> <record id="employee_mit" model="hr.employee"> @@ -168,7 +168,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_phone">(538)-497-4804</field> <field name="mobile_phone">(538)-672-3185</field> <field name="work_email">anita.oliver32@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_mit-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_mit-image.jpg"/> </record> <record id="employee_niv" model="hr.employee"> @@ -181,7 +181,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(450)-719-4182</field> <field name="work_email">sharlene.rhodes49@example.comcom</field> - <field name="image" type="base64" file="hr/static/img/employee_niv-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_niv-image.jpg"/> </record> <record id="employee_stw" model="hr.employee"> @@ -194,7 +194,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(332)-775-6660</field> <field name="work_email">randall.lewis74@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_stw-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_stw-image.jpg"/> </record> <record id="employee_chs" model="hr.employee"> @@ -207,7 +207,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(157)-363-8229</field> <field name="work_email">jennie.fletcher76@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_chs-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_chs-image.jpg"/> </record> <record id="employee_qdp" model="hr.employee"> @@ -221,7 +221,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">+3281813700</field> <field name="work_email">gilles@odoo.com</field> - <field name="image" type="base64" file="hr/static/img/employee_qdp-image.png"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_qdp-image.png"/> </record> <record id="employee_fme" model="hr.employee"> @@ -234,7 +234,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(449)-505-5146</field> <field name="work_email">keith.byrd52@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_fme-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_fme-image.jpg"/> </record> <record id="employee_fpi" model="hr.employee"> @@ -247,7 +247,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(203)-276-7903</field> <field name="work_email">audrey.peterson25@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_fpi-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_fpi-image.jpg"/> </record> <record id="employee_jth" model="hr.employee"> @@ -260,7 +260,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(663)-707-8451</field> <field name="work_email">toni.jimenez23@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_jth-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_jth-image.jpg"/> </record> <record id="employee_ngh" model="hr.employee"> @@ -273,7 +273,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(916)-264-7362</field> <field name="work_email">jeffrey.kelly72@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_ngh-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_ngh-image.jpg"/> </record> <record id="employee_vad" model="hr.employee"> @@ -286,7 +286,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(360)-694-7266</field> <field name="work_email">tina.williamson98@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_vad-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_vad-image.jpg"/> </record> <record id="employee_han" model="hr.employee"> @@ -297,7 +297,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(350)-912-1201</field> <field name="work_email">walter.horton80@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_han-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_han-image.jpg"/> </record> <record id="employee_jve" model="hr.employee"> @@ -308,7 +308,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(114)-262-1607</field> <field name="work_email">paul.williams59@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_jve-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_jve-image.jpg"/> </record> <record id="employee_jep" model="hr.employee"> @@ -319,7 +319,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(883)-331-5378</field> <field name="work_email">doris.cole31@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_jep-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_jep-image.jpg"/> </record> <record id="employee_jod" model="hr.employee"> @@ -330,7 +330,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(206)-267-3735</field> <field name="work_email">jod@odoo.com</field> - <field name="image" type="base64" file="hr/static/img/employee_jod-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_jod-image.jpg"/> </record> <record id="employee_jog" model="hr.employee"> @@ -341,7 +341,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(754)-532-3841</field> <field name="work_email">beth.evans77@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_jog-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_jog-image.jpg"/> </record> <record id="employee_jgo" model="hr.employee"> @@ -352,7 +352,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(944)-518-8232</field> <field name="work_email">ernest.reed47@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_jgo-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_jgo-image.jpg"/> </record> <record id="employee_lur" model="hr.employee"> @@ -363,7 +363,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">(644)-169-1352</field> <field name="work_email">eli.lambert22@example.com</field> - <field name="image" type="base64" file="hr/static/img/employee_lur-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_lur-image.jpg"/> </record> <record id="employee_hne" model="hr.employee"> @@ -374,7 +374,7 @@ If you have development competencies, we can propose you specific traineeships</ <field name="work_location">Building 1, Second Floor</field> <field name="work_email">abigail.peterson39@example.com</field> <field name="work_phone">(482)-233-3393</field> - <field name="image" type="base64" file="hr/static/img/employee_hne-image.jpg"/> + <field name="image_1920" type="base64" file="hr/static/img/employee_hne-image.jpg"/> </record> </data> </odoo> diff --git a/addons/hr/models/hr_employee.py b/addons/hr/models/hr_employee.py index a9252dac8605fc7abdd0a44c4c9b0c59c7869b33..6f28b32b610afb1775fc4cfeb16ee541e9b275d6 100644 --- a/addons/hr/models/hr_employee.py +++ b/addons/hr/models/hr_employee.py @@ -8,7 +8,7 @@ import itertools from werkzeug import url_encode import pytz -from odoo import api, fields, models, tools, _ +from odoo import api, fields, models, _ from odoo.exceptions import ValidationError, AccessError from odoo.modules.module import get_module_resource from odoo.addons.resource.models.resource_mixin import timezone_datetime @@ -25,13 +25,13 @@ class HrEmployeePrivate(models.Model): _name = "hr.employee" _description = "Employee" _order = 'name' - _inherit = ['hr.employee.base', 'mail.thread', 'mail.activity.mixin', 'resource.mixin'] + _inherit = ['hr.employee.base', 'mail.thread', 'mail.activity.mixin', 'resource.mixin', 'image.mixin'] _mail_post_access = 'read' @api.model def _default_image(self): image_path = get_module_resource('hr', 'static/src/img', 'default_image.png') - return tools.image_process(base64.b64encode(open(image_path, 'rb').read()), size=tools.IMAGE_BIG_SIZE) + return base64.b64encode(open(image_path, 'rb').read()) # resource and user # required on the resource, make sure required="True" set in the view @@ -93,13 +93,7 @@ class HrEmployeePrivate(models.Model): emergency_phone = fields.Char("Emergency Phone", groups="hr.group_hr_user", tracking=True) km_home_work = fields.Integer(string="Km Home-Work", groups="hr.group_hr_user", tracking=True) - # image: all image fields are base64 encoded and PIL-supported - image = fields.Binary( - "Photo", default=_default_image) - image_medium = fields.Binary( - "Medium-sized photo") - image_small = fields.Binary( - "Small-sized photo") + image_1920 = fields.Image(default=_default_image) phone = fields.Char(related='address_home_id.phone', related_sudo=False, string="Private Phone", groups="hr.group_hr_user") # employee in company parent_id = fields.Many2one('hr.employee', 'Manager') @@ -232,7 +226,7 @@ class HrEmployeePrivate(models.Model): def _sync_user(self, user): vals = dict( - image=user.image, + image_1920=user.image_1920, work_email=user.email, ) if user.tz: @@ -245,7 +239,6 @@ class HrEmployeePrivate(models.Model): user = self.env['res.users'].browse(vals['user_id']) vals.update(self._sync_user(user)) vals['name'] = vals.get('name', user.name) - tools.image_resize_images(vals) employee = super(HrEmployeePrivate, self).create(vals) url = '/web#%s' % url_encode({'action': 'hr.plan_wizard_action', 'active_id': employee.id, 'active_model': 'hr.employee'}) employee._message_log(body=_('<b>Congratulations !</b> May I recommand you to setup an <a href="%s">onboarding plan ?</a>') % (url)) @@ -262,7 +255,6 @@ class HrEmployeePrivate(models.Model): self.env['res.partner.bank'].browse(account_id).partner_id = vals['address_home_id'] if vals.get('user_id'): vals.update(self._sync_user(self.env['res.users'].browse(vals['user_id']))) - tools.image_resize_images(vals) res = super(HrEmployeePrivate, self).write(vals) if vals.get('department_id') or vals.get('user_id'): department_id = vals['department_id'] if vals.get('department_id') else self[:1].department_id.id diff --git a/addons/hr/models/hr_employee_public.py b/addons/hr/models/hr_employee_public.py index 8a80a23c9398a6253691889be5eb9ef6979bef48..62c221ee472fd5324eef4655be8fb9e899537744 100644 --- a/addons/hr/models/hr_employee_public.py +++ b/addons/hr/models/hr_employee_public.py @@ -32,9 +32,12 @@ class HrEmployeePublic(models.Model): # hr.employee.public specific fields child_ids = fields.One2many('hr.employee.public', 'parent_id', string='Direct subordinates', readonly=True) - image = fields.Binary("Photo", compute='_compute_image', readonly=True, compute_sudo=True) - image_medium = fields.Binary("Medium-sized photo", compute='_compute_image', readonly=True, compute_sudo=True) - image_small = fields.Binary("Small-sized photo", compute='_compute_image', readonly=True, compute_sudo=True) + image_1920 = fields.Image("Original Image", compute='_compute_image', compute_sudo=True) + image_1024 = fields.Image("Image 1024", compute='_compute_image', compute_sudo=True) + image_512 = fields.Image("Image 512", compute='_compute_image', compute_sudo=True) + image_256 = fields.Image("Image 256", compute='_compute_image', compute_sudo=True) + image_128 = fields.Image("Image 128", compute='_compute_image', compute_sudo=True) + image_64 = fields.Image("Image 64", compute='_compute_image', compute_sudo=True) parent_id = fields.Many2one('hr.employee.public', 'Manager', readonly=True) coach_id = fields.Many2one('hr.employee.public', 'Coach', readonly=True) @@ -42,9 +45,12 @@ class HrEmployeePublic(models.Model): for employee in self: # We have to be in sudo to have access to the images employee_id = self.sudo().env['hr.employee'].browse(employee.id) - employee.image = employee_id.image - employee.image_medium = employee_id.image_medium - employee.image_small = employee_id.image_small + employee.image_1920 = employee_id.image_1920 + employee.image_1024 = employee_id.image_1024 + employee.image_512 = employee_id.image_512 + employee.image_256 = employee_id.image_256 + employee.image_128 = employee_id.image_128 + employee.image_64 = employee_id.image_64 @api.model def _get_fields(self): diff --git a/addons/hr/models/res_users.py b/addons/hr/models/res_users.py index d863c41fd64a761e7792616551b94da1f9621275..6b9832bcbecea42f66e50e632e9ef7b3dad35e18 100644 --- a/addons/hr/models/res_users.py +++ b/addons/hr/models/res_users.py @@ -157,7 +157,7 @@ class User(models.Model): result = super(User, self).write(vals) employee_values = {} - for fname in [f for f in ['name', 'email', 'image', 'tz'] if f in vals]: + for fname in [f for f in ['name', 'email', 'image_1920', 'tz'] if f in vals]: employee_values[fname] = vals[fname] if employee_values: if 'email' in employee_values: diff --git a/addons/hr/report/hr_employee_badge.xml b/addons/hr/report/hr_employee_badge.xml index 1a5e8fdc6454b05c79ac51bcf810153124fa90dd..f186914ba3d1f823727dcde88c32f6d4f15e9476 100644 --- a/addons/hr/report/hr_employee_badge.xml +++ b/addons/hr/report/hr_employee_badge.xml @@ -25,7 +25,7 @@ </tr> <tr style="height:70%;"> <td align="center" valign="center"> - <img t-if="employee.image" t-att-src="image_data_uri(employee.image)" style="max-height:85pt;max-width:90%" alt="Employee Image"/> + <img t-if="employee.image_1920" t-att-src="image_data_uri(employee.image_1920)" style="max-height:85pt;max-width:90%" alt="Employee Image"/> </td> </tr> </table> diff --git a/addons/hr/views/hr_employee_public_views.xml b/addons/hr/views/hr_employee_public_views.xml index 0c8ddecb6b9e32abe823357a0f52c51f62cc591c..d6177dae4138e05bd63b7de8d059c8e9ae2dae1b 100644 --- a/addons/hr/views/hr_employee_public_views.xml +++ b/addons/hr/views/hr_employee_public_views.xml @@ -36,7 +36,7 @@ <div class="oe_button_box" name="button_box"> <!-- Used by other modules--> </div> - <field name="image" widget='image' class="oe_avatar" options='{"zoom": true, "preview_image":"image_medium"}'/> + <field name="image_1920" widget='image' class="oe_avatar" options='{"zoom": true, "preview_image":"image_128"}'/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1> @@ -112,9 +112,9 @@ <t t-name="kanban-box"> <div class="oe_kanban_global_click o_kanban_record_has_image_fill o_hr_kanban_record"> <!-- Medium employee's picture --> - <field name="image" widget="image" class="o_kanban_image_fill_left d-none d-md-block" options="{'zoom': true, 'background': true, 'preventClicks': false}"/> + <field name="image_128" widget="image" class="o_kanban_image_fill_left d-none d-md-block" options="{'zoom': true, 'background': true, 'preventClicks': false}"/> <!-- Employee's picture optimized for mobile --> - <field name="image_small" widget="image" class="o_kanban_image d-md-none rounded-circle" options="{'zoom': true, 'background': true, 'preventClicks': false}"/> + <field name="image_64" widget="image" class="o_kanban_image d-md-none rounded-circle" options="{'zoom': true, 'background': true, 'preventClicks': false}"/> <div class="oe_kanban_details"> <div class="o_kanban_record_top"> diff --git a/addons/hr/views/hr_employee_views.xml b/addons/hr/views/hr_employee_views.xml index 71df38b5d6ed1a30693c57a68886bf0f213f6b2e..434afc2ec6fa0fc860b9c71dbcdeb6b7e4e5b55f 100644 --- a/addons/hr/views/hr_employee_views.xml +++ b/addons/hr/views/hr_employee_views.xml @@ -74,7 +74,7 @@ </div> </button> </div> - <field name="image" widget='image' class="oe_avatar" options='{"zoom": true, "preview_image":"image_medium"}'/> + <field name="image_1920" widget='image' class="oe_avatar" options='{"zoom": true, "preview_image":"image_128"}'/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1> @@ -227,9 +227,9 @@ <t t-name="kanban-box"> <div class="oe_kanban_global_click o_kanban_record_has_image_fill o_hr_kanban_record"> <!-- Medium employee's picture --> - <field name="image" widget="image" class="o_kanban_image_fill_left d-none d-md-block" options="{'zoom': true, 'background': true, 'preventClicks': false}"/> + <field name="image_128" widget="image" class="o_kanban_image_fill_left d-none d-md-block" options="{'zoom': true, 'background': true, 'preventClicks': false}"/> <!-- Employee's picture optimized for mobile --> - <field name="image_small" widget="image" class="o_kanban_image d-md-none rounded-circle" options="{'zoom': true, 'background': true, 'preventClicks': false}"/> + <field name="image_64" widget="image" class="o_kanban_image d-md-none rounded-circle" options="{'zoom': true, 'background': true, 'preventClicks': false}"/> <div class="oe_kanban_details"> <div class="o_kanban_record_top"> @@ -271,7 +271,7 @@ <field name="id"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('hr.employee', 'image_small', record.id.raw_value)" role="img" t-att-title="record.id.value" t-att-alt="record.id.value"/> + <img t-att-src="activity_image('hr.employee', 'image_64', record.id.raw_value)" role="img" t-att-title="record.id.value" t-att-alt="record.id.value"/> <div> <field name="name" display="full"/> <field name="job_id" muted="1" display="full"/> diff --git a/addons/hr/views/res_users.xml b/addons/hr/views/res_users.xml index f6259a0e650eb13a6d20436b3edf162226a280a3..1f618fb776a336f0b6811131e69c28ba7a04a3e0 100644 --- a/addons/hr/views/res_users.xml +++ b/addons/hr/views/res_users.xml @@ -14,7 +14,7 @@ <field name="arch" type="xml"> <footer position="replace"/> <h1 position="replace"/> - <xpath expr="//field[@name='image']" position="replace"/> + <xpath expr="//field[@name='image_1920']" position="replace"/> <xpath expr="//field[@name='email']" position="attributes"> <attribute name="invisible">1</attribute> </xpath> @@ -75,7 +75,7 @@ </div> </button> </div> - <field name="image" widget='image' class="oe_avatar" options='{"zoom": true, "preview_image":"image_medium"}'/> + <field name="image_1920" widget='image' class="oe_avatar" options='{"zoom": true, "preview_image":"image_128"}'/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1> diff --git a/addons/hr_attendance/static/src/xml/attendance.xml b/addons/hr_attendance/static/src/xml/attendance.xml index f38dd7cfa7cb819fb1328cf251a3f451caf4a418..f0be4eddb6c34cd26bbacec08a4ecbf773ca0ef6 100644 --- a/addons/hr_attendance/static/src/xml/attendance.xml +++ b/addons/hr_attendance/static/src/xml/attendance.xml @@ -38,7 +38,7 @@ <t t-set="checked_in" t-value="widget.employee.attendance_state=='checked_in'"/> <t t-if="widget.employee"> <div class="o_hr_attendance_user_badge o_home_menu_background"> - <img class="img rounded-circle" t-attf-src="/web/image?model=hr.employee&field=image_medium&id=#{widget.employee.id}" t-att-title="widget.employee.name" t-att-alt="widget.employee.name"/> + <img class="img rounded-circle" t-attf-src="/web/image?model=hr.employee&field=image_128&id=#{widget.employee.id}" t-att-title="widget.employee.name" t-att-alt="widget.employee.name"/> </div> <h1 class="mb8"><t t-esc="widget.employee.name"/></h1> <h3 class="mt8 mb24"><t t-if="!checked_in">Welcome!</t><t t-else="">Want to check out?</t></h3> @@ -66,7 +66,7 @@ </div> <t t-if="widget.employee_id"> <div class="o_hr_attendance_user_badge o_home_menu_background"> - <img class="img rounded-circle" t-attf-src="/web/image?model=hr.employee&field=image_medium&id=#{widget.employee_id}" t-att-title="widget.employee_name" t-att-alt="widget.employee_name"/> + <img class="img rounded-circle" t-attf-src="/web/image?model=hr.employee&field=image_128&id=#{widget.employee_id}" t-att-title="widget.employee_name" t-att-alt="widget.employee_name"/> </div> <h1 class="mb8"><t t-esc="widget.employee_name"/></h1> <h3 class="mt8 mb24"><t t-if="!checked_in">Welcome!</t><t t-else="">Want to check out?</t></h3> @@ -109,7 +109,7 @@ <div class="o_hr_attendance_kiosk_mode"> <t t-if="widget.attendance"> <div class="o_hr_attendance_user_badge o_home_menu_background"> - <img class="img rounded-circle" t-attf-src="/web/image?model=hr.employee&field=image_medium&id=#{widget.attendance.employee_id[0]}" t-att-title="widget.employee_name" t-att-alt="widget.employee_name"/> + <img class="img rounded-circle" t-attf-src="/web/image?model=hr.employee&field=image_128&id=#{widget.attendance.employee_id[0]}" t-att-title="widget.employee_name" t-att-alt="widget.employee_name"/> </div> <t t-if="widget.attendance.check_out"> <h1 class="mb0">Goodbye <t t-esc="widget.employee_name"/>!</h1> diff --git a/addons/hr_attendance/views/hr_attendance_view.xml b/addons/hr_attendance/views/hr_attendance_view.xml index 9f12d4d6487a4d5d7f14edb066eaa0e221205865..bd416202f2f2ceff922a6ca43de4c06e4663b83c 100644 --- a/addons/hr_attendance/views/hr_attendance_view.xml +++ b/addons/hr_attendance/views/hr_attendance_view.xml @@ -27,7 +27,7 @@ <t t-name="kanban-box"> <div t-attf-class="oe_kanban_global_click"> <div> - <img t-att-src="kanban_image('hr.employee', 'image_small', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="24" height="24" class="oe_kanban_avatar mr4"/> + <img t-att-src="kanban_image('hr.employee', 'image_64', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="24" height="24" class="oe_kanban_avatar mr4"/> <span class="o_kanban_record_title"> <strong><t t-esc="record.employee_id.value"/></strong> </span> diff --git a/addons/hr_attendance/views/hr_employee_view.xml b/addons/hr_attendance/views/hr_employee_view.xml index c13e8848b61d07243816609ea51ff6a39906ba2f..ac2abad8010f89e705203725d9d7a9654e9b9a0d 100644 --- a/addons/hr_attendance/views/hr_employee_view.xml +++ b/addons/hr_attendance/views/hr_employee_view.xml @@ -137,7 +137,7 @@ <t t-name="kanban-box"> <div class="oe_kanban_global_click"> <div class="o_kanban_image"> - <img t-att-src="kanban_image('hr.employee', 'image_medium', record.id.raw_value)" alt="Employee"/> + <img t-att-src="kanban_image('hr.employee', 'image_128', record.id.raw_value)" alt="Employee"/> </div> <div class="oe_kanban_details"> <div id="textbox"> diff --git a/addons/hr_contract/views/hr_contract_views.xml b/addons/hr_contract/views/hr_contract_views.xml index 920501167ce69cd5af12e698d9e6a479d2e7b3c4..467b856f6f0801f2f0960fcc624b7f96b5aca91e 100644 --- a/addons/hr_contract/views/hr_contract_views.xml +++ b/addons/hr_contract/views/hr_contract_views.xml @@ -261,7 +261,7 @@ <field name="job_id"/> </div> <div class="oe_kanban_bottom_right"> - <img t-att-src="kanban_image('hr.employee', 'image_medium', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> + <img t-att-src="kanban_image('hr.employee', 'image_128', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> </div> </div> <div class="oe_clear"></div> @@ -280,7 +280,7 @@ <field name="employee_id"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('hr.employee', 'image_medium', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value"/> + <img t-att-src="activity_image('hr.employee', 'image_128', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value"/> <div> <field name="name" display="full"/> <field name="job_id" muted="1" display="full"/> diff --git a/addons/hr_expense/data/hr_expense_demo.xml b/addons/hr_expense/data/hr_expense_demo.xml index 57ec21bda800607cbfddfa9b0a9f2a6f9bb2b85a..a933f86d43eb55317f6c5b587ea8fa1523d98f6c 100644 --- a/addons/hr_expense/data/hr_expense_demo.xml +++ b/addons/hr_expense/data/hr_expense_demo.xml @@ -50,7 +50,7 @@ <field name="uom_po_id" ref="uom.product_uom_km"/> <field name="categ_id" ref="product.cat_expense"/> <field name="can_be_expensed" eval="True" /> - <field name="image" type="base64" file="hr_expense/static/img/car_travel-image.jpg"/> + <field name="image_1920" type="base64" file="hr_expense/static/img/car_travel-image.jpg"/> </record> <record id="air_ticket" model="product.product"> @@ -61,7 +61,7 @@ <field name="default_code">EXP_AF</field> <field name="categ_id" ref="product.cat_expense"/> <field name="can_be_expensed" eval="True" /> - <field name="image" type="base64" file="hr_expense/static/img/air_ticket-image.jpg"/> + <field name="image_1920" type="base64" file="hr_expense/static/img/air_ticket-image.jpg"/> </record> <record id="product.expense_hotel" model="product.product"> diff --git a/addons/hr_expense/views/hr_expense_views.xml b/addons/hr_expense/views/hr_expense_views.xml index 98f99b605e51afae1939d2c4f2ecdbd402fcd5ab..0afbe3be4db2c6513e9a5aed06921d7413fb0d48 100644 --- a/addons/hr_expense/views/hr_expense_views.xml +++ b/addons/hr_expense/views/hr_expense_views.xml @@ -251,7 +251,7 @@ <field name="currency_id"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('hr.employee', 'image_small', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value"/> + <img t-att-src="activity_image('hr.employee', 'image_64', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value"/> <div> <field name="name" display="full"/> <field name="total_amount" widget="monetary" muted="1" display="full"/> @@ -310,7 +310,7 @@ <widget name="web_ribbon" text="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/> <field name='product_variant_count' invisible='1'/> <field name="id" invisible="True"/> - <field name="image_medium" widget="image" class="oe_avatar"/> + <field name="image_1920" widget="image" class="oe_avatar" options="{'image_preview': 'image_128'}"/> <div class="oe_title"> <label class="oe_edit_only" for="name" string="Product Name"/> <h1><field name="name" placeholder="e.g. Lunch"/></h1> @@ -662,7 +662,7 @@ <field name="currency_id"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('hr.employee', 'image_small', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value"/> + <img t-att-src="activity_image('hr.employee', 'image_64', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value"/> <div> <field name="name" display="full"/> <field name="total_amount" widget="monetary" muted="1" display="full"/> diff --git a/addons/hr_holidays/report/hr_leave_reports.xml b/addons/hr_holidays/report/hr_leave_reports.xml index 69bb21a0f9ab2c5f0d1ebf294369a0cab8f1a9d7..20bc19d8451b1a5dc2066ad5be1960499f18f683 100644 --- a/addons/hr_holidays/report/hr_leave_reports.xml +++ b/addons/hr_holidays/report/hr_leave_reports.xml @@ -71,7 +71,7 @@ <div t-attf-class="oe_kanban_global_click"> <div> <span> - <img t-att-src="kanban_image('hr.employee', 'image_small', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="40" height="40" class="oe_kanban_avatar float-left mr4"/> + <img t-att-src="kanban_image('hr.employee', 'image_64', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="40" height="40" class="oe_kanban_avatar float-left mr4"/> </span> <span> <div> diff --git a/addons/hr_holidays/views/hr_leave_allocation_views.xml b/addons/hr_holidays/views/hr_leave_allocation_views.xml index c48b31c79707de6c2e81a979b4cfa507c1b3ff86..9bf45b801a0dd6734c38f6705d39336e2ed93ace 100644 --- a/addons/hr_holidays/views/hr_leave_allocation_views.xml +++ b/addons/hr_holidays/views/hr_leave_allocation_views.xml @@ -253,7 +253,7 @@ <div class="oe_kanban_global_click container"> <div class="row no-gutters"> <div class="col-2"> - <img t-att-src="kanban_image('hr.employee', 'image_small', record.employee_id.raw_value)" + <img t-att-src="kanban_image('hr.employee', 'image_64', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="40" height="40" @@ -306,7 +306,7 @@ <field name="employee_id"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('hr.employee', 'image_small', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value"/> + <img t-att-src="activity_image('hr.employee', 'image_64', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value"/> <div> <field name="employee_id"/> <span class="ml-3 text-muted"> diff --git a/addons/hr_holidays/views/hr_leave_views.xml b/addons/hr_holidays/views/hr_leave_views.xml index fa3c2e5c85bc1294da8bdcb072e2b6946c0eaf75..8dcc4dc63f4eae9b3411e55c4df0e2356d7442f2 100644 --- a/addons/hr_holidays/views/hr_leave_views.xml +++ b/addons/hr_holidays/views/hr_leave_views.xml @@ -113,7 +113,7 @@ <div class="oe_kanban_global_click container"> <div class="row no-gutters"> <div class="col-2"> - <img t-att-src="kanban_image('hr.employee', 'image_small', record.employee_id.raw_value)" + <img t-att-src="kanban_image('hr.employee', 'image_64', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="40" height="40" @@ -178,7 +178,7 @@ <field name="number_of_days"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('hr.employee', 'image_small', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="50" height="50"/> + <img t-att-src="activity_image('hr.employee', 'image_64', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="50" height="50"/> <div> <field name="name"/> <span class="ml-3 text-muted"> diff --git a/addons/hr_maintenance/views/maintenance_views.xml b/addons/hr_maintenance/views/maintenance_views.xml index 0ede973b40820c7a158870db88bd6a94caef48af..97be6402b9139c5482fbe35ac95fbfc123650647 100644 --- a/addons/hr_maintenance/views/maintenance_views.xml +++ b/addons/hr_maintenance/views/maintenance_views.xml @@ -99,7 +99,7 @@ <field name="department_id"/> </xpath> <xpath expr="//img[@t-att-title='record.owner_user_id.value']" position='replace'> - <img t-att-src="kanban_image('hr.employee', 'image_small', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="27" height="27" class="oe_kanban_avatar"/> + <img t-att-src="kanban_image('hr.employee', 'image_64', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="27" height="27" class="oe_kanban_avatar"/> </xpath> <div t-if="record.serial_no.raw_value" position='after'> <div t-if="!record.employee_id.raw_value">Unassigned</div> diff --git a/addons/hr_org_chart/static/src/xml/hr_org_chart.xml b/addons/hr_org_chart/static/src/xml/hr_org_chart.xml index 119aec4fa15f85b96c1f9cb09b2fb966c99359ae..8c5160fc59ca3b8f0f0076d6a537ec63625a107f 100644 --- a/addons/hr_org_chart/static/src/xml/hr_org_chart.xml +++ b/addons/hr_org_chart/static/src/xml/hr_org_chart.xml @@ -10,13 +10,13 @@ use bg-images to get a clean and centred images --> <a t-if="! is_self" class="o_media_object rounded-circle o_employee_redirect" - t-att-style="'background-image:url(\'/web/image/hr.employee.public/' + employee.id + '/image/\')'" + t-att-style="'background-image:url(\'/web/image/hr.employee.public/' + employee.id + '/image_1024/\')'" t-att-alt="employee.name" t-att-data-employee-id="employee.id" t-att-href="employee.link"/> <div t-if="is_self" class="o_media_object rounded-circle" - t-att-style="'background-image:url(\'/web/image/hr.employee.public/' + employee.id + '/image/\')'"/> + t-att-style="'background-image:url(\'/web/image/hr.employee.public/' + employee.id + '/image_1024/\')'"/> </div> <div class="media-body"> @@ -151,7 +151,7 @@ <t t-name="hr_orgchart_emp_popover_title"> <div> - <span t-att-style='"background-image:url(\"/web/image/hr.employee.public/" + employee.id + "/image/\")"'/> + <span t-att-style='"background-image:url(\"/web/image/hr.employee.public/" + employee.id + "/image_1024/\")"'/> <a href="#" class="float-right o_employee_redirect" t-att-data-employee-id="employee.id"><i class="fa fa-external-link" role="img" aria-label='Redirect' title="Redirect"></i></a> <b><t t-esc="employee.name"/></b> </div> diff --git a/addons/hr_recruitment/data/hr_recruitment_data.xml b/addons/hr_recruitment/data/hr_recruitment_data.xml index c0ddf96d334c6c04ff4fdd8bfa6f3f9edbcfc05c..b4be4c7da54cdb40a61c300e7272122cd1f753db 100644 --- a/addons/hr_recruitment/data/hr_recruitment_data.xml +++ b/addons/hr_recruitment/data/hr_recruitment_data.xml @@ -95,7 +95,7 @@ <table> <tr> <td width="75"> - <img src="/web/image/res.users/${object.user_id.id}/image_small" alt="Avatar" style="vertical-align:baseline;max-width:64px;" /> + <img src="/web/image/res.users/${object.user_id.id}/image_64" alt="Avatar" style="vertical-align:baseline;max-width:64px;" /> </td> <td> <strong>${object.user_id.name}</strong><br/> @@ -203,7 +203,7 @@ <table> <tr> <td width="75"> - <img src="/web/image/res.users/${object.user_id.id}/image_small" alt="Avatar" style="vertical-align:baseline;max-width:64px;" /> + <img src="/web/image/res.users/${object.user_id.id}/image_64" alt="Avatar" style="vertical-align:baseline;max-width:64px;" /> </td> <td> <strong>${object.user_id.name}</strong><br/> diff --git a/addons/hr_recruitment/views/hr_recruitment_views.xml b/addons/hr_recruitment/views/hr_recruitment_views.xml index 3b49ef198b7d00d6d1d2207d2aa66e34f034c195..2cc46130e01a27cbd6dbf1c89d3418cdde4fa5ea 100644 --- a/addons/hr_recruitment/views/hr_recruitment_views.xml +++ b/addons/hr_recruitment/views/hr_recruitment_views.xml @@ -339,7 +339,7 @@ <field name="legend_blocked" invisible="1"/> <field name="legend_done" invisible="1"/> </div> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="30" height="30" class="oe_kanban_avatar"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="30" height="30" class="oe_kanban_avatar"/> </div> </div> diff --git a/addons/hr_timesheet/views/hr_timesheet_views.xml b/addons/hr_timesheet/views/hr_timesheet_views.xml index 9aef1401601fb5407c34de2c04584dbad32e9a1d..131a8dbe5659405bec3f5b57d061df3769f360d5 100644 --- a/addons/hr_timesheet/views/hr_timesheet_views.xml +++ b/addons/hr_timesheet/views/hr_timesheet_views.xml @@ -148,7 +148,7 @@ <div t-attf-class="oe_kanban_global_click"> <div class="row"> <div class="col-2"> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="40" height="40" class="oe_kanban_avatar float-left"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="40" height="40" class="oe_kanban_avatar float-left"/> </div> <div class="col-10"> <div> diff --git a/addons/hr_work_entry/views/hr_work_entry_views.xml b/addons/hr_work_entry/views/hr_work_entry_views.xml index d8bd3acb375af414e63d236d4e6623cc4e4e72b4..dc8209ad3e4742b8d69841054057730eb2518251 100644 --- a/addons/hr_work_entry/views/hr_work_entry_views.xml +++ b/addons/hr_work_entry/views/hr_work_entry_views.xml @@ -29,7 +29,7 @@ event_limit="5"> <field name="state" invisible="1"/> <!-- Sidebar favorites filters --> - <field name="employee_id" write_model="hr.user.work.entry.employee" write_field="employee_id" avatar_field="image_small"/> + <field name="employee_id" write_model="hr.user.work.entry.employee" write_field="employee_id" avatar_field="image_64"/> <templates> <t t-name="calendar-box"> <t t-set="color" t-value="widget.getColor(event.color_index)"/> diff --git a/addons/im_livechat/models/im_livechat_channel.py b/addons/im_livechat/models/im_livechat_channel.py index 920ad6ecb90d813a765b7c080b26103cee521c79..ed7a6a73252e42bded5c4cdfbe77bdc805457524 100644 --- a/addons/im_livechat/models/im_livechat_channel.py +++ b/addons/im_livechat/models/im_livechat_channel.py @@ -4,7 +4,7 @@ import base64 import random import re -from odoo import api, fields, models, modules, tools +from odoo import api, fields, models, modules class ImLivechatChannel(models.Model): @@ -21,7 +21,7 @@ class ImLivechatChannel(models.Model): def _default_image(self): image_path = modules.get_module_resource('im_livechat', 'static/src/img', 'default.png') - return tools.image_process(base64.b64encode(open(image_path, 'rb').read()), size=tools.IMAGE_BIG_SIZE) + return base64.b64encode(open(image_path, 'rb').read()) def _default_user_ids(self): return [(6, 0, [self._uid])] @@ -42,17 +42,7 @@ class ImLivechatChannel(models.Model): script_external = fields.Text('Script (external)', compute='_compute_script_external', store=False, readonly=True) nbr_channel = fields.Integer('Number of conversation', compute='_compute_nbr_channel', store=False, readonly=True) - # images fields - 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', - 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', - 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.") + image_128 = fields.Image("Image", max_width=128, max_height=128, default=_default_image) # relationnal fields user_ids = fields.Many2many('res.users', 'im_livechat_channel_im_user', 'channel_id', 'user_id', string='Operators', default=_default_user_ids) @@ -83,15 +73,6 @@ class ImLivechatChannel(models.Model): for record in self: record.nbr_channel = len(record.channel_ids) - @api.model - def create(self, vals): - tools.image_resize_images(vals) - return super(ImLivechatChannel, self).create(vals) - - def write(self, vals): - tools.image_resize_images(vals) - return super(ImLivechatChannel, self).write(vals) - # -------------------------- # Action Methods # -------------------------- diff --git a/addons/im_livechat/views/im_livechat_channel_views.xml b/addons/im_livechat/views/im_livechat_channel_views.xml index eb5503dca1c99080bb604d151b8303393fba5f12..807bc64a7c7f5dcb9a8324c1ec184879acfb7f48 100644 --- a/addons/im_livechat/views/im_livechat_channel_views.xml +++ b/addons/im_livechat/views/im_livechat_channel_views.xml @@ -33,7 +33,7 @@ <t t-name="kanban-box"> <div class="oe_kanban_global_click"> <div class="o_kanban_image"> - <img t-att-src="kanban_image('im_livechat.channel', 'image_medium', record.id.raw_value)" class="img-fluid" alt="Channel"/> + <img t-att-src="kanban_image('im_livechat.channel', 'image_128', record.id.raw_value)" class="img-fluid" alt="Channel"/> </div> <div class="oe_kanban_details"> <div class="float-right"> @@ -87,7 +87,7 @@ <field string="% Happy" name="rating_percentage_satisfaction" widget="statinfo"/> </button> </div> - <field name="image" widget='image' class="oe_avatar" options='{"preview_image": "image_medium"}'/> + <field name="image_128" widget="image" class="oe_avatar"/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1> @@ -105,7 +105,7 @@ <t t-name="kanban-box"> <div class="oe_kanban_global_click"> <div class="o_kanban_image"> - <img t-att-src="kanban_image('res.users', 'image', record.id.raw_value)" alt="User"/> + <img t-att-src="kanban_image('res.users', 'image_1024', record.id.raw_value)" alt="User"/> </div> <div class="o_kanban_details"> <h4 class="o_kanban_record_title"><field name="name"/></h4> diff --git a/addons/im_livechat/views/mail_channel_views.xml b/addons/im_livechat/views/mail_channel_views.xml index 15041f566c70e85890d9f18a61e90c6fff00b8a8..ac2dd35ce6d81a91863946629f4afcccfe0133d5 100644 --- a/addons/im_livechat/views/mail_channel_views.xml +++ b/addons/im_livechat/views/mail_channel_views.xml @@ -39,7 +39,7 @@ <form string="Session Form" create="false" edit="false"> <sheet> <div style="width:50%" class="float-right"> - <field name="rating_last_image" widget="image" class="float-right" options='{"preview_image": "image_thumb"}' readonly="1" nolabel="1"/> + <field name="rating_last_image" widget="image" class="float-right" readonly="1" nolabel="1"/> <field name="rating_last_feedback" nolabel="1"/> </div> <div style="width:50%" class="float-left"> diff --git a/addons/lunch/controllers/main.py b/addons/lunch/controllers/main.py index 3a94df7066958b615d629807856ed756521e5641..690c37ce14d8c2de6a23875e49f5e2b2556c6a2b 100644 --- a/addons/lunch/controllers/main.py +++ b/addons/lunch/controllers/main.py @@ -86,7 +86,7 @@ class LunchController(http.Controller): res.update({ 'username': user.sudo().name, - 'userimage': '/web/image?model=res.users&id=%s&field=image_small' % user.id, + 'userimage': '/web/image?model=res.users&id=%s&field=image_64' % user.id, 'wallet': request.env['lunch.cashmove'].get_wallet_balance(user, False), 'is_manager': is_manager, 'locations': request.env['lunch.location'].search_read([], ['name']), diff --git a/addons/lunch/data/lunch_demo.xml b/addons/lunch/data/lunch_demo.xml index 4fc4ecf2fe3dd9752c803dbea561607fc6583b65..503067967481855531bc83dbb5b5f193027556fb 100644 --- a/addons/lunch/data/lunch_demo.xml +++ b/addons/lunch/data/lunch_demo.xml @@ -118,7 +118,7 @@ <field name="price">7.5</field> <field name="supplier_id" ref="supplier_corner"/> <field name="description">Beef, Bacon, Salad, Cheddar, Fried Onion, BBQ Sauce</field> - <field name="image" type="base64" file="lunch/static/img/bacon_burger.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/bacon_burger.png"/> <field name="new_until" eval="datetime.today() + relativedelta(weeks=1)"/> </record> @@ -128,7 +128,7 @@ <field name="price">7.0</field> <field name="supplier_id" ref="supplier_corner"/> <field name="description">Beef, Cheddar, Salad, Fried Onions, BBQ Sauce</field> - <field name="image" type="base64" file="lunch/static/img/cheeseburger.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/cheeseburger.png"/> </record> <record model="lunch.product" id="product_chicken_curry"> @@ -136,7 +136,7 @@ <field name="category_id" eval="str(ref('categ_sandwich'))"/> <field name="price">3.0</field> <field name="supplier_id" ref="supplier_corner"/> - <field name="image" type="base64" file="lunch/static/img/chicken_curry.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/chicken_curry.png"/> </record> <record model="lunch.product" id="product_spicy_tuna"> @@ -144,7 +144,7 @@ <field name="category_id" eval="str(ref('categ_sandwich'))"/> <field name="price">3.0</field> <field name="supplier_id" ref="supplier_corner"/> - <field name="image" type="base64" file="lunch/static/img/chicken_curry.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/chicken_curry.png"/> </record> <record model="lunch.product" id="product_mozzarella"> @@ -153,7 +153,7 @@ <field name="price">3.9</field> <field name="supplier_id" ref="supplier_corner"/> <field name="description">Mozzarella, Pesto, Tomatoes</field> - <field name="image" type="base64" file="lunch/static/img/mozza.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/mozza.png"/> </record> <record model="lunch.product" id="product_club"> @@ -162,7 +162,7 @@ <field name="price">3.4</field> <field name="supplier_id" ref="supplier_corner"/> <field name="description">Ham, Cheese, Vegetables</field> - <field name="image" type="base64" file="lunch/static/img/club.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/club.png"/> </record> <record model="lunch.product" id="product_maki"> @@ -171,7 +171,7 @@ <field name="price">12.0</field> <field name="supplier_id" ref="supplier_sushi_shop"/> <field name="description">6 Maki Salmon - 6 Maki Tuna - 6 Maki Shrimp/Avocado</field> - <field name="image" type="base64" file="lunch/static/img/maki.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/maki.png"/> <field name="new_until" eval="datetime.today() + relativedelta(weeks=1)"/> </record> @@ -181,7 +181,7 @@ <field name="price">13.80</field> <field name="supplier_id" ref="supplier_sushi_shop"/> <field name="description">4 Sushi Salmon - 6 Maki Salmon - 4 Sashimi Salmon </field> - <field name="image" type="base64" file="lunch/static/img/salmon_sushi.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/salmon_sushi.png"/> <field name="new_until" eval="datetime.today() + relativedelta(weeks=1)"/> </record> @@ -191,7 +191,7 @@ <field name="price">14.0</field> <field name="supplier_id" ref="supplier_sushi_shop"/> <field name="description">1 Avocado - 1 Salmon - 1 Eggs - 1 Tuna</field> - <field name="image" type="base64" file="lunch/static/img/temaki.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/temaki.png"/> <field name="new_until" eval="datetime.today() + relativedelta(weeks=1)"/> </record> @@ -201,7 +201,7 @@ <field name="price">9.25</field> <field name="supplier_id" ref="supplier_sushi_shop"/> <field name="description">2 Tempuras, Cabbages, Onions, Sesame Sauce</field> - <field name="image" type="base64" file="lunch/static/img/chirashi.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/chirashi.png"/> <field name="new_until" eval="datetime.today() + relativedelta(weeks=1)"/> </record> @@ -211,7 +211,7 @@ <field name="price">3.30</field> <field name="supplier_id" eval="str(ref('supplier_coin_gourmand'))"/> <field name="description">Cheese, Ham, Salad, Tomatoes, cucumbers, eggs</field> - <field name="image" type="base64" file="lunch/static/img/club.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/club.png"/> </record> <record model="lunch.product" id="product_country"> @@ -220,7 +220,7 @@ <field name="price">3.30</field> <field name="supplier_id" eval="str(ref('supplier_coin_gourmand'))"/> <field name="description">Brie, Honey, Walnut Kernels</field> - <field name="image" type="base64" file="lunch/static/img/brie.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/brie.png"/> </record> <record model="lunch.product" id="product_tuna"> @@ -229,7 +229,7 @@ <field name="price">2.50</field> <field name="supplier_id" eval="str(ref('supplier_coin_gourmand'))"/> <field name="description">Tuna, Mayonnaise</field> - <field name="image" type="base64" file="lunch/static/img/tuna_sandwich.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/tuna_sandwich.png"/> </record> <record model="lunch.product" id="product_gouda"> @@ -238,7 +238,7 @@ <field name="price">2.50</field> <field name="supplier_id" eval="str(ref('supplier_coin_gourmand'))"/> <field name="description"></field> - <field name="image" type="base64" file="lunch/static/img/gouda.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/gouda.png"/> </record> <record model="lunch.product" id="product_chicken_curry"> @@ -247,7 +247,7 @@ <field name="price">2.60</field> <field name="supplier_id" eval="str(ref('supplier_coin_gourmand'))"/> <field name="description"></field> - <field name="image" type="base64" file="lunch/static/img/chicken_curry.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/chicken_curry.png"/> </record> <record model="lunch.product" id="product_margherita"> @@ -256,7 +256,7 @@ <field name="price">6.90</field> <field name="supplier_id" eval="str(ref('supplier_pizza_inn'))"/> <field name="description">Tomatoes, Mozzarella</field> - <field name="image" type="base64" file="lunch/static/img/pizza_margherita.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/pizza_margherita.png"/> </record> <record model="lunch.product" id="product_funghi"> @@ -265,7 +265,7 @@ <field name="price">7.00</field> <field name="supplier_id" ref="supplier_pizza_inn"/> <field name="description">Tomatoes, Mushrooms, Mozzarella</field> - <field name="image" type="base64" file="lunch/static/img/pizza_funghi.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/pizza_funghi.png"/> </record> <record model="lunch.product" id="product_vege"> @@ -274,7 +274,7 @@ <field name="price">7.00</field> <field name="supplier_id" ref="supplier_pizza_inn"/> <field name="description">Tomatoes, Mozzarella, Mushrooms, Peppers, Olives</field> - <field name="image" type="base64" file="lunch/static/img/pizza_veggie.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/pizza_veggie.png"/> </record> <record model="lunch.product" id="product_italiana"> @@ -283,7 +283,7 @@ <field name="price">7.40</field> <field name="supplier_id" eval="str(ref('supplier_pizza_inn'))"/> <field name="description">Fresh Tomatoes, Basil, Mozzarella</field> - <field name="image" type="base64" file="lunch/static/img/italiana.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/italiana.png"/> </record> <record model="lunch.product" id="product_Bolognese"> @@ -292,7 +292,7 @@ <field name="price">7.70</field> <field name="supplier_id" eval="str(ref('supplier_pizza_inn'))"/> <field name="description"></field> - <field name="image" type="base64" file="lunch/static/img/pasta_bolognese.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/pasta_bolognese.png"/> </record> <record model="lunch.product" id="product_Napoli"> @@ -301,7 +301,7 @@ <field name="price">7.70</field> <field name="supplier_id" eval="str(ref('supplier_pizza_inn'))"/> <field name="description">Tomatoes, Basil</field> - <field name="image" type="base64" file="lunch/static/img/napoli.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/napoli.png"/> </record> <record model="lunch.topping" id="product_olives"> @@ -316,7 +316,7 @@ <field name="price">5.50</field> <field name="supplier_id" ref="supplier_pizza_inn"/> <field name="description">Tomato sauce, Olive oil, Fresh Tomatoes, Onions, Vegetables, Parmesan</field> - <field name="image" type="base64" file="lunch/static/img/4formaggio.png"/> + <field name="image_1920" type="base64" file="lunch/static/img/4formaggio.png"/> </record> <record model="lunch.cashmove" id="cashmove_1"> diff --git a/addons/lunch/models/lunch_product.py b/addons/lunch/models/lunch_product.py index b46d212adf8887154817ac754fecede8306febc0..3d668857f1c2177b522d1b487be09e87964e0b2b 100644 --- a/addons/lunch/models/lunch_product.py +++ b/addons/lunch/models/lunch_product.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models, tools +from odoo import api, fields, models from odoo.tools import formatLang @@ -85,6 +85,7 @@ class LunchProduct(models.Model): """ Products available to order. A product is linked to a specific vendor. """ _name = 'lunch.product' _description = 'Lunch Product' + _inherit = 'image.mixin' _order = 'name' name = fields.Char('Product Name', required=True) @@ -97,30 +98,5 @@ class LunchProduct(models.Model): company_id = fields.Many2one('res.company', related='supplier_id.company_id', store=True) currency_id = fields.Many2one('res.currency', related='company_id.currency_id') - # image: all image fields are base64 encoded and PIL-supported - image = fields.Binary( - "Image", - help="This field holds the image used as image for the product, limited to 1024x1024px.") - image_medium = fields.Binary( - "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", - 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.") - new_until = fields.Date('New Until') favorite_user_ids = fields.Many2many('res.users', 'lunch_product_favorite_user_rel', 'product_id', 'user_id') - - @api.model_create_multi - def create(self, vals_list): - for values in vals_list: - tools.image_resize_images(values) - return super(LunchProduct, self).create(vals_list) - - def write(self, values): - tools.image_resize_images(values) - return super(LunchProduct, self).write(values) diff --git a/addons/lunch/report/lunch_cashmove_report_views.xml b/addons/lunch/report/lunch_cashmove_report_views.xml index 73f091ccb92a52d518164951eff3eb2c918bb9cc..64dba141ea4989bd8e383f1956fb8c77031d4196 100644 --- a/addons/lunch/report/lunch_cashmove_report_views.xml +++ b/addons/lunch/report/lunch_cashmove_report_views.xml @@ -106,7 +106,7 @@ <t t-esc="record.date.value"/> </div> <div class="col-6"> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> </div> </div> </div> diff --git a/addons/lunch/views/lunch_cashmove_views.xml b/addons/lunch/views/lunch_cashmove_views.xml index dec3bbf9e5006d5aa5d85d98813679b50a63e337..d1cafa0e47be5573f0851f19b98f906e4fb70f8f 100644 --- a/addons/lunch/views/lunch_cashmove_views.xml +++ b/addons/lunch/views/lunch_cashmove_views.xml @@ -77,7 +77,7 @@ <t t-esc="record.date.value"/> </div> <div class="col-6"> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> </div> </div> </div> diff --git a/addons/lunch/views/lunch_orders_views.xml b/addons/lunch/views/lunch_orders_views.xml index 0995e6cf4841e89349b74ff3b998755a93123170..ef79c6c7b24f86a3d2d2c389f674b565c448bafd 100644 --- a/addons/lunch/views/lunch_orders_views.xml +++ b/addons/lunch/views/lunch_orders_views.xml @@ -88,7 +88,7 @@ </a> </div> <div class="col-6"> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> </div> </div> </div> diff --git a/addons/lunch/views/lunch_product_views.xml b/addons/lunch/views/lunch_product_views.xml index 6c69f416c68ff6e87d9f7c316a15e6ee6164c9f2..e328753add1de90035ac56b77fdc02c72765e0eb 100644 --- a/addons/lunch/views/lunch_product_views.xml +++ b/addons/lunch/views/lunch_product_views.xml @@ -46,7 +46,7 @@ <field name="currency_id" invisible="1"/> <sheet> <widget name="web_ribbon" text="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/> - <field name="image" widget="image" class="oe_avatar" options="{'preview_image': 'image_medium'}"/> + <field name="image_1920" widget="image" class="oe_avatar" options="{'preview_image': 'image_128'}"/> <div class="oe_title"> <label for="name" class="oe-edit-only"/> <h1> @@ -89,7 +89,7 @@ <t t-name="kanban-box"> <div class="oe_kanban_global_click o_kanban_record_has_image_fill o_kanban_record"> <div class="o_kanban_image_fill_left d-none d-md-block" - t-attf-style="background-image:url('#{kanban_image('lunch.product', 'image_medium', record.product_id.raw_value)}')"/> + t-attf-style="background-image:url('#{kanban_image('lunch.product', 'image_128', record.product_id.raw_value)}')"/> <div class="oe_kanban_details"> <div class="o_kanban_record_top"> <div class="o_kanban_record_headings"> @@ -137,7 +137,7 @@ <t t-name="kanban-box"> <div class="oe_kanban_global_click o_kanban_record_has_image_fill o_kanban_record"> <div class="o_kanban_image_fill_left d-none d-md-block" - t-attf-style="background-image:url('#{kanban_image('lunch.product', 'image_medium', record.id.raw_value)}')"/> + t-attf-style="background-image:url('#{kanban_image('lunch.product', 'image_128', record.id.raw_value)}')"/> <div class="oe_kanban_details"> <div class="o_kanban_record_top"> <div class="o_kanban_record_headings"> diff --git a/addons/lunch/wizard/lunch_line_wizard.py b/addons/lunch/wizard/lunch_line_wizard.py index 3678449a615b7b01c03b502b1ba52d427c1f0c64..4bdc3b1eb7c09e99c873768414027006e746820b 100644 --- a/addons/lunch/wizard/lunch_line_wizard.py +++ b/addons/lunch/wizard/lunch_line_wizard.py @@ -47,9 +47,8 @@ class LunchOrderWizard(models.TransientModel): available_toppings_2 = fields.Boolean(help='Are extras available for this product', compute='_compute_available_toppings') available_toppings_3 = fields.Boolean(help='Are extras available for this product', compute='_compute_available_toppings') - image = fields.Binary(related='product_id.image') - image_medium = fields.Binary(related='product_id.image_medium') - image_small = fields.Binary(related='product_id.image_small') + image_1920 = fields.Image(related='product_id.image_1920') + image_128 = fields.Image(related='product_id.image_128') quantity = fields.Float('Quantity', default=1) price_total = fields.Float('Total Price', compute='_compute_price_total') diff --git a/addons/lunch/wizard/lunch_line_wizard_views.xml b/addons/lunch/wizard/lunch_line_wizard_views.xml index 94afac2e5f45591502df0c82e0eac26ae1556dfd..7c8879f452d8d6a4ea09a3058021d2d5d21c11dc 100644 --- a/addons/lunch/wizard/lunch_line_wizard_views.xml +++ b/addons/lunch/wizard/lunch_line_wizard_views.xml @@ -16,7 +16,7 @@ <field name="edit" invisible="1"/> <div class="d-flex"> <div class="flex-grow-0 pr-5"> - <field name="image_medium" widget="image" class="o_lunch_image" /> + <field name="image_1920" widget="image" class="o_lunch_image" options="{'image_preview': 'image_128'}"/> </div> <div class="flex-grow-1 pr-5"> <h2><field name="product_name"/></h2> diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py index b540d428ba0282a87b8559b4c7a587e17968a3f8..bc20f0caac5d047bef64a1863c508eb9128ca898 100644 --- a/addons/mail/controllers/main.py +++ b/addons/mail/controllers/main.py @@ -241,7 +241,7 @@ class MailController(http.Controller): request.env[res_model].browse(res_id).check_access_rule('read') if partner_id in request.env[res_model].browse(res_id).sudo().exists().message_ids.mapped('author_id').ids: status, headers, _content = request.env['ir.http'].sudo().binary_content( - model='res.partner', id=partner_id, field='image_medium', default_mimetype='image/png') + model='res.partner', id=partner_id, field='image_128', default_mimetype='image/png') # binary content return an empty string and not a placeholder if obj[field] is False if _content != '': content = _content diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index 2b56951fb4f9dcf95c140142b4ee9d42926e2f5e..974897c3c1c7eb81500a74a5d322302495141265 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -12,7 +12,6 @@ from odoo import _, api, fields, models, modules, tools from odoo.exceptions import UserError, ValidationError from odoo.osv import expression from odoo.tools import ormcache -from odoo.tools.safe_eval import safe_eval MODERATION_FIELDS = ['moderation', 'moderator_ids', 'moderation_ids', 'moderation_notify', 'moderation_notify_msg', 'moderation_guidelines', 'moderation_guidelines_msg'] _logger = logging.getLogger(__name__) @@ -64,7 +63,7 @@ class Channel(models.Model): def _get_default_image(self): image_path = modules.get_module_resource('mail', 'static/src/img', 'groupdefault.png') - return tools.image_process(base64.b64encode(open(image_path, 'rb').read()), size=tools.IMAGE_BIG_SIZE) + return base64.b64encode(open(image_path, 'rb').read()) @api.model def default_get(self, fields): @@ -101,17 +100,7 @@ class Channel(models.Model): help="Members of those groups will automatically added as followers. " "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, - help="This field holds the image used as photo for the group, limited to 1024x1024px.") - 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', - 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.") + image_128 = fields.Image("Image", max_width=128, max_height=128, default=_get_default_image) is_subscribed = fields.Boolean( 'Is Subscribed', compute='_compute_is_subscribed') # moderation @@ -209,11 +198,10 @@ class Channel(models.Model): @api.model def create(self, vals): # ensure image at quick create - if not vals.get('image'): - defaults = self.default_get(['image']) - vals['image'] = defaults['image'] + if not vals.get('image_128'): + defaults = self.default_get(['image_128']) + vals['image_128'] = defaults['image_128'] - tools.image_resize_images(vals) # Create channel and alias channel = super(Channel, self.with_context( alias_model_name=self._name, alias_parent_model_name=self._name, mail_create_nolog=True, mail_create_nosubscribe=True) @@ -250,7 +238,6 @@ class Channel(models.Model): if not self.env.user.has_group('base.group_system'): raise UserError("You do not possess the rights to modify fields related to moderation on one of the channels you are modifying.") - tools.image_resize_images(vals) result = super(Channel, self).write(vals) if vals.get('group_ids'): diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index 229fdb943eb6da4a2676ae45c501baaa4e82fe2a..38426d629bdc064a78d000bfad9f82d505526502 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -79,7 +79,7 @@ class Message(models.Model): 'res.partner', 'Author', index=True, ondelete='set null', default=_get_default_author, help="Author of the message. If not set, email_from may hold an email address that did not match any partner.") - author_avatar = fields.Binary("Author's avatar", related='author_id.image_small', readonly=False) + author_avatar = fields.Binary("Author's avatar", related='author_id.image_64', readonly=False) # recipients: include inactive partners (they may have been archived after # the message was sent, but they should remain visible in the relation) partner_ids = fields.Many2many('res.partner', string='Recipients', context={'active_test': False}) diff --git a/addons/mail/static/src/js/composers/basic_composer.js b/addons/mail/static/src/js/composers/basic_composer.js index 2a496faf86d5f18e9193b5946dfc101dca74fb48..d79a7c930287ac618e41620bda71d1955cf1eb05 100644 --- a/addons/mail/static/src/js/composers/basic_composer.js +++ b/addons/mail/static/src/js/composers/basic_composer.js @@ -100,7 +100,7 @@ var BasicComposer = Widget.extend({ this.avatarURL = session.uid > 0 ? session.url('/web/image', { model: 'res.users', - field: 'image_small', + field: 'image_64', id: session.uid, }) : '/web/static/src/img/user_menu_avatar.png'; }, diff --git a/addons/mail/static/src/js/followers.js b/addons/mail/static/src/js/followers.js index 751187608aeff4f6636a1a5210bd673b4e486419..b6dc5ff699648c786e92ec26f30e6faf88b5b6b3 100644 --- a/addons/mail/static/src/js/followers.js +++ b/addons/mail/static/src/js/followers.js @@ -36,7 +36,7 @@ var Followers = AbstractField.extend({ init: function (parent, name, record, options) { this._super.apply(this, arguments); - this.image = this.attrs.image || 'image_small'; + this.image = this.attrs.image || 'image_64'; this.comment = this.attrs.help || false; this.followers = []; @@ -120,7 +120,7 @@ var Followers = AbstractField.extend({ } $follower_li = $(QWeb.render('mail.Followers.partner', { - 'record': _.extend(record, {'avatar_url': '/web/image/' + record.res_model + '/' + record.res_id + '/image_small'}), + 'record': _.extend(record, {'avatar_url': '/web/image/' + record.res_model + '/' + record.res_id + '/image_64'}), 'widget': self}) ); $follower_li.appendTo($followers_list); diff --git a/addons/mail/static/src/js/models/messages/message.js b/addons/mail/static/src/js/models/messages/message.js index f93209a913f21716319b811f4a692a51e3b2e5b0..d22569461e58b46e3d3a217cec38dc5b4fa21ba1 100644 --- a/addons/mail/static/src/js/models/messages/message.js +++ b/addons/mail/static/src/js/models/messages/message.js @@ -94,7 +94,7 @@ var Message = AbstractMessage.extend(Mixins.EventDispatcherMixin, ServicesMixin if (this._isOdoobotAuthor()) { return '/mail/static/src/img/odoobot.png'; } else if (this.hasAuthor()) { - return '/web/image/res.partner/' + this.getAuthorID() + '/image_small'; + return '/web/image/res.partner/' + this.getAuthorID() + '/image_64'; } else if (this.getType() === 'email') { return '/mail/static/src/img/email_icon.png'; } diff --git a/addons/mail/static/src/js/models/threads/channel.js b/addons/mail/static/src/js/models/threads/channel.js index 9e9f3ac6a39453b50e740384e26f1e376f648ca5..83a0a259e94fc84677c9aa8cd86078a514dcdd95 100644 --- a/addons/mail/static/src/js/models/threads/channel.js +++ b/addons/mail/static/src/js/models/threads/channel.js @@ -220,7 +220,7 @@ var Channel = SearchableThread.extend(ThreadTypingMixin, { getPreview: function () { var result = this._super.apply(this, arguments); if (!this.isTwoUserThread()) { - result.imageSRC = '/web/image/mail.channel/' + this.getID() + '/image_small'; + result.imageSRC = '/web/image/mail.channel/' + this.getID() + '/image_128'; } var lastMessage = this.getLastMessage(); return _.extend(result, { diff --git a/addons/mail/static/src/js/models/threads/dm_chat.js b/addons/mail/static/src/js/models/threads/dm_chat.js index 78cc01a70441300211bb3c2ffc1bb9b3a3e28e18..b53637e614b35188ee947596245638027cbef2cb 100644 --- a/addons/mail/static/src/js/models/threads/dm_chat.js +++ b/addons/mail/static/src/js/models/threads/dm_chat.js @@ -91,7 +91,7 @@ var DMChat = TwoUserChannel.extend(ChannelSeenMixin, { */ getPreview: function () { var result = this._super.apply(this, arguments); - result.imageSRC = '/web/image/res.partner/' + this.getDirectPartnerID() + '/image_small'; + result.imageSRC = '/web/image/res.partner/' + this.getDirectPartnerID() + '/image_64'; return result; }, /** diff --git a/addons/mail/static/src/xml/activity.xml b/addons/mail/static/src/xml/activity.xml index 11b4b0e9022027dda7c3aff002313d7b7367d6a3..d399439d79ee8665219ca27a24593c3ff247b604 100644 --- a/addons/mail/static/src/xml/activity.xml +++ b/addons/mail/static/src/xml/activity.xml @@ -17,7 +17,7 @@ <div class="o_thread_message" style="margin-bottom: 10px"> <div class="o_thread_message_sidebar"> <div class="o_avatar_stack"> - <img t-attf-src="/web/image#{activity.user_id[0] >= 0 ? ('/res.users/' + activity.user_id[0] + '/image_small') : ''}" class="o_thread_message_avatar rounded-circle mb8" t-att-title="activity.user_id[1]" t-att-alt="activity.user_id[1]"/> + <img t-attf-src="/web/image#{activity.user_id[0] >= 0 ? ('/res.users/' + activity.user_id[0] + '/image_64') : ''}" class="o_thread_message_avatar rounded-circle mb8" t-att-title="activity.user_id[1]" t-att-alt="activity.user_id[1]"/> <i t-att-class="'o_avatar_icon fa ' + activity.icon + ' bg-' + (activity.state == 'planned'? 'success' : (activity.state == 'today'? 'warning' : 'danger')) + '-full'" t-att-title="activity.activity_type_id[1]"/> </div> @@ -42,7 +42,7 @@ <dd class="mb8"> <t t-esc="activity.create_date.format(datetimeFormat)"/> by - <img t-attf-src="/web/image#{activity.create_uid[0] >= 0 ? ('/res.users/' + activity.create_uid[0] + '/image_small') : ''}" + <img t-attf-src="/web/image#{activity.create_uid[0] >= 0 ? ('/res.users/' + activity.create_uid[0] + '/image_64') : ''}" height="18" width="18" class="rounded-circle mr4" t-att-title="activity.create_uid[1]" @@ -51,7 +51,7 @@ </dd> <dt>Assigned to</dt> <dd class="mb8"> - <img t-attf-src="/web/image#{activity.user_id[0] >= 0 ? ('/res.users/' + activity.user_id[0] + '/image_small') : ''}" height="18" width="18" class="rounded-circle mr4" t-att-title="activity.user_id[1]" t-att-alt="activity.user_id[1]"/> + <img t-attf-src="/web/image#{activity.user_id[0] >= 0 ? ('/res.users/' + activity.user_id[0] + '/image_64') : ''}" height="18" width="18" class="rounded-circle mr4" t-att-title="activity.user_id[1]" t-att-alt="activity.user_id[1]"/> <b><t t-esc="activity.user_id[1]"/></b> <em>, due on </em><span t-attf-class="o_activity_color_#{activity.state}"><t t-esc="activity.date_deadline.format(dateFormat)"/></span> </dd> diff --git a/addons/mail/views/mail_channel_views.xml b/addons/mail/views/mail_channel_views.xml index 40911a053ff25ab907e50f8701a5d74a97b1f9c2..7667d2b47fe74c2eb44c332430795efaa678c985 100644 --- a/addons/mail/views/mail_channel_views.xml +++ b/addons/mail/views/mail_channel_views.xml @@ -61,7 +61,7 @@ </t> <t t-name="kanban-box"> <div class="oe_module_vignette oe_kanban_global_click"> - <img t-att-src="kanban_image('mail.channel', 'image_medium', record.id.raw_value)" class="oe_module_icon" alt="Channel"/> + <img t-att-src="kanban_image('mail.channel', 'image_128', record.id.raw_value)" class="oe_module_icon" alt="Channel"/> <div class="oe_module_desc"> <h4 class="o_kanban_record_title">#<field name="name"/></h4> <p class="oe_module_name"> @@ -94,7 +94,7 @@ </button> </div> <div class="oe_button_box" name="button_box"/> - <field name="image" widget="image" class="oe_avatar" options="{'preview_image': 'image_medium', 'size': [90, 90]}"/> + <field name="image_128" widget="image" class="oe_avatar" options="{'size': [90, 90]}"/> <div class="oe_title"> <div class="oe_edit_only"> <label for="name"/> diff --git a/addons/mail/views/mail_message_views.xml b/addons/mail/views/mail_message_views.xml index 6839b357611c4f4d397a833dd8c5199afc5fa5d2..4581e3efb416fa76c51285d1fc988b0e2c14a5a9 100644 --- a/addons/mail/views/mail_message_views.xml +++ b/addons/mail/views/mail_message_views.xml @@ -183,7 +183,7 @@ <field name="create_date" widget="date"/> </time> <div class="oe_kanban_bottom_right"> - <img t-att-src="kanban_image('res.users', 'image_small', record.create_uid.raw_value)" t-att-data-member_id="record.create_uid.raw_value" t-att-alt="record.create_uid.raw_value" width="32" height="32" class="oe_kanban_avatar"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.create_uid.raw_value)" t-att-data-member_id="record.create_uid.raw_value" t-att-alt="record.create_uid.raw_value" width="32" height="32" class="oe_kanban_avatar"/> </div> </div> </div> diff --git a/addons/mail/views/res_partner_views.xml b/addons/mail/views/res_partner_views.xml index a620c261b4434aaf13ca3af4ab2d56abf6958ec1..3bc62e5c9a36f2bed481336b7dfb50d8568525e3 100644 --- a/addons/mail/views/res_partner_views.xml +++ b/addons/mail/views/res_partner_views.xml @@ -57,7 +57,7 @@ <field name="id"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('res.partner', 'image_small', record.id.raw_value)" role="img" t-att-title="record.id.value" t-att-alt="record.id.value"/> + <img t-att-src="activity_image('res.partner', 'image_64', record.id.raw_value)" role="img" t-att-title="record.id.value" t-att-alt="record.id.value"/> <div> <field name="name" display="full"/> <field name="parent_id" muted="1" display="full"/> diff --git a/addons/mail_bot/data/mailbot_data.xml b/addons/mail_bot/data/mailbot_data.xml index b772ffd5951dd0f53a5bc57890cdf742be59f217..20233fd731031d86a21b882b5b5492174649946a 100644 --- a/addons/mail_bot/data/mailbot_data.xml +++ b/addons/mail_bot/data/mailbot_data.xml @@ -4,7 +4,7 @@ <record id="base.partner_root" model="res.partner"> <field name="name">OdooBot</field> <field name="email">odoobot@example.com</field> - <field name="image" type="base64" file="mail/static/src/img/odoobot.png"/> + <field name="image_1920" type="base64" file="mail/static/src/img/odoobot.png"/> </record> </data> </odoo> diff --git a/addons/mail_bot/views/res_users_views.xml b/addons/mail_bot/views/res_users_views.xml index 296e5380485665e51aa418246eafca67955e8617..f82b2b96f7234293cba7bef149c65d83e33d4e37 100644 --- a/addons/mail_bot/views/res_users_views.xml +++ b/addons/mail_bot/views/res_users_views.xml @@ -34,7 +34,7 @@ <field name="model">res.users</field> <field name="inherit_id" ref="base.view_users_form_simple_modif"/> <field name="arch" type="xml"> - <xpath expr="//field[@name='image']" position="before"> + <xpath expr="//field[@name='image_1920']" position="before"> <widget name="notification_alert"/> </xpath> </field> diff --git a/addons/maintenance/views/maintenance_views.xml b/addons/maintenance/views/maintenance_views.xml index 400607c118a69a2ab482c20b1d5dedea16e5f2d2..e651b315a22554cd36a8fe5a28bad58ae63e9cf3 100644 --- a/addons/maintenance/views/maintenance_views.xml +++ b/addons/maintenance/views/maintenance_views.xml @@ -166,7 +166,7 @@ </div> <div class="oe_kanban_bottom_right"> <field name="kanban_state" widget="state_selection"/> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> </div> </div> </div> @@ -466,7 +466,7 @@ <div class="o_kanban_inline_block"> <field name="activity_ids" widget="kanban_activity" /> </div> - <img t-att-src="kanban_image('res.users', 'image_small', record.owner_user_id.raw_value)" t-att-title="record.owner_user_id.value" t-att-alt="record.owner_user_id.value" width="27" height="27" class="oe_kanban_avatar"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.owner_user_id.raw_value)" t-att-title="record.owner_user_id.value" t-att-alt="record.owner_user_id.value" width="27" height="27" class="oe_kanban_avatar"/> </div> </div> </div> @@ -660,7 +660,7 @@ <div t-attf-class="oe_kanban_global_click"> <div class="mb4"> <strong><field name="name"/></strong> - <img t-att-src="kanban_image('res.users', 'image_small', record.technician_user_id.raw_value)" t-att-title="record.technician_user_id.value" t-att-alt="record.technician_user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.technician_user_id.raw_value)" t-att-title="record.technician_user_id.value" t-att-alt="record.technician_user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> </div> <div class="row mt4"> <div class="col-6"> diff --git a/addons/mrp/data/mrp_demo.xml b/addons/mrp/data/mrp_demo.xml index 6f6c7db8e072ea7972048e78cc2a66e5f95523ad..5c9311f332e814ac8806bba08e1ea5490afa481a 100644 --- a/addons/mrp/data/mrp_demo.xml +++ b/addons/mrp/data/mrp_demo.xml @@ -175,7 +175,7 @@ <field name="description">Solid wood table.</field> <field name="default_code">FURN_9666</field> <field name="tracking">serial</field> - <field name="image" type="base64" file="mrp/static/img/table.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/table.png"/> </record> <record id="product_product_computer_desk_head" model="product.product"> <field name="name">Table Top</field> @@ -189,7 +189,7 @@ <field name="description">Solid wood is a durable natural material.</field> <field name="default_code">FURN_8522</field> <field name="tracking">serial</field> - <field name="image" type="base64" file="mrp/static/img/table_top.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/table_top.png"/> </record> <record id="product_product_computer_desk_leg" model="product.product"> <field name="name">Table Leg</field> @@ -203,7 +203,7 @@ <field name="description">18″ x 2½″ Square Leg</field> <field name="default_code">FURN_2333</field> <field name="tracking">lot</field> - <field name="image" type="base64" file="mrp/static/img/table_leg.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/table_leg.png"/> </record> <record id="product_product_computer_desk_bolt" model="product.product"> <field name="name">Bolt</field> @@ -216,7 +216,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="description">Stainless steel screw full (dia - 5mm, Length - 10mm)</field> <field name="default_code">CONS_89957</field> - <field name="image" type="base64" file="mrp/static/img/product_product_computer_desk_bolt.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/product_product_computer_desk_bolt.png"/> </record> <record id="product_product_computer_desk_screw" model="product.product"> <field name="name">Screw</field> @@ -229,7 +229,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="description">Stainless steel screw</field> <field name="default_code">CONS_25630</field> - <field name="image" type="base64" file="mrp/static/img/product_product_computer_desk_screw.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/product_product_computer_desk_screw.png"/> </record> <record id="product_product_wood_ply" model="product.product"> @@ -243,7 +243,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="description">Layers that are stick together to assemble wood panels.</field> <field name="default_code">FURN_7111</field> - <field name="image" type="base64" file="mrp/static/img/product_product_wood_ply.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/product_product_wood_ply.png"/> </record> <record id="product_product_wood_wear" model="product.product"> <field name="name">Wear Layer</field> @@ -256,7 +256,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="description">Top layer of a wood panel.</field> <field name="default_code">FURN_8111</field> - <field name="image" type="base64" file="mrp/static/img/product_product_wood_wear.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/product_product_wood_wear.png"/> </record> <record id="product_product_ply_veneer" model="product.product"> <field name="name">Ply Veneer</field> @@ -268,7 +268,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_9111</field> - <field name="image" type="base64" file="mrp/static/img/product_product_ply_veneer.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/product_product_ply_veneer.png"/> </record> <record id="product_product_wood_panel" model="product.product"> @@ -281,7 +281,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_7023</field> - <field name="image" type="base64" file="mrp/static/img/product_product_wood_panel.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/product_product_wood_panel.png"/> </record> <record id="product_product_plastic_laminate" model="product.product"> <field name="name">Plastic Laminate</field> @@ -293,7 +293,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_8621</field> - <field name="image" type="base64" file="mrp/static/img/product_product_plastic_laminate.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/product_product_plastic_laminate.png"/> </record> <record id="product_product_computer_desk_product_template" model="product.template"> @@ -423,7 +423,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="description">Table kit</field> <field name="default_code">FURN_78236</field> - <field name="image" type="base64" file="mrp/static/img/product_product_table_kit.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/product_product_table_kit.png"/> </record> <record id="product_product_table_kit_product_template" model="product.template"> @@ -467,7 +467,7 @@ <field name="description">Drawer on casters for great usability.</field> <field name="default_code">FURN_2100</field> <field name="barcode">601647855646</field> - <field name="image" type="base64" file="mrp/static/img/product_product_drawer_black.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/product_product_drawer_black.png"/> </record> <record id="product_product_drawer_case" model="product.product"> @@ -482,7 +482,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_5623</field> <field name="barcode">601647855647</field> - <field name="image" type="base64" file="mrp/static/img/product_product_drawer_case_black.png"/> + <field name="image_1920" type="base64" file="mrp/static/img/product_product_drawer_case_black.png"/> </record> <record id="product.product_product_27" model="product.product"> diff --git a/addons/mrp/views/ir_attachment_view.xml b/addons/mrp/views/ir_attachment_view.xml index 415ae3a523348f29180dfb779087fbcff7e2939e..98104a35446e86fbab28998b043cd3a1648a5a65 100644 --- a/addons/mrp/views/ir_attachment_view.xml +++ b/addons/mrp/views/ir_attachment_view.xml @@ -37,7 +37,7 @@ <field name="priority" widget="priority"/> </span> <div class="oe_kanban_bottom_right"> - <img t-att-src="kanban_image('res.users', 'image_small', record.create_uid.raw_value)" t-att-data-member_id="record.create_uid.raw_value" t-att-alt="record.create_uid.raw_value" width="32" height="32" class="oe_kanban_avatar"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.create_uid.raw_value)" t-att-data-member_id="record.create_uid.raw_value" t-att-alt="record.create_uid.raw_value" width="32" height="32" class="oe_kanban_avatar"/> </div> </div> </div> diff --git a/addons/mrp/views/mrp_workorder_views.xml b/addons/mrp/views/mrp_workorder_views.xml index 21f08de5eda4ca237f6c33597b134ea944f559cb..9c7538b15cfceb12f599b09672d61777067d7a3a 100644 --- a/addons/mrp/views/mrp_workorder_views.xml +++ b/addons/mrp/views/mrp_workorder_views.xml @@ -389,7 +389,7 @@ <span t-if="record.working_state.raw_value != 'blocked' and record.working_user_ids.raw_value.length == 0 and record.last_working_user_id.raw_value"><i class="fa fa-pause" role="img" aria-label="Pause" title="Pause"/></span> <span t-if="record.working_state.raw_value == 'blocked' and (record.working_user_ids.raw_value.length == 0 or record.last_working_user_id.raw_value)"><i class="fa fa-stop" role="img" aria-label="Stop" title="Stop"/></span> <t t-if="record.last_working_user_id.raw_value"> - <img t-att-src="kanban_image('res.users', 'image_small', record.last_working_user_id.raw_value)" width="24" height="24" class="oe_kanban_avatar" alt="Avatar"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.last_working_user_id.raw_value)" width="24" height="24" class="oe_kanban_avatar" alt="Avatar"/> </t> </div> </div> diff --git a/addons/note/views/note_views.xml b/addons/note/views/note_views.xml index 72cf447c597d4fb15eea0e60991ff03ee3190d62..f27497b43d7380e620c0535e63b87f04c68bc5c4 100644 --- a/addons/note/views/note_views.xml +++ b/addons/note/views/note_views.xml @@ -122,7 +122,7 @@ <t t-if="record.message_partner_ids.raw_value.length > 1"> <div class="clearfix"></div> <t t-foreach="record.message_partner_ids.raw_value" t-as="follower"> - <img t-att-src="kanban_image('res.partner', 'image_small', follower)" width="24" height="24" class="oe_kanban_avatar float-right" t-att-data-member_id="follower" alt="Follower"/> + <img t-att-src="kanban_image('res.partner', 'image_64', follower)" width="24" height="24" class="oe_kanban_avatar float-right" t-att-data-member_id="follower" alt="Follower"/> </t> <div class="clearfix"></div> </t> diff --git a/addons/partner_autocomplete/static/src/js/partner_autocomplete_fieldchar.js b/addons/partner_autocomplete/static/src/js/partner_autocomplete_fieldchar.js index c1fab81a194cde0cd0fee5849ac05504d82346e2..69a1332122e8b257bf282cda547afa0cf0a2b4a8 100644 --- a/addons/partner_autocomplete/static/src/js/partner_autocomplete_fieldchar.js +++ b/addons/partner_autocomplete/static/src/js/partner_autocomplete_fieldchar.js @@ -115,7 +115,7 @@ var FieldAutocomplete = FieldChar.extend(AutocompleteMixin, { var self = this; this._getCreateData(company).then(function (data) { if (data.logo) { - var logoField = self.model === 'res.partner' ? 'image' : 'logo'; + var logoField = self.model === 'res.partner' ? 'image_1920' : 'logo'; data.company[logoField] = data.logo; } diff --git a/addons/partner_autocomplete/static/tests/partner_autocomplete_tests.js b/addons/partner_autocomplete/static/tests/partner_autocomplete_tests.js index b524dba75a603a14eb1cbdc7a5e7f01ed3011775..c605c9bc33ce7b1bd2b4a855cb2ed67d3bb040fe 100644 --- a/addons/partner_autocomplete/static/tests/partner_autocomplete_tests.js +++ b/addons/partner_autocomplete/static/tests/partner_autocomplete_tests.js @@ -15,7 +15,7 @@ odoo.define('partner_autocomplete.tests', function (require) { _.each(createData, function (val, key) { if (fields[key]) { - if (key === 'image') { + if (key === 'image_1920') { if (val) val = 'data:image/png;base64,' + val; assert.hasAttrValue(form.$(".o_field_image img"), "data-src", val, 'image value should have been updated to "' + val + '"'); } else { @@ -123,7 +123,7 @@ odoo.define('partner_autocomplete.tests', function (require) { name: {string: "Name", type: "char", searchable: true}, parent_id: {string: "Company", type: "many2one", relation: "res.partner"}, website: {string: "Website", type: "char", searchable: true}, - image: {string: "Image", type: "binary", searchable: true}, + image_1920: {string: "Image", type: "binary", searchable: true}, email: {string: "Email", type: "char", searchable: true}, phone: {string: "Phone", type: "char", searchable: true}, street: {string: "Street", type: "char", searchable: true}, @@ -163,7 +163,7 @@ odoo.define('partner_autocomplete.tests', function (require) { '<field name="company_type"/>' + '<field name="name" widget="field_partner_autocomplete"/>' + '<field name="website"/>' + - '<field name="image" widget="image"/>' + + '<field name="image_1920" widget="image"/>' + '</form>', }).then(function (form){ // Set company type to Individual @@ -198,7 +198,7 @@ odoo.define('partner_autocomplete.tests', function (require) { '<field name="company_type"/>' + '<field name="name" widget="field_partner_autocomplete"/>' + '<field name="website"/>' + - '<field name="image" widget="image"/>' + + '<field name="image_1920" widget="image"/>' + '<field name="email"/>' + '<field name="phone"/>' + '<field name="street"/>' + @@ -272,7 +272,7 @@ odoo.define('partner_autocomplete.tests', function (require) { '<field name="company_type"/>' + '<field name="name" widget="field_partner_autocomplete"/>' + '<field name="website"/>' + - '<field name="image" widget="image"/>' + + '<field name="image_1920" widget="image"/>' + '<field name="email"/>' + '<field name="phone"/>' + '<field name="street"/>' + diff --git a/addons/payment/data/payment_acquirer_data.xml b/addons/payment/data/payment_acquirer_data.xml index b9040c2275726f0f2bdf6159fd309673071f987e..8ff2324d2a7f7e851ef43c0bd7dc31c21dc95164 100644 --- a/addons/payment/data/payment_acquirer_data.xml +++ b/addons/payment/data/payment_acquirer_data.xml @@ -14,7 +14,7 @@ <record id="payment_acquirer_buckaroo" model="payment.acquirer"> <field name="name">Buckaroo</field> - <field name="image" type="base64" file="payment_buckaroo/static/src/img/buckaroo_icon.png"/> + <field name="image_128" type="base64" file="payment_buckaroo/static/src/img/buckaroo_icon.png"/> <field name="view_template_id" ref="default_acquirer_button"/> <field name="module_id" ref="base.module_payment_buckaroo"/> <field name="description" type="html"> @@ -38,7 +38,7 @@ <field name="name">Ingenico</field> <field name="sequence">2</field> <field name="view_template_id" ref="default_acquirer_button"/> - <field name="image" type="base64" file="payment_ogone/static/src/img/ogone_icon.png"/> + <field name="image_128" type="base64" file="payment_ogone/static/src/img/ogone_icon.png"/> <field name="module_id" ref="base.module_payment_ogone"/> <field name="description" type="html"> <p> @@ -61,7 +61,7 @@ <record id="payment_acquirer_adyen" model="payment.acquirer"> <field name="name">Adyen</field> <field name="view_template_id" ref="default_acquirer_button"/> - <field name="image" type="base64" file="payment_adyen/static/src/img/adyen_icon.png"/> + <field name="image_128" type="base64" file="payment_adyen/static/src/img/adyen_icon.png"/> <field name="module_id" ref="base.module_payment_adyen"/> <field name="description" type="html"> <p> @@ -87,7 +87,7 @@ <field name="name">Authorize.net</field> <field name="sequence">3</field> <field name="view_template_id" ref="default_acquirer_button"/> - <field name="image" type="base64" file="payment_authorize/static/src/img/authorize_icon.png"/> + <field name="image_128" type="base64" file="payment_authorize/static/src/img/authorize_icon.png"/> <field name="module_id" ref="base.module_payment_authorize"/> <field name="description" type="html"> <p> @@ -114,7 +114,7 @@ <field name="name">Wire Transfer</field> <field name="sequence">2</field> <field name="view_template_id" ref="default_acquirer_button"/> - <field name="image" type="base64" file="payment_transfer/static/src/img/transfer_icon.png"/> + <field name="image_128" type="base64" file="payment_transfer/static/src/img/transfer_icon.png"/> <field name="module_id" ref="base.module_payment_transfer"/> <field name="pending_msg"><i>Pending</i>... The order will be validated after the payment.</field> <field name="description" type="html"> @@ -127,7 +127,7 @@ <record id="payment_acquirer_sips" model="payment.acquirer"> <field name="name">Sips</field> <field name="view_template_id" ref="default_acquirer_button"/> - <field name="image" type="base64" file="payment_sips/static/src/img/sips_icon.png"/> + <field name="image_128" type="base64" file="payment_sips/static/src/img/sips_icon.png"/> <field name="module_id" ref="base.module_payment_sips"/> <field name="description" type="html"> <p> @@ -154,7 +154,7 @@ <field name="name">Paypal</field> <field name="sequence">1</field> <field name="view_template_id" ref="default_acquirer_button"/> - <field name="image" type="base64" file="payment_paypal/static/src/img/paypal_icon.png"/> + <field name="image_128" type="base64" file="payment_paypal/static/src/img/paypal_icon.png"/> <field name="module_id" ref="base.module_payment_paypal"/> <field name="description" type="html"> <p> @@ -179,7 +179,7 @@ <record id="payment_acquirer_stripe" model="payment.acquirer"> <field name="name">Stripe</field> <field name="view_template_id" ref="default_acquirer_button"/> - <field name="image" type="base64" file="payment_stripe/static/src/img/stripe_icon.png"/> + <field name="image_128" type="base64" file="payment_stripe/static/src/img/stripe_icon.png"/> <field name="module_id" ref="base.module_payment_stripe"/> <field name="description" type="html"> <p> @@ -222,7 +222,7 @@ <record id="payment_acquirer_payu" model="payment.acquirer"> <field name="name">PayUmoney</field> - <field name="image" type="base64" file="payment_payumoney/static/src/img/payumoney_icon.png"/> + <field name="image_128" type="base64" file="payment_payumoney/static/src/img/payumoney_icon.png"/> <field name="view_template_id" ref="default_acquirer_button"/> <field name="module_id" ref="base.module_payment_payumoney"/> <field name="description" type="html"> @@ -245,7 +245,7 @@ <record id="payment_acquirer_payulatam" model="payment.acquirer"> <field name="name">PayU Latam</field> - <field name="image" type="base64" file="payment_payulatam/static/src/img/payulatam_icon.png"/> + <field name="image_128" type="base64" file="payment_payulatam/static/src/img/payulatam_icon.png"/> <field name="view_template_id" ref="default_acquirer_button"/> <field name="module_id" ref="base.module_payment_payulatam"/> <field name="description" type="html"> @@ -267,7 +267,7 @@ <record id="payment_acquirer_alipay" model="payment.acquirer"> <field name="name">Alipay</field> - <field name="image" type="base64" file="payment_alipay/static/description/icon.png"/> + <field name="image_128" type="base64" file="payment_alipay/static/description/icon.png"/> <field name="view_template_id" ref="default_acquirer_button"/> <field name="module_id" ref="base.module_payment_alipay"/> <field name="description" type="html"> diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 6595a40399f0dd0237164b9ebbc2636db16d4ddb..5c3f2135590efc0ea0512fcd6be0ac7d493812cf 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -8,7 +8,7 @@ from dateutil import relativedelta import pprint from odoo import api, exceptions, fields, models, _, SUPERUSER_ID -from odoo.tools import consteq, float_round, image_resize_images, image_process, ustr +from odoo.tools import consteq, float_round, image_process, ustr from odoo.addons.base.models import ir_module from odoo.exceptions import ValidationError from odoo.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT @@ -152,18 +152,7 @@ class PaymentAcquirer(models.Model): module_id = fields.Many2one('ir.module.module', string='Corresponding Module') module_state = fields.Selection(selection=ir_module.STATES, string='Installation State', related='module_id.state', readonly=False) - image = fields.Binary( - "Image", help="This field holds the image used for this provider, limited to 1024x1024px") - image_medium = fields.Binary( - "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", - 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.") + image_128 = fields.Image("Image", max_width=128, max_height=128) payment_icon_ids = fields.Many2many('payment.icon', string='Supported Payment Icons') payment_flow = fields.Selection(selection=[('form', 'Redirection to the acquirer website'), @@ -275,13 +264,11 @@ class PaymentAcquirer(models.Model): @api.model def create(self, vals): - image_resize_images(vals) record = super(PaymentAcquirer, self).create(vals) record._check_required_if_provider() return record def write(self, vals): - image_resize_images(vals) result = super(PaymentAcquirer, self).write(vals) self._check_required_if_provider() return result diff --git a/addons/payment/views/payment_portal_templates.xml b/addons/payment/views/payment_portal_templates.xml index 9eea573702204bf877c11066fe91e1aceb763ceb..20d519599be3fd2910d12d0fc60a6949e8fa9c40 100644 --- a/addons/payment/views/payment_portal_templates.xml +++ b/addons/payment/views/payment_portal_templates.xml @@ -112,7 +112,7 @@ <a role="button" t-attf-class="btn btn-#{status} float-right" href="/my/home"><i class="fa fa-arrow-circle-right"/> Back to My Account</a> </div> <div class="col-md-6 offset-md-6 text-muted mt16"><!-- FIXME should be in a row... --> - <span t-field="tx.acquirer_id.image_small" t-att-title="tx.acquirer_id.name" role="img" t-att-aria-label="tx.acquirer_id.name" t-options='{"widget": "image", "style":"max-width: 60px; display: inline-block"}'/> + <span t-field="tx.acquirer_id.image_128" t-att-title="tx.acquirer_id.name" role="img" t-att-aria-label="tx.acquirer_id.name" t-options='{"widget": "image", "style":"max-width: 60px; display: inline-block"}'/> <span>Processed by <t t-esc="tx.acquirer_id.name"/>.</span> </div> </div> diff --git a/addons/payment/views/payment_views.xml b/addons/payment/views/payment_views.xml index ff335bc56e28606a8eefadfd2d30aa20fa68cdff..0be3849727ccb17bedeea07e0519f4c112afc422 100644 --- a/addons/payment/views/payment_views.xml +++ b/addons/payment/views/payment_views.xml @@ -61,7 +61,7 @@ </div> </button> </div> - <field name="image" widget='image' class="oe_avatar" options='{"preview_image": "image_medium"}'/> + <field name="image_128" widget="image" class="oe_avatar"/> <div class="oe_title"> <h1><field name="name" placeholder="Name"/></h1> </div> @@ -157,7 +157,7 @@ <t t-set="installed" t-value="!record.module_id.value || (record.module_id.value && record.module_state.raw_value === 'installed')"/> <div t-attf-class="oe_kanban_global_click #{installed and record.website_published.raw_value ? 'oe_kanban_color_5' : 'oe_kanban_color_white'}"> <div class="o_kanban_image"> - <img type="open" t-att-src="kanban_image('payment.acquirer', 'image_small', record.id.raw_value)" alt="Acquirer"/> + <img type="open" t-att-src="kanban_image('payment.acquirer', 'image_128', record.id.raw_value)" alt="Acquirer"/> </div> <div class="o_payment_acquirer_desc"> <h3 class="mt4"><t t-esc="record.name.value"/></h3> diff --git a/addons/payment_adyen/data/payment_acquirer_data.xml b/addons/payment_adyen/data/payment_acquirer_data.xml index a0b6488663dd43f9317b445b8bfe77f572aefe96..18e3bb8afdeca6752169b16558de979ec487904d 100644 --- a/addons/payment_adyen/data/payment_acquirer_data.xml +++ b/addons/payment_adyen/data/payment_acquirer_data.xml @@ -4,7 +4,7 @@ <record id="payment.payment_acquirer_adyen" model="payment.acquirer"> <field name="name">Adyen</field> - <field name="image" type="base64" file="payment_adyen/static/src/img/adyen_icon.png"/> + <field name="image_128" type="base64" file="payment_adyen/static/src/img/adyen_icon.png"/> <field name="provider">adyen</field> <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="adyen_form"/> diff --git a/addons/payment_authorize/data/payment_acquirer_data.xml b/addons/payment_authorize/data/payment_acquirer_data.xml index da0e438c41d2074a26689efedab0f4734d14f0d1..293bcbad9e04db51fa3909e418c3bbfa83bfc57f 100644 --- a/addons/payment_authorize/data/payment_acquirer_data.xml +++ b/addons/payment_authorize/data/payment_acquirer_data.xml @@ -4,7 +4,7 @@ <record id="payment.payment_acquirer_authorize" model="payment.acquirer"> <field name="name">Authorize.Net</field> - <field name="image" type="base64" file="payment_authorize/static/src/img/authorize_icon.png"/> + <field name="image_128" type="base64" file="payment_authorize/static/src/img/authorize_icon.png"/> <field name="provider">authorize</field> <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="authorize_form"/> diff --git a/addons/payment_buckaroo/data/payment_acquirer_data.xml b/addons/payment_buckaroo/data/payment_acquirer_data.xml index db69ed5fa7cce3e580024ed1d24d790437964373..7b11d68884485159d6c698158ea46f7f79f1502e 100644 --- a/addons/payment_buckaroo/data/payment_acquirer_data.xml +++ b/addons/payment_buckaroo/data/payment_acquirer_data.xml @@ -4,7 +4,7 @@ <record id="payment.payment_acquirer_buckaroo" model="payment.acquirer"> <field name="name">Buckaroo</field> - <field name="image" type="base64" file="payment_buckaroo/static/src/img/buckaroo_icon.png"/> + <field name="image_128" type="base64" file="payment_buckaroo/static/src/img/buckaroo_icon.png"/> <field name="provider">buckaroo</field> <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="buckaroo_form"/> diff --git a/addons/payment_ogone/data/payment_acquirer_data.xml b/addons/payment_ogone/data/payment_acquirer_data.xml index 49743cc2a62766ea4f33941b42b6160a3b9be3cb..8f121d164d5a578b77f7aa6a9b55c8a0c9dea348 100644 --- a/addons/payment_ogone/data/payment_acquirer_data.xml +++ b/addons/payment_ogone/data/payment_acquirer_data.xml @@ -4,7 +4,7 @@ <record id="payment.payment_acquirer_ogone" model="payment.acquirer"> <field name="name">Ingenico</field> - <field name="image" type="base64" file="payment_ogone/static/src/img/ogone_icon.png"/> + <field name="image_128" type="base64" file="payment_ogone/static/src/img/ogone_icon.png"/> <field name="provider">ogone</field> <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="ogone_form"/> diff --git a/addons/payment_paypal/data/payment_acquirer_data.xml b/addons/payment_paypal/data/payment_acquirer_data.xml index 62bac1466ffc49f8b55c888fe1860ab8a1406ce8..893feb51b6e55ec45f9640e11926e63e2c63c51d 100644 --- a/addons/payment_paypal/data/payment_acquirer_data.xml +++ b/addons/payment_paypal/data/payment_acquirer_data.xml @@ -4,7 +4,7 @@ <record id="payment.payment_acquirer_paypal" model="payment.acquirer"> <field name="name">Paypal</field> - <field name="image" type="base64" file="payment_paypal/static/src/img/paypal_icon.png"/> + <field name="image_128" type="base64" file="payment_paypal/static/src/img/paypal_icon.png"/> <field name="provider">paypal</field> <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="paypal_form"/> diff --git a/addons/payment_payumoney/data/payment_acquirer_data.xml b/addons/payment_payumoney/data/payment_acquirer_data.xml index f8c9dd971399d389d822b6ed00c6870b08f2ab81..dab5726f043e16d3883b55bc45d328148fb3b3cc 100644 --- a/addons/payment_payumoney/data/payment_acquirer_data.xml +++ b/addons/payment_payumoney/data/payment_acquirer_data.xml @@ -3,7 +3,7 @@ <data noupdate="1"> <record id="payment.payment_acquirer_payu" model="payment.acquirer"> <field name="name">PayUmoney</field> - <field name="image" type="base64" file="payment_payumoney/static/src/img/payumoney_icon.png"/> + <field name="image_128" type="base64" file="payment_payumoney/static/src/img/payumoney_icon.png"/> <field name="provider">payumoney</field> <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="payumoney_form"/> diff --git a/addons/payment_sips/data/payment_acquirer_data.xml b/addons/payment_sips/data/payment_acquirer_data.xml index c6082d6f6fc4d52ee75b592647ec842665cbbfe4..666c0271ad6debf842901211f4f3678f0c45e7f1 100644 --- a/addons/payment_sips/data/payment_acquirer_data.xml +++ b/addons/payment_sips/data/payment_acquirer_data.xml @@ -4,7 +4,7 @@ <record id="payment.payment_acquirer_sips" model="payment.acquirer"> <field name="name">Sips</field> - <field name="image" type="base64" file="payment_sips/static/src/img/sips_icon.png"/> + <field name="image_128" type="base64" file="payment_sips/static/src/img/sips_icon.png"/> <field name="provider">sips</field> <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="payment_sips.sips_form"/> diff --git a/addons/payment_stripe/data/payment_acquirer_data.xml b/addons/payment_stripe/data/payment_acquirer_data.xml index a82caaa37046b19f4f377b99f74d90be41b2f75b..2d30e4c6a72767f45953204bf1745d7713bf1fc2 100644 --- a/addons/payment_stripe/data/payment_acquirer_data.xml +++ b/addons/payment_stripe/data/payment_acquirer_data.xml @@ -3,7 +3,7 @@ <data noupdate="1"> <record id="payment.payment_acquirer_stripe" model="payment.acquirer"> <field name="name">Stripe</field> - <field name="image" type="base64" file="payment_stripe/static/src/img/stripe_icon.png"/> + <field name="image_128" type="base64" file="payment_stripe/static/src/img/stripe_icon.png"/> <field name="provider">stripe</field> <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="stripe_form"/> diff --git a/addons/payment_transfer/data/payment_acquirer_data.xml b/addons/payment_transfer/data/payment_acquirer_data.xml index 4cd7c7811e55db675ed7ba67413f95a25cb1f631..ba2964e13d8c0c50998d84ccce3583d686100bbb 100644 --- a/addons/payment_transfer/data/payment_acquirer_data.xml +++ b/addons/payment_transfer/data/payment_acquirer_data.xml @@ -4,7 +4,7 @@ <record id="payment.payment_acquirer_transfer" model="payment.acquirer"> <field name="name">Wire Transfer</field> - <field name="image" type="base64" file="payment_transfer/static/src/img/transfer_icon.png"/> + <field name="image_128" type="base64" file="payment_transfer/static/src/img/transfer_icon.png"/> <field name="provider">transfer</field> <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="transfer_form"/> diff --git a/addons/point_of_sale/data/point_of_sale_data.xml b/addons/point_of_sale/data/point_of_sale_data.xml index 0dfa33f862a169d5f4ebc3c0229595c4d4305975..48ca0eb669bd660ba6269567d2e763268f7f4f9f 100644 --- a/addons/point_of_sale/data/point_of_sale_data.xml +++ b/addons/point_of_sale/data/point_of_sale_data.xml @@ -39,7 +39,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">MISC</field> - <field name="image" type="base64" file="point_of_sale/static/img/product_product_49-image.jpg"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/product_product_49-image.jpg"/> </record> <record id="uom.product_uom_categ_unit" model="uom.category"> diff --git a/addons/point_of_sale/data/point_of_sale_demo.xml b/addons/point_of_sale/data/point_of_sale_demo.xml index 7bb512a4dd671824c5b9809544937b37aed89418..d564078cc2989000078fca5d9ebcd01386740bca 100644 --- a/addons/point_of_sale/data/point_of_sale_demo.xml +++ b/addons/point_of_sale/data/point_of_sale_demo.xml @@ -54,7 +54,7 @@ <field name="pos_categ_id" ref="pos_category_miscellaneous"/> <field name="uom_id" ref="uom.product_uom_unit" /> <field name="uom_po_id" ref="uom.product_uom_unit" /> - <field name="image" type="base64" file="point_of_sale/static/img/wall_shelf_unit.png"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/wall_shelf_unit.png"/> </record> <record id="small_shelf" model="product.product"> <field name="available_in_pos">True</field> @@ -69,7 +69,7 @@ <field name="to_weight">True</field> <field name="uom_id" ref="uom.product_uom_unit" /> <field name="uom_po_id" ref="uom.product_uom_unit" /> - <field name="image" type="base64" file="point_of_sale/static/img/small_shelf.png"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/small_shelf.png"/> </record> <record id="letter_tray" model="product.product"> @@ -84,7 +84,7 @@ <field name="pos_categ_id" ref="pos_category_miscellaneous"/> <field name="uom_id" ref="uom.product_uom_unit" /> <field name="uom_po_id" ref="uom.product_uom_unit" /> - <field name="image" type="base64" file="point_of_sale/static/img/letter_tray.png"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/letter_tray.png"/> </record> <record id="desk_organizer" model="product.product"> <field name="available_in_pos">True</field> @@ -99,7 +99,7 @@ <field name="pos_categ_id" ref="pos_category_miscellaneous"/> <field name="uom_id" ref="uom.product_uom_unit" /> <field name="uom_po_id" ref="uom.product_uom_unit" /> - <field name="image" type="base64" file="point_of_sale/static/img/desk_organizer.png"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/desk_organizer.png"/> <field name="taxes_id" eval='[(5,)]'/> <!-- no taxes --> </record> @@ -116,7 +116,7 @@ <field name="pos_categ_id" ref="pos_category_miscellaneous"/> <field name="uom_id" ref="uom.product_uom_unit" /> <field name="uom_po_id" ref="uom.product_uom_unit" /> - <field name="image" type="base64" file="point_of_sale/static/img/magnetic_board.png"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/magnetic_board.png"/> </record> <record id="monitor_stand" model="product.product"> <field name="available_in_pos">True</field> @@ -130,7 +130,7 @@ <field name="pos_categ_id" ref="pos_category_miscellaneous"/> <field name="uom_id" ref="uom.product_uom_unit" /> <field name="uom_po_id" ref="uom.product_uom_unit" /> - <field name="image" type="base64" file="point_of_sale/static/img/monitor_stand.png"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/monitor_stand.png"/> </record> <record id="desk_pad" model="product.product"> <field name="available_in_pos">True</field> @@ -144,7 +144,7 @@ <field name="pos_categ_id" ref="pos_category_miscellaneous"/> <field name="uom_id" ref="uom.product_uom_unit" /> <field name="uom_po_id" ref="uom.product_uom_unit" /> - <field name="image" type="base64" file="point_of_sale/static/img/desk_pad.png"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/desk_pad.png"/> </record> <record id="whiteboard" model="product.product"> @@ -157,7 +157,7 @@ <field name="categ_id" ref="product.product_category_5"/> <field name="uom_id" ref="uom.product_uom_unit" /> <field name="uom_po_id" ref="uom.product_uom_unit" /> - <field name="image" type="base64" file="point_of_sale/static/img/whiteboard.png"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/whiteboard.png"/> </record> <record id="led_lamp" model="product.product"> @@ -172,7 +172,7 @@ <field name="pos_categ_id" ref="pos_category_miscellaneous"/> <field name="uom_id" ref="uom.product_uom_unit" /> <field name="uom_po_id" ref="uom.product_uom_unit" /> - <field name="image" type="base64" file="point_of_sale/static/img/led_lamp.png"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/led_lamp.png"/> </record> <record id="newspaper_rack" model="product.product"> @@ -188,7 +188,7 @@ <field name="pos_categ_id" ref="pos_category_miscellaneous"/> <field name="uom_id" ref="uom.product_uom_unit" /> <field name="uom_po_id" ref="uom.product_uom_unit" /> - <field name="image" type="base64" file="point_of_sale/static/img/newspaper_stand.png"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/newspaper_stand.png"/> </record> <record id="whiteboard_pen" model="product.product"> @@ -202,7 +202,7 @@ <field name="pos_categ_id" ref="pos_category_miscellaneous"/> <field name="uom_id" ref="uom.product_uom_unit" /> <field name="uom_po_id" ref="uom.product_uom_unit" /> - <field name="image" type="base64" file="point_of_sale/static/img/whiteboard_pen.png"/> + <field name="image_1920" type="base64" file="point_of_sale/static/img/whiteboard_pen.png"/> </record> <record id="product.product_product_1" model="product.product"> diff --git a/addons/point_of_sale/models/pos_category.py b/addons/point_of_sale/models/pos_category.py index a8e01c2ae4fa3c93aee9172638dcf6ec13bad598..c3f40d94478905f01e4a458fe2022272a3c1f985 100644 --- a/addons/point_of_sale/models/pos_category.py +++ b/addons/point_of_sale/models/pos_category.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models, tools, _ +from odoo import api, fields, models, _ + class PosCategory(models.Model): _name = "pos.category" @@ -16,29 +17,7 @@ class PosCategory(models.Model): parent_id = fields.Many2one('pos.category', string='Parent Category', index=True) child_id = fields.One2many('pos.category', 'parent_id', string='Children Categories') sequence = fields.Integer(help="Gives the sequence order when displaying a list of product categories.") - # NOTE: there is no 'default image', because by default we don't show - # 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( - help="This field holds the image used as image for the cateogry, limited to 1024x1024px.") - 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", - 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.") - - @api.model - def create(self, vals): - tools.image_resize_images(vals) - return super(PosCategory, self).create(vals) - - def write(self, vals): - tools.image_resize_images(vals) - return super(PosCategory, self).write(vals) + image_128 = fields.Image("Image", max_width=128, max_height=128) def name_get(self): def get_names(cat): diff --git a/addons/point_of_sale/models/res_partner.py b/addons/point_of_sale/models/res_partner.py index a1b89f004e3f2bbd57404c9e276a90ff058a82ec..7f54488c51c4afa7e87540971e7fba1f0b0945dc 100644 --- a/addons/point_of_sale/models/res_partner.py +++ b/addons/point_of_sale/models/res_partner.py @@ -29,8 +29,8 @@ class ResPartner(models.Model): """ create or modify a partner from the point of sale ui. partner contains the partner's fields. """ # image is a dataurl, get the data after the comma - if partner.get('image'): - partner['image'] = partner['image'].split(',')[1] + if partner.get('image_1920'): + partner['image_1920'] = partner['image_1920'].split(',')[1] partner_id = partner.pop('id', False) if partner_id: # Modifying existing partner self.browse(partner_id).write(partner) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index e24a5d7841b12f15135c9d8d1f1930c88d82ded2..1cea3a6c9cefb56b9c5e7c289e31be48d2b6aabe 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -778,7 +778,7 @@ exports.PosModel = Backbone.Model.extend({ if (order) { order.get_orderlines().forEach(function (orderline) { var product = orderline.product; - var image_url = window.location.origin + '/web/image?model=product.product&field=image_medium&id=' + product.id; + var image_url = window.location.origin + '/web/image?model=product.product&field=image_128&id=' + product.id; // only download and convert image if we haven't done it before if (! product.image_base64) { diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 279d66b65eab97c278c85d9b7b3094192c340d55..ae1c62a535ace9452924ddd5ef4628298a8084b4 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -732,7 +732,7 @@ var ProductCategoriesWidget = PosBaseWidget.extend({ }, get_image_url: function(category){ - return window.location.origin + '/web/image?model=pos.category&field=image_medium&id='+category.id; + return window.location.origin + '/web/image?model=pos.category&field=image_128&id='+category.id; }, render_category: function( category, with_image ){ @@ -899,7 +899,7 @@ var ProductListWidget = PosBaseWidget.extend({ this.renderElement(); }, get_product_image_url: function(product){ - return window.location.origin + '/web/image?model=product.product&field=image_medium&id='+product.id; + return window.location.origin + '/web/image?model=product.product&field=image_128&id='+product.id; }, replace: function($target){ this.renderElement(); @@ -1308,7 +1308,7 @@ var ClientListScreenWidget = ScreenWidget.extend({ } }, partner_icon_url: function(id){ - return '/web/image?model=res.partner&id='+id+'&field=image_small'; + return '/web/image?model=res.partner&id='+id+'&field=image_64'; }, // ui handle for the 'edit selected customer' action diff --git a/addons/point_of_sale/views/pos_category_view.xml b/addons/point_of_sale/views/pos_category_view.xml index 96d05ff9321f2d683f8f33693b8e6b13e913987c..fa2b716cf5b1b15cc544c0de34b0c9b3a72c3717 100644 --- a/addons/point_of_sale/views/pos_category_view.xml +++ b/addons/point_of_sale/views/pos_category_view.xml @@ -6,7 +6,7 @@ <field name="arch" type="xml"> <form string="Pos Product Categories"> <sheet> - <field name="image" widget='image' class="oe_avatar"/> + <field name="image_128" widget="image" class="oe_avatar"/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1> @@ -41,14 +41,13 @@ <field name="arch" type="xml"> <kanban class="o_kanban_mobile"> <field name="name"/> - <field name="image_medium"/> <field name="id"/> <templates> <t t-name="kanban-box"> <div t-attf-class="oe_kanban_global_click"> <div class="row"> <div class="col-4"> - <img height="100" width="100" t-att-src="kanban_image('pos.category', 'image_medium', record.id.raw_value)" alt="Category"/> + <img height="100" width="100" t-att-src="kanban_image('pos.category', 'image_128', record.id.raw_value)" alt="Category"/> </div> <div class="col-8"> <strong class="o_kanban_record_title"><field name="name"/></strong> diff --git a/addons/point_of_sale/views/pos_session_view.xml b/addons/point_of_sale/views/pos_session_view.xml index d2641930c6dc577c26192958d054f8910a913c17..9ba67a2f1ae84bdb5b73534881c2a4f3f944f279 100644 --- a/addons/point_of_sale/views/pos_session_view.xml +++ b/addons/point_of_sale/views/pos_session_view.xml @@ -155,7 +155,7 @@ <span><field name="start_at" /></span> </div> <div class="oe_kanban_bottom_right"> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> </div> </div> </div> diff --git a/addons/portal/static/src/xml/portal_chatter.xml b/addons/portal/static/src/xml/portal_chatter.xml index 339477b371596d0b0ae743ea202c60edc7117ceb..e8e740692f84b4fa719ad6ccd70f9e1d0ea4cc70 100644 --- a/addons/portal/static/src/xml/portal_chatter.xml +++ b/addons/portal/static/src/xml/portal_chatter.xml @@ -29,7 +29,7 @@ </t> <t t-if="widget.options['display_composer']"> <div class="media"> - <img alt="Avatar" class="o_portal_chatter_avatar" t-attf-src="/web/image/res.partner/#{widget.options['partner_id']}/image_small/50x50"/> + <img alt="Avatar" class="o_portal_chatter_avatar" t-attf-src="/web/image/res.partner/#{widget.options['partner_id']}/image_64/50x50"/> <div class="media-body"> <form class="o_portal_chatter_composer_form" t-attf-action="/mail/chatter_post" method="POST"> <input type="hidden" name="csrf_token" t-att-value="widget.options['csrf_token']"/> diff --git a/addons/pos_restaurant/data/pos_restaurant_demo.xml b/addons/pos_restaurant/data/pos_restaurant_demo.xml index 4f71aa2c841173c2dcbec4a7ced484d882dfc804..8f8c2d463b131d5b23324638323efc94724bd0df 100644 --- a/addons/pos_restaurant/data/pos_restaurant_demo.xml +++ b/addons/pos_restaurant/data/pos_restaurant_demo.xml @@ -32,7 +32,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-pizza.png"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-pizza.png"/> </record> <record id="pos_food_funghi" model="product.product"> <field name="available_in_pos">True</field> @@ -41,7 +41,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-pizza.png"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-pizza.png"/> </record> <record id="pos_food_vege" model="product.product"> <field name="available_in_pos">True</field> @@ -50,7 +50,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-pizza.png"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-pizza.png"/> </record> <record id="pos_food_bolo" model="product.product"> <field name="available_in_pos">True</field> @@ -59,7 +59,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-pasta.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-pasta.jpg"/> </record> <record id="pos_food_4formaggi" model="product.product"> <field name="available_in_pos">True</field> @@ -68,7 +68,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-pasta-4f.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-pasta-4f.jpg"/> </record> <record id="pos_food_bacon" model="product.product"> <field name="available_in_pos">True</field> @@ -77,7 +77,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-burger.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-burger.jpg"/> </record> <record id="pos_food_cheeseburger" model="product.product"> <field name="available_in_pos">True</field> @@ -86,7 +86,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-cheeseburger.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-cheeseburger.jpg"/> </record> <record id="pos_food_chicken" model="product.product"> <field name="available_in_pos">True</field> @@ -95,7 +95,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-sandwich.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-sandwich.jpg"/> </record> <record id="pos_food_tuna" model="product.product"> <field name="available_in_pos">True</field> @@ -104,7 +104,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-tuna.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-tuna.jpg"/> </record> <record id="pos_food_mozza" model="product.product"> <field name="available_in_pos">True</field> @@ -113,7 +113,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-mozza.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-mozza.jpg"/> </record> <record id="pos_food_club" model="product.product"> <field name="available_in_pos">True</field> @@ -122,7 +122,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-club.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-club.jpg"/> </record> <record id="pos_food_maki" model="product.product"> <field name="available_in_pos">True</field> @@ -131,7 +131,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-maki.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-maki.jpg"/> </record> <record id="pos_food_salmon" model="product.product"> <field name="available_in_pos">True</field> @@ -140,7 +140,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-salmon.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-salmon.jpg"/> </record> <record id="pos_food_temaki" model="product.product"> <field name="available_in_pos">True</field> @@ -149,7 +149,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-temaki.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-temaki.jpg"/> </record> <record id="pos_food_chirashi" model="product.product"> <field name="available_in_pos">True</field> @@ -158,7 +158,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="food"/> <field name="categ_id" ref="pos_restaurant.product_category_pos_food"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-salmon-avocado.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-salmon-avocado.jpg"/> </record> <!-- Drinks --> @@ -169,7 +169,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="drinks"/> <field name="categ_id" ref="point_of_sale.product_category_pos"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-coke.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-coke.jpg"/> </record> <record id="water" model="product.product"> @@ -179,7 +179,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="drinks"/> <field name="categ_id" ref="point_of_sale.product_category_pos"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-water.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-water.jpg"/> </record> <record id="minute_maid" model="product.product"> @@ -189,7 +189,7 @@ <field name="weight">0.01</field> <field name="pos_categ_id" ref="drinks"/> <field name="categ_id" ref="point_of_sale.product_category_pos"/> - <field name="image" type="base64" file="pos_restaurant/static/img/th-minute_maid.jpg"/> + <field name="image_1920" type="base64" file="pos_restaurant/static/img/th-minute_maid.jpg"/> </record> <!-- Pos Config --> diff --git a/addons/product/data/product_demo.xml b/addons/product/data/product_demo.xml index a46ab878d1a23c7e28c11b4d0a87499f6b948889..229e87b652ad4e1e059bdb96b3c78bd8d3112b2e 100644 --- a/addons/product/data/product_demo.xml +++ b/addons/product/data/product_demo.xml @@ -85,7 +85,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_7777</field> - <field name="image" type="base64" file="product/static/img/product_chair.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_chair.png"/> </record> <record id="product_delivery_02" model="product.product"> @@ -98,7 +98,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_8888</field> - <field name="image" type="base64" file="product/static/img/product_lamp.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_lamp.png"/> </record> <record id="product_order_01" model="product.product"> @@ -111,7 +111,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_9999</field> - <field name="image" type="base64" file="product/static/img/product_product_43-image.jpg"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_43-image.jpg"/> </record> <record id="product_product_3" model="product.product"> @@ -125,7 +125,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="description_sale">Desk combination, black-brown: chair + desk + drawer.</field> <field name="default_code">FURN_7800</field> - <field name="image" type="base64" file="product/static/img/product_product_3-image.jpg"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_3-image.jpg"/> </record> <!-- Variants --> @@ -202,7 +202,7 @@ <field name="weight">0.01</field> <field name="attribute_value_ids" eval="[(6,0,[ref('product.product_attribute_value_1'), ref('product.product_attribute_value_3')])]"/> <field name="product_tmpl_id" ref="product_product_4_product_template"/> - <field name="image" type="base64" file="product/static/img/table02.png"/> + <field name="image_1920" type="base64" file="product/static/img/table02.png"/> </record> <record id="product_product_4b" model="product.product"> <field name="default_code">FURN_0097</field> @@ -210,7 +210,7 @@ <field name="product_tmpl_id" ref="product_product_4_product_template"/> <field name="standard_price">500.0</field> <field name="attribute_value_ids" eval="[(6,0,[ref('product.product_attribute_value_1'), ref('product.product_attribute_value_4')])]"/> - <field name="image" type="base64" file="product/static/img/table04.png"/> + <field name="image_1920" type="base64" file="product/static/img/table04.png"/> </record> <record id="product_product_4c" model="product.product"> <field name="default_code">FURN_0098</field> @@ -218,7 +218,7 @@ <field name="standard_price">500.0</field> <field name="product_tmpl_id" ref="product_product_4_product_template"/> <field name="attribute_value_ids" eval="[(6,0,[ref('product.product_attribute_value_2'), ref('product.product_attribute_value_3')])]"/> - <field name="image" type="base64" file="product/static/img/table03.png"/> + <field name="image_1920" type="base64" file="product/static/img/table03.png"/> </record> <record id="product_product_4d" model="product.product"> <field name="default_code">DESK0004</field> @@ -226,7 +226,7 @@ <field name="product_tmpl_id" ref="product_product_4_product_template"/> <field name="standard_price">500.0</field> <field name="attribute_value_ids" eval="[(6,0,[ref('product.product_attribute_value_2'), ref('product.product_attribute_value_4')])]"/> - <field name="image" type="base64" file="product/static/img/table01.png"/> + <field name="image_1920" type="base64" file="product/static/img/table01.png"/> </record> <record id="product_product_5" model="product.product"> @@ -239,7 +239,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">E-COM06</field> - <field name="image" type="base64" file="product/static/img/product_product_5-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_5-image.png"/> </record> <record id="product_product_6" model="product.product"> @@ -253,7 +253,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">E-COM07</field> <field name='weight'>0.330</field> - <field name="image" type="base64" file="product/static/img/product_product_6-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_6-image.png"/> </record> <record id="product_product_7" model="product.product"> @@ -266,7 +266,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">E-COM08</field> - <field name="image" type="base64" file="product/static/img/product_product_7-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_7-image.png"/> </record> <record id="product_product_8" model="product.product"> @@ -280,7 +280,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">E-COM09</field> <field name='weight'>9.54</field> - <field name="image" type="base64" file="product/static/img/product_product_8-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_8-image.png"/> </record> <record id="product_product_9" model="product.product"> @@ -293,7 +293,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">E-COM10</field> - <field name="image" type="base64" file="product/static/img/product_product_9-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_9-image.png"/> </record> <record id="product_product_10" model="product.product"> @@ -306,7 +306,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">E-COM11</field> - <field name="image" type="base64" file="product/static/img/product_product_10-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_10-image.png"/> </record> <record id="product_product_11_product_template" model="product.template"> @@ -317,7 +317,7 @@ <field name="type">consu</field> <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> - <field name="image" type="base64" file="product/static/img/product_product_11-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_11-image.png"/> </record> <!-- the product template attribute lines have to be defined before creating the variants --> @@ -378,7 +378,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_0269</field> - <field name="image" type="base64" file="product/static/img/product_product_12-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_12-image.png"/> </record> <record id="product_product_13" model="product.product"> @@ -391,7 +391,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_1118</field> - <field name="image" type="base64" file="product/static/img/product_product_13-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_13-image.png"/> </record> <record id="product_product_16" model="product.product"> @@ -404,7 +404,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_8900</field> - <field name="image" type="base64" file="product/static/img/product_product_16-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_16-image.png"/> </record> <record id="product_product_20" model="product.product"> @@ -417,7 +417,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_9001</field> - <field name="image" type="base64" file="product/static/img/product_product_20-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_20-image.png"/> </record> <record id="product_product_22" model="product.product"> <field name="name">Desk Stand with Screen</field> @@ -429,7 +429,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_7888</field> - <field name="image" type="base64" file="product/static/img/product_product_22-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_22-image.png"/> </record> <record id="product_product_24" model="product.product"> @@ -442,7 +442,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_0789</field> - <field name="image" type="base64" file="product/static/img/product_product_24-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_24-image.png"/> </record> <record id="product_product_25" model="product.product"> @@ -455,7 +455,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="default_code">FURN_6666</field> - <field name="image" type="base64" file="product/static/img/product_product_25-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_25-image.png"/> </record> <record id="product_product_27" model="product.product"> @@ -469,7 +469,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="description">Drawer with two routing possiblities.</field> <field name="default_code">FURN_8855</field> - <field name="image" type="base64" file="product/static/img/product_product_27-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_27-image.png"/> </record> <record id="consu_delivery_03" model="product.product"> @@ -483,7 +483,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="description_sale">Four person modern office workstation</field> <field name="default_code">FURN_8220</field> - <field name="image" type="base64" file="product/static/img/product_product_d03-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_d03-image.png"/> </record> <record id="consu_delivery_02" model="product.product"> @@ -497,7 +497,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="description_sale">Conference room table</field> <field name="default_code">FURN_6741</field> - <field name="image" type="base64" file="product/static/img/product_product_46-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_46-image.png"/> </record> <record id="consu_delivery_01" model="product.product"> @@ -511,7 +511,7 @@ <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="description_sale">Three Seater Sofa with Lounger in Steel Grey Colour</field> <field name="default_code">FURN_8999</field> - <field name="image" type="base64" file="product/static/img/product_product_d01-image.png"/> + <field name="image_1920" type="base64" file="product/static/img/product_product_d01-image.png"/> </record> <!-- diff --git a/addons/product/models/product.py b/addons/product/models/product.py index cdb4a74a498cb99fb3bc0766927a57c04a9f147f..400b434f775f78714cce95d401d420354a4db050 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -122,103 +122,86 @@ class ProductProduct(models.Model): # all image fields are base64 encoded and PIL-supported - # all image_raw fields are technical and should not be displayed to the user - image_raw_original = fields.Binary("Raw Original Image") + # all image_variant fields are technical and should not be displayed to the user + image_variant_max = fields.Image("Variant Image", max_width=1920, max_height=1920) # resized fields stored (as attachment) for performance - image_raw_big = fields.Binary("Raw Big-sized Image", compute='_compute_images', store=True) - image_raw_large = fields.Binary("Raw Large-sized Image", compute='_compute_images', store=True) - image_raw_medium = fields.Binary("Raw Medium-sized Image", compute='_compute_images', store=True) - image_raw_small = fields.Binary("Raw Small-sized Image", compute='_compute_images', store=True) - - can_image_raw_be_zoomed = fields.Boolean("Can image raw be zoomed", compute='_compute_images', store=True) + image_variant_1024 = fields.Image("Variant Image 1204", related="image_variant_max", max_width=1024, max_height=1024, store=True) + image_variant_512 = fields.Image("Variant Image 512", related="image_variant_max", max_width=512, max_height=512, store=True) + image_variant_256 = fields.Image("Variant Image 256", related="image_variant_max", max_width=256, max_height=256, store=True) + image_variant_128 = fields.Image("Variant Image 128", related="image_variant_max", max_width=128, max_height=128, store=True) + image_variant_64 = fields.Image("Variant Image 64", related="image_variant_max", max_width=64, max_height=64, store=True) + can_image_variant_1024_be_zoomed = fields.Boolean("Can Variant Image 1024 be zoomed", compute='_compute_can_image_variant_1024_be_zoomed', store=True) # Computed fields that are used to create a fallback to the template if # necessary, it's recommended to display those fields to the user. - image_original = fields.Binary("Original Image", compute='_compute_image_original', inverse='_set_image_original', help="Image in its original size, as it was uploaded.") - image_big = fields.Binary("Big-sized Image", compute='_compute_image_big', help="1024px * 1024px") - image_large = fields.Binary("Large-sized Image", compute='_compute_image_large', help="256px * 256px") - image_medium = fields.Binary("Medium-sized Image", compute='_compute_image_medium', help="128px * 128px") - image_small = fields.Binary("Small-sized Image", compute='_compute_image_small', help="64px * 64px") - can_image_be_zoomed = fields.Boolean("Can image be zoomed", compute='_compute_can_image_be_zoomed') - - image = fields.Binary("Image", compute='_compute_image', inverse='_set_image') - - @api.depends('image_raw_original') - def _compute_images(self): + image_1920 = fields.Image("Image", compute='_compute_image_1920', inverse='_set_image_1920') + image_1024 = fields.Image("Image 1024", compute='_compute_image_1024') + image_512 = fields.Image("Image 512", compute='_compute_image_512') + image_256 = fields.Image("Image 256", compute='_compute_image_256') + image_128 = fields.Image("Image 128", compute='_compute_image_128') + image_64 = fields.Image("Image 64", compute='_compute_image_64') + can_image_1024_be_zoomed = fields.Boolean("Can Image 1024 be zoomed", compute='_compute_can_image_1024_be_zoomed') + + @api.depends('image_variant_max', 'image_variant_1024') + def _compute_can_image_variant_1024_be_zoomed(self): for record in self: - image = record.image_raw_original - # for performance: avoid calling unnecessary methods when falsy - images = image and tools.image_get_resized_images(image, big_name=False) - record.image_raw_big = image and tools.image_get_resized_images(image, - large_name=False, medium_name=False, small_name=False)['image'] - record.image_raw_large = image and images['image_large'] - record.image_raw_medium = image and images['image_medium'] - record.image_raw_small = image and images['image_small'] - record.can_image_raw_be_zoomed = image and tools.is_image_size_above(image) - - def _compute_image_original(self): + record.can_image_variant_1024_be_zoomed = record.image_variant_max and tools.is_image_size_above(record.image_variant_max, record.image_variant_1024) + + def _compute_image_1920(self): """Get the image from the template if no image is set on the variant.""" for record in self: - record.image_original = record.image_raw_original or record.product_tmpl_id.image_original + record.image_1920 = record.image_variant_max or record.product_tmpl_id.image_1920 - def _set_image_original(self): + def _set_image_1920(self): for record in self: if ( # We are trying to remove an image even though it is already # not set, remove it from the template instead. - not record.image_original and not record.image_raw_original or + not record.image_1920 and not record.image_variant_max or # We are trying to add an image, but the template image is # not set, write on the template instead. - record.image_original and not record.product_tmpl_id.image_original or + record.image_1920 and not record.product_tmpl_id.image_1920 or # There is only one variant, always write on the template. self.search_count([ ('product_tmpl_id', '=', record.product_tmpl_id.id), ('active', '=', True), ]) <= 1 ): - record.image_raw_original = False - record.product_tmpl_id.image_original = record.image_original + record.image_variant_max = False + record.product_tmpl_id.image_1920 = record.image_1920 else: - record.image_raw_original = record.image_original + record.image_variant_max = record.image_1920 - def _compute_image_big(self): + def _compute_image_1024(self): """Get the image from the template if no image is set on the variant.""" for record in self: - record.image_big = record.image_raw_big or record.product_tmpl_id.image_big + record.image_1024 = record.image_variant_1024 or record.product_tmpl_id.image_1024 - def _compute_image_large(self): + def _compute_image_512(self): """Get the image from the template if no image is set on the variant.""" for record in self: - record.image_large = record.image_raw_large or record.product_tmpl_id.image_large + record.image_512 = record.image_variant_512 or record.product_tmpl_id.image_512 - def _compute_image_medium(self): + def _compute_image_256(self): """Get the image from the template if no image is set on the variant.""" for record in self: - record.image_medium = record.image_raw_medium or record.product_tmpl_id.image_medium + record.image_256 = record.image_variant_256 or record.product_tmpl_id.image_256 - def _compute_image_small(self): + def _compute_image_128(self): """Get the image from the template if no image is set on the variant.""" for record in self: - record.image_small = record.image_raw_small or record.product_tmpl_id.image_small + record.image_128 = record.image_variant_128 or record.product_tmpl_id.image_128 - def _compute_can_image_be_zoomed(self): + def _compute_image_64(self): """Get the image from the template if no image is set on the variant.""" for record in self: - record.can_image_be_zoomed = record.can_image_raw_be_zoomed if record.image_raw_original else record.product_tmpl_id.can_image_be_zoomed + record.image_64 = record.image_variant_64 or record.product_tmpl_id.image_64 - @api.depends('image_big') - def _compute_image(self): - for record in self: - record.image = record.image_big - - def _set_image(self): + def _compute_can_image_1024_be_zoomed(self): + """Get the image from the template if no image is set on the variant.""" for record in self: - record.image_original = record.image - # We want the image field to be recomputed to have a correct size. - # Without this `invalidate_cache`, the image field will keep holding the - # image_original instead of the big-sized image. - self.invalidate_cache() + record.can_image_1024_be_zoomed = record.can_image_variant_1024_be_zoomed if record.image_variant_max else record.product_tmpl_id.can_image_1024_be_zoomed _sql_constraints = [ ('barcode_uniq', 'unique(barcode)', "A barcode can only be assigned to one product !"), @@ -391,8 +374,8 @@ class ProductProduct(models.Model): for product in self: # If there is an image set on the variant and no image set on the # template, move the image to the template. - if product.image_raw_original and not product.product_tmpl_id.image_original: - product.product_tmpl_id.image_original = product.image_raw_original + if product.image_variant_max and not product.product_tmpl_id.image_1920: + product.product_tmpl_id.image_1920 = product.image_variant_max # Check if product still exists, in case it has been unlinked by unlinking its template if not product.exists(): continue diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index a9530f1f01f321841e07cbe4aa3d7d43502703a3..101ed0c4039014bde0c193811e92c9f7eecc0162 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -149,6 +149,13 @@ class ProductTemplate(models.Model): item_ids = fields.One2many('product.pricelist.item', 'product_tmpl_id', 'Pricelist Items') + can_image_1024_be_zoomed = fields.Boolean("Can Image 1024 be zoomed", compute='_compute_can_image_1024_be_zoomed', store=True) + + @api.depends('image_1920', 'image_1024') + def _compute_can_image_1024_be_zoomed(self): + for template in self: + template.can_image_1024_be_zoomed = template.image_1920 and tools.is_image_size_above(template.image_1920, template.image_1024) + @api.depends('product_variant_ids') def _compute_product_variant_id(self): for p in self: @@ -371,6 +378,16 @@ class ProductTemplate(models.Model): self.create_variant_ids() if 'active' in vals and not vals.get('active'): self.with_context(active_test=False).mapped('product_variant_ids').write({'active': vals.get('active')}) + if 'image_1920' in vals: + self.env['product.product'].invalidate_cache(fnames=[ + 'image_1920', + 'image_1024', + 'image_512', + 'image_256', + 'image_128', + 'image_64', + 'can_image_1024_be_zoomed', + ]) return res @api.returns('self', lambda value: value.id) diff --git a/addons/product/tests/test_variants.py b/addons/product/tests/test_variants.py index ccddf89c662d00bc2accf9892a2e068d53198df6..f07553a9141e17763fa8d925d76047a1d948a9ab 100644 --- a/addons/product/tests/test_variants.py +++ b/addons/product/tests/test_variants.py @@ -501,7 +501,7 @@ class TestVariantsImages(common.TestProductCommon): self.images.update({color: base64.b64encode(f.read())}) self.env['product.product'].create({ - 'image_raw_original': self.images[color], + 'image_variant_max': self.images[color], 'attribute_value_ids': [(6, 0, [color_value.id])], 'product_tmpl_id': self.template.id, }) @@ -511,7 +511,7 @@ class TestVariantsImages(common.TestProductCommon): return res def test_variant_images(self): - """Check that on variant, the image used is the image_raw_original if set, + """Check that on variant, the image used is the image_variant_max if set, and defaults to the template image otherwise. """ f = io.BytesIO() @@ -519,29 +519,29 @@ class TestVariantsImages(common.TestProductCommon): f.seek(0) image_black = base64.b64encode(f.read()) - images = self.variants.mapped('image_original') + images = self.variants.mapped('image_1920') self.assertEqual(len(set(images)), 4) variant_no_image = self.variants[0] - self.assertFalse(variant_no_image.image) - self.template.image = image_black + self.assertFalse(variant_no_image.image_1920) + self.template.image_1920 = image_black # the first has no image variant, all the others do - self.assertFalse(variant_no_image.image_raw_original) + self.assertFalse(variant_no_image.image_variant_max) self.assertTrue(all(images[1:])) # template image is the same as this one, since it has no image variant - self.assertEqual(variant_no_image.image, self.template.image) + self.assertEqual(variant_no_image.image_1920, self.template.image_1920) # having changed the template image should not have changed these - self.assertEqual(images[1:], self.variants.mapped('image')[1:]) + self.assertEqual(images[1:], self.variants.mapped('image_1920')[1:]) def test_update_images_with_archived_variants(self): """Update images after variants have been archived""" self.variants[1:].write({'active': False}) - self.variants[0].image = self.images['red'] - self.assertEqual(self.template.image, self.images['red']) - self.assertEqual(self.variants[0].image_raw_original, False) - self.assertEqual(self.variants[0].image, self.images['red']) + self.variants[0].image_1920 = self.images['red'] + self.assertEqual(self.template.image_1920, self.images['red']) + self.assertEqual(self.variants[0].image_variant_max, False) + self.assertEqual(self.variants[0].image_1920, self.images['red']) class TestVariantsArchive(common.TestProductCommon): diff --git a/addons/product/views/product_template_views.xml b/addons/product/views/product_template_views.xml index 1540b133fe203995365226200ba0eab1c096c6f9..35678b7068942e7415de1bfade6baaa0a0233a85 100644 --- a/addons/product/views/product_template_views.xml +++ b/addons/product/views/product_template_views.xml @@ -68,7 +68,6 @@ <field name="arch" type="xml"> <kanban> <field name="id"/> - <field name="image_small"/> <field name="lst_price"/> <field name="product_variant_count"/> <field name="currency_id"/> @@ -78,7 +77,7 @@ <t t-name="kanban-box"> <div class="oe_kanban_global_click"> <div class="o_kanban_image"> - <img t-att-src="kanban_image('product.template', 'image_small', record.id.raw_value)" alt="Product"/> + <img t-att-src="kanban_image('product.template', 'image_64', record.id.raw_value)" alt="Product"/> </div> <div class="oe_kanban_details"> <strong class="o_kanban_record_title"> @@ -111,7 +110,7 @@ <field name="id"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('product.template', 'image_small', record.id.raw_value)" role="img" t-att-title="record.id.value" t-att-alt="record.id.value"/> + <img t-att-src="activity_image('product.template', 'image_64', record.id.raw_value)" role="img" t-att-title="record.id.value" t-att-alt="record.id.value"/> <div> <field name="name" display="full"/> <div t-if="record.default_code.value" class="text-muted"> diff --git a/addons/product/views/product_views.xml b/addons/product/views/product_views.xml index b495635b7cd57f703e298e6c286d9931cb55c67e..3acf80d169f53dc59508f3c062465897466800f1 100644 --- a/addons/product/views/product_views.xml +++ b/addons/product/views/product_views.xml @@ -21,7 +21,7 @@ <field name='is_product_variant' invisible='1'/> <field name='attribute_line_ids' invisible='1'/> <field name="id" invisible="True"/> - <field name="image" widget="image" class="oe_avatar" options="{'preview_image': 'image_medium'}"/> + <field name="image_1920" widget="image" class="oe_avatar" options="{'preview_image': 'image_128'}"/> <div class="oe_title"> <label class="oe_edit_only" for="name" string="Product Name"/> <h1><field name="name" placeholder="Product Name"/></h1> @@ -268,7 +268,7 @@ <div class="oe_button_box" name="button_box"/> <field name="active" invisible="1"/> <field name="id" invisible="1"/> - <field name="image" widget="image" class="oe_avatar" options="{'preview_image': 'image_medium'}"/> + <field name="image_1920" widget="image" class="oe_avatar" options="{'preview_image': 'image_128'}"/> <div class="oe_title"> <label class="oe_edit_only" for="name" string="Product Name"/> <h1><field name="name" readonly="1" placeholder="e.g. Odoo Enterprise Subscription"/></h1> @@ -418,7 +418,6 @@ <field name="arch" type="xml"> <kanban> <field name="id"/> - <field name="image_small"/> <field name="lst_price"/> <field name="activity_state"/> <progressbar field="activity_state" colors='{"planned": "success", "today": "warning", "overdue": "danger"}'/> @@ -426,7 +425,7 @@ <t t-name="kanban-box"> <div class="oe_kanban_global_click"> <div class="o_kanban_image"> - <img t-att-src="kanban_image('product.product', 'image_small', record.id.raw_value)" alt="Product"/> + <img t-att-src="kanban_image('product.product', 'image_64', record.id.raw_value)" alt="Product"/> </div> <div class="oe_kanban_details"> <strong class="o_kanban_record_title"> @@ -457,7 +456,7 @@ <field name="default_code"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('product.product', 'image_small', record.id.raw_value)" role="img" t-att-title="record.id.value" t-att-alt="record.id.value"/> + <img t-att-src="activity_image('product.product', 'image_64', record.id.raw_value)" role="img" t-att-title="record.id.value" t-att-alt="record.id.value"/> <div> <field name="name" display="full"/> <div t-if="record.default_code.value" class="text-muted"> diff --git a/addons/project/views/project_portal_templates.xml b/addons/project/views/project_portal_templates.xml index b76a27479b95d7e65b9b086a610959877c67fae9..2ac7e60469345588b854934486d59a0c625afc55 100644 --- a/addons/project/views/project_portal_templates.xml +++ b/addons/project/views/project_portal_templates.xml @@ -91,7 +91,7 @@ <h6>Customer</h6> <div class="row"> <div class="col flex-grow-0 pr-3"> - <img t-if="project.partner_id.image" class="rounded-circle mt-1 o_portal_contact_img" t-att-src="image_data_uri(project.partner_id.image)" alt="Contact"/> + <img t-if="project.partner_id.image_1024" class="rounded-circle mt-1 o_portal_contact_img" t-att-src="image_data_uri(project.partner_id.image_1024)" alt="Contact"/> <img t-else="" class="rounded-circle mt-1 o_portal_contact_img" src="/web/static/src/img/user_menu_avatar.png" alt="Contact"/> </div> <div class="col pl-sm-0"> @@ -103,7 +103,7 @@ <h6>Project Manager</h6> <div class="row"> <div class="col flex-grow-0 pr-3"> - <img t-if="project.user_id.image" class="rounded-circle mt-1 o_portal_contact_img" t-att-src="image_data_uri(project.user_id.image)" alt="Contact"/> + <img t-if="project.user_id.image_1024" class="rounded-circle mt-1 o_portal_contact_img" t-att-src="image_data_uri(project.user_id.image_1024)" alt="Contact"/> <img t-else="" class="rounded-circle mt-1 o_portal_contact_img" src="/web/static/src/img/user_menu_avatar.png" alt="Contact"/> </div> <div class="col pl-sm-0"> @@ -205,7 +205,7 @@ <strong>Assigned to</strong> <div class="row"> <div class="col flex-grow-0 pr-3"> - <img t-if="task.user_id.image" class="rounded-circle mt-1 o_portal_contact_img" t-att-src="image_data_uri(task.user_id.image)" alt="Contact"/> + <img t-if="task.user_id.image_1024" class="rounded-circle mt-1 o_portal_contact_img" t-att-src="image_data_uri(task.user_id.image_1024)" alt="Contact"/> <img t-else="" class="rounded-circle mt-1 o_portal_contact_img" src="/web/static/src/img/user_menu_avatar.png" alt="Contact"/> </div> <div class="col pl-md-0"> @@ -217,7 +217,7 @@ <strong>Reported by</strong> <div class="row"> <div class="col flex-grow-0 pr-3"> - <img t-if="task.partner_id.image" class="rounded-circle mt-1 o_portal_contact_img" t-att-src="image_data_uri(task.partner_id.image)" alt="Contact"/> + <img t-if="task.partner_id.image_1024" class="rounded-circle mt-1 o_portal_contact_img" t-att-src="image_data_uri(task.partner_id.image_1024)" alt="Contact"/> <img t-else="" class="rounded-circle mt-1 o_portal_contact_img" src="/web/static/src/img/user_menu_avatar.png" alt="Contact"/> </div> <div class="col pl-md-0"> diff --git a/addons/project/views/project_rating_templates.xml b/addons/project/views/project_rating_templates.xml index a016e3e77b229aac9fa8731f573ca5d3b2f24b12..a1b8613ccb3896c36146b8838003999c9510ab6d 100644 --- a/addons/project/views/project_rating_templates.xml +++ b/addons/project/views/project_rating_templates.xml @@ -77,8 +77,8 @@ <t t-foreach="partner_stats.values()" t-as="partner_stat"> <div class="row mt8" t-if="partner_stat['total']" title="Top 5 partner ratings of last 15 days."> <div class="col-md-1"> - <img t-if="partner_stat['rated_partner'].image" class="o_top_partner_image" t-att-src="image_data_uri(partner_stat['rated_partner'].image)" alt="Rated partner"/> - <img t-if="not partner_stat['rated_partner'].image" class="o_top_partner_image" src='/web/static/src/img/placeholder.png' alt="Placeholder"/> + <img t-if="partner_stat['rated_partner'].image_1024" class="o_top_partner_image" t-att-src="image_data_uri(partner_stat['rated_partner'].image_1024)" alt="Rated partner"/> + <img t-if="not partner_stat['rated_partner'].image_1024" class="o_top_partner_image" src='/web/static/src/img/placeholder.png' alt="Placeholder"/> </div> <div class="col-md-4 o_smiley_no_padding_right"> <span class="ml8" t-esc="partner_stat['rated_partner'].name"/> @@ -126,8 +126,8 @@ <div t-attf-id="rating_#{rating.id}" class="container d-none"> <div class="row"> <div class="col-lg-2"> - <img t-if="rating.partner_id.image" class="o_top_partner_image" t-att-src="image_data_uri(rating.partner_id.image)" alt="Rated partner"/> - <img t-if="not rating.partner_id.image" class="o_top_partner_image" src='/web/static/src/img/placeholder.png' alt="Placeholder"/> + <img t-if="rating.partner_id.image_1024" class="o_top_partner_image" t-att-src="image_data_uri(rating.partner_id.image_1024)" alt="Rated partner"/> + <img t-if="not rating.partner_id.image_1024" class="o_top_partner_image" src='/web/static/src/img/placeholder.png' alt="Placeholder"/> </div> <div class="col-lg-10"> <div class="mt4"> diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml index 6bdc873c97c117caf6f4a7f8c4239ce7b387dece..43734fc16aa68a02b8d59a46efeccce6fccb334a 100644 --- a/addons/project/views/project_views.xml +++ b/addons/project/views/project_views.xml @@ -238,7 +238,7 @@ </div> <div class="col-4"> <div class="oe_kanban_bottom_right"> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> </div> </div> </div> @@ -610,7 +610,7 @@ </div> <div class="oe_kanban_bottom_right"> <field name="kanban_state" widget="state_selection" groups="base.group_user"/> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar"/> </div> </div> </div> @@ -698,7 +698,7 @@ <field name="user_id"/> <templates> <div t-name="activity-box"> - <img t-att-src="activity_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value"/> + <img t-att-src="activity_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value"/> <div> <field name="name" display="full"/> <field name="project_id" muted="1" display="full" invisible="context.get('default_project_id', False)"/> diff --git a/addons/purchase/views/portal_templates.xml b/addons/purchase/views/portal_templates.xml index 6d7237666655510dce32e6b825a0af609eca5794..58bcee1741fd9b96c57ef3821f8da7f9bcff892a 100644 --- a/addons/purchase/views/portal_templates.xml +++ b/addons/purchase/views/portal_templates.xml @@ -103,7 +103,7 @@ <t t-set="current_subtotal" t-value="current_subtotal + ol.price_total" groups="account.group_show_line_subtotals_tax_included"/> <div t-if="not ol.display_type" class="row purchases_vertical_align"> <div class="col-lg-1 text-center"> - <img t-att-src="image_data_uri(resize_to_48(ol.product_id.image))" alt="Product"/> + <img t-att-src="image_data_uri(resize_to_48(ol.product_id.image_64))" alt="Product"/> </div> <div id='product_name' class="col-lg-5"> <span t-esc="ol.product_id.name"/> diff --git a/addons/purchase_requisition/views/purchase_requisition_views.xml b/addons/purchase_requisition/views/purchase_requisition_views.xml index 8ef7677c1ced2900927cc9f8e263bba569c5c4b6..6d031aa317b01296c853229e82725288012ac523 100644 --- a/addons/purchase_requisition/views/purchase_requisition_views.xml +++ b/addons/purchase_requisition/views/purchase_requisition_views.xml @@ -243,7 +243,7 @@ <field name="vendor_id"/> </div> <div class="oe_kanban_bottom_right"> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar float-right"/> </div> </div> </div> diff --git a/addons/sale/data/mail_data.xml b/addons/sale/data/mail_data.xml index c149738db3ac41a6b0ffeafecd2e52b5724e6504..05ef93eaaa48522023934cbb5d99b135714eefb7 100644 --- a/addons/sale/data/mail_data.xml +++ b/addons/sale/data/mail_data.xml @@ -154,7 +154,7 @@ <td colspan="4"><i>${line.name}</i></td> % else: <td style="width: 150px;"> - <img src="/web/image/product.product/${line.product_id.id}/image_small" width="64" alt="Product image"></img> + <img src="/web/image/product.product/${line.product_id.id}/image_64" width="64" alt="Product image"></img> </td> <td align="left">${line.product_id.name}</td> <td>${line.product_uom_qty}</td> diff --git a/addons/sale/data/sale_demo.xml b/addons/sale/data/sale_demo.xml index ecdd2681779a4bb91b0de6febf71ad4e9dd22833..ee66c68efd4cb3783ebfb8d0d61fe064d0698022 100644 --- a/addons/sale/data/sale_demo.xml +++ b/addons/sale/data/sale_demo.xml @@ -690,7 +690,7 @@ Thanks!</field> <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="company_id" eval="[]"/> - <field name="image" type="base64" file="sale/static/img/advance_product_0-image.jpg"/> + <field name="image_1920" type="base64" file="sale/static/img/advance_product_0-image.jpg"/> <field name="taxes_id" eval="[]"/> <field name="supplier_taxes_id" eval="[]"/> </record> diff --git a/addons/sale/models/product_template.py b/addons/sale/models/product_template.py index 1db9daaa627ae3b86ca30b0b07bd255dd6be73b8..257f9fa595e13e9df58682621143da7e6b98a568 100644 --- a/addons/sale/models/product_template.py +++ b/addons/sale/models/product_template.py @@ -252,12 +252,12 @@ class ProductTemplate(models.Model): ) list_price = product.price_compute('list_price')[product.id] price = product.price if pricelist else list_price - display_image = bool(product.image) + display_image = bool(product.image_1920) else: product_template = product_template.with_context(current_attributes_price_extra=[v.price_extra or 0.0 for v in combination]) list_price = product_template.price_compute('list_price')[product_template.id] price = product_template.price if pricelist else list_price - display_image = bool(product_template.image) + display_image = bool(product_template.image_1920) filtered_combination = combination._without_no_variant_attributes() if filtered_combination: diff --git a/addons/sale/static/src/js/variant_mixin.js b/addons/sale/static/src/js/variant_mixin.js index 219cd1ea81716dbc2d713327ebd57d93d8ba0aa2..36577e8dedd31fcbeb0b7ca0ea851b7c0649eff4 100644 --- a/addons/sale/static/src/js/variant_mixin.js +++ b/addons/sale/static/src/js/variant_mixin.js @@ -611,7 +611,7 @@ var VariantMixin = { _updateProductImage: function ($productContainer, displayImage, productId, productTemplateId) { var model = productId ? 'product.product' : 'product.template'; var modelId = productId || productTemplateId; - var imageUrl = '/web/image/{0}/{1}/' + (this._productImageField ? this._productImageField : 'image'); + var imageUrl = '/web/image/{0}/{1}/' + (this._productImageField ? this._productImageField : 'image_1024'); var imageSrc = imageUrl .replace("{0}", model) .replace("{1}", modelId); diff --git a/addons/sale/views/sale_portal_templates.xml b/addons/sale/views/sale_portal_templates.xml index b6264bb8534fb276f8e7dee667130b3594e80e1b..d67a37a52878b21557ff618ca69ce328b2844a43 100644 --- a/addons/sale/views/sale_portal_templates.xml +++ b/addons/sale/views/sale_portal_templates.xml @@ -184,8 +184,8 @@ <div class="small mb-1"><strong class="text-muted">Salesperson</strong></div> <div class="row flex-nowrap"> <div class="col flex-grow-0 pr-2"> - <img class="rounded-circle mr4 float-left o_portal_contact_img" t-if="sale_order.user_id.image" t-att-src="image_data_uri(sale_order.user_id.image)" alt="Contact"/> - <img class="rounded-circle mr4 float-left o_portal_contact_img" t-if="not sale_order.user_id.image" src="/web/static/src/img/placeholder.png" alt="Contact"/> + <img class="rounded-circle mr4 float-left o_portal_contact_img" t-if="sale_order.user_id.image_1024" t-att-src="image_data_uri(sale_order.user_id.image_1024)" alt="Contact"/> + <img class="rounded-circle mr4 float-left o_portal_contact_img" t-if="not sale_order.user_id.image_1024" src="/web/static/src/img/placeholder.png" alt="Contact"/> </div> <div class="col pl-0" style="min-width: 150px"> <span t-field="sale_order.user_id" t-options='{"widget": "contact", "fields": ["name", "phone"], "no_marker": True}'/> diff --git a/addons/sale_product_configurator/data/sale_demo.xml b/addons/sale_product_configurator/data/sale_demo.xml index 00683af885504efb3e996df387dc315d9063d340..117ebd6acc0d56b2c9af2e26d2d15b57bbd60f40 100644 --- a/addons/sale_product_configurator/data/sale_demo.xml +++ b/addons/sale_product_configurator/data/sale_demo.xml @@ -9,7 +9,7 @@ <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> <field name="description_sale">Office chairs can harm your floor: protect it.</field> - <field name="image" type="base64" file="sale/static/img/floor_protection-image.png"/> + <field name="image_1920" type="base64" file="sale/static/img/floor_protection-image.png"/> </record> <record id="product.product_product_4_product_template" model="product.template"> diff --git a/addons/sale_product_configurator/static/src/js/product_configurator_modal.js b/addons/sale_product_configurator/static/src/js/product_configurator_modal.js index 7d52b07b76d9ea0e8ff3fcf626b2d125e1dad2f9..c2687e79d0d8398ffa9c094e45392cbdddfbbc44 100644 --- a/addons/sale_product_configurator/static/src/js/product_configurator_modal.js +++ b/addons/sale_product_configurator/static/src/js/product_configurator_modal.js @@ -60,7 +60,7 @@ var OptionalProductsModal = Dialog.extend(ServicesMixin, VariantMixin, { this.pricelistId = params.pricelistId; this.previousModalHeight = params.previousModalHeight; this.dialogClass = 'oe_optional_products_modal'; - this._productImageField = 'image_medium'; + this._productImageField = 'image_128'; // reset any previously populated properties maps optionalProductsMap = {}; @@ -209,7 +209,7 @@ var OptionalProductsModal = Dialog.extend(ServicesMixin, VariantMixin, { var productId = this.rootProduct.product_id; $modalContent .find('img:first') - .attr("src", "/web/image/product.product/" + productId + "/image_medium"); + .attr("src", "/web/image/product.product/" + productId + "/image_128"); if (this.rootProduct && (this.rootProduct.product_custom_attribute_values || diff --git a/addons/sale_product_configurator/views/templates.xml b/addons/sale_product_configurator/views/templates.xml index ba03bbb30d194e3219f283b7200f9fb46e7aa0c6..4a849dc784647b93640701aac4d281e66f2e5af4 100644 --- a/addons/sale_product_configurator/views/templates.xml +++ b/addons/sale_product_configurator/views/templates.xml @@ -54,8 +54,8 @@ </div> <div class="col-lg-1 d-inline-block"></div> <div class="col-lg-5 d-inline-block align-top text-left"> - <img t-if="product_variant" t-att-src="'/web/image/product.product/%s/image' % product_variant.id" class="d-block product_detail_img" alt="Product Image"/> - <img t-else="" t-att-src="'/web/image/product.template/%s/image' % product.id" class="d-block product_detail_img" alt="Product Image"/> + <img t-if="product_variant" t-att-src="'/web/image/product.product/%s/image_1024' % product_variant.id" class="d-block product_detail_img" alt="Product Image"/> + <img t-else="" t-att-src="'/web/image/product.template/%s/image_1024' % product.id" class="d-block product_detail_img" alt="Product Image"/> </div> </t> <t t-else=""> @@ -87,8 +87,8 @@ <input type="hidden" class="product_template_id" t-att-value="product.product_tmpl_id.id"/> <input type="hidden" class="product_id" t-att-value="product_variant.id"/> <td class='td-img'> - <img t-if="product_variant" t-att-src="'/web/image/product.product/%s/image_medium' % product_variant.id" alt="Product Image"/> - <img t-else="" t-att-src="'/web/image/product.template/%s/image_medium' % product.id" alt="Product Image"/> + <img t-if="product_variant" t-att-src="'/web/image/product.product/%s/image_128' % product_variant.id" alt="Product Image"/> + <img t-else="" t-att-src="'/web/image/product.template/%s/image_128' % product.id" alt="Product Image"/> </td> <td class='td-product_name'> <strong t-esc="combination_info['display_name']"/> @@ -165,8 +165,8 @@ <td class="td-img"> <input type="hidden" class="product_template_id" t-att-value="product.id"/> <input type="hidden" class="product_id" t-attf-name="optional-product-#{product.id}" t-att-value="product_variant.id"/> - <img t-if="product_variant" t-att-src="'/web/image/product.product/%s/image_medium' % product_variant.id" class="variant_image" alt="Product Image"/> - <img t-else="" t-att-src="'/web/image/product.template/%s/image_medium' % product.id" class="variant_image" alt="Product Image"/> + <img t-if="product_variant" t-att-src="'/web/image/product.product/%s/image_128' % product_variant.id" class="variant_image" alt="Product Image"/> + <img t-else="" t-att-src="'/web/image/product.template/%s/image_128' % product.id" class="variant_image" alt="Product Image"/> </td> <td class='td-product_name' colspan="2"> <div class="float-left"> diff --git a/addons/sales_team/views/crm_team_views.xml b/addons/sales_team/views/crm_team_views.xml index 7d60b8f3e261f9506acec2115ab61abb4dc125ae..a31b0e7ab2f88d94adc71bd67e5ee62958b8df17 100644 --- a/addons/sales_team/views/crm_team_views.xml +++ b/addons/sales_team/views/crm_team_views.xml @@ -87,7 +87,7 @@ <t t-name="kanban-box"> <div class="oe_kanban_global_click" style="max-width: 200px"> <div class="o_kanban_record_top"> - <img t-att-src="kanban_image('res.users', 'image_small', record.id.raw_value)" height="40" width="40" class="oe_avatar oe_kanban_avatar_smallbox mb0" alt="Avatar"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.id.raw_value)" height="40" width="40" class="oe_avatar oe_kanban_avatar_smallbox mb0" alt="Avatar"/> <div class="o_kanban_record_headings ml8"> <strong class="o_kanban_record_title"><field name="name"/></strong> </div> diff --git a/addons/stock/data/stock_demo.xml b/addons/stock/data/stock_demo.xml index ceaf8bad0aa83f7a4821a14b678de8e9b86acca1..2566a0979bd420c3b86ffeddeed76419157cc7e7 100644 --- a/addons/stock/data/stock_demo.xml +++ b/addons/stock/data/stock_demo.xml @@ -152,7 +152,7 @@ <field name="parent_id" ref="res_partner_company_1"/> <field name="email">jeff.lawson52@example.com</field> <field name="phone">(461)-417-6587</field> - <field name="image" type="base64" file="stock/static/img/res_partner_address_41.jpg"/> + <field name="image_1920" type="base64" file="stock/static/img/res_partner_address_41.jpg"/> </record> <record id="res_company_1" model="res.company"> diff --git a/addons/stock/data/stock_demo2.xml b/addons/stock/data/stock_demo2.xml index 3ed916236e051a0f1b59cc7c46839e5226aec3de..198d41714be2aa00e15d69213f8ad0b325360dbe 100644 --- a/addons/stock/data/stock_demo2.xml +++ b/addons/stock/data/stock_demo2.xml @@ -35,7 +35,7 @@ <field name="tracking">lot</field> <field name="uom_id" ref="uom.product_uom_unit"/> <field name="uom_po_id" ref="uom.product_uom_unit"/> - <field name="image" type="base64" file="stock/static/img/cable_management.png"/> + <field name="image_1920" type="base64" file="stock/static/img/cable_management.png"/> </record> <record id="lot_product_cable_management" model="stock.production.lot"> diff --git a/addons/stock_landed_costs/views/stock_landed_cost_views.xml b/addons/stock_landed_costs/views/stock_landed_cost_views.xml index fde86dfccdf6536b43419edb886f1cfa0195c8eb..8169f4b3f1fae569c2a1b8fa6c5e207cb1f6205b 100644 --- a/addons/stock_landed_costs/views/stock_landed_cost_views.xml +++ b/addons/stock_landed_costs/views/stock_landed_cost_views.xml @@ -205,7 +205,7 @@ <form string="Landed Costs"> <sheet> <widget name="web_ribbon" text="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/> - <field name="image_medium" widget="image" class="oe_avatar"/> + <field name="image_1920" widget="image" class="oe_avatar" options="{'image_preview': 'image_128'}"/> <div class="oe_title"> <div class="oe_edit_only"> <label for="name" name='label_name' string="Product Name"/> diff --git a/addons/stock_picking_batch/views/stock_picking_batch_views.xml b/addons/stock_picking_batch/views/stock_picking_batch_views.xml index 12d9c7a3fea3dd1ef3ffa26fa74fa26b07b481fd..0c677a986f8e00e752b8b07e3cb129dc797054f0 100644 --- a/addons/stock_picking_batch/views/stock_picking_batch_views.xml +++ b/addons/stock_picking_batch/views/stock_picking_batch_views.xml @@ -75,7 +75,7 @@ <div class="o_kanban_record_bottom"> <div class="oe_kanban_bottom_left"/> <div class="oe_kanban_bottom_right"> - <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar"/> + <img t-att-src="kanban_image('res.users', 'image_64', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value" width="24" height="24" class="oe_kanban_avatar"/> </div> </div> </div> diff --git a/addons/survey/views/gamification_badge_views.xml b/addons/survey/views/gamification_badge_views.xml index e9f03f859365e22231fbc0d5361ea668df686a8f..fa404edf6e223464ed7c0d6bdbd6e2a3a0116bd4 100644 --- a/addons/survey/views/gamification_badge_views.xml +++ b/addons/survey/views/gamification_badge_views.xml @@ -8,7 +8,7 @@ <form string="Badge"> <sheet> <div class="oe_button_box" name="button_box"/> - <field name="image" widget='image' class="oe_avatar"/> + <field name="image_1920" widget="image" class="oe_avatar" options="{'preview_image': 'image_128'}"/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1> diff --git a/addons/survey/views/survey_templates.xml b/addons/survey/views/survey_templates.xml index 605fd56ef60d9847a6ef93648c102fa8e2f13a3d..569da41c1c596df9d1afc04e90dd8a32fca48ed0 100644 --- a/addons/survey/views/survey_templates.xml +++ b/addons/survey/views/survey_templates.xml @@ -51,7 +51,7 @@ </div> </div> <div class="col-6 text-center" t-if="survey.certification_give_badge and answer.quizz_passed"> - <img t-att-src="'/web/image/gamification.badge/%s/image_medium' % survey.certification_badge_id.id"/> + <img t-att-src="'/web/image/gamification.badge/%s/image_128' % survey.certification_badge_id.id"/> <div>You received the badge <span class="font-weight-bold" t-esc="survey.certification_badge_id.name"/>!</div> </div> </div> diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 85f01e3c83d45b788111bc75d37fae400ae0354b..11996d46eccbf1f7ac8cc74583fbae11cc846ffb 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1186,7 +1186,7 @@ class Binary(http.Controller): '/web/partner_image/<int:rec_id>', '/web/partner_image/<int:rec_id>/<string:field>', '/web/partner_image/<int:rec_id>/<string:field>/<string:model>/'], type='http', auth="public") - def content_image_partner(self, rec_id, field='image_small', model='res.partner', **kwargs): + def content_image_partner(self, rec_id, field='image_64', model='res.partner', **kwargs): # other kwargs are ignored on purpose return self._content_image(id=rec_id, model='res.partner', field=field, placeholder='user_placeholder.jpg') diff --git a/addons/web/static/src/js/chrome/user_menu.js b/addons/web/static/src/js/chrome/user_menu.js index c2d19b7a879389751a9cd4a12638359130c1489f..3b93bbd9c3bd3eb2f51cc88dbe7bccd76895298e 100644 --- a/addons/web/static/src/js/chrome/user_menu.js +++ b/addons/web/static/src/js/chrome/user_menu.js @@ -46,7 +46,7 @@ var UserMenu = Widget.extend({ self.$('.oe_topbar_name').text(topbar_name); var avatar_src = session.url('/web/image', { model:'res.users', - field: 'image_small', + field: 'image_64', id: session.uid, }); $avatar.attr('src', avatar_src); diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 322168a724193fe79a02c1083c9e8e669c7df5b7..dbafc45e592f1f600c84379013a615bf14f0aff3 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1833,7 +1833,7 @@ var FieldBinaryImage = AbstractFieldBinary.extend({ this.$el.addClass(this.attrs.class); } - var urlThumb = this._getImageUrl(this.model, this.res_id, 'image_medium', unique); + var urlThumb = this._getImageUrl(this.model, this.res_id, 'image_128', unique); this.$el.empty(); $img = this.$el; diff --git a/addons/web/static/src/js/views/calendar/calendar_view.js b/addons/web/static/src/js/views/calendar/calendar_view.js index 2ee927a4af09fe3e519d03b22dc3217db59ff494..af4a0baa2ec5eeaaa689d7f8444afe6276dcc285 100644 --- a/addons/web/static/src/js/views/calendar/calendar_view.js +++ b/addons/web/static/src/js/views/calendar/calendar_view.js @@ -103,7 +103,7 @@ var CalendarView = AbstractView.extend({ }; if (fields[fieldName].relation) { if (['res.users', 'res.partner'].indexOf(fields[fieldName].relation) !== -1) { - filters[fieldName].avatar_field = 'image_small'; + filters[fieldName].avatar_field = 'image_64'; } filters[fieldName].avatar_model = fields[fieldName].relation; } diff --git a/addons/web/tests/test_image.py b/addons/web/tests/test_image.py index bf1bb06f8e6c655bdd35b0c8b5fa3959c08aed64..454f237ce1dbe8bd12507de5a7a43ab53fb8f7cc 100644 --- a/addons/web/tests/test_image.py +++ b/addons/web/tests/test_image.py @@ -20,17 +20,17 @@ class TestImage(HttpCase): self.assertEqual(image.size, (150, 150)) # CASE: resize placeholder to small - response = self.url_open('/web/image/fake/0/image_small') + response = self.url_open('/web/image/fake/0/image_64') image = Image.open(io.BytesIO(response.content)) self.assertEqual(image.size, (64, 64)) # CASE: resize placeholder to medium - response = self.url_open('/web/image/fake/0/image_medium') + response = self.url_open('/web/image/fake/0/image_128') image = Image.open(io.BytesIO(response.content)) self.assertEqual(image.size, (128, 128)) # CASE: resize placeholder to large - response = self.url_open('/web/image/fake/0/image_large') + response = self.url_open('/web/image/fake/0/image_256') image = Image.open(io.BytesIO(response.content)) self.assertEqual(image.size, (256, 256)) diff --git a/addons/website/tests/template_qweb_test.xml b/addons/website/tests/template_qweb_test.xml index 423c8d3212e6cb89d9844f849200e91f8cde1851..ac7dd4e390fbcf34110e3adde60c4411e755910b 100644 --- a/addons/website/tests/template_qweb_test.xml +++ b/addons/website/tests/template_qweb_test.xml @@ -28,7 +28,7 @@ <a href="/web/content/local_link">x</a> <span t-attf-style="background-image: url('/web/image/2')" t-att-empty="False">xxx</span> <div widget="html" t-field="user.signature"/> - <div widget="image" t-field="user.image" t-options="{'widget': 'image'}"/> + <div widget="image" t-field="user.image_1920" t-options="{'widget': 'image'}"/> </body> </html> </template> diff --git a/addons/website/tests/test_qweb.py b/addons/website/tests/test_qweb.py index 8e2eb382a408e8f5b9b7d995de787efb447c4c6d..9386c9f81e346fd6e59040ff73def6432738bebd 100644 --- a/addons/website/tests/test_qweb.py +++ b/addons/website/tests/test_qweb.py @@ -57,7 +57,7 @@ class TestQweb(TransactionCase): <div widget="html"><span class="toto"> span<span class="fa"></span><img src="http://test.cdn/web/image/1"> </span></div> - <div widget="image"><img src="http://test.cdn/web/image/res.users/%(user_id)s/image/%(filename)s" class="img img-fluid" alt="%(alt)s"/></div> + <div widget="image"><img src="http://test.cdn/web/image/res.users/%(user_id)s/image_1920/%(filename)s" class="img img-fluid" alt="%(alt)s"/></div> </body> </html>""" % { "js": attachments[0].url, diff --git a/addons/website_blog/models/website_blog.py b/addons/website_blog/models/website_blog.py index 57a731e444b7aa82e4694e663aa98a089f666556..6bf40b32f63055da0afa750156fed07d19b5c971 100644 --- a/addons/website_blog/models/website_blog.py +++ b/addons/website_blog/models/website_blog.py @@ -160,7 +160,7 @@ class BlogPost(models.Model): create_uid = fields.Many2one('res.users', 'Created by', index=True, readonly=True) write_date = fields.Datetime('Last Updated on', index=True, readonly=True) write_uid = fields.Many2one('res.users', 'Last Contributor', index=True, readonly=True) - author_avatar = fields.Binary(related='author_id.image_small', string="Avatar", readonly=False) + author_avatar = fields.Binary(related='author_id.image_64', string="Avatar", readonly=False) visits = fields.Integer('No of Views', copy=False) ranking = fields.Float(compute='_compute_ranking', string='Ranking') diff --git a/addons/website_blog/static/src/js/website_blog.editor.js b/addons/website_blog/static/src/js/website_blog.editor.js index 2eedfc78b2e24f6ce533a01bfcd18189dbaa1c85..1342d32201f02097ac1d0458485107af151ca853 100644 --- a/addons/website_blog/static/src/js/website_blog.editor.js +++ b/addons/website_blog/static/src/js/website_blog.editor.js @@ -127,7 +127,7 @@ options.registry.many2one.include({ var $img = $(this).find('img'); var css = window.getComputedStyle($img[0]); $img.css({ width: css.width, height: css.height }); - $img.attr('src', '/web/image/res.partner/'+self.ID+'/image'); + $img.attr('src', '/web/image/res.partner/'+self.ID+'/image_1024'); }); setTimeout(function () { $nodes.removeClass('o_dirty'); },0); } diff --git a/addons/website_blog/views/website_blog_views.xml b/addons/website_blog/views/website_blog_views.xml index 91c317c8f0ba65db5d6e201b9fcec1a5902f98eb..7152b2c299bb03e022256da6bbb99f6a02d4dee4 100644 --- a/addons/website_blog/views/website_blog_views.xml +++ b/addons/website_blog/views/website_blog_views.xml @@ -143,7 +143,7 @@ <i class="fa fa-clock-o" role="img" aria-label="Post date" title="Post date"/><span t-esc="record.post_date.value"/> </div> <div class="col-4 text-right"> - <img t-att-src="kanban_image('res.partner', 'image_small', record.author_id.raw_value)" t-att-title="record.author_id.value" t-att-alt="record.author_id.value" width="24" height="24" class="oe_kanban_avatar"/> + <img t-att-src="kanban_image('res.partner', 'image_64', record.author_id.raw_value)" t-att-title="record.author_id.value" t-att-alt="record.author_id.value" width="24" height="24" class="oe_kanban_avatar"/> </div> </div> </div> diff --git a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml index 822678fa8d7099bcb6b219982ceab01be9dbc68c..013944362fa0d24778ce2eda7440c845b9d76ba4 100644 --- a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml +++ b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml @@ -82,7 +82,7 @@ </t> <div class="media mt-3"> <a t-attf-href="/partners/#{slug(partner)}?#{current_grade and 'grade_id=%s&' % current_grade.id}#{current_country and 'country_id=%s' % current_country.id}" - t-field="partner.image_medium" + t-field="partner.image_128" t-options='{"widget": "image", "class": "mr-3"}' ></a> <div class="media-body o_partner_body" style="min-height: 64px;"> @@ -164,7 +164,7 @@ <t t-if="any([p.website_published for p in partner.implemented_partner_ids])"> <h3 id="references">References</h3> <div t-foreach="partner.implemented_partner_ids" t-if="reference.website_published" t-as="reference" class="media mt-3"> - <span t-field="reference.image_medium" t-options='{"widget": "image", "class": "d-block mr-3"}'/> + <span t-field="reference.image_128" t-options='{"widget": "image", "class": "d-block mr-3"}'/> <div class="media-body" style="min-height: 64px;"> <span t-field="reference.self"/> <div t-field='reference.website_short_description'/> diff --git a/addons/website_customer/views/website_customer_templates.xml b/addons/website_customer/views/website_customer_templates.xml index 9cd668d901dde7d829a3539a83a35ad6f1c7020a..8a5c917c1d16094f6bf5c3fb9b918743161e5e76 100644 --- a/addons/website_customer/views/website_customer_templates.xml +++ b/addons/website_customer/views/website_customer_templates.xml @@ -36,7 +36,7 @@ <t t-foreach="partners" t-as="partner"> <div class="media mt-3"> <a t-attf-href="/customers/#{slug(partner)}" - t-field="partner.image_medium" + t-field="partner.image_128" t-options='{"widget": "image", "class": "mr-3"}' ></a> <div class="media-body" style="min-height: 64px;"> @@ -197,7 +197,7 @@ </a> </h4> <div><a t-attf-href="/partners/#{slug(partner.assigned_partner_id)}" - t-field="partner.assigned_partner_id.image_medium" + t-field="partner.assigned_partner_id.image_128" t-options='{"widget": "image", "class": "d-block mx-auto"}' /> </div> @@ -218,7 +218,7 @@ <div t-foreach="partner.implemented_partner_ids" t-as="reference" class="media mt-3"> <t t-if="reference.website_published"> <a t-attf-href="/customers/#{slug(reference)}"> - <span t-field="reference.image_medium" t-options='{"widget": "image", "class": "d-block mr-3"}'/> + <span t-field="reference.image_128" t-options='{"widget": "image", "class": "d-block mr-3"}'/> </a> <div class="media-body" style="min-height: 64px;"> <a t-attf-href="/customers/#{slug(reference)}"> diff --git a/addons/website_event_track/models/event_track.py b/addons/website_event_track/models/event_track.py index 6f0a72d31c60023ccfe7b37fef24bfae47464535..20b146f0f845050dc4e6a0db5dc3689e31d6c1b6 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, readonly=False) + image = fields.Image("Image", related='partner_id.image_128', store=True, readonly=False) @api.depends('name') def _compute_website_url(self): @@ -202,4 +202,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, readonly=False) + image_128 = fields.Image(string="Logo", related='partner_id.image_128', store=True, readonly=False) diff --git a/addons/website_event_track/views/event_track_templates.xml b/addons/website_event_track/views/event_track_templates.xml index 6e55bb1c0b223f3e5005748a4e53f1d2c09e279a..cf924566f1f5cb6c71438a57bf791b8f21c96c3c 100644 --- a/addons/website_event_track/views/event_track_templates.xml +++ b/addons/website_event_track/views/event_track_templates.xml @@ -18,7 +18,7 @@ <div t-attf-class="col-sm-6 col-lg-#{(len(event.sponsor_ids) > 6) and 2 or (12 // len(event.sponsor_ids))} text-center mb16 oe_sponsor" t-foreach="event.sponsor_ids" t-as="sponsor"> <t t-if="sponsor.url"> <a t-att-href="sponsor.url" style="position: relative; display: inline-block;" class="bg-white"> - <span t-field="sponsor.image_medium" + <span t-field="sponsor.image_128" t-options='{"widget": "image", "class": "shadow"}'/> <div class="ribbon-wrapper"> <div t-field="sponsor.sponsor_type_id" t-attf-class="ribbon ribbon_#{sponsor.sponsor_type_id.name}"/> @@ -27,7 +27,7 @@ </t> <t t-if="not sponsor.url"> <span style="position: relative; display: inline-block;" class="bg-white"> - <span t-field="sponsor.image_medium" + <span t-field="sponsor.image_128" t-options='{"widget": "image", "class": "shadow"}'/> <div class="ribbon-wrapper"> <div t-field="sponsor.sponsor_type_id" t-attf-class="ribbon ribbon_#{sponsor.sponsor_type_id.name}"/> @@ -242,7 +242,7 @@ <div t-if="track.partner_id" class="mt32"> <div class="row"> <div class="col-md-2"> - <span t-field="track.partner_id.sudo().image_medium" + <span t-field="track.partner_id.sudo().image_128" t-options='{"widget": "image", "class": "rounded-circle"}'/> </div><div class="col-md-10"> <h4 t-field="track.partner_id.name" class="mb4"/> diff --git a/addons/website_event_track/views/event_track_views.xml b/addons/website_event_track/views/event_track_views.xml index 5ec6624b0c7f172020a0955a727fa70c04eb38c3..599d304d4e66f72f562a6190953f325e1ee6195f 100644 --- a/addons/website_event_track/views/event_track_views.xml +++ b/addons/website_event_track/views/event_track_views.xml @@ -44,7 +44,7 @@ </div> <div class="oe_kanban_bottom_right"> <field name="kanban_state" widget="state_selection" groups="base.group_user"/> - <img t-att-src="kanban_image('res.partner', 'image_small', record.partner_id.raw_value)" + <img t-att-src="kanban_image('res.partner', 'image_64', record.partner_id.raw_value)" t-att-title="record.partner_id.value" t-att-alt="record.partner_id.value" width="24" height="24" class="oe_kanban_avatar"/> </div> diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 3bd01177ec70092298e6093c16d15730a5341ef6..8056381da9608dd67810504b83c931b9a65d3d2a 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -388,7 +388,7 @@ class Post(models.Model): res = super(Post, self)._default_website_meta() res['default_opengraph']['og:title'] = res['default_twitter']['twitter:title'] = self.name res['default_opengraph']['og:description'] = res['default_twitter']['twitter:description'] = self.plain_content - res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = "/web/image/res.users/%s/image" % (self.create_uid.id) + res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = "/web/image/res.users/%s/image_1024" % (self.create_uid.id) res['default_twitter']['twitter:card'] = 'summary' res['default_meta_description'] = self.plain_content return res diff --git a/addons/website_forum/views/forum.xml b/addons/website_forum/views/forum.xml index ff8ad6c22561ad456d23bbbc0d2857452c89ddc5..1c46079b518711c94e70bf5cf13a1fd72a8c3242 100644 --- a/addons/website_forum/views/forum.xml +++ b/addons/website_forum/views/forum.xml @@ -29,7 +29,7 @@ <form string="Forum"> <sheet> <widget name="web_ribbon" text="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/> - <field name="image" widget="image" options="{'preview_image': 'image_medium'}" class="oe_avatar"/> + <field name="image_1920" widget="image" options="{'preview_image': 'image_128'}" class="oe_avatar"/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1> diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index f971c068f8e3d0987383e553c4bb8c4e77eb4a62..e5737e037d1caf81ca580499695b795acfe1d27a 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -73,7 +73,7 @@ <div class="card bg-secondary" t-if="question"> <h6 class="card-header"><b>Writer</b></h6> <div class="card-body o_card_people"> - <img class="o_wforum_people_photo_container d-block mx-auto mb-3" t-attf-src="/web/image/res.users/#{question.create_uid.id}/image_medium"/> + <img class="o_wforum_people_photo_container d-block mx-auto mb-3" t-attf-src="/web/image/res.users/#{question.create_uid.id}/image_128"/> <h6 class="text-center"> <b><i class="fa fa-diamond text-secondary"/> <t t-esc="question.create_uid.sudo().karma"/></b> <b><a t-attf-href="/forum/#{slug(forum)}/user/#{question.create_uid.sudo().id}" t-field="question.create_uid" t-options='{"widget": "contact", "fields": ["name", "country_id"]}'/></b> @@ -397,9 +397,9 @@ <h1 class="card-header h6 font-weight-bold bg-white" t-field="forum.name"/> <div class="card-img-bottom embed-responsive embed-responsive-16by9 o_wforum_forum_card_bg"> - <div t-if="forum.image" + <div t-if="forum.image_256" class="oe_img_bg embed-responsive-item" - t-attf-style="background-image: url(/web/image/forum.forum/#{forum.id}/image_large); background-position: center;"/> + t-attf-style="background-image: url(/web/image/forum.forum/#{forum.id}/image_256); background-position: center;"/> </div> </div> </a> @@ -913,7 +913,7 @@ <t t-call="website_forum.forum_user_tooltip"/> </div> <a t-att-href="user_profile_url" class="o_forum_user_info"> - <img class="float-left o_forum_avatar" t-attf-src="/web/image/res.users/#{answer.create_uid.id}/image_medium" alt="Avatar"/> + <img class="float-left o_forum_avatar" t-attf-src="/web/image/res.users/#{answer.create_uid.id}/image_128" alt="Avatar"/> </a> <a t-att-href="user_profile_url" t-field="answer.create_uid" @@ -969,7 +969,7 @@ <div class="o_forum_user_bio text-left card"> <div class="card-body"> <a t-att-href="user_profile_url"> - <img class="float-left img rounded o_forum_avatar_big" t-attf-src="/web/image/res.users/#{answer.create_uid.id}/image_medium" alt="Avatar"/> + <img class="float-left img rounded o_forum_avatar_big" t-attf-src="/web/image/res.users/#{answer.create_uid.id}/image_128" alt="Avatar"/> </a> <div class="o_forum_tooltip_header"> <h4 class="o_forum_tooltip_heading"><a t-att-href="user_profile_url" @@ -1126,7 +1126,7 @@ <input type="checkbox" t-att-value="user.id" class="custom-control-input" t-attf-id="user_#{user.id}"/> <label class="custom-control-label" t-attf-for="user_#{user.id}"> <div class="col-11 d-inline-flex"> - <img class="d-inline img o_forum_avatar" t-attf-src="/web/image/res.users/#{user.id}/image_medium" alt="Avatar"/> + <img class="d-inline img o_forum_avatar" t-attf-src="/web/image/res.users/#{user.id}/image_128" alt="Avatar"/> <b t-esc="user.name" class="d-inline"></b> </div> </label> diff --git a/addons/website_hr_recruitment/views/website_hr_recruitment_templates.xml b/addons/website_hr_recruitment/views/website_hr_recruitment_templates.xml index dd2b6504ea7f10fa307e02b5c3a261fca123d4b1..c25a60b78f8d88c8d5c33c1839a7c1b6271965e6 100644 --- a/addons/website_hr_recruitment/views/website_hr_recruitment_templates.xml +++ b/addons/website_hr_recruitment/views/website_hr_recruitment_templates.xml @@ -424,7 +424,7 @@ <h3 class="mb32 text-center">Your application has been sent to:</h3> </div> <div class="col-lg-1 offset-lg-4"> - <p t-field="responsible.image_small" t-options="{'widget': 'image', 'class': 'rounded-circle d-block mx-auto'}"/> + <p t-field="responsible.image_64" t-options="{'widget': 'image', 'class': 'rounded-circle d-block mx-auto'}"/> </div> <div class="col-lg-5 o_responsible_data"> <h4 class="mt0" t-field="responsible.name"/> diff --git a/addons/website_livechat/views/website_livechat.xml b/addons/website_livechat/views/website_livechat.xml index 2cc0dc35f6f5b9b6fbb1787247bca539e2bb012a..75e884bdcf168209fc712067306cda3bc88b0209 100644 --- a/addons/website_livechat/views/website_livechat.xml +++ b/addons/website_livechat/views/website_livechat.xml @@ -146,13 +146,13 @@ <h3>The Team</h3> <t t-foreach="team" t-as="user"> <div class="media mt-3"> - <t t-if="user.image_small"> + <t t-if="user.image_64"> <t t-if="user.livechat_username"> - <img t-att-src="user.image_small and image_data_uri(user.image_small) or '/web/static/src/img/placeholder.png'" + <img t-att-src="user.image_64 and image_data_uri(user.image_64) or '/web/static/src/img/placeholder.png'" class="rounded o_livechat_operator_avatar" t-att-alt="user.livechat_username"/> </t> <t t-else=""> - <img t-att-src="user.image_small and image_data_uri(user.image_small) or '/web/static/src/img/placeholder.png'" + <img t-att-src="user.image_64 and image_data_uri(user.image_64) or '/web/static/src/img/placeholder.png'" class="rounded o_livechat_operator_avatar" t-att-alt="user.name"/> </t> </t> @@ -214,7 +214,7 @@ <t t-foreach="channels" t-as="channel"> <div t-attf-class="media#{' mt-3' if channel_index else ''}"> <a t-attf-href="/livechat/channel/#{ slug(channel)}"> - <img t-att-src="channel.image_small and image_data_uri(channel.image_small) or '/web/static/src/img/placeholder.png'" t-att-alt="channel.name" /> + <img t-att-src="channel.image_64 and image_data_uri(channel.image_64) or '/web/static/src/img/placeholder.png'" t-att-alt="channel.name" /> </a> <div class="media-body"> <h4><t t-esc="channel.name"/></h4> diff --git a/addons/website_mail_channel/views/website_mail_channel_templates.xml b/addons/website_mail_channel/views/website_mail_channel_templates.xml index 7b439bb0b913a6a8c810a3f82bb6d4757268ee4b..d2b6e82a4c909fdd8a5f99a005078e8138d8057d 100644 --- a/addons/website_mail_channel/views/website_mail_channel_templates.xml +++ b/addons/website_mail_channel/views/website_mail_channel_templates.xml @@ -33,7 +33,7 @@ </div> <div class="row mt8" t-foreach="groups" t-as="group"> <div class="col-lg-3"> - <img t-att-src="website.image_url(group, 'image_small')" class="float-left" alt="Group"/> + <img t-att-src="website.image_url(group, 'image_64')" class="float-left" alt="Group"/> <strong><a t-attf-href="/groups/#{ slug(group) }" t-esc="group.name"/></strong><br /> <t t-if="group.alias_id and group.alias_id.alias_name and group.alias_id.alias_domain"> <i class='fa fa-envelope-o' role="img" aria-label="Alias" title="Alias"/> diff --git a/addons/website_membership/views/website_membership_templates.xml b/addons/website_membership/views/website_membership_templates.xml index 8939d1adf98ce0b59476cec28b53f150a41153e6..3ff095b31234bdc06293c9f632cc43c393ffbe91 100644 --- a/addons/website_membership/views/website_membership_templates.xml +++ b/addons/website_membership/views/website_membership_templates.xml @@ -54,7 +54,7 @@ <t t-set="partner" t-value="partners[partner_id]"/> <div class="media mt-3"> <a t-attf-href="/members/#{slug(partner)}" - t-field="partner.image_small" + t-field="partner.image_64" t-options='{"widget": "image", "class": "media-object mr-3"}' ></a> <div class="media-body" style="min-height: 64px;"> diff --git a/addons/website_partner/views/website_partner_templates.xml b/addons/website_partner/views/website_partner_templates.xml index 2f5c58b1dee449d7d996df69606ecd521448016a..60adb04ee2dc92646b67bc9951b1d0f4052f3384 100644 --- a/addons/website_partner/views/website_partner_templates.xml +++ b/addons/website_partner/views/website_partner_templates.xml @@ -17,7 +17,7 @@ <template id="partner_detail" name="Partner Details"> <h1 class="col-lg-12 text-center" id="partner_name" t-field="partner.display_name"/> <div class="col-lg-4"> - <div t-field="partner.image" t-options='{"widget": "image", "class": "d-block mx-auto mb16", "max_width": 512}'/> + <div t-field="partner.image_1920" t-options='{"widget": "image", "preview_image": "image_512", "class": "d-block mx-auto mb16"}'/> <address> <div t-field="partner.self" t-options='{ "widget": "contact", diff --git a/addons/website_profile/controllers/main.py b/addons/website_profile/controllers/main.py index 9dcc345cb0ac5918df98840a516f05e3955cd20a..e11d68fa835044f0f0fe6cbedda2766d78ffed92 100644 --- a/addons/website_profile/controllers/main.py +++ b/addons/website_profile/controllers/main.py @@ -72,8 +72,8 @@ class WebsiteProfile(http.Controller): @http.route([ '/profile/avatar/<int:user_id>', ], type='http', auth="public", website=True, sitemap=False) - def get_user_profile_avatar(self, user_id, field='image_large', width=0, height=0, crop=False, **post): - if field not in ('image_small', 'image_medium', 'image_large'): + def get_user_profile_avatar(self, user_id, field='image_256', width=0, height=0, crop=False, **post): + if field not in ('image_64', 'image_128', 'image_256'): return werkzeug.exceptions.Forbidden() can_sudo = self._check_avatar_access(user_id, **post) diff --git a/addons/website_profile/views/website_profile.xml b/addons/website_profile/views/website_profile.xml index e30e6ee65937934402ba7ebf9196858cb05d48a2..b5470a833a9ab343b01bd6e4e1fc07a9fb5fa692 100644 --- a/addons/website_profile/views/website_profile.xml +++ b/addons/website_profile/views/website_profile.xml @@ -104,7 +104,7 @@ <div class="col-3"> <div class="card o_card_people"> <div class="card-body"> - <img class="o_forum_avatar_img w-100 mb-3" t-attf-src="/web/image/res.users/#{user.id}/image_medium"/> + <img class="o_forum_avatar_img w-100 mb-3" t-attf-src="/web/image/res.users/#{user.id}/image_128"/> <div class="text-center"> <a href="#" class="o_forum_profile_pic_edit btn btn-primary" aria-label="Edit"> <i class="fa fa-pencil fa-1g float-sm-none float-md-left" title="Edit"></i> @@ -206,7 +206,7 @@ <!-- ==== Header Left ==== --> <div class="col-12 col-md-4 col-lg-3"> <div t-attf-class="d-flex align-items-start h-100 #{'justify-content-between' if (request.env.user == user) else 'justify-content-around' }"> - <div class="o_wprofile_pict d-inline-block mb-3 mb-md-0" t-attf-style="background-image:url(/web/image/res.users/#{user.id}/image)"/> + <div class="o_wprofile_pict d-inline-block mb-3 mb-md-0" t-attf-style="background-image:url(/web/image/res.users/#{user.id}/image_1024)"/> <a class="btn btn-primary d-inline-block d-md-none" t-if="request.env.user == user and user.karma != 0" t-attf-href="/profile/edit?url_param=#{edit_button_url_param}"> <i class="fa fa-pencil mr-1"/>EDIT </a> @@ -252,7 +252,7 @@ <div class="o_wprofile_sidebar_top d-flex justify-content-between"> <div t-if="user.rank_id" class="d-flex align-items-center"> <small class="font-weight-bold mr-2">Current rank:</small> - <img t-attf-src="/web/image/gamification.karma.rank/#{user.rank_id.id}/image_small" height="16" alt="" class="mr-1"/> + <img t-attf-src="/web/image/gamification.karma.rank/#{user.rank_id.id}/image_64" height="16" alt="" class="mr-1"/> <a href="/profile/ranks_badges" t-field="user.rank_id"/> </div> <button class="btn btn-sm d-md-none bg-white border" type="button" data-toggle="collapse" data-target="#o_wprofile_sidebar_collapse" aria-expanded="false" aria-controls="o_wprofile_sidebar_collapse">More info</button> @@ -341,7 +341,7 @@ </svg> <div class="o_pc_overlay d-flex flex-column align-items-center justify-content-center"> <img class="img-fluid" - t-attf-src="/web/image/gamification.karma.rank/#{next_rank_id.id if next_rank_id else user.rank_id.id}/image_medium" + t-attf-src="/web/image/gamification.karma.rank/#{next_rank_id.id if next_rank_id else user.rank_id.id}/image_128" t-att-alt="(next_rank_id.name if next_rank_id else user.rank_id.name) + ' badge'" t-att-style="'max-width: ' + (img_max_width if img_max_width else '50%;')"/> <h4 class=" mb-0"> @@ -367,7 +367,7 @@ <div class="card"> <div class="card-body p-2 pr-3"> <div class="media align-items-center"> - <img height="38" t-attf-src="/web/image/gamification.badge/#{badge.badge_id.id}/image_small" class="mr-0"/> + <img height="38" t-attf-src="/web/image/gamification.badge/#{badge.badge_id.id}/image_64" class="mr-0"/> <div class="media-body col-md-10 p-0"> <h6 class="my-0 text-truncate" t-field="badge.badge_id.name"/> </div> @@ -406,7 +406,7 @@ <t t-foreach="ranks" t-as="rank"> <li t-attf-class="list-group-item"> <div class="media align-items-center"> - <img width="40" t-attf-src="/web/image/gamification.karma.rank/#{rank.id}/image" class="mr-2" alt="Rank badge"/> + <img width="40" t-attf-src="/web/image/gamification.karma.rank/#{rank.id}/image_64" class="mr-2" alt="Rank badge"/> <div class="media-body"> <h5 class="mt-0 mb-0" t-field="rank.name"/> <span class="badge badge-success"><span t-field="rank.karma_min"/></span> point<span t-if="rank.karma_min">s</span> @@ -437,9 +437,9 @@ <table class="table table-sm mb64"> <tr t-foreach="badges" t-as="badge"> <td class="align-middle"> - <img t-if="not badge.image and badge.level" t-attf-src="/website_profile/static/src/img/badge_#{badge.level}.svg" + <img t-if="not badge.image_1920 and badge.level" t-attf-src="/website_profile/static/src/img/badge_#{badge.level}.svg" class="my-1" style="height:2.5em" t-att-alt="badge.name"/> - <img t-else="" t-attf-src="/web/image/gamification.badge/#{badge.id}/image" class="my-1" style="height:2.5em" t-att-alt="badge.name"/> + <img t-else="" t-attf-src="/web/image/gamification.badge/#{badge.id}/image_1024" class="my-1" style="height:2.5em" t-att-alt="badge.name"/> <h6 t-field="badge.name" class="d-inline my-0"/> </td> <td class="align-middle d-none d-md-table-cell"> @@ -512,7 +512,7 @@ <div class="card text-center mb-2 border-bottom-0 o_wprofile_pointer"> <div class="card-body"> <div class="d-inline-block position-relative"> - <img class="rounded-circle img-fluid" t-att-src="'/profile/avatar/%s?field=image_medium%s' % (user['id'], '&res_model=%s&res_id=%s' % (record._name, record.id) if record else '')"/> + <img class="rounded-circle img-fluid" t-att-src="'/profile/avatar/%s?field=image_128%s' % (user['id'], '&res_model=%s&res_id=%s' % (record._name, record.id) if record else '')"/> <img class="position-absolute" t-attf-src="/website_profile/static/src/img/rank_#{user_index + 1}.svg" alt="User rank" style="bottom: 0; right: -10px"/> </div> <h3 class="mt-2 mb-0" t-esc="user['name']"></h3> @@ -531,7 +531,7 @@ <span t-esc="user['position']"/> </td> <td class="align-middle d-none d-sm-table-cell"> - <img class="rounded-circle o_wprofile_img_small" height="30" t-att-src="'/profile/avatar/%s?field=image_medium%s' % (user['id'], '&res_model=%s&res_id=%s' % (record._name, record.id) if record else '')"/> + <img class="rounded-circle o_wprofile_img_small" height="30" t-att-src="'/profile/avatar/%s?field=image_128%s' % (user['id'], '&res_model=%s&res_id=%s' % (record._name, record.id) if record else '')"/> </td> <td class="align-middle w-md-75"> <span class="font-weight-bold" t-esc="user['name']"/><br/> diff --git a/addons/website_sale/data/mail_template_data.xml b/addons/website_sale/data/mail_template_data.xml index 18a1bb70a511f9af79da2feb172f907b34e82f4f..32d57e03bba4e6854e4156fb68258732b860b68f 100644 --- a/addons/website_sale/data/mail_template_data.xml +++ b/addons/website_sale/data/mail_template_data.xml @@ -43,7 +43,7 @@ <table width="100%"> <tr> <td style="padding: 10px; width:150px;"> - <img src="/web/image/product.product/${line.product_id.id}/image_medium" height="100px" width="100px" alt="Product image"></img> + <img src="/web/image/product.product/${line.product_id.id}/image_128" height="100px" width="100px" alt="Product image"></img> </td> <td> <strong>${line.product_id.display_name}</strong><br/>${line.name} diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py index 056cbce05415ad98e5b48114524ee2cbaf0828a9..d8b22e6dfc91397cb05e325d02dbab986b8ded1b 100644 --- a/addons/website_sale/models/product.py +++ b/addons/website_sale/models/product.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models, tools, _ +from odoo import api, fields, models, _ from odoo.exceptions import ValidationError, UserError from odoo.addons.website.models import ir_http from odoo.tools.translate import html_translate @@ -137,7 +137,7 @@ class ProductPricelist(models.Model): class ProductPublicCategory(models.Model): _name = "product.public.category" - _inherit = ["website.seo.metadata", "website.multi.mixin"] + _inherit = ["website.seo.metadata", "website.multi.mixin", 'image.mixin'] _description = "Website Product Category" _parent_store = True _order = "sequence, name" @@ -148,32 +148,9 @@ class ProductPublicCategory(models.Model): child_id = fields.One2many('product.public.category', 'parent_id', string='Children Categories') parents_and_self = fields.Many2many('product.public.category', compute='_compute_parents_and_self') sequence = fields.Integer(help="Gives the sequence order when displaying a list of product categories.", index=True) - # NOTE: there is no 'default image', because by default we don't show - # 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. - # In this case, the default image is set by the js code. - 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', - 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', - 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.") product_tmpl_ids = fields.Many2many('product.template', relation='product_public_category_product_template_rel') - @api.model - def create(self, vals): - tools.image_resize_images(vals) - return super(ProductPublicCategory, self).create(vals) - - def write(self, vals): - tools.image_resize_images(vals) - return super(ProductPublicCategory, self).write(vals) - @api.constrains('parent_id') def check_parent_id(self): if not self._check_recursion(): @@ -383,7 +360,7 @@ class ProductTemplate(models.Model): res = super(ProductTemplate, self)._default_website_meta() res['default_opengraph']['og:description'] = res['default_twitter']['twitter:description'] = self.description_sale res['default_opengraph']['og:title'] = res['default_twitter']['twitter:title'] = self.name - res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = "/web/image/product.template/%s/image" % (self.id) + res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = "/web/image/product.template/%s/image_1024" % (self.id) res['default_meta_description'] = self.description_sale return res @@ -457,7 +434,7 @@ class Product(models.Model): """ self.ensure_one() variant_images = list(self.product_variant_image_ids) - if self.image_raw_original: + if self.image_variant_max: # if the main variant image is set, display it first variant_images = [self] + variant_images else: diff --git a/addons/website_sale/models/product_image.py b/addons/website_sale/models/product_image.py index e991343b55df1a1ae0676fe79b150d038f2b4d26..562ebe798549a91e766d0bef87640f3038df5137 100644 --- a/addons/website_sale/models/product_image.py +++ b/addons/website_sale/models/product_image.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models, _ +from odoo import api, fields, models, tools, _ from odoo.exceptions import ValidationError from odoo.addons.website.tools import get_video_embed_code @@ -16,7 +16,7 @@ class ProductImage(models.Model): name = fields.Char("Name", required=True) sequence = fields.Integer(default=10, index=True) - image_original = fields.Binary(required=True) + image_1920 = fields.Image(required=True) product_tmpl_id = fields.Many2one('product.template', "Product Template", index=True, ondelete='cascade') product_variant_id = fields.Many2one('product.product', "Product Variant", index=True, ondelete='cascade') @@ -24,6 +24,13 @@ class ProductImage(models.Model): help='URL of a video for showcasing your product.') embed_code = fields.Char(compute="_compute_embed_code") + can_image_1024_be_zoomed = fields.Boolean("Can Image 1024 be zoomed", compute='_compute_can_image_1024_be_zoomed', store=True) + + @api.depends('image_1920', 'image_1024') + def _compute_can_image_1024_be_zoomed(self): + for image in self: + image.can_image_1024_be_zoomed = image.image_1920 and tools.is_image_size_above(image.image_1920, image.image_1024) + @api.depends('video_url') def _compute_embed_code(self): for image in self: diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 85ef87d0e08db4604a0b1163cbddc5770bdb886e..08c7f8775cf0ccd2964d62803e25764272618f25 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -440,7 +440,7 @@ publicWidget.registry.WebsiteSale = publicWidget.Widget.extend(VariantMixin, { else { // compatibility 12.0 var model = productId ? 'product.product' : 'product.template'; var modelId = productId || productTemplateId; - var imageSrc = '/web/image/{0}/{1}/image' + var imageSrc = '/web/image/{0}/{1}/image_1024' .replace("{0}", model) .replace("{1}", modelId); @@ -451,7 +451,7 @@ publicWidget.registry.WebsiteSale = publicWidget.Widget.extend(VariantMixin, { var $thumbnail = $productContainer.find('img.js_variant_img_small'); if ($thumbnail.length !== 0) { // if only one, thumbnails are not displayed - $thumbnail.attr("src", "/web/image/{0}/{1}/image/90x90" + $thumbnail.attr("src", "/web/image/{0}/{1}/image_128/90x90" .replace('{0}', model) .replace('{1}', modelId)); $('.carousel').carousel(0); diff --git a/addons/website_sale/static/src/scss/website_sale_frontend.scss b/addons/website_sale/static/src/scss/website_sale_frontend.scss index 6993c1e2fa87d58b154ad8971866bba49f277dfc..c0932d95425d07901760e18e6a88bc0f83e81013 100644 --- a/addons/website_sale/static/src/scss/website_sale_frontend.scss +++ b/addons/website_sale/static/src/scss/website_sale_frontend.scss @@ -140,6 +140,6 @@ $o-wsale-wizard-label-completed: $success; } table.js_cart_lines .td-img img { - // allows sizing the placeholder image to the "image_small" size of 64px + // allows sizing the placeholder image to the "image_64" size of 64px max-height: 64px; } \ No newline at end of file diff --git a/addons/website_sale/static/src/xml/website_sale_utils.xml b/addons/website_sale/static/src/xml/website_sale_utils.xml index 0c470a0d58d13c56c32df9904344dc249c892236..000f7118519af9d3e0473bb89d749b60b6bc51cd 100644 --- a/addons/website_sale/static/src/xml/website_sale_utils.xml +++ b/addons/website_sale/static/src/xml/website_sale_utils.xml @@ -11,7 +11,7 @@ t-att-href="product['website_url']" class="dropdown-item p-2 text-wrap"> <div class="media align-items-center o_search_product_item"> <t t-if="widget.displayImage"> - <img t-attf-src="/web/image/product.template/#{product['id']}/image_small" + <img t-attf-src="/web/image/product.template/#{product['id']}/image_64" class="flex-shrink-0"/> </t> <div class="media-body px-3"> diff --git a/addons/website_sale/tests/test_website_sale_image.py b/addons/website_sale/tests/test_website_sale_image.py index 3577844e90d683ba650886a59a2d5e48793a1871..63342ce9f12c2f5401a6a7a5f72a5a7c05c9d517 100644 --- a/addons/website_sale/tests/test_website_sale_image.py +++ b/addons/website_sale/tests/test_website_sale_image.py @@ -89,7 +89,7 @@ class TestWebsiteSaleImage(odoo.tests.HttpCase): # create the template, without creating the variants template = self.env['product.template'].with_context(create_product_product=True).create({ 'name': 'A Colorful Image', - 'product_template_image_ids': [(0, 0, {'name': 'image 1', 'image': image_gif}), (0, 0, {'name': 'image 4', 'image': image_svg})], + 'product_template_image_ids': [(0, 0, {'name': 'image 1', 'image_1920': image_gif}), (0, 0, {'name': 'image 4', 'image_1920': image_svg})], }) # set the color attribute and values on the template @@ -112,33 +112,33 @@ class TestWebsiteSaleImage(odoo.tests.HttpCase): # because the template image is empty and there is only one variant) product_red = self.env['product.product'].create({ 'product_tmpl_id': template.id, - 'image': blue_image, + 'image_1920': blue_image, 'attribute_value_ids': [(6, 0, attr_values.filtered(lambda l: l.name == name_red).ids)], - 'product_variant_image_ids': [(0, 0, {'name': 'image 2', 'image': image_bmp})], + 'product_variant_image_ids': [(0, 0, {'name': 'image 2', 'image_1920': image_bmp})], }) - self.assertEqual(template.image_original, blue_image) + self.assertEqual(template.image_1920, blue_image) # create the green variant product_green = self.env['product.product'].create({ - 'image': green_image, + 'image_1920': green_image, 'product_tmpl_id': template.id, 'attribute_value_ids': [(6, 0, attr_values.filtered(lambda l: l.name == name_green).ids)], - 'product_variant_image_ids': [(0, 0, {'name': 'image 3', 'image': image_png})], + 'product_variant_image_ids': [(0, 0, {'name': 'image 3', 'image_1920': image_png})], }) # now set the red image on the first variant, that works because # template image is not empty anymore and we have a second variant - product_red.image = red_image + product_red.image_1920 = red_image - # Verify image_original size > 1024 can be zoomed - self.assertTrue(template.can_image_be_zoomed) - self.assertFalse(template.product_template_image_ids[0].can_image_be_zoomed) - self.assertFalse(template.product_template_image_ids[1].can_image_be_zoomed) - self.assertFalse(product_red.can_image_be_zoomed) - self.assertFalse(product_red.product_variant_image_ids[0].can_image_be_zoomed) - self.assertTrue(product_green.can_image_be_zoomed) - self.assertTrue(product_green.product_variant_image_ids[0].can_image_be_zoomed) + # Verify image_1920 size > 1024 can be zoomed + self.assertTrue(template.can_image_1024_be_zoomed) + self.assertFalse(template.product_template_image_ids[0].can_image_1024_be_zoomed) + self.assertFalse(template.product_template_image_ids[1].can_image_1024_be_zoomed) + self.assertFalse(product_red.can_image_1024_be_zoomed) + self.assertFalse(product_red.product_variant_image_ids[0].can_image_1024_be_zoomed) + self.assertTrue(product_green.can_image_1024_be_zoomed) + self.assertTrue(product_green.product_variant_image_ids[0].can_image_1024_be_zoomed) # jpeg encoding is changing the color a bit jpeg_blue = (65, 105, 227) @@ -146,62 +146,68 @@ class TestWebsiteSaleImage(odoo.tests.HttpCase): jpeg_green = (34, 139, 34) # Verify original size: keep original - image = Image.open(io.BytesIO(base64.b64decode(template.image_original))) + image = Image.open(io.BytesIO(base64.b64decode(template.image_1920))) self.assertEqual(image.size, (1920, 1080)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_blue, "blue") - image = Image.open(io.BytesIO(base64.b64decode(product_red.image_original))) + image = Image.open(io.BytesIO(base64.b64decode(product_red.image_1920))) self.assertEqual(image.size, (800, 500)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_red, "red") - image = Image.open(io.BytesIO(base64.b64decode(product_green.image_original))) + image = Image.open(io.BytesIO(base64.b64decode(product_green.image_1920))) self.assertEqual(image.size, (1920, 1080)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_green, "green") - # Verify big size: keep aspect ratio - image = Image.open(io.BytesIO(base64.b64decode(template.image_big))) + # Verify 1024 size: keep aspect ratio + image = Image.open(io.BytesIO(base64.b64decode(template.image_1024))) self.assertEqual(image.size, (1024, 576)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_blue, "blue") - image = Image.open(io.BytesIO(base64.b64decode(product_red.image_big))) + image = Image.open(io.BytesIO(base64.b64decode(product_red.image_1024))) self.assertEqual(image.size, (800, 500)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_red, "red") - image = Image.open(io.BytesIO(base64.b64decode(product_green.image_big))) + image = Image.open(io.BytesIO(base64.b64decode(product_green.image_1024))) self.assertEqual(image.size, (1024, 576)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_green, "green") - # Verify image == image_big - self.assertEqual(template.image_big, template.image) - self.assertEqual(product_red.image_big, product_red.image) - self.assertEqual(product_green.image_big, product_green.image) + # Verify 512 size: keep aspect ratio + image = Image.open(io.BytesIO(base64.b64decode(template.image_512))) + self.assertEqual(image.size, (512, 288)) + self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_blue, "blue") + image = Image.open(io.BytesIO(base64.b64decode(product_red.image_512))) + self.assertEqual(image.size, (512, 320)) + self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_red, "red") + image = Image.open(io.BytesIO(base64.b64decode(product_green.image_512))) + self.assertEqual(image.size, (512, 288)) + self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_green, "green") - # Verify large size: keep aspect ratio - image = Image.open(io.BytesIO(base64.b64decode(template.image_large))) + # Verify 256 size: keep aspect ratio + image = Image.open(io.BytesIO(base64.b64decode(template.image_256))) self.assertEqual(image.size, (256, 144)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_blue, "blue") - image = Image.open(io.BytesIO(base64.b64decode(product_red.image_large))) + image = Image.open(io.BytesIO(base64.b64decode(product_red.image_256))) self.assertEqual(image.size, (256, 160)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_red, "red") - image = Image.open(io.BytesIO(base64.b64decode(product_green.image_large))) + image = Image.open(io.BytesIO(base64.b64decode(product_green.image_256))) self.assertEqual(image.size, (256, 144)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_green, "green") - # Verify medium size: keep aspect ratio - image = Image.open(io.BytesIO(base64.b64decode(template.image_medium))) + # Verify 128 size: keep aspect ratio + image = Image.open(io.BytesIO(base64.b64decode(template.image_128))) self.assertEqual(image.size, (128, 72)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_blue, "blue") - image = Image.open(io.BytesIO(base64.b64decode(product_red.image_medium))) + image = Image.open(io.BytesIO(base64.b64decode(product_red.image_128))) self.assertEqual(image.size, (128, 80)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_red, "red") - image = Image.open(io.BytesIO(base64.b64decode(product_green.image_medium))) + image = Image.open(io.BytesIO(base64.b64decode(product_green.image_128))) self.assertEqual(image.size, (128, 72)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_green, "green") - # Verify small size: keep aspect ratio - image = Image.open(io.BytesIO(base64.b64decode(template.image_small))) + # Verify 64 size: keep aspect ratio + image = Image.open(io.BytesIO(base64.b64decode(template.image_64))) self.assertEqual(image.size, (64, 36)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_blue, "blue") - image = Image.open(io.BytesIO(base64.b64decode(product_red.image_small))) + image = Image.open(io.BytesIO(base64.b64decode(product_red.image_64))) self.assertEqual(image.size, (64, 40)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_red, "red") - image = Image.open(io.BytesIO(base64.b64decode(product_green.image_small))) + image = Image.open(io.BytesIO(base64.b64decode(product_green.image_64))) self.assertEqual(image.size, (64, 36)) self.assertEqual(image.getpixel((image.size[0] / 2, image.size[1] / 2)), jpeg_green, "green") @@ -210,25 +216,27 @@ class TestWebsiteSaleImage(odoo.tests.HttpCase): self.start_tour("/", 'shop_zoom', login="admin") # CASE: unlink move image to fallback if fallback image empty - template.image = False + template.image_1920 = False product_red.unlink() - self.assertEqual(template.image_original, red_image) + self.assertEqual(template.image_1920, red_image) # CASE: unlink does nothing special if fallback image already set self.env['product.product'].create({ 'product_tmpl_id': template.id, - 'image': green_image, + 'image_1920': green_image, }).unlink() - self.assertEqual(template.image_original, red_image) + self.assertEqual(template.image_1920, red_image) # CASE: display variant image first if set - self.assertEqual(product_green._get_images()[0].image_original, green_image) + self.assertEqual(product_green._get_images()[0].image_1920, green_image) # CASE: display variant fallback after variant o2m, correct fallback - # write on the raw field, otherwise it will write on the fallback here - product_green.image_raw_original = False + # write on the variant field, otherwise it will write on the fallback + product_green.image_variant_max = False images = product_green._get_images() - self.assertEqual(images[0].image_original, image_png) - self.assertEqual(images[1].image_original, red_image) - self.assertEqual(images[2].image_original, image_gif) - self.assertEqual(images[3].image_original, image_svg) + # images on fields are resized to max 1920 + image = Image.open(io.BytesIO(base64.b64decode(images[0].image_1920))) + self.assertEqual(image.size, (1268, 1920)) + self.assertEqual(images[1].image_1920, red_image) + self.assertEqual(images[2].image_1920, image_gif) + self.assertEqual(images[3].image_1920, image_svg) diff --git a/addons/website_sale/views/product_views.xml b/addons/website_sale/views/product_views.xml index 25a1aa6118159cf55513b86a845c28a435a5651b..43284ead368325a0111b48540a35172e5406ea43 100644 --- a/addons/website_sale/views/product_views.xml +++ b/addons/website_sale/views/product_views.xml @@ -145,7 +145,7 @@ <field name="arch" type="xml"> <form string="Website Public Categories"> <sheet> - <field name="image_medium" widget='image' class="oe_avatar"/> + <field name="image_1920" widget="image" class="oe_avatar" options="{'preview_image': 'image_128'}"/> <div class="oe_left"> <group> <field name="name"/> @@ -227,7 +227,7 @@ <div class="col-md-6 col-xl-7 text-center o_website_sale_image_modal_container"> <div class="row"> <div class="col"> - <field name="image_original" widget="image"/> + <field name="image_1920" widget="image"/> </div> <div class="col" attrs="{'invisible': [('video_url', 'in', ['', False])]}"> <div class="o_video_container p-2"> @@ -251,13 +251,13 @@ <kanban string="Product Images" default_order="sequence"> <field name="id"/> <field name="name"/> - <field name="image_original"/> + <field name="image_1920"/> <field name="sequence" widget="handle"/> <templates> <t t-name="kanban-box"> <div class="card oe_kanban_global_click p-0"> <div class="o_squared_image"> - <img class="card-img-top" t-att-src="kanban_image('product.image', 'image_original', record.id.value)" t-att-alt="record.name.value"/> + <img class="card-img-top" t-att-src="kanban_image('product.image', 'image_1920', record.id.value)" t-att-alt="record.name.value"/> </div> <div class="card-body p-0"> <h4 class="card-title p-2 m-0 bg-200"> @@ -265,12 +265,12 @@ </h4> </div> <!-- below 100 Kb: good --> - <t t-if="record.image_original.raw_value.length < 100*1000"> + <t t-if="record.image_1920.raw_value.length < 100*1000"> <t t-set="size_status" t-value="'badge-success'"/> <t t-set="message">Acceptable file size</t> </t> <!-- below 1000 Kb: decent --> - <t t-elif="record.image_original.raw_value.length < 1000*1000"> + <t t-elif="record.image_1920.raw_value.length < 1000*1000"> <t t-set="size_status" t-value="'badge-warning'" /> <t t-set="message">Huge file size. The image should be optimized/reduced.</t> </t> @@ -279,7 +279,7 @@ <t t-set="size_status" t-value="'badge-danger'"/> <t t-set="message">Optimization required! Reduce the image size or increase your compression settings.</t> </t> - <span t-attf-class="badge #{size_status} o_product_image_size" t-esc="record.image_original.value" t-att-title="message"/> + <span t-attf-class="badge #{size_status} o_product_image_size" t-esc="record.image_1920.value" t-att-title="message"/> </div> </t> </templates> diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index ca4a23d6418917ee9adbd16aa54677aa97f4d7e0..0e32d3c58c9b261b857ea0205801ff1fd71eaf4e 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -145,8 +145,8 @@ <a href="#" role="button" class="ribbon btn btn-danger">Sale</a> </div> <a t-att-href="product_href" class="d-block h-100" itemprop="url"> - <span t-field="product.image" - t-options="{'widget': 'image', 'preview_image': 'image' if product_image_big else 'image_large'}" + <span t-field="product.image_1920" + t-options="{'widget': 'image', 'preview_image': 'image_1024' if product_image_big else 'image_256'}" class="d-flex h-100 justify-content-center align-items-center"/> </a> </div> @@ -573,8 +573,8 @@ <div class="mt16 text-center" style="height: 100%;"> <t t-set="combination_info" t-value="alt_product._get_combination_info()"/> <t t-set="product_variant" t-value="alt_product.env['product.product'].browse(combination_info['product_id'])"/> - <div t-if="product_variant" t-field="product_variant.image_small" t-options="{'widget': 'image', 'class': 'rounded shadow o_alternative_product' }" /> - <div t-else="" t-field="alt_product.image_small" t-options="{'widget': 'image', 'class': 'rounded shadow o_alternative_product' }" /> + <div t-if="product_variant" t-field="product_variant.image_64" t-options="{'widget': 'image', 'class': 'rounded shadow o_alternative_product' }" /> + <div t-else="" t-field="alt_product.image_64" t-options="{'widget': 'image', 'class': 'rounded shadow o_alternative_product' }" /> <h6> <a t-attf-href="/shop/product/#{ slug(alt_product) }" style="display: block"> <span t-att-title="alt_product.name" t-field="alt_product.name" class="o_text_overflow" style="display: block;" /> @@ -837,7 +837,7 @@ <tr t-att-class="'optional_product info' if line.linked_line_id else None"> <td colspan="2" t-if="not line.product_id.product_tmpl_id" class='td-img'></td> <td align="center" t-if="line.product_id.product_tmpl_id" class='td-img'> - <span t-field="line.product_id.image_small" t-options="{'widget': 'image', 'class': 'rounded'}" /> + <span t-field="line.product_id.image_64" t-options="{'widget': 'image', 'class': 'rounded'}" /> </td> <td t-if="line.product_id.product_tmpl_id" class='td-product_name'> <div> @@ -961,7 +961,7 @@ <t t-foreach="website_sale_order.website_order_line" t-as="line"> <div class="row mb8 cart_line"> <div class="col-3 text-center"> - <span t-field="line.product_id.image_small" t-options="{'widget': 'image', 'class': 'rounded'}" /> + <span t-field="line.product_id.image_64" t-options="{'widget': 'image', 'class': 'rounded'}" /> </div> <div class="col-9"> <div> @@ -995,7 +995,7 @@ <t t-set="combination_info" t-value="product._get_combination_info_variant()"/> <td class='td-img'> <a t-attf-href="/shop/product/#{ slug(product.product_tmpl_id) }"> - <span t-field="product.image_small" t-options="{'widget': 'image', 'class': 'rounded'}" /> + <span t-field="product.image_64" t-options="{'widget': 'image', 'class': 'rounded'}" /> </a> </td> <td class='td-product_name'> @@ -1442,7 +1442,7 @@ <tr t-foreach="website_sale_order.website_order_line" t-as="line"> <td class='' colspan="2" t-if="not line.product_id.product_tmpl_id"></td> <td class='td-img text-center' t-if="line.product_id.product_tmpl_id"> - <span t-field="line.product_id.image_small" t-options="{'widget': 'image', 'class': 'rounded'}" /> + <span t-field="line.product_id.image_64" t-options="{'widget': 'image', 'class': 'rounded'}" /> </td> <td class='td-product_name' t-if="line.product_id.product_tmpl_id"> <div> @@ -1724,7 +1724,7 @@ <div t-if="product_image._name == 'product.image' and product_image.embed_code" class="d-flex align-items-center justify-content-center h-100 embed-responsive embed-responsive-16by9"> <t t-raw="product_image.embed_code"/> </div> - <div t-else="" t-field="product_image.image" class="d-flex align-items-center justify-content-center h-100" t-options='{"widget": "image", "preview_image": "image", "class": "product_detail_img mh-100", "alt-field": "name", "zoom": product_image.can_image_be_zoomed and "image_original"}'/> + <div t-else="" t-field="product_image.image_1920" class="d-flex align-items-center justify-content-center h-100" t-options='{"widget": "image", "preview_image": "image_1024", "class": "product_detail_img mh-100", "alt-field": "name", "zoom": product_image.can_image_1024_be_zoomed and "image_1920"}'/> </div> </t> </div> @@ -1740,7 +1740,7 @@ <div t-ignore="True" class="d-none d-md-block text-center"> <ol t-if="len(product_images) > 1" class="carousel-indicators d-inline-block position-static mx-auto my-0 p-1 text-left"> <t t-foreach="product_images" t-as="product_image"><li t-attf-class="d-inline-block m-1 align-top {{'active' if product_image_first else ''}}" data-target="#o-carousel-product" t-att-data-slide-to="str(product_image_index)"> - <div t-field="product_image.image_small" class="d-flex align-items-center justify-content-center h-100" t-options='{"widget": "image", "alt-field": "name"}'/> + <div t-field="product_image.image_64" class="d-flex align-items-center justify-content-center h-100" t-options='{"widget": "image", "alt-field": "name"}'/> <i t-if="product_image._name == 'product.image' and product_image.embed_code" class="fa fa-2x fa-play-circle-o o_product_video_thumb"/> </li></t> </ol> diff --git a/addons/website_sale_comparison/views/website_sale_comparison_template.xml b/addons/website_sale_comparison/views/website_sale_comparison_template.xml index 06cf34d6b649c154caa2c1758b3740ccb43d1d57..9eb1d4da7df94357ae57830f1bfc3c4e02d99bb6 100644 --- a/addons/website_sale_comparison/views/website_sale_comparison_template.xml +++ b/addons/website_sale_comparison/views/website_sale_comparison_template.xml @@ -97,7 +97,7 @@ <strong class='float-right'>x</strong> </a> <a t-att-href="'/shop/product/%s' % slug(product.product_tmpl_id)"> - <img t-attf-src="/web/image/product.product/#{product.id}/image_large" class="img img-fluid" style="margin:auto;" alt="Product image"/> + <img t-attf-src="/web/image/product.product/#{product.id}/image_256" class="img img-fluid" style="margin:auto;" alt="Product image"/> </a> <div class='product_summary'> <a class="o_product_comparison_table" t-attf-href="/shop/product/#{ slug(product.product_tmpl_id) }"> @@ -143,7 +143,7 @@ <t t-set="combination_info" t-value="product._get_combination_info_variant()"/> <div class="row no-gutters align-items-center mt-2 o_product_row" t-att-data-category_ids="product.public_categ_ids.ids"> <div class="col-3"> - <img class="img img-fluid" t-attf-src="/web/image/product.product/#{product.id}/image_small" style="max-height: 50px;" alt="Product image"/> + <img class="img img-fluid" t-attf-src="/web/image/product.product/#{product.id}/image_64" style="max-height: 50px;" alt="Product image"/> </div> <div class="col-8 pl-2"> <h6> diff --git a/addons/website_sale_digital/data/product_demo.xml b/addons/website_sale_digital/data/product_demo.xml index 2388f15a023f53ec133df4a185f595203bd1d0cd..444ea7f5dc076958db2523441c37c532b1f4fa94 100644 --- a/addons/website_sale_digital/data/product_demo.xml +++ b/addons/website_sale_digital/data/product_demo.xml @@ -7,7 +7,7 @@ <field name="list_price">4.50</field> <field name="type">service</field> <field name="website_published" eval="True"/> - <field name="image" type="base64" file="website_sale_digital/static/digital_product_1.jpg"/> + <field name="image_1920" type="base64" file="website_sale_digital/static/digital_product_1.jpg"/> <field name="categ_id" ref="product.product_category_6"/> </record> diff --git a/addons/website_sale_slides/data/website_sale_slides_demo.xml b/addons/website_sale_slides/data/website_sale_slides_demo.xml index c5f8a3d1b358044cb18e32307971946a9513748f..f578264c9072d91ab2ba9f76a78f40211eb6faef 100644 --- a/addons/website_sale_slides/data/website_sale_slides_demo.xml +++ b/addons/website_sale_slides/data/website_sale_slides_demo.xml @@ -9,7 +9,7 @@ <field name="list_price">100.0</field> <field name="type">service</field> <field name="website_published" eval="True"/> - <field name="image" type="base64" file="website_sale_slides/static/img/product_course.png"/> + <field name="image_1920" type="base64" file="website_sale_slides/static/img/product_course.png"/> </record> <record id="website_slides.slide_channel_demo_6_furn3" model="slide.channel"> @@ -25,7 +25,7 @@ <field name="list_price">12.0</field> <field name="type">consu</field> <field name="website_published" eval="True"/> - <field name="image" type="base64" file="website_sale_slides/static/img/water_can.jpg"/> + <field name="image_1920" type="base64" file="website_sale_slides/static/img/water_can.jpg"/> </record> <record id="product_course_channel_1_option_1" model="product.product"> @@ -34,7 +34,7 @@ <field name="list_price">4.5</field> <field name="type">consu</field> <field name="website_published" eval="True"/> - <field name="image" type="base64" file="website_sale_slides/static/img/flower_pot.jpg"/> + <field name="image_1920" type="base64" file="website_sale_slides/static/img/flower_pot.jpg"/> </record> <record id="product_course_demo_1" model="product.product"> @@ -43,7 +43,7 @@ <field name="list_price">150.0</field> <field name="type">service</field> <field name="website_published" eval="True"/> - <field name="image" type="base64" file="website_sale_slides/static/img/channel_demo_tree_1.jpg"/> + <field name="image_1920" type="base64" file="website_sale_slides/static/img/channel_demo_tree_1.jpg"/> </record> <record id="product_course_demo_1_product_template" model="product.template"> diff --git a/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml b/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml index 77ac50e78233e4a238e9f12a3ac091697c56ad77..e6f95956448417320a020116b3a66d21ee5a9b1b 100644 --- a/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml +++ b/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml @@ -63,7 +63,7 @@ <tr t-att-data-wish-id='wish.id' t-att-data-product-id='wish.product_id.id'> <td class='td-img'> <a t-att-href="'/shop/product/%s' % slug(wish.product_id.product_tmpl_id)"> - <img t-attf-src="/web/image/product.product/#{wish.product_id.id}/image_medium" class="img img-fluid" style="margin:auto;" alt="Product image"/> + <img t-attf-src="/web/image/product.product/#{wish.product_id.id}/image_128" class="img img-fluid" style="margin:auto;" alt="Product image"/> </a> </td> <td class='text-left'> diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index d6e1caceb93f27abb069cfb9c28457ff54043153..57c25a04af0b026fb8f92f8c5fae53238eae11a3 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -324,7 +324,7 @@ class WebsiteSlides(WebsiteProfile): return request.env['res.users'].sudo().search_read([ ('karma', '>', 0), ('website_published', '=', True), - ('image', '!=', False)], ['id'], limit=3, order='karma desc') + ('image_1920', '!=', False)], ['id'], limit=3, order='karma desc') @http.route([ '/slides/<model("slide.channel"):channel>', @@ -557,9 +557,9 @@ class WebsiteSlides(WebsiteProfile): return response @http.route('/slides/slide/<int:slide_id>/get_image', type='http', auth="public", website=True, sitemap=False) - def slide_get_image(self, slide_id, field='image_medium', width=0, height=0, crop=False): + def slide_get_image(self, slide_id, field='image_128', width=0, height=0, crop=False): # Protect infographics by limiting access to 256px (large) images - if field not in ('image_small', 'image_medium', 'image_large'): + if field not in ('image_64', 'image_128', 'image_256', 'image_512', 'image_1024', 'image_1920'): return werkzeug.exceptions.Forbidden() slide = request.env['slide.slide'].sudo().browse(slide_id).exists() @@ -846,7 +846,7 @@ class WebsiteSlides(WebsiteProfile): def _get_valid_slide_post_values(self): return ['name', 'url', 'tag_ids', 'slide_type', 'channel_id', 'is_preview', - 'mime_type', 'datas', 'description', 'image', 'index_content', 'website_published'] + 'mime_type', 'datas', 'description', 'image_1920', 'index_content', 'website_published'] @http.route(['/slides/tag/search_read'], type='json', auth='user', methods=['POST'], website=True) def slide_tag_search_read(self, fields, domain): diff --git a/addons/website_slides/data/gamification_data.xml b/addons/website_slides/data/gamification_data.xml index 4bf7a829b9d989b7247219391e452110dac04ee5..08606251fad898ed80d9651f8ec321b6e2c86f33 100644 --- a/addons/website_slides/data/gamification_data.xml +++ b/addons/website_slides/data/gamification_data.xml @@ -5,7 +5,7 @@ <record id="badge_data_register" model="gamification.badge"> <field name="name">Get started</field> <field name="description">Register to the platform</field> - <field name="image" type="base64" file="website_slides/static/src/img/standard_badge_bronze.svg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/standard_badge_bronze.svg"/> <field name="website_published" eval="True"/> <field name="level">bronze</field> <field name="rule_auth">nobody</field> @@ -46,7 +46,7 @@ <record id="badge_data_profile" model="gamification.badge"> <field name="name">Know yourself</field> <field name="description">Complete your profile</field> - <field name="image" type="base64" file="website_slides/static/src/img/standard_badge_bronze.svg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/standard_badge_bronze.svg"/> <field name="website_published" eval="True"/> <field name="level">bronze</field> <field name="rule_auth">nobody</field> @@ -88,7 +88,7 @@ <record id="badge_data_course" model="gamification.badge"> <field name="name">Power User</field> <field name="description">Complete a course</field> - <field name="image" type="base64" file="website_slides/static/src/img/standard_badge_silver.svg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/standard_badge_silver.svg"/> <field name="website_published" eval="True"/> <field name="level">silver</field> <field name="rule_auth">nobody</field> @@ -128,7 +128,7 @@ <record id="badge_data_certification" model="gamification.badge"> <field name="name">Certified Knowledge</field> <field name="description">Get a certification</field> - <field name="image" type="base64" file="website_slides/static/src/img/standard_badge_gold.svg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/standard_badge_gold.svg"/> <field name="website_published" eval="False"/> <field name="level">gold</field> <field name="rule_auth">nobody</field> @@ -169,7 +169,7 @@ <record id="badge_data_karma" model="gamification.badge"> <field name="name">Community hero</field> <field name="description">Reach 2000 XP</field> - <field name="image" type="base64" file="website_slides/static/src/img/standard_badge_gold.svg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/standard_badge_gold.svg"/> <field name="website_published" eval="True"/> <field name="level">gold</field> <field name="rule_auth">nobody</field> diff --git a/addons/website_slides/data/mail_data.xml b/addons/website_slides/data/mail_data.xml index e00ddd2f78b9d696baf081a5319e002a7c1d1f7a..b14fea317a11ddbea022a7430db93eeb2370406c 100644 --- a/addons/website_slides/data/mail_data.xml +++ b/addons/website_slides/data/mail_data.xml @@ -12,7 +12,7 @@ A new ${object.slide_type} <strong>${object.name}</strong> has been published on ${object.channel_id.name} at ${format_datetime(object.write_date, tz=user.tz)} <div style="margin: 16px 8px 16px 8px; text-align: center;"> <a href="${object.website_url}"> - <img alt="${object.name}" src="${ctx['base_url']}/web/image/slide.slide/${object.id}/image" style="height:auto; width:150px; margin: 16px;"/> + <img alt="${object.name}" src="${ctx['base_url']}/web/image/slide.slide/${object.id}/image_1024" style="height:auto; width:150px; margin: 16px;"/> </a> </div> <div style="margin: 16px 8px 16px 8px; text-align: center;"> @@ -39,7 +39,7 @@ ${ctx['user'].name} shared the ${object.slide_type} <strong>${object.name}</strong> with you! <div style="margin: 16px 8px 16px 8px; text-align: center;"> <a href="${(object.website_url + '?fullscreen=1') if ctx['fullscreen'] else object.website_url | safe}"> - <img alt="${object.name}" src="${ctx['base_url']}/web/image/slide.slide/${object.id}/image" style="height:auto; width:150px; margin: 16px;"/> + <img alt="${object.name}" src="${ctx['base_url']}/web/image/slide.slide/${object.id}/image_1024" style="height:auto; width:150px; margin: 16px;"/> </a> </div> <div style="margin: 16px 8px 16px 8px; text-align: center;"> diff --git a/addons/website_slides/data/slide_channel_demo.xml b/addons/website_slides/data/slide_channel_demo.xml index 1c6ae501db413feb16b99250d66f4dcb762dfb7d..d88c30abe46acdcd156c3d822191fdf2685d8b1c 100644 --- a/addons/website_slides/data/slide_channel_demo.xml +++ b/addons/website_slides/data/slide_channel_demo.xml @@ -11,7 +11,7 @@ (4, ref('website_slides.slide_channel_tag_level_basic')), (4, ref('website_slides.slide_channel_tag_role_gardener')), (4, ref('website_slides.slide_channel_tag_other_2'))]"/> - <field name="image" type="base64" file="website_slides/static/src/img/channel_demo_gardening.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel_demo_gardening.jpg"/> <field name="description">Learn the basics of gardening !</field> <field name="create_date" eval="DateTime.now() - relativedelta(days=8)"/> </record> @@ -27,7 +27,7 @@ (4, ref('website_slides.slide_channel_tag_level_intermediate')), (4, ref('website_slides.slide_channel_tag_role_gardener')), (4, ref('website_slides.slide_channel_tag_other_0'))]"/> - <field name="image" type="base64" file="website_slides/static/src/img/channel_demo_gardening_2.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel_demo_gardening_2.jpg"/> <field name="description">Learn how to take care of your favorite trees. Learn when to plant, how to manage potted trees, ...</field> <field name="create_date" eval="DateTime.now() - relativedelta(days=7)"/> </record> @@ -55,7 +55,7 @@ (4, ref('website_slides.slide_channel_tag_role_carpenter')), (4, ref('website_slides.slide_channel_tag_other_0')), (4, ref('website_slides.slide_channel_tag_other_2'))]"/> - <field name="image" type="base64" file="website_slides/static/src/img/channel_demo_flowers.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel_demo_flowers.jpg"/> <field name="description">A lot of nice documentation: trees, wood, gardens. A gold mine for references.</field> <field name="create_date" eval="DateTime.now() - relativedelta(days=6)"/> </record> @@ -83,7 +83,7 @@ (4, ref('website_slides.slide_channel_tag_role_carpenter')), (4, ref('website_slides.slide_channel_tag_role_furniture')), (4, ref('website_slides.slide_channel_tag_other_2'))]"/> - <field name="image" type="base64" file="website_slides/static/src/img/channel_demo_tree_1.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel_demo_tree_1.jpg"/> <field name="description">Knowing which kind of wood to use depending on your application is important. In this course you will learn the basics of wood characteristics.</field> <field name="create_date" eval="DateTime.now() - relativedelta(days=5)"/> @@ -104,7 +104,7 @@ will learn the basics of wood characteristics.</field> <field name="tag_ids" eval="[(5, 0), (4, ref('website_slides.slide_channel_tag_level_basic')), (4, ref('website_slides.slide_channel_tag_role_furniture'))]"/> - <field name="image" type="base64" file="website_slides/static/src/img/channel_demo_furniture_2.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel_demo_furniture_2.jpg"/> <field name="description">If you are looking for technical specifications, have a look at this documentation.</field> <field name="create_date" eval="DateTime.now() - relativedelta(days=4)"/> </record> @@ -126,7 +126,7 @@ will learn the basics of wood characteristics.</field> (4, ref('website_slides.slide_channel_tag_role_furniture')), (4, ref('website_slides.slide_channel_tag_other_0')), (4, ref('website_slides.slide_channel_tag_other_1'))]"/> - <field name="image" type="base64" file="website_slides/static/src/img/channel_demo_furniture.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel_demo_furniture.jpg"/> <field name="description">All you need to know about furniture creation.</field> <field name="create_date" eval="DateTime.now() - relativedelta(days=3)"/> </record> @@ -159,7 +159,7 @@ will learn the basics of wood characteristics.</field> (4, ref('website_slides.slide_channel_tag_role_carpenter')), (4, ref('website_slides.slide_channel_tag_role_furniture')), (4, ref('website_slides.slide_channel_tag_other_1'))]"/> - <field name="image" type="base64" file="website_slides/static/src/img/channel_demo_diy.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel_demo_diy.jpg"/> <field name="description">So much amazing certification.</field> <field name="create_date" eval="DateTime.now() - relativedelta(days=2)"/> </record> diff --git a/addons/website_slides/data/slide_slide_demo.xml b/addons/website_slides/data/slide_slide_demo.xml index 9407a40867158003be029f31981a354d228986c1..3e329b38c2896e72ce435199877dfcd10216c621 100644 --- a/addons/website_slides/data/slide_slide_demo.xml +++ b/addons/website_slides/data/slide_slide_demo.xml @@ -7,7 +7,7 @@ <field name="name">Know-How Summary</field> <field name="sequence">1</field> <field name="datas" type="base64" file="website_slides/static/src/img/presentation.pdf"/> - <field name="image" type="base64" file="website_slides/static/src/img/channel-training-default.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel-training-default.jpg"/> <field name="slide_type">presentation</field> <field name="channel_id" ref="website_slides.channel_public"/> <field name="category_id" eval="False"/> @@ -21,7 +21,7 @@ <record id="slide_slide_demo_0_1" model="slide.slide"> <field name="name">Home Gardening</field> <field name="sequence">2</field> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_gardening_1.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_gardening_1.jpg"/> <field name="slide_type">infographic</field> <field name="channel_id" ref="website_slides.channel_public"/> <field name="category_id" eval="False"/> @@ -38,7 +38,7 @@ <record id="slide_slide_demo_1_0" model="slide.slide"> <field name="name">Tree Infographic</field> <field name="sequence">1</field> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_tree_infographic_1.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_tree_infographic_1.jpg"/> <field name="slide_type">infographic</field> <field name="channel_id" ref="website_slides.slide_channel_demo_1_gard1"/> <field name="category_id" ref="website_slides.slide_category_demo_1_0"/> @@ -52,7 +52,7 @@ <record id="slide_slide_demo_1_1" model="slide.slide"> <field name="name">Interesting Tree Facts</field> <field name="sequence">2</field> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_tree_infographic_2.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_tree_infographic_2.jpg"/> <field name="slide_type">infographic</field> <field name="channel_id" ref="website_slides.slide_channel_demo_1_gard1"/> <field name="category_id" ref="website_slides.slide_category_demo_1_0"/> @@ -66,7 +66,7 @@ <record id="slide_slide_demo_1_2" model="slide.slide"> <field name="name">Energy Efficiency Facts</field> <field name="sequence">3</field> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_tree_infographic_3.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_tree_infographic_3.jpg"/> <field name="slide_type">infographic</field> <field name="channel_id" ref="website_slides.slide_channel_demo_1_gard1"/> <field name="category_id" ref="website_slides.slide_category_demo_1_0"/> @@ -91,7 +91,7 @@ <field name="name">How to plant a potted tree</field> <field name="sequence">4</field> <field name="url">https://www.youtube.com/watch?v=QYmgrw0PgLU</field> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_thumb_QYmgrw0PgLU.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_thumb_QYmgrw0PgLU.jpg"/> <field name="document_id">QYmgrw0PgLU</field> <field name="slide_type">video</field> <field name="channel_id" ref="website_slides.slide_channel_demo_1_gard1"/> @@ -106,7 +106,7 @@ <record id="slide_slide_demo_1_4" model="slide.slide"> <field name="name">A little chat with Harry Potted</field> <field name="sequence">5</field> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_tree_img_1.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_tree_img_1.jpg"/> <field name="slide_type">webpage</field> <field name="channel_id" ref="website_slides.slide_channel_demo_1_gard1"/> <field name="category_id" ref="website_slides.slide_category_demo_1_1"/> @@ -199,7 +199,7 @@ <field name="name">3 Main Methodologies</field> <field name="sequence">6</field> <field name="datas" type="base64" file="website_slides/static/src/img/presentation.pdf"/> - <field name="image" type="base64" file="website_slides/static/src/img/channel-training-default.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel-training-default.jpg"/> <field name="slide_type">presentation</field> <field name="channel_id" ref="website_slides.slide_channel_demo_1_gard1"/> <field name="category_id" ref="website_slides.slide_category_demo_1_1"/> @@ -217,7 +217,7 @@ <field name="name">Main Trees Categories</field> <field name="sequence">1</field> <field name="datas" type="base64" file="website_slides/static/src/img/presentation.pdf"/> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_tree_img_2.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_tree_img_2.jpg"/> <field name="slide_type">presentation</field> <field name="channel_id" ref="website_slides.slide_channel_demo_2_gard2"/> <field name="category_id" ref="website_slides.slide_category_demo_2_0"/> @@ -278,7 +278,7 @@ <record id="slide_slide_demo_2_1" model="slide.slide"> <field name="name">A Mighty Forest from Ages</field> <field name="sequence">2</field> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_tree_img_3.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_tree_img_3.jpg"/> <field name="slide_type">webpage</field> <field name="channel_id" ref="website_slides.slide_channel_demo_2_gard2"/> <field name="category_id" ref="website_slides.slide_category_demo_2_0"/> @@ -327,7 +327,7 @@ <record id="slide_slide_demo_2_2" model="slide.slide"> <field name="name">Tree planting in hanging bottles on wall</field> <field name="url">https://www.youtube.com/watch?v=ebBez6bcSEc</field> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_thumb_ebBez6bcSEc.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_thumb_ebBez6bcSEc.jpg"/> <field name="document_id">ebBez6bcSEc</field> <field name="slide_type">video</field> <field name="channel_id" ref="website_slides.slide_channel_demo_2_gard2"/> @@ -346,7 +346,7 @@ <field name="name">Unforgettable Tools</field> <field name="sequence">1</field> <field name="datas" type="base64" file="website_slides/static/src/img/presentation.pdf"/> - <field name="image" type="base64" file="website_slides/static/src/img/channel-training-default.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel-training-default.jpg"/> <field name="slide_type">presentation</field> <field name="channel_id" ref="website_slides.slide_channel_demo_5_furn2"/> <field name="category_id" ref="website_slides.slide_category_demo_5_0"/> @@ -370,7 +370,7 @@ <record id="slide_slide_demo_5_1" model="slide.slide"> <field name="name">How to find quality wood</field> <field name="sequence">2</field> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_thumb_5WMqwTnZ-qs.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_thumb_5WMqwTnZ-qs.jpg"/> <field name="url">https://www.youtube.com/watch?v=5WMqwTnZ-qs</field> <field name="document_id">5WMqwTnZ-qs</field> <field name="slide_type">video</field> @@ -386,7 +386,7 @@ <record id="slide_slide_demo_5_2" model="slide.slide"> <field name="name">How to create your own piece of furniture</field> <field name="sequence">3</field> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_thumb_ptjeDDoURL8.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_thumb_ptjeDDoURL8.jpg"/> <field name="url">https://www.youtube.com/watch?v=ptjeDDoURL8</field> <field name="document_id">ptjeDDoURL8</field> <field name="slide_type">video</field> @@ -402,7 +402,7 @@ <record id="slide_slide_demo_5_3" model="slide.slide"> <field name="name">Test your knowledge !</field> <field name="sequence">4</field> - <field name="image" type="base64" file="website_slides/static/src/img/slide_demo_owl.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/slide_demo_owl.jpg"/> <field name="slide_type">quiz</field> <field name="channel_id" ref="website_slides.slide_channel_demo_5_furn2"/> <field name="category_id" ref="website_slides.slide_category_demo_5_0"/> diff --git a/addons/website_slides/models/slide_slide.py b/addons/website_slides/models/slide_slide.py index 4a0523e559379532dc83eb47acf70983f942f02a..d369a297afafb29fff38ab6492c55c6e3ef2403a 100644 --- a/addons/website_slides/models/slide_slide.py +++ b/addons/website_slides/models/slide_slide.py @@ -287,8 +287,8 @@ class Slide(models.Model): if not values.get('index_content'): values['index_content'] = values.get('description') - if values.get('slide_type') == 'infographic' and not values.get('image'): - values['image'] = values['datas'] + if values.get('slide_type') == 'infographic' and not values.get('image_1920'): + values['image_1920'] = values['datas'] if values.get('website_published') and not values.get('date_published'): values['date_published'] = datetime.datetime.now() if values.get('url') and not values.get('document_id'): @@ -604,7 +604,7 @@ class Slide(models.Model): return values values.update({ 'name': snippet['title'], - 'image': self._fetch_data(snippet['thumbnails']['high']['url'], {}, 'image')['values'], + 'image_1920': self._fetch_data(snippet['thumbnails']['high']['url'], {}, 'image')['values'], 'description': snippet['description'], 'mime_type': False, }) @@ -615,8 +615,8 @@ class Slide(models.Model): def get_slide_type(vals): # TDE FIXME: WTF ?? slide_type = 'presentation' - if vals.get('image'): - image = Image.open(io.BytesIO(base64.b64decode(vals['image']))) + if vals.get('image_1920'): + image = Image.open(io.BytesIO(base64.b64decode(vals['image_1920']))) width, height = image.size if height > width: return 'document' @@ -648,14 +648,14 @@ class Slide(models.Model): values = { 'name': google_values['title'], - 'image': self._fetch_data(google_values['thumbnailLink'].replace('=s220', ''), {}, 'image')['values'], + 'image_1920': self._fetch_data(google_values['thumbnailLink'].replace('=s220', ''), {}, 'image')['values'], 'mime_type': google_values['mimeType'], 'document_id': document_id, } if google_values['mimeType'].startswith('video/'): values['slide_type'] = 'video' elif google_values['mimeType'].startswith('image/'): - values['datas'] = values['image'] + values['datas'] = values['image_1920'] values['slide_type'] = 'infographic' elif google_values['mimeType'].startswith('application/vnd.google-apps'): values['slide_type'] = get_slide_type(values) @@ -677,6 +677,6 @@ class Slide(models.Model): res = super(Slide, self)._default_website_meta() res['default_opengraph']['og:title'] = res['default_twitter']['twitter:title'] = self.name res['default_opengraph']['og:description'] = res['default_twitter']['twitter:description'] = self.description - res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = "/web/image/slide.slide/%s/image" % (self.id) + res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = "/web/image/slide.slide/%s/image_1024" % (self.id) res['default_meta_description'] = self.description return res diff --git a/addons/website_slides/static/src/js/slides_course_fullscreen_player.js b/addons/website_slides/static/src/js/slides_course_fullscreen_player.js index 22e8b126b2d8eb3f55c16ba39a1710ec4b2b3355..093f147aff6ccb63b4fb736d332867b3fef064aa 100644 --- a/addons/website_slides/static/src/js/slides_course_fullscreen_player.js +++ b/addons/website_slides/static/src/js/slides_course_fullscreen_player.js @@ -498,7 +498,7 @@ odoo.define('website_slides.fullscreen', function (require) { slideData.embedCode = $(slideData.embedCode).attr('src'); // embedCode containts an iframe tag, where src attribute is the url (youtube or embed document from odoo) slideData.embedUrl = "https://" + slideData.embedCode + "&rel=0&autoplay=1&enablejsapi=1&origin=" + window.location.origin; } else if (slideData.type === 'infographic') { - slideData.embedUrl = _.str.sprintf('/web/image/slide.slide/%s/image', slideData.id); + slideData.embedUrl = _.str.sprintf('/web/image/slide.slide/%s/image_1024', slideData.id); } else if (_.contains(['document', 'presentation'], slideData.type)) { slideData.embedUrl = $(slideData.embedCode).attr('src'); } diff --git a/addons/website_slides/static/src/xml/website_slides_fullscreen.xml b/addons/website_slides/static/src/xml/website_slides_fullscreen.xml index 6793dd5c73685ba056f4bb88fa73898ad0de8a4f..ceebb9d246c469614b17a719d421928cfba889b4 100644 --- a/addons/website_slides/static/src/xml/website_slides_fullscreen.xml +++ b/addons/website_slides/static/src/xml/website_slides_fullscreen.xml @@ -8,7 +8,7 @@ </t> <t t-if="widget.get('slide').type === 'infographic'"> <div class="o_wslides_fs_player w-100 h-100 overflow-auto d-flex align-items-start justify-content-center"> - <img t-att-src="'/web/image/slide.slide/'+ widget.get('slide').id +'/image'" class="img-fluid position-relative m-auto" alt="Slide image"/> + <img t-att-src="'/web/image/slide.slide/'+ widget.get('slide').id +'/image_1024'" class="img-fluid position-relative m-auto" alt="Slide image"/> </div> </t> </t> diff --git a/addons/website_slides/views/slide_channel_views.xml b/addons/website_slides/views/slide_channel_views.xml index 27dbd5742c3bce5e1a7c3fa1ca4229fa83c34cc1..7cdf9e63d960fb79b668a6caadb3d460384ced07 100644 --- a/addons/website_slides/views/slide_channel_views.xml +++ b/addons/website_slides/views/slide_channel_views.xml @@ -64,7 +64,7 @@ <field name="is_published" widget="website_button"/> </button> </div> - <field name="image" widget="image" class="oe_avatar" options="{'preview_image': 'image_medium'}"/> + <field name="image_1920" widget="image" class="oe_avatar" options="{'preview_image': 'image_128'}"/> <div class="oe_title"> <label for="name" class="oe_edit_only" string="Name"/> <h1><field name="name" default_focus="1" placeholder="Name"/></h1> diff --git a/addons/website_slides/views/slide_slide_views.xml b/addons/website_slides/views/slide_slide_views.xml index 9ee8fd67c9819610ff6ca86dc8fb712eba195c5b..5fcb30dbad4cb742920f3446c56c17adc26c96d4 100644 --- a/addons/website_slides/views/slide_slide_views.xml +++ b/addons/website_slides/views/slide_slide_views.xml @@ -47,7 +47,7 @@ <field name="is_published" widget="website_button"/> </button> </div> - <field name="image" widget="image" class="oe_avatar" options='{"preview_image": "image_large"}' + <field name="image_1920" widget="image" class="oe_avatar" options='{"preview_image": "image_256"}' attrs="{'readonly': [('slide_type', 'in', ('document', 'presentation', 'video'))]}" /> <div class="oe_title"> diff --git a/addons/website_slides/views/website_slides_templates_course.xml b/addons/website_slides/views/website_slides_templates_course.xml index 8f90923b48575bada228473446f22dc36c3538fe..9fac350ac7169ab18cab045eacc61c361dde416d 100644 --- a/addons/website_slides/views/website_slides_templates_course.xml +++ b/addons/website_slides/views/website_slides_templates_course.xml @@ -120,7 +120,7 @@ <!-- ==== Header Left ==== --> <div class="col-12 col-md-4 col-lg-3"> <div class="d-flex align-items-start justify-content-around h-100"> - <div class="o_wslides_course_pict d-inline-block mb-2 mt-3 my-md-0" t-attf-style="background-image:url(/web/image/slide.channel/#{channel.id}/image)" t-ignore="True"/> + <div class="o_wslides_course_pict d-inline-block mb-2 mt-3 my-md-0" t-attf-style="background-image:url(/web/image/slide.channel/#{channel.id}/image_1024)" t-ignore="True"/> </div> </div> @@ -534,7 +534,7 @@ <!-- Featured lesson --> <div t-if="not search and not search_slide_type and slide_promoted" class="container py-1 mb-2"> <div class="card flex-column flex-lg-row"> - <t t-set="image_url" t-value="'/web/image/slide.slide/%s/image' % slide_promoted.id"/> + <t t-set="image_url" t-value="'/web/image/slide.slide/%s/image_1024' % slide_promoted.id"/> <a t-if="slide_promoted.is_preview or channel.is_member or is_slides_publisher" t-attf-href="/slides/slide/#{slug(slide_promoted)}#{query_string}" class="w-100 w-lg-50 flex-shrink-0 rounded"> @@ -608,8 +608,8 @@ <div class="card w-100 o_wslides_lesson_card mb-4"> <t t-set="can_access" t-value="slide.is_preview or channel.is_member or channel.can_publish"/> - <t t-if="slide.image"> - <t t-set="lesson_image" t-value="'/web/image/slide.slide/%s/image' % slide.id"/> + <t t-if="slide.image_1024"> + <t t-set="lesson_image" t-value="'/web/image/slide.slide/%s/image_1024' % slide.id"/> <a t-if="can_access" t-attf-href="/slides/slide/#{slug(slide)}#{query_string}" t-title="slide.name"> <div class="card-img-top border-bottom" t-attf-style="padding-top: 50%; background-image: url(#{lesson_image}); background-size: cover; background-position:center"/> </a> diff --git a/addons/website_slides/views/website_slides_templates_homepage.xml b/addons/website_slides/views/website_slides_templates_homepage.xml index 5e689745e4b1112cda5378f29149cd0409048fc9..de824406f1f7b4cdb917f152f4c64485950eb06f 100644 --- a/addons/website_slides/views/website_slides_templates_homepage.xml +++ b/addons/website_slides/views/website_slides_templates_homepage.xml @@ -15,7 +15,7 @@ <t t-foreach="top3_users" t-as="user"> <img class="rounded-circle img-fluid shadow ml-n4" style="border: 6px solid white" - t-attf-src="/web/image/res.users/#{user['id']}/image_medium"/> + t-attf-src="/web/image/res.users/#{user['id']}/image_128"/> </t> </div> </div> @@ -283,9 +283,9 @@ <template id='course_card' name="Course Card"> <div t-attf-class="card w-100 o_wslides_course_card mb-4 #{'o_wslides_course_unpublished' if not channel.is_published else ''}"> - <t t-set="course_image" t-value="'/web/image/slide.channel/%s/image' % channel.id"/> + <t t-set="course_image" t-value="'/web/image/slide.channel/%s/image_1024' % channel.id"/> <a t-attf-href="/slides/#{slug(channel)}" t-title="channel.name"> - <div t-if="channel.image_large" class="card-img-top" t-attf-style="padding-top: 50%; background-image: url(#{course_image}); background-size: cover; background-position:center"/> + <div t-if="channel.image_1024" class="card-img-top" t-attf-style="padding-top: 50%; background-image: url(#{course_image}); background-size: cover; background-position:center"/> <div t-else="" class="o_wslides_gradient card-img-top position-relative" style="padding-top: 50%; opacity: 0.8"> <i class="fa fa-graduation-cap fa-2x mr-3 mb-3 position-absolute text-white-75" style="right:0; bottom: 0"/> </div> @@ -394,7 +394,7 @@ <div class="o_wslides_home_aside"> <div t-if="user.rank_id" class="d-flex align-items-center"> <span class="font-weight-bold text-muted mr-2">Current rank:</span> - <img t-attf-src="/web/image/gamification.karma.rank/#{user.rank_id.id}/image_small" height="16" alt="" class="mr-1"/> + <img t-attf-src="/web/image/gamification.karma.rank/#{user.rank_id.id}/image_64" height="16" alt="" class="mr-1"/> <a href="/profile/ranks_badges" t-field="user.rank_id"/> </div> <t t-set="next_rank_id" t-value="user._get_next_rank()"/> @@ -415,7 +415,7 @@ <div t-attf-class="d-flex mb-3 align-items-center #{'o_wslides_entry_muted' if not challenge_done else ''}"> <img class="mr-2" style="max-height: 36px;" - t-att-src="'/web/image/gamification.badge/%s/image_medium' % challenge.reward_id.id" + t-att-src="'/web/image/gamification.badge/%s/image_128' % challenge.reward_id.id" t-att-alt="challenge.reward_id.name"/> <div class="flex-grow-1"> <b class="text_small_caps" t-esc="challenge.reward_id.name"/><br/> @@ -430,7 +430,7 @@ <template id='slides_misc_user_image' name="User Avatar"> <img t-att-class="img_class if img_class else 'rounded-circle float-left'" t-att-style="img_style if img_style else 'max-height: 32px;'" - t-att-src="'/profile/avatar/%s?field=image_medium' % user.id" + t-att-src="'/profile/avatar/%s?field=image_128' % user.id" t-att-alt="user.name"/> </template> </data></odoo> diff --git a/addons/website_slides/views/website_slides_templates_lesson.xml b/addons/website_slides/views/website_slides_templates_lesson.xml index ea6b1b74b6609d39e1b85d03fc1126b17640b05d..642e097aa645e60150e96f38cc1959c7c4037dfb 100644 --- a/addons/website_slides/views/website_slides_templates_lesson.xml +++ b/addons/website_slides/views/website_slides_templates_lesson.xml @@ -89,9 +89,9 @@ <!-- Slide sub-template: display an item in a list of related slides (Related, Most Viewed, ...) --> <template id="slide_aside_card" name="Related Slide"> <a class="list-group-item list-group-item-action d-flex align-items-start px-2" t-att-href="'/slides/slide/%s' % (slug(aside_slide))"> - <t t-set="slide_image" t-value="'/web/image/slide.slide/%s/image' % aside_slide.id"/> + <t t-set="slide_image" t-value="'/web/image/slide.slide/%s/image_1024' % aside_slide.id"/> - <div t-if="aside_slide.image" class="flex-shrink-0 mr-1 border" t-attf-style="width: 20%; padding-top: 20%; background-image: url(#{slide_image}); background-size: cover; background-position:center"/> + <div t-if="aside_slide.image_1024" class="flex-shrink-0 mr-1 border" t-attf-style="width: 20%; padding-top: 20%; background-image: url(#{slide_image}); background-size: cover; background-position:center"/> <div t-else="" class="o_wslides_gradient flex-shrink-0 mr-1" t-attf-style="width: 20%; padding-top: 20%;"/> <div class="overflow-hidden d-flex flex-column justify-content-start"> <h6 t-esc="aside_slide.name" class="o_wslides_desc_truncate_2 mb-1" style="line-height: 1.15"/> @@ -234,7 +234,7 @@ </div> <div class="o_wslides_lesson_content_type"> <img t-if="slide.slide_type == 'infographic'" - t-attf-src="/web/image/slide.slide/#{slide.id}/image" class="img-fluid" style="width:100%" t-att-alt="slide.name"/> + t-attf-src="/web/image/slide.slide/#{slide.id}/image_1024" class="img-fluid" style="width:100%" t-att-alt="slide.name"/> <div t-if="slide.slide_type in ('presentation', 'document')" class="embed-responsive embed-responsive-4by3 embed-responsive-item mb8" style="height: 600px;"> <t t-raw="slide.embed_code"/> </div> diff --git a/addons/website_slides/views/website_slides_templates_lesson_embed.xml b/addons/website_slides/views/website_slides_templates_lesson_embed.xml index e6fe7a1ae81eb3ed836ed383d4b96542b9ad941f..d69ddef3215d69b9a0b972f699aa4a8afc9596a0 100644 --- a/addons/website_slides/views/website_slides_templates_lesson_embed.xml +++ b/addons/website_slides/views/website_slides_templates_lesson_embed.xml @@ -58,7 +58,7 @@ <div class="col-6 col-md-4 col-lg-3 oe_slides_suggestion_media"> <div class="card mb-3"> <a t-att-href="suggest_slide.website_url" target="_new" class="card-img-top embed-responsive embed-responsive-16by9"> - <img t-attf-src="/web/image/slide.slide/#{suggest_slide.id}/image" class="card-img-top embed-responsive-item" t-att-alt="suggest_slide.name"/> + <img t-attf-src="/web/image/slide.slide/#{suggest_slide.id}/image_1024" class="card-img-top embed-responsive-item" t-att-alt="suggest_slide.name"/> </a> <div class="card-body"> <h6 class="card-title"> @@ -80,14 +80,14 @@ <i class="fa fa-circle-o-notch fa-spin mr-2"/><b>Loading...</b> </div> <div class="toast-body p-0"> - <img class="img-fluid w-100" t-attf-src="/web/image/slide.slide/#{slide.id}/image_large"/> + <img class="img-fluid w-100" t-attf-src="/web/image/slide.slide/#{slide.id}/image_256"/> </div> </div> </div> <canvas id="PDFViewerCanvas" class="img-fluid w-100" style="display: none;"></canvas> </t> <t t-if="slide.slide_type == 'infographic'"> - <img t-attf-src="/web/image/slide.slide/#{slide.id}/image" class="img-fluid" style="width: 100%" alt="Slide image"/> + <img t-attf-src="/web/image/slide.slide/#{slide.id}/image_1024" class="img-fluid" style="width: 100%" alt="Slide image"/> </t> </div> <!-- Fixed bottom navbar --> diff --git a/addons/website_slides/views/website_slides_templates_profile.xml b/addons/website_slides/views/website_slides_templates_profile.xml index 212b0ad99935e3f1f2913915bee71bb8bc717636..e083fd724d6b49dba0f5f68c0e43f6cb9ebbf609 100644 --- a/addons/website_slides/views/website_slides_templates_profile.xml +++ b/addons/website_slides/views/website_slides_templates_profile.xml @@ -39,7 +39,7 @@ <div class="card-body o_wprofile_slides_course_card_body p-0 d-flex" t-attf-onclick="location.href='/slides/#{slug(course.channel_id)}';"> - <div t-if="course.channel_id.image" class="pl-5 pr-4 rounded-left" t-attf-style="background-image:url(/web/image/slide.channel/#{course.channel_id.id}/image); background-size: cover; background-position: center"/> + <div t-if="course.channel_id.image_1024" class="pl-5 pr-4 rounded-left" t-attf-style="background-image:url(/web/image/slide.channel/#{course.channel_id.id}/image_1024); background-size: cover; background-position: center"/> <div t-else="" class="o_wslides_gradient pl-5 pr-4 rounded-left position-relative" style="opacity: 0.8"> <i class="fa fa-graduation-cap fa-fw mr-2 mt-3 position-absolute text-white-75" style="right:0; top: 0"/> </div> diff --git a/addons/website_slides_survey/data/slide_slide_demo.xml b/addons/website_slides_survey/data/slide_slide_demo.xml index fe4642fbaf51ca4e4649956fa2ee9d8b5c8ca385..bf9cc7c95f924b731a5785cd7614eaece5e383a2 100644 --- a/addons/website_slides_survey/data/slide_slide_demo.xml +++ b/addons/website_slides_survey/data/slide_slide_demo.xml @@ -6,7 +6,7 @@ <record id="slide_slide_demo_5_4" model="slide.slide"> <field name="name">Furniture Creation Certification</field> <field name="sequence">5</field> - <field name="image" type="base64" file="website_slides/static/src/img/channel_demo_furniture.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel_demo_furniture.jpg"/> <field name="slide_type">certification</field> <field name="channel_id" ref="website_slides.slide_channel_demo_5_furn2"/> <field name="category_id" ref="website_slides.slide_category_demo_5_0"/> @@ -21,7 +21,7 @@ <record id="slide_slide_demo_6_0" model="slide.slide"> <field name="name">DIY Furniture Certification</field> <field name="sequence">1</field> - <field name="image" type="base64" file="website_slides/static/src/img/channel_demo_furniture_3.jpg"/> + <field name="image_1920" type="base64" file="website_slides/static/src/img/channel_demo_furniture_3.jpg"/> <field name="slide_type">certification</field> <field name="channel_id" ref="website_slides.slide_channel_demo_6_furn3"/> <field name="category_id" eval="False"/> diff --git a/addons/website_slides_survey/views/website_profile.xml b/addons/website_slides_survey/views/website_profile.xml index 105a5843861a704fd3ecbd47398d6214b7397081..dd80c485308ddbb4c876cd374a0c83d2e5a7a4a5 100644 --- a/addons/website_slides_survey/views/website_profile.xml +++ b/addons/website_slides_survey/views/website_profile.xml @@ -17,7 +17,7 @@ <div class="col-12 col-lg-6" t-foreach="certificates" t-as="certificate"> <div class="card mb-2"> <div class="card-body o_wprofile_slides_course_card_body p-0 d-flex"> - <div class="pl-5 pr-4 rounded-left" t-attf-style="background-image:url(/web/image/slide.slide/#{certificate.slide_id.id}/image_medium); background-position: center"/> + <div class="pl-5 pr-4 rounded-left" t-attf-style="background-image:url(/web/image/slide.slide/#{certificate.slide_id.id}/image_128); background-position: center"/> <div class="p-2 w-100"> <h5 class="mt-0 mb-1" t-esc="certificate.survey_id.title"/> <div t-if="user.id == uid"> diff --git a/doc/reference/javascript_reference.rst b/doc/reference/javascript_reference.rst index e963cf878f5dd7e6b0489368811d52acb640c09b..2b2b51e4dc84a9417e71a1a775c1674ef34801dd 100644 --- a/doc/reference/javascript_reference.rst +++ b/doc/reference/javascript_reference.rst @@ -1763,7 +1763,7 @@ order. .. code-block:: xml - <field name="image" widget='image' options='{"preview_image":"image_medium"}'/> + <field name="image" widget='image' options='{"preview_image":"image_128"}'/> - binary (FieldBinaryFile) Generic widget to allow saving/downloading a binary file. diff --git a/odoo/addons/base/data/res_partner_data.xml b/odoo/addons/base/data/res_partner_data.xml index ee4b4fbf31cf7fec9fdfcd3382ebc68b8d1e54f4..951240cf6ae8a8c70722a16a12e4117e73718849 100644 --- a/odoo/addons/base/data/res_partner_data.xml +++ b/odoo/addons/base/data/res_partner_data.xml @@ -11,7 +11,7 @@ <field name="phone"></field> <field name="email">info@yourcompany.com</field> <field name="website">www.yourcompany.com</field> - <field name="image" type="base64" file="base/static/img/res_company_logo.png"/> + <field name="image_1920" type="base64" file="base/static/img/res_company_logo.png"/> </record> <record model="res.partner" id="base.partner_root"> @@ -25,7 +25,7 @@ <field name="name">Administrator</field> <field name="company_id" ref="main_company"/> <field name="email">admin@example.com</field> - <field name="image" type="base64" file="base/static/img/avatar_grey.png"/> + <field name="image_1920" type="base64" file="base/static/img/avatar_grey.png"/> </record> <record id="public_partner" model="res.partner"> diff --git a/odoo/addons/base/data/res_partner_demo.xml b/odoo/addons/base/data/res_partner_demo.xml index 39e3c8dedd6e21c5c7d321d37dc88fed80607913..3f97483710a34883491460ee958b52adaa9d38b5 100644 --- a/odoo/addons/base/data/res_partner_demo.xml +++ b/odoo/addons/base/data/res_partner_demo.xml @@ -51,7 +51,7 @@ <field name="email">wood.corner26@example.com</field> <field name="phone">(623)-853-7197</field> <field name="website">http://www.wood-corner.com</field> - <field name="image" type="base64" file="base/static/img/res_partner_1-image.png"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_1-image.png"/> </record> <record id="res_partner_2" model="res.partner"> <field name="name">Deco Addict</field> @@ -65,7 +65,7 @@ <field name="email">deco.addict82@example.com</field> <field name="phone">(603)-996-3829</field> <field name="website">http://www.deco-addict.com</field> - <field name="image" type="base64" file="base/static/img/res_partner_2-image.png"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_2-image.png"/> </record> <record id="res_partner_3" model="res.partner"> <field name="name">Gemini Furniture</field> @@ -79,9 +79,9 @@ <field name="email">gemini.furniture39@example.com</field> <field name="phone">(941)-284-4875</field> <field name="website">http://www.gemini-furniture.com/</field> - <field name="image" type="base64" file="base/static/img/res_partner_3-image.png"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_3-image.png"/> </record> - + <record id="res_partner_4" model="res.partner"> <field name="name">Ready Mat</field> <field eval="[(6, 0, [ref('res_partner_category_14'), ref('res_partner_category_12')])]" name="category_id"/> @@ -94,7 +94,7 @@ <field name="email">ready.mat28@example.com</field> <field name="phone">(803)-873-6126</field> <field name="website">http://www.ready-mat.com/</field> - <field name="image" type="base64" file="base/static/img/res_partner_4-image.png"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_4-image.png"/> </record> <record id="res_partner_10" model="res.partner"> @@ -107,9 +107,9 @@ <field name="country_id" ref="base.us"/> <field name="email">jackson.group82@example.com</field> <field name="phone">(334)-502-1024</field> - <field name="image" type="base64" file="base/static/img/res_partner_10-image.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_10-image.jpg"/> </record> - + <record id="res_partner_12" model="res.partner"> <field name="name">Azure Interior</field> <field eval="[(6, 0, [ref('res_partner_category_11')])]" name="category_id"/> @@ -122,7 +122,7 @@ <field name="country_id" ref="base.us"/> <field name="email">azure.Interior24@example.com</field> <field name="website">http://www.azure-interior.com</field> - <field name="image" type="base64" file="base/static/img/res_partner_12-image.png"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_12-image.png"/> </record> <record id="res_partner_18" model="res.partner"> @@ -136,7 +136,7 @@ <field name="phone">(828)-316-0593</field> <field name="country_id" ref="base.us"/> <field name="website">http://www.lumber-inc.com</field> - <field name="image" type="base64" file="base/static/img/res_partner_18-image.png"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_18-image.png"/> </record> <record id="res_partner_address_1" model="res.partner"> diff --git a/odoo/addons/base/data/res_partner_image_demo.xml b/odoo/addons/base/data/res_partner_image_demo.xml index a74973eedb4a3e65bec1087672d8c79eb482e3f4..d70d8624ad8fc34345487363a9608e5a4b9b6703 100644 --- a/odoo/addons/base/data/res_partner_image_demo.xml +++ b/odoo/addons/base/data/res_partner_image_demo.xml @@ -3,103 +3,103 @@ <data noupdate="0"> <record id="base.res_partner_address_1" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_1.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_1.jpg"/> </record> <record id="base.res_partner_address_2" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_2.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_2.jpg"/> </record> <record id="base.res_partner_address_3" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_3.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_3.jpg"/> </record> <record id="base.res_partner_address_4" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_4.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_4.jpg"/> </record> <record id="base.res_partner_address_5" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_5.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_5.jpg"/> </record> <record id="base.res_partner_address_7" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_7.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_7.jpg"/> </record> <record id="base.res_partner_address_10" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_10.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_10.jpg"/> </record> <record id="base.res_partner_address_11" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_11.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_11.jpg"/> </record> <record id="base.res_partner_address_13" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_13.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_13.jpg"/> </record> <record id="base.res_partner_address_14" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_14.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_14.jpg"/> </record> <record id="base.res_partner_address_15" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_15.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_15.jpg"/> </record> <record id="base.res_partner_address_16" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_16.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_16.jpg"/> </record> <record id="base.res_partner_address_17" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_17.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_17.jpg"/> </record> <record id="base.res_partner_address_18" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_18.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_18.jpg"/> </record> <record id="base.res_partner_address_24" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_24.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_24.jpg"/> </record> <record id="base.res_partner_address_25" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_25.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_25.jpg"/> </record> <record id="base.res_partner_address_27" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_27.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_27.jpg"/> </record> <record id="base.res_partner_address_28" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_28.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_28.jpg"/> </record> <record id="base.res_partner_address_30" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_30.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_30.jpg"/> </record> <record id="base.res_partner_address_31" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_31.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_31.jpg"/> </record> <record id="base.res_partner_address_32" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_32.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_32.jpg"/> </record> <record id="base.res_partner_address_33" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_33.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_33.jpg"/> </record> <record id="base.res_partner_address_34" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_address_34.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_address_34.jpg"/> </record> <record id="base.res_partner_main1" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_main1.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_main1.jpg"/> </record> <record id="base.res_partner_main2" model="res.partner"> - <field name="image" type="base64" file="base/static/img/res_partner_main2.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/res_partner_main2.jpg"/> </record> </data> diff --git a/odoo/addons/base/data/res_users_data.xml b/odoo/addons/base/data/res_users_data.xml index f274489fb1d9ed4683a5f95d1629ac7ea2bbeae1..6439180c2a757bfbfacb9863ed4ef75d6c40fff3 100644 --- a/odoo/addons/base/data/res_users_data.xml +++ b/odoo/addons/base/data/res_users_data.xml @@ -36,7 +36,7 @@ Administrator</span>]]></field> <field name="password"></field> <!-- Avoid auto-including this demo user in any default group --> <field name="groups_id" eval="[(6,0,[])]"/> - <field name="image" type="base64" file="base/static/img/public_user-image.png"/> + <field name="image_1920" type="base64" file="base/static/img/public_user-image.png"/> <field name="partner_id" ref="public_partner"/> <field name="active" eval="False"/> </record> diff --git a/odoo/addons/base/data/res_users_demo.xml b/odoo/addons/base/data/res_users_demo.xml index 4f4c580dfb8cae9612a76d0d4d703afa3c2d0699..980c4d2b3bc08dff099c86cd169e9ea05f4133a5 100644 --- a/odoo/addons/base/data/res_users_demo.xml +++ b/odoo/addons/base/data/res_users_demo.xml @@ -36,7 +36,7 @@ <field name="signature" type="xml"><span>-- <br/>+Mr Demo</span></field> <field name="company_id" ref="main_company"/> <field name="groups_id" eval="[(6,0,[ref('base.group_user'), ref('base.group_partner_manager')])]"/> - <field name="image" type="base64" file="base/static/img/user_demo-image.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/user_demo-image.jpg"/> </record> <record model="res.partner" id="base.partner_root"> @@ -55,7 +55,7 @@ <field name="phone">+1 555-555-5555</field> <field name="email">admin@yourcompany.example.com</field> <field name="tz">Europe/Brussels</field> - <field name="image" type="base64" file="base/static/img/partner_root-image.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/partner_root-image.jpg"/> </record> @@ -69,7 +69,7 @@ <field name="zip">07002</field> <field name="country_id" ref="base.us"/> <field name="company_name">YourCompany</field> - <field name="image" type="base64" file="base/static/img/partner_demo_portal.jpg"/> + <field name="image_1920" type="base64" file="base/static/img/partner_demo_portal.jpg"/> <field name="phone">(683)-556-5104</field> </record> <record id="demo_user0" model="res.users" context="{'no_reset_password': True}"> diff --git a/odoo/addons/base/models/image_mixin.py b/odoo/addons/base/models/image_mixin.py index 855415e385fcff907efa4d573ced3987ab1b4b19..e8a04cde5dca2b4f3ca8f9332b83c1d96daa3f77 100644 --- a/odoo/addons/base/models/image_mixin.py +++ b/odoo/addons/base/models/image_mixin.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import models, fields, api, tools +from odoo import models, fields class ImageMixin(models.AbstractModel): @@ -10,40 +10,11 @@ class ImageMixin(models.AbstractModel): # all image fields are base64 encoded and PIL-supported - image_original = fields.Binary("Original Image", help="Image in its original size, as it was uploaded.") + image_1920 = fields.Image("Image", max_width=1920, max_height=1920) # resized fields stored (as attachment) for performance - image_big = fields.Binary("Big-sized Image", compute='_compute_images', store=True, help="1024px * 1024px") - image_large = fields.Binary("Large-sized Image", compute='_compute_images', store=True, help="256px * 256px") - image_medium = fields.Binary("Medium-sized Image", compute='_compute_images', store=True, help="128px * 128px") - image_small = fields.Binary("Small-sized Image", compute='_compute_images', store=True, help="64px * 64px") - - can_image_be_zoomed = fields.Boolean("Can image raw be zoomed", compute='_compute_images', store=True) - - image = fields.Binary("Image", compute='_compute_image', inverse='_set_image') - - @api.depends('image_original') - def _compute_images(self): - for record in self: - image = record.image_original - # for performance: avoid calling unnecessary methods when falsy - images = image and tools.image_get_resized_images(image, big_name=False) - record.image_big = image and tools.image_get_resized_images(image, - large_name=False, medium_name=False, small_name=False)['image'] - record.image_large = image and images['image_large'] - record.image_medium = image and images['image_medium'] - record.image_small = image and images['image_small'] - record.can_image_be_zoomed = image and tools.is_image_size_above(image) - - @api.depends('image_big') - def _compute_image(self): - for record in self: - record.image = record.image_big - - def _set_image(self): - for record in self: - record.image_original = record.image - # We want the image field to be recomputed to have a correct size. - # Without this `invalidate_cache`, the image field will keep holding the - # image_original instead of the big-sized image. - self.invalidate_cache() + image_1024 = fields.Image("Image 1024", related="image_1920", max_width=1024, max_height=1024, store=True) + image_512 = fields.Image("Image 512", related="image_1920", max_width=512, max_height=512, store=True) + image_256 = fields.Image("Image 256", related="image_1920", max_width=256, max_height=256, store=True) + image_128 = fields.Image("Image 128", related="image_1920", max_width=128, max_height=128, store=True) + image_64 = fields.Image("Image 64", related="image_1920", max_width=64, max_height=64, store=True) diff --git a/odoo/addons/base/models/res_company.py b/odoo/addons/base/models/res_company.py index cc5ddc750875f04366c6015e001758b3b28e669a..17c4e95446f142312f9628855529181f142eadcc 100644 --- a/odoo/addons/base/models/res_company.py +++ b/odoo/addons/base/models/res_company.py @@ -70,7 +70,7 @@ class Company(models.Model): partner_id = fields.Many2one('res.partner', string='Partner', required=True) report_header = fields.Text(string='Company Tagline', help="Appears by default on the top right corner of your printed documents (report header).") report_footer = fields.Text(string='Report Footer', translate=True, help="Footer text displayed at the bottom of all reports.") - logo = fields.Binary(related='partner_id.image', default=_get_logo, string="Company Logo", readonly=False) + logo = fields.Binary(related='partner_id.image_1920', default=_get_logo, string="Company Logo", readonly=False) # logo_web: do not store in attachments, since the image is retrieved in SQL for # performance reasons (see addons/web/controllers/main.py, Binary.company_logo) logo_web = fields.Binary(compute='_compute_logo_web', store=True, attachment=False) @@ -154,10 +154,10 @@ class Company(models.Model): for company in self: company.partner_id.country_id = company.country_id - @api.depends('partner_id', 'partner_id.image') + @api.depends('partner_id.image_1920') def _compute_logo_web(self): for company in self: - company.logo_web = tools.image_process(company.partner_id.image, size=(180, 0)) + company.logo_web = tools.image_process(company.partner_id.image_1920, size=(180, 0)) @api.onchange('state_id') def _onchange_state(self): @@ -218,7 +218,7 @@ class Company(models.Model): partner = self.env['res.partner'].create({ 'name': vals['name'], 'is_company': True, - 'image': vals.get('logo'), + 'image_1920': vals.get('logo'), 'email': vals.get('email'), 'phone': vals.get('phone'), 'website': vals.get('website'), diff --git a/odoo/addons/base/models/res_partner.py b/odoo/addons/base/models/res_partner.py index e9c3f91c44af2acbd14e90077fc1a01f29da177d..c4671db916adf25c507a4db1d5b27834e649cfab 100644 --- a/odoo/addons/base/models/res_partner.py +++ b/odoo/addons/base/models/res_partner.py @@ -15,7 +15,7 @@ import requests from lxml import etree from werkzeug import urls -from odoo import api, fields, models, tools, SUPERUSER_ID, _ +from odoo import api, fields, models, tools, _ from odoo.modules import get_module_resource from odoo.osv.expression import get_unaccent_wrapper from odoo.exceptions import UserError, ValidationError @@ -130,7 +130,7 @@ class PartnerTitle(models.Model): class Partner(models.Model): _description = 'Contact' - _inherit = ['format.address.mixin'] + _inherit = ['format.address.mixin', 'image.mixin'] _name = "res.partner" _order = "display_name" @@ -220,16 +220,6 @@ class Partner(models.Model): store=True) company_name = fields.Char('Company Name') - # image: all image fields are base64 encoded and PIL-supported - image = fields.Binary("Image") - image_medium = fields.Binary("Medium-sized image", - help="Medium-sized image of this contact. 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", - help="Small-sized image of this contact. It is automatically "\ - "resized as a 64x64px image, with aspect ratio preserved. "\ - "Use this field anywhere a small image is required.") # hack to allow using plain browse record in qweb views, and used in ir.qweb.field.contact self = fields.Many2one(comodel_name=_name, compute='_compute_get_ids') @@ -329,7 +319,7 @@ class Partner(models.Model): colorize, img_path, image_base64 = False, False, False if partner_type in ['other'] and parent_id: - parent_image = self.browse(parent_id).image + parent_image = self.browse(parent_id).image_1920 image_base64 = parent_image or None if not image_base64 and partner_type == 'invoice': @@ -348,7 +338,7 @@ class Partner(models.Model): if image_base64 and colorize: image_base64 = tools.image_process(image_base64, colorize=True) - return tools.image_process(image_base64, size=tools.IMAGE_BIG_SIZE) + return image_base64 @api.model def _fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False): @@ -408,8 +398,8 @@ class Partner(models.Model): @api.onchange('email') def onchange_email(self): - if not self.image and self._context.get('gravatar_image') and self.email: - self.image = self._get_gravatar_image(self.email) + if not self.image_1920 and self._context.get('gravatar_image') and self.email: + self.image_1920 = self._get_gravatar_image(self.email) @api.onchange('parent_id', 'company_id') def _onchange_company_id(self): @@ -568,10 +558,6 @@ class Partner(models.Model): if len(companies) > 1 or company not in companies: raise UserError( ("The selected company is not compatible with the companies of the related user(s)")) - # no padding on the big image, because it's used as website logo - tools.image_resize_images(vals, return_big=False) - tools.image_resize_images(vals, return_medium=False, return_small=False) - result = True # To write in SUPERUSER on field is_company and avoid access rights problems. if 'is_company' in vals and self.user_has_groups('base.group_partner_manager') and not self.env.su: @@ -595,11 +581,8 @@ class Partner(models.Model): vals['company_name'] = False # compute default image in create, because computing gravatar in the onchange # cannot be easily performed if default images are in the way - if not vals.get('image'): - vals['image'] = self._get_default_image(vals.get('type'), vals.get('is_company'), vals.get('parent_id')) - # no padding on the big image, because it's used as website logo - tools.image_resize_images(vals, return_big=False) - tools.image_resize_images(vals, return_medium=False, return_small=False) + if not vals.get('image_1920'): + vals['image_1920'] = self._get_default_image(vals.get('type'), vals.get('is_company'), vals.get('parent_id')) partners = super(Partner, self).create(vals_list) if self.env.context.get('_partners_skip_fields_sync'): diff --git a/odoo/addons/base/models/res_users.py b/odoo/addons/base/models/res_users.py index d7ef51862cd2a435cf5e1d840cc5aa499b79c243..7606124f223f9191530c84cfeae6fd863eae9988 100644 --- a/odoo/addons/base/models/res_users.py +++ b/odoo/addons/base/models/res_users.py @@ -201,9 +201,9 @@ class Users(models.Model): __uid_cache = defaultdict(dict) # {dbname: {uid: password}} # User can write on a few of his own fields (but not his groups for example) - SELF_WRITEABLE_FIELDS = ['signature', 'action_id', 'company_id', 'email', 'name', 'image', 'image_medium', 'image_small', 'lang', 'tz'] + SELF_WRITEABLE_FIELDS = ['signature', 'action_id', 'company_id', 'email', 'name', 'image_1920', 'lang', 'tz'] # User can read a few of his own fields - SELF_READABLE_FIELDS = ['signature', 'company_id', 'login', 'email', 'name', 'image', 'image_medium', 'image_small', 'lang', 'tz', 'tz_offset', 'groups_id', 'partner_id', '__last_update', 'action_id'] + SELF_READABLE_FIELDS = ['signature', 'company_id', 'login', 'email', 'name', 'image_1920', 'image_1024', 'image_512', 'image_256', 'image_128', 'image_64', 'lang', 'tz', 'tz_offset', 'groups_id', 'partner_id', '__last_update', 'action_id'] def _default_groups(self): default_user = self.env.ref('base.default_user', raise_if_not_found=False) diff --git a/odoo/addons/base/tests/test_image.py b/odoo/addons/base/tests/test_image.py index fd9dfd4efc2d451ba9a6192e8e83f8b4d70b8889..db565bc79d87e8d10786d36d9edd930c00a080cf 100644 --- a/odoo/addons/base/tests/test_image.py +++ b/odoo/addons/base/tests/test_image.py @@ -10,14 +10,7 @@ from odoo.tests.common import TransactionCase class TestImage(TransactionCase): - """Tests for the different image tools helpers. - - The following helpers are not tested here because they are wrappers for the - other methods or they are tested elsewhere (eg. on TestWebsiteSaleImage): - - image_get_resized_images - - image_resize_images - - is_image_size_above - """ + """Tests for the different image tools helpers.""" def setUp(self): super(TestImage, self).setUp() self.bg_color = (135, 90, 123) diff --git a/odoo/addons/base/tests/test_ir_http.py b/odoo/addons/base/tests/test_ir_http.py index 6d8f29686b159347fa96c70bd6a4ac00243e1015..5d06b2f4293748f9104991917f1a2c20a2be5698 100644 --- a/odoo/addons/base/tests/test_ir_http.py +++ b/odoo/addons/base/tests/test_ir_http.py @@ -40,14 +40,14 @@ class test_ir_http_mimetype(common.TransactionCase): def test_ir_http_mimetype_basic_field(self): """ Test mimetype for classic field """ partner = self.env['res.partner'].create({ - 'image': GIF, + 'image_1920': GIF, 'name': 'Test mimetype basic field', }) status, headers, content = self.env['ir.http'].binary_content( model='res.partner', id=partner.id, - field='image', + field='image_1920', default_mimetype='application/octet-stream', ) mimetype = dict(headers).get('Content-Type') @@ -62,7 +62,7 @@ class test_ir_http_mimetype(common.TransactionCase): 'type': 'binary', }) - resized = odoo.tools.image_process(prop.value_binary, size=odoo.tools.IMAGE_SMALL_SIZE) + resized = odoo.tools.image_process(prop.value_binary, size=(64, 64)) # Simul computed field which resize and that is not attachement=True (E.G. on product) prop.write({'value_binary': resized}) status, headers, content = self.env['ir.http'].binary_content( diff --git a/odoo/addons/base/tests/test_orm.py b/odoo/addons/base/tests/test_orm.py index b16d229b4955234724ae45e0738a08330c472ab6..b44c22f19cd10ff415be5ae6c57dcd95ca8760e2 100644 --- a/odoo/addons/base/tests/test_orm.py +++ b/odoo/addons/base/tests/test_orm.py @@ -364,7 +364,7 @@ class TestInherits(TransactionCase): write_date_before = user.write_date # write base64 image - user.write({'image': 'R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='}) + user.write({'image_1920': 'R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='}) write_date_after = user.write_date self.assertNotEqual(write_date_before, write_date_after) diff --git a/odoo/addons/base/views/res_partner_views.xml b/odoo/addons/base/views/res_partner_views.xml index ee59fe130c0e5b1c4eb56f87a686b2db8b2eb6be..7099f4b0850dc57d3830d8e4e864f65794933a97 100644 --- a/odoo/addons/base/views/res_partner_views.xml +++ b/odoo/addons/base/views/res_partner_views.xml @@ -67,7 +67,7 @@ <form string="Contact"> <field name="is_company" invisible="1"/> <field name="type" invisible="1"/> - <field name="image" widget='image' class="oe_avatar" options='{"preview_image": "image_medium"}'/> + <field name="image_1920" widget='image' class="oe_avatar" options='{"preview_image": "image_128"}'/> <div class="oe_title"> <field name="company_type" options="{'horizontal': true}" class="oe_edit_only" widget="radio" groups="base.group_no_one"/> <h1> @@ -97,7 +97,7 @@ <field name="priority" eval="20"/> <field name="arch" type="xml"> <form string="Partner"> - <field name="image" widget='image' class="oe_avatar" options='{"preview_image": "image_medium"}' readonly="1"/> + <field name="image_1920" widget='image' class="oe_avatar" options='{"preview_image": "image_128"}' readonly="1"/> <div class="oe_title"> <h1> <field name="name" readonly="1"/> @@ -135,7 +135,7 @@ <field name="arch" type="xml"> <form string="Partners"> <sheet> - <field name="image" widget='image' class="oe_avatar" options='{"preview_image": "image_medium"}'/> + <field name="image_1920" widget='image' class="oe_avatar" options='{"preview_image": "image_128"}'/> <div class="oe_title"> <field name="is_company" invisible="1"/> <field name="commercial_partner_id" invisible="1"/> @@ -205,7 +205,7 @@ <sheet> <widget name="web_ribbon" text="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/> <div class="oe_button_box" name="button_box"/> - <field name="image" widget='image' class="oe_avatar" options='{"preview_image": "image_medium"}'/> + <field name="image_1920" widget='image' class="oe_avatar" options='{"preview_image": "image_128"}'/> <div class="oe_title"> <field name="is_company" invisible="1"/> <field name="commercial_partner_id" invisible="1"/> @@ -300,7 +300,7 @@ <field name="country_id"/> <field name="mobile"/> <field name="state_id"/> - <field name="image_small"/> + <field name="image_64"/> <field name="lang"/> <!-- fields in form x2many view to diminish requests --> <field name="comment"/> @@ -310,8 +310,8 @@ <t t-set="color" t-value="kanban_color(record.color.raw_value)"/> <div t-att-class="color + (record.title.raw_value == 1 ? ' oe_kanban_color_alert' : '') + ' oe_kanban_global_click'"> <div class="o_kanban_image"> - <img alt="" t-if="record.image_small.raw_value" t-att-src="kanban_image('res.partner', 'image_small', record.id.raw_value)"/> - <t t-if="!record.image_small.raw_value"> + <img alt="" t-if="record.image_64.raw_value" t-att-src="kanban_image('res.partner', 'image_64', record.id.raw_value)"/> + <t t-if="!record.image_64.raw_value"> <img alt="Delivery" t-if="record.type.raw_value === 'delivery'" t-att-src='_s + "/base/static/img/truck.png"'/> <img alt="Invoice" t-if="record.type.raw_value === 'invoice'" t-att-src='_s + "/base/static/img/money.png"'/> <t t-if="record.type.raw_value !== 'invoice' && record.type.raw_value !== 'delivery'"> @@ -373,11 +373,11 @@ <field name="mobile" widget="phone"/> </group> <group colspan="1"> - <field name="image_medium" widget="image" class="oe_avatar" nolabel="1"/> + <field name="image_1920" widget="image" class="oe_avatar" nolabel="1" options="{'image_preview': 'image_128'}"/> </group> </group> <field name="lang" invisible="True"/> - <field name="image" invisible="True"/> + <field name="image_1920" invisible="True"/> <field name="user_id" invisible="True"/> </sheet> </form> @@ -503,7 +503,7 @@ <field name="mobile"/> <field name="state_id"/> <field name="category_id"/> - <field name="image_medium"/> + <field name="image_128"/> <field name="type"/> <templates> <t t-name="kanban-box"> @@ -512,16 +512,16 @@ <t t-if="record.type.raw_value === 'delivery'" t-set="placeholder" t-value="'/base/static/img/truck.png'"/> <t t-elif="record.type.raw_value === 'invoice'" t-set="placeholder" t-value="'/base/static/img/money.png'"/> <t t-else="" t-set="placeholder" t-value="'/base/static/img/avatar_grey.png'"/> - <div class="o_kanban_image_fill_left d-none d-md-block" t-attf-style="background-image:url('#{kanban_image('res.partner', 'image_medium', record.id.raw_value, placeholder)}')"> - <img class="o_kanban_image_inner_pic" t-if="record.parent_id.raw_value" t-att-alt="record.parent_id.value" t-att-src="kanban_image('res.partner', 'image_small', record.parent_id.raw_value)"/> + <div class="o_kanban_image_fill_left d-none d-md-block" t-attf-style="background-image:url('#{kanban_image('res.partner', 'image_128', record.id.raw_value, placeholder)}')"> + <img class="o_kanban_image_inner_pic" t-if="record.parent_id.raw_value" t-att-alt="record.parent_id.value" t-att-src="kanban_image('res.partner', 'image_64', record.parent_id.raw_value)"/> </div> - <div class="o_kanban_image rounded-circle d-md-none" t-attf-style="background-image:url('#{kanban_image('res.partner', 'image_medium', record.id.raw_value, placeholder)}')"> - <img class="o_kanban_image_inner_pic" t-if="record.parent_id.raw_value" t-att-alt="record.parent_id.value" t-att-src="kanban_image('res.partner', 'image_small', record.parent_id.raw_value)"/> + <div class="o_kanban_image rounded-circle d-md-none" t-attf-style="background-image:url('#{kanban_image('res.partner', 'image_128', record.id.raw_value, placeholder)}')"> + <img class="o_kanban_image_inner_pic" t-if="record.parent_id.raw_value" t-att-alt="record.parent_id.value" t-att-src="kanban_image('res.partner', 'image_64', record.parent_id.raw_value)"/> </div> </t> <t t-else=""> <t t-set="placeholder" t-value="'/base/static/img/company_image.png'"/> - <div class="o_kanban_image_fill_left o_kanban_image_full" t-attf-style="background-image: url(#{kanban_image('res.partner', 'image_medium', record.id.raw_value, placeholder)})" role="img"/> + <div class="o_kanban_image_fill_left o_kanban_image_full" t-attf-style="background-image: url(#{kanban_image('res.partner', 'image_128', record.id.raw_value, placeholder)})" role="img"/> </t> <div class="oe_kanban_details"> <strong class="o_kanban_record_title oe_partner_heading"><field name="display_name"/></strong> diff --git a/odoo/addons/base/views/res_users_views.xml b/odoo/addons/base/views/res_users_views.xml index 7d2472ca7c0d8e62d1eef88f2ddf4fb4d627e018..0ef4f47208cec44d60882f7b1e669817139c4787 100644 --- a/odoo/addons/base/views/res_users_views.xml +++ b/odoo/addons/base/views/res_users_views.xml @@ -125,7 +125,7 @@ <div class="alert alert-info text-center mb-3" attrs="{'invisible': [('id', '>', 0)]}" role="alert"> You are inviting a new user. </div> - <field name="image" widget='image' class="oe_avatar" options='{"zoom": true, "preview_image": "image_medium"}'/> + <field name="image_1920" widget='image' class="oe_avatar" options='{"zoom": true, "preview_image": "image_128"}'/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1><field name="name" required="1"/></h1> @@ -189,7 +189,7 @@ <field name="partner_id" required="0" readonly="1"/> </div> </div> - <field name="image" widget='image' class="oe_avatar" options='{"preview_image": "image_medium"}'/> + <field name="image_1920" widget='image' class="oe_avatar" options='{"preview_image": "image_128"}'/> <div class="oe_title"> <label for="name" class="oe_edit_only"/> <h1><field name="name" required="1"/></h1> @@ -269,7 +269,7 @@ <t t-name="kanban-box"> <div t-attf-class="oe_kanban_global_click"> <div class="o_kanban_image"> - <img alt="Avatar" t-att-src="kanban_image('res.users', 'image_medium', record.id.raw_value)"/> + <img alt="Avatar" t-att-src="kanban_image('res.users', 'image_128', record.id.raw_value)"/> </div> <div class="oe_kanban_details"> <ul> @@ -342,7 +342,7 @@ <field eval="18" name="priority"/> <field name="arch" type="xml"> <form string="Users"> - <field name="image" readonly="0" widget='image' class="oe_right oe_avatar" options='{"preview_image": "image_small"}'/> + <field name="image_1920" readonly="0" widget='image' class="oe_right oe_avatar" options='{"preview_image": "image_64"}'/> <h1> <field name="name" readonly="1" class="oe_inline"/> </h1> diff --git a/odoo/addons/test_impex/tests/test_load.py b/odoo/addons/test_impex/tests/test_load.py index 2765d458a405cec93e85cbb1e92e5af3b61b3e70..e558608c449f976d93f663c6851cd887689f134b 100644 --- a/odoo/addons/test_impex/tests/test_load.py +++ b/odoo/addons/test_impex/tests/test_load.py @@ -979,7 +979,7 @@ class test_o2m_multiple(ImporterCase): class test_realworld(common.TransactionCase): def test_bigfile(self): data = json.loads(pkgutil.get_data(self.__module__, 'contacts_big.json').decode('utf-8')) - result = self.env['res.partner'].load(['name', 'mobile', 'email', 'image'], data) + result = self.env['res.partner'].load(['name', 'mobile', 'email', 'image_1920'], data) self.assertFalse(result['messages']) self.assertEqual(len(result['ids']), len(data)) diff --git a/odoo/addons/test_new_api/ir.model.access.csv b/odoo/addons/test_new_api/ir.model.access.csv index e071b1b25f141ec38ab1a7c0de0847a6ec4a3705..3db5381a4b933a194f0086ba9e0f4bac093e27e2 100644 --- a/odoo/addons/test_new_api/ir.model.access.csv +++ b/odoo/addons/test_new_api/ir.model.access.csv @@ -32,3 +32,4 @@ access_test_new_api_field_with_caps,access_test_new_api_field_with_caps,model_te access_test_new_api_req_m2o,access_test_new_api_req_m2o,model_test_new_api_req_m2o,,1,1,1,1 access_test_new_api_attachment,access_test_new_api_attachment,model_test_new_api_attachment,,1,1,1,1 access_test_new_api_attachment_host,access_test_new_api_attachment_host,model_test_new_api_attachment_host,,1,1,1,1 +access_test_new_api_model_image,access_test_new_api_model_image,model_test_new_api_model_image,,1,1,1,1 diff --git a/odoo/addons/test_new_api/models.py b/odoo/addons/test_new_api/models.py index 031b55aa3ac37547b4772384b3ab6e13e7e22aea..e045754bcc2ca7a38c9590df0b7311ad4ba5c981 100644 --- a/odoo/addons/test_new_api/models.py +++ b/odoo/addons/test_new_api/models.py @@ -480,6 +480,18 @@ class ComputeCascade(models.Model): record.baz = "<%s>" % (record.bar or "") +class ModelImage(models.Model): + _name = 'test_new_api.model_image' + _description = 'Test Image field' + + name = fields.Char(required=True) + + image = fields.Image() + image_512 = fields.Image("Image 512", related='image', max_width=512, max_height=512, store=True, readonly=False) + image_256 = fields.Image("Image 256", related='image', max_width=256, max_height=256, store=False, readonly=False) + image_128 = fields.Image("Image 128", max_width=128, max_height=128) + + class BinarySvg(models.Model): _name = 'test_new_api.binary_svg' _description = 'Test SVG upload' diff --git a/odoo/addons/test_new_api/tests/test_new_fields.py b/odoo/addons/test_new_api/tests/test_new_fields.py index d372f6f23ae69f00a1ca1de2b2873d1c0854fee1..49891ee6fd9f25d6f5ba2a407bea5d2321469fd9 100644 --- a/odoo/addons/test_new_api/tests/test_new_fields.py +++ b/odoo/addons/test_new_api/tests/test_new_fields.py @@ -1,7 +1,10 @@ # # test cases for new-style fields # +import base64 from datetime import date, datetime, time +import io +from PIL import Image from odoo import fields from odoo.exceptions import AccessError, UserError @@ -1301,11 +1304,11 @@ class TestFields(common.TransactionCase): from odoo.addons.base.tests.test_mimetypes import SVG demo_user = self.env.ref('base.user_demo') # User demo changes his own avatar - demo_user.with_user(demo_user).image = SVG + demo_user.with_user(demo_user).image_1920 = SVG # The SVG file should have been neutered attachment = self.env['ir.attachment'].search([ ('res_model', '=', demo_user.partner_id._name), - ('res_field', '=', 'image'), + ('res_field', '=', 'image_1920'), ('res_id', '=', demo_user.partner_id.id), ]) self.assertEqual(attachment.mimetype, 'text/plain') @@ -1330,6 +1333,110 @@ class TestFields(common.TransactionCase): self.assertEqual(field.related, ('monetary_id', 'amount')) self.assertEqual(field.currency_field, 'base_currency_id') + def test_94_image(self): + f = io.BytesIO() + Image.new('RGB', (4000, 2000), '#4169E1').save(f, 'PNG') + f.seek(0) + image_w = base64.b64encode(f.read()) + + f = io.BytesIO() + Image.new('RGB', (2000, 4000), '#4169E1').save(f, 'PNG') + f.seek(0) + image_h = base64.b64encode(f.read()) + + record = self.env['test_new_api.model_image'].create({ + 'name': 'image', + 'image': image_w, + 'image_128': image_w, + }) + + # test create (no resize) + self.assertEqual(record.image, image_w) + # test create (resize, width limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_128))).size, (128, 64)) + # test create related store (resize, width limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_512))).size, (512, 256)) + # test create related no store (resize, width limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_256))).size, (256, 128)) + + record.write({ + 'image': image_h, + 'image_128': image_h, + }) + + # test write (no resize) + self.assertEqual(record.image, image_h) + # test write (resize, height limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_128))).size, (64, 128)) + # test write related store (resize, height limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_512))).size, (256, 512)) + # test write related no store (resize, height limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_256))).size, (128, 256)) + + record = self.env['test_new_api.model_image'].create({ + 'name': 'image', + 'image': image_h, + 'image_128': image_h, + }) + + # test create (no resize) + self.assertEqual(record.image, image_h) + # test create (resize, height limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_128))).size, (64, 128)) + # test create related store (resize, height limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_512))).size, (256, 512)) + # test create related no store (resize, height limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_256))).size, (128, 256)) + + record.write({ + 'image': image_w, + 'image_128': image_w, + }) + + # test write (no resize) + self.assertEqual(record.image, image_w) + # test write (resize, width limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_128))).size, (128, 64)) + # test write related store (resize, width limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_512))).size, (512, 256)) + # test write related store (resize, width limited) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_256))).size, (256, 128)) + + # test create inverse store + record = self.env['test_new_api.model_image'].create({ + 'name': 'image', + 'image_512': image_w, + }) + record.invalidate_cache(fnames=['image_512'], ids=record.ids) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_512))).size, (512, 256)) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image))).size, (4000, 2000)) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_256))).size, (256, 128)) + # test write inverse store + record.write({ + 'image_512': image_h, + }) + record.invalidate_cache(fnames=['image_512'], ids=record.ids) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_512))).size, (256, 512)) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image))).size, (2000, 4000)) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_256))).size, (128, 256)) + + # test create inverse no store + record = self.env['test_new_api.model_image'].create({ + 'name': 'image', + 'image_256': image_w, + }) + record.invalidate_cache(fnames=['image_256'], ids=record.ids) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_512))).size, (512, 256)) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image))).size, (4000, 2000)) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_256))).size, (256, 128)) + # test write inverse no store + record.write({ + 'image_256': image_h, + }) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_512))).size, (256, 512)) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image))).size, (2000, 4000)) + self.assertEqual(Image.open(io.BytesIO(base64.b64decode(record.image_256))).size, (128, 256)) + class TestX2many(common.TransactionCase): def test_definition_many2many(self): diff --git a/odoo/fields.py b/odoo/fields.py index 41779826d6e2544af045bdef5bff9b675c5e15e6..8d866204765ee4947e7861668031f2747e6db6fd 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -23,7 +23,7 @@ except ImportError: import psycopg2 from .tools import float_repr, float_round, frozendict, html_sanitize, human_size, pg_varchar, \ - ustr, OrderedSet, pycompat, sql, date_utils, unique, IterableGenerator + ustr, OrderedSet, pycompat, sql, date_utils, unique, IterableGenerator, image_process from .tools import DEFAULT_SERVER_DATE_FORMAT as DATE_FORMAT from .tools import DEFAULT_SERVER_DATETIME_FORMAT as DATETIME_FORMAT from .tools.translate import html_translate, _ @@ -1906,6 +1906,33 @@ class Binary(Field): atts.unlink() +class Image(Binary): + _slots = { + 'max_width': 0, + 'max_height': 0, + } + + def create(self, record_values): + new_record_values = [] + for record, value in record_values: + new_record_values.append((record, self._image_process(value))) + super(Image, self).create(new_record_values) + + def write(self, records, value): + value = self._image_process(value) + super(Image, self).write(records, value) + + def _image_process(self, value): + if value and (self.max_width or self.max_height): + value = image_process(value, size=(self.max_width, self.max_height)) + return value + + def _compute_related(self, records): + super(Image, self)._compute_related(records) + for record in records: + record[self.name] = self._image_process(record[self.name]) + + class Selection(Field): """ :param selection: specifies the possible values for this field. diff --git a/odoo/tools/image.py b/odoo/tools/image.py index ee7d109c10bcd2da1960a2a62ef7bb10346b441a..ed1581c05cf9e7f8e01039080847fbab1743a925 100644 --- a/odoo/tools/image.py +++ b/odoo/tools/image.py @@ -25,11 +25,6 @@ FILETYPE_BASE64_MAGICWORD = { b'P': 'svg+xml', } -IMAGE_BIG_SIZE = (1024, 1024) -IMAGE_LARGE_SIZE = (256, 256) -IMAGE_MEDIUM_SIZE = (128, 128) -IMAGE_SMALL_SIZE = (64, 64) - # Arbitraty limit to fit most resolutions, including Nokia Lumia 1020 photo, # 8K with a ratio up to 16:10, and almost all variants of 4320p IMAGE_MAX_RESOLUTION = 45e6 @@ -219,7 +214,7 @@ class ImageProcess(): if new_h > h: new_w, new_h = (new_w * h) // new_h, h - # Corretly place the center of the crop. + # Correctly place the center of the crop. x_offset = (w - new_w) * center_x h_offset = (h - new_h) * center_y @@ -231,7 +226,7 @@ class ImageProcess(): return self.resize(max_width, max_height) def colorize(self): - """Replace the trasparent background by a random color. + """Replace the transparent background by a random color. :return: self to allow chaining :rtype: ImageProcess @@ -367,18 +362,18 @@ def image_to_base64(image, format, **params): return base64.b64encode(stream.getvalue()) -def is_image_size_above(base64_source, size=IMAGE_BIG_SIZE): - """Return whether or not the size of the given image `base64_source` is - above the provided `size` (tuple: width, height). +def is_image_size_above(base64_source_1, base64_source_2): + """Return whether or not the size of the given image `base64_source_1` is + above the size of the given image `base64_source_2`. """ - if not base64_source: + if not base64_source_1 or not base64_source_2: return False - if base64_source[:1] in (b'P', 'P'): + if base64_source_1[:1] in (b'P', 'P') or base64_source_2[:1] in (b'P', 'P'): # False for SVG return False - image = base64_to_image(base64_source) - width, height = image.size - return width > size[0] or height > size[1] + image_source = base64_to_image(base64_source_1) + image_target = base64_to_image(base64_source_2) + return image_source.width > image_target.width or image_source.height > image_target.height def image_guess_size_from_field_name(field_name): @@ -392,67 +387,13 @@ def image_guess_size_from_field_name(field_name): :return: the guessed size :rtype: tuple (width, height) """ - suffix = 'big' if field_name == 'image' else field_name.split('_')[-1] - if suffix == 'big': - return IMAGE_BIG_SIZE - if suffix == 'large': - return IMAGE_LARGE_SIZE - if suffix == 'medium': - return IMAGE_MEDIUM_SIZE - if suffix == 'small': - return IMAGE_SMALL_SIZE - return (0, 0) - - -def image_get_resized_images(base64_source, - big_name='image', large_name='image_large', medium_name='image_medium', small_name='image_small'): - """ Standard tool function that returns a dictionary containing the - big, medium, large and small versions of the source image. - - :param {..}_name: key of the resized image in the return dictionary; - 'image', 'image_large', 'image_medium' and 'image_small' by default. - Set a key to False to not include it. - - Refer to image_resize_image for the other parameters. - - :return return_dict: dictionary with resized images, depending on - previous parameters. - """ - return_dict = dict() - if big_name: - return_dict[big_name] = image_process(base64_source, size=IMAGE_BIG_SIZE) - if large_name: - return_dict[large_name] = image_process(base64_source, size=IMAGE_LARGE_SIZE) - if medium_name: - return_dict[medium_name] = image_process(base64_source, size=IMAGE_MEDIUM_SIZE) - if small_name: - return_dict[small_name] = image_process(base64_source, size=IMAGE_SMALL_SIZE) - return return_dict - - -def image_resize_images(vals, - return_big=True, return_large=False, return_medium=True, return_small=True, - big_name='image', large_name='image_large', medium_name='image_medium', small_name='image_small'): - """ Update ``vals`` with image fields resized as expected. """ - big_image = vals.get(big_name) - large_image = vals.get(large_name) - medium_image = vals.get(medium_name) - small_image = vals.get(small_name) - - biggest_image = big_image or large_image or medium_image or small_image - - if biggest_image: - vals.update(image_get_resized_images(biggest_image, - big_name=return_big and big_name, large_name=return_large and large_name, medium_name=return_medium and medium_name, small_name=return_small and small_name)) - elif any(f in vals for f in [big_name, large_name, medium_name, small_name]): - if return_big: - vals[big_name] = False - if return_large: - vals[large_name] = False - if return_medium: - vals[medium_name] = False - if return_small: - vals[small_name] = False + suffix = '1024' if field_name == 'image' else field_name.split('_')[-1] + if suffix == 'max': + return (1920, 1920) + try: + return (int(suffix), int(suffix)) + except ValueError: + return (0, 0) def image_data_uri(base64_source):