mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] buttons for channel management
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models, fields
|
||||
from odoo import api, models, fields, _
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.addons.queue_job.job import job
|
||||
from odoo.addons.component.core import Component
|
||||
from odoo.addons.component_event import skip_if
|
||||
@@ -78,6 +79,31 @@ class HotelRoomTypeRestriction(models.Model):
|
||||
names.append((name[0], name[1]))
|
||||
return names
|
||||
|
||||
@api.multi
|
||||
def open_channel_bind_ids(self):
|
||||
channel_bind_ids = self.mapped('channel_bind_ids')
|
||||
action = self.env.ref('hotel_channel_connector.channel_hotel_room_type_restriction_action').read()[0]
|
||||
action['views'] = [(self.env.ref('hotel_channel_connector.channel_hotel_room_type_restriction_view_form').id, 'form')]
|
||||
action['target'] = 'new'
|
||||
if len(channel_bind_ids) == 1:
|
||||
action['res_id'] = channel_bind_ids.ids[0]
|
||||
elif len(channel_bind_ids) > 1:
|
||||
# WARNING: more than one binding is currently not expected
|
||||
action['domain'] = [('id', 'in', channel_bind_ids.ids)]
|
||||
else:
|
||||
action['context'] = {
|
||||
'default_odoo_id': self.id,
|
||||
'default_name': self.name,
|
||||
}
|
||||
return action
|
||||
|
||||
@api.multi
|
||||
def disconnect_channel_bind_ids(self):
|
||||
channel_bind_ids = self.mapped('channel_bind_ids')
|
||||
msg = _("This function is not yet implemented.")
|
||||
msg += _(" The room type [%s] should be delete from the channel manager.") % channel_bind_ids.get_external_id
|
||||
raise UserError(msg)
|
||||
|
||||
class BindingHotelRoomTypeListener(Component):
|
||||
_name = 'binding.hotel.room.type.restriction.listener'
|
||||
_inherit = 'base.connector.listener'
|
||||
|
||||
@@ -27,4 +27,13 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="channel_hotel_room_type_restriction_action" model="ir.actions.act_window">
|
||||
<field name="name">Hotel Channel Connector Bindings</field>
|
||||
<field name="res_model">channel.hotel.room.type.restriction</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[]</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<field name="name">channel.hotel.room.type.form</field>
|
||||
<field name="model">channel.hotel.room.type</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Hotel Channel Virtual Room">
|
||||
<form string="Hotel Channel Room Type">
|
||||
<group>
|
||||
<field name="id" invisible="1" />
|
||||
<field name="backend_id" attrs="{'visible': [('id','=', False)], 'readonly': [('id','!=', False)]}" />
|
||||
|
||||
@@ -5,19 +5,22 @@
|
||||
<field name="model">hotel.room.type.restriction</field>
|
||||
<field name="inherit_id" ref="hotel.room_type_restriction_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//sheet" position="inside">
|
||||
<notebook>
|
||||
<page name="connector" string="Channel Connector">
|
||||
<group string="Hotel Channel Bindings">
|
||||
<field name="channel_bind_ids" nolabel="1">
|
||||
<tree>
|
||||
<field name="backend_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='toggle_active']" position="before">
|
||||
<field name="channel_bind_ids" invisible="1" />
|
||||
<button name="open_channel_bind_ids" type="object"
|
||||
class="oe_stat_button" icon="fa-toggle-off" string="Connect to Channel"
|
||||
attrs="{'invisible': [('channel_bind_ids','!=', [])]}"
|
||||
/>
|
||||
<button name="open_channel_bind_ids" type="object"
|
||||
class="oe_stat_button" icon="fa-cloud-upload" string="Synchronize to Channel"
|
||||
attrs="{'invisible': [('channel_bind_ids','=', [])]}"
|
||||
/>
|
||||
<button name="disconnect_channel_bind_ids" type="object"
|
||||
class="oe_stat_button" icon="fa-toggle-on" string="Disconnect from Channel"
|
||||
attrs="{'invisible': [('channel_bind_ids','=', [])]}"
|
||||
confirm="Disconnecting will automatically delete the room type in the Channel. Do you want to proceed?"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
'data/cron_jobs.xml',
|
||||
'data/sequences.xml',
|
||||
'data/records.xml',
|
||||
'views/inherited_channel_hotel_room_type_restriction_views.xml',
|
||||
'views/inherited_channel_connector_backend_views.xml',
|
||||
'views/inherited_channel_ota_info_views.xml',
|
||||
#'security/wubook_security.xml',
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record id="channel_hotel_room_type_restriction_view_form" model="ir.ui.view">
|
||||
<field name="model">channel.hotel.room.type.restriction</field>
|
||||
<field name="inherit_id" ref="hotel_channel_connector.channel_hotel_room_type_restriction_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='external_id']" position="attributes">
|
||||
<attribute name="placeholder">Use restriction plan ID = 0 for the Channel default Restriction Plan.
|
||||
</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user