[FIX] pms: fix precommit

This commit is contained in:
miguelpadin
2021-05-25 11:23:58 +02:00
parent 9d1d2c5638
commit e8f10126ad
5 changed files with 42 additions and 36 deletions

View File

@@ -18,6 +18,11 @@
"partner_contact_nationality",
"queue_job",
],
"external_dependencies": {
"python": [
"bs4",
],
},
"data": [
"data/cron_jobs.xml",
"data/queue_data.xml",

View File

@@ -1,4 +1,4 @@
from odoo import api, fields, models
from odoo import fields, models
class PmsProperty(models.Model):

View File

@@ -1,8 +1,8 @@
import base64
import datetime
import os
from datetime import date
import os
import requests
from bs4 import BeautifulSoup as bs
@@ -16,12 +16,8 @@ class TravellerReport(models.TransientModel):
_description = "Traveller Report"
txt_filename = fields.Text()
txt_binary = fields.Binary(
string="File Download"
)
txt_message = fields.Char(
string="File Preview"
)
txt_binary = fields.Binary(string="File Download")
txt_message = fields.Char(string="File Preview")
def generate_file(self):
@@ -36,14 +32,13 @@ class TravellerReport(models.TransientModel):
# file creation
txt_binary = self.env["traveller.report.wizard"].create(
{
"txt_filename": pms_property.institution_property_id
+ ".999",
"txt_filename": pms_property.institution_property_id + ".999",
"txt_binary": base64.b64encode(str.encode(content)),
"txt_message": content,
}
)
return {
"name": _("Preview & Send File"),
"name": _("Traveller Report"),
"res_id": txt_binary.id,
"res_model": "traveller.report.wizard",
"target": "new",
@@ -148,8 +143,8 @@ class TravellerReport(models.TransientModel):
headers = {
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 "
"Build/MRA58N) AppleWebKit/537.36 (KHTML, like "
"Gecko) Chrome/90.0.4430.93 Mobile Safari/537.36",
"Build/MRA58N) AppleWebKit/537.36 (KHTML, like "
"Gecko) Chrome/90.0.4430.93 Mobile Safari/537.36",
}
s = requests.session()
login_payload = {
@@ -161,7 +156,7 @@ class TravellerReport(models.TransientModel):
headers=headers,
data=login_payload,
verify=get_module_resource("pms_l10n_es", "static", "cert.pem"),
)
)
pwd = get_module_resource("pms_l10n_es", "wizards", "")
checkin_list_file = open(pwd + pms_property.institution_user + ".999", "w+")
@@ -174,7 +169,7 @@ class TravellerReport(models.TransientModel):
data={"autoSeq": "on"},
files=files,
verify=get_module_resource("pms_l10n_es", "static", "cert.pem"),
)
)
os.remove(pwd + pms_property.institution_user + ".999")
s.close()
@@ -185,13 +180,13 @@ class TravellerReport(models.TransientModel):
else:
if called_from_user:
message = {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _('Sent succesfully!'),
'message': _('Successful file sending'),
'sticky': False,
}
"type": "ir.actions.client",
"tag": "display_notification",
"params": {
"title": _("Sent succesfully!"),
"message": _("Successful file sending"),
"sticky": False,
},
}
return message

View File

@@ -7,12 +7,17 @@
<form>
<field name="txt_filename" invisible="1" />
<div class="row">
<div class="col-12"
<div
class="col-12"
attrs="{'invisible': [('txt_message','=',False)]}"
>
<group>
<field name="txt_message" readonly="1" />
<field name="txt_binary" filename="txt_filename" readonly="1"/>
<field
name="txt_binary"
filename="txt_filename"
readonly="1"
/>
</group>
</div>
@@ -20,22 +25,22 @@
<div class="row ">
<div class="col-3">
<button
name="generate_file"
class="btn btn-primary btn-sm"
type="object"
string="Preview file"
/>
name="generate_file"
class="btn btn-primary btn-sm"
type="object"
string="Preview file"
/>
</div>
<div class="col-3">
<button
name="send_file_gc"
class="btn btn-primary btn-sm"
type="object"
string="Send file"
/>
name="send_file_gc"
class="btn btn-primary btn-sm"
type="object"
string="Send file"
/>
</div>
</div>
<footer/>
<footer />
</form>
</field>
</record>
@@ -49,7 +54,7 @@
</record>
<menuitem
id="menu_traveller_report"
name="Police File Download"
name="Traveller Report"
sequence="30"
parent="pms.pms_configuration_menu"
action="action_traveller_report"

View File

@@ -1,2 +1,3 @@
# generated from manifests external_dependencies
bs4
xlrd