Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions pos_close_approval/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"depends": ["pos_session_pay_invoice"],
"post_load": "post_load_hook",
"data": [
"wizards/change_payment_method_wizard.xml",
"wizards/pos_cash_box.xml",
"views/res_config_settings.xml",
"views/pos_payment.xml",
"security/ir.model.access.csv",
"wizards/bank_statement_account.xml",
"views/pos_session_views.xml",
Expand Down
1 change: 1 addition & 0 deletions pos_close_approval/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_bank_statement_line_account,access_account_bank_statement_line_account,model_account_bank_statement_line_account,point_of_sale.group_pos_manager,1,1,1,0
access_pos_cash_box,access_pos_cash_box,model_pos_cash_box,point_of_sale.group_pos_manager,1,1,1,0
pos_close_approval.access_change_payment_method_wizard,access_change_payment_method_wizard,model_change_payment_method_wizard,point_of_sale.group_pos_manager,1,1,1,0
23 changes: 23 additions & 0 deletions pos_close_approval/views/pos_payment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2021 Creu Blanca
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.ui.view" id="pos_payment_form_view">
<field name="name">pos.payment.form (in pos_close_approval)</field>
<field name="model">pos.payment</field>
<field name="inherit_id" ref="point_of_sale.view_pos_payment_form" />
<field name="arch" type="xml">
<xpath expr="//form/*[1]" position="before">
<header>
<button
name="%(pos_close_approval.change_payment_method_wizard_act_window)d"
type="action"
string="Change Payment Method"
class="btn-primary"
groups="point_of_sale.group_pos_manager"
/>
</header>
</xpath>
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions pos_close_approval/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import pos_cash_box
from . import bank_statement_account
from . import change_payment_method_wizard
46 changes: 46 additions & 0 deletions pos_close_approval/wizards/change_payment_method_wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2025 CreuBlanca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo.exceptions import UserError


class ChangePaymentMethodWizard(models.TransientModel):

_name = "change.payment.method.wizard"
_description = "Wizard para cambiar método de pago"

payment_id = fields.Many2one("pos.payment", required=True, readonly=True)
old_payment_method_id = fields.Many2one(
"pos.payment.method",
string="Método de pago antiguo",
required=True,
readonly=True,
)
new_payment_method_id = fields.Many2one(
"pos.payment.method", string="Nuevo método de pago", required=True
)

@api.model
def default_get(self, fields):
res = super().default_get(fields)
active_id = self.env.context.get("active_id")
if active_id:
payment = self.env["pos.payment"].browse(active_id)
res.update(
{
"payment_id": payment.id,
"old_payment_method_id": payment.payment_method_id.id,
}
)
return res

def confirm_change(self):
self.ensure_one()
payment = self.payment_id
session = payment.pos_order_id.session_id
if session.state == "closed":
raise UserError(
_("The session is closed, the payment method cannot be changed.")
)
payment.payment_method_id = self.new_payment_method_id
41 changes: 41 additions & 0 deletions pos_close_approval/wizards/change_payment_method_wizard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2025 CreuBlanca
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.ui.view" id="change_payment_method_wizard_form_view">
<field
name="name"
>change.payment.method.wizard.form (in pos_close_approval)</field>
<field name="model">change.payment.method.wizard</field>
<field name="arch" type="xml">
<form string="Change Payment Method Wizard">
<!-- TODO -->
<group>
<field name="payment_id" readonly="1" />
<field name="old_payment_method_id" readonly="1" />
<field name="new_payment_method_id" />
</group>
<footer>
<button
name="confirm_change"
string="Confirm"
class="btn-primary"
type="object"
/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
</field>
</record>

<record model="ir.actions.act_window" id="change_payment_method_wizard_act_window">
<field name="name">Change Payment Method Wizard</field> <!-- TODO -->
<field name="res_model">change.payment.method.wizard</field>
<field name="view_mode">form</field>
<field name="context">{}</field>
<field name="target">new</field>
</record>


</odoo>