Commit Graph
43 Commits
Author SHA1 Message Date
Nicolas Martinelli adfec42561 [FIX] base_import_module: imported module version
- Create a simple module, set version to 2.0
- Import the zip file

The 'Latest Version' (field `installed_version`) is set to 11.0.1.0,
while one would expect 11.0.2.0.

There are several reasons for this. First, the method
`get_values_from_terp` doesn't return the version, so at this point the
information is already lost. Then, the field `installed_version` is a
computed field which retrieves the version from the `__manifest__.py`
file. In the case of an imported module, there is no such file in which
we can look up for the value (even though the imported module contained
one).

To avoid this, we explicitly set the 'Installed Version' (field
`latest_version`) to the version retrieved at import. Since this field
refers to the version installed in the database, it makes sense to use
it this way. Moreover, in the case of imported modules, we use the value
of `latest_version` for `installed_version`.

Fixes #23988
opw-1833522
2018-04-23 09:58:24 +02:00
Adrian Torres d33ce2b4d1 [FIX] base_import_module: don't assume data/ exists
Before this commit, while performing a check on whether a customization
being imported was done using studio or not, we would assume that the
.zip would, at the very least, contain a data folder.

This is not the case as loose files can be imported and the data folder
is only generated by studio customizations.

To solve this, we walk over the whole zip instead of walking over the
data/ folder only (which may be non-existant), so loose files, files
inside the data folder and potentially files in other folders can be
parsed without raising unexpected errors.
2018-02-26 15:33:37 +01:00
Nicolas Martinelli f347865161 [FIX] base_import_module: decoding error
In P3, `url_path` is already decoded in UTF-8, and therefore cannot be
decoded.

opw-783978
Closes #20912
2017-11-24 08:01:28 +01:00
Adrian Torres ba9381ed2a [FIX] base_import_module: display correct error
Previous to this commit, when importing a studio module with unmet
dependencies that were not studio the error message would just display
the Studio is required to install Studio customizations.

With this commit it should now correctly display the missing
dependencies by checking if only web_studio is in the set of unmet
dependencies

opw-777642
2017-10-31 08:22:59 +01:00
Adrian Torres 64d52cf85f [IMP] base_import_module: Add layer of security (#19175)
Previous to this commit, anyone could import studio customizations into
a community db, this was troublesome since some people would just
install studio, do their customizations and then move them into a
community db, not paying anything at all.

This commit fixes this by checking whether the exported views were
created with studio or not and if studio is installed
2017-10-11 12:03:05 +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 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
Christophe Simonis ab02bf34b0 [MERGE] forward port branch saas-16 up to cc38b93ab2 2017-06-09 17:11:47 +02:00
Christophe Simonis cc38b93ab2 [MERGE] forward port branch saas-15 up to 49f819a7a7 2017-06-09 16:43:27 +02:00
Olivier Dony 7d7d6ee5af [MERGE] Forward-port saas-11 up to fff4af36ab 2017-06-07 23:43:08 +02:00
Olivier Dony ef82574fb1 [MERGE] Forward-port saas-6 up to b604f3b3da 2017-06-07 23:29:41 +02:00
Olivier Dony b604f3b3da [MERGE] Forward-port 8.0 up to c6b9b69f6a 2017-06-07 23:11:38 +02:00
Olivier Dony c6b9b69f6a [FIX] base_import_module: allow selective access to module files
As a consequence of rev. 76cd8d2558,
imported modules were unable to access their resource files during
import.

Rather than further modifying the file_open API to whitelist paths
(the whole thing needs a redesign in master), we temporarily
whitelist the temporary directory by including it in the global
addons_paths, making sure to undo it afterwards.

This gives all lower level function access the resource files via
file_open, without having to pass around whitelisted paths
through many different calls.
2017-06-07 22:46:25 +02:00
Christophe Simonis 99c34c4119 [MERGE] forward port branch saas-16 up to 6f3eada2c3 2017-06-06 19:38:29 +02:00
Olivier Dony e2e23142e9 [FIX] base_import_module: make low-level method private
The import_module() method does not need to be public,
so let's mark it private. It's not called by anyone
except import_zipfile().

After 76cd8d2558 it would
fail anyway because addons_path would not be prepared by
import_zipfile().
2017-06-06 16:32:37 +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
Xavier Morel 3979f6802e [#8530] convert exception handlers to except..as syntax
Futurize fixers:
* lib2to3.fixes.fix_except
2017-04-11 14:53:29 +02:00
Martin Trigaux 2382520c34 [IMP] odoofication 2017-03-30 08:59:13 +02:00
Christophe Simonis 2217b37130 [MERGE] forward port branch saas-11 up to 573293a06d 2017-01-04 19:15:31 +01:00
Christophe Simonis 1aad733dc4 [IMP] base_import_module: correct validation of custom views
Consider also imported and exported views when validating custom views.
2017-01-03 13:12:17 +01:00
Christophe Simonis 341bea8f88 [MERGE] forward port branch saas-12 up to 43cb4ac 2016-10-10 13:00:05 +02:00
Olivier Dony 447179c2d3 [MERGE] Forward-port 8.0 up to 3d55aff1c8 2016-10-03 23:53:23 +02:00
Olivier Dony 12634e1227 [FIX] base_import_module, tools: raise a clear error for unsupported file types
Also restrict XML data attribute evaluation context
even for real module data files. This will prevent
accidentally depending on context parameters that
would not be available inside base_import_module.
2016-10-03 19:48:09 +02:00
Olivier Dony 8aba05dc08 [FIX] base_import_module, tools: raise a clear error for unsupported file types
Also restrict XML data attribute evaluation context
even for real module data files. This will prevent
accidentally depending on context parameters that
would not be available inside base_import_module.
2016-10-03 16:57:00 +02:00
Mohammed Shekha 870f2ff893 [MIG] base_import_module: Migrated to new API 2016-07-13 12:46:50 +02:00
Christophe Simonis 56a442e205 [MERGE] forward port of branch saas-6 up to dade7e3 2015-11-25 13:26:02 +01:00
Denis Ledoux d47ee18fef [MERGE] forward port of branch 8.0 up to c9fce1a 2015-11-17 13:19:14 +01:00
Denis Ledoux 384b8d496d [FIX] base_import_module: exception logger for module imports
When importing a module, if an error was raised
during the import, the traceback wasn't displayed
anywhere, making harder the debugging.

While it make sense to not display the entire traceback
to the user, in the web client, this is useful to
diplay the traceback in the logs, for debugging purposes.

opw-653882
2015-11-06 12:03:35 +01:00
Christophe Simonis d750206c49 [MERGE] forward port of branch saas-6 up to e9f1ee4 2015-10-01 15:16:59 +02:00
Olivier Dony af4a60b941 [MERGE] Forward-port 8.0 up to rev. 26d0fe6d9f 2015-09-30 02:53:59 +02:00
Arnaud Pineux 44bfb2bf44 [FIX] base_import_module: special chars in error messages
use ustr() instead of str() to avoid traceback with translations

Closes #4272
2015-09-28 15:21:24 +02:00
Thomas Groutars 8880c170bb [ADD] base_import_module: add boolean field imported on ir.module.module 2015-08-31 10:57:44 +02:00
Goffin Simon 0fd773a486 [IMP] Cleanup and refactoring of exception handling
Unify and refactor exception handling in framework and addons.

The generic `except_osv` is now deprecated, and replaced by more specialized exception subtypes:
 - `UserError` (renamed from Warning, as it conflicts with the built-in `Warning`) raised when a non-technical error occurs during a business operation. It could be a missing information in the data provided by the user, or a misconfiguration.
 - `AccessError`: raised when any operation is denied because the user conducting it does not have the required access rights.
 - `AccessDenied`: raised when an operation that requires authenticated access is attempted via an unauthenticated request.
 - `MissingError`: raised when an operation is attempted on a record that does not exist.
 - `ValidationError`: raised when an operation violates a SQL or Python constraint.
 - All other exceptions are internal errors due to a system problem or bug, and raised untouched to the client-side, which should display a traceback.

All exceptions take a single message argument.

The `test_exceptions` module has been updated to showcase both new and old (deprecated) exceptions.

A great many old `except_osv` had a useless title with "Error!" or "Warning", those have been removed, as this is handled by the client-side widget that displays the messages.

This commit introduces a more consistent policy for logging errors and warnings:
 - All messages that do not require administrator attention should be logged at INFO level or lower. This includes all errors that are notified to the user in a friendly manner, even for access right problems or validation errors during business operations.
 - All messages that indicate a likely misconfiguration or malicious use by the users should be logged at WARNING level, as they typically require administrator attention.
 - All other unhandled internal errors cannot typically be handled by the user and should be logged at ERROR or higher level, as they require immediate administrator attention.
2015-01-16 17:15:18 +01:00
Leonardo Donelli 4a0b13ed92 [REF] remove vim modelines and resulting trailing blank lines
Let 2015 be a year without modelines!
cf #4174
2014-12-31 15:52:13 +01:00
Fabien Meghazi ed1c173971 [FIX] Some fixes for base_import_module
- Properly check unmet dependencies
- Set imported module's state to 'installed'
- Fix bad translation usage
2014-09-05 12:32:11 +02:00
Fabien Meghazi c1e6e70870 Added --force to odoo deploy
Will force --init mode even if module is already installed
2014-06-11 09:55:17 +02:00
Fabien Meghazi fc9d0d9ab0 [FIX] typo 2014-05-26 17:26:19 +02:00
tpa-odoo 8fa3a17c39 [IMP] improved code to show import result in wizard and improved typo 2014-05-22 17:09:52 +05:30
tpa-odoo 41147025b8 [ADD] add wizard to import zipped module 2014-05-22 15:51:51 +05:30
Fabien Meghazi 5e484ae892 [IMP] Properly import files
bzr revid: fme@openerp.com-20140324151711-89mfg14573dpnh0p
2014-03-24 16:17:11 +01:00
Fabien Meghazi 5d107cfaa0 [IMP] static file injected in ir.attachment
bzr revid: fme@openerp.com-20140320143346-nimxg7c61lm1253x
2014-03-20 15:33:46 +01:00
Fabien Meghazi 40fdb08a7d [WIP] base_import_module
bzr revid: fme@openerp.com-20140319085343-zkee3rmqc9dzpa7h
2014-03-19 09:53:43 +01:00