Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc addons 10.0 openapi merge stable branch #699

Merged
Changes from 1 commit
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
aaa6b9c
[NEW] sale_layout_hidden_section module (it-projects-llc/addons-dev#224)
ArtyomLosev Jun 26, 2017
c20bcd4
[DOC] Update docs for sale_layout_hidden_section (it-projects-llc/add…
ArtyomLosev Jun 28, 2017
0c4398e
[DOC] Update docs (it-projects-llc/addons-dev#229)
ArtyomLosev Jun 28, 2017
459d0bd
[ADD] added global sections (it-projects-llc/addons-dev#230)
ArtyomLosev Jun 29, 2017
9e92ccc
[ADD] global field, customized tree view (it-projects-llc/addons-dev#…
ArtyomLosev Jul 3, 2017
36300b9
[DOC] sale_layout_hidden_section description (it-projects-llc/addons-…
Englishrain Nov 3, 2017
3ed503b
[DOC] new main image (it-projects-llc/addons-dev#307)
ilmir-k Nov 3, 2017
27ddbed
[10.0][DOC] sale_layout_hidden_section: update docs (it-projects-llc/…
ilmir-k Apr 12, 2018
7713658
[DOC] update version format in manifest file
ilmir-k Apr 12, 2018
ed1e7b1
Merge branch '10.0' into 10.0-sale_layout_hidden_section
ilmir-k Apr 12, 2018
a90339f
[ADD] copyrights
ilmir-k Apr 13, 2018
1b4bf69
Merge branch '10.0-sale_layout_hidden_section' of github.com:ilmir-k/…
ilmir-k Apr 13, 2018
b9f933a
:rainbow: CI errors (#662)
GabbasovDinar Sep 25, 2018
eb92ad7
:arrow_up::one::zero: currency_rate_update (#665)
carlosrve Oct 9, 2018
10b2c95
:handshake: New Translations! We need your help ...
i18n-bot Oct 13, 2018
4b60a2e
:book: add minimal s3 access
yelizariev Oct 24, 2018
cdd1bf6
:ambulance: can't use child_of operator with many2many fields (#670)
trojikman Oct 26, 2018
581fe21
:book: IAM has to be under Installation section
yelizariev Nov 8, 2018
84f4a44
:ambulance: Product Variant were downloaded on server instead of pass…
yelizariev Nov 8, 2018
e4eea91
:zap: Save resized image to s3 instead of passing original (big) image
yelizariev Nov 8, 2018
5eec8b9
:rainbow: remove obsolete <odoo><data>
yelizariev Nov 14, 2018
bc375d9
:ambulance: when the "image_resize_image" function was called, they r…
RafiZz Nov 2, 2018
9158b5b
:rainbow: all the __openerp__.py files renamed in __manifest__.py
Rusllan Dec 4, 2018
4c73308
Merge pull request #694 from Rusllan/10.0-manifest-renaming
yelizariev Dec 4, 2018
0ae0e3a
:rainbow: removing string attribute from <tree>
Rusllan Dec 11, 2018
463b63c
Merge pull request #701 from Rusllan/10.0-string_removed
yelizariev Dec 12, 2018
3fcd192
:sos: add TODO about product.product's images
yelizariev Dec 12, 2018
5fd8495
:ambulance: 'guess_type' does not always return a result so an 'Incor…
RafiZz Dec 11, 2018
f2097c1
:rose:
RafiZz Dec 11, 2018
fb11d5f
Merge branch '10.0' into 10.0-fix-ir_attachment_url-getting_mimetype
RafiZz Dec 14, 2018
919a1b9
:book: clarify the module advantage
ilmir-k Dec 18, 2018
e34330b
:book: manifest: name and summary
ilmir-k Dec 18, 2018
c4e4214
:book: index.html: description fixes
ilmir-k Dec 18, 2018
77277dd
Merge pull request #574 from ilmir-k/10.0-sale_layout_hidden_section
yelizariev Dec 18, 2018
5abeb01
Merge pull request #699 from RafiZz/10.0-fix-ir_attachment_url-gettin…
yelizariev Dec 18, 2018
d0ca7d8
:book: Travis status added
Rusllan Dec 28, 2018
517f9a9
Merge pull request #711 from Rusllan/10.0-travis_status
yelizariev Dec 28, 2018
66e5f41
:handshake: New Translations! We need your help ...
i18n-bot Feb 9, 2019
af72455
:ambulance: Website Switcher didn't work for non-admin users
yelizariev Aug 14, 2018
3238ecc
Merge pull request #730 from yelizariev/10.0-backport-web_website-fix…
yelizariev Feb 15, 2019
d7a40eb
:zap: autocheckout feature
KolushovAlexandr Feb 1, 2019
cf5105c
:shield: tests do not work due to clock updates
KolushovAlexandr Mar 8, 2019
4149c19
:shield: logger provoked errores in tests. https://github.com/odoo/od…
KolushovAlexandr Mar 11, 2019
f9668c3
Merge pull request #728 from KolushovAlexandr/10.0-base_attendance-au…
yelizariev Mar 25, 2019
f1d2553
:shield: services postgresql 10.0
kaadevelop May 27, 2019
9ff14af
Merge pull request #751 from kaadevelop/10.0
yelizariev May 28, 2019
02697e7
:shield: postgres 10
kaadevelop May 28, 2019
beb4574
Merge pull request #753 from kaadevelop/10.0
yelizariev May 28, 2019
3e19abd
[UPD] Update attachment_large_object.pot
i18n-bot May 28, 2019
1b709ab
[UPD] Update auth_signup_confirmation.pot
i18n-bot May 28, 2019
e7fbba8
[UPD] Update auth_signup_confirmation_crm.pot
i18n-bot May 28, 2019
cc6feb3
[UPD] Update autostaging_base.pot
i18n-bot May 28, 2019
1e804f1
[UPD] Update autostaging_project_task.pot
i18n-bot May 28, 2019
7bfe644
[UPD] Update barcode_widget.pot
i18n-bot May 28, 2019
10d9215
[UPD] Update base_attendance.pot
i18n-bot May 28, 2019
77505ed
[UPD] Update base_details.pot
i18n-bot May 28, 2019
a2e77ba
[UPD] Update base_groupby_extra.pot
i18n-bot May 28, 2019
d2005af
[UPD] Update base_import_map.pot
i18n-bot May 28, 2019
c46a331
[UPD] Update base_session_store_psql.pot
i18n-bot May 28, 2019
d25f50a
[UPD] Update crm_expected_revenue.pot
i18n-bot May 28, 2019
c3a4f88
[UPD] Update crm_next_action.pot
i18n-bot May 28, 2019
6bf8940
[UPD] Update customer_marketing.pot
i18n-bot May 28, 2019
d6a141e
[UPD] Update hr_public_holidays_ics_import.pot
i18n-bot May 28, 2019
f81699a
[UPD] Update hr_rule_input_compute.pot
i18n-bot May 28, 2019
6725ebf
[UPD] Update ir_actions_todo_repeat.pot
i18n-bot May 28, 2019
e463f2e
[UPD] Update ir_attachment_force_storage.pot
i18n-bot May 28, 2019
16442a6
[UPD] Update ir_attachment_s3.pot
i18n-bot May 28, 2019
f7f048d
[UPD] Update ir_attachment_url.pot
i18n-bot May 28, 2019
5d3b17c
[UPD] Update ir_config_parameter_multi_company.pot
i18n-bot May 28, 2019
5715c2d
[UPD] Update product_category_taxes.pot
i18n-bot May 28, 2019
7cbb916
[UPD] Update product_details.pot
i18n-bot May 28, 2019
f66f6ce
[UPD] Update production_lot_details.pot
i18n-bot May 28, 2019
bde8d55
[UPD] Update product_tags.pot
i18n-bot May 28, 2019
a37d6dc
[UPD] Update project_gantt8.pot
i18n-bot May 28, 2019
43ed9f3
[UPD] Update project_task_order_kanban_state.pot
i18n-bot May 28, 2019
ea8c80c
[UPD] Update project_task_search_custom.pot
i18n-bot May 28, 2019
5ebec06
[UPD] Update project_task_subtask.pot
i18n-bot May 28, 2019
d8ebfea
[UPD] Update reminder_base.pot
i18n-bot May 28, 2019
0b96555
[UPD] Update reminder_crm_next_action.pot
i18n-bot May 28, 2019
3e2d51f
[UPD] Update reminder_crm_next_action_time.pot
i18n-bot May 28, 2019
fc07adc
[UPD] Update reminder_hr_recruitment.pot
i18n-bot May 28, 2019
57877b8
[UPD] Update reminder_task_deadline.pot
i18n-bot May 28, 2019
fc21546
[UPD] Update res_partner_phone.pot
i18n-bot May 28, 2019
f944eca
[UPD] Update res_partner_skype.pot
i18n-bot May 28, 2019
8ea9c48
[UPD] Update sale_layout_hidden_section.pot
i18n-bot May 28, 2019
a30da17
[UPD] Update sale_order_hide_tax.pot
i18n-bot May 28, 2019
25d8a29
[UPD] Update sms_sg.pot
i18n-bot May 28, 2019
608ea29
[UPD] Update theme_kit.pot
i18n-bot May 28, 2019
20b9f85
[UPD] Update web_debranding.pot
i18n-bot May 28, 2019
d5f44ed
[UPD] Update web_gantt8.pot
i18n-bot May 28, 2019
2f3b20f
[UPD] Update web_polymorphic_field.pot
i18n-bot May 28, 2019
fcb6ab9
[UPD] Update web_preview.pot
i18n-bot May 28, 2019
7c132fb
[UPD] Update web_website.pot
i18n-bot May 28, 2019
5e9f5f3
:handshake: New Translations! We need your help ...
i18n-bot May 29, 2019
e40ece5
:shield: remove transifex settings; auto creating *.pot files
kaadevelop May 29, 2019
c8e22f2
Merge pull request #755 from kaadevelop/10.0_transifex
yelizariev May 30, 2019
cc8cc9c
:shield: travis.yml notifications webhook travis
kaadevelop Jun 24, 2019
27246f7
Merge pull request #766 from kaadevelop/10.0
yelizariev Jun 24, 2019
4195910
:arrow_up::one::zero: porting project_timelog from 9.0 to 10.0
GabbasovDinar Feb 27, 2018
0e648f1
:shield: web_website
GabbasovDinar Feb 1, 2019
0523cc9
:ambulance: timelog incompatibility with some odoo modules
KolushovAlexandr Jul 2, 2019
57a8e30
:shield: base_attendance test compatibility with timelog module
KolushovAlexandr Jul 2, 2019
520a12e
:green_heart: timelog
KolushovAlexandr Jul 2, 2019
f77602b
Merge pull request #772 from KolushovAlexandr/10.0-timelog-tests
yelizariev Jul 5, 2019
c0126d6
:book: image for App stor updated
Mirgalimova Jul 20, 2019
7234f9b
Merge pull request #783 from Mirgalimova/10.0-images
yelizariev Jul 22, 2019
22cee9c
:book: doc cleanup
yelizariev Jul 25, 2019
22498b1
:shield: travis.yml enable check tags
Aug 2, 2019
455729a
Merge pull request #791 from kaadevelop/10.0
itpp-bot Aug 7, 2019
5fb3e2c
Merge remote-tracking branch 'misc-addons/10.0' into misc-addons-10.0…
yelizariev Aug 10, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

⚡️ Save resized image to s3 instead of passing original (big) image

  • Loading branch information...
yelizariev committed Nov 8, 2018
commit e4eea911d2e6b55d0ff464788b62b3b58e573e83
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

from . import models
from . import controllers
@@ -4,7 +4,7 @@
"summary": """Upload attachments on Amazon S3""",
"category": "Tools",
"images": [],
"version": "10.0.1.1.2",
"version": "10.0.1.2.0",
"application": False,

"author": "IT-Projects LLC, Ildar Nasyrov",
@@ -19,6 +19,7 @@
"external_dependencies": {"python": ['boto3'], "bin": []},
"data": [
"views/ir_attachment_s3.xml",
"security/ir.model.access.csv",
],
"qweb": [
],
@@ -0,0 +1 @@
from . import main
@@ -0,0 +1,88 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
import logging
import werkzeug

import odoo
from odoo.http import request, route
from odoo.addons.web.controllers.main import Binary
# TODO some code can be part of ir_attachment_url

_logger = logging.getLogger(__name__)


class BinaryExtended(Binary):

def redirect_to_url(self, url):
return werkzeug.utils.redirect(url, code=301)

@route()
def content_image(self, xmlid=None, model='ir.attachment', id=None, field='datas', filename_field='datas_fname', unique=None, filename=None, mimetype=None, download=None, width=0, height=0):

res = super(BinaryExtended, self).content_image(xmlid, model, id, field, filename_field, unique, filename, mimetype, download, width, height)

if not (res.status_code == 301 and (width or height)):
return res

# * check that it's image on s3
# * upload resized image if needed
# * return url to resized image

# FIND ATTACHMENT. The code is copy-pasted from binary_content method
env = request.env
# get object and content
obj = None
if xmlid:
obj = env.ref(xmlid, False)
elif id and model in env.registry:
obj = env[model].browse(int(id))

attachment = None
if model == 'ir.attachment':
attachment = obj
else:
attachment = env['ir.http'].find_field_attachment(env, model, field, obj)

if not attachment:
# imposible case?
_logger.error('Attachment is not found')
return res

# FIX SIZES
height = int(height or 0)
width = int(width or 0)
# resize maximum 500*500
if width > 500:
width = 500
if height > 500:
height = 500

# CHECK FOR CACHE.
# We may already uploaded that resized image
cache = env['ir.attachment.resized'].sudo().search([
('attachment_id', '=', attachment.id),
('width', '=', width),
('height', '=', height),
])
if cache:
url = cache.resized_attachment_id.url
return self.redirect_to_url(url)

# PREPARE CACHE
content = attachment.datas
content = odoo.tools.image_resize_image(base64_source=content, size=(width or None, height or None), encoding='base64', filetype='PNG')
resized_attachment = env['ir.attachment'].with_context(force_s3=True).create({
'name': '%sx%s %s' % (width, height, attachment.name),
'datas': content,
})

env['ir.attachment.resized'].sudo().create({
'attachment_id': attachment.id,
'width': width,
'height': height,
'resized_attachment_id': resized_attachment.id,
})

url = resized_attachment.url
return self.redirect_to_url(url)
@@ -1,3 +1,8 @@
`1.2.0`
-------

- **Improvement:** Save resized image to s3 instead of passing original (big) image

`1.1.2`
-------

@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2018 Ildar Nasyrov <https://it-projects.info/team/iledarn>
# Copyright 2016-2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
import os
import hashlib
import logging

from odoo import api, models, _
from odoo import api, models, _, fields
from odoo.tools.safe_eval import safe_eval

_logger = logging.getLogger(__name__)
@@ -15,9 +17,21 @@
found on your installation')


class IrAttachmentResized(models.Model):
_name = 'ir.attachment.resized'
_description = 'Url to resized image'

attachment_id = fields.Many2one('ir.attachment')
width = fields.Integer()
height = fields.Integer()
resized_attachment_id = fields.Many2one('ir.attachment', ondelete='cascade')


class IrAttachment(models.Model):
_inherit = 'ir.attachment'

resized_ids = fields.One2many('ir.attachment.resized', 'attachment_id')

def _get_s3_settings(self, param_name, os_var_name):
config_obj = self.env['ir.config_parameter']
res = config_obj.sudo().get_param(param_name)
@@ -62,11 +76,12 @@ def _get_s3_resource(self):
def _inverse_datas(self):
# set s3_records to empty recordset
condition = self._get_s3_settings('s3.condition', 'S3_CONDITION')
if condition:
if condition and not self.env.context.get('force_s3'):
condition = safe_eval(condition, mode="eval")
s3_records = self.sudo().search([('id', 'in', self.ids)] + condition)
else:
# if there is no condition then store all attachments on s3
# if there is no condition or force_s3 in context
# then store all attachments on s3
s3_records = self

if s3_records:
@@ -78,7 +93,9 @@ def _inverse_datas(self):
s3_records = s3_records._filter_protected_attachments()
s3_records = s3_records.filtered(lambda r: r.type != 'url')

resized_to_remove = self.env['ir.attachment.resized'].sudo()
for attach in self & s3_records: # datas field has got empty somehow in the result of ``s3_records = self.sudo().search([('id', 'in', self.ids)] + condition)`` search for non-superusers but it is in original recordset. Here we use original (with datas) in case it intersects with the search result
resized_to_remove |= attach.sudo().resized_ids
value = attach.datas
bin_data = value and value.decode('base64') or ''
fname = hashlib.sha1(bin_data).hexdigest()
@@ -102,4 +119,6 @@ def _inverse_datas(self):
}
super(IrAttachment, attach.sudo()).write(vals)

resized_to_remove.mapped('resized_attachment_id').unlink()
resized_to_remove.unlink()
super(IrAttachment, self - s3_records)._inverse_datas()
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_ir_attachment_resized,access_ir_attachment_resized,model_ir_attachment_resized,base.group_user,1,0,0,0
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.