diff --git a/pos_session_pay_invoice/README.rst b/pos_session_pay_invoice/README.rst index 5e525e446f..2c33d31619 100644 --- a/pos_session_pay_invoice/README.rst +++ b/pos_session_pay_invoice/README.rst @@ -17,13 +17,13 @@ POS Session Pay invoice :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github - :target: https://github.com/OCA/pos/tree/14.0/pos_session_pay_invoice + :target: https://github.com/OCA/pos/tree/16.0/pos_session_pay_invoice :alt: OCA/pos .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/pos-14-0/pos-14-0-pos_session_pay_invoice + :target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_session_pay_invoice :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=14.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -68,7 +68,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -85,6 +85,9 @@ Contributors * Enric Tobella * Jordi Ballester +* Tecnativa (https://www.tecnativa.com): + + * Carlos Lopez Maintainers ~~~~~~~~~~~ @@ -99,6 +102,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/pos `_ project on GitHub. +This module is part of the `OCA/pos `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_session_pay_invoice/__manifest__.py b/pos_session_pay_invoice/__manifest__.py index 617413e1cb..2dae1d61aa 100644 --- a/pos_session_pay_invoice/__manifest__.py +++ b/pos_session_pay_invoice/__manifest__.py @@ -3,7 +3,7 @@ { "name": "POS Session Pay invoice", - "version": "14.0.1.1.0", + "version": "16.0.1.0.0", "category": "Point Of Sale", "author": "Creu Blanca, Odoo Community Association (OCA)", "website": "https://github.com/OCA/pos", @@ -14,7 +14,7 @@ "security/ir.model.access.csv", "wizard/pos_box_cash_invoice_out.xml", "wizard/pos_box_cash_invoice_in.xml", - "wizard/cash_invoice_in.xml", + "wizard/cash_pay_invoice.xml", "views/pos_session.xml", ], } diff --git a/pos_session_pay_invoice/models/__init__.py b/pos_session_pay_invoice/models/__init__.py index e9ab911ddc..b2f4b5e054 100644 --- a/pos_session_pay_invoice/models/__init__.py +++ b/pos_session_pay_invoice/models/__init__.py @@ -1 +1,2 @@ from . import pos_order +from . import pos_session diff --git a/pos_session_pay_invoice/models/pos_session.py b/pos_session_pay_invoice/models/pos_session.py new file mode 100644 index 0000000000..829e3fdaf0 --- /dev/null +++ b/pos_session_pay_invoice/models/pos_session.py @@ -0,0 +1,17 @@ +from odoo import models + + +class PosSession(models.Model): + _inherit = "pos.session" + + def button_show_wizard_pay_invoice(self): + cash_journal = self.cash_journal_id + action = self.env["ir.actions.actions"]._for_xml_id( + "pos_session_pay_invoice.action_pos_invoice_in_control" + ) + action["context"] = { + "active_ids": cash_journal.ids, + "active_name": cash_journal._name, + "pos_session_id": self.id, + } + return action diff --git a/pos_session_pay_invoice/readme/CONTRIBUTORS.rst b/pos_session_pay_invoice/readme/CONTRIBUTORS.rst index e250875ecd..120a999245 100644 --- a/pos_session_pay_invoice/readme/CONTRIBUTORS.rst +++ b/pos_session_pay_invoice/readme/CONTRIBUTORS.rst @@ -1,2 +1,5 @@ * Enric Tobella * Jordi Ballester +* Tecnativa (https://www.tecnativa.com): + + * Carlos Lopez \ No newline at end of file diff --git a/pos_session_pay_invoice/static/description/index.html b/pos_session_pay_invoice/static/description/index.html index 15ecdc78b7..bd08aa2a32 100644 --- a/pos_session_pay_invoice/static/description/index.html +++ b/pos_session_pay_invoice/static/description/index.html @@ -1,4 +1,3 @@ - @@ -369,7 +368,7 @@

POS Session Pay invoice

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:6eac7dbff1f6e08ae835df882a549b193c4d037be692dfd6913960c06245184b !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: LGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

+

Beta License: LGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

This modules allows to pay an existing Supplier Invoice / Customer Refund, or to collect payment for an existing Customer Invoice, from within a POS Session.

Table of contents

@@ -420,7 +419,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -436,6 +435,10 @@

Contributors

@@ -445,7 +448,7 @@

Maintainers

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/pos project on GitHub.

+

This module is part of the OCA/pos project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/pos_session_pay_invoice/tests/test_pay_invoice.py b/pos_session_pay_invoice/tests/test_pay_invoice.py index 6046603a1f..fbd6140a05 100644 --- a/pos_session_pay_invoice/tests/test_pay_invoice.py +++ b/pos_session_pay_invoice/tests/test_pay_invoice.py @@ -4,6 +4,7 @@ import odoo from odoo.tests import Form +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT from odoo.addons.point_of_sale.tests.common import TestPointOfSaleCommon @@ -12,18 +13,8 @@ class TestSessionPayInvoice(TestPointOfSaleCommon): @classmethod def setUpClass(cls, chart_template_ref=None): super().setUpClass(chart_template_ref=chart_template_ref) + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) cls.pos_config.cash_control = True - - account = cls.env["account.account"].create( - { - "code": "test_cash_pay_invoice", - "company_id": cls.company.id, - "name": "Test", - "user_type_id": cls.env.ref("account.data_account_type_revenue").id, - "reconcile": True, - } - ) - cls.invoice_out = cls.env["account.move"].create( { "company_id": cls.company.id, @@ -32,19 +23,20 @@ def setUpClass(cls, chart_template_ref=None): "invoice_date": "2016-03-12", "move_type": "out_invoice", "invoice_line_ids": [ - 0, - 0, - { - "product_id": cls.product3.id, - "name": "Producto de prueba", - "account_id": account.id, - "quantity": 1.0, - "price_unit": 100.0, - }, + ( + 0, + 0, + { + "product_id": cls.product3.id, + "name": "Producto de prueba", + "quantity": 1.0, + "price_unit": 100.0, + "tax_ids": [], + }, + ) ], } ) - cls.invoice_out._onchange_invoice_line_ids() cls.invoice_out.action_post() cls.invoice_in = cls.env["account.move"].create( { @@ -54,19 +46,20 @@ def setUpClass(cls, chart_template_ref=None): "date": "2016-03-12", "invoice_date": "2016-03-12", "invoice_line_ids": [ - 0, - 0, - { - "product_id": cls.product3.id, - "name": "Producto de prueba", - "account_id": account.id, - "quantity": 1.0, - "price_unit": 100.0, - }, + ( + 0, + 0, + { + "product_id": cls.product3.id, + "name": "Producto de prueba", + "quantity": 1.0, + "price_unit": 100.0, + "tax_ids": [], + }, + ) ], } ) - cls.invoice_in._onchange_invoice_line_ids() cls.invoice_in.action_post() refund_wizard = ( cls.env["account.move.reversal"] @@ -75,7 +68,7 @@ def setUpClass(cls, chart_template_ref=None): active_id=cls.invoice_out.id, active_model=cls.invoice_out._name, ) - .create({}) + .create({"journal_id": cls.invoice_out.journal_id.id}) .reverse_moves() ) cls.refund = cls.env[refund_wizard["res_model"]].browse(refund_wizard["res_id"]) @@ -83,33 +76,26 @@ def setUpClass(cls, chart_template_ref=None): def test_pos_in_invoice(self): self.assertEqual(self.invoice_in.amount_residual, 100.0) - self.pos_config.open_session_cb() + self.pos_config._action_to_open_ui() session = self.pos_config.current_session_id - self.assertIsNotNone(session.statement_ids) - cash_statements = session.statement_ids.filtered( - lambda x: x.journal_id.type == "cash" - ) - self.assertEqual(len(cash_statements), 1) + self.assertTrue(session.cash_control) + self.assertTrue(session.cash_journal_id) session.action_pos_session_open() - cash_in = self.env["cash.invoice.in"].with_context( - active_ids=session.ids, active_model="pos.session" - ) + wizard_context = session.button_show_wizard_pay_invoice()["context"] + cash_in = self.env["cash.pay.invoice"].with_context(**wizard_context) with Form(cash_in) as form: form.invoice_id = self.invoice_in self.assertEqual(form.amount, -100) - cash_in.browse(form.id).run() + cash_in.browse(form.id).action_pay_invoice() session.action_pos_session_closing_control() - session._validate_session() - session.flush() - session.refresh() - self.invoice_in.flush() - self.invoice_in.refresh() + session.invalidate_recordset() + self.invoice_in.invalidate_recordset() self.invoice_in._compute_amount() self.assertEqual(self.invoice_in.amount_residual, 0.0) def test_pos_out_invoice(self): self.assertEqual(self.invoice_out.amount_residual, 100.0) - self.pos_config.open_session_cb() + self.pos_config._action_to_open_ui() session = self.pos_config.current_session_id out_invoice = self.env["pos.box.cash.invoice.out"].with_context( active_ids=session.ids, @@ -122,15 +108,14 @@ def test_pos_out_invoice(self): form.amount = 75 out_invoice.browse(form.id).run() session.action_pos_session_closing_control() - session._validate_session() - session.flush() - self.invoice_out.flush() + session.invalidate_recordset() + self.invoice_out.invalidate_recordset() self.invoice_out._compute_amount() self.assertEqual(self.invoice_out.amount_residual, 25.0) def test_pos_invoice_refund(self): self.assertEqual(self.refund.amount_residual, 100.0) - self.pos_config.open_session_cb() + self.pos_config._action_to_open_ui() session = self.pos_config.current_session_id in_invoice = self.env["pos.box.cash.invoice.in"].with_context( active_ids=session.ids, @@ -142,8 +127,7 @@ def test_pos_invoice_refund(self): self.assertEqual(form.amount, -100) in_invoice.browse(form.id).run() session.action_pos_session_closing_control() - session._validate_session() - session.flush() - self.invoice_out.flush() - self.refund.refresh() + session.invalidate_recordset() + self.invoice_out.invalidate_recordset() + self.refund.invalidate_recordset() self.assertEqual(self.refund.amount_residual, 0.0) diff --git a/pos_session_pay_invoice/views/pos_session.xml b/pos_session_pay_invoice/views/pos_session.xml index 87e3cca07d..d5c956b735 100644 --- a/pos_session_pay_invoice/views/pos_session.xml +++ b/pos_session_pay_invoice/views/pos_session.xml @@ -36,8 +36,8 @@