mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[UPD] Task 973 - binding for pricelist plan
This commit is contained in:
@@ -82,7 +82,6 @@ class ProductPricelist(models.Model):
|
|||||||
inverse_name='odoo_id',
|
inverse_name='odoo_id',
|
||||||
string='Hotel Channel Connector Bindings')
|
string='Hotel Channel Connector Bindings')
|
||||||
|
|
||||||
|
|
||||||
pricelist_type = fields.Selection(selection_add=[
|
pricelist_type = fields.Selection(selection_add=[
|
||||||
('virtual', 'Virtual Plan'),
|
('virtual', 'Virtual Plan'),
|
||||||
])
|
])
|
||||||
@@ -104,7 +103,6 @@ class ProductPricelist(models.Model):
|
|||||||
for item in record.item_ids):
|
for item in record.item_ids):
|
||||||
record.is_virtual_plan = False
|
record.is_virtual_plan = False
|
||||||
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('name')
|
@api.depends('name')
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
@@ -144,10 +142,14 @@ class ProductPricelist(models.Model):
|
|||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def disconnect_channel_bind_ids(self):
|
def disconnect_channel_bind_ids(self):
|
||||||
channel_bind_ids = self.mapped('channel_bind_ids')
|
# TODO: multichannel rooms is not implemented
|
||||||
msg = _("This function is not yet implemented.")
|
self.channel_bind_ids.with_context({'connector_no_export': True}).unlink()
|
||||||
msg += _(" The pricelist [%s] should be delete from the channel manager.") % channel_bind_ids.get_external_id
|
|
||||||
raise UserError(msg)
|
@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 BindingProductPricelistListener(Component):
|
class BindingProductPricelistListener(Component):
|
||||||
|
|||||||
@@ -5,11 +5,31 @@
|
|||||||
<field name="model">product.pricelist</field>
|
<field name="model">product.pricelist</field>
|
||||||
<field name="inherit_id" ref="product.product_pricelist_view" />
|
<field name="inherit_id" ref="product.product_pricelist_view" />
|
||||||
<field name="arch" type="xml">
|
<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 pricelist plan with binding -->
|
||||||
|
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive"
|
||||||
|
confirm="Archive a pricelist plan will automatically delete the pricelist 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 pricelist 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">
|
<xpath expr="//button[@name='toggle_active']" position="before">
|
||||||
<field name="channel_bind_ids" invisible="1" />
|
|
||||||
<button name="open_channel_bind_ids" type="object"
|
<button name="open_channel_bind_ids" type="object"
|
||||||
class="oe_stat_button" icon="fa-toggle-off" string="Connect to Channel"
|
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"
|
<button name="open_channel_bind_ids" type="object"
|
||||||
class="oe_stat_button" icon="fa fa-gears" string="Configure Channel"
|
class="oe_stat_button" icon="fa fa-gears" string="Configure Channel"
|
||||||
@@ -18,7 +38,8 @@
|
|||||||
<button name="disconnect_channel_bind_ids" type="object"
|
<button name="disconnect_channel_bind_ids" type="object"
|
||||||
class="oe_stat_button" icon="fa-toggle-on" string="Disconnect from Channel"
|
class="oe_stat_button" icon="fa-toggle-on" string="Disconnect from Channel"
|
||||||
attrs="{'invisible': [('channel_bind_ids','=', [])]}"
|
attrs="{'invisible': [('channel_bind_ids','=', [])]}"
|
||||||
confirm="Disconnecting will automatically delete the pricelist in the Channel. Do you want to proceed?"
|
confirm="Disconnecting will unbind the pricelist plan from the Channel but it will not be deleted.
|
||||||
|
Do you want to proceed?"
|
||||||
/>
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
from odoo.addons.component.core import Component
|
from odoo.addons.component.core import Component
|
||||||
from odoo.addons.hotel_channel_connector.components.core import ChannelConnectorError
|
from odoo.addons.hotel_channel_connector.components.core import ChannelConnectorError
|
||||||
from odoo import api
|
from odoo import api, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class ProductPricelistDeleter(Component):
|
class ProductPricelistDeleter(Component):
|
||||||
@@ -18,3 +19,4 @@ class ProductPricelistDeleter(Component):
|
|||||||
section='pricelist',
|
section='pricelist',
|
||||||
internal_message=str(err),
|
internal_message=str(err),
|
||||||
channel_message=err.data['message'])
|
channel_message=err.data['message'])
|
||||||
|
raise ValidationError(_(err.data['message']) + ". " + _(str(err)))
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
from odoo.addons.component.core import Component
|
from odoo.addons.component.core import Component
|
||||||
from odoo.addons.hotel_channel_connector.components.core import ChannelConnectorError
|
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 ProductPricelistExporter(Component):
|
class ProductPricelistExporter(Component):
|
||||||
@@ -23,6 +24,7 @@ class ProductPricelistExporter(Component):
|
|||||||
section='pricelist',
|
section='pricelist',
|
||||||
internal_message=str(err),
|
internal_message=str(err),
|
||||||
channel_message=err.data['message'])
|
channel_message=err.data['message'])
|
||||||
|
raise ValidationError(_(err.data['message']))
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create_plan(self, binding):
|
def create_plan(self, binding):
|
||||||
@@ -33,6 +35,7 @@ class ProductPricelistExporter(Component):
|
|||||||
section='pricelist',
|
section='pricelist',
|
||||||
internal_message=str(err),
|
internal_message=str(err),
|
||||||
channel_message=err.data['message'])
|
channel_message=err.data['message'])
|
||||||
|
raise ValidationError(_(err.data['message']))
|
||||||
else:
|
else:
|
||||||
binding.external_id = external_id
|
binding.external_id = external_id
|
||||||
self.binder.bind(external_id, binding)
|
self.binder.bind(external_id, binding)
|
||||||
@@ -67,6 +70,7 @@ class ProductPricelistExporter(Component):
|
|||||||
section='pricelist',
|
section='pricelist',
|
||||||
internal_message=str(err),
|
internal_message=str(err),
|
||||||
channel_message=err.data['message'])
|
channel_message=err.data['message'])
|
||||||
|
raise ValidationError(_(err.data['message']))
|
||||||
else:
|
else:
|
||||||
binding.external_id = external_id
|
binding.external_id = external_id
|
||||||
self.binder.bind(external_id, binding)
|
self.binder.bind(external_id, binding)
|
||||||
@@ -102,3 +106,4 @@ class ProductPricelistExporter(Component):
|
|||||||
section='pricelist',
|
section='pricelist',
|
||||||
internal_message=str(err),
|
internal_message=str(err),
|
||||||
channel_message=err.data['message'])
|
channel_message=err.data['message'])
|
||||||
|
raise ValidationError(_(err.data['message']))
|
||||||
|
|||||||
Reference in New Issue
Block a user