Commit Graph
68 Commits
Author SHA1 Message Date
Thibault Delavallée 50f5d28c80 [MOV] web(_editor): move image rendering from web_editor to web
Currently the image field rendering in QWeb using the /web/image
controller is done in web_editor. However there is no link between
the web editor and the rendering. The rendering can therefore be moved
directly in web.

During the move two options have been added to the rendering of image
field :

 * qweb_img_raw_data: fallback on standard base64 behavior that is
   otherwise impossible to achieve;
 * qweb_img_responsive: True by default, add the img-responsive
   class that is not always requested;

Thanks.
2017-08-24 17:06:07 +02:00
Xavier Morel 9d0af3c72c [FIX] web_editor: P3 io error
Views archs (and sub-archs) should be serialized to and deserialized
from unicode, not bytes.
2017-08-23 14:34:50 +02:00
Olivier Dony 695716efb0 [FIX] P3: remove pycompat.{keys,items,values} helpers
Now that we're closer to switching to P3 for good, these helpers have
outlived their usefulness, and mostly add noise.

All remaining dict.iter*() or dict.view*() must be converted to the
normal keys(), values() or items() calls.

Whenever the result is likely to be used for more than the scope of a
loop, or when the dict needs to be modified during iteration, the calls
must be wrapped in a ``list()``, to protect the new P3 semantics.
Those cases are very exceptional.

Also removed some dead code or improved the API to remove unnecessary
conversions.
2017-08-20 23:25:54 +02:00
Xavier Morel 481a00dc4b [FIX] P3: hash/hmac payload must be bytes 2017-08-20 23:25:54 +02:00
Xavier Morel 7dd062f835 [FIX] P3: text model types
* remove references to basestring & unicode (use relevant pycompat
  helpers)
* remove some str calls (either entirely or replaced by relevant
  helper, either text or native)
* use better API to avoid unnecessary conversions
* remove some XML declarations in views
2017-08-20 23:25:54 +02:00
Xavier Morel 3824b5dcc1 [FIX] P3: fix base64 and StringIO uses
* StringIO removed from stdlib, replace with io
* try to correctly handle BytesIO/StringIO (one is for bytes the other
  is for text)
* fix base64: Python 3 removed bytes-encoding and bytes-bytes
  codecs (via #encode) so replace all calls to str.encode('base64'),
  also b64encode is a bytes->bytes conversion so attempt to properly
  handle that

issue #8530
2017-08-20 23:25:54 +02:00
Xavier Morel a4ada695e1 [FIX] P3: absolute ordering removed 2017-08-19 02:34:21 +02:00
Christophe Simonis bf51fe55a1 [MERGE] forward port branch saas-16 up to 0f2b2c4e2b 2017-07-07 14:30:30 +02:00
Christophe Simonis 780ae8a808 [MERGE] forward port branch saas-15 up to 10cb34bcac 2017-07-04 18:14:13 +02:00
Christophe Simonis 10cb34bcac [MERGE] forward port branch saas-14 up to 97258040d8 2017-07-04 14:40:20 +02:00
Christophe Simonis 657e328903 [MERGE] forward port branch saas-11 up to 7b0a1e4031 2017-07-04 12:28:38 +02:00
Christophe Simonis 7b0a1e4031 [MERGE] forward port branch 9.0 up to b9131adb48 2017-07-04 11:51:23 +02:00
Kishan Gajjar aaeef14903 [IMP] web_editor, website(_*): show all snippets even if module is not installed
* mail_channel, mass_mailing, twitter, event

- t-install attribute holds the technical name of the module that
  needs to be install to use a particular snippet.

- Disable the drag & drop feature for these dummy snippets.

- Move some images to website module.

- Installed snippets display at the top of the list.

- Hide not-installed module snippets if user don't have rights to install module.
2017-07-04 10:54:20 +02:00
Nicolas Lempereur b3e7753d1b [FIX] web{site,_editor}: allow edit en_US field
If the website default language is not en_US, qweb fields are not
translatable in en_US (and thus can't be translated) because:

- the code expected en_US to be the default language.
- there was a error in website _dispatch

opw-746776
closes #17939
2017-06-30 14:14:27 +02:00
Nicolas Lempereur 2955bf2651 [FIX] web_editor: translation and no default en_US
Before 036ccbef when writing on qweb field with default language mi_SC:

- writing in mi_SC: wrote on the current res.user language (wrong)
- writing in en_US: wrote on en_US translation (right)
- writing in de_DE: wrote on de_DE translation (right)

but after 036ccbef:

- writing in mi_SC: wrote on mi_SC (right)
- writing in en_US: wrote on mi_SC (wrong)
- writing in de_DE: wrote on mi_SC (wrong)

With this commit, this drawback is also solved by keeping the lang in
context if present.

opw-746776
closes #17917
2017-06-30 13:11:51 +02:00
Christophe Simonis dd43071638 [MERGE] forward port branch saas-16 up to 278e478d55 2017-06-27 14:19:31 +02:00
Christophe Simonis 34b432d528 [MERGE] forward port branch saas-15 up to 4d79a1ff58 2017-06-26 19:19:39 +02:00
Christophe Simonis e1c74e374c [MERGE] forward port branch saas-14 up to 3bac72ba74 2017-06-26 14:04:04 +02:00
Goffin Simon 036ccbeff1 [FIX] web_editor: Translating a product in the website
Steps to reproduce the bug:
-Change the default lang on the website to be different than en_US
-Edit the name of a product in the website

Bug:
The name of the product is changed in en_US and not in the language
set on the website. The lang is in fact removed from the context in
function saveElement(in addons/web_editor/static/rte.js).

opw:747084
2017-06-21 12:02:06 +02:00
Xavier Morel 01e3514147 [FIX] P3: urllib, urllib2 and urlparse
In Python 3, all of these were "consolidated" under urllib(.request,
.parse, .errors) which is inconvenient.

Since we already have hard dependencies on requests and
werkzeug(.urls, which is a backport of Python 3's unicode-aware
urllib.parse) migrate *everything* to that.

A sticking point is urllib2.URLError, those were (mostly) replaced by
the slightly more general IOError which URLError extends.
2017-05-15 12:26:30 +02:00
xmo-odoo fffaf735f5 [FIX] P3: list -> iterable builtins (#16811)
In Python 3:

* various builtins and dict methods were changed to return
  view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
  removed altogether

This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).

Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.

issue #8530
2017-05-10 09:39:55 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
xmo-odoo 2e6a589f41 [FIX] builtins removed from Python 3
* Reverse wrapper courtesy of @rco-odoo's original P3 branch
* thin compat module stripped down from werkzeug (to augment as needed)

issue 8530
2017-04-27 13:59:33 +02:00
Christophe Simonis aebd043662 [FIX] web_editor: correct syntaxerror
Oversight of previous forward-port
2017-03-28 18:27:42 +02:00
Christophe Simonis 2df5faa551 [MERGE] forward port branch saas-14 up to 2f68e9e93a 2017-03-28 18:05:31 +02:00
fwi-odoo 1213920e40 [FIX] web_editor: correctly fetch the inherited views
The `issuperset` method check if a set contains all the element of the set given
in paremeter. So in our case, the user needed to be in all the view groups
to get the inherited view. That's not the behaviour expected.
If the user is in only one of the group required to have access to the view,
we want to return the inherited view.
2017-03-21 12:59:54 +01:00
qsm-odoo 7751c1bfb9 [REF] web_editor, website: split customize_template_get
Commit a2ae219d4e fixed the customize_template_get
function(s) which had been modified for the 10.0 web_studio release.
While the fix also reorganized the structure to make it more efficient
and understandable, it promised that the function would be refactored
in master. This is what this commit does.

The customize_template_get route of the website module was also removed
with commit 5a030db3eb as it was an useless
duplicate of the web_editor customize_template_get route.

The old route handled two totally different features of odoo: getting
all the page-related views to allow their edition with the HTML editor
and getting the "toggable views" which appear in the "Customize"
website menu. The parameter "full" allowed to determine which one the
route was supposed to do and was useless until website was installed to
add its feature (by extending the route behavior). In both cases, views
informations are returned, only the number of views differs. The
above-mentionned fix already did part of the refactoring by returning
the same info structure for each view in both cases.

Now, the function has been split. The web_editor customize_template_get
route is renamed as get_assets_editor_resources and returns the info the
HTML editor needs to work (the "assets" term is in prevision of the
new LESS editor).
A new website route "get_switchable_related_views" has been created to
return the info the "Customize" website menu needs.
Both use the renamed ir.ui.view function "get_related_views" (old
ir.ui.view customize_template_get function) which now returns a
recordset and not a list of dictionnaries.
2017-02-14 16:32:15 +01:00
qsm-odoo a2ae219d4e [FIX] web_editor, website: fix customize_template_get
Commit e11f23b701 split the website
customize_template_get into web_editor and website ones. This split
was not perfect and commit 20861b482a
tried to make it work... but did not made it totally and added an
indirect dependency to website module in web_editor...

As the final result is wrong and inconsistent and that the previous
9.0 implementation was already ugly, this was not possible to make
a consistent full-stable fix.

This commit tries to make a fix as stable as possible (the main method
name did not change, the arguments did not change, their purpose is
the same, ...) which makes the code work and be less ugly. However,
the function returns are now slightly different (and JS depends on it).
It returns only valid view information (not header stuff which is not
related to anything and the inherit_id value is now a combination of
the inherit view id and name). Also, a new private method has been
created.

Also, the method contained code which was deprecated since saas-6 but
was never removed (and never broke anything "by chance").

In master these methods will be refactored to make more sense.
2016-10-14 13:16:49 +02:00
Jeremy Kersten e2fb1cb6ce [FIX] web_editor: add missing import
Thanks to my Linter...
2016-09-30 15:11:58 +02:00
Jeremy Kersten 20861b482a [FIX] website: fix customize_template_get
broken by e11f23b
If not full, result was always empty

This commit fix the list of view when you click on Customize top menu in website.
This menu should only display the 'customize_show' views.
2016-09-30 15:11:58 +02:00
Martin Geubelle e11f23b701 [REF] web_editor, website: move ACE editor to web_editor
The commit e59a7fe3ff has moved
the ACE editor from website to web_editor. As some code on ir_ui_view
was used for this widget, the code has also been moved to web_editor.
2016-09-28 16:55:51 +02:00
Jeremy Kersten f0463a3e1d [IMP] web_editor, website, website_sale: add zoom option for t-field image
web_editor Qweb: Add 'zoom' option for widget image
    <span t-field="product.image_small" t-options="{'widget': 'image', 'zoom': 'image_medium'}" />

website: Add Zoom code to be standard for all website module

website_sale: add zoom on Main product image
2016-09-21 21:29:18 +02:00
Raphael Collet 70dec2d896 [REF] registry: now mapping model name to model class 2016-08-31 17:21:59 +02:00
Raphael Collet 75dc39e042 [REF] openerp.http: make request.context consistent with request.env.context 2016-08-31 17:21:58 +02:00
qsm-odoo 1421c68207 [FIX] web_editor: adapt the forgotten rendering of updated contact fields
The frontend allow the rendering of fields thanks to converters and
their value_to_html and record_to_html methods. These methods were
changed with https://github.com/odoo/odoo/commit/3407fb70e4a5b16174234d10d97710572b6f808c#diff-d5a9a5d91bd3171e30e7facd628bdf5cL411.

The problem is that the web_editor also contains code which relies on
these methods and it was not adapted.
2016-08-19 17:44:27 +02:00
Jeremy Kersten 21bd473de7 [FIX] qweb: fix ir.qweb.field.contact
Before this commit when you edit a contact with the editor, you didn't see
the selected record before the save.

Now, you can edit a contact with the html editor.
We move the hacked field self (on res.partner) from website_partner to base.

2 bugs:
   field and record was reversed in call
   need to pass a browseRecord and not a dict, because we uses .env on it

This hack allow to use widget='contact' on the browse record
itself and not on a specific field from the browse record

Eg:
    <div t-field="partner.self" t-options='{
                 "widget": "contact",
                 "fields": ["address", "phone"]
    }'/>
2016-08-17 10:32:52 +02:00
Raphael Collet ffdafd3f8a [REM] most uses of _model (useless in most cases) 2016-08-16 09:55:46 +02:00
fwi-odoo a32c1d3c8d [MIG] web_editor: migrate to new api 2016-08-03 13:42:25 +02:00
fwi-odoo d4e813b873 [REF] web, *: change deprecated import openerp.addons.web.http to odoo.http
We also remove the mock in web as there is no need for it anymore.
2016-08-03 13:42:05 +02:00
Christophe Matthieu ae5f853819 [IMP] qweb: remove values from record_to_html to avoid crappy code 2016-07-05 18:43:09 +02:00
Simon Lejeune 5c54571f4e [FIX] web_editor: remove the editable key if no write on the model
The `check_access_rule` call allow to remove the `editable` key from the
rendering context (which will lead to the display of the editor bar) if
an access rule prevents the edition of the ir.ui.view record. Also remove
it in case the user has no write access on the model (i.e. demo user).
2016-07-05 17:44:56 +02:00
Christophe Matthieu 08eb9384d2 [IMP] qweb: use iterator to compile directives in order 2016-06-14 13:12:17 +02:00
Christophe Matthieu 1583194845 [IMP] qweb: typo: remove qwebcontext and use values 2016-06-14 13:12:15 +02:00
Christophe Matthieu b3302398bc [IMP] ir.qweb: extract and create independent qweb class from ir.qweb
The goal is to make the code more readable, more easily be optimized, allowing to share the library "QWEB" (python and js) separately Odoo.
2016-06-14 13:12:14 +02:00
Christophe Matthieu 7ede9bcb2d [IMP] base ir.qweb: compile template (and use ast) to improve rendering speed
* The compiled templates are cached per user, lang, inherit context values
* ir.ui.fields: attributes method return an dict, and record_to_html return only the content value of the field
* all rendered text use build_text and all attributes use build_attribute
* t-esc-options is removed and replace by format_value method
* AssetsBundle receive the list files and remains
2016-06-14 09:46:25 +02:00
Christophe Simonis e641d740d7 [MERGE] forward port of branch saas-10 up to fac4cc7 2016-05-24 14:08:42 +02:00
Christophe Simonis fac4cc7006 [MERGE] forward port of branch saas-9 up to f8e6bb7 2016-05-24 13:19:19 +02:00
Martin Trigaux 216d328a11 [FIX] web_editor: serialise translations of html_translate fields
The html_translate fields (e.g. website_descripton on product.product) were not
serialised and the raw value from the web_editor was saved as a translation.

This was an issue in case of special characters that may be present in the
translation. A translation containing non-breaking space was sent in html
(`foo&nbsp;bar`) while lxml converts such characters to unicode (`foo\xa0bar`).

When writing a translation, the value is checked against incorrect format using
```
value0 = field.translate(lambda term: None, record[fname])
value1 = field.translate({trans.src: trans.value}.get, value0)
value2 = field.translate({trans.value: trans.src}.get, value1)
if value2 != value0:
    raise ValidationError(_("Translation is not valid:\n%s") % trans.value)
```

As value1 is the unicode version of the translation and `trans.value` is the
html version of the translation, the last substitution in the callback method
was never made and the ValidationError was raised.

This commit forces the serialisation through lxml to be sure the compared
strings are using the same parser instead of comparing value from summernote and
lxml that may be both valid but still different.

opw-675767
2016-05-18 15:01:29 +02:00
Christophe Simonis 2dcbdd0778 [MERGE] forward port of branch saas-10 up to bb8f0f1 2016-04-25 15:48:31 +02:00
Christophe Simonis bb8f0f1fc3 [MERGE] forward port of branch saas-9 up to 4d337f7 2016-04-25 14:43:44 +02:00