trytonpsk-hotel/invoice.py

42 lines
1.3 KiB
Python
Raw Normal View History

2022-03-16 14:16:18 +01:00
# 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
# from trytond.model import fields
# from trytond.pyson import Eval
class Invoice(metaclass=PoolMeta):
__name__ = 'account.invoice'
@classmethod
def post(cls, invoices):
super(Invoice, cls).post(invoices)
2022-05-22 08:52:05 +02:00
# FIXME: esta creando notas en ceros
# for invoice in invoices:
# if invoice.type == 'out':
# cls.set_advances_from_origin(invoice)
2022-03-16 14:16:18 +01:00
2022-03-19 06:21:49 +01:00
@classmethod
def set_advances_from_origin(cls, invoice):
advances_to_add = []
vouchers = []
for line in invoice.lines:
if line.origin and line.origin.__name__ == 'hotel.booking':
booking = line.origin
if not booking.vouchers:
continue
2022-03-20 14:46:25 +01:00
for voucher in booking.vouchers:
if invoice.party.id == voucher.party.id:
vouchers.append(voucher)
2022-03-19 06:21:49 +01:00
if vouchers:
invoice.create_move_advance(set(vouchers))
2022-03-16 14:16:18 +01:00
class InvoiceLine(metaclass=PoolMeta):
__name__ = 'account.invoice.line'
@classmethod
def _get_origin(cls):
return super(InvoiceLine, cls)._get_origin() + [
'hotel.booking'
]