-
-
Notifications
You must be signed in to change notification settings - Fork 726
[14.0] [MIG] website_field_autocomplete: Migration to 14.0 #870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
racielperdomo1993
wants to merge
28
commits into
OCA:14.0
from
racielperdomo1993:14.0-mig-website_field_autocomplete
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
37d2a60
[ADD] Create new module website_field_autocomplete
lasley 6348d0a
[FIX] Update view attrs to match in website_field_autocomplete
lasley 4088b67
[FIX] Improve JS syntax and data names in website_field_autocomplete
lasley 4b52650
[FIX] Return deferred query & update ReadMe in website_field_autocomp…
lasley 8a11bf8
[IMP] Js modularity and ReadMe in website_field_autocomplete
lasley caa674f
[ADD] Demo data on homepage for website_field_autocomplete
lasley e15f552
[IMP] website_field_autocomplete: Switch from JS model to controller
lasley 3978d5e
[IMP] website_field_autocomplete: Improvements for modularity
lasley ce51cd0
[FIX] website_field_autocomplete: Move demo to isolated page
lasley 2bf75f3
OCA Transbot updated translations from Transifex
oca-transbot 0eed2fc
OCA Transbot updated translations from Transifex
oca-transbot 77d73cc
[IMP] website_field_autocomplete: Upgrade for modularity
lasley 55d1a74
[FIX] website_field_autocomplete: Fix namespacing
lasley b80dad7
[FIX] website_field_autocomplete: Demo data
lasley d07af73
[FIX] website_field_autocomplete: Use search_read
lasley c8a9da1
OCA Transbot updated translations from Transifex
oca-transbot 134759b
OCA Transbot updated translations from Transifex
oca-transbot beb6a49
[FIX] remove en.po that was erroneously created by transbot
sbidoul ecff0e1
OCA Transbot updated translations from Transifex
oca-transbot d010ff5
OCA Transbot updated translations from Transifex
oca-transbot f05f931
[MIG] Make modules uninstallable
pedrobaeza 7819b1a
[MIG] Rename manifest files
pedrobaeza 175a344
[MIG] website_field_autocomplete: Upgrade to v10
lasley 28740dc
OCA Transbot updated translations from Transifex
oca-transbot a37eaca
[UPD] Update website_field_autocomplete.pot
oca-travis ca02678
[IMP] website_field_autocomplete: black, isort, prettier
racielperdomo1993 4d7e122
[MIG] website_field_autocomplete: Migration to 14.0
racielperdomo1993 fa3d023
[IMP] website_field_autocomplete: compatibility many2one fields
miguel-S73 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/website_field_autocomplete/odoo/addons/website_field_autocomplete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../../website_field_autocomplete |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import setuptools | ||
|
|
||
| setuptools.setup( | ||
| setup_requires=['setuptools-odoo'], | ||
| odoo_addon=True, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| .. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg | ||
| :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
| :alt: License: AGPL-3 | ||
|
|
||
| ============================ | ||
| Website Field - AutoComplete | ||
| ============================ | ||
|
|
||
| Adds an AutoComplete field for use in Odoo Website. | ||
|
|
||
| This module is somewhat difficult to use on its own in an effort to not require | ||
| any dependencies other than website. | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| To use this module, you need to add an input field with the | ||
| ``js_website_autocomplete`` class, such as in the below format: | ||
|
|
||
| .. code:: xml | ||
|
|
||
| <input type="text" | ||
| class="js_website_autocomplete" | ||
| data-query-field="name" | ||
| data-display-field="name" | ||
| data-value-field="id" | ||
| data-limit="10" | ||
| data-domain='[["website_published", "=", true]]' | ||
| data-model="product.template" | ||
| /> | ||
|
|
||
| Following is a breakdown of the available attributes & their defaults: | ||
|
|
||
| +--------------------+---------------------------------------------+---------------+----------+ | ||
| | Attribute | Description | Default | Required | | ||
| +====================+=============================================+===============+==========+ | ||
| | data-model | Model name to query | | True | | ||
| +--------------------+---------------------------------------------+---------------+----------+ | ||
| | data-field | Field name in Model | | False | | ||
| +--------------------+---------------------------------------------+---------------+----------+ | ||
| | data-query-field | Field to query when searching | name | False | | ||
| +--------------------+---------------------------------------------+---------------+----------+ | ||
| | data-display-field | Field to display | query-field | False | | ||
| +--------------------+---------------------------------------------+---------------+----------+ | ||
| | data-value-field | Field to use as form value | display-field | False | | ||
| +--------------------+---------------------------------------------+---------------+----------+ | ||
| | data-limit | Limit results to this many | 10 | False | | ||
| +--------------------+---------------------------------------------+---------------+----------+ | ||
| | data-domain | Additional domain for query | [] | False | | ||
| +--------------------+---------------------------------------------+---------------+----------+ | ||
|
|
||
|
|
||
| .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
| :alt: Try me on Runbot | ||
| :target: https://runbot.odoo-community.org/runbot/186/10.0 | ||
|
|
||
|
|
||
| Known Issues / Road Map | ||
| ======================= | ||
|
|
||
| * Replace jQuery UI Autocomplete w/ HTML5 Datalist when `ready for production <http://caniuse.com/#feat=datalist>`_. | ||
|
|
||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues | ||
| <https://github.com/OCA/website/issues>`_. In case of trouble, please | ||
| check there if your issue has already been reported. If you spotted it first, | ||
| help us smashing it by providing a detailed and welcomed feedback. | ||
|
|
||
|
|
||
| Credits | ||
| ======= | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| * Dave Lasley <dave@laslabs.com> | ||
| * `Studio73 <https://www.studio73.es>`__: | ||
| * Miguel Gandia <miguel@studio73.es> | ||
|
|
||
| Maintainer | ||
| ---------- | ||
|
|
||
| .. image:: https://odoo-community.org/logo.png | ||
| :alt: Odoo Community Association | ||
| :target: https://odoo-community.org | ||
|
|
||
| This module is maintained by the OCA. | ||
|
|
||
| OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
| mission is to support the collaborative development of Odoo features and | ||
| promote its widespread use. | ||
|
|
||
| To contribute to this module, please visit https://odoo-community.org. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright 2016 LasLabs Inc. | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| from . import controllers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Copyright 2016 LasLabs Inc. | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| { | ||
| "name": "Website Field - AutoComplete", | ||
| "summary": "Provides an autocomplete field for Website on any model", | ||
| "version": "14.0.1.0.0", | ||
| "category": "Website", | ||
| "website": "https://github.com/OCA/website", | ||
| "author": "LasLabs, Odoo Community Association (OCA)", | ||
| "license": "AGPL-3", | ||
| "application": False, | ||
| "installable": True, | ||
| "depends": [ | ||
| "website", | ||
| ], | ||
| "data": [ | ||
| "views/assets.xml", | ||
| ], | ||
| "demo": [ | ||
| "demo/field_autocomplete_demo.xml", | ||
| ], | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright 2016 LasLabs Inc. | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| from . import main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Copyright 2016 LasLabs Inc. | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
|
|
||
| from odoo import http | ||
| from odoo.http import request | ||
|
|
||
| from odoo.addons.website.controllers.main import Website | ||
|
|
||
|
|
||
| class Website(Website): | ||
| @http.route( | ||
| "/website/field_autocomplete/<string:model>", | ||
| type="json", | ||
| auth="public", | ||
| methods=["POST"], | ||
| website=True, | ||
| ) | ||
| def _get_field_autocomplete(self, model, **kwargs): | ||
| """Return json autocomplete data""" | ||
| domain = kwargs.get("domain", []) | ||
| fields = kwargs.get("fields", []) | ||
| limit = kwargs.get("limit", None) | ||
| res = self._get_autocomplete_data(model, domain, fields, limit) | ||
| return list(res.values()) | ||
|
|
||
| def _get_autocomplete_data(self, model, domain, fields, limit=None): | ||
| """Gets and returns raw record data | ||
| Params: | ||
| model: Model name to query on | ||
| domain: Search domain | ||
| fields: List of fields to get | ||
| limit: Limit results to | ||
| Returns: | ||
| Dict of record dicts, keyed by ID | ||
| """ | ||
| if limit: | ||
| limit = int(limit) | ||
| res = request.env[model].search_read(domain, fields, limit=limit) | ||
| return {r["id"]: r for r in res} | ||
51 changes: 51 additions & 0 deletions
51
website_field_autocomplete/demo/field_autocomplete_demo.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <!-- | ||
| Copyright 2016 LasLabs Inc. | ||
| @license AGPL-3 or later (http://www.gnu.org/licenses/agpl.html). | ||
| --> | ||
| <odoo> | ||
| <record id="field_autocomplete_demo" model="ir.ui.view"> | ||
| <field name="name">Field Autocomplete Demo</field> | ||
| <field name="type">qweb</field> | ||
| <field name="key">website.field_autocomplete_demo</field> | ||
| <field name="arch" type="xml"> | ||
| <t name="Field Autocomplete Demo" t-name="website.field_autocomplete_demo"> | ||
| <t t-call="website.layout"> | ||
| <div id="wrap" class="oe_structure oe_empty"> | ||
| <div class="container"> | ||
| <h1>Website Menu Autocomplete:</h1> | ||
| <div class="row"> | ||
| <label for="url">URL</label> | ||
| <input | ||
| type="text" | ||
| name="url" | ||
| class="js_website_autocomplete" | ||
| data-query-field="name" | ||
| data-display-field="name" | ||
| data-value-field="url" | ||
| data-limit="10" | ||
| data-model="website.menu" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </t> | ||
| </t> | ||
| </field> | ||
| </record> | ||
| <record id="field_autocomplete_demo_page" model="website.page"> | ||
| <field name="is_published">True</field> | ||
| <field name="url">/page/website_field_autocomplete</field> | ||
| <field name="view_id" ref="field_autocomplete_demo" /> | ||
| <field name="track">True</field> | ||
| </record> | ||
| <record id="field_autocomplete_demo_link" model="website.menu"> | ||
| <field name="name">AutoComplete</field> | ||
| <field name="url">/page/website_field_autocomplete</field> | ||
| <field name="page_id" ref="field_autocomplete_demo_page" /> | ||
| <field name="parent_id" ref="website.main_menu" /> | ||
| <field name="sequence" type="int">50</field> | ||
| </record> | ||
|
|
||
|
|
||
| </odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * website_field_autocomplete | ||
| # | ||
| # Translators: | ||
| # OCA Transbot <transbot@odoo-community.org>, 2017 | ||
| # Quentin THEURET <odoo@kerpeo.com>, 2017 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 10.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2017-07-25 07:50+0000\n" | ||
| "PO-Revision-Date: 2017-07-25 07:50+0000\n" | ||
| "Last-Translator: Quentin THEURET <odoo@kerpeo.com>, 2017\n" | ||
| "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" | ||
| "Language: fr\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:website.menu,name:website_field_autocomplete.field_autocomplete_demo_link | ||
| msgid "AutoComplete" | ||
| msgstr "AutoCompletion" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:ir.ui.view,arch_db:website_field_autocomplete.field_autocomplete_demo | ||
| msgid "URL" | ||
| msgstr "URL" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:ir.ui.view,arch_db:website_field_autocomplete.field_autocomplete_demo | ||
| msgid "Website Menu Autocomplete:" | ||
| msgstr "Menu d'Autocompletion du site Web :" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * website_field_autocomplete | ||
| # | ||
| # Translators: | ||
| # Bole <bole@dajmi5.com>, 2017 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 10.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2017-03-30 02:38+0000\n" | ||
| "PO-Revision-Date: 2017-03-30 02:38+0000\n" | ||
| "Last-Translator: Bole <bole@dajmi5.com>, 2017\n" | ||
| "Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" | ||
| "Language: hr\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" | ||
| "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:website.menu,name:website_field_autocomplete.field_autocomplete_demo_link | ||
| msgid "AutoComplete" | ||
| msgstr "Automatsko popunjavanje" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:ir.ui.view,arch_db:website_field_autocomplete.field_autocomplete_demo | ||
| msgid "URL" | ||
| msgstr "URL" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:ir.ui.view,arch_db:website_field_autocomplete.field_autocomplete_demo | ||
| msgid "Website Menu Autocomplete:" | ||
| msgstr "Webstranice izbornik automatskog popunjavanja" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * website_field_autocomplete | ||
| # | ||
| # Translators: | ||
| # Imre Kristoffer Eilertsen <imreeil42@gmail.com>, 2016 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 9.0c\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2016-08-01 05:06+0000\n" | ||
| "PO-Revision-Date: 2016-08-01 05:06+0000\n" | ||
| "Last-Translator: Imre Kristoffer Eilertsen <imreeil42@gmail.com>, 2016\n" | ||
| "Language-Team: Norwegian Bokmål (Norway) (https://www.transifex.com/oca/" | ||
| "teams/23907/nb_NO/)\n" | ||
| "Language: nb_NO\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:website.menu,name:website_field_autocomplete.field_autocomplete_demo_link | ||
| msgid "AutoComplete" | ||
| msgstr "Autofullfør" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:ir.ui.view,arch_db:website_field_autocomplete.field_autocomplete_demo | ||
| msgid "URL" | ||
| msgstr "URL" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:ir.ui.view,arch_db:website_field_autocomplete.field_autocomplete_demo | ||
| msgid "Website Menu Autocomplete:" | ||
| msgstr "Autofullfør på nettsidemeny:" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * website_field_autocomplete | ||
| # | ||
| # Translators: | ||
| # Peter Hageman <hageman.p@gmail.com>, 2017 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 10.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2017-07-11 02:45+0000\n" | ||
| "PO-Revision-Date: 2017-07-11 02:45+0000\n" | ||
| "Last-Translator: Peter Hageman <hageman.p@gmail.com>, 2017\n" | ||
| "Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" | ||
| "teams/23907/nl_NL/)\n" | ||
| "Language: nl_NL\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:website.menu,name:website_field_autocomplete.field_autocomplete_demo_link | ||
| msgid "AutoComplete" | ||
| msgstr "" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:ir.ui.view,arch_db:website_field_autocomplete.field_autocomplete_demo | ||
| msgid "URL" | ||
| msgstr "URL" | ||
|
|
||
| #. module: website_field_autocomplete | ||
| #: model:ir.ui.view,arch_db:website_field_autocomplete.field_autocomplete_demo | ||
| msgid "Website Menu Autocomplete:" | ||
| msgstr "" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use type="json" and POST?