[ADD]pms: automatic create statement (#54)

This commit is contained in:
Darío Lodeiros
2021-02-18 09:52:02 +01:00
committed by GitHub
parent ef60556ed6
commit 4b680c8fdc

View File

@@ -78,6 +78,7 @@ class WizardPaymentFolio(models.TransientModel):
property_folio_id = folios.mapped("pms_property_id.id") property_folio_id = folios.mapped("pms_property_id.id")
if len(property_folio_id) != 1: if len(property_folio_id) != 1:
raise ValidationError(_("Only can payment by property")) raise ValidationError(_("Only can payment by property"))
ctx = dict(self.env.context, company_id=folios[0].company_id.id)
statement = ( statement = (
self.env["account.bank.statement"] self.env["account.bank.statement"]
.sudo() .sudo()
@@ -91,8 +92,20 @@ class WizardPaymentFolio(models.TransientModel):
) )
reservation_ids = reservations.ids if reservations else [] reservation_ids = reservations.ids if reservations else []
service_ids = services.ids if services else [] service_ids = services.ids if services else []
# TODO: If not open statement, create new, with cash control option if not statement:
if 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 { return {
"date": date, "date": date,
"amount": amount, "amount": amount,
@@ -105,5 +118,3 @@ class WizardPaymentFolio(models.TransientModel):
"journal_id": statement.journal_id.id, "journal_id": statement.journal_id.id,
"counterpart_account_id": receivable_account.id, "counterpart_account_id": receivable_account.id,
} }
else:
return False