Permalink
Browse files

Merge pull request #710 from Rusllan/11.0-automerge-5abeb016cd044cdef…

…c18773c0d2333e323d01a9c

11.0 automerge 5abeb01
  • Loading branch information...
yelizariev committed Dec 28, 2018
2 parents d1ce509 + d7c2643 commit 786373537733ebfac9ce2a54a9d62dc4df3c8e11
@@ -75,7 +75,7 @@
<field name="name">sale.order.line.tree</field>
<field name="model">sale.order.line</field>
<field name="arch" type="xml">
<tree string="Booking Tree" colors="red:overlap">
<tree colors="red:overlap">
<field name="order_id"/>
<field name="product_id"/>
<field name="name"/>
@@ -5,7 +5,7 @@
<field name="name">Update Rates service</field>
<field name="model">currency.rate.update.service</field>
<field name="arch" type="xml">
<tree string="Rates">
<tree>
<field name="service"/>
<field name="currency_to_update"/>

@@ -6,7 +6,7 @@
<field name="name">sale.order.line.tree</field>
<field name="model">sale.order.line</field>
<field name="arch" type="xml">
<tree string="Sales Orders Lines">
<tree>
<field name="sequence" widget="handle"/>
<field name="state" invisible="1"/>
<field name="th_weight" invisible="1"/>
@@ -23,14 +23,14 @@
<notebook invisible="1">
<page string="Invoiced">
<field name="invoiced_line_ids" mode="tree" nolabel="1">
<tree string="Invoiced lines" editable="False" create="0" delete="false">
<tree editable="False" create="0" delete="false">
<field name="write_date"/>
</tree>
</field>
</page>
<page string="Draft">
<field name="draft_line_ids" mode="tree" nolabel="1">
<tree string="Draft lines" editable="False" create="0" delete="false">
<tree editable="False" create="0" delete="false">
<field name="write_date"/>
</tree>
</field>
@@ -1,4 +1,3 @@
# -*- 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
@@ -22,6 +21,9 @@ def content_image(self, xmlid=None, model='ir.attachment', id=None, field='datas

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

# TODO: if model=="product.product" and field in ('image', 'image_small', 'image_medium')
# we need to make similar trick, because those fields are computed resizes of image_variant
# with sizes 64*64, 128*128, 1024*1024
if not (res.status_code == 301 and (width or height)):
return res

@@ -1,4 +1,3 @@
# -*- 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 base64
@@ -3,7 +3,7 @@
"summary": """Use attachment URL and upload data to external storage""",
"category": "Tools",
"images": [],
"version": "11.0.1.1.7",
"version": "11.0.1.1.8",
"application": False,

"author": "IT-Projects LLC, Ildar Nasyrov",
@@ -1,3 +1,9 @@
`1.1.8`
-------

- **Fix** When a link to a picture that does not have an extension is written in a binary field, its mimetype is not determined, which leads to an "binascii.Error: decoding with base64 codec failed (Error: Incorrect padding)"
- **Improvement:** The `index_content` field is filled for attachments when a link to a file is written in a binary field.

`1.1.7`
-------

@@ -1,8 +1,33 @@
# Copyright 2017 Dinar Gabbasov <https://www.it-projects.info/team/GabbasovDinar>
# Copyright 2018 Rafis Bikbov <https://www.it-projects.info/team/RafiZz>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import fields
import mimetypes
import requests

from odoo.tools.mimetypes import guess_mimetype
from . import image


def get_mimetype_and_optional_content_by_url(url):
mimetype = mimetypes.guess_type(url)[0]
content = None

# head request for content-type header getting
if not mimetype:
with requests.head(url) as r:
mimetype = getattr(r, 'headers', {}).get('Content-Type')

index_content = mimetype and mimetype.split('/')[0]
if not mimetype or index_content == 'text':
with requests.get(url) as r:
content = getattr(r, 'content')
if not mimetype and content:
mimetype = guess_mimetype(content)

return mimetype, content


class Binary(fields.Binary):

def write(self, records, value, create=False):
@@ -20,13 +45,18 @@ def write(self, records, value, create=False):
if value and image.is_url(value):
with records.env.norecompute():
if value:
mimetype, content = get_mimetype_and_optional_content_by_url(value)
index_content = records.env['ir.attachment']._index(content, None, mimetype)

# update the existing attachments
atts.write({
'url': value,
'mimetype': mimetypes.guess_type(value)[0],
'mimetype': mimetype,
'datas': None,
'type': 'url',
'index_content': index_content,
})

# create the missing attachments
for record in (records - records.browse(atts.mapped('res_id'))):
atts.create({
@@ -36,6 +66,8 @@ def write(self, records, value, create=False):
'res_id': record.id,
'type': 'url',
'url': value,
'mimetype': mimetype,
'index_content': index_content,
})
else:
atts.unlink()
@@ -1,3 +1,6 @@
# Copyright 2017 Dinar Gabbasov <https://www.it-projects.info/team/GabbasovDinar>
# Copyright 2018 Rafis Bikbov <https://www.it-projects.info/team/RafiZz>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import tools
import re

@@ -51,7 +51,7 @@
<field name="name">pitch.tree</field>
<field name="model">pitch_booking.pitch</field>
<field name="arch" type="xml">
<tree string="Pitches">
<tree>
<field name="name"/>
<field name="venue_id"/>
</tree>
@@ -78,7 +78,7 @@
<field name="name">venue.tree</field>
<field name="model">pitch_booking.venue</field>
<field name="arch" type="xml">
<tree string="Venues">
<tree>
<field name="name"/>
</tree>
</field>
@@ -68,7 +68,7 @@
<field name="name">project_tags.project_tag.tree</field>
<field name="model">project_tags.project_tag</field>
<field name="arch" type="xml">
<tree string="project_tag"
<tree
>
<field name="name"
/>
@@ -8,7 +8,7 @@
<field name="priority" eval="999"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='timesheet_ids']/tree" position="replace">
<tree editable="bottom" string="Timesheet Activities" default_order="date">
<tree editable="bottom" default_order="date">
<field name="name" attrs="{'readonly': [('status', '=', 'nonactive')]}"/>
<field name="status" invisible="1"/>
<field name="user_current" invisible="1"/>
@@ -105,7 +105,7 @@
<field name="name">timelog</field>
<field name="model">project.timelog</field>
<field name="arch" type="xml">
<tree string="My timelog" create="false" edit="true" >
<tree create="false" edit="true" >
<field name="work_id" string="Subtask"/>
<field name="start_datetime" />
<field name="end_datetime" />
@@ -120,7 +120,7 @@
<field name="name">timelog</field>
<field name="model">project.timelog</field>
<field name="arch" type="xml">
<tree string="Timelog" create="false" edit="true" >
<tree create="false" edit="true" >
<field name="user_id" string="User"/>
<field name="work_id" sting="Subtask"/>
<field name="start_datetime" />
@@ -218,7 +218,7 @@
<field name="name">account.analytic.line.ext.tree</field>
<field name="model">account.analytic.line</field>
<field name="arch" type="xml">
<tree string="Project Task Work">
<tree>
<field name="user_id" invisible="1"/>
<field name="name" readonly="1"/>
<field name="account_id" readonly="1"/>
@@ -32,7 +32,7 @@
<field name="model">res.users.signature</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Signatures">
<tree>
<field name="name"/>
<field name="comment"/>
</tree>
@@ -6,7 +6,7 @@
<field name="name">sendandlog.tree</field>
<field name="model">sms_sg.sendandlog</field>
<field name="arch" type="xml">
<tree string="Course Tree">
<tree>
<field name="msg"/>
<field name="phone"/>
<field name="response_content"/>
@@ -15,7 +15,7 @@
<field name="name">web_iframe_pages.page.tree</field>
<field name="model">web_iframe_pages.page</field>
<field name="arch" type="xml">
<tree string="IFrame" editable="top">
<tree editable="top">
<field name="menu_id_parent_id" context="{'default_iframe_pages_group':True}"/>
<field name="menu_id_name"/>
<field name="link"/>

0 comments on commit 7863735

Please sign in to comment.