diff --git a/pos_payment_change/__manifest__.py b/pos_payment_change/__manifest__.py index 3fe47e6da4..8a448a4004 100644 --- a/pos_payment_change/__manifest__.py +++ b/pos_payment_change/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Point Of Sale - Change Payments", - "version": "16.0.1.0.4", + "version": "17.0.1.0.0", "summary": "Allow cashier to change order payments, as long as" " the session is not closed.", "category": "Point Of Sale", diff --git a/pos_payment_change/static/description/index.html b/pos_payment_change/static/description/index.html index 86a38d40c1..8d489d639a 100644 --- a/pos_payment_change/static/description/index.html +++ b/pos_payment_change/static/description/index.html @@ -8,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. @@ -274,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 } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -368,12 +369,12 @@

Point Of Sale - Change Payments

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:f92dd72ac053a86a8837e2a670cfa091391cadb66e6e3b45553b3b34f8d76400 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

This module extends the functionnality of the Odoo Point of Sale to allow the cashier to change the payments of a PoS order.

This feature is usefull when the user realized that he did a mistake, -just after he marked the order as paid, or during the close of the session, -Only if entries has not been generated.

+just after he marked the order as paid, or during the close of the +session, Only if entries has not been generated.

Table of contents

-
-https://raw.githubusercontent.com/OCA/pos/16.0/pos_payment_change/static/description/pos_order_form.png -
+

Button Change Payment

-
-https://raw.githubusercontent.com/OCA/pos/16.0/pos_payment_change/static/description/pos_payment_change_wizard_form.png -
+

Button Open Wizard

Note

-

If the option ‘Refund and Resale’ is selected, changing the payments will -display the three PoS orders. the oringal one, the refund one, and the new one.

-
-https://raw.githubusercontent.com/OCA/pos/16.0/pos_payment_change/static/description/pos_order_tree.png -
+

If the option ‘Refund and Resale’ is selected, changing the payments +will display the three PoS orders. the oringal one, the refund one, and +the new one.

+

New POS Payments Created

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.

@@ -470,20 +462,23 @@

Contributors

Other credits

The development of this module has been financially supported by:

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.

Current maintainer:

legalsylvain

-

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_payment_change/views/view_pos_config.xml b/pos_payment_change/views/view_pos_config.xml index 6ec422b38b..196c697683 100644 --- a/pos_payment_change/views/view_pos_config.xml +++ b/pos_payment_change/views/view_pos_config.xml @@ -10,22 +10,15 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). pos.config - -
-
- Payment Change Policy -
- -
-
-
+ + + +
diff --git a/pos_payment_change/views/view_pos_order.xml b/pos_payment_change/views/view_pos_order.xml index bde665be8a..7c19134223 100644 --- a/pos_payment_change/views/view_pos_order.xml +++ b/pos_payment_change/views/view_pos_order.xml @@ -13,10 +13,10 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
diff --git a/pos_payment_change/wizards/pos_payment_change_wizard.py b/pos_payment_change/wizards/pos_payment_change_wizard.py index a68514086f..b9373fbc49 100644 --- a/pos_payment_change/wizards/pos_payment_change_wizard.py +++ b/pos_payment_change/wizards/pos_payment_change_wizard.py @@ -12,7 +12,13 @@ class PosPaymentChangeWizard(models.TransientModel): _description = "PoS Payment Change Wizard" # Column Section - order_id = fields.Many2one(comodel_name="pos.order", string="Order", readonly=True) + order_id = fields.Many2one( + comodel_name="pos.order", + string="Order", + readonly=True, + required=True, + ondelete="cascade", + ) old_line_ids = fields.One2many( comodel_name="pos.payment.change.wizard.old.line", @@ -27,14 +33,16 @@ class PosPaymentChangeWizard(models.TransientModel): string="New Payment Lines", ) - amount_total = fields.Float(string="Total", readonly=True) + amount_total = fields.Float( + string="Total", readonly=True, related="order_id.amount_total" + ) # View Section @api.model def default_get(self, fields): PosOrder = self.env["pos.order"] res = super().default_get(fields) - order = PosOrder.browse(self._context.get("active_id")) + order = PosOrder.browse(self._context.get("pos_order_id")) old_lines_vals = [] for payment in order.payment_ids: old_lines_vals.append( diff --git a/pos_payment_change/wizards/pos_payment_change_wizard_new_line.py b/pos_payment_change/wizards/pos_payment_change_wizard_new_line.py index 72b571a1ac..591dbca202 100644 --- a/pos_payment_change/wizards/pos_payment_change_wizard_new_line.py +++ b/pos_payment_change/wizards/pos_payment_change_wizard_new_line.py @@ -19,7 +19,14 @@ class PosPaymentChangeWizardLine(models.TransientModel): comodel_name="pos.payment.method", string="Payment Method", required=True, - domain=lambda s: s._domain_new_payment_method_id(), + domain="[('id', 'in', available_payment_method_ids)]", + ) + + available_payment_method_ids = fields.Many2many( + comodel_name="pos.payment.method", + string="Available Payment Methods", + help="List of available payment methods for the current POS Order", + compute="_compute_available_payment_method_ids", ) company_currency_id = fields.Many2one( @@ -33,24 +40,22 @@ class PosPaymentChangeWizardLine(models.TransientModel): amount = fields.Monetary( required=True, - default=0.0, currency_field="company_currency_id", + compute="_compute_amount", + store=True, + readonly=False, ) - @api.model - def _domain_new_payment_method_id(self): - PosOrder = self.env["pos.order"] - order = PosOrder.browse(self.env.context.get("active_id")) - return [("id", "in", order.mapped("session_id.payment_method_ids").ids)] - - # View Section - @api.model - def default_get(self, fields): - res = super().default_get(fields) - if "new_line_ids" not in self._context: - return res - balance = self._context.get("amount_total", 0.0) - for line in self.wizard_id.old_line_ids: - balance -= line.get("amount") - res.update({"amount": balance}) - return res + @api.depends("wizard_id") + def _compute_available_payment_method_ids(self): + for line in self: + line.available_payment_method_ids = ( + line.wizard_id.order_id.session_id.payment_method_ids + ) + + @api.depends("wizard_id") + def _compute_amount(self): + for line in self: + line.amount = line.wizard_id.amount_total - sum( + old_line.amount for old_line in line.wizard_id.old_line_ids + ) diff --git a/pos_payment_change/wizards/view_pos_payment_change_wizard.xml b/pos_payment_change/wizards/view_pos_payment_change_wizard.xml index e947a8254e..91eb4811e9 100644 --- a/pos_payment_change/wizards/view_pos_payment_change_wizard.xml +++ b/pos_payment_change/wizards/view_pos_payment_change_wizard.xml @@ -11,11 +11,12 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
- + + @@ -28,6 +29,11 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +