Skip to content

Commit

Permalink
Merge PR OCA#2732 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by tafaRU
  • Loading branch information
OCA-git-bot committed Apr 26, 2022
2 parents 41a61a7 + 432986c commit d96eea6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 27 deletions.
6 changes: 5 additions & 1 deletion l10n_it_withholding_tax/models/withholding_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,11 @@ def generate_account_move(self):
move_lines.append((0, 0, ml_vals))

move_vals["line_ids"] = move_lines
move = self.env["account.move"].create(move_vals)
move = (
self.env["account.move"]
.with_context(default_move_type="entry")
.create(move_vals)
)
move.action_post()

# Save move in the wt move
Expand Down
64 changes: 38 additions & 26 deletions l10n_it_withholding_tax/tests/test_withholding_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def setUp(self):
{"name": "Bank", "type": "bank", "code": "BNK67"}
)

# Payment Register
self.payment_register_model = self.env["account.payment.register"]
self.register_view_id = "account.view_account_payment_register_form"

# Payments
vals_payment = {
"name": "",
Expand Down Expand Up @@ -139,19 +143,15 @@ def test_withholding_tax(self):
"active_model": "account.move",
"active_ids": [self.invoice.id],
}
register_payments = (
self.env["account.payment.register"]
.with_context(ctx)
.create(
{
"payment_date": time.strftime("%Y") + "-07-15",
"amount": 800,
"journal_id": self.journal_bank.id,
"payment_method_id": self.env.ref(
"account.account_payment_method_manual_out"
).id,
}
)
register_payments = self.payment_register_model.with_context(ctx).create(
{
"payment_date": time.strftime("%Y") + "-07-15",
"amount": 800,
"journal_id": self.journal_bank.id,
"payment_method_id": self.env.ref(
"account.account_payment_method_manual_out"
).id,
}
)
register_payments.action_create_payments()

Expand Down Expand Up @@ -183,19 +183,15 @@ def test_partial_payment(self):
"active_id": self.invoice.id,
"default_reconciled_invoice_ids": [(4, self.invoice.id, None)],
}
register_payments = (
self.env["account.payment.register"]
.with_context(ctx)
.create(
{
"payment_date": time.strftime("%Y") + "-07-15",
"amount": 600,
"journal_id": self.journal_bank.id,
"payment_method_id": self.env.ref(
"account.account_payment_method_manual_out"
).id,
}
)
register_payments = self.payment_register_model.with_context(ctx).create(
{
"payment_date": time.strftime("%Y") + "-07-15",
"amount": 600,
"journal_id": self.journal_bank.id,
"payment_method_id": self.env.ref(
"account.account_payment_method_manual_out"
).id,
}
)
register_payments.action_create_payments()

Expand Down Expand Up @@ -283,3 +279,19 @@ def test_duplicating_wt(self):
new_tax = self.wt1040.copy()
self.assertEqual(new_tax.code, "1040 (copy)")
self.assertEqual(new_tax.name, "Code 1040")

def test_create_payments(self):
"""Test create payment when Register Payment wizard is open from Bill tree view"""
ctx = {
"active_ids": [self.invoice.id],
"active_model": "account.move",
}
f = Form(
self.payment_register_model.with_context(ctx), view=self.register_view_id
)
payment_register = f.save()
# passing default_move_type="in_invoice" in the context in order
# to simulate opening of payment_register from Bills tree view
payment_register.with_context(
default_move_type="in_invoice"
).action_create_payments()

0 comments on commit d96eea6

Please sign in to comment.