mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[UPD] Task 973 - binding for restriction plan
This commit is contained in:
@@ -53,6 +53,7 @@ class ChannelHotelRoomTypeRestriction(models.Model):
|
||||
importer = work.component(usage='hotel.room.type.restriction.importer')
|
||||
return importer.import_restriction_plans()
|
||||
|
||||
|
||||
class HotelRoomTypeRestriction(models.Model):
|
||||
_inherit = 'hotel.room.type.restriction'
|
||||
|
||||
@@ -99,10 +100,15 @@ class HotelRoomTypeRestriction(models.Model):
|
||||
|
||||
@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 restriction plan [%s] should be delete from the channel manager.") % channel_bind_ids.get_external_id
|
||||
raise UserError(msg)
|
||||
# TODO: multichannel rooms is not implemented
|
||||
self.channel_bind_ids.with_context({'connector_no_export': True}).unlink()
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
if 'active' in vals and vals.get('active') is False:
|
||||
self.channel_bind_ids.unlink()
|
||||
return super().write(vals)
|
||||
|
||||
|
||||
class BindingHotelRoomTypeListener(Component):
|
||||
_name = 'binding.hotel.room.type.restriction.listener'
|
||||
@@ -115,6 +121,7 @@ class BindingHotelRoomTypeListener(Component):
|
||||
for binding in record.channel_bind_ids:
|
||||
binding.update_plan_name()
|
||||
|
||||
|
||||
class ChannelBindingHotelRoomTypeRestrictionListener(Component):
|
||||
_name = 'channel.binding.hotel.room.type.restriction.listener'
|
||||
_inherit = 'base.connector.listener'
|
||||
|
||||
@@ -5,11 +5,31 @@
|
||||
<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="//form/sheet" position="inside">
|
||||
<page string="Channel Bindings" invisible="1">
|
||||
<field name="channel_bind_ids" />
|
||||
</page>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//button[@name='toggle_active']" position="replace">
|
||||
<!-- custom message for warning when archiving a channel restriction plan with binding -->
|
||||
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive"
|
||||
confirm="Archive a restriction plan will automatically delete the restriction plan in the Channel.
|
||||
Do you want to proceed?"
|
||||
attrs="{'invisible': [('channel_bind_ids', '=', [])]}">
|
||||
<field name="active" widget="boolean_button" options='{"terminology": "archive"}'/>
|
||||
</button>
|
||||
<!-- default message for archiving a channel restriction plan without binding -->
|
||||
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive"
|
||||
attrs="{'invisible': [('channel_bind_ids','!=', [])]}">
|
||||
<field name="active" widget="boolean_button" options='{"terminology": "archive"}'/>
|
||||
</button>
|
||||
</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','!=', [])]}"
|
||||
attrs="{'invisible': ['|', ('channel_bind_ids','!=', []), ('active','=', False) ]}"
|
||||
/>
|
||||
<button name="open_channel_bind_ids" type="object"
|
||||
class="oe_stat_button" icon="fa fa-gears" string="Configure Channel"
|
||||
@@ -18,7 +38,8 @@
|
||||
<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 restriction plan in the Channel. Do you want to proceed?"
|
||||
confirm="Disconnecting will unbind the restriction plan from the Channel but it will not be deleted.
|
||||
Do you want to proceed?"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
from odoo.addons.component.core import Component
|
||||
from odoo.addons.hotel_channel_connector.components.core import ChannelConnectorError
|
||||
from odoo import api, fields
|
||||
from odoo import api, fields, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class HotelRoomTypeRestrictionExporter(Component):
|
||||
@@ -23,6 +24,7 @@ class HotelRoomTypeRestrictionExporter(Component):
|
||||
section='restriction',
|
||||
internal_message=str(err),
|
||||
channel_message=err.data['message'])
|
||||
raise ValidationError(_(err.data['message']))
|
||||
|
||||
@api.model
|
||||
def create_rplan(self, binding):
|
||||
@@ -33,5 +35,6 @@ class HotelRoomTypeRestrictionExporter(Component):
|
||||
section='restriction',
|
||||
internal_message=str(err),
|
||||
channel_message=err.data['message'])
|
||||
raise ValidationError(_(err.data['message']))
|
||||
else:
|
||||
self.binder.bind(external_id, binding)
|
||||
|
||||
Reference in New Issue
Block a user