[14.0][FWD] partner_statement
- Added html and xlsx support for activity outgoing statement
This commit is contained in:
committed by
Miquel Raïch
parent
f3e1ac3b18
commit
17a596997a
@@ -29,14 +29,27 @@ class ActivityStatementWizard(models.TransientModel):
|
||||
else:
|
||||
self.date_start = self.date_end - relativedelta(days=30)
|
||||
|
||||
def _export(self):
|
||||
"""Export to PDF."""
|
||||
data = self._prepare_statement()
|
||||
return self.env.ref(
|
||||
"partner_statement.action_print_activity_statement"
|
||||
).report_action(self.ids, data=data)
|
||||
|
||||
def _prepare_statement(self):
|
||||
res = super()._prepare_statement()
|
||||
res.update({"date_start": self.date_start})
|
||||
return res
|
||||
|
||||
def _print_report(self, report_type):
|
||||
self.ensure_one()
|
||||
data = self._prepare_statement()
|
||||
if report_type == "xlsx":
|
||||
report_name = "p_s.report_activity_statement_xlsx"
|
||||
else:
|
||||
report_name = "partner_statement.activity_statement"
|
||||
return (
|
||||
self.env["ir.actions.report"]
|
||||
.search(
|
||||
[("report_name", "=", report_name), ("report_type", "=", report_type)],
|
||||
limit=1,
|
||||
)
|
||||
.report_action(self, data=data)
|
||||
)
|
||||
|
||||
def _export(self, report_type):
|
||||
"""Default export is PDF."""
|
||||
return self._print_report(report_type)
|
||||
|
||||
@@ -11,9 +11,22 @@ class OutstandingStatementWizard(models.TransientModel):
|
||||
_inherit = "statement.common.wizard"
|
||||
_description = "Outstanding Statement Wizard"
|
||||
|
||||
def _export(self):
|
||||
"""Export to PDF."""
|
||||
def _print_report(self, report_type):
|
||||
self.ensure_one()
|
||||
data = self._prepare_statement()
|
||||
return self.env.ref(
|
||||
"partner_statement.action_print_outstanding_statement"
|
||||
).report_action(self.ids, data=data)
|
||||
if report_type == "xlsx":
|
||||
report_name = "p_s.report_outstanding_statement_xlsx"
|
||||
else:
|
||||
report_name = "partner_statement.outstanding_statement"
|
||||
return (
|
||||
self.env["ir.actions.report"]
|
||||
.search(
|
||||
[("report_name", "=", report_name), ("report_type", "=", report_type)],
|
||||
limit=1,
|
||||
)
|
||||
.report_action(self, data=data)
|
||||
)
|
||||
|
||||
def _export(self, report_type):
|
||||
"""Default export is PDF."""
|
||||
return self._print_report(report_type)
|
||||
|
||||
@@ -50,10 +50,6 @@ class StatementCommon(models.AbstractModel):
|
||||
else:
|
||||
self.date_end = fields.Date.context_today(self)
|
||||
|
||||
def button_export_pdf(self):
|
||||
self.ensure_one()
|
||||
return self._export()
|
||||
|
||||
def _prepare_statement(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
@@ -67,5 +63,17 @@ class StatementCommon(models.AbstractModel):
|
||||
"filter_negative_balances": self.filter_negative_balances,
|
||||
}
|
||||
|
||||
def _export(self):
|
||||
raise NotImplementedError
|
||||
def button_export_html(self):
|
||||
self.ensure_one()
|
||||
report_type = "qweb-html"
|
||||
return self._export(report_type)
|
||||
|
||||
def button_export_pdf(self):
|
||||
self.ensure_one()
|
||||
report_type = "qweb-pdf"
|
||||
return self._export(report_type)
|
||||
|
||||
def button_export_xlsx(self):
|
||||
self.ensure_one()
|
||||
report_type = "xlsx"
|
||||
return self._export(report_type)
|
||||
|
||||
@@ -72,13 +72,25 @@
|
||||
</group>
|
||||
<footer>
|
||||
<button
|
||||
name="button_export_pdf"
|
||||
string="Export PDF"
|
||||
name="button_export_html"
|
||||
string="View"
|
||||
type="object"
|
||||
default_focus="1"
|
||||
class="oe_highlight"
|
||||
/>
|
||||
or
|
||||
<button
|
||||
name="button_export_pdf"
|
||||
string="Export PDF"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button
|
||||
name="button_export_xlsx"
|
||||
string="Export XLSX"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user