-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] point_of_sale: fix session report payment difference
Current behavior: If you use a non cash payment method, with "identify customer" option and register a payment difference at the closing of the session. The difference is not taken into account in the session report. Steps to reproduce: - Activate "identify customer" option on the bank payment method - Open a session - Add a product to the order - Pay the order with the bank payment method - Close the session with a payment difference - Print the session report - Open the report, at the bottom you should see the payment difference but it is not the case opw-3597291 closes odoo#148753 X-original-commit: 30ba7fd Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com> Signed-off-by: Robin Engels (roen) <roen@odoo.com>
- Loading branch information
1 parent
ec9610d
commit 9564374
Showing
3 changed files
with
67 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
import odoo | ||
|
||
from odoo.addons.point_of_sale.tests.common import TestPoSCommon | ||
|
||
@odoo.tests.tagged('post_install', '-at_install') | ||
class TestReportSession(TestPoSCommon): | ||
|
||
def setUp(self): | ||
super(TestReportSession, self).setUp() | ||
self.config = self.basic_config | ||
|
||
def test_report_session(self): | ||
|
||
product1 = self.create_product('Product 1', self.categ_basic, 150) | ||
self.open_new_session() | ||
session = self.pos_session | ||
|
||
order = self.env['pos.order'].create({ | ||
'session_id': session.id, | ||
'partner_id': self.partner_a.id, | ||
'lines': [(0, 0, { | ||
'name': "OL/0001", | ||
'product_id': product1.id, | ||
'price_unit': 150, | ||
'discount': 0, | ||
'qty': 1.0, | ||
'price_subtotal': 150, | ||
'price_subtotal_incl': 150, | ||
}),], | ||
'amount_total': 150.0, | ||
'amount_tax': 0.0, | ||
'amount_paid': 0.0, | ||
'amount_return': 0.0, | ||
'last_order_preparation_change': '{}' | ||
}) | ||
|
||
payment_context = {"active_ids": order.ids, "active_id": order.id} | ||
order_payment = self.env['pos.make.payment'].with_context(**payment_context).create({ | ||
'amount': 150, | ||
'payment_method_id': self.bank_split_pm1.id | ||
}) | ||
order_payment.with_context(**payment_context).check() | ||
session.action_pos_session_closing_control(bank_payment_method_diffs={self.bank_split_pm1.id: 50}) | ||
|
||
# PoS Orders have negative IDs to avoid conflict, so reports[0] will correspond to the newest order | ||
report = self.env['report.point_of_sale.report_saledetails'].get_sale_details(session_ids=[session.id]) | ||
split_payment_bank = [p for p in report['payments'] if p.get('id', 0) == self.bank_split_pm1.id] | ||
self.assertEqual(split_payment_bank[0]['cash_moves'][0]['amount'], 50) |