mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
[IMP] intrastat_product: method for XLSX filename
This commit is contained in:
@@ -936,6 +936,30 @@ class IntrastatProductDeclaration(models.Model):
|
||||
"""
|
||||
return {}
|
||||
|
||||
@api.model
|
||||
def _get_xlsx_report_filename(self):
|
||||
self.ensure_one()
|
||||
declaration_type_label = dict(
|
||||
self.fields_get("declaration_type", "selection")["declaration_type"][
|
||||
"selection"
|
||||
]
|
||||
)[self.declaration_type]
|
||||
draft_label = ""
|
||||
if self.state == "draft":
|
||||
draft_label = (
|
||||
"-%s"
|
||||
% dict(self.fields_get("state", "selection")["state"]["selection"])[
|
||||
self.state
|
||||
]
|
||||
)
|
||||
filename = _(
|
||||
"intrastat-%(year_month)s-%(declaration_type)s%(draft)s",
|
||||
year_month=self.year_month,
|
||||
declaration_type=declaration_type_label,
|
||||
draft=draft_label,
|
||||
)
|
||||
return filename
|
||||
|
||||
def done(self):
|
||||
for decl in self:
|
||||
decl.generate_declaration()
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
<field name="report_type">xlsx</field>
|
||||
<field name="report_name">intrastat_product.product_declaration_xls</field>
|
||||
<field name="report_file">intrastat_product.product_declaration_xls</field>
|
||||
<field
|
||||
name="print_report_name"
|
||||
>'intrastat-%s-%s%s' % (object.year_month, object.declaration_type, object.state == 'draft' and '-draft' or '')</field>
|
||||
<field name="print_report_name">object._get_xlsx_report_filename()</field>
|
||||
<field name="binding_model_id" ref="model_intrastat_product_declaration" />
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user