[FIX] pms-api-rest: fix precommit

This commit is contained in:
miguelpadin
2022-09-16 11:02:05 +02:00
committed by Darío Lodeiros
parent 5675e96b05
commit 713f425c22
3 changed files with 36 additions and 21 deletions

View File

@@ -1,6 +1,7 @@
from datetime import datetime, timedelta
from odoo import _, fields
from odoo.exceptions import MissingError
from datetime import datetime, timedelta
from odoo.addons.base_rest import restapi
from odoo.addons.base_rest_datamodel.restapi import Datamodel
@@ -29,15 +30,24 @@ class PmsAgencyService(Component):
def get_prices(self, prices_search_param):
product = room_type = board_service = False
if prices_search_param.roomTypeId:
room_type = self.env["pms.room.type"].search([("id", "=", prices_search_param.roomTypeId)])
room_type = self.env["pms.room.type"].search(
[("id", "=", prices_search_param.roomTypeId)]
)
if prices_search_param.productId:
product = self.env["product.product"].search([("id", "=", prices_search_param.productId)])
product = self.env["product.product"].search(
[("id", "=", prices_search_param.productId)]
)
if prices_search_param.boardServiceId:
board_service = self.env["pms.board.service.room.type"].search([
("id", "=", prices_search_param.boardServiceId)]
board_service = self.env["pms.board.service.room.type"].search(
[("id", "=", prices_search_param.boardServiceId)]
)
if sum([var is not False for var in [product, room_type, board_service]]) != 1:
raise MissingError(_("It is necessary to indicate one and only one product, board service or room type"))
raise MissingError(
_(
"It is necessary to indicate one and only one product,"
" board service or room type"
)
)
PmsPriceInfo = self.env.datamodels["pms.price.info"]
result_prices = []
@@ -61,8 +71,9 @@ class PmsAgencyService(Component):
pricelist_id=prices_search_param.pricelistId,
partner_id=prices_search_param.partnerId,
product_qty=prices_search_param.productQty,
date_consumption=price_date
), 2
date_consumption=price_date,
),
2,
),
)
)
@@ -79,8 +90,9 @@ class PmsAgencyService(Component):
pricelist_id=prices_search_param.pricelistId,
partner_id=prices_search_param.partnerId,
product_qty=prices_search_param.productQty,
date_consumption=price_date
), 2
date_consumption=price_date,
),
2,
),
)
)
@@ -96,9 +108,7 @@ class PmsAgencyService(Component):
date_consumption=False,
board_service_id=False,
):
pms_property = self.env["pms.property"].browse(
pms_property_id
)
pms_property = self.env["pms.property"].browse(pms_property_id)
product_context = dict(
self.env.context,
date=datetime.today().date(),

View File

@@ -59,7 +59,9 @@ class PmsSaleChannelService(Component):
PmsSaleChannelInfo(
id=sale_channel.id,
name=sale_channel.name if sale_channel.name else None,
channelType=sale_channel.channel_type if sale_channel.channel_type else None,
channelType=sale_channel.channel_type
if sale_channel.channel_type
else None,
)
)
return result_sale_channels

View File

@@ -27,16 +27,16 @@ class PmsServiceLineService(Component):
auth="jwt_api_pms",
)
def get_service_line(self, service_line_id):
service_line = self.env["pms.service.line"].search([("id", "=", service_line_id)])
service_line = self.env["pms.service.line"].search(
[("id", "=", service_line_id)]
)
if not service_line:
raise MissingError(_("Service line not found"))
PmsServiceLineInfo = self.env.datamodels["pms.service.line.info"]
return PmsServiceLineInfo(
id=service_line.id,
date=datetime.combine(
service_line.date, datetime.min.time()
).isoformat(),
date=datetime.combine(service_line.date, datetime.min.time()).isoformat(),
priceUnit=round(service_line.price_unit, 2),
discount=round(service_line.discount, 2),
quantity=service_line.day_qty,
@@ -55,7 +55,9 @@ class PmsServiceLineService(Component):
auth="jwt_api_pms",
)
def update_service_line(self, service_line_id, pms_service_line_info_data):
service_line = self.env["pms.service.line"].search([("id", "=", service_line_id)])
service_line = self.env["pms.service.line"].search(
[("id", "=", service_line_id)]
)
vals = {}
if service_line:
if pms_service_line_info_data.date:
@@ -85,9 +87,10 @@ class PmsServiceLineService(Component):
)
def delete_service_line(self, service_line_id):
# esto tb podría ser con un browse
service_line = self.env["pms.service.line"].search([("id", "=", service_line_id)])
service_line = self.env["pms.service.line"].search(
[("id", "=", service_line_id)]
)
if service_line:
service_line.unlink()
else:
raise MissingError(_("Service line not found"))