Skip to content

Commit

Permalink
[FIX] account_move magic button on fiscal document fix OCA#3261
Browse files Browse the repository at this point in the history
Signed-off-by: Luis Felipe Miléo <[email protected]>
  • Loading branch information
mileo committed Aug 1, 2024
1 parent 0a62278 commit f40511b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion l10n_br_account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def open_fiscal_document(self):
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)

if len(self.fiscal_document_ids) == 1:
form_view = [(self.env.ref("l10n_br_fiscal.document_form").id, "form")]
form_view = [(self.env.ref("l10n_br_account.l10n_br_fiscal_document_form_inherit").id, "form")]
if "views" in action:
action["views"] = form_view + [
(state, view) for state, view in action["views"] if view != "form"
Expand Down
7 changes: 7 additions & 0 deletions l10n_br_account/models/fiscal_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,10 @@ def action_document_back2draft(self):
if self.move_ids:
self.move_ids.button_draft()
return result

def open_account_moves(self):
""""""
self.ensure_one()
action = self.env.ref('account.action_move_out_invoice_type').read()[0]
action["domain"] = [("id", "in", self.move_ids.ids)]
return action
20 changes: 18 additions & 2 deletions l10n_br_account/views/document_view.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="nfe_document_form_inherit" model="ir.ui.view">
<field name="name">l10n_br_nfe.document.form.inherit</field>
<record id="l10n_br_fiscal_document_form_inherit" model="ir.ui.view">
<field name="name">l10n_br_fiscal.document.form2</field>
<field name="model">l10n_br_fiscal.document</field>
<field name="inherit_id" ref="l10n_br_fiscal.document_form" />

<field name="mode">primary</field>
<field name="priority">1</field>

<field name="arch" type="xml">
<field name="state_fiscal" position="after">
<field name="move_ids" invisible="1" />
</field>
<div name="button_box" position="inside">
<button
name="open_account_moves"
title="Open Account Moves"
type="object"
class="oe_stat_button"
icon="fa-pencil-square-o"
attrs="{'invisible': [('move_ids', '=', [])]}"
>
<span>Account Moves</span>
</button>
</div>
</field>
</record>

Expand Down

0 comments on commit f40511b

Please sign in to comment.