mirror of
https://bitbucket.org/presik/trytonpsk-hotel.git
synced 2023-12-14 07:52:52 +01:00
Fix
This commit is contained in:
parent
5360c307f9
commit
54c6ac8b75
|
@ -22,6 +22,7 @@ from . import operation
|
|||
from . import ir
|
||||
from . import email_activity
|
||||
from . import guest
|
||||
from . import commission
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -87,6 +88,7 @@ def register():
|
|||
room.HotelTask,
|
||||
room.HousekeepingStart,
|
||||
operation.NightAuditStart,
|
||||
commission.Commission,
|
||||
module='hotel', type_='model')
|
||||
Pool.register(
|
||||
booking.BookingReport,
|
||||
|
|
44
booking.py
44
booking.py
|
@ -774,6 +774,50 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
Move.create(to_create)
|
||||
Move.do(self.moves)
|
||||
|
||||
def set_offset_commssion_move(self):
|
||||
pool = Pool()
|
||||
Move = pool.get('account.move')
|
||||
Period = pool.get('account.period')
|
||||
MoveLine = pool.get('account.move.line')
|
||||
if not self.commission:
|
||||
return
|
||||
|
||||
period_id = Period.find(self.company.id, date=date.today())
|
||||
description = self.booking.number
|
||||
if self.ota_booking_code:
|
||||
description += ' | ' + self.ota_booking_code
|
||||
move, = Move.create([{
|
||||
'journal': self.journal.id,
|
||||
'period': period_id,
|
||||
'date': date.today(),
|
||||
# 'origin': str(self),
|
||||
'state': 'draft',
|
||||
'description': description,
|
||||
}])
|
||||
|
||||
to_create = []
|
||||
party = self.channel.agent.party
|
||||
to_create.append({
|
||||
'description': description,
|
||||
'account': party.account_receivable_used,
|
||||
'debit': 0,
|
||||
'credit': self.commission,
|
||||
'move': move.id,
|
||||
})
|
||||
to_create.append({
|
||||
'description': description,
|
||||
'account': party.account_payable_used,
|
||||
'debit': self.commission,
|
||||
'credit': 0,
|
||||
'move': move.id,
|
||||
})
|
||||
MoveLine.create(to_create)
|
||||
self.offset_move = move.id
|
||||
self.save()
|
||||
for line in move.lines:
|
||||
if line.credit > 0:
|
||||
return line.id
|
||||
|
||||
def get_move(self, charge):
|
||||
'''
|
||||
Return stock move for charge according a storage
|
||||
|
|
8
commission.py
Normal file
8
commission.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
|
||||
class Commission(metaclass=PoolMeta):
|
||||
__name__ = 'commission'
|
||||
offset_move = fields.Many2One('account.move', 'Offset Move')
|
19
commission.xml
Normal file
19
commission.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?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. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="commission_view_form">
|
||||
<field name="model">commission</field>
|
||||
<field name="inherit" ref="commission.commission_view_form"/>
|
||||
<field name="name">commission_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="commission_view_list">
|
||||
<field name="model">commission</field>
|
||||
<field name="inherit" ref="commission.commission_view_form"/>
|
||||
<field name="name">commission_list</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
4
folio.py
4
folio.py
|
@ -139,8 +139,8 @@ class Folio(ModelSQL, ModelView):
|
|||
'get_num_guests')
|
||||
num_adults = fields.Function(fields.Integer('Num. Adults'),
|
||||
'get_num_guests')
|
||||
stock_moves = fields.Function(fields.One2Many('stock.move', 'origin', 'Moves',
|
||||
readonly=True), 'get_stock_moves')
|
||||
stock_moves = fields.Function(fields.One2Many('stock.move', 'origin',
|
||||
'Moves'), 'get_stock_moves')
|
||||
vehicle_plate = fields.Char('Vehicle Plate')
|
||||
taxes = fields.Many2Many('hotel.folio-account.tax', 'folio', 'tax', 'Taxes',
|
||||
order=[('tax.sequence', 'ASC'), ('tax.id', 'ASC')],
|
||||
|
|
10
invoice.py
10
invoice.py
|
@ -34,9 +34,13 @@ class Invoice(metaclass=PoolMeta):
|
|||
@classmethod
|
||||
def post(cls, invoices):
|
||||
super(Invoice, cls).post(invoices)
|
||||
if invoice.type == 'out' and invoice.agent:
|
||||
cls.set_advances_from_origin(invoice)
|
||||
# for invoice in invoices:
|
||||
for invoice in invoices:
|
||||
if invoice.type == 'out' and invoice.origin and \
|
||||
invoice.origin.__class__ == 'hotel.booking':
|
||||
booking = invoice.origin
|
||||
move_line = booking.set_offset_commssion_move()
|
||||
cls.write([invoice], {'payment_lines': [('add', [move_line])]})
|
||||
# cls.set_advances_from_origin(invoice)
|
||||
# invoice.set_booking_payments()
|
||||
# FIXME: esta creando notas en ceros
|
||||
# for invoice in invoices:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.39
|
||||
version=6.0.40
|
||||
depends:
|
||||
party
|
||||
company
|
||||
|
@ -35,3 +35,4 @@ xml:
|
|||
message.xml
|
||||
operation.xml
|
||||
dash.xml
|
||||
commission.xml
|
||||
|
|
9
view/commission_form.xml
Normal file
9
view/commission_form.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?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/field[@name='origin']" position="after">
|
||||
<label name="offset_move"/>
|
||||
<field name="offset_move"/>
|
||||
</xpath>
|
||||
</data>
|
9
view/commission_tree.xml
Normal file
9
view/commission_tree.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?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="/tree/field[@name='invoice_state']" position="after">
|
||||
<label name="offset_move"/>
|
||||
<field name="offset_move"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in a new issue