Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] [MIG] sale_payment_sheet #2554

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
236a70a
[ADD] sale_payment_sheet: New module
sergio-teruel Dec 7, 2020
03113ad
[ADD] sale_payment_sheet: Allow add refund invoices to payment sheets
sergio-teruel Feb 24, 2021
3a8aec0
[ADD] sale_payment_sheet: Add total amount in tree view
sergio-teruel Apr 27, 2021
143716b
[IMP] sale_payment_sheet: Allow to group statement lines by reference
sergio-teruel May 5, 2021
db27286
[ADD] sale_payment_sheet: Avoid take an invoice that it already is on…
sergio-teruel Jul 8, 2021
677df20
[IMP] sale_payment_sheet: black, isort, prettier
cesar-tecnativa Jun 6, 2022
5f08fbf
[MIG] sale_payment_sheet: Migration to 15.0
cesar-tecnativa Jun 6, 2022
46f9417
[IMP] sale_payment_sheet: Show invoices in wizard payments and improv…
cesar-tecnativa Aug 11, 2022
1f5de3b
[FIX] sale_payment_sheet: Fix to v15
sergio-teruel Aug 21, 2022
7c461d4
[UPD] Update sale_payment_sheet.pot
Aug 24, 2022
02445c4
[UPD] README.rst
OCA-git-bot Aug 24, 2022
3119307
[IMP] sale_payment_sheet: Display partner shipping as optional in inv…
sergio-teruel Sep 8, 2022
a70f6ea
sale_payment_sheet 15.0.1.1.0
OCA-git-bot Sep 13, 2022
820b3da
[FIX] Update deprecated unit tests
Oct 11, 2022
b837452
sale_payment_sheet 15.0.1.1.1
OCA-git-bot Oct 20, 2022
9b6358c
[IMP] sale_payment_sheet: Remove redundant default on related field.
victoralmau Nov 29, 2022
3421915
sale_payment_sheet 15.0.1.1.2
OCA-git-bot Nov 29, 2022
8a83526
[IMP] sale_payment_sheet: pre-commit stuff
angelmoya Jun 6, 2023
6fb6989
[MIG] sale_payment_sheet: Migration to 16.0
angelmoya Jun 6, 2023
8b79c7a
[IMP] sale_payment_sheet: add more tests and fix version
angelmoya Jun 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sale_payment_sheet/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Sale payment sheet",
"summary": "Allow to create invoice payments to commercial users without "
"accounting permissions",
"version": "16.0.1.1.2",
"version": "16.0.1.0.0",
"development_status": "Beta",
"category": "Account",
"website": "https://github.com/OCA/sale-workflow",
Expand Down
70 changes: 64 additions & 6 deletions sale_payment_sheet/tests/test_sale_payment_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def setUpClass(cls):
)
cls.invoice1 = cls._create_invoice(cls)
cls.invoice2 = cls._create_invoice(cls)
(cls.invoice1 + cls.invoice2).action_post()
cls.refund1 = cls._create_refund(cls)
(cls.invoice1 + cls.invoice2 + cls.refund1).action_post()

def _create_invoice(self):
with Form(
Expand All @@ -60,18 +61,30 @@ def _create_invoice(self):
line_form.price_unit = 100.00
return invoice_form.save()

def _create_refund(self):
with Form(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do with here, as you are saving 2 times with it (one exiting the context and the other on the explicit call).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.env["account.move"].with_context(default_move_type="out_refund")
) as invoice_form:
invoice_form.partner_id = self.partner
with invoice_form.invoice_line_ids.new() as line_form:
line_form.name = "invoice test"
line_form.account_id = self.account_invoice
line_form.quantity = 1.0
line_form.price_unit = 10.00
return invoice_form.save()

def test_payment_wizard(self):
PaymentWiz = self.env["sale.invoice.payment.wiz"].with_context(
active_model="account.move",
active_ids=(self.invoice1 + self.invoice2).ids,
active_ids=(self.invoice1 + self.invoice2 + self.refund1).ids,
)
with Form(PaymentWiz) as wiz_form:
wiz_form.journal_id = self.bank_journal
wiz_form.amount = 150.00
wiz = wiz_form.save()
action = wiz.create_sale_invoice_payment_sheet()
sheet = self.SalePaymentSheet.browse(action["res_id"])
self.assertEqual(len(sheet.line_ids), 2)
self.assertEqual(len(sheet.line_ids), 3)
line_partial_payment = sheet.line_ids.filtered(
lambda ln: ln.transaction_type == "partial"
)
Expand All @@ -81,7 +94,7 @@ def test_payment_wizard(self):
lambda ln: ln.transaction_type == "full"
)
self.assertTrue(line_full_payment)
self.assertEqual(line_full_payment.invoice_id, self.invoice1)
self.assertEqual(line_full_payment.invoice_id, (self.invoice1 + self.refund1))
self.assertEqual(sheet.amount_total, 150.00)

def _create_payment_sheet(self):
Expand All @@ -91,7 +104,6 @@ def _create_payment_sheet(self):
with sheet_form.line_ids.new() as line_sheet:
line_sheet.partner_id = self.partner
line_sheet.invoice_id = invoice
# line_sheet.ref = "REF{}".format(line_sheet.id)
# Only write for partial amount payed, by default the
# amount line is total amount residual
if index > 0:
Expand Down Expand Up @@ -146,6 +158,8 @@ def test_payment_sheet_reopen(self):
self.assertFalse(sheet.statement_id)

def test_payment_sheet_unlink(self):
sheet = self._create_payment_sheet()
sheet.unlink()
sheet = self._create_payment_sheet()
sheet.button_confirm_sheet()
with self.assertRaises(UserError):
Expand All @@ -169,4 +183,48 @@ def test_payment_sheet_invoice_constraint(self):
with sheet_form.line_ids.new() as line_sheet:
line_sheet.partner_id = self.partner
line_sheet.invoice_id = self.invoice1
sheet_form.save()

def test_wizard_sale_invoice_payment(self):
wiz = (
self.env["sale.invoice.payment.wiz"]
.with_context(
active_model="account.move",
active_ids=(self.invoice1 + self.invoice2).ids,
)
.create(
{
"journal_id": self.bank_journal.id,
"amount": 100.00,
}
)
)
action = wiz.create_sale_invoice_payment_sheet()
sheet = self.SalePaymentSheet.browse(action["res_id"])
self.assertEqual(len(sheet.line_ids), 1)
self.assertEqual(sheet.amount_total, 100.00)

def test_wizard_sale_invoice_payment_wrong(self):
wiz = (
self.env["sale.invoice.payment.wiz"]
.with_context(active_model="account.move", active_ids=[])
.create(
{
"journal_id": self.bank_journal.id,
"amount": 100.00,
}
)
)
action = wiz.create_sale_invoice_payment_sheet()
self.assertFalse(action)
wiz = (
self.env["sale.invoice.payment.wiz"]
.with_context(active_model="account.move.line", active_ids=[])
.create(
{
"journal_id": self.bank_journal.id,
"amount": 100.00,
}
)
)
action = wiz.create_sale_invoice_payment_sheet()
self.assertFalse(action)