This commit is contained in:
oscar alvarez 2022-07-07 23:51:11 -05:00
parent 467eff8966
commit bae79e55af
6 changed files with 172 additions and 3 deletions

View File

@ -37,6 +37,8 @@ def register():
booking.Booking,
booking.BookingDailyStart,
booking.ManagerStart,
booking.BookingStatementLine,
booking.StatementPaymentForm,
housekeeping.Housekeeping,
housekeeping.HousekeepingCleaningType,
party.Party,
@ -97,6 +99,7 @@ def register():
booking.BookingDaily,
booking.UpdateHolder,
booking.Manager,
booking.WizardStatementPayment,
folio.OpenMigration,
folio.GuestsList,
folio.StatisticsByMonth,

View File

@ -129,6 +129,11 @@ class Booking(Workflow, ModelSQL, ModelView):
ota_booking_code = fields.Char('OTA Code', select=True,
states={'invisible': Eval('media') != 'ota'}
)
# payments = fields.One2Many('account.statement.line', 'booking', 'Payments')
# readonly=True)
payments = fields.Many2Many('hotel.booking-statement.line', 'booking',
'statement_line', 'Payments', states=STATES_CHECKIN, readonly=True,
depends=['party'])
vehicles_num = fields.Integer('Vehicles Number', states=STATES,
help="Number of vehicles that bring with guests.")
vehicle_plate = fields.Integer('Vehicle Plate', states=STATES)
@ -193,6 +198,9 @@ class Booking(Workflow, ModelSQL, ModelView):
'do_pay': {
'invisible': Eval('state').in_(['offer', 'cancelled']),
},
'do_payment': {
'invisible': Eval('state').in_(['offer', 'cancelled']),
},
'send_email': {
'invisible': Eval('state') != 'confirmed'
},
@ -307,17 +315,22 @@ class Booking(Workflow, ModelSQL, ModelView):
@classmethod
@ModelView.button_action('hotel.wizard_select_rooms')
def select_rooms(cls, bookings):
def select_rooms(cls, records):
pass
@classmethod
@ModelView.button_action('hotel.wizard_update_holder')
def update_holder(cls, bookings):
def update_holder(cls, records):
pass
@classmethod
@ModelView.button_action('hotel.wizard_booking_advance_voucher')
def do_pay(cls, bookings):
def do_pay(cls, records):
pass
@classmethod
@ModelView.button_action('hotel.wizard_statement_payment_form')
def do_payment(cls, records):
pass
@classmethod
@ -1047,6 +1060,23 @@ class BookingVoucher(ModelSQL):
}])
class BookingStatementLine(ModelSQL):
'Booking - Statement Line'
__name__ = 'hotel.booking-statement.line'
_table = 'hotel_booking_statement_line_rel'
booking = fields.Many2One('hotel.booking', 'Booking',
ondelete='CASCADE', select=True, required=True)
statement_line = fields.Many2One('account.statement.line', 'Statement Line',
ondelete='RESTRICT', required=True)
# @classmethod
# def set_voucher_origin(cls, voucher_id, booking_id):
# cls.create([{
# 'voucher': voucher_id,
# 'booking': booking_id,
# }])
class BookingForecastStart(ModelView):
'Booking Forecast Start'
__name__ = 'hotel.print_booking_forecast.start'
@ -1739,3 +1769,106 @@ class BookingChannelCommision(ModelSQL):
ondelete='CASCADE', select=True, required=True)
booking = fields.Many2One('hotel.booking', 'Booking', ondelete='RESTRICT',
required=True)
class StatementPaymentForm(ModelView):
'Statement Payment Form'
__name__ = 'sale_shop.payment_form.start'
statement = fields.Many2One('account.statement', 'Statement',
required=True, domain=['OR', [
('create_uid.login', '=', Eval('user')),
('state', '=', 'draft')
], [
Eval('user') == 'admin',
('state', '=', 'draft'),
]])
amount_to_pay = fields.Numeric('Amount to Pay', required=True,
digits=(16, Eval('currency_digits', 2)),
depends=['currency_digits'])
currency_digits = fields.Integer('Currency Digits')
voucher = fields.Char('Voucher', states={
'required': Bool(Eval('require_voucher')),
}, depends=['require_voucher'])
party = fields.Many2One('party.party', 'Party')
user = fields.Many2One('res.user', 'User', states={
'readonly': True
})
require_voucher = fields.Boolean('Require Voucher',
depends=['statement'])
@classmethod
def default_require_voucher(cls):
return False
@classmethod
def default_user(cls):
user = Pool().get('res.user')(Transaction().user)
return user.id
@fields.depends('statement', 'require_voucher')
def on_change_with_require_voucher(self):
if self.statement:
return self.statement.journal.require_voucher
return False
class WizardStatementPayment(Wizard):
'Wizard Statement Payment'
__name__ = 'sale_shop.payment_form'
start = StateView('sale_shop.payment_form.start',
'hotel.statement_payment_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Pay', 'pay_', 'tryton-ok', default=True),
])
pay_ = StateTransition()
def default_start(self, fields):
pool = Pool()
Booking = pool.get('hotel.booking')
User = pool.get('res.user')
booking = Booking(Transaction().context['active_id'])
user = User(Transaction().user)
return {
'currency_digits': 2,
'party': booking.party.id,
}
def transition_pay_(self):
pool = Pool()
User = pool.get('res.user')
user = User(Transaction().user)
Booking = pool.get('hotel.booking')
Statement = pool.get('account.statement')
StatementLine = pool.get('account.statement.line')
BookingStatementLine = pool.get('hotel.booking-statement.line')
active_id = Transaction().context.get('active_id', False)
booking = Booking(active_id)
form = self.start
try:
account = form.party.account_receivable.id
except:
raise UserError(gettext(
'sale_shop.party_without_account_receivable'))
if form.amount_to_pay:
line = StatementLine(
statement=form.statement.id,
date=date.today(),
amount=form.amount_to_pay,
party=form.party.id,
account=account,
description=self.start.voucher,
number=self.start.voucher,
voucher=self.start.voucher,
)
line.save()
line.create_move()
BookingStatementLine.create([{
'booking': booking.id,
'statement_line': line.id,
}])
booking.save()
return 'end'

View File

@ -353,5 +353,15 @@ this repository contains the full copyright notices and license terms. -->
</record>
<menuitem parent="hotel.menu_reporting" id="menu_hotel_manager"
action="wizard_hotel_print_manager"/>
<record model="ir.action.wizard" id="wizard_statement_payment_form">
<field name="name">Pay</field>
<field name="wiz_name">sale_shop.payment_form</field>
</record>
<record model="ir.ui.view" id="statement_payment_view_form">
<field name="model">sale_shop.payment_form.start</field>
<field name="type">form</field>
<field name="name">statement_payment_form</field>
</record>
</data>
</tryton>

View File

@ -12,6 +12,8 @@ depends:
party_personal
commission
dash
account_statement
sale_shop
xml:
hotel.xml
configuration.xml

View File

@ -31,12 +31,16 @@ this repository contains the full copyright notices and license terms. -->
<button name="select_rooms" string="Select Rooms"
icon="tryton-open" colspan="2"/>
<button name="do_pay" string="Do Pay" icon="tryton-open"/>
<button name="do_payment" string="Pay / Advance" icon="tryton-open"/>
<button name="send_email" string="Send Email" icon="tryton-open"/>
<notebook colspan="6">
<page string="Lines" id="lines">
<field name="lines" colspan="4"
view_ids="hotel.booking_folio_view_tree"/>
</page>
<page string="Payments" id="payments">
<field name="payments" colspan="4"/>
</page>
<page string="Advances and Invoices" id="invoices_vouchers">
<field name="vouchers" colspan="4"/>
<field name="invoices" colspan="4"/>

View File

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!-- This file is part of the sale_payment module for Tryton.
The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<form>
<label name="statement"/>
<field name="statement" widget="selection"/>
<label name="user"/>
<field name="user" widget="selection"/>
<label name="amount_to_pay"/>
<field name="amount_to_pay"/>
<label name="party"/>
<field name="party"/>
<label name="voucher"/>
<field name="voucher"/>
<field name="require_voucher" invisible="1"/>
</form>