Skip to content

Commit

Permalink
[IMP] account_payment_order: Integrate Default Tranfer Move Date opti…
Browse files Browse the repository at this point in the history
…on (now_date_maturity)

Related to OCA#1289

In v13 the existing behavior was defined with today's date the Transfer Move, therefore, we define
that behavior by default without configuration since it is the expected behavior.

https://github.com/OCA/bank-payment/pull/805/files

TT49582
  • Loading branch information
victoralmau committed Jun 17, 2024
1 parent ada23ab commit 074e676
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 45 deletions.
10 changes: 5 additions & 5 deletions account_payment_order/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ def _compute_payment_method_line_fields(self):

def _prepare_move_line_default_vals(self, write_off_line_vals=None):
"""Overwrite date_maturity of the move_lines that are generated when related
to a payment order and a specific configuration.
to a payment order.
"""
vals_list = super()._prepare_move_line_default_vals(
write_off_line_vals=write_off_line_vals
)
payment_mode = self.payment_order_id.payment_mode_id
if payment_mode.transfer_date_option == "now_date_maturity":
for vals in vals_list:
vals["date_maturity"] = self.payment_line_ids[0].date
if not self.payment_order_id:
return vals_list
for vals in vals_list:
vals["date_maturity"] = self.payment_line_ids[0].date
return vals_list
5 changes: 1 addition & 4 deletions account_payment_order/models/account_payment_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def _prepare_account_payment_vals(self):
"destination_account_id": self.move_line_id.account_id.id,
"company_id": self.order_id.company_id.id,
"amount": sum(self.mapped("amount_currency")),
"date": self[:1].date,
"date": fields.Date.today(),
"currency_id": self.currency_id.id,
"ref": self.order_id.name,
"payment_reference": " - ".join([line.communication for line in self]),
Expand All @@ -197,9 +197,6 @@ def _prepare_account_payment_vals(self):
"payment_order_id": self.order_id.id,
"payment_line_ids": [(6, 0, self.ids)],
}
# Set today according to transfer_date_option
if payment_mode.transfer_date_option == "now_date_maturity":
vals["date"] = fields.Date.today()
# Determine payment method line according payment method and journal
line = self.env["account.payment.method.line"].search(
[
Expand Down
8 changes: 0 additions & 8 deletions account_payment_order/models/account_payment_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ class AccountPaymentMode(models.Model):
],
string="Default Payment Execution Date",
)
transfer_date_option = fields.Selection(
selection=[
("payment_date", "Payment date"),
("now_date_maturity", "Now + Payment date as due date"),
],
default="payment_date",
string="Transfer moves dates",
)
group_lines = fields.Boolean(
string="Group Transactions in Payment Orders",
default=True,
Expand Down
26 changes: 1 addition & 25 deletions account_payment_order/tests/test_payment_order_inbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,31 +152,7 @@ def test_creation(self):
self.assertEqual(len(self.payment_order_obj.search(self.domain)), 0)

@freeze_time("2024-04-01")
def test_creation_transfer_move_date_01(self):
self.inbound_mode.write({"transfer_date_option": "payment_date"})
self.inbound_order.date_prefered = "fixed"
self.inbound_order.date_scheduled = "2024-06-01"
self.inbound_order.draft2open()
payment_move = self.inbound_order.payment_ids.move_id
self.assertEqual(payment_move.date, date(2024, 6, 1))
self.assertEqual(
payment_move.line_ids.mapped("date_maturity"),
[date(2024, 6, 1), date(2024, 6, 1)],
)
self.assertEqual(self.inbound_order.payment_count, 1)
self.inbound_order.open2generated()
self.inbound_order.generated2uploaded()
self.assertEqual(self.inbound_order.state, "uploaded")
payment_move = self.inbound_order.payment_ids.move_id
self.assertEqual(payment_move.date, date(2024, 6, 1))
self.assertEqual(
payment_move.line_ids.mapped("date_maturity"),
[date(2024, 6, 1), date(2024, 6, 1)],
)

@freeze_time("2024-04-01")
def test_creation_transfer_move_date_02(self):
self.inbound_mode.write({"transfer_date_option": "now_date_maturity"})
def test_creation_transfer_move_date(self):
self.inbound_order.date_prefered = "fixed"
self.inbound_order.date_scheduled = "2024-06-01"
self.inbound_order.draft2open()
Expand Down
3 changes: 1 addition & 2 deletions account_payment_order/tests/test_payment_order_outbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@ def test_manual_line_and_manual_date(self):
outbound_order.draft2open()
self.assertEqual(outbound_order.payment_count, 2)
self.assertEqual(
outbound_order.payment_line_ids[0].date,
outbound_order.payment_line_ids[0].payment_ids.date,
outbound_order.payment_line_ids[0].payment_ids.date, fields.Date.today()
)
self.assertEqual(outbound_order.payment_line_ids[1].date, date.today())
self.assertEqual(
Expand Down
1 change: 0 additions & 1 deletion account_payment_order/views/account_payment_mode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
attrs="{'invisible': ['|', ('payment_type', '!=', 'inbound'), ('payment_order_ok', '!=', True)]}"
/>
<field name="default_date_prefered" />
<field name="transfer_date_option" />
<field name="group_lines" />
</group>
<group
Expand Down

0 comments on commit 074e676

Please sign in to comment.