Commit Graph
43 Commits
Author SHA1 Message Date
Nicolas Martinelli 7242544506 [FIX] base_import: activate advanced mode
The commit 1ba4fbe640 did not match the specs of the task, but
was merged anyway. Reverting the commit, and check by default so the
user is not confused with missing fields.

opw-1824074
2018-04-12 14:54:25 +02:00
Christophe Simonis 10128fa7e8 [MERGE] forward port branch saas-16 up to dc2a6c6cd2 2017-10-20 19:27:04 +02:00
Christophe Simonis 868e718e09 [MERGE] forward port branch saas-15 up to 8d0942380b 2017-10-17 15:14:47 +02:00
Christophe Simonis fbdda5437a [MERGE] forward port branch 10.0 up to cbca27d005 2017-10-17 12:09:58 +02:00
amoyaux e1769cbea9 [FIX] base_import: parse date and float for relational fields
Use case to reproduce:
-> Import a file with a float using a coma related to the model
(for example the product.supplierinfo/price)

It happens because the method that parse the date and float field
only compare them to the main imported model.

This commit complete the method by using a recursion on relational
model in order to also parse the relational subfields.
2017-10-13 09:43:11 +02:00
Christophe Simonis b8dd34fcbb [MERGE] forward port branch saas-16 up to 64d56995e0 2017-09-06 13:29:05 +02:00
Christophe Simonis 64d56995e0 [MERGE] forward port branch saas-15 up to ef5ac872b8 2017-09-06 12:26:36 +02:00
Christophe Simonis ec0d51f20e [MERGE] forward port branch 10.0 up to a4bcb66bfc 2017-09-06 10:59:06 +02:00
Nicolas Martinelli a4bcb66bfc [FIX] base_import: headerless import
- Import a CSV file without header
- Untick the option 'The first row contains the label of the column'

An error is reported.

If no header, the method `_match_headers` should return consistent
object types.

opw-769117
2017-09-05 16:37:48 +02:00
Xavier Morel c11ac13417 [FIX] P3: import file content needs to be *bytes* 2017-08-20 23:25:54 +02:00
Xavier Morel be7c5aefdf [FIX] P3: CSV reading & writing 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
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
Haresh Shyara c02b2ca7d1 [IMP] base_import: Improve import preview for related fields
normal mode: Importing only regular/basic fields from source file
advanced mode: Importing any related fields from source file(i.e. if detected pattern in header like '<relational_fieldname>/<fname>')

- Rename following checkbox "Show all fields for completion (advanced)" in "Show fields of relation fields (advanced)"
- If the import file contains a column with a field of a relation field, show the column label in the preview, even if "Show fields of relation fields (advanced)" is not checked > to make it less confusing when importing advanced files (e.g. products with attributes)

This is a backport of 1ba4fbe640, which was performed due to several
tickets mentioning confusion with the new import system.
2017-01-03 12:07:47 +01:00
Moises Lopez f507fc95c7 [IMP] fields: remove '_id(s)' from the label
For autogenerated labels.
Use title instead of capitalize to get every word with a capital letter.

Closes #12769
2016-12-07 10:47:04 +01:00
Haresh Shyara 1ba4fbe640 [IMP] base_import: Improve import preview for related fields
normal mode: Importing only regular/basic fields from source file
advanced mode: Importing any related fields from source file(i.e. if detected pattern in header like '<relational_fieldname>/<fname>')

- Rename following checkbox "Show all fields for completion (advanced)" in "Show fields of relation fields (advanced)"
- If the import file contains a column with a field of a relation field, show the column label in the preview, even if "Show fields of relation fields (advanced)" is not checked > to make it less confusing when importing advanced files (e.g. products with attributes)
2016-11-10 09:44:20 +01:00
Jeremy Kersten 7a7723eacf [FIX] base_import: allow to specify datetime format, fix encoding, add test date, fix translation
After this commit,
 - chinese custom date are supported
 - Possibility to specify the custom datetime format and not only dateformat.
   Withtout it, impossible to import a date column and datetime column at
   sametime with custom format.
 - Add test to check import date with custom format
 - Fix translation where error messages was in the source.

This commit fixes #13783 and closes #13803

Courtesy of @odony for the review ;)
2016-10-14 12:36:04 +02:00
Raphael Collet 0783318f97 [FIX] adapt logger names 2016-09-02 17:28:13 +02:00
Raphael Collet 70dec2d896 [REF] registry: now mapping model name to model class 2016-08-31 17:21:59 +02:00
Hitesh Trivedi 53fe4007f4 [MIG] base_import: migrate tests
Some changes were required since in new API, fields label
are not manage as before (defaulf value is field name, and
not 'unknown' anymore).
2016-07-07 14:44:10 +02:00
Hitesh Trivedi 46df9da439 [MIG] base_import : migrate to new api 2016-07-07 14:44:10 +02:00
Hitesh Trivedi cf3e8324f1 [MOV] base_import: module directory organization
Note: move test models file in models to not import tests
directory, which breaks the mute_logger of test cases
2016-07-07 14:44:10 +02:00
Raphael Collet 8da9116f5d [REM] models: remove deprecated method BaseModel.import_data() 2016-06-16 16:50:46 +02:00
Cedric Snauwaert 841f208b22 [REF] base_import: simplify import by reducing choice for the columns based on heuristic
automatically try to detect type of columns from the first 10 rows of file:
If column only contains integer, only show, int, float, monetary, m2o, o2m, m2m fields in wizard
If column only contains true/false values, only show boolean fields in wizard
etc

add an advanced mode which is the same as previous import (show all fields)

Support different date format and float value with currency as well as float value with parenthesis to reprensent negative value.
2016-04-07 09:42:23 +02:00
Christophe Simonis c169c59e69 [FIX] base_import: adapt forward-ported test to v9 2016-02-24 18:45:51 +01:00
Christophe Simonis dd875ed1a1 [MERGE] forward port of branch saas-6 up to f5ed710 2016-02-24 18:02:53 +01:00
Nicolas Lempereur d4e5019ec7 [FIX] web: csv export newline for text/html field
CSV export was added in f146e2a and since then newline were not
exported.

But new line should be allowed if the string is quoted by " characters
which is done in Odoo.

closes #11005
opw-667853
2016-02-24 11:26:16 +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
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
Christophe Simonis f18b46fcde [FIX] base_import: ignore stripped empty lines
Better fix for commit dab37df04d
2015-04-01 13:22:11 +02:00
Xavier Morel 68f14c6870 [FIX] handling of big fields in CSV
fixes #2742
2015-02-27 14:11:21 +01:00
Xavier Morel 65cd4a2a33 [FIX] remove deprecated checks/fast_suite test attributes from standard modules 2015-01-15 14:31:40 +01:00
Martin Trigaux f138aa2608 [FIX] models: display_name and name_get mismatch
- display_name uses name_get and not the other way around:
name_get should not call _compute_display_name, _compute_display_name should call name_get.
The previous behaviour was not backward-compatible with the old api.
All the models redefining name_get would have 2 different behaviors between name_get and display_name.

- Do not set an inverse function to display_name:
In most cases, writing on display_name writes on _rec_name (if any, not mandatory).
If the display_name computation is redefined, we need to redefine as well the inverse method to avoid unexpected behaviour
This required to also modify tests in base_import as readonly fields are avoided.

- Remove search method on display_name:
For the same reason as for the first point, it could be good that searching on display_name use name_search (and not the other way around).
However doing this would be very inefficiant (need to do the search, without limit, extract the ids of the name_get result just to generate
a subdomain ('id', 'in', [...]). As in most cases it would anyway mean to search on the _rec_name it's better to directly do so.

- Changing label to avoid mismatch:
In view displaying the list of fields or when a match is made on the label of a field (e.g. when importing csv file,
matching is made on both label and technical name), the fact that display_name field has '
Calling it 'Display Name' will avoid most errors.

- remove display_name definition from website_forum_doc,ir_model:
These fields are doing the same thing as the display_name of the new api, we can remove them.
We need to keep the one for res.partner as it's a stored field.
2014-07-25 13:58:59 +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
Xavier Morel 9b0f10af12 [FIX] base_import: just loading module should not require unittest2. Reported by M.Taylor
bzr revid: xmo@openerp.com-20120911132446-u1yd48tsfd7km6hn
2012-09-11 15:24:46 +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 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 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