mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] automatic register cash moves
This commit is contained in:
@@ -1668,6 +1668,21 @@ class PmsFolio(models.Model):
|
|||||||
"""
|
"""
|
||||||
if not pay_type:
|
if not pay_type:
|
||||||
pay_type = journal.type
|
pay_type = journal.type
|
||||||
|
vals = {
|
||||||
|
"journal_id": journal.id,
|
||||||
|
"partner_id": partner.id,
|
||||||
|
"amount": amount,
|
||||||
|
"date": fields.Date.today(),
|
||||||
|
"ref": folio.name,
|
||||||
|
"folio_ids": [(6, 0, [folio.id])],
|
||||||
|
"payment_type": "inbound",
|
||||||
|
"partner_type": "customer",
|
||||||
|
"state": "draft",
|
||||||
|
}
|
||||||
|
pay = self.env["account.payment"].create(vals)
|
||||||
|
pay.action_post()
|
||||||
|
|
||||||
|
# Automatic register payment in cash register
|
||||||
if pay_type == "cash":
|
if pay_type == "cash":
|
||||||
line = self._get_statement_line_vals(
|
line = self._get_statement_line_vals(
|
||||||
journal=journal,
|
journal=journal,
|
||||||
@@ -1681,36 +1696,22 @@ class PmsFolio(models.Model):
|
|||||||
date=date,
|
date=date,
|
||||||
)
|
)
|
||||||
self.env["account.bank.statement.line"].sudo().create(line)
|
self.env["account.bank.statement.line"].sudo().create(line)
|
||||||
else:
|
|
||||||
vals = {
|
|
||||||
"journal_id": journal.id,
|
|
||||||
"partner_id": partner.id,
|
|
||||||
"amount": amount,
|
|
||||||
"date": fields.Date.today(),
|
|
||||||
"ref": folio.name,
|
|
||||||
"folio_ids": [(6, 0, [folio.id])],
|
|
||||||
"payment_type": "inbound",
|
|
||||||
"partner_type": "customer",
|
|
||||||
"state": "draft",
|
|
||||||
}
|
|
||||||
pay = self.env["account.payment"].create(vals)
|
|
||||||
pay.action_post()
|
|
||||||
|
|
||||||
folio.message_post(
|
# folio.message_post(
|
||||||
body=_(
|
# body=_(
|
||||||
"""Payment: <b>%s</b> by <b>%s</b>""",
|
# """Payment: <b>%s</b> by <b>%s</b>""",
|
||||||
amount,
|
# amount,
|
||||||
journal.display_name,
|
# journal.display_name,
|
||||||
)
|
# )
|
||||||
)
|
# )
|
||||||
for reservation in folio.reservation_ids:
|
# for reservation in folio.reservation_ids:
|
||||||
reservation.message_post(
|
# reservation.message_post(
|
||||||
body=_(
|
# body=_(
|
||||||
"""Payment: <b>%s</b> by <b>%s</b>""",
|
# """Payment: <b>%s</b> by <b>%s</b>""",
|
||||||
amount,
|
# amount,
|
||||||
journal.display_name,
|
# journal.display_name,
|
||||||
)
|
# )
|
||||||
)
|
# )
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def do_refund(
|
def do_refund(
|
||||||
@@ -1733,6 +1734,22 @@ class PmsFolio(models.Model):
|
|||||||
"""
|
"""
|
||||||
if not pay_type:
|
if not pay_type:
|
||||||
pay_type = journal.type
|
pay_type = journal.type
|
||||||
|
|
||||||
|
vals = {
|
||||||
|
"journal_id": journal.id,
|
||||||
|
"partner_id": partner.id,
|
||||||
|
"amount": amount if amount > 0 else -amount,
|
||||||
|
"date": fields.Date.today(),
|
||||||
|
"ref": folio.name,
|
||||||
|
"folio_ids": [(6, 0, [folio.id])],
|
||||||
|
"payment_type": "outbound",
|
||||||
|
"partner_type": "customer",
|
||||||
|
"state": "draft",
|
||||||
|
}
|
||||||
|
pay = self.env["account.payment"].create(vals)
|
||||||
|
pay.action_post()
|
||||||
|
|
||||||
|
# Automatic register refund in cash register
|
||||||
if pay_type == "cash":
|
if pay_type == "cash":
|
||||||
line = self._get_statement_line_vals(
|
line = self._get_statement_line_vals(
|
||||||
journal=journal,
|
journal=journal,
|
||||||
@@ -1746,36 +1763,22 @@ class PmsFolio(models.Model):
|
|||||||
date=date,
|
date=date,
|
||||||
)
|
)
|
||||||
self.env["account.bank.statement.line"].sudo().create(line)
|
self.env["account.bank.statement.line"].sudo().create(line)
|
||||||
else:
|
|
||||||
vals = {
|
|
||||||
"journal_id": journal.id,
|
|
||||||
"partner_id": partner.id,
|
|
||||||
"amount": amount if amount > 0 else -amount,
|
|
||||||
"date": fields.Date.today(),
|
|
||||||
"ref": folio.name,
|
|
||||||
"folio_ids": [(6, 0, [folio.id])],
|
|
||||||
"payment_type": "outbound",
|
|
||||||
"partner_type": "customer",
|
|
||||||
"state": "draft",
|
|
||||||
}
|
|
||||||
pay = self.env["account.payment"].create(vals)
|
|
||||||
pay.action_post()
|
|
||||||
|
|
||||||
folio.message_post(
|
# folio.message_post(
|
||||||
body=_(
|
# body=_(
|
||||||
"""Refund: <b>%s</b> by <b>%s</b>""",
|
# """Refund: <b>%s</b> by <b>%s</b>""",
|
||||||
amount,
|
# amount,
|
||||||
journal.display_name,
|
# journal.display_name,
|
||||||
)
|
# )
|
||||||
)
|
# )
|
||||||
for reservation in folio.reservation_ids:
|
# for reservation in folio.reservation_ids:
|
||||||
reservation.message_post(
|
# reservation.message_post(
|
||||||
body=_(
|
# body=_(
|
||||||
"""Refund: <b>%s</b> by <b>%s</b>""",
|
# """Refund: <b>%s</b> by <b>%s</b>""",
|
||||||
amount,
|
# amount,
|
||||||
journal.display_name,
|
# journal.display_name,
|
||||||
)
|
# )
|
||||||
)
|
# )
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def open_wizard_several_partners(self):
|
def open_wizard_several_partners(self):
|
||||||
|
|||||||
@@ -535,17 +535,6 @@
|
|||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page string="Payments">
|
<page string="Payments">
|
||||||
<separator string="Cash" colspan="4" />
|
|
||||||
<field name="statement_line_ids" nolabel="1">
|
|
||||||
<tree>
|
|
||||||
<field name="journal_id" string="Payment Mode" />
|
|
||||||
<field name="date" />
|
|
||||||
<field name="amount" />
|
|
||||||
<field name="partner_id" invisible="1" />
|
|
||||||
<field name="state" invisible="1" />
|
|
||||||
</tree>
|
|
||||||
</field>
|
|
||||||
<separator string="Bank" colspan="4" />
|
|
||||||
<field name="payment_ids" nolabel="1">
|
<field name="payment_ids" nolabel="1">
|
||||||
<tree>
|
<tree>
|
||||||
<field name="journal_id" string="Payment Mode" />
|
<field name="journal_id" string="Payment Mode" />
|
||||||
|
|||||||
Reference in New Issue
Block a user