Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python-version: "3.11"
- name: Get python version
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ repos:
- --header
- "# generated from manifests external_dependencies"
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
rev: 5.0.0
hooks:
- id: flake8
name: flake8
additional_dependencies: ["flake8-bugbear==21.9.2"]
additional_dependencies: ["flake8-bugbear==21.9.2", "importlib-metadata<5.0.0"]
- repo: https://github.com/OCA/pylint-odoo
rev: v8.0.19
hooks:
Expand Down
4 changes: 3 additions & 1 deletion pms/models/pms_service_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools import format_date

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -218,6 +219,7 @@ def _compute_auto_qty(self):
@api.constrains("day_qty")
def no_free_resources(self):
for record in self:
record = record.with_context(property=record.pms_property_id.id)
limit = record.product_id.daily_limit
if limit > 0:
out_qty = sum(
Expand All @@ -236,7 +238,7 @@ def no_free_resources(self):
_("%(product_name)s limit exceeded for %(date)s")
% {
"product_name": record.service_id.product_id.name,
"date": record.date,
"date": format_date(self.env, record.date),
}
)

Expand Down
194 changes: 89 additions & 105 deletions pms/views/pms_reservation_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,116 +521,100 @@
<field name="pms_property_id" invisible="1" />
</tree>
</field>
<group
<separator
string="Services"
name="reservation_services"
attrs="{'invisible':[('reservation_type', 'in', ('out'))]}"
/>
<field
name="service_ids"
attrs="{'invisible':[('reservation_type', 'in', ('out'))]}"
context="{'default_reservation_id': active_id, 'default_folio_id': folio_id, 'form_view_ref':'pms.pms_service_view_form'}"
>
<field
name="service_ids"
context="{'default_reservation_id': active_id, 'default_folio_id': folio_id, 'form_view_ref':'pms.pms_service_view_form'}"
nolabel="1"
<!-- If charge this view with tree_view_ref, its !crash! (field not found) when open reservation form from folio form... ¿?-->
<tree
name="Services"
editable="bottom"
decoration-success="is_board_service == True"
>
<!-- If charge this view with tree_view_ref, its !crash! (field not found) when open reservation form from folio form... ¿?-->
<tree
name="Services"
editable="bottom"
decoration-success="is_board_service == True"
<field name="is_board_service" invisible="1" />
<field
name="company_id"
invisible="1"
readonly="1"
/>
<field
name="pms_property_id"
invisible="1"
readonly="1"
/>
<button
title="Open Services"
type="object"
class="oe_stat_button"
icon="fa-1x fa-bed"
name="open_service_ids"
attrs="{'invisible':[('is_board_service','=', False)]}"
/>
<field name="per_day" invisible="1" readonly="1" />
<field name="folio_id" invisible="1" readonly="1" />
<field
name="reservation_id"
invisible="1"
attrs="{'required': [('per_day','=',True)]}"
/>
<field
name="product_id"
domain="[('sale_ok', '=', True)]"
options="{'no_create': True,'no_open': True}"
/>
<field name="name" />
<field
name="product_qty"
attrs="{'readonly': [('per_day','=',True)]}"
force_save="1"
/>
<field name="sale_channel_origin_id" />
<field name="default_invoice_to" optional="hide" />
<button
title="Open Services"
type="object"
class="oe_stat_button"
icon="fa-2x fa-bars"
name="open_service_ids"
attrs="{'invisible': [('per_day','=',False)]}"
/>
<field
name="tax_ids"
widget="many2many_tags"
optional="show"
/>
<field name="board_service_line_id" invisible="1" />
<field name="price_subtotal" optional="hide" />
<field name="price_tax" optional="hide" />
<field name="discount" />
<field name="price_total" />
<field
name="service_line_ids"
invisible="1"
readonly="1"
>
<field name="is_board_service" invisible="1" />
<field
name="company_id"
invisible="1"
readonly="1"
/>
<field
name="pms_property_id"
invisible="1"
readonly="1"
/>
<button
title="Open Services"
type="object"
class="oe_stat_button"
icon="fa-1x fa-bed"
name="open_service_ids"
attrs="{'invisible':[('is_board_service','=', False)]}"
/>
<field
name="per_day"
invisible="1"
readonly="1"
/>
<field
name="folio_id"
invisible="1"
readonly="1"
/>
<field
name="reservation_id"
invisible="1"
attrs="{'required': [('per_day','=',True)]}"
/>
<field
name="product_id"
domain="[('sale_ok', '=', True)]"
options="{'no_create': True,'no_open': True}"
/>
<field name="name" />
<field
name="product_qty"
attrs="{'readonly': [('per_day','=',True)]}"
force_save="1"
/>
<field name="sale_channel_origin_id" />
<field
name="default_invoice_to"
optional="hide"
/>
<button
title="Open Services"
type="object"
class="oe_stat_button"
icon="fa-2x fa-bars"
name="open_service_ids"
attrs="{'invisible': [('per_day','=',False)]}"
/>
<field
name="tax_ids"
widget="many2many_tags"
optional="show"
/>
<field
name="board_service_line_id"
invisible="1"
/>
<field name="price_subtotal" optional="hide" />
<field name="price_tax" optional="hide" />
<field name="discount" />
<field name="price_total" />
<field
name="service_line_ids"
invisible="1"
readonly="1"
>
<tree name="Days">
<field name="date" />
<field name="day_qty" />
<field
name="discount"
attrs="{'readonly':[('is_board_service','=', True)]}"
/>
<field name="price_unit" />
<field name="price_day_total" />
<field
name="is_board_service"
invisible="1"
/>
</tree>
</field>
</tree>
</field>
</group>
<tree name="Days">
<field name="date" />
<field name="day_qty" />
<field
name="discount"
attrs="{'readonly':[('is_board_service','=', True)]}"
/>
<field name="price_unit" />
<field name="price_day_total" />
<field
name="is_board_service"
invisible="1"
/>
</tree>
</field>
</tree>
</field>
<group
class="oe_subtotal_footer oe_right"
name="reservation_total"
Expand Down
22 changes: 21 additions & 1 deletion pms_api_rest/services/pms_extra_bed_service.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from odoo import _
from odoo.exceptions import ValidationError

from odoo.addons.base_rest import restapi
from odoo.addons.base_rest_datamodel.restapi import Datamodel
from odoo.addons.component.core import Component
Expand Down Expand Up @@ -28,6 +31,7 @@ def get_extra_beds(self, extra_beds_search_param):
domain = [("is_extra_bed", "=", True)]
if extra_beds_search_param.name:
domain.append(("name", "like", extra_beds_search_param.name))
property_obj = None
if extra_beds_search_param.pmsPropertyId:
domain.extend(
[
Expand All @@ -36,10 +40,26 @@ def get_extra_beds(self, extra_beds_search_param):
("pms_property_ids", "=", False),
]
)
property_obj = (
self.env["pms.property"]
.sudo()
.search([("id", "=", extra_beds_search_param.pmsPropertyId)])
)
if not property_obj:
raise ValidationError(
_(
"Property not found or not specified. Please provide a valid property ID."
)
)

result_extra_beds = []
PmsExtraBed = self.env.datamodels["pms.extra.bed.info"]
beds = self.env["product.product"].sudo().search(domain)
beds = (
self.env["product.product"]
.sudo()
.with_context(property=property.id)
.search(domain)
)
pms_api_check_access(user=self.env.user, records=beds)
for bed in beds:
avail = -1
Expand Down
4 changes: 2 additions & 2 deletions pms_api_rest/views/product_template_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='company_id']" position="after">
<field name="currency_id" position="before">
<field name="channel_available" />
</xpath>
</field>
</field>
</record>

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
bs4
geopy
jose
jwt
pyjwt
marshmallow
pycountry
simplejson
Expand Down
Loading