Browse Source

Merge PR #311 into 12.0

Signed-off-by sebastienbeau
pull/321/head
OCA-git-bot 5 years ago
parent
commit
cb713086c6
  1. 6
      report_xlsx_helper/report/report_xlsx_abstract.py
  2. 12
      report_xlsx_helper/report/test_partner_report_xlsx.py
  3. 7
      report_xlsx_helper/tests/test_report_xlsx_helper.py
  4. 1
      report_xlsx_helper_demo/report/partner_export_xlsx.py

6
report_xlsx_helper/report/report_xlsx_abstract.py

@ -1,7 +1,7 @@
# Copyright 2009-2018 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import datetime
from datetime import datetime, date
import re
from types import CodeType
from xlsxwriter.utility import xl_rowcol_to_cell
@ -503,6 +503,10 @@ class ReportXlsxAbstract(models.AbstractModel):
cell_type = 'number'
elif isinstance(cell_value, datetime):
cell_type = 'datetime'
elif isinstance(cell_value, date):
cell_value = datetime.combine(
cell_value, datetime.min.time())
cell_type = 'datetime'
else:
if not cell_value:
cell_type = 'blank'

12
report_xlsx_helper/report/test_partner_report_xlsx.py

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2018 Noviat.
# Copyright 2009-2019 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
@ -53,6 +52,15 @@ class TestPartnerXlsx(models.AbstractModel):
},
'width': 14,
},
'date': {
'header': {
'value': 'Date',
},
'data': {
'value': self._render("partner.date"),
},
'width': 13,
},
}
ws_params = {

7
report_xlsx_helper/tests/test_report_xlsx_helper.py

@ -1,6 +1,8 @@
# Copyright 2009-2018 Noviat.
# Copyright 2009-2019 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import date
from odoo.tests.common import TransactionCase
@ -8,8 +10,11 @@ class TestReportXlsxHelper(TransactionCase):
def setUp(self):
super(TestReportXlsxHelper, self).setUp()
today = date.today()
p1 = self.env.ref('base.res_partner_1')
p2 = self.env.ref('base.res_partner_2')
p1.date = today
p2.date = today
self.partners = p1 + p2
ctx = {
'report_name': 'report_xlsx_helper.test_partner_xlsx',

1
report_xlsx_helper_demo/report/partner_export_xlsx.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2009-2018 Noviat.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Loading…
Cancel
Save