mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
14.0 pms dates wizard (#32)
* [ADD]pms: Filtered dates wizard * [IMP]pms: add filter by checkin partner departure * [IMP]pms: change filters by date to advanced filters * [REF] pms: change of multiple buttons for one button * [REF]pms: dict instead of 'ifs' Co-authored-by: Brais Abeijón <a17braisab@iessanclemente.net>
This commit is contained in:
@@ -66,6 +66,7 @@
|
|||||||
"views/ir_sequence_views.xml",
|
"views/ir_sequence_views.xml",
|
||||||
"wizards/wizard_reservation.xml",
|
"wizards/wizard_reservation.xml",
|
||||||
"wizards/wizard_massive_changes.xml",
|
"wizards/wizard_massive_changes.xml",
|
||||||
|
"wizards/wizard_advanced_filters.xml",
|
||||||
],
|
],
|
||||||
"demo": [
|
"demo": [
|
||||||
"demo/pms_master_data.xml",
|
"demo/pms_master_data.xml",
|
||||||
|
|||||||
@@ -49,3 +49,4 @@ manager_access_availability,manager_access_availability,model_pms_room_type_avai
|
|||||||
manager_access_pms_sale_channel,manager_access_pms_sale_channel,model_pms_sale_channel,pms.group_pms_manager,1,1,1,1
|
manager_access_pms_sale_channel,manager_access_pms_sale_channel,model_pms_sale_channel,pms.group_pms_manager,1,1,1,1
|
||||||
user_access_pms_reservation_wizard,user_access_pms_reservation_wizard,model_pms_reservation_wizard,pms.group_pms_user,1,1,1,1
|
user_access_pms_reservation_wizard,user_access_pms_reservation_wizard,model_pms_reservation_wizard,pms.group_pms_user,1,1,1,1
|
||||||
user_access_pms_massive_changes_wizard,user_access_pms_massive_changes_wizard,model_pms_massive_changes_wizard,pms.group_pms_user,1,1,1,1
|
user_access_pms_massive_changes_wizard,user_access_pms_massive_changes_wizard,model_pms_massive_changes_wizard,pms.group_pms_user,1,1,1,1
|
||||||
|
user_access_pms_advanced_filters_wizard,user_access_pms_advanced_filters_wizard,model_pms_advanced_filters_wizard,pms.group_pms_user,1,1,1,1
|
||||||
|
|||||||
|
@@ -1,2 +1,3 @@
|
|||||||
from . import wizard_reservation
|
from . import wizard_reservation
|
||||||
from . import wizard_massive_changes
|
from . import wizard_massive_changes
|
||||||
|
from . import wizard_advanced_filters
|
||||||
|
|||||||
58
pms/wizards/wizard_advanced_filters.py
Normal file
58
pms/wizards/wizard_advanced_filters.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
from odoo import _, fields, models
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
from odoo.tools.safe_eval import safe_eval
|
||||||
|
|
||||||
|
PMS_BUSINESS_MODELS = [
|
||||||
|
("pms.reservation"),
|
||||||
|
("pms.checkin.partner"),
|
||||||
|
("pms.service.line"),
|
||||||
|
("pms.folio"),
|
||||||
|
("account.move"),
|
||||||
|
("account.payment"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class AdvancedFiltersWizard(models.TransientModel):
|
||||||
|
|
||||||
|
_name = "pms.advanced.filters.wizard"
|
||||||
|
_description = "Wizard for advanced filters"
|
||||||
|
|
||||||
|
pms_model_id = fields.Many2one(
|
||||||
|
"ir.model",
|
||||||
|
string="Recipients Model",
|
||||||
|
ondelete="cascade",
|
||||||
|
required=True,
|
||||||
|
domain=[("model", "in", PMS_BUSINESS_MODELS)],
|
||||||
|
default=lambda self: self.env.ref("pms.model_pms_reservation").id,
|
||||||
|
)
|
||||||
|
pms_model_name = fields.Char(
|
||||||
|
string="Recipients Model Name",
|
||||||
|
related="pms_model_id.model",
|
||||||
|
readonly=True,
|
||||||
|
related_sudo=True,
|
||||||
|
)
|
||||||
|
pms_domain = fields.Char(string="Domain")
|
||||||
|
|
||||||
|
def action_filter(self):
|
||||||
|
self.ensure_one()
|
||||||
|
actions = {
|
||||||
|
"pms.reservation": self.env.ref(
|
||||||
|
"pms.open_pms_reservation_form_tree_all"
|
||||||
|
).read()[0],
|
||||||
|
"pms.checkin.partner": self.env.ref("pms.action_checkin_partner").read()[0],
|
||||||
|
"pms.service.line": self.env.ref("pms.action_service_line").read()[0],
|
||||||
|
"pms.folio": self.env.ref("pms.open_pms_folio1_form_tree_all").read()[0],
|
||||||
|
"account.move": self.env.ref("account.action_move_out_invoice_type").read()[
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"account.payment": self.env.ref("account.action_account_payments").read()[
|
||||||
|
0
|
||||||
|
],
|
||||||
|
}
|
||||||
|
domain = self.pms_domain
|
||||||
|
if domain:
|
||||||
|
domain = safe_eval(self.pms_domain)
|
||||||
|
actions[self.pms_model_name]["domain"] = domain
|
||||||
|
return actions[self.pms_model_name]
|
||||||
|
else:
|
||||||
|
raise UserError(_("You must add filters to perform the search"))
|
||||||
50
pms/wizards/wizard_advanced_filters.xml
Normal file
50
pms/wizards/wizard_advanced_filters.xml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="advanced_filters_wizard" model="ir.ui.view">
|
||||||
|
<field name="name">Filter by dates</field>
|
||||||
|
<field name="model">pms.advanced.filters.wizard</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Advanced filters">
|
||||||
|
<group>
|
||||||
|
<field name="pms_model_id" widget="selection" string="Model" />
|
||||||
|
<field
|
||||||
|
name="pms_domain"
|
||||||
|
widget="domain"
|
||||||
|
string="Filters"
|
||||||
|
options="{'model': 'pms_model_name'}"
|
||||||
|
/>
|
||||||
|
<field name="pms_model_name" invisible="1" />
|
||||||
|
</group>
|
||||||
|
<footer>
|
||||||
|
<button
|
||||||
|
type="object"
|
||||||
|
class="oe_stat_button"
|
||||||
|
id="reservation_button"
|
||||||
|
name="action_filter"
|
||||||
|
string="Search"
|
||||||
|
/>
|
||||||
|
<button string="Cancel" class="oe_link" special="cancel" />
|
||||||
|
</footer>
|
||||||
|
<div>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record id="action_advanced_filters_wizard" model="ir.actions.act_window">
|
||||||
|
<field name="name">Advanced Filters</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">pms.advanced.filters.wizard</field>
|
||||||
|
<field name="view_id" ref="advanced_filters_wizard" />
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
<menuitem
|
||||||
|
id="menu_pms_advanced_filters"
|
||||||
|
name="Advanced Filters"
|
||||||
|
parent="pms.pms_reports_menu"
|
||||||
|
sequence="30"
|
||||||
|
action="action_advanced_filters_wizard"
|
||||||
|
/>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user