Skip to content

Commit

Permalink
[IMP] l10n_br_account_payment_order: wizard trigger CNAB info load af…
Browse files Browse the repository at this point in the history
…ter posted
  • Loading branch information
kaynnan committed Jul 27, 2024
1 parent 1b26aea commit 183e4d2
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions l10n_br_account_payment_order/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
# Wizards
"wizards/account_payment_line_create_view.xml",
"wizards/account_move_line_change.xml",
"wizards/account_move_payment_mode.xml",
# Views
"views/account_journal.xml",
"views/account_payment_order.xml",
Expand Down
1 change: 1 addition & 0 deletions l10n_br_account_payment_order/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ access_l10n_br_cnab_payment_fields_manager,l10n_br_cnab.payment.fields manager,m
access_account_move_line_cnab_change_user,access_account_move_line_cnab_change_user,model_account_move_line_cnab_change,group_cnab_user,1,1,1,1
access_l10n_br_cnab_boleto_wallet_code_manager,access_l10n_br_cnab_boleto_wallet_code manager,model_l10n_br_cnab_boleto_wallet_code,group_cnab_manager,1,1,1,1
access_l10n_br_cnab_boleto_wallet_code_user,access_l10n_br_cnab_boleto_wallet_code user,model_l10n_br_cnab_boleto_wallet_code,group_cnab_user,1,0,0,0
access_account_move_payment_mode_cnab_change_user,access_account_move_payment_mode_cnab_change,model_account_move_payment_mode_cnab_change,base.group_user,1,1,1,1
1 change: 1 addition & 0 deletions l10n_br_account_payment_order/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import account_payment_line_create
from . import account_move_line_change
from . import account_move_payment_mode
24 changes: 24 additions & 0 deletions l10n_br_account_payment_order/wizards/account_move_payment_mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2024 - TODAY, Kaynnan Lemes <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models

from ..constants import BR_CODES_PAYMENT_ORDER


class AccountMovePaymentModeWizard(models.TransientModel):
_name = "account.move.payment.mode.cnab.change"
_description = "Account Move Payment Mode CNAB Wizard"

payment_mode_id = fields.Many2one(
"account.payment.mode",
required=True,
domain=lambda self: [("payment_method_code", "in", BR_CODES_PAYMENT_ORDER)],
)

def set_payment_mode(self):
move_id = self.env.context.get("active_id")
move = self.env["account.move"].browse(move_id)

Check warning on line 21 in l10n_br_account_payment_order/wizards/account_move_payment_mode.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account_payment_order/wizards/account_move_payment_mode.py#L20-L21

Added lines #L20 - L21 were not covered by tests
if move.state == "posted":
move.payment_mode_id = self.payment_mode_id
move.load_cnab_info()

Check warning on line 24 in l10n_br_account_payment_order/wizards/account_move_payment_mode.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account_payment_order/wizards/account_move_payment_mode.py#L23-L24

Added lines #L23 - L24 were not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 - TODAY, Kaynnan Lemes <[email protected]>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

<record id="account_move_payment_mode_cnab_change_wizard_form" model="ir.ui.view">
<field name="name">account.move.payment.mode.cnab.change.form</field>
<field name="model">account.move.payment.mode.cnab.change</field>
<field name="arch" type="xml">
<form string="Set Payment Mode CNAB">
<group>
<field name="payment_mode_id" />
</group>
<footer>
<button
name="set_payment_mode"
string="Confirm"
class="btn-primary"
type="object"
/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
</field>
</record>

<record
id="account_move_payment_mode_cnab_change_wizard_action"
model="ir.actions.act_window"
>
<field name="name">Set Payment Mode CNAB</field>
<field name="res_model">account.move.payment.mode.cnab.change</field>
<field name="view_mode">form</field>
<field name="context">{}</field>
<field name="target">new</field>
</record>

<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.view</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath expr="//button[@name='action_post']" position="after">
<button
name="%(account_move_payment_mode_cnab_change_wizard_action)d"
string="Set Payment Mode CNAB"
type="action"
class="oe_highlight"
attrs="{'invisible': [('state', '!=', 'posted')]}"
/>
</xpath>
</field>
</record>

</odoo>

0 comments on commit 183e4d2

Please sign in to comment.