[ADD] Optional Check Auto payment invoice on Wizard invoicing

This commit is contained in:
Dario Lodeiros
2019-04-05 12:26:14 +02:00
parent 467f667b9a
commit 8bf40768b1
4 changed files with 31 additions and 22 deletions

View File

@@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
19 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
20 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
21 user_access_account_partial_reconcile user_accessaccount_partial_reconcile account.model_account_partial_reconcile hotel.group_hotel_user 1 1 1 1
22 user_access_hotel_cancelation_rule user_access_hotel_cancelation_rule model_hotel_cancelation_rule base.group_user 1 0 0 0
23 manager_access_hotel_floor manager_access_hotel_floor model_hotel_floor hotel.group_hotel_manager 1 1 1 1
24 manager_access_hotel_amenity manager_access_hotel_amenity model_hotel_amenity hotel.group_hotel_manager 1 1 1 1
25 manager_access_hotel_amenity_type manager_access_hotel_amenity_type model_hotel_amenity_type hotel.group_hotel_manager 1 1 1 1
39 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
40 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
41 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
42 manager_access_hotel_cancelation_rule manager_access_hotel_cancelation_rule model_hotel_cancelation_rule base.group_user 1 1 1 1
43 call_access_hotel_floor call_access_hotel_floor model_hotel_floor hotel.group_hotel_call 1 0 0 0
44 call_access_hotel_amenity call_access_hotel_amenity model_hotel_amenity hotel.group_hotel_call 1 0 0 0
45 call_access_hotel_amenity_type call_access_hotel_amenity_type model_hotel_amenity_type hotel.group_hotel_call 1 0 0 0
59 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
60 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
61 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
62 call_access_hotel_cancelation_rule call_access_hotel_cancelation_rule model_hotel_cancelation_rule base.group_user 1 0 0 0

View File

@@ -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):

View File

@@ -37,7 +37,7 @@
<field name="name" />
<field name="state" />
<field name="pending_amount" />
<field name="amount_total" />
<field name="amount_total" />
</tree>
</field>
<field name="reservation_ids" widget="many2many_tags"
@@ -65,6 +65,7 @@
<field name="price_total" />
</tree>
</field>
<field name="auto_invoice" />
</group>
<footer>
<button name="create_invoices" string="Create and View Invoices" type="object"

View File

@@ -4,11 +4,11 @@
import time
import logging
from datetime import datetime, timedelta
from openerp.exceptions import ValidationError
from openerp.tools import (
from odoo.exceptions import ValidationError
from odoo.tools import (
DEFAULT_SERVER_DATE_FORMAT,
DEFAULT_SERVER_DATETIME_FORMAT)
from openerp import models, fields, api, _
from odoo import models, fields, api, _
import odoo.addons.decimal_precision as dp
_logger = logging.getLogger(__name__)