Commit Graph
111423 Commits
Author SHA1 Message Date
Christophe Simonis 7f2bd08608 [FIX] core: define float_utils.round also in python2 2017-08-23 16:31:57 +02:00
Xavier Morel 8361ec8819 [FIX] phantomjs for p3
P2 and P3 subprocess stdout seem to have very odd/different behaviours
in the face of mixing select and buffering.

Use raw/low-level IO (os.read) with select to try and fix that
up. Also read more than one byte at a time since os.read will not
block *if* the fd is readable, it will just get whatever data is
immediately available.
2017-08-23 14:34:50 +02:00
Xavier Morel 1cec339092 [FIX] account: bug which blows up in P3
In P2, list comprehensions "leak" their variables to the surrounding
scope, in this case leading to "stl" from the first listcomp being
visible to the second one leading to code which does not break but
does not seem to make any sense.

/cc @csn-odoo
2017-08-23 14:34:50 +02:00
Xavier Morel 1b3ac016af [FIX] account: P3 invalid comparison
Python 3 removed "universal"
ordering. ``ResCompany.fiscalyear_lock_date`` is not required and thus
needs a fallback in case it's empty lest we try comparing a string and
None or False, which is an error.
2017-08-23 14:34:50 +02:00
Xavier Morel a65dfe2421 [FIX] P3: exception semantics issues 2017-08-23 14:34:50 +02:00
Xavier Morel f315ea4b71 [FIX] resource: P3 rounding issue 2017-08-23 14:34:50 +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
Pierre Masereel cde29c29eb [FIX] stock: compute location on quant package
The field 'location_id' on quant package is not computed anymore, as all
quants of a package are in the same location we take the location of the
first quant
2017-08-22 17:20:56 +02:00
Pierre Masereel 472384e658 [FIX] mrp: Only show lots of consumed product
When you use the produce wizard of mrp, you can select the lot_id of any
existing prosuct to set on the consumed product.

To avoid the seletion of a lot of another product, we set a domain
showing only the lots of the current product.
2017-08-22 16:44:29 +02:00
Pierre Masereel 56b0e29c4f [FIX] stock: auto complete serial number product quantity
When a serial number is set or changed on a move line during a picking,
we automatically set the quantity done to 1 because, you will always
process one quantity of the product having the serial number you've just
entered
2017-08-22 16:27:03 +02:00
Olivier Dony 1492670e71 [MERGE] P3: apply text/io model correction & final fixes
Closes #16919
2017-08-20 23:27:44 +02:00
Olivier Dony 2cc77a1990 [FIX] P3: os.write(bytes) 2017-08-20 23:25:54 +02:00
Olivier Dony 9197676e88 [FIX] P3: socket.error.errno instead of [0]
As of P3 socket.error is replaced by IOError and the underlying error
code must be accessed with `.errno `. This also worked in P2, so simply
use that all the time.
2017-08-20 23:25:54 +02:00
Olivier Dony 66fffc96ca [FIX] P3: text regex patterns only work with text input
.. not bytes
2017-08-20 23:25:54 +02:00
Olivier Dony f0333285fa [FIX] P3: convert exception handlers to except..as
Those are possibly posterior or leftovers from 3979f6802e
2017-08-20 23:25:54 +02:00
Olivier Dony f5b7de0e6c [FIX] P3: correct more dict iterable builtins use
Some bits posterior or leftover from fffaf735f5

See also parent commit.
2017-08-20 23:25:54 +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
Olivier Dony 589c0d7e2c [FIX] P3: more requirements.txt changes
- jcconv is not P3-ready and is only optional, for use on the POSBox
  firmware for Japanese charset support in some receipt printers
  (The POSBox firmware is still based on Odoo 8 + PY2 at this time)

- wsgiref is built-in since Python 2.5, and the one on pypi does not work
  on Python 3.2+
2017-08-20 23:25:54 +02:00
Olivier Dony 92e8a342c9 [FIX] P3: crm: dead code removal + simplify
Merge wizard contained dead code with references to an unused lib for
validating emails. Removing everything is easier.

+ remove unnecessary pycompat wrapping for safe use of dict.items()
2017-08-20 23:25:54 +02:00
Xavier Morel 555ff9ab84 [FIX] P3: quickfix URL/http text model 2017-08-20 23:25:54 +02:00
Xavier Morel 97515adde4 [FIX] P3: phantomjs & text model
In P3, can only append integers to bytearray, not bytes, also fix some
byte/string comparisons & encoding crap
2017-08-20 23:25:54 +02:00
Xavier Morel 40d1246a17 [FIX] P3: Response wrapping in http
Explicitly check for both bytes and text results to wrap in a Response
object, as bytes is a string_type in P2 but not P3.
2017-08-20 23:25:54 +02:00
Xavier Morel c24ab97c52 [FIX] P3: bytes.startswith(bytes) 2017-08-20 23:25:54 +02:00
Xavier Morel 30a9e6602c [FIX] P3: url_for text model
Have url_for work entirely on text internally, especially since
Request.path is text and so are lang names.
2017-08-20 23:25:54 +02:00
Xavier Morel 3b67fda251 [FIX] P3: file modes
In P3, files *must* be opened in binary mode when reading or writing
binary data, text mode (default) generates text and thus decodes on
the fly.
2017-08-20 23:25:54 +02:00
Xavier Morel b93613066f [FIX] P3: JSON is an object<->text encoding
It doesn't load bytes, and it doesn't dump to bytes.
2017-08-20 23:25:54 +02:00
Xavier Morel bc7dce254d [FIX] P3: text model, base_url is a string but query_string is bytes 2017-08-20 23:25:54 +02:00
Xavier Morel e33a79c65b [FIX] P3: date parsing text model 2017-08-20 23:25:54 +02:00
Xavier Morel 588e9e788c [FIX] P3: (ir.attachment)._index works on binary data
Thus needs a binary pattern and to decode it into ascii text.

Also improve the regex.
2017-08-20 23:25:54 +02:00
Xavier Morel ca20bbac50 [FIX] P3: guess_mimetype works on proper binary data 2017-08-20 23:25:54 +02:00
Xavier Morel 200612ca1e [FIX] P3: text model in various mail bits
No formal decision there, and the stdlib API seems like a PITA as it's
based around native strings, not bytes and not text.

* try to use cross-model API instead of random encode/decode
* unicode all the mail_template things
* formataddr *requires* a text tuple now

  In P2, formataddr((False, False)) "worked" (generated "False
  <False>"), in P3 it will fail and blow up.
* attachments are quite definitely bytes
* remove try_coerce_ascii because it's garbage
2017-08-20 23:25:54 +02:00
Xavier Morel ae866acf08 [FIX] P3: assets bundle text model
* remains is a list of text
* sep is text
* json.dumps generates text (surprise!) so beware with that
2017-08-20 23:25:54 +02:00
Xavier Morel 43dedda9eb [FIX] P3: cross-version binary data is bytes, not str 2017-08-20 23:25:54 +02:00
Xavier Morel a9d8d59833 [FIX] P3: error messages are text, dump XML docs as text 2017-08-20 23:25:54 +02:00
Xavier Morel 508926d2b8 [FIX] P3: hex() returns text, don't re-decode it 2017-08-20 23:25:54 +02:00
Xavier Morel 23299189c4 [FIX] P3: translations + text model 2017-08-20 23:25:54 +02:00
Xavier Morel 57ddba862a [FIX] P3: (ir.values).value is bytes
or buffer/memoryview when coming directly from XML
2017-08-20 23:25:54 +02:00
Xavier Morel a5e21f69e7 [FIX] P3: view arch should be text-'encoded' XML 2017-08-20 23:25:54 +02:00
Xavier Morel b8f0ed664c [FIX] P3: arch should be unicode 2017-08-20 23:25:54 +02:00
Xavier Morel 748bba42ca [FIX] P3: WSGI applications must return *bytes*
XMLRPC dumps returns text rather than bytes (for reasons unknown),
which does not suit Werkzeug's WSGI server, we need to encode the
body.

For simplicity and future-proofiness, return Werkzeug responses
instead, Werkzeug takes care of encoding text and passing bytes
through.
2017-08-20 23:25:54 +02:00
Xavier Morel bc741c3efa [FIX] P3: check for non-iterability of strings 2017-08-20 23:25:54 +02:00
Xavier Morel c11ac13417 [FIX] P3: import file content needs to be *bytes* 2017-08-20 23:25:54 +02:00
Xavier Morel 72083bc8ba [FIX] P3: ImportError text changed & text model fix 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 9d83784f1d [FIX] P3: "mogrify" returns bytes, decode it
Otherwise when the subquery is somehow injected in the parent
query (didn't find where but...) it's b-prefixed and treated as a
binary rather than a sub-query somehow, which fails.
2017-08-20 23:25:54 +02:00
Xavier Morel 91fe770945 [FIX] P3: oddly enough, binary data needles should be byte objects 2017-08-20 23:25:54 +02:00
Xavier Morel 69c8528388 [FIX] P3: encoding & decoding mess while manipulating XML
* IrValues.value should be a binary field, since pickle encodes
  objects to bytes
* Which means the "action" string must be encoded before storage and
  decoded before use
* Remove complete garbage mess of random encodings during XML
  conversion, this probably still requires serious thinking and fixing
  but it seems to run for now (yay)
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 0797cfd355 [FIX] P3: subprocess stdout is bytes 2017-08-20 23:25:54 +02:00
Xavier Morel 364becdab1 [FIX] P3: text/binary handling
* unichr -> pycompat (builtin removed from Python 3, ``chr`` has
  become unicode-aware)
* Psycopg2 bytea values (binary fields) are returned as memoryviews in
  P3 but buffers in P2
* Both bytes and (text) strings are conventionally iterable in
  P3 (they have a __iter__ method), so fix up the exclusion pattern
  for flatten
2017-08-20 23:25:54 +02:00