Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How to implement a search in website - Odoo 13

Odebírat

Get notified when there's activity on this post

This question has been flagged
pythonodoo
1 Odpovědět
11252 Zobrazení
Avatar
Mariem.J

Hi ,

I have a list of studiants in website , I want to add a search bar to search name ,age,...
How to make it ?

Thanks.

0
Avatar
Zrušit
Avatar
Prakash
Nejlepší odpověď
Odoo default "portal_searchbar" template using search records in website.

Call the template in XML and Controllers return search and search_in parameter corresponding value based on your requirements.

sortby, filterby, groupby is extra features based on complex data can add, if required.

Example default core module.

<template id="portal_my_timesheets" name="My Timesheets">
<t t-call="portal.portal_layout">
<t t-set="breadcrumbs_searchbar" t-value="True"/>

<t t-call="portal.portal_searchbar">
<t t-set="title">Timesheets</t>
</t>
<t t-if="not grouped_timesheets">
<div class="alert alert-warning mt8" role="alert">
There are no timesheets.
</div>
</t>
<t t-if="grouped_timesheets">
<t t-call="portal.portal_table">
<t t-foreach="grouped_timesheets" t-as="timesheets">
<thead>
<tr t-attf-class="{{'thead-light' if not groupby == 'none' else ''}}">
<th t-if="groupby == 'none'">Description</th>
<th t-else="">
<em class="font-weight-normal text-muted">Timesheets for project:</em>
<span t-field="timesheets[0].project_id.name"/></th>
<th>Date</th>
<th>Employee</th>
<th class="text-right">Duration</th>
</tr>
</thead>
<tbody>
<t t-foreach="timesheets" t-as="timesheet">
<tr>
<td><span t-esc="timesheet.name"/></td>
<td><span t-field="timesheet.date" t-options='{"widget": "date"}'/></td>
<td><span t-field="timesheet.employee_id"/></td>
<td class="text-right"><span t-field="timesheet.unit_amount" t-options='{"widget": "duration", "unit": "hour", "round": "minute"}'/></td>
</tr>
</t>
</tbody>
</t>
</t>
</t>
</t>
</template>



@http.route(['/my/timesheets', '/my/timesheets/page/<int:page>'], type='http', auth="user", website=True)
def portal_my_timesheets(self, page=1, sortby=None, filterby=None, search=None, search_in='all', groupby='project', **kw):
Timesheet_sudo = request.env['account.analytic.line'].sudo()
values = self._prepare_portal_layout_values()
domain = request.env['account.analytic.line']._timesheet_get_portal_domain()

searchbar_sortings = {
'date': {'label': _('Newest'), 'order': 'date desc'},
'name': {'label': _('Name'), 'order': 'name'},
}

searchbar_inputs = {
'all': {'input': 'all', 'label': _('Search in All')},
}

searchbar_groupby = {
'none': {'input': 'none', 'label': _('None')},
'project': {'input': 'project', 'label': _('Project')},
}

today = fields.Date.today()
quarter_start, quarter_end = date_utils.get_quarter(today)
last_week = today + relativedelta(weeks=-1)
last_month = today + relativedelta(months=-1)
last_year = today + relativedelta(years=-1)

searchbar_filters = {
'all': {'label': _('All'), 'domain': []},
'today': {'label': _('Today'), 'domain': [("date", "=", today)]},

}
# default sort by value
if not sortby:
sortby = 'date'
order = searchbar_sortings[sortby]['order']
# default filter by value
if not filterby:
filterby = 'all'
domain = AND([domain, searchbar_filters[filterby]['domain']])

if search and search_in:
domain = AND([domain, [('name', 'ilike', search)]])

timesheet_count = Timesheet_sudo.search_count(domain)
# pager
pager = portal_pager(
url="/my/timesheets",
url_args={'sortby': sortby, 'search_in': search_in, 'search': search, 'filterby': filterby},
total=timesheet_count,
page=page,
step=self._items_per_page
)

if groupby == 'project':
order = "project_id, %s" % order
timesheets = Timesheet_sudo.search(domain, order=order, limit=self._items_per_page, offset=pager['offset'])
if groupby == 'project':
grouped_timesheets = [Timesheet_sudo.concat(*g) for k, g in groupbyelem(timesheets, itemgetter('project_id'))]
else:
grouped_timesheets = [timesheets]

values.update({
'timesheets': timesheets,
'grouped_timesheets': grouped_timesheets,
'page_name': 'timesheet',
'default_url': '/my/timesheets',
'pager': pager,
'searchbar_sortings': searchbar_sortings,
'search_in': search_in,
'sortby': sortby,
'groupby': groupby,
'searchbar_inputs': searchbar_inputs,
'searchbar_groupby': searchbar_groupby,
'searchbar_filters': OrderedDict(sorted(searchbar_filters.items())),
'filterby': filterby,
})
return request.render("hr_timesheet.portal_my_timesheets", values)
4
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Save filtered tree view to load as it is at another time Vyřešeno
python odoo
Avatar
Avatar
Avatar
2
srp 25
3414
Private functions and public functions in odoo python Vyřešeno
python odoo
Avatar
Avatar
Avatar
Avatar
3
úno 25
4834
odoo ghost module
python odoo
Avatar
0
kvě 24
46
Call python method from inherit_id attribute
python odoo
Avatar
Avatar
1
dub 24
4197
how Restrict users to see only his own invoice ?
python odoo
Avatar
Avatar
Avatar
Avatar
Avatar
4
zář 23
6146
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now