diff --git a/pms/models/account_payment.py b/pms/models/account_payment.py index 159407ee0e..f092620da9 100644 --- a/pms/models/account_payment.py +++ b/pms/models/account_payment.py @@ -4,7 +4,7 @@ from dateutil.relativedelta import relativedelta -from odoo import api, fields, models +from odoo import _, api, fields, models class AccountPayment(models.Model): @@ -113,7 +113,15 @@ def action_draft(self): lambda inv: inv._is_downpayment() ) if downpayment_invoices.state == "posted": - downpayment_invoices._reverse_moves(cancel=True) + default_values_list = [ + { + "ref": _(f'Reversal of: {move.name + " - " + move.ref}'), + } + for move in downpayment_invoices + ] + downpayment_invoices._reverse_moves( + default_values_list, cancel=True + ) else: downpayment_invoices.unlink() return super(AccountPayment, self).action_draft() diff --git a/pms/models/pms_folio.py b/pms/models/pms_folio.py index c78ae5f9ee..94aaee21ce 100644 --- a/pms/models/pms_folio.py +++ b/pms/models/pms_folio.py @@ -1954,17 +1954,6 @@ def _create_invoices( month_day, ) if invoice_date: - if ( - self.company_id.period_lock_date - and invoice_date < self.company_id.period_lock_date - and not self.user_has_groups("account.group_account_manager") - ): - raise UserError( - _( - "The period to create this invoice is locked. " - "Please contact your administrator to unlock it." - ) - ) if invoice_date < datetime.date.today() and not self._context.get( "autoinvoice" ): @@ -2212,7 +2201,7 @@ def do_payment( date=date, ) self.env["account.bank.statement.line"].sudo().create(line) - folio.message_post( + folio.sudo().message_post( body=_( """Payment: %s by %s""", amount, @@ -2299,7 +2288,7 @@ def do_refund( ) self.env["account.bank.statement.line"].sudo().create(line) - folio.message_post( + folio.sudo().message_post( body=_( """Refund: %s by %s""", amount, diff --git a/pms/models/pms_property.py b/pms/models/pms_property.py index da2a37bb23..1b0c055cb2 100644 --- a/pms/models/pms_property.py +++ b/pms/models/pms_property.py @@ -708,7 +708,7 @@ def autoinvoicing(self, offset=0, with_delay=False, autocommit=False): if any([res.state != "cancel" for res in folio.reservation_ids]): folios_to_invoice += folio else: - folio.message_post( + folio.sudo().message_post( body=_( "Not invoiced due to pending amounts and cancelled reservations" ) @@ -744,9 +744,15 @@ def autoinvoicing(self, offset=0, with_delay=False, autocommit=False): downpayment_invoices = downpayments_invoices_to_reverse.mapped("move_id") if downpayment_invoices: for downpayment_invoice in downpayment_invoices: + default_values_list = [ + { + "ref": _(f'Reversal of: {move.name + " - " + move.ref}'), + } + for move in downpayment_invoice + ] downpayment_invoice.with_context( {"sii_refund_type": "I"} - )._reverse_moves(cancel=True) + )._reverse_moves(default_values_list, cancel=True) downpayment_invoice.message_post( body=_( """ @@ -830,7 +836,7 @@ def autoinvoice_folio(self, folio): "maximum amount allowed for simplified invoices, and dont have " "enought data in hosts to create a normal invoice." ) - folio.message_post(body=mens) + folio.sudo().message_post(body=mens) raise ValidationError(mens) for downpayment in downpayments.filtered( lambda d: d.default_invoice_to == invoice.partner_id @@ -852,11 +858,17 @@ def autoinvoice_folio(self, folio): ).invoice_lines.mapped("move_id") ).filtered(lambda i: i.is_simplified_invoice) if downpayment_invoices: + default_values_list = [ + { + "ref": _(f'Reversal of: {move.name + " - " + move.ref}'), + } + for move in downpayment_invoices + ] downpayment_invoices.with_context( {"sii_refund_type": "I"} - )._reverse_moves(cancel=True) + )._reverse_moves(default_values_list, cancel=True) except Exception as e: - folio.message_post(body=_("Error in autoinvoicing folio: " + str(e))) + folio.sudo().message_post(body=_("Error in autoinvoicing folio: " + str(e))) @api.constrains("journal_normal_invoice_id") def _check_journal_normal_invoice(self): diff --git a/pms/views/pms_reservation_views.xml b/pms/views/pms_reservation_views.xml index 2f6dbb7923..34cd058aca 100644 --- a/pms/views/pms_reservation_views.xml +++ b/pms/views/pms_reservation_views.xml @@ -14,7 +14,6 @@