Skip to content
Snippets Groups Projects
Commit 2eaf7e61 authored by emanuel buzey's avatar emanuel buzey Committed by Daniil Digtyar Vasilieva
Browse files

Remove report.txt header, rename file, move view, and refactor code

parent 52b0d418
No related branches found
No related tags found
2 merge requests!195[REL] 14.0.2.0.0,!192[IMP] self_consumption: adding reports and documents
......@@ -22,12 +22,12 @@
"data/project_type_data.xml",
"data/ir_sequence_data.xml",
"data/ir_attactment_data.xml",
"data/custom_paper_format_views.xml",
"views/selfconsumption_views.xml",
"views/supply_point_views.xml",
"views/res_partner_views.xml",
"views/distribution_table_views.xml",
"views/supply_point_assignation_views.xml",
"views/custom_paper_format_views.xml",
"wizards/selfconsumption_import_wizard_views.xml",
"wizards/distribution_table_import_wizard_views.xml",
"reports/selfconsumption_reports.xml",
......
<odoo>
<record id="custom_paperformat_id" model="report.paperformat">
<field name="name">A4 Format Without Margins</field>
<field name="custom_format_name">Self-consumption Reports</field>
<field name="name">A4 Format Self-consumption Manager Authorization</field>
<field name="format">custom</field>
<field name="page_width">210</field>
<field name="page_height">297</field>
......
......@@ -3,4 +3,3 @@ from . import supply_point
from . import partner
from . import distribution_table
from . import supply_point_assignation
from . import custom_paper_format
from odoo import models, fields
class CustomPaperFormat(models.Model):
_inherit = 'report.paperformat'
custom_format_name = fields.Char('Custom Format Name', required=True)
custom_page_width = fields.Float('Custom Page Width')
custom_page_height = fields.Float('Custom Page Height')
custom_margin_top = fields.Float('Custom Margin Top')
custom_margin_bottom = fields.Float('Custom Margin Bottom')
custom_margin_left = fields.Float('Custom Margin Left')
custom_margin_right = fields.Float('Custom Margin Right')
orientation = fields.Char('Orientation')
\ No newline at end of file
......@@ -120,12 +120,12 @@ class Selfconsumption(models.Model):
'code': assignation.supply_point_id.code,
'coefficient': assignation.coefficient,
})
file_content = "Code;Coefficient\n"
file_content = ""
for data in report_data:
line = f"{data['code']};{str(data['coefficient']).replace('.', ',')}\n"
file_content += line
txt_file = io.BytesIO(file_content.encode())
file_name = "coefficient_report.txt"
file_name = "Coeficiente de reparto.txt"
self.write({
'report_file': base64.b64encode(txt_file.getvalue()),
'report_file_name': file_name,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment