-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.0][MIG] pos_event_sale: Migration to 16.0
- Loading branch information
1 parent
ae3ed62
commit 843c094
Showing
41 changed files
with
817 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
from . import event_event | ||
from . import event_mail | ||
from . import event_registration | ||
from . import event_ticket | ||
from . import pos_order | ||
from . import pos_order_line | ||
from . import pos_config | ||
from . import pos_session | ||
from . import res_config_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
############################################################################## | ||
# Copyright (c) 2023 braintec AG (https://braintec.com) | ||
# All Rights Reserved | ||
# | ||
# Licensed under the AGPL-3.0 (http://www.gnu.org/licenses/agpl.html) | ||
# See LICENSE file for full licensing details. | ||
############################################################################## | ||
|
||
from odoo import models | ||
|
||
|
||
class EventMail(models.Model): | ||
_inherit = "event.mail" | ||
|
||
def _create_missing_mail_registrations(self, registrations): | ||
"""Create mail registrations just for those partners with email. | ||
This way we also prevent long delays in the POS, at the time of the order validation. | ||
""" | ||
return super()._create_missing_mail_registrations( | ||
registrations.filtered("email") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
############################################################################## | ||
# Copyright (c) 2023 braintec AG (https://braintec.com) | ||
# All Rights Reserved | ||
# | ||
# Licensed under the AGPL-3.0 (http://www.gnu.org/licenses/agpl.html). | ||
# See LICENSE file for full licensing details. | ||
############################################################################## | ||
|
||
from odoo import api, fields, models | ||
from odoo.tools import date_utils | ||
|
||
|
||
class PosSession(models.Model): | ||
_inherit = "pos.session" | ||
|
||
@api.model | ||
def _pos_ui_models_to_load(self): | ||
models_to_load = super()._pos_ui_models_to_load() | ||
models_to_load.extend( | ||
[ | ||
"event.event", | ||
"event.event.ticket", | ||
"event.tag.category", | ||
"event.tag", | ||
] | ||
) | ||
return models_to_load | ||
|
||
def _get_pos_ui_event_event(self, params): | ||
if self.config_id.iface_event_sale: | ||
return self.env["event.event"].search_read(**params["search_params"]) | ||
return [] | ||
|
||
def _loader_params_event_event(self): | ||
domain = [ | ||
("company_id", "in", (False, self.config_id.company_id[0].id)), | ||
("event_ticket_ids.product_id.active", "=", True), | ||
("event_ticket_ids.available_in_pos", "=", True), | ||
] | ||
|
||
if self.config_id.iface_available_event_stage_ids: | ||
event_stage_ids = self.config_id.iface_available_event_stage_ids | ||
domain.append(("stage_id", "in", event_stage_ids.ids)) | ||
|
||
if self.config_id.iface_available_event_type_ids: | ||
event_type_ids = self.config_id.iface_available_event_type_ids | ||
domain.append(("event_type_id", "in", event_type_ids)) | ||
|
||
if self.config_id.iface_available_event_tag_ids: | ||
event_tag_ids = self.config_id.iface_available_event_tag_ids | ||
domain.append(("tag_ids", "in", event_tag_ids)) | ||
|
||
if self.config_id.iface_event_load_days_before >= 0: | ||
date_end = date_utils.subtract( | ||
fields.Date.today(), self.config_id.iface_event_load_days_before, "days" | ||
) | ||
domain.append(("date_end", ">=", date_end)) | ||
|
||
if self.config_id.iface_event_load_days_after >= 0: | ||
date_start = date_utils.add( | ||
fields.Date.today(), self.config_id.iface_event_load_days_after, "days" | ||
) | ||
domain.append(("date_start", "<=", date_start)) | ||
|
||
fields_list = [ | ||
"name", | ||
"display_name", | ||
"event_type_id", | ||
"tag_ids", | ||
"country_id", | ||
"date_begin", | ||
"date_end", | ||
"date_tz", | ||
"seats_limited", | ||
"seats_available", | ||
] | ||
|
||
return { | ||
"search_params": { | ||
"domain": domain, | ||
"fields": fields_list, | ||
}, | ||
} | ||
|
||
def _get_pos_ui_event_event_ticket(self, params): | ||
if self.config_id.iface_event_sale: | ||
return self.env["event.event.ticket"].search_read(**params["search_params"]) | ||
return [] | ||
|
||
def _loader_params_event_event_ticket(self): | ||
domain = [ | ||
("product_id.active", "=", True), | ||
("available_in_pos", "=", True), | ||
] | ||
|
||
fields_list = [ | ||
"name", | ||
"description", | ||
"event_id", | ||
"product_id", | ||
"price", | ||
"seats_limited", | ||
"seats_available", | ||
] | ||
|
||
return { | ||
"search_params": { | ||
"domain": domain, | ||
"fields": fields_list, | ||
}, | ||
} | ||
|
||
def _get_pos_ui_event_tag_category(self, params): | ||
if self.config_id.iface_event_sale: | ||
return self.env["event.tag.category"].search_read(**params["search_params"]) | ||
return [] | ||
|
||
def _loader_params_event_tag_category(self): | ||
return { | ||
"search_params": { | ||
"domain": [], | ||
"fields": [ | ||
"name", | ||
], | ||
}, | ||
} | ||
|
||
def _get_pos_ui_event_tag(self, params): | ||
if self.config_id.iface_event_sale: | ||
return self.env["event.tag"].search_read(**params["search_params"]) | ||
return [] | ||
|
||
def _loader_params_event_tag(self): | ||
return { | ||
"search_params": { | ||
"domain": [], | ||
"fields": [ | ||
"name", | ||
"category_id", | ||
"color", | ||
], | ||
}, | ||
} | ||
|
||
def _loader_params_product_product(self): | ||
params = super()._loader_params_product_product() | ||
params["search_params"]["fields"].append("detailed_type") | ||
return params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2021 Camptocamp (https://www.camptocamp.com). | ||
# @author Iván Todorovich <ivan.todorovich@camptocamp.com> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
pos_iface_event_sale = fields.Boolean( | ||
related="pos_config_id.iface_event_sale", readonly=False | ||
) | ||
pos_iface_available_event_stage_ids = fields.Many2many( | ||
related="pos_config_id.iface_available_event_stage_ids", readonly=False | ||
) | ||
pos_iface_available_event_type_ids = fields.Many2many( | ||
related="pos_config_id.iface_available_event_type_ids", readonly=False | ||
) | ||
pos_iface_available_event_tag_ids = fields.Many2many( | ||
related="pos_config_id.iface_available_event_tag_ids", readonly=False | ||
) | ||
pos_iface_event_seats_available_warning = fields.Integer( | ||
related="pos_config_id.iface_event_seats_available_warning", readonly=False | ||
) | ||
pos_iface_event_load_days_before = fields.Integer( | ||
related="pos_config_id.iface_event_load_days_before", readonly=False | ||
) | ||
pos_iface_event_load_days_after = fields.Integer( | ||
related="pos_config_id.iface_event_load_days_after", readonly=False | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.