mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Comment Dependeces return and partner firstname
This commit is contained in:
@@ -19,10 +19,9 @@
|
||||
"depends": [
|
||||
"base",
|
||||
"mail",
|
||||
"account_payment_return",
|
||||
"partner_firstname",
|
||||
"email_template_qweb",
|
||||
"sales_team",
|
||||
#"account_payment_return",
|
||||
# "partner_firstname",
|
||||
#"email_template_qweb",
|
||||
"sale",
|
||||
],
|
||||
"data": [
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import ir_http
|
||||
from . import payment_return
|
||||
#from . import payment_return
|
||||
from . import pms_board_service_room_type
|
||||
from . import pms_property
|
||||
from . import res_users
|
||||
|
||||
@@ -55,32 +55,32 @@ class AccountPayment(models.Model):
|
||||
# Action methods
|
||||
"""WIP"""
|
||||
|
||||
def return_payment_folio(self):
|
||||
journal = self.journal_id
|
||||
partner = self.partner_id
|
||||
amount = self.amount
|
||||
reference = self.communication
|
||||
account_move_lines = self.move_line_ids.filtered(
|
||||
lambda x: (x.account_id.internal_type == "receivable")
|
||||
)
|
||||
return_line_vals = {
|
||||
"move_line_ids": [(6, False, [x.id for x in account_move_lines])],
|
||||
"partner_id": partner.id,
|
||||
"amount": amount,
|
||||
"reference": reference,
|
||||
}
|
||||
return_vals = {
|
||||
"journal_id": journal.id,
|
||||
"line_ids": [(0, 0, return_line_vals)],
|
||||
}
|
||||
return_pay = self.env["payment.return"].create(return_vals)
|
||||
if self.save_amount:
|
||||
self.amount = self.save_amount
|
||||
if self.save_date:
|
||||
self.payment_date = self.save_date
|
||||
if self.save_journal_id:
|
||||
self.journal_id = self.env["account.journal"].browse(self.save_journal_id)
|
||||
return_pay.action_confirm()
|
||||
# def return_payment_folio(self):
|
||||
# journal = self.journal_id
|
||||
# partner = self.partner_id
|
||||
# amount = self.amount
|
||||
# reference = self.communication
|
||||
# account_move_lines = self.move_line_ids.filtered(
|
||||
# lambda x: (x.account_id.internal_type == "receivable")
|
||||
# )
|
||||
# return_line_vals = {
|
||||
# "move_line_ids": [(6, False, [x.id for x in account_move_lines])],
|
||||
# "partner_id": partner.id,
|
||||
# "amount": amount,
|
||||
# "reference": reference,
|
||||
# }
|
||||
# return_vals = {
|
||||
# "journal_id": journal.id,
|
||||
# "line_ids": [(0, 0, return_line_vals)],
|
||||
# }
|
||||
# return_pay = self.env["payment.return"].create(return_vals)
|
||||
# if self.save_amount:
|
||||
# self.amount = self.save_amount
|
||||
# if self.save_date:
|
||||
# self.payment_date = self.save_date
|
||||
# if self.save_journal_id:
|
||||
# self.journal_id = self.env["account.journal"].browse(self.save_journal_id)
|
||||
# return_pay.action_confirm()
|
||||
|
||||
# Business methods
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class PmsFolio(models.Model):
|
||||
"res.partner", "Agency", ondelete="restrict", domain=[("is_agency", "=", True)],
|
||||
)
|
||||
payment_ids = fields.One2many("account.payment", "folio_id", readonly=True)
|
||||
return_ids = fields.One2many("payment.return", "folio_id", readonly=True)
|
||||
# return_ids = fields.One2many("payment.return", "folio_id", readonly=True)
|
||||
payment_term_id = fields.Many2one(
|
||||
"account.payment.term",
|
||||
string="Payment Terms",
|
||||
@@ -195,9 +195,9 @@ class PmsFolio(models.Model):
|
||||
pending_amount = fields.Monetary(
|
||||
compute="compute_amount", store=True, string="Pending in Folio"
|
||||
)
|
||||
refund_amount = fields.Monetary(
|
||||
compute="compute_amount", store=True, string="Payment Returns"
|
||||
)
|
||||
# refund_amount = fields.Monetary(
|
||||
# compute="compute_amount", store=True, string="Payment Returns"
|
||||
# )
|
||||
invoices_paid = fields.Monetary(
|
||||
compute="compute_amount",
|
||||
store=True,
|
||||
@@ -423,20 +423,20 @@ class PmsFolio(models.Model):
|
||||
vals = {
|
||||
"pending_amount": 0,
|
||||
"invoices_paid": 0,
|
||||
"refund_amount": 0,
|
||||
# "refund_amount": 0,
|
||||
}
|
||||
record.update(vals)
|
||||
else:
|
||||
total_inv_refund = 0
|
||||
payments = acc_pay_obj.search([("folio_id", "=", record.id)])
|
||||
total_paid = sum(pay.amount for pay in payments)
|
||||
return_lines = self.env["payment.return.line"].search(
|
||||
[
|
||||
("move_line_ids", "in", payments.mapped("move_line_ids.id")),
|
||||
("return_id.state", "=", "done"),
|
||||
]
|
||||
)
|
||||
total_inv_refund = sum(pay_return.amount for pay_return in return_lines)
|
||||
# return_lines = self.env["payment.return.line"].search(
|
||||
# [
|
||||
# ("move_line_ids", "in", payments.mapped("move_line_ids.id")),
|
||||
# ("return_id.state", "=", "done"),
|
||||
# ]
|
||||
# )
|
||||
# total_inv_refund = sum(pay_return.amount for pay_return in return_lines)
|
||||
total = record.amount_total
|
||||
# REVIEW: Must We ignored services in cancelled folios
|
||||
# pending amount?
|
||||
@@ -445,7 +445,7 @@ class PmsFolio(models.Model):
|
||||
vals = {
|
||||
"pending_amount": total - total_paid + total_inv_refund,
|
||||
"invoices_paid": total_paid,
|
||||
"refund_amount": total_inv_refund,
|
||||
# "refund_amount": total_inv_refund,
|
||||
}
|
||||
record.update(vals)
|
||||
|
||||
@@ -486,29 +486,29 @@ class PmsFolio(models.Model):
|
||||
action = {"type": "ir.actions.act_window_close"}
|
||||
return action
|
||||
|
||||
def action_return_payments(self):
|
||||
self.ensure_one()
|
||||
return_move_ids = []
|
||||
acc_pay_obj = self.env["account.payment"]
|
||||
payments = acc_pay_obj.search(
|
||||
["|", ("move_ids", "in", self.move_ids.ids), ("folio_id", "=", self.id)]
|
||||
)
|
||||
return_move_ids += self.move_ids.filtered(
|
||||
lambda invoice: invoice.type == "out_refund"
|
||||
).mapped("payment_move_line_ids.move_id.id")
|
||||
return_lines = self.env["payment.return.line"].search(
|
||||
[("move_line_ids", "in", payments.mapped("move_line_ids.id")),]
|
||||
)
|
||||
return_move_ids += return_lines.mapped("return_id.move_id.id")
|
||||
# def action_return_payments(self):
|
||||
# self.ensure_one()
|
||||
# return_move_ids = []
|
||||
# acc_pay_obj = self.env["account.payment"]
|
||||
# payments = acc_pay_obj.search(
|
||||
# ["|", ("move_ids", "in", self.move_ids.ids), ("folio_id", "=", self.id)]
|
||||
# )
|
||||
# return_move_ids += self.move_ids.filtered(
|
||||
# lambda invoice: invoice.type == "out_refund"
|
||||
# ).mapped("payment_move_line_ids.move_id.id")
|
||||
# return_lines = self.env["payment.return.line"].search(
|
||||
# [("move_line_ids", "in", payments.mapped("move_line_ids.id")),]
|
||||
# )
|
||||
# return_move_ids += return_lines.mapped("return_id.move_id.id")
|
||||
|
||||
return {
|
||||
"name": _("Returns"),
|
||||
"view_type": "form",
|
||||
"view_mode": "tree,form",
|
||||
"res_model": "account.move",
|
||||
"type": "ir.actions.act_window",
|
||||
"domain": [("id", "in", return_move_ids)],
|
||||
}
|
||||
# return {
|
||||
# "name": _("Returns"),
|
||||
# "view_type": "form",
|
||||
# "view_mode": "tree,form",
|
||||
# "res_model": "account.move",
|
||||
# "type": "ir.actions.act_window",
|
||||
# "domain": [("id", "in", return_move_ids)],
|
||||
# }
|
||||
|
||||
def action_checks(self):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -279,7 +279,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</span>
|
||||
<span t-if="doc.return_ids">
|
||||
<!-- <span t-if="doc.return_ids">
|
||||
<table style="width:80%;">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -302,7 +302,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</span>
|
||||
</span> -->
|
||||
</div>
|
||||
<p t-field="doc.note" />
|
||||
<p t-if="doc.payment_term_id.note">
|
||||
|
||||
@@ -40,13 +40,13 @@
|
||||
class="oe_edit_only btn-primary"
|
||||
attrs="{'invisible': [('state','=','draft')]}"
|
||||
/>
|
||||
<button
|
||||
<!-- <button
|
||||
string="Return"
|
||||
name="return_payment_folio"
|
||||
type="object"
|
||||
class="oe_edit_only btn-primary"
|
||||
attrs="{'invisible': [('state','=','draft')]}"
|
||||
/>
|
||||
/> -->
|
||||
<button
|
||||
string="Delete"
|
||||
name="delete"
|
||||
|
||||
@@ -200,11 +200,11 @@
|
||||
options="{'no_create': True}"
|
||||
/>
|
||||
</page>
|
||||
<page
|
||||
<!-- <page
|
||||
name="returns"
|
||||
string="Retun Payments"
|
||||
attrs="{'invisible': [('refund_amount','<=',0)]}"
|
||||
>
|
||||
> -->
|
||||
<field name="return_ids" options="{'no_create': True}" />
|
||||
</page>
|
||||
<page string="Other data" invisible="1">
|
||||
|
||||
Reference in New Issue
Block a user