[IMP] Precommit improvements

This commit is contained in:
Darío Lodeiros
2020-11-16 13:02:43 +01:00
parent b7fd5cfdfb
commit 447de5f8f3
5 changed files with 140 additions and 92 deletions

View File

@@ -1,18 +1,20 @@
from odoo import fields, models
from odoo import models, fields
class ReservationWizard(models.TransientModel):
_name = 'pms.reservation.wizard'
allowed_rooms = fields.One2many('pms.room', compute="_compute_allowed_rooms")
options = fields.Many2one('pms.room', string='Room')
_name = "pms.reservation.wizard"
allowed_rooms = fields.One2many("pms.room", compute="_compute_allowed_rooms")
options = fields.Many2one("pms.room", string="Room")
def _compute_allowed_rooms(self):
for record in self:
record.allowed_rooms = self._context.get('rooms_available')
record.allowed_rooms = self._context.get("rooms_available")
def unify(self):
if self.options:
for record in self:
for line in self.env['pms.reservation'].search([('id', '=', self._context.get('active_id'))]).reservation_line_ids:
line.room_id = self.options
for line in (
self.env["pms.reservation"]
.search([("id", "=", self._context.get("active_id"))])
.reservation_line_ids
):
line.room_id = self.options

View File

@@ -1,24 +1,31 @@
<?xml version="1.0" ?>
<odoo>
<record id="reservation_wizard" model="ir.ui.view">
<field name="name">Reservation Wizard</field>
<field name="model">pms.reservation.wizard</field>
<field name="arch" type="xml">
<form string="Choose The Details">
<group>
<field name="options"
string="Suggested rooms to unify the reservation:"
options="{'no_create': True,'no_open': True}"
required="1"
domain="[('id', 'in', allowed_rooms)]"/>
<field name="allowed_rooms" invisible="1"/>
</group>
<footer>
<button name="unify" string="Unify" type="object" class="oe_highlight" />
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
<record id="reservation_wizard" model="ir.ui.view">
<field name="name">Reservation Wizard</field>
<field name="model">pms.reservation.wizard</field>
<field name="arch" type="xml">
<form string="Choose The Details">
<group>
<field
name="options"
string="Suggested rooms to unify the reservation:"
options="{'no_create': True,'no_open': True}"
required="1"
domain="[('id', 'in', allowed_rooms)]"
/>
<field name="allowed_rooms" invisible="1" />
</group>
<footer>
<button
name="unify"
string="Unify"
type="object"
class="oe_highlight"
/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
</odoo>