diff --git a/hotel/security/ir.model.access.csv b/hotel/security/ir.model.access.csv index 3b8db2475..af083d8f4 100644 --- a/hotel/security/ir.model.access.csv +++ b/hotel/security/ir.model.access.csv @@ -19,6 +19,7 @@ user_access_hotel_board_service_room_type,user_access_hotel_board_service_room_t user_access_hotel_board_service_room_type_line,user_access_hotel_board_service_room_type_line,model_hotel_board_service_room_type_line,hotel.group_hotel_user,1,0,0,0 user_access_hotel_board_service_line,user_access_hotel_board_service_line,model_hotel_board_service_line,hotel.group_hotel_user,1,0,0,0 user_access_account_partial_reconcile,user_accessaccount_partial_reconcile,account.model_account_partial_reconcile,hotel.group_hotel_user,1,1,1,1 +user_access_hotel_cancelation_rule,user_access_hotel_cancelation_rule,model_hotel_cancelation_rule,base.group_user,1,0,0,0 manager_access_hotel_floor,manager_access_hotel_floor,model_hotel_floor,hotel.group_hotel_manager,1,1,1,1 manager_access_hotel_amenity,manager_access_hotel_amenity,model_hotel_amenity,hotel.group_hotel_manager,1,1,1,1 manager_access_hotel_amenity_type,manager_access_hotel_amenity_type,model_hotel_amenity_type,hotel.group_hotel_manager,1,1,1,1 @@ -38,6 +39,7 @@ manager_access_hotel_room_type,manager_access_hotel_room_type,model_hotel_room_t manager_access_hotel_board_service_room_type,manager_access_hotel_board_service_room_type,model_hotel_board_service_room_type,hotel.group_hotel_manager,1,1,1,1 manager_access_hotel_board_service_room_type_line,manager_access_hotel_board_service_room_type_line,model_hotel_board_service_room_type_line,hotel.group_hotel_manager,1,1,1,1 manager_access_hotel_board_service_line,manager_access_hotel_board_service_line,model_hotel_board_service_line,hotel.group_hotel_manager,1,1,1,1 +manager_access_hotel_cancelation_rule,manager_access_hotel_cancelation_rule,model_hotel_cancelation_rule,base.group_user,1,1,1,1 call_access_hotel_floor,call_access_hotel_floor,model_hotel_floor,hotel.group_hotel_call,1,0,0,0 call_access_hotel_amenity,call_access_hotel_amenity,model_hotel_amenity,hotel.group_hotel_call,1,0,0,0 call_access_hotel_amenity_type,call_access_hotel_amenity_type,model_hotel_amenity_type,hotel.group_hotel_call,1,0,0,0 @@ -57,3 +59,4 @@ call_access_hotel_room_type,call_access_hotel_room_type,model_hotel_room_type,ho call_access_hotel_board_service_room_type,call_access_hotel_board_service_room_type,model_hotel_board_service_room_type,hotel.group_hotel_call,1,0,0,0 call_access_hotel_board_service_room_type_line,call_access_hotel_board_service_room_type_line,model_hotel_board_service_room_type_line,hotel.group_hotel_call,1,0,0,0 call_access_hotel_board_service_line,call_access_hotel_board_service_line,model_hotel_board_service_line,hotel.group_hotel_call,1,0,0,0 +call_access_hotel_cancelation_rule,call_access_hotel_cancelation_rule,model_hotel_cancelation_rule,base.group_user,1,0,0,0 diff --git a/hotel/wizard/folio_make_invoice_advance.py b/hotel/wizard/folio_make_invoice_advance.py index ab6e4b59e..6d76c7a6e 100644 --- a/hotel/wizard/folio_make_invoice_advance.py +++ b/hotel/wizard/folio_make_invoice_advance.py @@ -4,7 +4,7 @@ import time from odoo.tools import DEFAULT_SERVER_DATE_FORMAT from odoo import api, fields, models, _ import odoo.addons.decimal_precision as dp -from odoo.exceptions import UserError +from odoo.exceptions import UserError, ValidationError from datetime import timedelta @@ -66,6 +66,9 @@ class FolioAdvancePaymentInv(models.TransientModel): ('fixed', 'Down payment (fixed amount)') ], string='What do you want to invoice?', default=_get_advance_payment_method, required=True) + auto_invoice = fields.Boolean('Auto Payment Invoice', + default=True, + help='Automatic validation and link payment to invoice') count = fields.Integer(default=_count, string='# of Orders') folio_ids = fields.Many2many("hotel.folio", string="Folios", help="Folios grouped", @@ -172,23 +175,25 @@ class FolioAdvancePaymentInv(models.TransientModel): @api.model def _validate_invoices(self, invoice): - invoice.action_invoice_open() - payment_ids = self.folio_ids.mapped('payment_ids.id') - domain = [('account_id', '=', invoice.account_id.id), - ('payment_id', 'in', payment_ids), ('reconciled', '=', False), - '|', ('amount_residual', '!=', 0.0), - ('amount_residual_currency', '!=', 0.0)] - if invoice.type in ('out_invoice', 'in_refund'): - domain.extend([('credit', '>', 0), ('debit', '=', 0)]) - type_payment = _('Outstanding credits') - else: - domain.extend([('credit', '=', 0), ('debit', '>', 0)]) - type_payment = _('Outstanding debits') - info = {'title': '', 'outstanding': True, 'content': [], 'invoice_id': invoice.id} - lines = self.env['account.move.line'].search(domain) - currency_id = invoice.currency_id - for line in lines: - invoice.assign_outstanding_credit(line.id) + if self.auto_invoice: + invoice.action_invoice_open() + payment_ids = self.folio_ids.mapped('payment_ids.id') + domain = [('account_id', '=', invoice.account_id.id), + ('payment_id', 'in', payment_ids), ('reconciled', '=', False), + '|', ('amount_residual', '!=', 0.0), + ('amount_residual_currency', '!=', 0.0)] + if invoice.type in ('out_invoice', 'in_refund'): + domain.extend([('credit', '>', 0), ('debit', '=', 0)]) + type_payment = _('Outstanding credits') + else: + domain.extend([('credit', '=', 0), ('debit', '>', 0)]) + type_payment = _('Outstanding debits') + info = {'title': '', 'outstanding': True, 'content': [], 'invoice_id': invoice.id} + lines = self.env['account.move.line'].search(domain) + currency_id = invoice.currency_id + for line in lines: + invoice.assign_outstanding_credit(line.id) + return True @api.multi def create_invoices(self): diff --git a/hotel/wizard/folio_make_invoice_advance_views.xml b/hotel/wizard/folio_make_invoice_advance_views.xml index 690803d57..bd25e4f94 100644 --- a/hotel/wizard/folio_make_invoice_advance_views.xml +++ b/hotel/wizard/folio_make_invoice_advance_views.xml @@ -37,7 +37,7 @@ - + +