From f26cf50bca257d429baab9d8a54eeb84cf0b6da8 Mon Sep 17 00:00:00 2001 From: Oscar Date: Sat, 9 Oct 2021 12:49:43 -0500 Subject: [PATCH] Refactory 06 --- booking.py | 32 +++------ booking.xml | 64 ------------------ folio.py | 148 ++++++++++++++++++++---------------------- folio.xml | 62 ++++++++++++++++++ view/booking_form.xml | 46 +++++-------- 5 files changed, 159 insertions(+), 193 deletions(-) diff --git a/booking.py b/booking.py index 308b345..696a76b 100644 --- a/booking.py +++ b/booking.py @@ -6,7 +6,9 @@ from datetime import datetime, timedelta from decimal import Decimal from trytond.model import Workflow, ModelView, ModelSQL, fields -from trytond.wizard import Wizard, StateView, Button, StateTransition, StateReport +from trytond.wizard import ( + Wizard, StateView, Button, StateTransition, StateReport +) from trytond.report import Report from trytond.pyson import Eval, If, In, Get, Not, Or, Equal, Bool from trytond.transaction import Transaction @@ -15,7 +17,7 @@ from trytond.exceptions import UserError from trytond.i18n import gettext from constants import ( STATE_BOOKING, REGISTRATION_STATE, SEGMENT, GUARANTEE, SATISFACTION, - MEDIA, PLAN, SOURCE, INVOICE_METHOD, COMPLEMENTARY, INVOICE_STATES, + MEDIA, PLAN, SOURCE, INVOICE_METHOD, COMPLEMENTARY, ) STATES = { @@ -145,13 +147,14 @@ class Booking(Workflow, ModelSQL, ModelView): )) cls._buttons.update({ 'select_rooms': { - 'invisible': Eval('state') != 'offer', + 'invisible': Eval('state').in_(['finished', 'cancelled', 'not_show']), }, 'create_guest': { 'invisible': Eval('state') != 'offer', }, 'cancel': { - 'invisible': Eval('state').in_(['cancel', '']) + 'invisible': Eval('state').in_( + ['cancelled', 'not_show', 'finished']) }, 'offer': { 'invisible': Eval('state').in_(['offer', 'confirmed']) @@ -163,8 +166,7 @@ class Booking(Workflow, ModelSQL, ModelView): 'invisible': Eval('state') != 'confirmed', }, 'pay_advance': { - 'invisible': - Eval('registration_state').in_(['check_out', 'offer']), + 'invisible': Eval('state').in_(['finished', 'cancelled']), }, 'send_email': { 'invisible': Eval('state') != 'confirmed' @@ -248,15 +250,13 @@ class Booking(Workflow, ModelSQL, ModelView): @ModelView.button @Workflow.transition('offer') def offer(cls, records): - for record in records: - record.delete_occupancy() + pass @classmethod @ModelView.button @Workflow.transition('cancelled') def cancel(cls, records): - for record in records: - record.cancel_occupancy() + pass @classmethod @ModelView.button @@ -302,18 +302,6 @@ class Booking(Workflow, ModelSQL, ModelView): number = config.booking_sequence.get() cls.write([booking], {'number': number}) - def cancel_occupancy(self): - Operation = Pool().get('hotel.operation') - ops = Operation.search([('origin', '=', str(self))]) - if ops: - Operation.cancel(ops) - - def delete_occupancy(self): - Operation = Pool().get('hotel.operation') - for l in self.lines: - if l.operation: - Operation.delete([l.operation]) - def update_folio(self, state): Line = Pool().get('hotel.folio') Line.write(list(self.lines), {'registration_state': state}) diff --git a/booking.xml b/booking.xml index 89e7b14..e068593 100644 --- a/booking.xml +++ b/booking.xml @@ -198,70 +198,6 @@ this repository contains the full copyright notices and license terms. --> - - hotel.folio - tree - board_folio_tree - - - hotel.folio - form - board_folio_form - - - Board Folios - hotel.folio - - - - - - - - - - - - - - - - Arriving Today - - - - - - Leaving Today - - - - - - No Show Yesterday - - - - - - All - - - - - + + hotel.folio + tree + board_folio_tree + + + hotel.folio + form + board_folio_form + + + Board Folios + hotel.folio + + + + + + + + + + + + + + + + Arriving Today + + + + + + Leaving Today + + + + + + No Show Yesterday + + + + + + All + + + + +