Skip to content

Commit

Permalink
[RFC] l10n_br_fiscal: refactor to prevent potential incorret entries
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelsavegnago committed Dec 9, 2024
1 parent 9741c82 commit 7270481
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 9 additions & 0 deletions l10n_br_fiscal/models/operation_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ def _get_cancelled_documents(self):
def action_create_new(self):
ctx = self._context.copy()
model = "l10n_br_fiscal.document"
if self.document_type_ids:
ctx.update(

Check warning on line 106 in l10n_br_fiscal/models/operation_dashboard.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_fiscal/models/operation_dashboard.py#L106

Added line #L106 was not covered by tests
{
"default_document_type_id": self.document_type_ids[
0
].document_type_id.id,
}
)
if self.fiscal_operation_type == "out":
ctx.update(
{
Expand Down Expand Up @@ -154,6 +162,7 @@ def open_action(self):
ctx.update(
{
"default_fiscal_operation_type": fiscal_operation_type,
"create": False,
}
)

Expand Down
9 changes: 7 additions & 2 deletions l10n_br_fiscal/views/l10n_br_fiscal_action.xml
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@
<field name="view_mode">kanban,tree,form</field>
<field name="search_view_id" ref="document_search" />
<field name="view_id" ref="document_tree" />
<field name="context">{'create': False}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new Document
Expand All @@ -616,7 +617,9 @@
<field name="search_view_id" ref="document_search" />
<field name="view_id" ref="document_tree" />
<field name="domain">[('fiscal_operation_type', '=', 'in')]</field>
<field name="context">{'default_fiscal_operation_type': 'in'}</field>
<field
name="context"
>{'default_fiscal_operation_type': 'in', 'create': False}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new Document
Expand All @@ -636,7 +639,9 @@
<field name="search_view_id" ref="document_search" />
<field name="view_id" ref="document_tree" />
<field name="domain">[('fiscal_operation_type', '=', 'out')]</field>
<field name="context">{'default_fiscal_operation_type': 'out'}</field>
<field
name="context"
>{'default_fiscal_operation_type': 'out', 'create': False}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new Document
Expand Down

0 comments on commit 7270481

Please sign in to comment.