From d71c29f2f41e9951efd812d0ee1852ba1bb5ce19 Mon Sep 17 00:00:00 2001 From: Pablo Date: Fri, 26 Jul 2019 13:55:16 +0200 Subject: [PATCH] [UPD] Task 973 - binding for pricelist plan --- .../models/product_pricelist/common.py | 14 +++++----- .../inherited_product_pricelist_views.xml | 27 ++++++++++++++++--- .../models/product_pricelist/deleter.py | 4 ++- .../models/product_pricelist/exporter.py | 7 ++++- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/hotel_channel_connector/models/product_pricelist/common.py b/hotel_channel_connector/models/product_pricelist/common.py index f2257a721..995672a20 100644 --- a/hotel_channel_connector/models/product_pricelist/common.py +++ b/hotel_channel_connector/models/product_pricelist/common.py @@ -82,7 +82,6 @@ class ProductPricelist(models.Model): inverse_name='odoo_id', string='Hotel Channel Connector Bindings') - pricelist_type = fields.Selection(selection_add=[ ('virtual', 'Virtual Plan'), ]) @@ -104,7 +103,6 @@ class ProductPricelist(models.Model): for item in record.item_ids): record.is_virtual_plan = False - @api.multi @api.depends('name') def name_get(self): @@ -144,10 +142,14 @@ class ProductPricelist(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 pricelist [%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 BindingProductPricelistListener(Component): diff --git a/hotel_channel_connector/views/inherited_product_pricelist_views.xml b/hotel_channel_connector/views/inherited_product_pricelist_views.xml index dec33b25a..09f8b7309 100644 --- a/hotel_channel_connector/views/inherited_product_pricelist_views.xml +++ b/hotel_channel_connector/views/inherited_product_pricelist_views.xml @@ -5,11 +5,31 @@ product.pricelist + + + + + + + + + + + + + -