mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] add pricelist type as a selection
This commit is contained in:
@@ -8,10 +8,10 @@ class ProductPricelist(models.Model):
|
||||
|
||||
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.")
|
||||
pricelist_type = fields.Selection([
|
||||
('daily', 'Daily Plan'),
|
||||
], string='Pricelist Type', default='daily')
|
||||
|
||||
@api.multi
|
||||
@api.depends('name')
|
||||
def name_get(self):
|
||||
|
||||
@@ -82,9 +82,10 @@ class ProductPricelist(models.Model):
|
||||
inverse_name='odoo_id',
|
||||
string='Hotel Channel Connector Bindings')
|
||||
|
||||
is_virtual_plan = fields.Boolean("Is a Virtual Pricing Plan", compute='_compute_virtual_plan',
|
||||
help="A virtual plan is based on another Pricelist "
|
||||
"with a fixed or percentage variation.")
|
||||
|
||||
pricelist_type = fields.Selection(selection_add=[
|
||||
('virtual', 'Virtual Plan'),
|
||||
])
|
||||
|
||||
@api.depends('item_ids')
|
||||
def _compute_virtual_plan(self):
|
||||
@@ -137,8 +138,7 @@ class ProductPricelist(models.Model):
|
||||
action['context'] = {
|
||||
'default_odoo_id': self.id,
|
||||
'default_name': self.name,
|
||||
'default_is_daily_plan': self.is_daily_plan,
|
||||
'default_is_virtual_plan': self.is_virtual_plan,
|
||||
'default_pricelist_plan': self.pricelist_type,
|
||||
}
|
||||
return action
|
||||
|
||||
@@ -160,7 +160,7 @@ class BindingProductPricelistListener(Component):
|
||||
if 'name' in fields:
|
||||
for binding in record.channel_bind_ids:
|
||||
binding.update_plan_name()
|
||||
if 'item_ids' in fields and record.is_virtual_plan:
|
||||
if 'item_ids' in fields and record.pricelist_type == 'virtual':
|
||||
for binding in record.channel_bind_ids:
|
||||
binding.modify_vplan()
|
||||
|
||||
@@ -172,10 +172,10 @@ class ChannelBindingProductPricelistListener(Component):
|
||||
|
||||
@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
|
||||
def on_record_create(self, record, fields=None):
|
||||
if record.is_virtual_plan:
|
||||
record.create_vplan()
|
||||
else:
|
||||
if record.pricelist_type == 'daily':
|
||||
record.create_plan()
|
||||
elif record.pricelist_type == 'virtual':
|
||||
record.create_vplan()
|
||||
|
||||
@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
|
||||
def on_record_unlink(self, record, fields=None):
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
</group>
|
||||
<group>
|
||||
<field name="external_id" />
|
||||
<field name="is_daily_plan" />
|
||||
<field name="is_virtual_plan"/>
|
||||
<field name="pricelist_type" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//field[@name='country_group_ids']" position="before">
|
||||
<field name="is_daily_plan" />
|
||||
<field name="is_virtual_plan" />
|
||||
<field name="pricelist_type" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user