diff --git a/.~lock.housekeeping.fods# b/.~lock.housekeeping.fods# new file mode 100644 index 0000000..d3cb5b5 --- /dev/null +++ b/.~lock.housekeeping.fods# @@ -0,0 +1 @@ +,psk,Acer,09.08.2022 15:10,file:///home/psk/.config/libreoffice/4; \ No newline at end of file diff --git a/housekeeping.fods b/housekeeping.fods index 79c93aa..b1f5469 100644 Binary files a/housekeeping.fods and b/housekeeping.fods differ diff --git a/room.py b/room.py index e21c5b7..46c9912 100644 --- a/room.py +++ b/room.py @@ -65,6 +65,7 @@ class Room(Workflow, ModelSQL, ModelView): last_clean = fields.DateTime('Last Clean') housekeeping = fields.Many2One('company.employee', 'Employee') notes = fields.Text('Notes') + guests = fields.Function(fields.Integer('Guests'), 'get_guests') @classmethod def __setup__(cls): @@ -135,6 +136,19 @@ class Room(Workflow, ModelSQL, ModelView): def inspected(cls, records): pass + def get_guests(self, name=None): + pool = Pool() + Folio = pool.get('hotel.folio') + folios = Folio.search([ + ('room', '=', self.id), + ('arrival_date', '<=', date.today()), + ('departure_date', '>', date.today()) + ]) + res = [] + for folio in folios: + res.append(len(folio.guests)) + return sum(res) + def get_cleaning_type(self, name=None): pool = Pool() Config = pool.get('hotel.configuration') @@ -277,9 +291,13 @@ class HousekeepingReport(Report): dom.append(('employee.id', '=', data['employee'])) rooms = Room.search(dom) + total_guests = [] + for room in rooms: + total_guests.append(room.guests) report_context['records'] = rooms report_context['company'] = Company(data['company']) report_context['date'] = datetime.now() + report_context['total_guests'] = sum(total_guests) return report_context diff --git a/service.fods b/service.fods index 7161764..0f1dd2d 100644 Binary files a/service.fods and b/service.fods differ diff --git a/service.py b/service.py index e7e98b9..3d000da 100644 --- a/service.py +++ b/service.py @@ -26,6 +26,8 @@ class ServiceKind(ModelSQL, ModelView): salable = fields.Boolean('Salable') category = fields.Selection([ ('breakfast', 'Breakfast'), + ('lunch', 'Lunch'), + ('dinner', 'Dinner'), ('restaurant', 'Restaurant'), ('laundry', 'Laundry'), ('spa', 'Spa'), @@ -120,7 +122,7 @@ class Service(Workflow, ModelSQL, ModelView): pass def get_count_services(self, name=None): - return len(self.lines) + return sum([line.quantity for line in self.lines]) @classmethod def set_number(cls, services): @@ -287,7 +289,7 @@ class CreateDailyServicesStart(ModelView): __name__ = 'hotel.daily_services.start' kind = fields.Many2One('hotel.service.kind', 'Kind', required=True, domain=[ - ('category', '=', 'breakfast'), + ('category', 'in', ['breakfast', 'dinner', 'lunch']), ('product', '!=', None) ]) date = fields.Date('Date', required=True) @@ -313,26 +315,44 @@ class CreateDailyServices(Wizard): pool = Pool() Service = pool.get('hotel.service') Folio = pool.get('hotel.folio') - - folios = Folio.search([ - ('arrival_date', '<', self.start.date), - ('departure_date', '>=', self.start.date), - ('registration_state', 'in', ['check_in']), - ]) + kind = self.start.kind + if kind == 'breakfast': + dom = [ + ('arrival_date', '<', self.start.date), + ('departure_date', '>=', self.start.date), + ('registration_state', 'in', ['check_in']), + ] + elif kind == 'lunch': + dom = [ + ('arrival_date', '<', self.start.date), + ('departure_date', '>', self.start.date), + ('registration_state', 'in', ['check_in', 'check_out']), + ] + else: # self.kind == 'dinner': + dom = [ + ('arrival_date', '<=', self.start.date), + ('departure_date', '>', self.start.date), + ('registration_state', 'in', ['check_in', 'pending']), + ] + folios = Folio.search(dom) lines_to_create = [] service, = Service.create([{ 'service_date': self.start.date, 'state': 'draft', - 'kind': self.start.kind.id, + 'kind': kind.id, }]) Service.open([service]) - product = self.start.kind.product + product = kind.product for fol in folios: - if not fol.breakfast_included: + booking = fol.booking + if booking.plan == 'no_breakfast': + continue + if kind == 'lunch' and booking.plan in ['half_american', 'bed_breakfast'] : + continue + if kind == 'dinner' and booking.plan == 'bed_breakfast': continue for guest in fol.guests: - lines_to_create.append({ 'folio': fol.id, 'service': service.id, diff --git a/service.xml b/service.xml index 80a6ee9..c126451 100644 --- a/service.xml +++ b/service.xml @@ -143,7 +143,7 @@ this repository contains the full copyright notices and license terms. --> + sequence="60" action="act_service_kind_tree"/> hotel.daily_services.start diff --git a/tryton.cfg b/tryton.cfg index 802ea5d..9ea46cb 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=6.0.26 +version=6.0.27 depends: party company diff --git a/view/service_line_tree.xml b/view/service_line_tree.xml index 86a7c4c..e37eede 100644 --- a/view/service_line_tree.xml +++ b/view/service_line_tree.xml @@ -4,7 +4,7 @@ this repository contains the full copyright notices and license terms. --> - +