mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Wizard change group prices
This commit is contained in:
@@ -72,6 +72,7 @@
|
||||
"wizards/wizard_advanced_filters.xml",
|
||||
"wizards/wizard_folio.xml",
|
||||
"wizards/wizard_invoice_filter_days.xml",
|
||||
"wizards/wizard_folio_changes.xml",
|
||||
],
|
||||
"demo": [
|
||||
"demo/pms_master_data.xml",
|
||||
|
||||
@@ -759,6 +759,13 @@ class PmsFolio(models.Model):
|
||||
action = {"type": "ir.actions.act_window_close"}
|
||||
return action
|
||||
|
||||
def folio_multi_changes(self):
|
||||
self.ensure_one()
|
||||
reservation_ids = self.reservation_ids.ids
|
||||
action = self.env.ref("pms.action_folio_changes").sudo().read()[0]
|
||||
action["context"] = ({"default_reservation_ids": [(6, 0, reservation_ids)]},)
|
||||
return action
|
||||
|
||||
# def action_return_payments(self):
|
||||
# self.ensure_one()
|
||||
# return_move_ids = []
|
||||
|
||||
@@ -69,6 +69,7 @@ class PmsReservation(models.Model):
|
||||
ondelete="restrict",
|
||||
domain="[('id', 'in', allowed_room_ids)]",
|
||||
copy=False,
|
||||
tracking=True,
|
||||
)
|
||||
allowed_room_ids = fields.Many2many(
|
||||
"pms.room",
|
||||
@@ -88,6 +89,7 @@ class PmsReservation(models.Model):
|
||||
compute="_compute_board_service_room_id",
|
||||
store=True,
|
||||
readonly=False,
|
||||
tracking=True,
|
||||
)
|
||||
room_type_id = fields.Many2one(
|
||||
"pms.room.type",
|
||||
@@ -111,11 +113,13 @@ class PmsReservation(models.Model):
|
||||
related="folio_id.agency_id",
|
||||
readonly=False,
|
||||
store=True,
|
||||
tracking=True,
|
||||
)
|
||||
channel_type_id = fields.Many2one(
|
||||
related="folio_id.channel_type_id",
|
||||
store=True,
|
||||
readonly=False,
|
||||
tracking=True,
|
||||
)
|
||||
partner_invoice_id = fields.Many2one(
|
||||
"res.partner",
|
||||
@@ -154,6 +158,7 @@ class PmsReservation(models.Model):
|
||||
compute="_compute_pricelist_id",
|
||||
store=True,
|
||||
readonly=False,
|
||||
tracking=True,
|
||||
)
|
||||
show_update_pricelist = fields.Boolean(
|
||||
string="Has Pricelist Changed",
|
||||
@@ -167,6 +172,7 @@ class PmsReservation(models.Model):
|
||||
compute="_compute_commission_percent",
|
||||
store=True,
|
||||
readonly=False,
|
||||
tracking=True,
|
||||
)
|
||||
commission_amount = fields.Float(
|
||||
string="Commission amount",
|
||||
@@ -315,10 +321,18 @@ class PmsReservation(models.Model):
|
||||
)
|
||||
out_service_description = fields.Text("Cause of out of service")
|
||||
checkin = fields.Date(
|
||||
"Check In", required=True, default=_get_default_checkin, copy=False
|
||||
"Check In",
|
||||
required=True,
|
||||
default=_get_default_checkin,
|
||||
copy=False,
|
||||
tracking=True,
|
||||
)
|
||||
checkout = fields.Date(
|
||||
"Check Out", required=True, default=_get_default_checkout, copy=False
|
||||
"Check Out",
|
||||
required=True,
|
||||
default=_get_default_checkout,
|
||||
copy=False,
|
||||
tracking=True,
|
||||
)
|
||||
arrival_hour = fields.Char(
|
||||
"Arrival Hour",
|
||||
@@ -365,11 +379,15 @@ class PmsReservation(models.Model):
|
||||
detail_origin = fields.Char(
|
||||
"Detail Origin", compute="_compute_detail_origin", store=True
|
||||
)
|
||||
folio_pending_amount = fields.Monetary(related="folio_id.pending_amount")
|
||||
folio_pending_amount = fields.Monetary(
|
||||
related="folio_id.pending_amount",
|
||||
tracking=True,
|
||||
)
|
||||
folio_payment_state = fields.Selection(
|
||||
related="folio_id.payment_state",
|
||||
string="Payment State",
|
||||
store=True,
|
||||
tracking=True,
|
||||
)
|
||||
shared_folio = fields.Boolean(compute="_compute_shared")
|
||||
# Used to notify is the reservation folio has other reservations/services
|
||||
@@ -445,6 +463,7 @@ class PmsReservation(models.Model):
|
||||
readonly=True,
|
||||
store=True,
|
||||
compute="_compute_amount_reservation",
|
||||
tracking=True,
|
||||
)
|
||||
price_tax = fields.Float(
|
||||
string="Taxes Amount",
|
||||
@@ -470,6 +489,7 @@ class PmsReservation(models.Model):
|
||||
compute="_compute_discount",
|
||||
readonly=False,
|
||||
store=True,
|
||||
tracking=True,
|
||||
)
|
||||
date_order = fields.Date(
|
||||
compute="_compute_pms_creation_date",
|
||||
|
||||
@@ -60,3 +60,4 @@ user_access_folio_make_invoice_advance,user_access_folio_make_invoice_advance,mo
|
||||
user_access_pms_invoice_filter_days,user_access_pms_invoice_filter_days,model_pms_invoice_filter_days,pms.group_pms_user,1,1,1,1
|
||||
user_access_pms_invoice_filter_days_items,user_access_pms_invoice_filter_days_items,model_pms_invoice_filter_days_items,pms.group_pms_user,1,1,1,1
|
||||
user_access_wizard_payment_folio,user_access_wizard_payment_folio,model_wizard_payment_folio,pms.group_pms_user,1,1,1,1
|
||||
user_access_wizard_folio_changes,user_access_wizard_folio_changes,model_wizard_folio_changes,pms.group_pms_user,1,1,1,1
|
||||
|
||||
|
@@ -102,6 +102,14 @@
|
||||
string="Invoices"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
name="folio_multi_changes"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-calculator"
|
||||
>
|
||||
<span class="o_stat_text">Change Prices</span>
|
||||
</button>
|
||||
</div>
|
||||
<widget
|
||||
name="web_ribbon"
|
||||
@@ -219,6 +227,7 @@
|
||||
<field name="currency_id" invisible="1" />
|
||||
<!--<field name="refund_amount" invisible="1" />-->
|
||||
<field name="invoices_paid" invisible="1" />
|
||||
<field name="number_of_rooms" invisible="1" />
|
||||
</group>
|
||||
<notebook colspan="4" col="1">
|
||||
<page string="Sale Lines">
|
||||
|
||||
@@ -6,3 +6,4 @@ from . import wizard_folio_availability
|
||||
from . import folio_make_invoice_advance
|
||||
from . import wizard_invoice_filter_days
|
||||
from . import wizard_payment_folio
|
||||
from . import wizard_folio_changes
|
||||
|
||||
115
pms/wizards/wizard_folio_changes.py
Normal file
115
pms/wizards/wizard_folio_changes.py
Normal file
@@ -0,0 +1,115 @@
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
|
||||
class WizardFolioChanges(models.TransientModel):
|
||||
|
||||
_name = "wizard.folio.changes"
|
||||
_description = "Folio Changes"
|
||||
|
||||
def _default_folio_id(self):
|
||||
folio_id = self._context.get("active_id")
|
||||
folio = self.env["pms.folio"].browse(folio_id)
|
||||
return folio
|
||||
|
||||
def _default_reservation_ids(self):
|
||||
folio_id = self._context.get("active_id")
|
||||
folio = self.env["pms.folio"].browse(folio_id)
|
||||
return folio.reservation_ids
|
||||
|
||||
folio_id = fields.Many2one(
|
||||
"pms.folio",
|
||||
string="Folio",
|
||||
default=_default_folio_id,
|
||||
)
|
||||
reservation_ids = fields.Many2many(
|
||||
"pms.reservation",
|
||||
string="Reservations",
|
||||
default=_default_reservation_ids,
|
||||
domain="[('id', 'in', allowed_reservation_ids)]",
|
||||
)
|
||||
allowed_reservation_ids = fields.Many2many(
|
||||
"pms.reservation",
|
||||
string="Allowed Reservations",
|
||||
compute="_compute_allowed_reservations",
|
||||
)
|
||||
new_price = fields.Float(
|
||||
string="New Price",
|
||||
)
|
||||
new_discount = fields.Float(
|
||||
string="New Discount %",
|
||||
)
|
||||
apply_on_monday = fields.Boolean(
|
||||
string="Apply Availability Rule on mondays",
|
||||
default=False,
|
||||
)
|
||||
apply_on_tuesday = fields.Boolean(
|
||||
string="Apply Availability Rule on tuesdays",
|
||||
default=False,
|
||||
)
|
||||
apply_on_wednesday = fields.Boolean(
|
||||
string="Apply Availability Rule on wednesdays",
|
||||
default=False,
|
||||
)
|
||||
apply_on_thursday = fields.Boolean(
|
||||
string="Apply Availability Rule on thursdays",
|
||||
default=False,
|
||||
)
|
||||
apply_on_friday = fields.Boolean(
|
||||
string="Apply Availability Rule on fridays",
|
||||
default=False,
|
||||
)
|
||||
apply_on_saturday = fields.Boolean(
|
||||
string="Apply Availability Rule on saturdays",
|
||||
default=False,
|
||||
)
|
||||
apply_on_sunday = fields.Boolean(
|
||||
string="Apply Availability Rule on sundays",
|
||||
default=False,
|
||||
)
|
||||
apply_on_all_week = fields.Boolean(
|
||||
string="Apply Availability Rule for the whole week",
|
||||
default=True,
|
||||
)
|
||||
|
||||
@api.depends("folio_id")
|
||||
def _compute_allowed_reservations(self):
|
||||
self.ensure_one()
|
||||
self.allowed_reservation_ids = self.folio_id.reservation_ids
|
||||
|
||||
def button_change(self):
|
||||
vals = {}
|
||||
week_days_to_apply = (
|
||||
self.apply_on_monday,
|
||||
self.apply_on_tuesday,
|
||||
self.apply_on_wednesday,
|
||||
self.apply_on_thursday,
|
||||
self.apply_on_friday,
|
||||
self.apply_on_saturday,
|
||||
self.apply_on_sunday,
|
||||
)
|
||||
reservation_lines = self.reservation_ids.reservation_line_ids
|
||||
if not self.apply_on_all_week:
|
||||
reservation_lines = reservation_lines.filtered(
|
||||
lambda x: week_days_to_apply[x.date.timetuple()[6]]
|
||||
)
|
||||
if self.new_price:
|
||||
vals["price"] = self.new_price
|
||||
if self.new_discount:
|
||||
vals["discount"] = self.new_discount
|
||||
|
||||
reservation_lines.write(vals)
|
||||
|
||||
self.folio_id.message_post(
|
||||
body=_(
|
||||
"Prices/Discounts have been changed from folio",
|
||||
)
|
||||
)
|
||||
reservations = self.env["pms.reservation"].browse(
|
||||
reservation_lines.mapped("reservation_id.id")
|
||||
)
|
||||
for reservation in reservations:
|
||||
reservation.message_post(
|
||||
body=_(
|
||||
"Prices/Discounts have been changed from folio",
|
||||
)
|
||||
)
|
||||
128
pms/wizards/wizard_folio_changes.xml
Normal file
128
pms/wizards/wizard_folio_changes.xml
Normal file
@@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="wizard_folio_changes_view_form" model="ir.ui.view">
|
||||
<field name="name">wizard.folio.changes.view.form</field>
|
||||
<field name="model">wizard.folio.changes</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Folio Changes">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table class="table table-bordered text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>All days</th>
|
||||
<th>Sunday</th>
|
||||
<th>Monday</th>
|
||||
<th>Tuesday</th>
|
||||
<th>Wednesday</th>
|
||||
<th>Thursday</th>
|
||||
<th>Friday</th>
|
||||
<th>Saturday</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<field
|
||||
name="apply_on_all_week"
|
||||
widget="boolean_toggle"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<field
|
||||
name="apply_on_sunday"
|
||||
widget="boolean_toggle"
|
||||
attrs="{'invisible':[('apply_on_all_week','=',True)]}"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<field
|
||||
name="apply_on_monday"
|
||||
widget="boolean_toggle"
|
||||
attrs="{'invisible':[('apply_on_all_week','=',True)]}"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<field
|
||||
name="apply_on_tuesday"
|
||||
widget="boolean_toggle"
|
||||
attrs="{'invisible':[('apply_on_all_week','=',True)]}"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<field
|
||||
name="apply_on_wednesday"
|
||||
widget="boolean_toggle"
|
||||
attrs="{'invisible':[('apply_on_all_week','=',True)]}"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<field
|
||||
name="apply_on_thursday"
|
||||
widget="boolean_toggle"
|
||||
attrs="{'invisible':[('apply_on_all_week','=',True)]}"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<field
|
||||
name="apply_on_friday"
|
||||
widget="boolean_toggle"
|
||||
attrs="{'invisible':[('apply_on_all_week','=',True)]}"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<field
|
||||
name="apply_on_saturday"
|
||||
widget="boolean_toggle"
|
||||
attrs="{'invisible':[('apply_on_all_week','=',True)]}"
|
||||
/>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-5 ">
|
||||
<group>
|
||||
<field name="folio_id" invisible="1" />
|
||||
<field name="allowed_reservation_ids" invisible="1" />
|
||||
<field
|
||||
name="reservation_ids"
|
||||
widget="many2many_tags"
|
||||
nolabel="1"
|
||||
/>
|
||||
</group>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<group>
|
||||
<field name="new_price" />
|
||||
<field name="new_discount" />
|
||||
</group>
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
<button
|
||||
type="object"
|
||||
class="btn-primary"
|
||||
id="payment"
|
||||
name="button_change"
|
||||
string="Change"
|
||||
/>
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_folio_changes" model="ir.actions.act_window">
|
||||
<field name="name">Folio Changes</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">wizard.folio.changes</field>
|
||||
<field name="view_id" ref="wizard_folio_changes_view_form" />
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user