From ec530288c8fe6654d5b4a20f58534066b0629cb8 Mon Sep 17 00:00:00 2001 From: oscar alvarez Date: Fri, 28 Oct 2022 11:44:14 -0500 Subject: [PATCH] Fix --- folio.py | 39 +++++++++++++++++++++++++++++-------- message.xml | 10 +++++----- patch.sql | 2 ++ service.py | 5 +++++ view/board_folio_form.xml | 2 ++ view/booking_folio_form.xml | 6 ++++-- view/folio_charge_form.xml | 4 ++-- view/folio_charge_tree.xml | 2 +- 8 files changed, 52 insertions(+), 18 deletions(-) diff --git a/folio.py b/folio.py index ec45379..f54c4c3 100644 --- a/folio.py +++ b/folio.py @@ -174,6 +174,7 @@ class Folio(ModelSQL, ModelView): )}, help="Number of persons in house setted manually.") invoices = fields.Function(fields.Many2Many('account.invoice', None, None, 'Invoices'), 'get_invoices') + charges_blocked = fields.Boolean('Charges Blocked') @classmethod def __setup__(cls): @@ -1153,9 +1154,11 @@ class FolioCharge(Workflow, ModelSQL, ModelView): digits=(16, 2)), 'get_amount') taxed_amount = fields.Function(fields.Numeric('Amount with Tax', digits=(16, 2)), 'get_taxed_amount') + # Remove for deprecation to_invoice = fields.Boolean('To Invoice', states={ 'invisible': Bool(Eval('invoice_line')), }, depends=['invoice_line']) + #################### storage = fields.Many2One('stock.location', 'Storage', domain=[('type', '=', 'storage')], states={ 'readonly': Bool(Eval('invoice_line')), @@ -1168,20 +1171,40 @@ class FolioCharge(Workflow, ModelSQL, ModelView): @classmethod def delete(cls, records): - pass + target = [] + for rec in records: + if rec.invoice_line or rec.move: + continue + target.append(rec) + super().delete(target) @classmethod def __setup__(cls): super(FolioCharge, cls).__setup__() cls._buttons.update({ - 'transfer': { - 'invisible': True, - }, + # 'transfer': { + # 'invisible': True, + # }, 'bill': { 'invisible': Eval('invoice_state') is not None, }, }) + @classmethod + def check_create(cls, vlist): + Folio = Pool().get('hotel.folio') + for value in vlist: + folio_id = value.get('folio', None) + if folio_id: + folio = Folio(folio_id) + if folio.charges_blocked: + raise UserError(gettext('hotel.msg_folio_charges_blocked')) + + @classmethod + def create(cls, vlist): + cls.check_create(vlist) + return super().create(vlist) + @staticmethod def default_quantity(): return 1 @@ -1256,10 +1279,10 @@ class FolioCharge(Workflow, ModelSQL, ModelView): def bill(cls, records): cls.create_sales(records) - @classmethod - @ModelView.button_action('hotel.wizard_operation_line_transfer') - def transfer(cls, records): - pass + # @classmethod + # @ModelView.button_action('hotel.wizard_operation_line_transfer') + # def transfer(cls, records): + # pass @fields.depends('unit_price', 'folio', 'product', 'description', '_parent_folio.main_guest') diff --git a/message.xml b/message.xml index 1453997..b07bb7c 100644 --- a/message.xml +++ b/message.xml @@ -93,14 +93,14 @@ this repository contains the full copyright notices and license terms. --> The accommodation isn't paid! - + + The folio(s) has the charges blocked! + It can not check-in of future dates! - + diff --git a/patch.sql b/patch.sql index b532661..ab3a333 100644 --- a/patch.sql +++ b/patch.sql @@ -38,3 +38,5 @@ UPDATE account_invoice_line AS ail ON ta.booking_id=fo.booking ) AS st WHERE ail.id=st.line_id AND ail.origin ILIKE 'hotel.booking%'; + +ALTER TABLE account_invoice_line DROP COLUMN origin2; diff --git a/service.py b/service.py index abf9c5c..dd3b462 100644 --- a/service.py +++ b/service.py @@ -255,6 +255,11 @@ class ServiceLine(Workflow, ModelSQL, ModelView): folio = folios[0] invoice_to = None + + if folio.charges_blocked: + raise UserError( + gettext('hotel.msg_folio_charges_blocked') + ) if folio.booking.channel: invoice_to = self.folio.main_guest.id diff --git a/view/board_folio_form.xml b/view/board_folio_form.xml index e22d08e..e3e0f2b 100644 --- a/view/board_folio_form.xml +++ b/view/board_folio_form.xml @@ -54,6 +54,8 @@ this repository contains the full copyright notices and license terms. --> +