Commit Graph
32 Commits
Author SHA1 Message Date
Xavier Morel a4ee8e5723 [IMP] base_import: use mimetype guessing
Rather than trust the user-controlled mimetype or extension of imported
files which may be incorrect (because the user is lying, because the
system is misconfigured, because software is not installed, because
software is registering non-standard mimetypes, etc...), start by trying
to guess the mimetype *then* fallback on trying the type/ext.

Of note: CSV is becoming less and less great as it's nigh impossible to
guess for it.
2016-02-17 15:45:11 +01:00
Xavier Morel 97d2b758fe [FIX] catch exception on incorrect mime type
If the user provides a known mimetype which doesn't actually match the
file as far as we're concerned, warn and fallback on extension rather
than blow up.

This comes up when a user installs Excel on Windows: it associates CSV
files with itself and sets their mime type to application/vnd.ms-excel,
which is not correct and leads to us trying to load a CSV with xlrd (an
excel-parsing library).

Fixes #9779
2016-02-17 15:45:11 +01:00
Ajay Javiya 31518bc09b [IMP] base: make group "Technical Features" effective in debug mode only
In method `user_has_groups`, make "Technical Features" effective in debug mode.
Make the group "Employees" inherit "Technical Features".
Make the group "Technical Features" invisible in the user form view.
Remove useless `ir.rule` attached on group "Technical Features".
Fix `test_acl` by avoiding the tricks around the group "Technical Features".
2015-08-28 14:51:09 +02:00
Xavier Morel f5a1693f06 [ADD] base_import: support for XLS and ODS files
* added intermediate ``_read_file`` step dispatching between CSV, ODS
  and XLS(X) parsing
  - primary dispatch on mime type, secondary on file extension:
    + OS may not provide a relevant mime type if no software locally
      installed for the filetype (e.g. Windows sends excel files as
      application/octet-stream if excel is not installed, and ODS files as
      zip if OpenOffice/LibreOffice isn't installed)
    + applications may re-register extensions to non-standard mimetypes
      breaking the dispatcher

    So if the mimetype is found trust it, otherwise try with the
    filename's extension (if any)
  - all readers skip lines with only empty cells in their output
  - ODS and XLS content are "CSVified", rows are converted to arrays of
    unicode strings
* UI altered to not assume CSV files everywhere, and avoid returning
  garbage preview data for non-CSV imports

Various:
* added a ``can_import`` utility function to tests.common, can be used
  to skip tests if an optional Python dependency is not installed (but
  one would like tests to run if the dependency is available)
* fixed datetime issue in ir_fields
* added converter for monetary fields (iso float)
* spreadsheet don't have integers, twiddling required to ensure integral
  values won't be serialized as floats (breaking conversion back to
  Python)
* improved some tests by asserting no error is generated (bonus: logs
  the error message if there is one, rather than just saying the result
  is blown)
* because some systems only provide elderly versions of
  XLRD (e.g. current debian stable provides 0.9.2 from April 2013)
  - keep using xldate_as_tuple instead of 0.9.3's xldate_as_datetime,
    workaround is simple
  - check for xlrd.xlsx in case of pre-0.8 XLRD

Authorship:
Ronak Baxi <rba@odoo.com>
Mohammed Shekha <msh@openerp.com>

Task 10792
Closes #7285
2015-08-26 16:50:09 +02:00
David Béal 245b5afcfd [FIX] base_import: prioritise field name over string
When importing csv data, the column name is matched on the field name and string
attribute. For some fields (e.g. name & display_name), you could get a match on
both the string and technical field name for different fields
The order of the fields is not deterministic as stored in a dictionnary so
different results were possible at different import.
The technical name should be prioritised (more stable, unique constraint).

Fixes #6657
2015-05-21 10:48:31 +02:00
Christophe Simonis f18b46fcde [FIX] base_import: ignore stripped empty lines
Better fix for commit dab37df04d
2015-04-01 13:22:11 +02:00
Jeremy Kersten dab37df04d [FIX] base_import: strip line while importing
Empty line was already deleted but if you had a line with just a tab (\t)
the line was imported with an exception "list index out of range"
2015-04-01 10:13:02 +02:00
Jeremy Kersten b9adcc7598 [IMP] base_import: match column names withtout check the case
If you try to import a file with a header 'Parent_id/id'
_match_header will not match Parent_id with parent_id
because it was comparing with case sensitive.

It's not a bug, but in most cases this new behaviour (non
sensitive case search) is what the end user was expected.

Hate Excel and the auto correct capitalization !
2015-03-26 11:34:22 +01:00
rlu-odoo 8b67a7202d [REF] OpenERP --> Odoo in various UI texts
Rebranding has been done in:
- data/demo files
- html templates
- help notices
- comments
- logger messages
- and other various messages

(Commit taken from odoo-dev:8.0-improve-openerp-odoo-rlu at rev 7deaa08)

Closes #1260
2014-07-18 13:45:41 +02:00
Raphael Collet cbe2dbb672 [MERGE] new v8 api by rco
A squashed merge is required as the conversion of the apiculture branch from
bzr to git was not correctly done. The git history contains irrelevant blobs
and commits. This branch brings a lot of changes and fixes, too many to list
exhaustively.

- New orm api, objects are now used instead of ids
- Environements to encapsulates cr uid context while maintaining backward compatibility
- Field compute attribute is a new object oriented way to define function fields
- Shared browse record cache
- New onchange protocol
- Optional copy flag on fields
- Documentation update
- Dead code cleanup
- Lots of fixes
2014-07-06 17:05:41 +02:00
Jaydeep Barot 026e38b48f [REM] Unnecessary size parameters on char fields 2014-06-25 17:13:43 +02:00
Denis Ledoux cd8b44a492 [MERGE] Forward-port of latest saas-2 bugfixes, up to rev. 9142 revid:dle@openerp.com-20140310101705-2g3e6gp5jd2g8fpc
bzr revid: dle@openerp.com-20140310110340-nueeuldz8w44os3u
2014-03-10 12:03:40 +01:00
Denis Ledoux f54fc4f9dc [ADD] base_import: add the possibility to import one2many with database id, for users with technical features
bzr revid: dle@openerp.com-20140310101705-2g3e6gp5jd2g8fpc
2014-03-10 11:17:05 +01:00
Xavier Morel e0493cd6d4 [FIX] handling of single-line files sent for preview
bzr revid: xmo@openerp.com-20131015100313-sdgqx1t43922kgq8
2013-10-15 12:03:13 +02:00
Xavier Morel 956bfd007d [REV] garbage
bzr revid: xmo@openerp.com-20121102140127-69e3ae5vca1ni46r
2012-11-02 15:01:27 +01:00
Vijaykumar Baladaniya deaae5dec3 [IMP]Give a proper message When a validate or import is refused due to a problem.
bzr revid: vba@tinyerp.com-20121030091231-ty2edtpcjyaxqzzx
2012-10-30 14:42:31 +05:30
Xavier Morel b70d0dab52 [FIX] cases where options dict is decoded as unicode strings on windows: csv.reader kwargs *must* be strings
bzr revid: xmo@openerp.com-20121010123827-x76udyurqzgnqebg
2012-10-10 14:38:27 +02:00
Xavier Morel fd5d4e5dd3 [IMP] don't display deprecated fields in import window
bzr revid: xmo@openerp.com-20120926114235-iqkmi23yk2v1hq7w
2012-09-26 13:42:35 +02:00
Xavier Morel 627bb128e0 [IMP] adapt base_import to using Model.load instead of Model.import_data
bzr revid: xmo@openerp.com-20120926082530-krhladsrn9mzs3lx
2012-09-26 10:25:30 +02:00
Xavier Morel 2918133ee5 [IMP] catch-and-return all errors in parse_preview
bzr revid: xmo@openerp.com-20120903140022-osfkgk4l6r2hj42j
2012-09-03 16:00:22 +02:00
Xavier Morel cdb6869809 [IMP] add encoding csv option
and generify handling of options a bit, imprive styling, and rename 'quote' to 'quoting'

bzr revid: xmo@openerp.com-20120830141226-exli9s1hh4vij6sd
2012-08-30 16:12:26 +02:00
Xavier Morel ca6323607e [IMP] make import objects live for 12 hours when transient cron is active
bzr revid: xmo@openerp.com-20120830110603-8stvh3vpsn4vzr4f
2012-08-30 13:06:03 +02:00
Xavier Morel b1407fc769 [FIX] field for file mime type is file_type, not file_mime
bzr revid: xmo@openerp.com-20120830103928-rjtrdvkzrybfpi0c
2012-08-30 12:39:28 +02:00
Xavier Morel 7006b17af3 [IMP] un-b64 the import file field, use raw binary
bzr revid: xmo@openerp.com-20120830103215-trv5cjg9jvj8ano1
2012-08-30 12:32:15 +02:00
Xavier Morel 34f9664377 [FIX] no field selected for import by the user
bzr revid: xmo@openerp.com-20120814142933-myng67f2cily6vfg
2012-08-14 16:29:33 +02:00
Xavier Morel 8fa23a9518 [ADD] actual importing, no fields matching yet
also no error pinpointing because API does not allow for it currently

bzr revid: xmo@openerp.com-20120814141456-zh9kdbjy8wj1sxys
2012-08-14 16:14:56 +02:00
Xavier Morel 323b979146 [ADD] error reporting to user during preview
bzr revid: xmo@openerp.com-20120814124835-9nkqni98ie2eyt5r
2012-08-14 14:48:35 +02:00
Xavier Morel aec461651e [FIX] NUL byte in a file leads csv.reader to raise csv.Error
bzr revid: xmo@openerp.com-20120814123112-p4iio7fl561ronln
2012-08-14 14:31:12 +02:00
Xavier Morel 84ea769476 [IMP] add information to _match_headers
bzr revid: xmo@openerp.com-20120814120737-0zuxqyjhnnx1aye3
2012-08-14 14:07:37 +02:00
Xavier Morel de09433413 [ADD] feeding of import data into import_data
bzr revid: xmo@openerp.com-20120814093813-ql1uq1kb2766db0e
2012-08-14 11:38:13 +02:00
Xavier Morel 45d5003dd6 [ADD] matching and parsing of CSV, preview production
bzr revid: xmo@openerp.com-20120813134219-ijo7d2kwn82qs4tm
2012-08-13 15:42:19 +02:00
Xavier Morel b34767381b [ADD] fields fetching and filtering method for import
bzr revid: xmo@openerp.com-20120810073513-zidmkuw6yjhtuwpj
2012-08-10 09:35:13 +02:00