summaryrefslogtreecommitdiff
path: root/odoo/addons/base/models/ir_qweb_fields.py
AgeCommit message (Collapse)Author
2021-03-29[IMP] base: improve qweb barcode widgetChristophe Monniez
When printing barcodes for a large amount of records, wkhtmltopdf will make the same amount of http requests to the server in order to retrieve barcodes. This can lead to performance issues or wkhtml to crash. Fortunately, an already existsing qweb widget exists that include barcodes images as inline base64. With this commit, the web widget is a bit improved to accept attributes for the generated image tag. Each option dictionary key starting with `img_` will be converted into a tag attribute with the corresponding value. e.g.: `'img_alt': 'Barcode'` will result in `<img alt="Barcode"...` The `alt` img attribute now defaults to `'Barcode %s' % value` with the barcode value. Finally, if the `symbology` option is not given, the widget defaults to `Code128`. If `symbology` is set to `auto`, the action report will try to guess the barcode type, based on the len of the value. Cherry-pick of db8b3f1dbf780287fe807ab8d05f2858f3fa03f1 This backport of an improvement will permit to fix existing databases that use the route `/report/barcode/...` in their reports with a large amount of barcodes to print. A `Mea Culpa for my sins` improvement was also done in this cherry-pick and will be forward-ported up to master: a safer lxml.html Element is used to build the img element. closes odoo/odoo#68414 X-original-commit: c3eafec76c75b4e3b02e358bab66e2a05938b9db Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-02-11[FIX] base, web_editor: don't crash on deleted recordsJeremy Kersten
task-2458109 closes odoo/odoo#66019 X-original-commit: 550043b6c36cf657e6cee229676a95ee6482e421 Signed-off-by: Olivier Dony (odo) <odo@openerp.com> Signed-off-by: Jérémy Kersten (jke) <jke@openerp.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-11-16[FIX] *: rephrase, correct typosMartin Trigaux
Courtesy of Transifex's translators for reporting bad/unclear sentences. closes odoo/odoo#61785 Related: odoo/enterprise#14751 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-09-03[IMP] base,web: add image_url widget support in qweb.Victor Feyens
The new "image_url" widget logic provides the ability to provide static image links in Char fields instead of duplicating the image file in database (+ filestore) through an Image field (& ir_attachment). This commits implements the frontend qweb logic for this widget, following the logic of the existing "image" qweb widget.
2020-08-03[IMP] base: support giving tzinfo to QWeb babel datetime formatThibault Delavallée
PURPOSE Allow to finely tune display of datetimes in front-end by adding support of tzinfo parameter of babel format_datetime. See babel for more details about its use. Also add some missing translations bits due to last QWeb options added. LINKS Followup of 69d2513de21c2e80de605f77912a3687b8a79c6d PR #55325 X-original-commit: c7d6e90c93e505950496eec382c89a9936d243be
2020-07-31[IMP] website: support add_direction in duration qweb widgetThibault Delavallée
RATIONALE Events are sometimes held online, gathering a community. In this merge we improve Event application to better support full-online events with improved tracks, wishlists, chat rooms, ... PURPOSE Prepare Event Online support by providing fixes in registration and event frontend flows. Also provide a quick back2basic in backend views to prepare addition of Online sub modules. SPECIFICATIONS Allow to give add_direction to duration widget, propagated to babel formatting. See babel for any information about its use. LINKS Community PR odoo/odoo#55197 Enterprise PR odoo/enterprise#12113 Task ID-2309702 (Event Preparatory Merge 4) Prepares Task ID-2252655 (Main Online Event task)
2020-07-23[IMP] base: add format support on duration fieldThibault Delavallée
RATIONALE Even will soon gain a major update called Event Online, allowing to better support full-online events. In order to prepare its merge, preparatory merge are done to lessen the final diff. PURPOSE In this commit we add support of formatting on duration widget. Possible values are long, short and narrow (see babel formatting options). This option is not used in digital display mode. LINKS PR #54801 Task ID 2304817 (Event Preparation 3) Prepares Task ID 2252655 (Main Online Event task) Prepares Task ID 2283796 (Event B2Basics) X-original-commit: 468a30b0057f4f1c4fba409f4b4baa4f889aad12
2020-06-30[FIX] *: correct all or improve code translation lookupMartin Trigaux
This commit fixes all issues detected by the new pylint gettext-variable test. It converts some calls to the new syntax _("Foo %s", bar) to progressively migrate the code to the new syntax. A few calls were not technically incorrect but still detected by the linter. _("Foo" + "Bar") has been converted to _("Foo" "Bar") as it has the same effect and make sure the argument is of type asteroid.Const instead of BinOp). closes odoo/odoo#53683 Related: odoo/enterprise#11467 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-05-14[IMP] *: convert to private methodsMartin Trigaux
render, render_template, load, activity_schedule_with_view, get_website_pages should all be private: It should not be possible to render an aribtrary template only with its name or id Still need to render some qweb views from js so the method render_template is kept public. This explains why the website editor still need read access on ir.ui.view as we want to allow any snippet to be rendered.
2020-01-28[IMP] *: use ast.literal_evalMartin Trigaux
When simply need to parse a domain, it is easier Add .strip() on ir.ui.view as ast.literal_eval produces an syntax error if the node starts with spaces (as done in the xpath of hr_attendance.view_employee_form_inherit_hr_attendance) closes odoo/odoo#43831 Related: odoo/enterprise#7894 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-01-10[FIX] requirements: update library versions to match Debian BusterChristophe Monniez
Some library versions are outdated since the release of Debian Buster. With this commit the required libraries versions will match as close as possible the versions available in the current Debian stable release (Buster). Also, the requirements were tested against a Windows Python 3.7 to ensure that a "pip install -r" can be used without the need of a CPP compiler. As Babel format_time now returns 'HNE' (Heure Normale de l'EST) for Fr locale instead of the zone offset, the test is adapted. Finally the babel.dates is explicitely imported, otherwise the proper import of this submodule is relying on a side effect. closes odoo/odoo#43106 X-original-commit: 32e455bf72980e6330871aa9cd99c26c6e1225d7 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2019-11-15[IMP] base: add support of VAT field for "contact" qweb widgetshreya thakrar
This commit adds support for displaying 'VAT' field in a 'contact' widget used in qweb views. This commit also does the necessary changes needed for behavior improvements of report editor in studio. For more information, see https://github.com/odoo/enterprise/pull/6543 or task pad. task-1904639 closes odoo/odoo#39722 Related: odoo/enterprise#6543 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-10-01[FIX] *: remove en_US as fallback for lang codewan
en_US may not be activated as it is possible to create a database in another language using the database manager. When trying to install a chart of account, the tax return entry tried to format a date at the installation of the module, with no lang in the context. The fallback was made on en_US but an error is raised if that language is not activated. As it is a very common scenario to retrieve a language from the context, add a generic tool method to do it. Replace and closes odoo/odoo#37629 closes odoo/odoo#37568 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-09-27[REF] website_event, *: review event design and featuresCocographique
* event, website_event_questions, website_event_sale, website_event_track, base Part of https://github.com/odoo/odoo/pull/37009 task-2043872 Co-authored-by: qsm-odoo <qsm@odoo.com> Co-authored-by: Jérémy Kersten <jke@odoo.com>
2019-09-20[MERGE] forward port branch saas-12.4 up to 4a1321bc99dChristophe Simonis
closes odoo/odoo#37127 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-17[MERGE] forward port branch saas-12.3 up to d8ce75466e4Christophe Simonis
2019-09-11[FIX] base: barcode qweb field correct APILucas Perais (lpe)
Before this commit, the barcode Qweb Field had a option called "type", which meant what is the mapping between numbers and barcode, that mapping is called a symbology https://www.barcoding.com/resources/barcoding-basics/barcode-symbologies/ This option "type" collided with what the qweb engine does at ``` qweb > _compile_directive_field that calls ir_qweb > _get_field ``` It resulted in a crash where type = "barcode" was not a valid symbology to pass to the barcode lib It is safe to say that this barcode widget was never user, otherwise it would have crashed This commit changes that non-functioning API, and the barcode renders well OPW 2066870 forward-port of #36499 (330d862513dba5bbc4716fe9c8694fd0db696934) closes odoo/odoo#36499 closes odoo/odoo#36658 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com> Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2019-09-16[FIX] *: correct typos, improve wordingMartin Trigaux
Courtesy of translators closes odoo/odoo#36953 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-08-28[FIX] base,web_editor: fix typoMartin Trigaux
Remove redundant _description
2019-05-29[IMP] api.py: Rename company_id/company_ids into company/companiesYannick Tivisse
The goal is to be coherent with the user property. Actually, company_id and company_ids on the environment are no fields. Calling env.company_id returns a browse record, not an id.
2019-07-03[IMP] base: remove read access to decimal.precisionMartin Trigaux
There is no reason to interact directly with it. The method precision_get is done in SQL and ormcached, it is better to use it
2019-07-03[IMP] decimal_precision: integrate into baseMitali Patel
The decimal precision feature makes sense to be an ORM feature, no need to be in a specific module Previous syntax was from odoo.addons import decimal_precision as dp fields.Float(digits=dp.get_precision('Foo')) and now is: fields.Float(digits='Foo') Remove the possibility to have a callable method on the digits attribute (it was only used for precision anyway) and directly retrieve the digits on the decimal.precision model Rename the method digits to get_digits to avoid confusion between the field attribute when declaring a field and the method to retrieve the precision Task id: 48198
2019-05-06[MERGE] forward port branch saas-12.2 up to 78b3b650b0dChristophe Simonis
2019-05-03[MERGE] forward port branch saas-12.1 up to 2420492c264Christophe Simonis
2019-05-03[MERGE] forward port branch 12.0 up to d7c0c5c127bChristophe Simonis
2019-05-02[MERGE] forward port branch saas-11.3 up to 2c68df0ab43Christophe Simonis
2019-05-02[MERGE] forward port branch 11.0 up to 82c901c9379Christophe Simonis
2019-04-26[IMP] base: avoid unnecessary exists in Contact HTML formatterXavier Morel
Protactively checking exists() seems unnecessary, it's likely that the widget would be called on an empty recordset but seems very unlikely that it'll be called on a missing record. The commit which added the exists() call performs significant refactoring/rewrite and doesn't explain why this exists() call would be useful. Since exists is not cached and qweb field converters are not batched, saves a large number of queries when formatting a series of addresses e.g. with 99 hr.job, /jobs goes from ~170 queries and ~100ms spent in SQL to ~70 queries and ~60ms spent in SQL. Though the total performance improvement is very limited as even with odoo/odoo#32985 the endpoint takes ~700ms (with the aforementioned 99 hr.job visible to the current user). closes odoo/odoo#32986 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-06-28[IMP] tools: introduces format_durationjem-odoo
As some formatting tools already exists, it is time for float_time conversion to have its own. Purpose is to extract formatting logic from the float_time qweb widget to tools, in order to reuse it in mail.template (jinja). We named it 'format_duration', to follow babel convention. This can bring confusion with the duration qweb widget, but this widget should be called 'timedelta', as it is more generic than this one. Task-2025396 closes odoo/odoo#34417 Signed-off-by: Jérome Maes (jem) <jem@openerp.com>
2019-05-27[IMP] base: correct fields labelsSwapnesh Shah
Typos and grammar closes odoo/odoo#33544 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-05-13[MERGE] forward port branch saas-12.3 up to 60e71302a38Christophe Simonis
2019-05-13[IMP] base: Contextualize the multi companyYannick Tivisse
Purpose ======= Allow the user to select the allowed companies for which he wants to see records on top of selecting his current company. It is confusing for users to see the records from the company he is connected to and the records of the children companies. Instead of using the hierarchy of companies to access records across companies, the user can now select (from his set of allowed companies) the companies for which he wants to access records. /!\ This means that the user will interact with records from company A when in company B. Example: a SO has been created and confirmed in A. When in B, I create the invoice from it. Specifications ============== 1/ Deprecate the parent/children hierarchy on the res.company model. The fields are kept on the res.company model to ensure the retro-compatibility, but won't be used accross the standard code anymore. The only functional usage for this mechanism was to allow to see records from several companies by creating a virtual parent company, which will be possible with the new mechanism. 2/ By default, a user will only see the records of the company he is connected to (or records without a company). (It is still editable by the user if needed). For that, put this information in the user context, to allow having different configurations on different browser tabs. Instead of having domains like ['|', ('company_id', '=', False), ('company_id', 'child_of', user.company_id.id)] you'll have something like ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] Note that the 'company_ids' is a value that is passed in the evaluation context on the record rule, as we already have user, or time. company_ids is a list of the ids of all the enabled companies in the user's context. 3/ Out of the generic improvements brought by this task, this will illustrate issues that could exist since several versions. For example, it should not be possible to create a scrap order for the company A with a package of the company B, or it should not be possible to create an invoice on the company A with payment terms from the company B. Before the version 12.0, it was easy to encounter this kind of issues as the admin was the SUPERUSER_ID. A positive side effect of the fact that the SUPERUSER_ID has become an inactive user was to make it more difficult to introduce mismatch on the records, but haven't solved the issue, as it was still possible to do it with parent companies configuration. Some of these issues have been fixed in this commit, but all the business flows should be re-tested to check if an ir.rule should be introduced (eg: a multi company rule for stock.quand.package), if the company of a record is correctly transfered to another record created from the first record (eg: From a SO, create an invoice and a payment, the company of the sales order should be transfered on the invoice and the payment, even if the company of the sales order is A and I'm logged into the company B with the company A enabled. 4/ Currently, if I click on a button on a notification email (example 'View Task'), I face a traceback if I'm not logged into the company of the record. Now, if you click on a button and if you have access to the record, the correct company will be automatically set. 5/ If I display a kanban view with several records from several companies (and an image), all the images should be displayed. 6/ Currently if you copy paste an url, this will crash if you're not in the correct company. This won't be fixed because it's quite impossible to do it in a clean way. This task brings a workaround. Copy/Paste -> Traceback -> Log into the correct company, re-copy/paste -> Ok. 7/ 2 property methods have been added on the environment to retrieve the company on which the user is logged in and the companies the user enabled, on a specific tab. That way, when creating a record, instead of doing default=lambda self: self.env.user.company_id do default=lambda self: self.env.company_id On the other hand, to retrieve the enabled companies, do companies = self.env.company_ids 8/ Modify the Company Switcher widget to allow to log into another company WITHOUT writing on the res.users (and thus bringing cache invalidation issues and so on). Also allow to enable several companies and see records from several companies, and independantly of the other browser's tabs. 9/ When focusing on a tab, save the current company configuration on the local storage. That way, when doing 'CTRL+T' or a middle click, the context is propagated to the new tab. 10/ Improve the error message in case of multi company access errors. Now, when the user is in debug mode, display the related names of the records and the name of the user who brings the issue. 11/ Remove the context erasing when writing on a res.users This is probably coming from the migration to new API of the base module. The context was not propagated at this moment, which was a common mistake at that time. When migrating the module, probably by using the 'black box' method, as the context was not propagated, it was erased on the new version. This is now an issue because the context (i.e. the enabled companies) was erased when writing on a res.users, leading to tracebacks. See: https://github.com/odoo/odoo/commit/7eab8e26d3d46c53f4be924d6a34e80a66e74960#diff-4c2e738ee8f64f11806c889ea097b5e7R624 12/ Fix the crash manager on redirect warnings. The issue is the following - Create an invoice on a company without a configured CoA. - Set a partner - On the onchange_partner_id, a redirect warning is raised to propose you to configure a CoA - Click on 'Go to the configuration panel' - A generic warning says something like 'Do you want to discard your changes?' - Click on yes, the page refreshes, but not on the redirect action. Now, set correctly the action on the hash, and reload instead. The breadcrumb is lost for example, but you reach the correct action at least. 13/ Introduce a res.group to enable/disable the multi company per tab feature. 14/ To help the users to know which tab is in which company, add the possibility to have a favicon per company. When creating a company, the classical 'O' icon is colored by default in a random color. 15/ Remove the company switcher on the frontend. This was mainly there to allow a user to swicth to the company linked to the website. This behavior is now transparent to the user. If the website A is activated, then the company set on the context is the company of the website. 16/ Deprecated the _company_default_get method on the res.company model. Remove the method _get_company on the res.users model. 17/ Add 'allowed_company_ids' and 'current_company_id' on the pyeval context. You can now use those variables on domains in the views to access directly to the activated company.ies on the current tab. TaskID: 1960971 closes odoo/odoo#32341 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-05-02[MERGE] forward port branch saas-12.1 up to b11930047f6Denis Ledoux
2019-03-15[IMP] base: only show date of datetime in qwebPierre Masereel
2018-12-13[FIX] base,website_google_map: fix partner address not showingSébastien Theys
Following commit 983c7e81529eb26a7a756e7d875b5638a26a3733. `_compute_display_name` is overridden in partner to force `show_adress` and some other context variables to None. When those values are in the context, calling `display_name` can give a different result than calling `name_get()[0][1]`. This commit reverts the changes of the mentioned commit where the behavior is actually different, that is, when `show_address` is in the context. It also adds a comment on the `_compute_display_name` method to avoid further mistakes. closes odoo/odoo#29510
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.
2019-01-17[IMP] web_editor,*: Refactoring the wysiwyg editor and 'html' fieldChristophe Matthieu
* Creating a new structure by transforming all the plugins in the library using the odoo inheritance system. Plugins are easier to implement with the AbstractPlugin to add Odoo behaviors. * From now on, the methods of the library (in this case Summernote) can no longer be called by other modules or files. Only the wysiwyg widgets can access it, to simplify the updating process. The wysiwyg object serves as an interface. * Depending on the options the snippets will be loaded or not, the editor will be in an iframe or not... all of this is transparent from the outside. * Regarding iframes, all controllers related to editing have been removed: the new API no longer needs them. This speeds up loading, eases testing and removes complexity for the same features. PUBLIC FEATURES There are several public methods on the Wysiwyg class: * Wysiwyg.prepare (WidgetParent): returns a deferred resolved when the library (xml, lazy, assets...) is loaded. * Wysiwyg.getRange (DOM): returns the range (selection in the dom) * Wysiwyg.setRange (startNode, startOffset, endNode, endOffset): creates a range (selection in the dom) * Wysiwyg.setRangeFromNode (DOM, options) that creates a range from an element (option available to select all, start or end) A jQuery selector was added: :o_editable, which indicates whether the current element is editable. That is, if it is contained in a tag with the attribute 'contentEditable = "true"' or in a tag with the class o_editable. Several methods are also present: * focusIn: makes a focus and places the cursor at the beginning of the element * focusInEnd: makes a focus and places the cursor at the end of the element * selectContent: makes a focus and selects the content HTML FIELD The HTML field can receive different options: * style-inline: {boolean} transforms a class into an inline style when saving and vice versa when reading. * no-attachment: {boolean} prevents the use of attachments (in media dialog) * cssEdit: {xml_id} to use a template containing the css to loaded in an iframe when editing * cssReadonly: {xml_id} to use a template containing the css to load into an iframe when viewing in readonly * snippets: {xml_id} snippets template (can be used with or without cssEdit) * wrapper: {template} qweb static template (containing a tag: id = "wrapper") that will include the content during editing (removed on save) MASS MAILING A widget was created for mass mailing. There are now two fields: body_html and body_arch. body_arch contains the code with the class without conversion into inline style, useful when editing and one with the inline style that is visible in readonly mode and sent by email. Advantage: no spreading errors, able to update css/theme, able to do more changes when converting to inline style so that a maximum of mail clients have an impeccable rendering. Co-authored-by: Antoine Guenet <age@odoo.com>
2018-10-09[IMP] mail,crm,...: Replace occurences of name_get()[0][1] by display_nameTWA
Purpose ======= display_name is equal to doing name_get()[0][1] Replacing name_get()[0][1] by display_name could be good for 2 things: - Uniformization of the code - Probable optimization if name_get is used inside a for loop on a recordset (as the values will be prefetched and put in the cache). TaskID: 1849250 closes odoo/odoo#26341
2018-09-26[FIX] base: description of contact widget optionsMartin Geubelle
There were spelling errors in the description of the `contact` qweb widget options.
2018-09-21[IMP] base: Add missing _description on modelsYannick Tivisse
2018-09-21[IMP]base_*: Improvement in model descriptionNimesh Jethva
Purpose of this commit is to give description more "business oriented" because those descriptions appears in Odoo Studio which is supposed to be used by end users, not only by developers. Related Task ID : 37311
2018-09-07[MERGE] forward port branch saas-11.4 up to d78f23df848Christophe Simonis
2018-09-06[FIX] base,account,product: correct currency convertion when company is get ↵Christophe Simonis
from context Method `_convert` expect a browserecord, not an integer.
2018-09-05[FIX] base: correct typoMartin Trigaux
2018-08-28[FIX] base,account,sale: typo in field labelsMartin Trigaux
2018-08-13[IMP] base, *: use a many2one for the company report layoutChristophe Matthieu
Before this rev. one could set the report layout on the company using a hardcoded list (background, clean, standard, etc.). Other modules (typically accounting modules) could add options in this list. The used template was built on the layout key. Now, the layout is a many2one field to a newly created model `report.layout`, which is linked to a view with the layout architecture. This gives more control to customize reports and create a new layout (without creating a python module that extend the layout selection).
2018-08-13[IMP] base, hr_timesheet: add option `digital` in qweb field durationChristophe Matthieu
The option `digital` has been added. It allows to display "01:00" instead of "1 hour". This behaviour was implemented in a report (timesheet) but the logic was done in the XML, which is not adequate. This commit also allows to have a negative value for this widget.
2018-08-13[IMP] qweb: add many2many qweb widgetChristophe Matthieu
Instead of looping on x2m values in the qweb report, this new widget will automatically render the x2m values for you (separeted with a comma).
2018-08-13[IMP] qweb: add method who defines qweb widget optionsChristophe Matthieu
Each qweb widget should now explicitily define a method `get_available_options` which specifies all options used in the widget rendering. The options are a dictionary with the option as key and the option type as value (e.g. string, integer, array, model, etc.). This is used by the Studio report editor (to customize widget options) and parsed in JS.