Add transfer_to_folio, sale wizard, current folios
This commit is contained in:
parent
a4ce7fbd28
commit
020782268c
|
@ -85,6 +85,8 @@ def register():
|
|||
guest.TagGuest,
|
||||
stock.Move,
|
||||
sale.InvoiceIncomeDailyStart,
|
||||
sale.Sale,
|
||||
sale.SaleTransferFolioStart,
|
||||
service.Service,
|
||||
service.ServiceLine,
|
||||
service.ServiceKind,
|
||||
|
@ -152,6 +154,7 @@ def register():
|
|||
room.Housekeeping,
|
||||
housekeeping.HousekeepingSchedule,
|
||||
sale.InvoiceIncomeDaily,
|
||||
sale.SaleTransferFolio,
|
||||
party.CreateGuest,
|
||||
operation.NightAuditWizard,
|
||||
siat.SiatSyncWizard,
|
||||
|
|
|
@ -14,41 +14,50 @@
|
|||
</head>
|
||||
<body>
|
||||
<div style="text-align: center;">
|
||||
<img alt="image_logo" src="{{record.company.logo_link}}" />
|
||||
<img
|
||||
style="max-width: 170px;"
|
||||
alt="image_logo"
|
||||
src="{{record.company.logo_link}}"
|
||||
/>
|
||||
</div>
|
||||
<br />
|
||||
<p>Estimado cliente</p>
|
||||
<p>Estimado cliente / Dear customer</p>
|
||||
<p><b>{{record.party.rec_name}}</b></p>
|
||||
<br />
|
||||
<p>
|
||||
Nuestro hotel {{record.company.party.name}} ha recibido un nuevo pago! a
|
||||
continuación encontrará el detalle de la transacción:
|
||||
Hemos recibido un nuevo pago, a continuación encontrará el detalle de la
|
||||
transacción y el estado de cuenta / We have received a new payment, below
|
||||
you will find the details of the transaction and account statement:
|
||||
</p>
|
||||
<br />
|
||||
<table class="default">
|
||||
<tr>
|
||||
<td style="background-color: black; height: 20px; min-width: 150px;" />
|
||||
<td style="background-color: black; height: 20px; min-width: 150px;" />
|
||||
<td
|
||||
style="background-color: darkgray; height: 20px; min-width: 190px;"
|
||||
/>
|
||||
<td
|
||||
style="background-color: darkgray; height: 20px; min-width: 190px;"
|
||||
/>
|
||||
</tr>
|
||||
{% for pay in record.payments %}
|
||||
<tr>
|
||||
<td style="padding-left: 3px;">Fecha:</td>
|
||||
<td style="padding: 3px 5px;">Fecha:</td>
|
||||
<td style="text-align: right; padding-right: 3px;">{{pay.date}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 3px;">Medio de Pago:</td>
|
||||
<td style="padding: 3px 5px;">Medio de Pago:</td>
|
||||
<td style="text-align: right; padding-right: 3px;">
|
||||
{{pay.statement.journal.name}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 3px;">Valor del Pago:</td>
|
||||
<td style="padding: 3px 5px;">Valor del Pago:</td>
|
||||
<td style="text-align: right; padding-right: 3px;">
|
||||
{{ "{:,.2f}".format(pay.amount)}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 3px;">No. Voucher:</td>
|
||||
<td style="padding: 3px 5px;">No. Voucher:</td>
|
||||
<td style="text-align: right; padding-right: 3px;">{{pay.number}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -56,18 +65,45 @@
|
|||
<td style="background-color: darkseagreen; height: 10px;" />
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td style="background-color: aliceblue; height: 10px;">
|
||||
Total Pagado:
|
||||
</td>
|
||||
<td
|
||||
style="
|
||||
background-color: aliceblue;
|
||||
height: 10px;
|
||||
padding: 3px 5px;
|
||||
text-align: right;
|
||||
"
|
||||
>
|
||||
{{"{:,.2f}".format(record.total_advances)}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td
|
||||
style="background-color: aliceblue; height: 10px; padding: 3px 5px;"
|
||||
>
|
||||
Pendiente de Pago:
|
||||
</td>
|
||||
<td
|
||||
style="
|
||||
background-color: aliceblue;
|
||||
height: 10px;
|
||||
padding: 3px 5px;
|
||||
text-align: right;
|
||||
"
|
||||
>
|
||||
{{"{:,.2f}".format(record.pending_to_pay)}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<p><b>Información Relevante / Relevant Information</b></p>
|
||||
<p>
|
||||
{{record.company.party.commercial_name}} tiene aprobados los protocolos de
|
||||
bioseguridad por la autoridad local.
|
||||
</p>
|
||||
<br />
|
||||
<p>Atentamente / Best regards,</p>
|
||||
<p>
|
||||
<b
|
||||
>Servicio al Cliente / Service Customer |
|
||||
>Servicio al Cliente / Customer Service |
|
||||
{{record.company.party.commercial_name}}</b
|
||||
>
|
||||
</p>
|
||||
|
@ -90,7 +126,7 @@
|
|||
</div>
|
||||
<p style="text-align: center;">
|
||||
<a href="https://www.presik.com" style="color: #554400ff;">
|
||||
Powered by presik.com
|
||||
Hotels powered by presik.com
|
||||
</a>
|
||||
</p>
|
||||
</body>
|
||||
|
|
34
folio.py
34
folio.py
|
@ -1594,7 +1594,7 @@ class FolioCharge(Workflow, ModelSQL, ModelView):
|
|||
('type', '=', 'storage')], states={
|
||||
'readonly': Bool(Eval('invoice_line')),
|
||||
})
|
||||
move = fields.Many2One('stock.move', 'Move')
|
||||
move = fields.Many2One('stock.move', 'Move', states={'readonly': True})
|
||||
status = fields.Selection([
|
||||
('paid', 'Paid'),
|
||||
('pending', 'Pending'),
|
||||
|
@ -1614,6 +1614,7 @@ class FolioCharge(Workflow, ModelSQL, ModelView):
|
|||
],
|
||||
],
|
||||
)
|
||||
origin = fields.Reference('Origin', selection='get_origin', readonly=True)
|
||||
|
||||
# @classmethod
|
||||
# def delete(cls, records):
|
||||
|
@ -1652,6 +1653,18 @@ class FolioCharge(Workflow, ModelSQL, ModelView):
|
|||
number = config.charge_sequence.get()
|
||||
cls.write([charge], {'number': number})
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
'Return list of Model names for origin Reference'
|
||||
return ['sale.sale']
|
||||
|
||||
@classmethod
|
||||
def get_origin(cls):
|
||||
Model = Pool().get('ir.model')
|
||||
get_name = Model.get_name
|
||||
models = cls._get_origin()
|
||||
return [(None, '')] + [(m, get_name(m)) for m in models]
|
||||
|
||||
@classmethod
|
||||
def _add_taxes(cls, vlist):
|
||||
pool = Pool()
|
||||
|
@ -1710,6 +1723,25 @@ class FolioCharge(Workflow, ModelSQL, ModelView):
|
|||
return self.quantity * self.unit_price
|
||||
return 0
|
||||
|
||||
@classmethod
|
||||
def get_current_folios(cls):
|
||||
res = cls.search_read([
|
||||
('registration_state', '=', 'check_in'),
|
||||
('arrival_date', '<=', date.today()),
|
||||
('departure_date', '>=', date.today()),
|
||||
('charges_blocked', '=', False),
|
||||
], fields_names=[
|
||||
'booking.number',
|
||||
'main_guest.name',
|
||||
'main_guest.id_number',
|
||||
'room.code',
|
||||
'product.template.name',
|
||||
'registration_state',
|
||||
'arrival_date',
|
||||
'departure_date',
|
||||
])
|
||||
return res
|
||||
|
||||
def get_unit_price_w_tax(self, name=None):
|
||||
Tax = Pool().get('account.tax')
|
||||
res = self.unit_price or 0
|
||||
|
|
15
hotel.xml
15
hotel.xml
|
@ -112,5 +112,20 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="sequence_type" ref="sequence_type_hotel"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="sale_transfer_to_folio_start_view_form">
|
||||
<field name="model">sale.transfer_to_folio.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">sale_transfer_to_folio_form</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="act_sale_transfer_to_folio">
|
||||
<field name="name">Transfer to Folio</field>
|
||||
<field name="wiz_name">sale.transfer_to_folio</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="act_sale_transfer_to_folio_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">sale.sale,-1</field>
|
||||
<field name="action" ref="act_sale_transfer_to_folio"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
85
sale.py
85
sale.py
|
@ -1,17 +1,68 @@
|
|||
# This file is part of Presik. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from datetime import datetime
|
||||
from datetime import datetime, date
|
||||
from decimal import Decimal
|
||||
|
||||
from trytond.pool import Pool
|
||||
from trytond.wizard import Wizard, StateView, Button, StateReport
|
||||
from trytond.i18n import gettext
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.report import Report
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.wizard import (
|
||||
Wizard, StateView, Button, StateReport, StateTransition)
|
||||
|
||||
_ZERO = Decimal(0)
|
||||
|
||||
|
||||
class Sale(metaclass=PoolMeta):
|
||||
__name__ = 'sale.sale'
|
||||
folio = fields.Many2One('hotel.folio', 'Folio', states={
|
||||
'readonly': True,
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Sale, cls).__setup__()
|
||||
cls.state.selection.append(('transfered', 'Transfered'))
|
||||
|
||||
@classmethod
|
||||
def transfer_to_folio(cls, sale_id, folio_id):
|
||||
sale, = cls.browse([sale_id])
|
||||
Charge = Pool().get('hotel.folio.charge')
|
||||
Folio = Pool().get('hotel.folio')
|
||||
to_create = []
|
||||
folio = Folio(folio_id)
|
||||
number = folio.booking.number
|
||||
if folio.charges_blocked:
|
||||
raise UserError(gettext('hotel.msg_folio_charges_blocked'))
|
||||
if folio.registration_state == 'check_out':
|
||||
raise UserError(gettext('hotel.msg_folio_closed'))
|
||||
for line in sale.lines:
|
||||
to_create.append({
|
||||
'folio': folio_id,
|
||||
'product': line.product.id,
|
||||
'description': line.description,
|
||||
'quantity': line.quantity,
|
||||
'date_service': line.sale.sale_date,
|
||||
'unit_price': line.unit_price,
|
||||
'kind': 'product',
|
||||
'order': number,
|
||||
'status': 'pending',
|
||||
'origin': f'sale.sale,{sale_id}',
|
||||
})
|
||||
Charge.create(to_create)
|
||||
|
||||
cls.write([sale], {
|
||||
'state': 'transfered',
|
||||
'folio': folio_id,
|
||||
'invoice_method': 'manual',
|
||||
'shipment_method': 'manual',
|
||||
'reference': number,
|
||||
})
|
||||
return 'ok'
|
||||
|
||||
|
||||
class InvoiceIncomeDailyStart(ModelView):
|
||||
'Invoice Income Daily Start'
|
||||
__name__ = 'hotel.invoice_income_daily.start'
|
||||
|
@ -221,3 +272,31 @@ class InvoiceSimplifiedReport(Report):
|
|||
|
||||
report_context['company'] = Company(Transaction().context['company'])
|
||||
return report_context
|
||||
|
||||
|
||||
class SaleTransferFolioStart(ModelView):
|
||||
'Sale Transfer Folio Start'
|
||||
__name__ = 'sale.transfer_to_folio.start'
|
||||
folio = fields.Many2One('hotel.folio', 'Folio', domain=[
|
||||
('registration_state', '=', 'check_in'),
|
||||
('arrival_date', '<=', date.today()),
|
||||
('departure_date', '>=', date.today()),
|
||||
])
|
||||
|
||||
|
||||
class SaleTransferFolio(Wizard):
|
||||
'Sale Transfer Folio'
|
||||
__name__ = 'sale.transfer_to_folio'
|
||||
start = StateView(
|
||||
'sale.transfer_to_folio.start',
|
||||
'hotel.sale_transfer_to_folio_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Ok', 'accept', 'tryton-ok', default=True),
|
||||
])
|
||||
accept = StateTransition()
|
||||
|
||||
def transition_accept(self):
|
||||
Sale = Pool().get('sale.sale')
|
||||
sale_id = Transaction().context['active_id']
|
||||
Sale.transfer_to_folio(sale_id, self.start.folio.id)
|
||||
return 'end'
|
||||
|
|
5
sale.xml
5
sale.xml
|
@ -3,6 +3,11 @@
|
|||
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="sale_view_form">
|
||||
<field name="model">sale.sale</field>
|
||||
<field name="inherit" ref="sale.sale_view_form"/>
|
||||
<field name="name">sale_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.report" id="report_invoice_income_daily">
|
||||
<field name="name">Report Invoice Income Daily</field>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.112
|
||||
version=6.0.113
|
||||
depends:
|
||||
party
|
||||
company
|
||||
|
|
|
@ -41,4 +41,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="move"/>
|
||||
<label name="analytic_account"/>
|
||||
<field name="analytic_account"/>
|
||||
<label name="origin"/>
|
||||
<field name="origin"/>
|
||||
</form>
|
||||
|
|
|
@ -13,5 +13,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="order"/>
|
||||
<field name="invoice_to"/>
|
||||
<field name="state" expand="1"/>
|
||||
<field name="status"/>
|
||||
<field name="status" expand="1"/>
|
||||
<field name="origin" expand="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form/notebook/page[@id='other']/field[@name='shipping_date']"
|
||||
position="after">
|
||||
<label name="folio"/>
|
||||
<field name="folio"/>
|
||||
</xpath>
|
||||
</data>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<label name="folio" />
|
||||
<field name="folio" />
|
||||
</form>
|
Loading…
Reference in New Issue