mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Add virtual pricelists
This commit is contained in:
@@ -2,11 +2,16 @@
|
|||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
|
||||||
class ProductPricelist(models.Model):
|
class ProductPricelist(models.Model):
|
||||||
_inherit = 'product.pricelist'
|
_inherit = 'product.pricelist'
|
||||||
|
|
||||||
is_staff = fields.Boolean('Is Staff')
|
is_staff = fields.Boolean('Is Staff')
|
||||||
|
|
||||||
|
is_daily_plan = fields.Boolean('Daily Pricing Plan', default=True,
|
||||||
|
help = "Check if the pricing plan is daily. "
|
||||||
|
"Note that only daily plans can be edited on "
|
||||||
|
"the Hotel Calendar Management.")
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('name')
|
@api.depends('name')
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ class ChannelProductPricelist(models.Model):
|
|||||||
string='Pricelist',
|
string='Pricelist',
|
||||||
required=True,
|
required=True,
|
||||||
ondelete='cascade')
|
ondelete='cascade')
|
||||||
is_daily_plan = fields.Boolean("Channel Daily Plan", default=True, old_name='wdaily_plan')
|
|
||||||
|
|
||||||
@job(default_channel='root.channel')
|
@job(default_channel='root.channel')
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -54,6 +53,7 @@ class ChannelProductPricelist(models.Model):
|
|||||||
importer = work.component(usage='product.pricelist.importer')
|
importer = work.component(usage='product.pricelist.importer')
|
||||||
return importer.import_pricing_plans()
|
return importer.import_pricing_plans()
|
||||||
|
|
||||||
|
|
||||||
class ProductPricelist(models.Model):
|
class ProductPricelist(models.Model):
|
||||||
_inherit = 'product.pricelist'
|
_inherit = 'product.pricelist'
|
||||||
|
|
||||||
@@ -62,6 +62,28 @@ class ProductPricelist(models.Model):
|
|||||||
inverse_name='odoo_id',
|
inverse_name='odoo_id',
|
||||||
string='Hotel Channel Connector Bindings')
|
string='Hotel Channel Connector Bindings')
|
||||||
|
|
||||||
|
is_virtual_plan = fields.Boolean("Is a Virtual Pricing Plan", compute='_compute_virtual_plan', readonly="True",
|
||||||
|
help="A virtual plan is based on another Pricelist "
|
||||||
|
"with a fixed or percentage variation.")
|
||||||
|
|
||||||
|
@api.depends('item_ids')
|
||||||
|
def _compute_virtual_plan(self):
|
||||||
|
for record in self:
|
||||||
|
record.is_virtual_plan = True
|
||||||
|
if any(item.applied_on != '3_global'
|
||||||
|
or (item.date_start or item.date_end)
|
||||||
|
or item.compute_price != 'formula'
|
||||||
|
or item.base != 'pricelist'
|
||||||
|
or not item.base_pricelist_id.is_daily_plan
|
||||||
|
or (item.price_discount != 0 and item.price_surcharge != 0)
|
||||||
|
or item.min_quantity != 0
|
||||||
|
or item.price_round != 0
|
||||||
|
or item.price_min_margin != 0
|
||||||
|
or item.price_max_margin != 0
|
||||||
|
for item in record.item_ids):
|
||||||
|
record.is_virtual_plan = False
|
||||||
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('name')
|
@api.depends('name')
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
@@ -95,6 +117,8 @@ class ProductPricelist(models.Model):
|
|||||||
action['context'] = {
|
action['context'] = {
|
||||||
'default_odoo_id': self.id,
|
'default_odoo_id': self.id,
|
||||||
'default_name': self.name,
|
'default_name': self.name,
|
||||||
|
'default_is_daily_plan': self.is_daily_plan,
|
||||||
|
'default_is_virtual_plan': self.is_virtual_plan,
|
||||||
}
|
}
|
||||||
return action
|
return action
|
||||||
|
|
||||||
@@ -105,6 +129,7 @@ class ProductPricelist(models.Model):
|
|||||||
msg += _(" The pricelist [%s] should be delete from the channel manager.") % channel_bind_ids.get_external_id
|
msg += _(" The pricelist [%s] should be delete from the channel manager.") % channel_bind_ids.get_external_id
|
||||||
raise UserError(msg)
|
raise UserError(msg)
|
||||||
|
|
||||||
|
|
||||||
class BindingProductPricelistListener(Component):
|
class BindingProductPricelistListener(Component):
|
||||||
_name = 'binding.product.pricelist.listener'
|
_name = 'binding.product.pricelist.listener'
|
||||||
_inherit = 'base.connector.listener'
|
_inherit = 'base.connector.listener'
|
||||||
@@ -116,6 +141,7 @@ class BindingProductPricelistListener(Component):
|
|||||||
for binding in record.channel_bind_ids:
|
for binding in record.channel_bind_ids:
|
||||||
binding.update_plan_name()
|
binding.update_plan_name()
|
||||||
|
|
||||||
|
|
||||||
class ChannelBindingProductPricelistListener(Component):
|
class ChannelBindingProductPricelistListener(Component):
|
||||||
_name = 'channel.binding.product.pricelist.listener'
|
_name = 'channel.binding.product.pricelist.listener'
|
||||||
_inherit = 'base.connector.listener'
|
_inherit = 'base.connector.listener'
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<group>
|
<group>
|
||||||
<field name="external_id" />
|
<field name="external_id" />
|
||||||
<field name="is_daily_plan" />
|
<field name="is_daily_plan" />
|
||||||
|
<field name="is_virtual_plan" />
|
||||||
</group>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -21,6 +21,11 @@
|
|||||||
confirm="Disconnecting will automatically delete the pricelist in the Channel. Do you want to proceed?"
|
confirm="Disconnecting will automatically delete the pricelist in the Channel. Do you want to proceed?"
|
||||||
/>
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
|
<xpath expr="//field[@name='country_group_ids']" position="before">
|
||||||
|
<field name="is_daily_plan" />
|
||||||
|
<field name="is_virtual_plan" />
|
||||||
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user