Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/10.0' into 11.0-automerge-5abe…
Browse files Browse the repository at this point in the history
…b016cd044cdefc18773c0d2333e323d01a9c
  • Loading branch information
Rusllan committed Dec 27, 2018
2 parents b377a39 + 5abeb01 commit 8b6b191
Show file tree
Hide file tree
Showing 28 changed files with 363 additions and 19 deletions.
2 changes: 1 addition & 1 deletion base_attendance/views/res_attendance_view.xml
Expand Up @@ -10,7 +10,7 @@
<field name="name">res.partner.attendance.tree</field>
<field name="model">res.partner.attendance</field>
<field name="arch" type="xml">
<tree string="Partner attendances">
<tree>
<field name="partner_id"/>
<field name="check_in"/>
<field name="check_out"/>
Expand Down
2 changes: 1 addition & 1 deletion booking_calendar/views.xml
Expand Up @@ -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"/>
Expand Down
2 changes: 1 addition & 1 deletion currency_rate_update/currency_rate_update.xml
Expand Up @@ -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"/>

Expand Down
Expand Up @@ -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"/>
Expand Down
Expand Up @@ -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>
Expand Down
3 changes: 3 additions & 0 deletions ir_attachment_s3/controllers/main.py
Expand Up @@ -22,6 +22,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

Expand Down
2 changes: 1 addition & 1 deletion ir_attachment_url/__manifest__.py
Expand Up @@ -4,7 +4,7 @@
"summary": """Use attachment URL and upload data to external storage""",
"category": "Tools",
"images": [],
"version": "10.0.1.1.6",
"version": "10.0.1.1.7",
"application": False,

"author": "IT-Projects LLC, Ildar Nasyrov",
Expand Down
6 changes: 6 additions & 0 deletions ir_attachment_url/doc/changelog.rst
@@ -1,3 +1,9 @@
`1.1.7`
-------

- **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.6`
-------

Expand Down
36 changes: 34 additions & 2 deletions ir_attachment_url/models/binary_fields.py
@@ -1,9 +1,34 @@
# -*- coding: utf-8 -*-
from odoo import fields
# 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).
import mimetypes
import requests

from odoo import fields
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):
Expand All @@ -21,13 +46,18 @@ def write(self, records, value):
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({
Expand All @@ -37,6 +67,8 @@ def write(self, records, value):
'res_id': record.id,
'type': 'url',
'url': value,
'mimetype': mimetype,
'index_content': index_content,
})
else:
atts.unlink()
Expand Down
3 changes: 3 additions & 0 deletions ir_attachment_url/models/image.py
@@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
# 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

Expand Down
4 changes: 2 additions & 2 deletions pitch_booking/views.xml
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion project_tags/view/project_tag_view.xml
Expand Up @@ -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"
/>
Expand Down
8 changes: 4 additions & 4 deletions project_timelog/views/project_timelog_views.xml
Expand Up @@ -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"/>
Expand Down Expand Up @@ -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" />
Expand All @@ -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" />
Expand Down Expand Up @@ -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"/>
Expand Down
2 changes: 1 addition & 1 deletion res_users_signature/res_users_signature_views.xml
Expand Up @@ -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>
Expand Down
45 changes: 45 additions & 0 deletions sale_layout_hidden_section/README.rst
@@ -0,0 +1,45 @@
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.png
:target: https://www.gnu.org/licenses/lgpl
:alt: License: LGPL-3

============================
Sale Layout Hidden Section
============================

In Odoo all the layouts are the corresponding sections, which used to group the PDF report data. By default, all such layouts are displayed for every existing Sale Orders and there are no possibility to display a specific one. So it is inconvenient, because some of the layouts may not suit for some set of sale orders.

The module eliminates this disadvantage, because allows to use layouts only within Sale Order they created for.

Credits
=======

Contributors
------------
* Artyom Losev <apps@it-projects.info>

Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__

Maintainers
-----------
* `IT-Projects LLC <https://it-projects.info>`__

To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/10.0/sale_layout_hidden_section/>`__.

Thank you for understanding!

`IT-Projects Team <https://www.it-projects.info/team>`__

Further information
===================

Demo: http://runbot.it-projects.info/demo/misc-addons/10.0

HTML Description: https://apps.odoo.com/apps/modules/10.0/sale_layout_hidden_section

Usage instructions: `<doc/index.rst>`_

Changelog: `<doc/changelog.rst>`_

Tested on Odoo 10.0 e66e1e2142aa8812149e82cdc5f391aa9599cea6
4 changes: 4 additions & 0 deletions sale_layout_hidden_section/__init__.py
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from . import models
34 changes: 34 additions & 0 deletions sale_layout_hidden_section/__manifest__.py
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Artyom Losev
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": """Separate Layouts for Sale Orders""",
"summary": """
Display the layouts (sections) within the Sale Orders they were created for""",
"category": "Sale",
"images": ['images/sale_layout_hidden_section.png'],
"version": "10.0.1.0.0",
"application": False,

"author": "IT-Projects LLC, Artyom Losev",
"support": "apps@it-projects.info",
"website": "https://it-projects.info",
"price": 29.00,
"currency": 'EUR',

"license": "LGPL-3",

"depends": [
"sale",
],
"external_dependencies": {"python": [], "bin": []},
"data": [
'views/views.xml'
],
"post_load": None,
"pre_init_hook": None,
"post_init_hook": None,

"auto_install": False,
"installable": True,
}
4 changes: 4 additions & 0 deletions sale_layout_hidden_section/doc/changelog.rst
@@ -0,0 +1,4 @@
`1.0.0`
-------

- Init version
35 changes: 35 additions & 0 deletions sale_layout_hidden_section/doc/index.rst
@@ -0,0 +1,35 @@
================================
Hidden Layouts for Sale Orders
================================

Installation
============

* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way


Configuration
=============

* Open ``Sales >> Settings`` menu
* Switch **Sales Reports Layout** to *Personalize the sales orders and invoice report with categories, subtotals and page-breaks*
* Click ``[Apply]``

Usage
=====

* Open ``Sales >> Sale Orders`` menu
* Click ``[Create]``
* Add a product to sale order line
* Create new section in ``Section`` field
RESULT: the section created is available (selectable) for this SO only

Global Section
--------------

At any time you are able to set a section as global at ``Sales >> Configuration >> Report Layout Categories`` menu. It means that the section will be available for all SO created.

Note
----

Once you create new sale order, you need to save it after creating new layout (Section), otherwise layout will not be displayed on other order lines.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions sale_layout_hidden_section/models.py
@@ -0,0 +1,22 @@
# coding: utf-8
# Copyright 2017 Artyom Losev
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import models, fields, api


class SaleLayoutCategory(models.Model):
_inherit = 'sale.layout_category'

sale_order_id = fields.Many2one('sale.order')
is_global = fields.Boolean(default=False, string='Global')


class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'

@api.model
def create(self, vals):
record = super(SaleOrderLine, self).create(vals)
if record.layout_category_id and not record.layout_category_id.sale_order_id:
record.layout_category_id.sale_order_id = record.order_id
return record
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8b6b191

Please sign in to comment.