Skip to content
Open
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 stay/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{
"name": "Stay",
"version": "14.0.5.1.0",
"version": "14.0.5.1.1",
"category": "Lodging",
"license": "AGPL-3",
"summary": "Simple management of stays and meals",
Expand Down
14 changes: 14 additions & 0 deletions stay/migrations/14.0.5.1.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2025 Akretion France (https://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


def migrate(cr, version):
if not version:
return

cr.execute(
"""
ALTER TABLE IF EXISTS res_company_res_users_rel RENAME TO stay_notify_company_user_rel
"""
)
9 changes: 8 additions & 1 deletion stay/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ class ResCompany(models.Model):
ondelete="restrict",
check_company=True,
)
# Warning: explicit definition of the relation table is needed here
# because many modules have a M2M fields from res.company to res.users
# and we must avoid a table name collision
stay_notify_user_ids = fields.Many2many(
"res.users", string="Users Notified by E-mail for Stays without Group"
"res.users",
relation="stay_notify_company_user_rel",
column1="res_company_id",
column2="res_users_id",
string="Users Notified by E-mail for Stays without Group",
)
3 changes: 2 additions & 1 deletion stay/models/stay.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,8 @@ class StayRoomAssign(models.Model):
notes = fields.Text(related="stay_id.notes", store=True, readonly=False)
partner_id = fields.Many2one(related="stay_id.partner_id", store=True)
partner_name = fields.Text(related="stay_id.partner_name", store=True)
company_id = fields.Many2one(related="stay_id.company_id", store=True)
company_id = fields.Many2one(related="stay_id.company_id", store=True, index=True)
construction = fields.Boolean(related="stay_id.construction", store=True)
# for filter
my_stay_group = fields.Boolean(
compute="_compute_my_stay_group", search="_search_my_stay_group"
Expand Down
1 change: 1 addition & 0 deletions stay/wizard/stay_fire_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def _report_fire_data(self):
("arrival_date", "<=", self.date),
("departure_date", ">", self.date),
("room_id", "=", room.id),
("construction", "=", False),
]
)
guest_qty = sum([assign.guest_qty for assign in assigns])
Expand Down
6 changes: 1 addition & 5 deletions stay_api/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

========
Stay API
========
Expand All @@ -17,7 +13,7 @@ Stay API
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fvertical--abbey-lightgray.png?logo=github
Expand Down
4 changes: 1 addition & 3 deletions stay_api/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
"author": "Akretion, Odoo Community Association (OCA)",
"maintainers": ["alexis-via"],
"website": "https://github.com/OCA/vertical-abbey",
"depends": ["stay", "fastapi", "phone_validation"],
"depends": ["stay", "fastapi", "partner_match_or_create"],
"external_dependencies": {"python": ["fastapi", "pydantic<2"]},
"data": [
"data/res_users.xml",
"security/ir.model.access.csv",
"wizards/stay_create_partner_view.xml",
"wizards/res_config_settings_view.xml",
"views/stay_stay.xml",
"views/stay_type.xml",
"views/res_partner_title.xml",
"data/mail_template.xml",
],
"post_init_hook": "stay_api_postinstall",
Expand Down
1 change: 0 additions & 1 deletion stay_api/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from . import fastapi_endpoint
from . import stay_stay
from . import stay_type
from . import res_partner_title
19 changes: 0 additions & 19 deletions stay_api/models/res_partner_title.py

This file was deleted.

70 changes: 7 additions & 63 deletions stay_api/models/stay_stay.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class StayStay(models.Model):
controller_lastname = fields.Char(tracking=True, string="Lastname")
controller_title_id = fields.Many2one(
"res.partner.title",
domain=[("stay_code", "!=", False)],
domain=[("api_code", "!=", False)],
string="Title",
tracking=True,
)
Expand Down Expand Up @@ -205,16 +205,16 @@ def _controller_prepare_create_update(self, cobject, try_match_partner=True):
title_id = False
if title_code:
title = self.env["res.partner.title"].search(
[("stay_code", "=", title_code)], limit=1
[("api_code", "=", title_code)], limit=1
)
if title:
title_id = title.id
partner_name = f"{title.shortcut or title.name} {partner_name}"
else:
avail_title_read = self.env["res.partner.title"].search_read(
[("stay_code", "!=", False)], ["stay_code"]
[("api_code", "!=", False)], ["api_code"]
)
avail_title_list = [x["stay_code"] for x in avail_title_read]
avail_title_list = [x["api_code"] for x in avail_title_read]
error_msg = (
f"Wrong title: {title_code}. "
f"Possible values: {', '.join(avail_title_list)}."
Expand Down Expand Up @@ -284,63 +284,7 @@ def _controller_prepare_create_update(self, cobject, try_match_partner=True):
"controller_notes": "<br>".join(notes_list),
}
if try_match_partner:
vals["partner_id"] = self._controller_try_match_partner(vals)
return vals

def _controller_try_match_partner(self, vals):
email = vals["controller_email"]
mobile = vals["controller_mobile"]
partner_id = None
if "res.partner.phone" in self.env: # module base_partner_one2many_phone
partner_phone = (
self.env["res.partner.phone"]
.sudo()
.search_read(
[
("type", "in", ("1_email_primary", "2_email_secondary")),
("email", "=ilike", email),
("partner_id", "!=", False),
],
["partner_id"],
limit=1,
)
vals["partner_id"] = self.env["res.partner"]._controller_try_match_partner(
vals
)
if partner_phone:
partner_id = partner_phone[0]["partner_id"][0]
else:
partner = self.env["res.partner"].search_read(
[("email", "=ilike", email)], ["id"], limit=1
)
if partner:
partner_id = partner[0]["id"]
if partner_id:
logger.info("Match on email %s with partner ID %d", email, partner_id)
# 'and vals['controller_country_id'] to make sure the mobile phone has been reformatted
if not partner_id and mobile and vals["controller_country_id"]:
if "res.partner.phone" in self.env: # module base_partner_one2many_phone
partner_phone = (
self.env["res.partner.phone"]
.sudo()
.search_read(
[
("type", "in", ("5_mobile_primary", "6_mobile_secondary")),
("phone", "=", mobile),
("partner_id", "!=", False),
],
["partner_id"],
limit=1,
)
)
if partner_phone:
partner_id = partner_phone[0]["partner_id"][0]
else:
partner = self.env["res.partner"].search_read(
[("mobile", "=", mobile)], ["id"], limit=1
)
if partner:
partner_id = partner[0]["id"]
if partner_id:
logger.info("Match on mobile %s with partner ID %d", mobile, partner_id)
if not partner_id:
logger.info("No match on an existing partner")
return partner_id
return vals
28 changes: 0 additions & 28 deletions stay_api/post_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,3 @@ def stay_api_postinstall(cr, registry):
for stay in stays:
stay.write({"controller_uuid": str(uuid4())})
logger.info("%d stays updated with uuid", len(stays))
# also set stay_code on res.partner.title
model_datas = env["ir.model.data"].search(
[
("module", "=", "base"),
("model", "=", "res.partner.title"),
("res_id", "!=", False),
("name", "!=", False),
]
)
unique_code = set()
for model_data in model_datas:
stay_code = model_data.name.split("_")[-1]
if stay_code in unique_code:
logger.warning(
"Skipping XMLID %s.%s because the suffix is not unique",
model_data.module,
model_data.name,
)
continue
unique_code.add(stay_code)
title = env["res.partner.title"].browse(model_data.res_id)
title.write({"stay_code": stay_code})
logger.info(
"Wrote stay_code=%s on title %s ID %d",
stay_code,
title.display_name,
title.id,
)
4 changes: 2 additions & 2 deletions stay_api/routers/stay.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ def stay_read(
"lastname": stay.partner_id.lastname,
}
)
if stay.partner_id.title and stay.partner_id.title.stay_code:
vals["title"] = stay.partner_id.title.stay_code
if stay.partner_id.title and stay.partner_id.title.api_code:
vals["title"] = stay.partner_id.title.api_code
logger.info("Stay controller /read answer: %s", vals)
return StayRead(**vals)

Expand Down
1 change: 0 additions & 1 deletion stay_api/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_stay_create_partner,Full access on stay.create.partner wizard,model_stay_create_partner,stay.group_stay_user,1,1,1,1
access_stay_type_read,Read access on stay.type,model_stay_type,stay.group_stay_viewer,1,0,0,0
access_stay_type_full,Full access on stay.type,model_stay_type,stay.group_stay_manager,1,1,1,1
26 changes: 10 additions & 16 deletions stay_api/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Stay API</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="stay-api">
<h1 class="title">Stay API</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="stay-api">
<h1>Stay API</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:66e4bebfd014c37dc188d60c737c5576698c8a89942c4c0fe05f1752dc1a325b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/vertical-abbey/tree/14.0/stay_api"><img alt="OCA/vertical-abbey" src="https://img.shields.io/badge/github-OCA%2Fvertical--abbey-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/vertical-abbey-14-0/vertical-abbey-14-0-stay_api"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/vertical-abbey&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/vertical-abbey/tree/14.0/stay_api"><img alt="OCA/vertical-abbey" src="https://img.shields.io/badge/github-OCA%2Fvertical--abbey-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/vertical-abbey-14-0/vertical-abbey-14-0-stay_api"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/vertical-abbey&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module provides a REST API to create new stays. Useful if you have
a web form on your website and you want it to create a new draft stay
upon validation.</p>
Expand All @@ -392,34 +387,34 @@ <h1>Stay API</h1>
</ul>
</div>
<div class="section" id="installation">
<h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
<p>This module depends on the OCA module <strong>fastapi</strong> from
<a class="reference external" href="https://github.com/OCA/rest-framework">rest-framework</a>.</p>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/vertical-abbey/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/vertical-abbey/issues/new?body=module:%20stay_api%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple">
<li>Akretion</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -434,6 +429,5 @@ <h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
40 changes: 0 additions & 40 deletions stay_api/views/res_partner_title.xml

This file was deleted.

2 changes: 1 addition & 1 deletion stay_api/views/stay_stay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<field name="arch" type="xml">
<button name="draft2confirm" position="before">
<button
name="%(stay_create_partner_action)d"
name="%(partner_match_or_create.partner_match_or_create_action)d"
type="action"
string="Set Partner from Web Form Infos"
attrs="{'invisible': ['|', ('partner_id', '!=', False), ('controller_mode', '=', False)]}"
Expand Down
1 change: 0 additions & 1 deletion stay_api/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import stay_create_partner
from . import res_config_settings
Loading