summaryrefslogtreecommitdiff
path: root/odoo/tools/convert.py
AgeCommit message (Collapse)Author
2019-03-22[FIX] convert: enable kwargs in tag <function>Raphael Collet
closes odoo/odoo#31417 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2018-11-29[FIX] core: fixup of convert cleanupXavier Morel
_tag_delete was not properly converted when the _tag_ calling convention was modified in 4d581e26c2c30a53c41fcdc89d42c79e9ba1ef2f, so <delete> tags would all blow up if encountered. closes odoo/odoo#29149
2018-11-29[REF] *: replace deprecated pycompat helpers for builtinsAdrian Torres
This commit replaces calls to pycompat helpers that were intended for python 2 <-> python 3 interoperability for python 3 builtins, as python 2 is no longer officially supported by Odoo. This includes: * calls to imap/izip/ifilter replaced by map/zip/filter * uses of text_type replaced by str * uses of unichr replaced by chr * calls to implements_to_string, implements_iterator removed * string_types and integer_types replaced by str, int respectively * calls to to_native replaced by calls to to_text This is done in preparation to the removal of these deprecated helpers in the following commit.
2018-10-22[FIX] core: adapt forward-ported code after ↵Christophe Simonis
4d581e26c2c30a53c41fcdc89d42c79e9ba1ef2f
2018-10-22[MERGE] forward port branch 12.0 up to b81c2bce846Christophe Simonis
2018-10-21[FIX] models: restore warning on wrong recordMartin Trigaux
Was lost during d5b687a48ffb Set the module name in the context to be able to detect errors in xml and csv import closes odoo/odoo#27680
2018-10-19[FIX] core: early fail on missing foreign recordsChristophe Simonis
When installing/updating a module, verify existence of foreign records before updating them. Also handle forcecreate=False records. Also fix misprefixed XML id in sale_quotation_builder. closes odoo/odoo#27659
2018-10-11[REM] core: assert, ir_set and url tags from XML data filesXavier Morel
* ir_set and url were accepted by the RNG despite ir_set having been removed back in 2015 or so and <url> having possibly never existed in the first place (could not find any reference to an <url> element outside of sitemap qweb templates) * <assert> was essentially deprecated/removed in 2015 with the v9 accounting having stopped running account_assert_test.xml, which was the last file using the tag so far as I can tell. The file itself remained as dead code until 2018
2018-10-11[REF] core: cleanup noupdate handling in XML importXavier Morel
Use the same pattern as for the envs: a stack of noupdate values pushed and popped around data nodes. Avoids re-parsing the same noupdate attribute on every node execution, and completely removes the need to pass the nearest data node to every _tag_ function.
2018-10-11[FIX] core: support for uid/context in XML data filesXavier Morel
* add tests for uid/context on record & function & root nodes (odoo, data, openerp) "inherited" by record & function * add rng validation to the test cases to ensure technical capabilities are matched by validation capabilities (which was not the case as we could validate nonsense and import stuff which didn't pass validation or something) * extact uid/context into its own rng pattern - add uid support to record validation - add uid support to root nodes validation - fix uid support on function validation: was typoed to @id, which is not used anywhere in function tags loading & makes no sense as far as I can tell * replace get_uid/get_context by get_env & reimplement the whole mess: build a stack of environments from the root nodes (each root node = one env in the stack, though the exact same env can be present multiple times if none of the root nodes has a @uid or @context) and leaves can build upon this "ready made" environment for their own uses or use it as-is. As a result, all uid/context should now properly transfer from the root nodes to the leaves needing them * fix support for context on functions: was not actually implemented as the context was not propagated into the old-style API call * add uid support to record & context is now inherited from env
2018-10-11[IMP] core: convert_xml refactorings to prepare for improvementsXavier Morel
* add _tag_ methods for root nodes (remove some of the parse special casing) * remove unnecessary/useless returns * remove cr & uid (there's an env) * remove mode argument from callbacks (redundant and confused with self.mode) * try to cleanup menuitem callback a bit * make second callback param not optional (because it's not)
2018-08-20[IMP] tools: replace SQL codeFlorent de Labarre
No need to construct the table name, can use the model name Closes #25659
2018-08-13[ADD] website_theme_install: try to make theme multi website compliantJeremy Kersten
From now, when you install a theme, it load the data from xml to template table theme [ir.ui.view|ir.attachment|website.page|website.menu]. Data are only copied from this template table into the real table when you choose a theme on a website; Making them website_specific and with a link to the original to allow futur update. A special case is done to create theme.ir.ui.view when you are installing a theme, even if you continue to use template tag to create quick view. Co-authored-by: Derie Romain <rde@odoo.com> Co-authored-by: Kersten Jérémy <jke@odoo.com>
2018-07-24[REF] models: import records in batchRaphael Collet
Create new methods on `BaseModel` to create records with given xml ids in batch. Those methods replace the methods `_update` and `_update_dummy` of model 'ir.model.data', which are now deprecated. Adapt XML and CSV import code to create records in batch.
2018-07-16[IMP] de-commit-ify db/module installXavier Morel
Try to remove cr.commit (and rollback) from module and db install: * put a savepoint around test data loading * remove a bunch of commits sprinkled throughout * remove rollback on data loading failure (assuming it bubbles up, the entire module's installation should be rolled back) * add commit right before the tests are run, so they can run isolated and still see whatever was done when installing their module * convert a few explicit closing to context managers
2018-06-01[IMP] convert: simplify context when creating recordsRaphael Collet
The context was containing a dictionary under the key `install_mode_data`, which was informing about the model, xml_id, module, filename. Actually only the module and filename were necessary, and the others were slowing down the import because of generating artificially different environments. The context now has two entries `install_module` and `install_filename`.
2018-05-09[MERGE] forward port branch 11.0 up to b793e23ae53Christophe Simonis
2018-05-09[FIX] orm: "relate" binding type on actionsxmo-odoo
When ir.values was removed and the "action" ir.values were merged directly into the actions themselves, "client_action_relate" was discarded as unused (and possibly too similar to client_action_multi?). *However*: * it was actually used implicitly as "relate" was the default key2 of the <act_window> XML tag * and it had a crucial difference from client_action_multi: client_action_multi is shown on both form and list views by default and only on list if multi=True, whereas relate is shown on *either* the form or list view (tree if multi else form) This means without relate the actions which should be only visible on the form view are now on both list and tree, which leads to overpopulated `Action` menus and odd behaviours (e.g. actions relying active_id on lists, which id do they get and why?) => reintroduce relate as "action_form_only" for the specific case of multi=False and either no key2 or a key2 of client_action_relate. If multi=True then binding_type=action. Fixes #20124 Followup: Task 1843603 to remove #multi and redundancy
2017-11-16[REM] tools: Remove the yml import engineYannick Tivisse
2017-11-07[IMP] convert.py: Extend accessible variables in '_tag_record'Yannick Tivisse
Purpose ======= Currently on <record> tags, it's impossible to use 'datetime' or 'obj' when using 'search' attribute on a field. The following example won't work: <record id="foo" model="model.model"> <field name="bar_id" search="[('company.id', '=', obj([]).env.user.company_id.id)]"/> </record> Specification ============= Use '_get_idref' to extend the accessible variables on the 'safe_eval' computation.
2017-10-25[IMP] tools: basic spelling and grammar correctionsAndrew Latham
Closes #20391
2017-09-25[FIX] reading of HTML and XML view fields in P3Xavier Morel
Reading them as bytes would not crash but could fill the corresponding field with pretty much garbage. Turns out Html fields inherit from Text and XML content generally goes into text fields, so handling these items as text makes much more sense than as binary data.
2017-09-15[ADD] website: add new page managementrde
website.page = old ir.ui.view with page=True website.redirect is a new mechanism to replace in the futur the ir.attachment mechanism of redirect. From now, we don't have a specific /page controller to serve 'page'. We use a new model website.page which is rendered if none route matches the url and that the field 'url' on website.page matches the request.httprequest.path. The order to serve a path is: - Routes defines in controllers (/shop, /blog, ...) - ir.attachment with name matching the path - website.page with url matching the path - website.redirect with url_from matching the path - 404 To improve: - allow regexp in website.redirect model - allow to edit the view_arch from the page.management via redirect backend (needed when traceback in the page, or when modifying a js/css/less/...)
2017-08-28[ADD] base: direct support for binding an action to a modelRaphael Collet
2017-08-20[FIX] P3: file modesXavier Morel
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[FIX] P3: error messages are text, dump XML docs as textXavier Morel
2017-08-20[FIX] P3: encoding & decoding mess while manipulating XMLXavier Morel
* 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[FIX] P3: CSV reading & writingXavier Morel
2017-08-20[FIX] P3: text model typesXavier Morel
* remove references to basestring & unicode (use relevant pycompat helpers) * remove some str calls (either entirely or replaced by relevant helper, either text or native) * use better API to avoid unnecessary conversions * remove some XML declarations in views
2017-08-20[FIX] P3: fix base64 and StringIO usesXavier Morel
* 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-06-19[IMP] tools: add filename in error message of bad schemaJerther
To easily identify the file responsible for the error Closes #17622 Fixes #15869
2017-06-02[IMP] base: Add 'active' attribute on menuitem tagYannick Tivisse
This attribute will be used in the next commit to hide by default account menuitems in the account module to finally display them in the account_invoicing module. Without this attribute, we should create the menuitems with the <menuitem> tag and after that make them inactive by using a <record> tag
2017-05-26[IMP] base: Always load menuitem xmlids on templatesYannick Tivisse
PURPOSE ======= Currently we can choose to load the xmlid of a menuitem if web_tour is installed by setting the attribute `load_xmlid=True` on the view. This is strange for 2 reasons: - Searching all the ir.model.data on menuitems with load_xmlid=True to compute its xmlid, searching the related subtree on the returned structure of the method load_menus is quite complicated for the perfomance gain (if there is any perfomance gain to do it) - This is not working in community in frontend, as only the root menuitems are loaded, thus it is the `load_menus_root` instead of the `load_menus` that is called. This issue prevent a tour step to be displayed correctly on community and enterprise on a menuitem. SPECIFICATION ============= Remove all the `load_xmlid` attributes and the related mechanism and move it into base to always load the xmlids for all the menuitems. It won't bee to heavy as the result is cached. It's better the keep the current mechanism (Load the xmlids from ir.model.data and insert them into the tree) as we only make 1 search to the ir.model.data
2017-05-15[FIX] missing importxmo-odoo
Call would crash when you crash.
2017-05-12[FIX] P3: raise exception with existing tracebackXavier Morel
In Python 2, to raise a new exception but reuse a traceback requires a special form of ``raise`` (``raise etype, evalue, tb``). In Python 3, this is now done via a ``with_traceback`` method on exception objects. However this requires a bit of trickery as the former is invalid syntax in Python 3, hence pycompat bridge created via an exec for Python 2.
2017-05-10[IMP] import, report: allow print_report_name when defining a reportThibault Delavallée
Otherwise you have to have another xml block just to define the print report name instead of doing everything in the report tag.
2017-05-10[FIX] P3: list -> iterable builtins (#16811)xmo-odoo
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-08[REM] odoo/report: remove deprecated stuffLaurent Smet
- RML Reports - Webkit Reports (most part already removed by 13b9982c6298021289707ed364e3c1d622a09f13) - LocalService in netsvc.py - rename attributes like rml_% to report_% - rename ir.actions.report.xml to ir.actions.report - allow rendering directly on an ir.actions.report by calling render method - remove 'controller' report_type - remove unused res.font stuff - remove print_report method in models.py (not used) - restore removed call to pdftotext process in test_reports
2017-05-05[MERGE] forward port branch saas-15 up to c0e4ab80804Christophe Simonis
2017-05-05[MERGE] forward port branch 10.0 up to d5cdb777172Christophe Simonis
2017-05-04[FIX] tools: unnecessary error loggingNicolas Martinelli
The limit of 64 characters on the XMLID has been removed a long time ago. This error is therefore not necessary anymore.
2017-04-28[FIX] Various P3-related import changesxmo-odoo
* 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-27[FIX] builtins removed from Python 3xmo-odoo
* Reverse wrapper courtesy of @rco-odoo's original P3 branch * thin compat module stripped down from werkzeug (to augment as needed) issue 8530
2017-04-25[FIX] iterator definition & steppingxmo-odoo
* in P3, the iterator stepping method has become a dunder method (next -> __next__), the protocol has not changed, add a __next__ alias to the iterator-next definition (nota: ir.config also has a next method but it's not part of an iterator, so don't alias it and don't convert calls to it) * since ~2.6, a builtin (next()) has been added to step an iterator & allow for a default (in case of iterator end), convert all manual stepping to the builtin Fixers: libfuturize.fixes.fix_next_call #8530
2017-04-11[#8530] convert exception handlers to except..as syntaxXavier Morel
Futurize fixers: * lib2to3.fixes.fix_except
2016-11-23[REM] workflow: Remove workflow engine, documentation and testsYannick Tivisse
2016-10-10[MERGE] forward port branch saas-12 up to 43cb4acChristophe Simonis
2016-09-16[MERGE] forward port branch saas-12 up to 10cde43Christophe Simonis
2016-09-02[FIX] odoo: rename imports and adapt import hooksRaphael Collet
2016-09-02[REF] openerp: move `openerp` to `odoo`Raphael Collet