summaryrefslogtreecommitdiff
path: root/odoo/tools
AgeCommit message (Collapse)Author
2021-05-27[FIX] core: fix formatting issues for --test-tags docsIvan Yelizariev
`./odoo-bin -h` prints unnecessary spaces between sentences. --- task-2431630 Finetuning of #71130 closes odoo/odoo#71331 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2021-05-27[IMP] core: clarify docs about config --test-tagsIvan Yelizariev
Technical name is not added to test_tags since https://github.com/odoo/odoo/commit/95b4f2ab4b5698ab3a28c9c35ac8da6fb6def983 at_install tag is added by default since introducing @tagged decorator: https://github.com/odoo/odoo/commit/b356b190338e3ee032b9e3a7f670f76468965006 Clarify how special tags at_install/post_install work. Also, add dots for @tagged doc, because otherwise we have a mess in sphinx docs. --- task-2431630 closes odoo/odoo#71130 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2021-05-17[IMP] mail: allow to force the FROM headers of the outgoing mail serverstd-odoo
Purpose ======= We want to be able to force the FROM headers when we sent email in SMTP. So we can avoid the emails to be considered as spam. Specifications ============== This is done with 2 system parameters. If the system parameter `mail.force.smtp.from` is set we encapsulate all outgoing email from with the given value. If the previous system parameter is not set and if both `mail.dynamic.smtp.from` and `mail.catchall.domain` are set, we encapsulate the FROM only if the domain of the email is not the same as the domain of the catchall parameter. Otherwise we do not encapsulate the email (same behavior as before this commit). Task 2367946 See odoo/odoo/pull/61853 closes odoo/odoo#70854 X-original-commit: 044532aed6f796cd93e37556b4a8ce47d2c23a7c Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com> Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2021-04-28[FIX] mail.py: sanitize do not remove file iconNicolas Lempereur
Scenario: - add a file in mass mailing editor => an icon is added linking the file - save - edit => the icon is replaced by a generic icon - save - send mail => no icon is shown in email received The system is using eg. `data-mimetype="pdf"` to show the icon, before 12.0 this worked but in saas-12.3 the system uses mailing.mailing body_arch's field that is sanitizing attributes and remove it on save, so the icon is only working in received email if you save one and only one time after adding file inside the mass mailing. opw-2474053 (ticket for similar issue in 14.0) closes odoo/odoo#70046 X-original-commit: 7e14515b84d8081557517df7e9dc7d8c0d17f2be Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-04-16[FIX] core: fix <act_window> deprecation warningNaglis Jonaitis
Without the f-string literal the XML ID is not printed. closes odoo/odoo#69359 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-03-24[FIX] translate.py: CSV export correct module nameNicolas Lempereur
Correct small typo that the module when exporting translations as CSV file might have been the wrong module because we used variable from previous loop. This did not seem to cause any issue since in this given case in import we got the module from the part before . in XML ID ({module}.{name}) that was right. found when working on opw-2439029 closes odoo/odoo#68284 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-03-23[FIX] translate.py: import model from CSV correctlyNicolas Lempereur
When importing transtlation from CSV, we: - cut at `:` character to get the model - used a model for types other than model and model_terms This caused error that do not happen in PO import because: - the model is before the `,` character - the imd_model column is constrained to 64 characters, and a name that is not a model could be over that size. With this changeset, the CSV import match better current PO import. opw-2439029 closes odoo/odoo#68260 X-original-commit: cff91c6acbb7ef6a884d4dc4170574b83ff6e4cb Signed-off-by: Martin Trigaux (mat) <mat@odoo.com> Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-03-08[FIX] tools: support malformed more malformed pdfwan
We do not want to fail ever if loading the attachment fails. We still log a warning in every case though. Some malformed PDFs lead to seeking the wrong bytes while looking for some parts, raising a ValueError closes odoo/odoo#67283 Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2021-03-19[FIX] base: allow using another postgres schema than publicStéphane Bidoul
Before 1721ec1363 and fdc4ef97c9d09, Odoo did work fine when the user had another default schema than 'public'. This commit restores this behaviour by searching for existing objects in the user's current schema, which is the first in the schema search path and the one used when no schema is specified when creating objects. closes odoo/odoo#68141 X-original-commit: 223781b34afacd1c0c5674d395cece6d472b048c Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2021-03-16[FIX] base: tools: float_split_str: avoid traceback when rounding to 0 ↵oco-odoo
places and add some test cases closes odoo/odoo#67949 X-original-commit: 42d409f180381316c97abd0c0ef5a062656e6122 Signed-off-by: Olivier Dony (odo) <odo@openerp.com> Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-03-09[FIX] tools: properly format error messageMartin Trigaux
To reproduce: 1. take a translatable record with an external id 2. delete the record but keep the ir.model.data (sql) 3. export the translations of the module linked to the orphan ir.model.data -> Error while formating the message This commit fixes three issues: - %d instead of %s to construct the string - wrong order to identify the missing records - display the external ids instead of the ids (which may not be very helpful to debug) Courtesy of Yannick Brant closes odoo/odoo#67509 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-03-04[FIX] packaging: remove dead code that prevent rpm buildChristophe Monniez
Since 9c2ce1f12c2, more files are included in packaging. The rpm build failed because shebang lines of packaged files must not use `/usr/bin/env` [0] [1] [2]. As it seems that those old files are not of any use anymore, this commit removes them. [0] https://docs.fedoraproject.org/en-US/packaging-guidelines/#_shebang_lines [1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#Multiple_Python_Runtimes [2] https://pagure.io/packaging-committee/issue/738 closes odoo/odoo#67258 X-original-commit: d2a6ed1b2709eb0f1ea8a38818bd669e6d990cd8 Signed-off-by: Raphael Collet (rco) <rco@openerp.com> Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-02-16[FIX] base: mail signature CSS inlined for icons etcNicolas Lempereur
The mail signature of an user did not inline the CSS like the body of a message, so for example icons seemed to work but would not be seen (unless the mail reader had the same font-awesome system). With this change we inline the signature too. On edition there was also an issue since the original icon was saved as data-class which was stripped: so eg. when editing a mail.message with working icon, the icons would disappear. opw-2453912 closes odoo/odoo#66264 X-original-commit: a723bcbebbbc3a526cf63f28b66f53b8be3fe76e Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-09[FIX] tools: prevent call to pillow exif_transpose image methodChristophe Monniez
In a previous fix [0], the call to exif_transpose was kept to allow rotation of images format different than `JPEG`. After a small test, it appeared that the call would crash if the image in another format had the same `LensInfo` tag. So it's safer to not call this method at all. With this commit, the rotation tag is retrieved disregarding the file format by using the `getexif` method if available, falling back to the private method for Pillow < 6 support. As a bonus, a test is also added with a small embedded `JPEG` image, crafted with an `Orientation` exif tag and, for reference, the `LensInfo`tag that caused so much trouble. The fix referenced in [0] was not forward-ported as it was only moving the code the is completely removed in the present. [0] b83c48d5c48954193 closes odoo/odoo#65793 X-original-commit: 38f696dfa5134d93b5a3a1c0647aa8f8c1bd18c9 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-01-11[FIX] tools: try decrypting PDF with empty passwordnie
Steps: - Install accounting - On the dashboard, try to upload an "encrypted" PDF like this one https://launchpadlibrarian.net/24827090/DS-0157.pdf Bug: Traceback: PyPDF2.utils.PdfReadError: file has not been decrypted Explanation: In 13.0, these errors were caught in a catch all `except` as shown here: https://github.com/odoo/odoo/blob/4e089041252c25cc197a30f9e285d82f7162d809/addons/account_facturx/models/account_move.py#L303-L328 From this SO comment: https://stackoverflow.com/questions/52047944/pdfbox-extracting-blanks-from-pdf-encrypted-with-no-password#comment91054285_52047944 > A PDF can be encrypted with two passwords: a user password and an owner password. When a PDF is encrypted with a user password, you can't open the document in a PDF viewer without entering that password. When a PDF is encrypted with an owner password only, everyone can open a PDF without that password, but some restrictions may be in place. From time to time, we get a PDF encrypted with an owner password. The content is still readable, but PyPDF2 fails because it thinks the PDF is encrypted. With this fix, we try to unwrap the PDF by providing an empty user password. This way, PyPDF2 thinks the content is now decrypted. However, PyPDF2 only supports decrypting versions 1 and 2 of the encryption implementation. If the version is different, we skip reading the attachments and carry on to allow the user to upload the document. opw:2375993 closes odoo/odoo#62557 Signed-off-by: backspac <backspac@users.noreply.github.com>
2021-01-10[FIX] misc: Babel; handle 'kur' (kurdish) localeNasreddin (bon)
Issue - add a new language with locale code KUR (for Kurdish) - print any report with a datetime on it (RFQ for example) Cause Babel (version < 2.7.0) does not handle locale "KUR". Solution If wrong locale or not managed by Babel, try to fallback on server default locale. If still wrong locale or not managed, then fallback on "en_US" as locale. opw-2416482 closes odoo/odoo#64301 X-original-commit: 0276c3ef20c79e7061ea5b92aafd6dea190c6a27 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2020-12-28[FIX] odoo_tools/mail.py: Crash at html2plaintext if no treeAchraf (abz)
What are the steps to reproduce your issue ? 1. Install website_blog 2. Go to website and add a new blog post 3. Remove the block content 4. Save and go to Blog page What is currently happening ? Crash: Template fallback An error occured while rendering the template website_blog.post_teaser opw-241937 closes odoo/odoo#63840 X-original-commit: d9097c2b6244154ea64142b5e8fd31cfdd34e66e Signed-off-by: Achraf <abz-odoo@users.noreply.github.com>
2020-12-08[FIX] core: don't require xlrdXavier Morel
Despite being part of the requirement.txt, xlrd apparently was still optional-ish, and absent from some environments like the iotbox. Restore this by only monkeypatching xlrd if it's actually present. closes odoo/odoo#63025 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-12-08[FIX] core: parsing of external ids in PO filesRaphael Collet
The parsing of external ids was made with the regexp `(\w+)\.([\w-]+)`. This regexp is inadequate for external ids that contain non-alphanumeric characters like. We have such a use-case with the selections of field `rating_operator` in module `sale_subscription` that uses the values `">"` and `"<"`. The fix consists in replacing the regexp by `(\w+)\.([^ ]+)`. closes odoo/odoo#62976 Related: odoo/enterprise#15182 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-11-27[ADD] core: 3.9 bytecode instructions in safe_evalXavier Morel
Python 3.9 has 10 new bytecode instructions, for now this commit adds 8 * CONTAINS_OP / IS_OP: moved out of COMPARE_OP which is now only used for *rich* comparisons (bpo-39156) * JUMP_IF_NOT_EXC_MATCH: also moved out of COMPARE_OP for the sole purpose of testing exception types * RERAISE and WITH_EXCEPT_START (bpo-32949) used to simplify the context manager bytecode, but RERAISE was then used for try/except/finally, we don't support context managers in safe_eval so we don't care about the latter * LIST_TO_TUPLE, LIST_EXTEND, SET_UPDATE, DICT_MERGE and DICT_UPDATE (bpo-39320) updates to unpacking (* and **) in various contexts * LIST_TO_TUPLE we're skipping as it's only used when calling a function with two `*arg` parameters (aka `foo(*a, *b)`) * SET_UPDATE is used for set literals of 3 or more items or unpacking ({*a}) * LIST_EXTEND is used in the same cases as well as function calls with unpacking * DICT_MERGE is used for function calls with `**kwargs` * DICT_UPDATE is used when unpacking in a dict literal (`{**kw}`) See odoo/odoo#59980 closes odoo/odoo#62498 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-11-27[IMP] requirements: resolve compatibility issues for 3.8 and 3.9Xavier Morel
Only updates outdated requirements which actively cause issues: * freezegun broken in 3.8 (removal of time.clock) * xlrd broken in 3.8 (removal of time.clock) * also monkeypatches xlrd.xlsx for 3.9 (removal of Element.getiterator, breaks because of defusedxml) * jinja triggers DeprecationWarning in 3.8 * pillow triggers warning in 3.9 * lxml, greenlet don't compile in 3.9 * reportlab doesn't work in 3.9 New versions try to match those of Debian Bullseye. Also adds a script to more easily compare dependency versions between the requirements files and what's in various distributions (currently supports checking against debian and ubuntu). Furthermore updates warnings filtering: * removes xlrd (mischeck was monkeypatched as noted above) * removes setuptools (was for older versions, one would hope this isn't an issue anymore) * adds babel: python-babel/babel#684 fixes the deprecation warning but is not part of any release yet * ignores error related to `random.sample` on a set, this is a diagnostics bug because recordsets implement both Sequence and Set, and the stdlib checks for Set first (bpo-42470) See #59980 Closes #61103 closes odoo/odoo#62380 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-11-20[FIX] core: incomplete tracebackjev-odoo
XML loading always raises a ParseError, however when an XML loading error is triggered from an HTTP request (e.g. a button) the final ParseError logged & shown to the user would not be properly chained to its ancestor, leading the original cause to be lost and issues being much harder to diagnose. This cause is lost in _handle_exception where we duplicate the exception in order to chain it correctly, the __cause__ of the source exception was not properly copied over, and would thus break the chain. The fix also requires explicitly chaining the ParseError to its cause, this should not be necessary but the cause is also lost if this is missing, it is not clear why. opw-2381776 closes odoo/odoo#61914 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-11-17[FIX] tools: extract translations in static/src/ directoryMartin Trigaux
Since 14.0, the javascript code of snippets is moved inside a /static/src/snippets directory. With owl, the components are defined in static/src/components Some other modules were using more exotic path and ended up with no translations. opw-2381030
2020-11-10[FIX] *: sanitize action content readingMartin Trigaux
The open_action_with_context was not using _for_xml_id, producing an error when reading the action content. In open_action, the action_name was taken from the context and needs sanity checks. Ensure only actions from the account module can be read and only if the user has access to the target model. This is a limitation of the previous behaviour but, at the moment, all known calls are made refering to an action from the account module. Limit the scope of this method while the 14.0 is still early to avoid having a door open to ready any action, and difficult to close later. Remove old action fetching from the context in create_move that is no longer used. closes odoo/odoo#61365 Related: odoo/enterprise#14682 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com> Co-authored-by: Xavier Morel <xmo@odoo.com>
2020-10-30[FIX] base: fix `populate.randint` toolRémy Voet (ryv)
The randint generator generated always `None` because the `return` was forget in method of `populate.compute`. - Add a test for the randint tool, and fix the issue. - Change the documentation of `_populate_factories` to be more explicit about the custom generator. closes odoo/odoo#60327 Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2020-10-29[FIX] config: empty argument --foo= to disableJulien Castiaux
In the odoorc file, set a `logfile` path, but disable it via the command line with `--logfile=`. The logs are output to the logfile configured in the config file instead of stdout. Parsing `--logile=` yield an empty string which was interpreted as argument not set and skipped. Closes #3852 closes odoo/odoo#60990 X-original-commit: bae0d99b8d654283be4d265e3b40a83247a2299c Signed-off-by: Martin Trigaux (mat) <mat@odoo.com> Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2020-10-27[IMP] translate: add add/radd methods on _lt classPaul Morelle
In order to ease the usage of lazy translation, add the possibility to add the _lt objects together and with strings. Adding two _lt objects together or to a string will execute their translation, so these operations still must be done once the user's language has been defined. For example, this is now possible: MESSAGES = { 1: _lt("Hello, world!"), 2: _lt("Lorem ipsum"), } def get_text(code): return _("Text is: ") + MESSAGES[code] closes odoo/odoo#60842 X-original-commit: c4596664e5514018c565eaf14b93e000d972bd30 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com> Signed-off-by: Paul Morelle <madprog@users.noreply.github.com>
2020-10-14[FIX] core: PyPDF2 suppresses warningsXavier Morel
By default, PdfFileReader will monkeypatch the `warnings` module even if it has no reason whatsoever to do so and suppress the `captureWarnings` behavior. This means as soon as we've loaded a PDF file, `warnings.warn` don't trigger `logging` warnings anymore, and become invisible. This can lead to non-deterministic behaviors depending as warnings may or may not be suppressed depending when they occur relative to loading a PDF e.g. load a module which runs a test which loads a PDF before a module triggering a warning and the warning won't be visible, other way around it will. Except ofc while we have an override to PdfFileReader it's not used *everywhere*, so need to monkeypatch the init. closes odoo/odoo#60002 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-10-12[FIX] tools/safe_eval: Add missing builtin `sorted`Luis González
Before this commit, the function `sorted` wasn't available on `safe_eval`, even though it's a Python built-in, which mades it unavailable for Python-code evaluation, e.g. server actions. After this commit, the above function is now accessible. closes odoo/odoo#59711 X-original-commit: a725c8927963848c3f8ada3b71897a54b740cce6 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-09-28[FIX] tools.sql, website_*: increment counter with skip lockJeremy Kersten
*blog, forum, slides Based on https://github.com/odoo/odoo/pull/48552#discussion_r440061218 suggestion Add a new method 'increment_skip_lock' in tools.sql to allow to easily increment a specific field of 1 if the record is not locked. The method return boolean if at least 1 record has been incremented. closes odoo/odoo#58534 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-09-28[REM] *: ability to put raw modules in evaluation contextsDebauche Stéphane
Co-authored-by: Xavier Morel <xmo@odoo.com>
2020-09-11[FIX] core: remove callbacks from queue before invocationXavier Morel
The callbacks system is not re-entrant: because we were only clearing the callbacks after having executed them all, if one of the post-commit callbacks commits then all the callbacks will get re-executed (including the one which commits). Which at best can lead to odd effects & data corruption and at worst crashing the software because we're overflowing the stack (or maybe the other way around, hard-crashing might be a better idea than unexpectedly calling the same functions multiple times). By popping the callbacks before executing them, we ensure that each one will only get called once (unless it's explicitely re-pushed on the stack). closes odoo/odoo#57509 X-original-commit: 4257be4d771605ecd972bd5b04cb9c0f1163b455 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-09-07[FIX] *: typos and english incoherencesVictor Feyens
Mainly transifex issues but also some errors found through 'grep' checks. Fix typos and obscure english strings in xml contents, fields strings/helps, some docstrings, ... ensuring correct translations base (and fallback when translations isn't available). closes odoo/odoo#57206 Related: odoo/enterprise#13032 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-09-03[FIX] core: cursor hooks API and implementationRaphael Collet
Python 3.8 changed the equality rules for bound methods to be based on the *identity* of the receiver (`__self__`) rather than its *equality*. This means that in 3.7, methods from different instances will compare (and hash) equal, thereby landing in the same map "slot", but that isn't the case in 3.8. While it's usually not relevant, it's an issue for `GroupCalls` which is indexed by a function: in 3.7, that being a method from recordsets comparing equal will deduplicate them, but not anymore in 3.8, leading to duplicated callbacks (exactly the thing GroupCalls aims to avoid). Also, the API of `GroupCalls` turned out to be unusual and weird. The bug above is fixed by using a plain list for callbacks, thereby avoiding comparisons between registered functions. The API is now: callbacks.add(func) # add func to callbacks callbacks.run() # run all callbacks in addition order callbacks.clear() # remove all callbacks In order to handle aggregated data, the `callbacks` object provides a dictionary `callbacks.data` that any callback function can freely use. For the sake of consistency, the `callbacks.data` dict is automatically cleared upon execution of callbacks. Discovered by @william-andre Related to odoo#56583 References: * https://bugs.python.org/issue1617161 * python/cpython#7848 * https://docs.python.org/3/whatsnew/changelog.html#python-3-8-0-alpha-1 (no direct link because individual entries are not linkable, look for bpo-1617161) X-original-commit: a986f4929bab95759086cc77ca5e60795f82e91a
2020-08-19[REM] core: assertion reportsXavier Morel
That's a not-very-useful subset of OdooTestResult, so: * make results merge-able (aka add ability to update a result with the contents of another) * remove support for test data files, and transmission of the assertion report thing through the data-files loading * replace "legitimate" uses of assertion report by test result * have run_unit_tests manipulate and return a result instead of weird flags & ternaries
2020-08-14[IMP] core: replace dedicated uid cache by ormcacheXavier Morel
Before this, invalidations to the UID cache is not synchronised between workers because it's an ad-hoc solution (so a user changing their password or an admin disabling a user would only lock out an attacker currently using the API of one of possibly several workers). Shift the entire thing to ormcache which already has proper support for synchronising cache invalidation between workers. Also simplify the cache invalidation mess in Users.write because the caches have been unified into a single registry-level LRU, so the half-dozen cache clears on specific ormcached methods & models is pretty much the same as repeatedly calling clear_caches on the current model. **However** registry.cache is trivially accessible from server actions and safe_eval as long as they provide access to a model (through `model.pool.cache`). Which is common, and an issue given we're very much putting sensible data in there. Fix this by renaming `Registry.cache` to `Registry.__cache`, this requires few editions and mangled names are not accessible from safe_eval contexts. The alternative would have been to add more bespoke handling of the uid cache to hook it into the cache invalidation propagation machinery. After discussion with (@)odony, fixing LRU access and using that seems cleaner and less error-prone. Note on lazy_property ===================== Make Registry.cache / Registry.__cache into a regular attribute: the overhead of the LRU is not that high (compared to that of the registry itself), it's rare that we *don't* need it, and it's assumed to be a persisted attribute (it's not just a cache) so making it a normal attribute seems fine; and lazy_property doesn't work for mangled names: the name of the property is mangled using the name of the definition class, but the name of the symbol (fget) is not mangled so lazy_property would set the __cache attribute but then Python would lookup _Registry__cache, creating a new cache every access. And we can't (always) mangle things correctly on `__get__(obj, owner)`: `owner` is just `type(obj)`, meaning in the case of inheritance the type we get is the type through which the property is accessed rather than the one it's defined on. So it would work in the cases where no inheritance is involved (such as Registry.__cache) but not in general (lest we want to play around walking the MRO ourselves to find the definition source, which doesn't seem worth it). lazy_property *could* be made to work properly on Python 3.6+: the descriptor protocol gains `__set_name__(name, owner)`, which is called with the properly mangled name — and with the definition class to boot (though there might still be issues when overriding lazy properties as the override will be mangled & named differently... or maybe that's a feature?). However we're still supporting 3.5 at this point, AFAIK, so that's not an option. Plus it feels unnecessary / not very useful. However add an assertion to `lazy_property` so it signals when we try to use it on a mangled method (as otherwise it kinda sorta work in the sense that the property / object is accessible but is in effect a slower way to write a regular property).
2020-08-06[FIX] tools: skip inexistant modelMartin Trigaux
When trying to generate translation for a model that is not present in the registry (leftover of migration?), the code used to return self.browse(), expecting an empty recordset. self was however a TranslationModuleReader that has no browse method return empty recordset with no model specified closes odoo/odoo#55574 X-original-commit: c004f00bdec83b7c56664425011db53db85da53a Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-08-06[FIX] tools: LRU doesn't have keys() method anymoreJeremy Kersten
Since commit 1b30a78b, LRU is now based on OrderedDict and keys can be found on dictionnary 'd' directly. closes odoo/odoo#55541 X-original-commit: 3f093da75765d66ed1e2d828e8b41ed05d936d0b Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-08-05[IMP] mass_mailing: add preview block for mailingsstd-odoo
PURPOSE When displaying an email in a list the mail client (gmail, outlook...) computes a preview based on the content. This preview is generally not well computed as it contains a lot of garbage and tags while it should contain only relevant text. SPECIFICATIONS To build this preview, all mail clients read the content of the email. The only way to be able to customize the preview is to add an invisible HTML element at the beginning of the email with the wanted preview text. We add at the end of the preview `&zwnj;` (zero-width non-joiner) to fill the end of the preview in order to not have the beginning of the mail at the end of the preview. It doesn't work with simple space as the mail clients trim each HTML element content. Task ID-2172125 PR #49886
2020-07-28[IMP] core, account, lunch: make <menuitem> recursiveXavier Morel
For clarity, some data files are formatted as pseudo-tree structure. This is somewhat confusing and dangerous when the structure has no meaning... so add meaning: * allow nesting menuitems, nested items are set as children to the parent they're nested in * update schema to allow an icon *or* a parent on regular menu items, and neither on nested (they have an implicit parent meaning can't have an icon) * remove attributes which don't actually exist from the menuitem schema * also type sequence as an integer while at it Convert two large-ish menuitem data files to recursive form. closes odoo/odoo#54564 Related: odoo/enterprise#11887 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-07-28[REM] core, *: deprecate <act_window> and <report>Xavier Morel
Convert deprecated tags through the codebase.
2020-07-15[FIX] base: cloc test and default excludeThibault Francois
- Python code is counted slightly differently in python 3.8. ```python a = """ str """ ``` is counted as 2 lines until python 3.7 and only one since python 3.8 This change will not impact a lot the count but we have to make sure the test will pass if the test are run on python 3.8 - the folder migrations is not maintained from version to version and thus should not be counted for the maintenance. closes odoo/odoo#54537 X-original-commit: 2a57a156c7b8e81c01afa095b3291361d208611f Signed-off-by: Antony Lesuisse (al) <al@openerp.com>
2020-07-16[FIX] core: handle recordsets in traverse_containersXavier Morel
Since recordsets are self-recursive, they should be treated like strings (where iterating a string yields a string, infinitely) in case somebody happens to return a non-downgraded recordset from a method. closes odoo/odoo#54572 X-original-commit: 6d88845f339d164fc2667c3417dcc331b317e4db Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-07-14[IMP] web: improve eval context datesJulien Mougenot
This commit handles 2 things: 1) the merging of the `py_utils.context()` into the evaluation context returned by `BasicModel._getEvalContext` to access the same time-related keys, 2) the addition of 2 new keys into the `py_utils.context` (thus transmitted to the basic model): `today` (an alias for the already present `current_date`) and `now` which represents the current date and time value. Task 2269697
2020-07-10[REF] base: clean dosctring and remove deprecated functionwilliam
The function check_with_xsd has been deprecated for more than 3 years. Docstring is now compliant with PEP 257 closes odoo/odoo#54338 X-original-commit: 29938397ee17835645e89ee0dadb26e14ef45927 Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-07-10[IMP] base: _check_with_xsd from ir.attachmentwilliam
Search the xsd files from in the database. To enable this option, the Environment should be passed to the optional `env` parameter. Both the XSD root and the XSD imported by the root and the recusrively imported files will be searched in the database. X-original-commit: 06a35f2e11230db81b8c21696d228097b31cf649
2020-06-30[IMP] tools: use same syntax for _lt than _Martin Trigaux
A new gettext syntax was added at odoo/odoo#52155 but only for _, not for _lt Allow to have the same syntax
2020-06-30[IMP] tools: fallback on empty translationMartin Trigaux
Avoid returning False if, for any reason, the return is falsy (False, None,...) Following the discussion in odoo/odoo#53254, the root cause was a call in the form _(foo) where foo was equal False While nothing else than a string should be the argument of _, it's still technically possible to pass something else and get a bad return value. Fallback on empty string to be consistent.
2020-06-24[FIX] tools: Return input_str when removing accents if emptyNasreddin (bon)
Issue The misc feature remove_accents(input_str) return a string 'False' if the param is a boolean. Solution Return input_str if equal '' or False. opw-2278959 closes odoo/odoo#53572 X-original-commit: 3fc7ce3b5599355933734e5e3f59d14a7a9b199c Related: odoo/enterprise#11391 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2020-06-18[FIX] tools.pdf: do not crash when PDF has no attachmentsBenjamin Frantzen (bfr)
In the PDF, `DictionaryObject` can be wrapped in `IndirectObject`. For nested dictionaries, using `get` on a `DictionaryObject` will unwrap the result if it's an `IndirectObject`, but not `__getitem__` so when trying to futher call `get` on the result will cause an error: we need to unwrap the object first. Instead, we patch `DictionaryObject.get()` for it to unwrap the object in case it's an `IndirectObject`. This is a follow-up commit of fece5ab1bf2fef043b131f1bd0886f0841116103 closes odoo/odoo#53269 X-original-commit: 189a0b28ec7fdb7472f936450cfd7b4bfd6912ed Signed-off-by: Olivier Dony (odo) <odo@openerp.com> Signed-off-by: bfr-o <bfr-o@users.noreply.github.com>