Skip to content

Commit

Permalink
IMP l10n_it_vat_registries: ordering option
Browse files Browse the repository at this point in the history
  • Loading branch information
eLBati committed Feb 16, 2024
1 parent 94c6063 commit 921c9ae
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
7 changes: 7 additions & 0 deletions l10n_it_vat_registries/models/account_tax_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ class AccountTaxRegistry(models.Model):
required=True,
default=lambda self: self.env.company,
)
entry_order = fields.Selection(
[
("date_name", "Date - Number"),
("journal_date_name", "Journal - Date - Number"),
],
default="date_name",
)
journal_ids = fields.One2many(
"account.journal", "tax_registry_id", "Journals", readonly=True
)
Expand Down
1 change: 1 addition & 0 deletions l10n_it_vat_registries/models/vat_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def _get_report_values(self, docids, data=None):
"compute_totals_tax": self._compute_totals_tax,
"l10n_it_count_fiscal_page_base": data["form"]["fiscal_page_base"],
"only_totals": data["form"]["only_totals"],
"entry_order": data["form"].get("entry_order"),
"date_format": date_format,
"year_footer": data["form"]["year_footer"],
}
Expand Down
13 changes: 13 additions & 0 deletions l10n_it_vat_registries/report/report_registro_iva.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@
t-value="total_used_taxes | used_taxes"
/>
<t t-foreach="inv_taxes" t-as="line">
<t t-if="entry_order == 'journal_date_name'">
<t t-if="move.journal_id.id != sv_journal_id">
<tr>
<td colspan='9'>
<h5
style="page-break-inside: avoid;border-top:1px solid;border-bottom:1px solid; color:DimGrey;"
t-esc="move.journal_id.name"
/>
</td>
</tr>
</t>
</t>
<t t-set="sv_journal_id" t-value="move.journal_id.id" />
<t t-if="print_details > 0 ">
<t
t-set="line_class_left"
Expand Down
1 change: 1 addition & 0 deletions l10n_it_vat_registries/views/account_tax_registry_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<group>
<field name="name" />
<field name="layout_type" />
<field name="entry_order" />
</group>
<separator string="Journals" />
<field name="journal_ids" />
Expand Down
16 changes: 15 additions & 1 deletion l10n_it_vat_registries/wizard/print_registro_iva.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ class WizardRegistroIva(models.TransientModel):
default="customer",
)
tax_registry_id = fields.Many2one("account.tax.registry", "VAT registry")
entry_order = fields.Selection(
[
("date_name", "Date - Number"),
("journal_date_name", "Journal - Date - Number"),
],
default="date_name",
)
journal_ids = fields.Many2many(
"account.journal",
"registro_iva_journals_rel",
Expand All @@ -41,6 +48,7 @@ class WizardRegistroIva(models.TransientModel):
def on_change_tax_registry_id(self):
self.journal_ids = self.tax_registry_id.journal_ids
self.layout_type = self.tax_registry_id.layout_type
self.entry_order = self.tax_registry_id.entry_order

@api.onchange("date_range_id")
def on_change_date_range_id(self):
Expand All @@ -54,14 +62,19 @@ def get_year_footer(self):
self.year_footer = self.from_date.year

def _get_move_ids(self, wizard):
MAPPING = {
"journal_date_name": "journal_id, date, name",
"date_name": "date, name",
}
order = MAPPING[wizard.entry_order]
moves = self.env["account.move"].search(
[
("date", ">=", self.from_date),
("date", "<=", self.to_date),
("journal_id", "in", [j.id for j in self.journal_ids]),
("state", "=", "posted"),
],
order="date, name",
order=order,
)
return moves.ids

Expand Down Expand Up @@ -96,6 +109,7 @@ def print_registro(self):
else:
datas_form["tax_registry_name"] = ""
datas_form["only_totals"] = wizard.only_totals
datas_form["entry_order"] = wizard.entry_order
# report_name = 'l10n_it_vat_registries.report_registro_iva'
report_name = "l10n_it_vat_registries.action_report_registro_iva"
datas = {"ids": move_ids, "model": "account.move", "form": datas_form}
Expand Down
1 change: 1 addition & 0 deletions l10n_it_vat_registries/wizard/print_registro_iva.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<separator string="Journals" colspan="2" />
<group>
<field name="tax_registry_id" />
<field name="entry_order" />
</group>
<field
name="journal_ids"
Expand Down

0 comments on commit 921c9ae

Please sign in to comment.