[ADD]pms_api_rest: cash flow by turns

This commit is contained in:
Darío Lodeiros
2023-10-16 16:56:04 +02:00
parent a794448255
commit 69bb04baa8
2 changed files with 44 additions and 1 deletions

View File

@@ -3,4 +3,4 @@ from . import res_users
from . import account_payment
from . import sql_export
from . import pms_room_type_class
from . import account_bank_statement

View File

@@ -0,0 +1,43 @@
from odoo import api, fields, models
class AccountBankStatement(models.Model):
_inherit = "account.bank.statement"
_order = "date desc, cash_turn desc, name desc, id desc"
cash_turn = fields.Integer(
string="Turn",
help="Set the day turn of the cash statement",
copy=False,
readonly=True,
compute="_compute_cash_turn",
store=True,
)
@api.depends("journal_id", "pms_property_id", "date")
def _compute_cash_turn(self):
for record in self:
if record.journal_id.type == "cash" and record.pms_property_id:
day_statements = self.search(
[
("journal_id.type", "=", "cash"),
("pms_property_id", "=", record.pms_property_id.id),
("date", "=", record.date),
],
order="create_date asc",
)
record.cash_turn = list(day_statements).index(record) + 1
def name_get(self):
result = []
for record in self:
name = record.name
if record.cash_turn:
name += (
" [%s]" % str(record.cash_turn)
+ " ("
+ record.create_uid.name
+ ")"
)
result.append((record.id, name))
return result