mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] l10n_es
This commit is contained in:
@@ -15,3 +15,10 @@ class ResCompany(models.Model):
|
||||
calculated.")
|
||||
default_cancel_policy_days = fields.Integer('Cancelation Days')
|
||||
default_cancel_policy_percent = fields.Integer('Percent to pay')
|
||||
cardex_warning = fields.Text(
|
||||
'Warning in Cardex',
|
||||
default="Time to access rooms: 14: 00h. Departure time: \
|
||||
12: 00h. If the accommodation is not left at that time, \
|
||||
the establishment will charge a day's stay according to \
|
||||
current rate that day",
|
||||
help="Notice under the signature on the traveler's ticket.")
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# Copyright 2017 Alexandre Díaz
|
||||
# Copyright 2017 Dario Lodeiros
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from openerp import models, fields
|
||||
from openerp import models, fields, api
|
||||
from odoo.osv.expression import get_unaccent_wrapper
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
@@ -22,3 +23,49 @@ class ResPartner(models.Model):
|
||||
|
||||
reservations_count = fields.Integer('Reservations', compute='_compute_reservations_count')
|
||||
folios_count = fields.Integer('Folios', compute='_compute_folios_count')
|
||||
|
||||
@api.model
|
||||
def name_search(self, name, args=None, operator='ilike', limit=100):
|
||||
result = super(ResPartner, self).name_search(name, args=None,
|
||||
operator='ilike',
|
||||
limit=100)
|
||||
if args is None:
|
||||
args = []
|
||||
if name and operator in ('=', 'ilike', '=ilike', 'like', '=like'):
|
||||
self.check_access_rights('read')
|
||||
where_query = self._where_calc(args)
|
||||
self._apply_ir_rules(where_query, 'read')
|
||||
from_clause, where_clause, where_clause_params = where_query.get_sql()
|
||||
where_str = where_clause and (" WHERE %s AND " % where_clause) or ' WHERE '
|
||||
|
||||
# search on the name of the contacts and of its company
|
||||
search_name = name
|
||||
if operator in ('ilike', 'like'):
|
||||
search_name = '%%%s%%' % name
|
||||
if operator in ('=ilike', '=like'):
|
||||
operator = operator[1:]
|
||||
|
||||
unaccent = get_unaccent_wrapper(self.env.cr)
|
||||
|
||||
query = """SELECT id
|
||||
FROM res_partner
|
||||
{where} ({phone} {operator} {percent}
|
||||
OR {mobile} {operator} {percent})
|
||||
ORDER BY {display_name} {operator} {percent} desc,
|
||||
{display_name}
|
||||
""".format(where=where_str,
|
||||
operator=operator,
|
||||
phone=unaccent('phone'),
|
||||
display_name=unaccent('display_name'),
|
||||
mobile=unaccent('mobile'),
|
||||
percent=unaccent('%s'),)
|
||||
|
||||
where_clause_params += [search_name]*3
|
||||
if limit:
|
||||
query += ' limit %s'
|
||||
where_clause_params.append(limit)
|
||||
self.env.cr.execute(query, where_clause_params)
|
||||
partner_ids = [row[0] for row in self.env.cr.fetchall()]
|
||||
if partner_ids:
|
||||
result += self.browse(partner_ids).name_get()
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user