Skip to content
Closed
Show file tree
Hide file tree
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 Jun 21, 2016
6348d0a
[FIX] Update view attrs to match in website_field_autocomplete
lasley Jun 22, 2016
4088b67
[FIX] Improve JS syntax and data names in website_field_autocomplete
lasley Jun 22, 2016
4b52650
[FIX] Return deferred query & update ReadMe in website_field_autocomp…
lasley Jun 22, 2016
8a11bf8
[IMP] Js modularity and ReadMe in website_field_autocomplete
lasley Jun 23, 2016
caa674f
[ADD] Demo data on homepage for website_field_autocomplete
lasley Jun 24, 2016
e15f552
[IMP] website_field_autocomplete: Switch from JS model to controller
lasley Jun 24, 2016
3978d5e
[IMP] website_field_autocomplete: Improvements for modularity
lasley Jun 24, 2016
ce51cd0
[FIX] website_field_autocomplete: Move demo to isolated page
lasley Jun 27, 2016
2bf75f3
OCA Transbot updated translations from Transifex
oca-transbot Jul 4, 2016
0eed2fc
OCA Transbot updated translations from Transifex
oca-transbot Jul 11, 2016
77d73cc
[IMP] website_field_autocomplete: Upgrade for modularity
lasley Jul 9, 2016
55d1a74
[FIX] website_field_autocomplete: Fix namespacing
lasley Jul 9, 2016
b80dad7
[FIX] website_field_autocomplete: Demo data
lasley Jul 14, 2016
d07af73
[FIX] website_field_autocomplete: Use search_read
lasley Jul 20, 2016
c8a9da1
OCA Transbot updated translations from Transifex
oca-transbot Aug 1, 2016
134759b
OCA Transbot updated translations from Transifex
oca-transbot Aug 8, 2016
beb6a49
[FIX] remove en.po that was erroneously created by transbot
sbidoul Aug 15, 2016
ecff0e1
OCA Transbot updated translations from Transifex
oca-transbot Sep 4, 2016
d010ff5
OCA Transbot updated translations from Transifex
oca-transbot Sep 18, 2016
f05f931
[MIG] Make modules uninstallable
pedrobaeza Oct 6, 2016
7819b1a
[MIG] Rename manifest files
pedrobaeza Oct 6, 2016
175a344
[MIG] website_field_autocomplete: Upgrade to v10
lasley Oct 22, 2016
28740dc
OCA Transbot updated translations from Transifex
oca-transbot May 2, 2017
a37eaca
[UPD] Update website_field_autocomplete.pot
oca-travis Jun 21, 2018
ca02678
[IMP] website_field_autocomplete: black, isort, prettier
racielperdomo1993 Jan 11, 2022
4d7e122
[MIG] website_field_autocomplete: Migration to 14.0
racielperdomo1993 Jan 11, 2022
fa3d023
[IMP] website_field_autocomplete: compatibility many2one fields
miguel-S73 Oct 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions setup/website_field_autocomplete/setup.py
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,
)
96 changes: 96 additions & 0 deletions website_field_autocomplete/README.rst
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.
4 changes: 4 additions & 0 deletions website_field_autocomplete/__init__.py
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
23 changes: 23 additions & 0 deletions website_field_autocomplete/__manifest__.py
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",
],
}
4 changes: 4 additions & 0 deletions website_field_autocomplete/controllers/__init__.py
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
40 changes: 40 additions & 0 deletions website_field_autocomplete/controllers/main.py
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(
Copy link
Member

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?

"/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 website_field_autocomplete/demo/field_autocomplete_demo.xml
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>
35 changes: 35 additions & 0 deletions website_field_autocomplete/i18n/fr.po
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 :"
35 changes: 35 additions & 0 deletions website_field_autocomplete/i18n/hr.po
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"
35 changes: 35 additions & 0 deletions website_field_autocomplete/i18n/nb_NO.po
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:"
35 changes: 35 additions & 0 deletions website_field_autocomplete/i18n/nl_NL.po
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 ""
Loading