Skip to content

Commit

Permalink
Add field move_line_count
Browse files Browse the repository at this point in the history
Add button box in form view
  • Loading branch information
alexis-via committed May 7, 2024
1 parent ad53c8f commit dfe9a53
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
21 changes: 15 additions & 6 deletions account_move_export/models/account_move_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def default_get(self, fields_list):
"('company_id', '=', company_id), ('state', '!=', 'cancel')]",
)
move_count = fields.Integer(
compute="_compute_move_count", store=True, string="# of Journal Entries"
compute="_compute_counts", store=True, string="# of Journal Entries"
)
move_line_count = fields.Integer(
compute="_compute_counts", store=True, string="# of Journal Items"
)
date_range_id = fields.Many2one(
"date.range",
Expand Down Expand Up @@ -229,20 +232,26 @@ def _compute_dates(self):
export.date_end = export.date_range_id.date_end

@api.depends("move_ids")
def _compute_move_count(self):
rg_res = self.env["account.move"].read_group(
def _compute_counts(self):
rg_move_res = self.env["account.move"].read_group(
[("account_move_export_id", "in", self.ids)],
["account_move_export_id"],
["account_move_export_id"],
)
mapped_data = dict(
move_data = dict(
[
(x["account_move_export_id"][0], x["account_move_export_id_count"])
for x in rg_res
for x in rg_move_res
]
)
for export in self:
export.move_count = mapped_data.get(export.id, 0)
export.move_count = move_data.get(export.id, 0)
export.move_line_count = self.env["account.move.line"].search_count(
[
("move_id.account_move_export_id", "=", export.id),
("display_type", "not in", ("line_section", "line_note")),
]
)

@api.constrains("date_start", "date_end")
def _check_dates(self):
Expand Down
38 changes: 27 additions & 11 deletions account_move_export/views/account_move_export.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,36 @@
confirm="Are you sure you want to go back to draft?"
string="Back to Draft"
/>
<button
name="button_account_move_fullscreen"
type="object"
string="Journal Entries Fullscreen"
/>
<button
name="button_account_move_line_fullscreen"
type="object"
string="Journal Items Fullscreen"
/>
<field name="state" widget="statusbar" />
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button
class="oe_stat_button"
name="button_account_move_fullscreen"
type="object"
help="Show journal entries fullscreen"
icon="fa-building-o"
>
<field
name="move_count"
widget="statinfo"
string="Journal Entries"
/>
</button>
<button
name="button_account_move_line_fullscreen"
type="object"
help="Show journal items fullscreen"
icon="fa-bars"
>
<field
name="move_line_count"
widget="statinfo"
string="Journal Items"
/>
</button>
</div>
<div class="oe_title">
<h1>
<field name="name" />
Expand Down Expand Up @@ -87,7 +104,6 @@
<group name="export_file" string="Export File" colspan="2">
<field name="file_format" />
<field name="attachment_datas" filename="attachment_name" />
<field name="move_count" />
<field name="attachment_id" invisible="1" />
<field name="attachment_name" invisible="1" />

Expand Down

0 comments on commit dfe9a53

Please sign in to comment.