mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[DONE] PWA payment-flow (#55)
* [REF] pms: move payment action from wizard to folio * [FIX] pms: fix last commit (travis error) * [ADD] pms: test case partial payment * [FIX] add firstname to pms.checkin.partner(l10n)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import logging
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo import api, fields, models
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -51,70 +50,14 @@ class WizardPaymentFolio(models.TransientModel):
|
||||
self.allowed_method_ids = journal_ids
|
||||
|
||||
def button_payment(self):
|
||||
BankStatementLine = self.env["account.bank.statement.line"]
|
||||
line = self._get_statement_line_vals(
|
||||
journal=self.payment_method_id,
|
||||
receivable_account=self.payment_method_id.suspense_account_id,
|
||||
user=self.env.user,
|
||||
amount=self.amount,
|
||||
folios=self.folio_id,
|
||||
self.env["pms.folio"].do_payment(
|
||||
self.payment_method_id,
|
||||
self.payment_method_id.suspense_account_id,
|
||||
self.env.user,
|
||||
self.amount,
|
||||
self.folio_id,
|
||||
reservations=False,
|
||||
services=False,
|
||||
partner=self.partner_id,
|
||||
date=self.date,
|
||||
)
|
||||
BankStatementLine.sudo().create(line)
|
||||
|
||||
def _get_statement_line_vals(
|
||||
self,
|
||||
journal,
|
||||
receivable_account,
|
||||
user,
|
||||
amount,
|
||||
folios,
|
||||
reservations=False,
|
||||
services=False,
|
||||
partner=False,
|
||||
date=False,
|
||||
):
|
||||
property_folio_id = folios.mapped("pms_property_id.id")
|
||||
if len(property_folio_id) != 1:
|
||||
raise ValidationError(_("Only can payment by property"))
|
||||
ctx = dict(self.env.context, company_id=folios[0].company_id.id)
|
||||
statement = (
|
||||
self.env["account.bank.statement"]
|
||||
.sudo()
|
||||
.search(
|
||||
[
|
||||
("journal_id", "=", journal.id),
|
||||
("property_id", "=", property_folio_id[0]),
|
||||
("state", "=", "open"),
|
||||
]
|
||||
)
|
||||
)
|
||||
reservation_ids = reservations.ids if reservations else []
|
||||
service_ids = services.ids if services else []
|
||||
if not statement:
|
||||
# TODO: cash control option
|
||||
st_values = {
|
||||
"journal_id": journal.id,
|
||||
"user_id": self.env.user.id,
|
||||
"property_id": property_folio_id[0],
|
||||
"name": str(fields.Datetime.now()),
|
||||
}
|
||||
statement = (
|
||||
self.env["account.bank.statement"]
|
||||
.with_context(ctx)
|
||||
.sudo()
|
||||
.create(st_values)
|
||||
)
|
||||
return {
|
||||
"date": date,
|
||||
"amount": amount,
|
||||
"partner_id": partner.id if partner else False,
|
||||
"statement_folio_ids": [(6, 0, folios.ids)],
|
||||
"reservation_ids": [(6, 0, reservation_ids)],
|
||||
"service_ids": [(6, 0, service_ids)],
|
||||
"payment_ref": folios.mapped("name"),
|
||||
"statement_id": statement.id,
|
||||
"journal_id": statement.journal_id.id,
|
||||
"counterpart_account_id": receivable_account.id,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user