diff --git a/pos_session_pay_invoice/README.rst b/pos_session_pay_invoice/README.rst index 5e525e446f..38153a2b90 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| @@ -39,17 +39,23 @@ to collect payment for an existing Customer Invoice, from within a POS Session. Configuration ============= -#. Go to *Point of Sale / Configuration / Point of Sale* and activate the - 'Cash Control' setting. +#. Go to *Point of Sale / Configuration / Payment Methods* + and ensure that at least one payment method with a journal type "cash" + is created (or create one if it does not exist). + +#. Go to *Point of Sale / Configuration / Settings* + Select a Point of Sale and ensure than in the payment methods section, + at least one payment method has a journal type "cash" Usage ===== #. Go to *Point of Sale / Dashboard* and create and open or access to an already open POS Session. -#. Press the button **Pay Invoice** to pay a Supplier Invoice or a Customer +#. Open the POS Session form view on the Backend. +#. Press the button **Pay Supplier** to pay a Supplier Invoice or **Pay Refund** for a Customer Refund. It will be paid using Cash. -#. Select **Collect Payment from Invoice** in to receive a payment of an +#. Select **Get Payment from Invoice** to receive a payment of an existing Customer Invoice or a Supplier Refund. You will need to select a Journal if the POS Config has defined multiple Payment Methods. @@ -59,16 +65,13 @@ Known issues / Roadmap * Cannot pay invoices in a different currency than that defined in the journal associated to the payment method used to pay/collect payment. -* Should depend on `pos_invoicing` but it requires a refactoring of `pos_invoicing`. - It will be improved when migrating to 13.0 - 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 +88,9 @@ Contributors * Enric Tobella * Jordi Ballester +* Tecnativa (https://www.tecnativa.com): + + * Carlos Lopez Maintainers ~~~~~~~~~~~ @@ -99,6 +105,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..57eef3267e 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", @@ -11,10 +11,7 @@ "license": "LGPL-3", "depends": ["point_of_sale", "account_cash_invoice"], "data": [ - "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..7e46d7d2e6 --- /dev/null +++ b/pos_session_pay_invoice/models/pos_session.py @@ -0,0 +1,35 @@ +from odoo import models + + +class PosSession(models.Model): + _inherit = "pos.session" + + def button_show_wizard_pay_in_invoice(self): + action = self._get_action_wizard_pay_invoice() + action["context"]["pos_pay_invoice_type"] = "vendor" + action["context"]["pos_pay_invoice_domain"] = "in_invoice" + return action + + def button_show_wizard_pay_out_refund(self): + action = self._get_action_wizard_pay_invoice() + action["context"]["pos_pay_invoice_type"] = "vendor" + action["context"]["pos_pay_invoice_domain"] = "out_refund" + return action + + def button_show_wizard_pay_out_invoice(self): + action = self._get_action_wizard_pay_invoice() + action["context"]["pos_pay_invoice_type"] = "customer" + action["context"]["pos_pay_invoice_domain"] = "out_invoice" + return action + + def _get_action_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/CONFIGURE.rst b/pos_session_pay_invoice/readme/CONFIGURE.rst index ecefd6e106..1dea19c5fd 100644 --- a/pos_session_pay_invoice/readme/CONFIGURE.rst +++ b/pos_session_pay_invoice/readme/CONFIGURE.rst @@ -1,2 +1,7 @@ -#. Go to *Point of Sale / Configuration / Point of Sale* and activate the - 'Cash Control' setting. +#. Go to *Point of Sale / Configuration / Payment Methods* + and ensure that at least one payment method with a journal type "cash" + is created (or create one if it does not exist). + +#. Go to *Point of Sale / Configuration / Settings* + Select a Point of Sale and ensure than in the payment methods section, + at least one payment method has a journal type "cash" 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/readme/ROADMAP.rst b/pos_session_pay_invoice/readme/ROADMAP.rst index e9a91dc501..83dd2652f0 100644 --- a/pos_session_pay_invoice/readme/ROADMAP.rst +++ b/pos_session_pay_invoice/readme/ROADMAP.rst @@ -1,5 +1,2 @@ * Cannot pay invoices in a different currency than that defined in the journal associated to the payment method used to pay/collect payment. - -* Should depend on `pos_invoicing` but it requires a refactoring of `pos_invoicing`. - It will be improved when migrating to 13.0 diff --git a/pos_session_pay_invoice/readme/USAGE.rst b/pos_session_pay_invoice/readme/USAGE.rst index 7f4d8f3ca7..5ecb420da1 100644 --- a/pos_session_pay_invoice/readme/USAGE.rst +++ b/pos_session_pay_invoice/readme/USAGE.rst @@ -1,7 +1,8 @@ #. Go to *Point of Sale / Dashboard* and create and open or access to an already open POS Session. -#. Press the button **Pay Invoice** to pay a Supplier Invoice or a Customer +#. Open the POS Session form view on the Backend. +#. Press the button **Pay Supplier** to pay a Supplier Invoice or **Pay Refund** for a Customer Refund. It will be paid using Cash. -#. Select **Collect Payment from Invoice** in to receive a payment of an +#. Select **Get Payment from Invoice** to receive a payment of an existing Customer Invoice or a Supplier Refund. You will need to select a Journal if the POS Config has defined multiple Payment Methods. diff --git a/pos_session_pay_invoice/security/ir.model.access.csv b/pos_session_pay_invoice/security/ir.model.access.csv deleted file mode 100644 index 829e93e93e..0000000000 --- a/pos_session_pay_invoice/security/ir.model.access.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_pos_box_cash_invoice_in,access_pos_box_cash_invoice_in,model_pos_box_cash_invoice_in,base.group_user,1,1,1,1 -access_pos_box_cash_invoice_out,access_pos_box_cash_invoice_out,model_pos_box_cash_invoice_out,base.group_user,1,1,1,1 diff --git a/pos_session_pay_invoice/static/description/index.html b/pos_session_pay_invoice/static/description/index.html index 15ecdc78b7..a95dc484b1 100644 --- a/pos_session_pay_invoice/static/description/index.html +++ b/pos_session_pay_invoice/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -369,7 +369,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

@@ -390,8 +390,12 @@

POS Session Pay invoice

Configuration

    -
  1. Go to Point of Sale / Configuration / Point of Sale and activate the -‘Cash Control’ setting.
  2. +
  3. Go to Point of Sale / Configuration / Payment Methods +and ensure that at least one payment method with a journal type “cash” +is created (or create one if it does not exist).
  4. +
  5. Go to Point of Sale / Configuration / Settings +Select a Point of Sale and ensure than in the payment methods section, +at least one payment method has a journal type “cash”
@@ -399,9 +403,10 @@

Usage

  1. Go to Point of Sale / Dashboard and create and open or access to an already open POS Session.
  2. -
  3. Press the button Pay Invoice to pay a Supplier Invoice or a Customer +
  4. Open the POS Session form view on the Backend.
  5. +
  6. Press the button Pay Supplier to pay a Supplier Invoice or Pay Refund for a Customer Refund. It will be paid using Cash.
  7. -
  8. Select Collect Payment from Invoice in to receive a payment of an +
  9. Select Get Payment from Invoice to receive a payment of an existing Customer Invoice or a Supplier Refund. You will need to select a Journal if the POS Config has defined multiple Payment Methods.
@@ -411,8 +416,6 @@

Known issues / Roadmap

  • Cannot pay invoices in a different currency than that defined in the journal associated to the payment method used to pay/collect payment.
  • -
  • Should depend on pos_invoicing but it requires a refactoring of pos_invoicing. -It will be improved when migrating to 13.0
@@ -420,7 +423,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,16 +439,22 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

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..b6700181ee 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,67 +76,52 @@ 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_in_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, - active_model="pos.session", - default_session_id=session.id, - ) - with Form(out_invoice) as form: - form.move_id = self.invoice_out + wizard_context = session.button_show_wizard_pay_out_invoice()["context"] + cash_out = self.env["cash.pay.invoice"].with_context(**wizard_context) + with Form(cash_out) as form: + form.invoice_id = self.invoice_out self.assertEqual(form.amount, 100) form.amount = 75 - out_invoice.browse(form.id).run() + cash_out.browse(form.id).action_pay_invoice() 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, - active_model="pos.session", - default_session_id=session.id, - ) - with Form(in_invoice) as form: - form.move_id = self.refund + wizard_context = session.button_show_wizard_pay_out_refund()["context"] + cash_out = self.env["cash.pay.invoice"].with_context(**wizard_context) + with Form(cash_out) as form: + form.invoice_id = self.refund self.assertEqual(form.amount, -100) - in_invoice.browse(form.id).run() + cash_out.browse(form.id).action_pay_invoice() 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..3ad2b4a8fa 100644 --- a/pos_session_pay_invoice/views/pos_session.xml +++ b/pos_session_pay_invoice/views/pos_session.xml @@ -23,11 +23,10 @@