mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] Clean special caracters in names (Not ñ)
This commit is contained in:
committed by
Dario Lodeiros
parent
4131edb896
commit
8a314bb002
@@ -24,7 +24,7 @@ from odoo import models, fields, api
|
|||||||
import base64
|
import base64
|
||||||
import datetime
|
import datetime
|
||||||
from odoo.tools.translate import _
|
from odoo.tools.translate import _
|
||||||
|
import unidecode
|
||||||
|
|
||||||
|
|
||||||
class PoliceWizard(models.TransientModel):
|
class PoliceWizard(models.TransientModel):
|
||||||
@@ -41,8 +41,10 @@ class PoliceWizard(models.TransientModel):
|
|||||||
def generate_file(self):
|
def generate_file(self):
|
||||||
company = self.env.user.company_id
|
company = self.env.user.company_id
|
||||||
if company.police_number is not False and company.property_name is not False:
|
if company.police_number is not False and company.property_name is not False:
|
||||||
lines = self.env['hotel.checkin.partner'].search([('enter_date', '=',
|
lines = self.env['hotel.checkin.partner'].search(
|
||||||
self.download_date)])
|
[('enter_date',
|
||||||
|
'=',
|
||||||
|
self.download_date)])
|
||||||
content = "1|"+company.police_number+"|"+company.property_name.upper()[0:40]
|
content = "1|"+company.police_number+"|"+company.property_name.upper()[0:40]
|
||||||
content += "|"
|
content += "|"
|
||||||
content += datetime.datetime.now().strftime("%Y%m%d|%H%M")
|
content += datetime.datetime.now().strftime("%Y%m%d|%H%M")
|
||||||
@@ -65,7 +67,13 @@ class PoliceWizard(models.TransientModel):
|
|||||||
content += datetime.datetime.strptime(
|
content += datetime.datetime.strptime(
|
||||||
line.partner_id.document_expedition_date,
|
line.partner_id.document_expedition_date,
|
||||||
"%Y-%m-%d").date().strftime("%Y%m%d") + "|"
|
"%Y-%m-%d").date().strftime("%Y%m%d") + "|"
|
||||||
|
firstname = line.partner_id.firstname
|
||||||
|
if 'ñ' not in firstname and 'Ñ' not in firstname:
|
||||||
|
firstname = unidecode.unidecode(firstname)
|
||||||
lastname = line.partner_id.lastname.split()
|
lastname = line.partner_id.lastname.split()
|
||||||
|
for i, string in enumerate(lastname):
|
||||||
|
if 'ñ' not in string and 'Ñ' not in string:
|
||||||
|
lastname[i] = unidecode.unidecode(string)
|
||||||
if len(lastname) >= 2:
|
if len(lastname) >= 2:
|
||||||
content += lastname[0].upper() + "|"
|
content += lastname[0].upper() + "|"
|
||||||
lastname.pop(0)
|
lastname.pop(0)
|
||||||
@@ -75,7 +83,7 @@ class PoliceWizard(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
content += lastname[0].upper() + "|"
|
content += lastname[0].upper() + "|"
|
||||||
content += "|"
|
content += "|"
|
||||||
content += line.partner_id.firstname.upper() + "|"
|
content += firstname.upper() + "|"
|
||||||
content += line.partner_id.gender.upper()[0] + "|"
|
content += line.partner_id.gender.upper()[0] + "|"
|
||||||
content += datetime.datetime.strptime(
|
content += datetime.datetime.strptime(
|
||||||
line.partner_id.birthdate_date,
|
line.partner_id.birthdate_date,
|
||||||
@@ -96,7 +104,6 @@ class PoliceWizard(models.TransientModel):
|
|||||||
Checkin without data, \
|
Checkin without data, \
|
||||||
or incorrect data: - ' +
|
or incorrect data: - ' +
|
||||||
line.partner_id.name)})
|
line.partner_id.name)})
|
||||||
|
|
||||||
return self.write({
|
return self.write({
|
||||||
'txt_filename': company.police_number + '.' + self.download_num,
|
'txt_filename': company.police_number + '.' + self.download_num,
|
||||||
'txt_message': _(
|
'txt_message': _(
|
||||||
|
|||||||
Reference in New Issue
Block a user