diff --git a/datev_export_xml/__manifest__.py b/datev_export_xml/__manifest__.py index 76776a62..fefee7b7 100644 --- a/datev_export_xml/__manifest__.py +++ b/datev_export_xml/__manifest__.py @@ -16,9 +16,7 @@ "Maria Sparenberg, initOS GmbH, Odoo Community Association (OCA)", "summary": "Export invoices and refunds as xml and pdf files zipped in DATEV format.", "website": "https://github.com/OCA/l10n-germany", - "depends": [ - "datev_export", - ], + "depends": ["datev_export",], "data": [ "data/ir_cron_data.xml", "security/groups.xml", @@ -29,8 +27,6 @@ "views/res_config_settings_views.xml", "views/templates.xml", ], - "demo": [ - "demo/export_data.xml", - ], + "demo": ["demo/export_data.xml",], "installable": True, } diff --git a/datev_export_xml/models/datev_export.py b/datev_export_xml/models/datev_export.py index 0a6ca9b6..53922651 100644 --- a/datev_export_xml/models/datev_export.py +++ b/datev_export_xml/models/datev_export.py @@ -116,10 +116,7 @@ def name_get(self): datev_filename = fields.Char( "ZIP filename", readonly=True, related="attachment_id.name" ) - datev_filesize = fields.Char( - "Filesize", - compute="_compute_datev_filesize", - ) + datev_filesize = fields.Char("Filesize", compute="_compute_datev_filesize",) invoice_ids = fields.Many2many(comodel_name="account.move", string="Invoices") invoices_count = fields.Integer( @@ -213,10 +210,7 @@ def get_zip(self): self.write({"state": "running", "exception_info": None}) with self.env.cr.savepoint(): - zip_file = self.generate_zip( - self.invoice_ids, - self.check_xsd, - ) + zip_file = self.generate_zip(self.invoice_ids, self.check_xsd,) if not self.manually_document_selection: description = _( "Filtered Export of {} Documents\nDate Range: {}-{}\nTypes: {}" @@ -371,10 +365,7 @@ def action_pending(self): _("It's not allowed to set an already running export to pending!") ) r.write( - { - "state": "pending", - "exception_info": None, - } + {"state": "pending", "exception_info": None,} ) def action_draft(self): diff --git a/datev_export_xml/models/datev_pdf_generator.py b/datev_export_xml/models/datev_pdf_generator.py index 7699f385..e9ddbf26 100644 --- a/datev_export_xml/models/datev_pdf_generator.py +++ b/datev_export_xml/models/datev_pdf_generator.py @@ -47,10 +47,7 @@ def generate_pdf(self, invoice): # Otherwise generate a new once report = self.env["ir.actions.report"].search( - [ - ("model", "=", "account.move"), - ("report_name", "=", self.report_name()), - ], + [("model", "=", "account.move"), ("report_name", "=", self.report_name()),], ) if report: return report._render(invoice.ids)[0] diff --git a/datev_export_xml/models/datev_xml_generator.py b/datev_export_xml/models/datev_xml_generator.py index 66bed416..68a91c9f 100644 --- a/datev_export_xml/models/datev_xml_generator.py +++ b/datev_export_xml/models/datev_xml_generator.py @@ -53,9 +53,7 @@ def generate_xml_document(self, invoices, check_xsd=True): if check_xsd: self.check_xml_file( - "document.xml", - root, - "Document_v050.xsd", + "document.xml", root, "Document_v050.xsd", ) return "document.xml", etree.tostring(root) @@ -71,9 +69,7 @@ def generate_xml_invoice(self, invoice, check_xsd=True): if check_xsd: self.check_xml_file( - doc_name, - root, - "Belegverwaltung_online_invoice_v050.xsd", + doc_name, root, "Belegverwaltung_online_invoice_v050.xsd", ) return doc_name, etree.tostring(root) diff --git a/datev_export_xml/models/datev_zip_generator.py b/datev_export_xml/models/datev_zip_generator.py index af476afb..6edb9f63 100644 --- a/datev_export_xml/models/datev_zip_generator.py +++ b/datev_export_xml/models/datev_zip_generator.py @@ -45,9 +45,7 @@ def generate_zip(self, invoices, check_xsd): with io.BytesIO() as s, zipfile.ZipFile(s, mode="w") as zip_file: xml_document_data = self.generate_xml_document(invoices, check_xsd) zip_file.writestr( - xml_document_data[0], - xml_document_data[1], - zipfile.ZIP_DEFLATED, + xml_document_data[0], xml_document_data[1], zipfile.ZIP_DEFLATED, ) for invoice in invoices.with_context(progress_iter=True): @@ -62,9 +60,7 @@ def generate_zip(self, invoices, check_xsd): attachment = self.generate_pdf(invoice) if attachment: zip_file.writestr( - invoice.datev_filename(), - attachment, - zipfile.ZIP_DEFLATED, + invoice.datev_filename(), attachment, zipfile.ZIP_DEFLATED, ) zip_file.close() diff --git a/datev_export_xml/models/res_config_settings.py b/datev_export_xml/models/res_config_settings.py index 23157e85..61bbf875 100644 --- a/datev_export_xml/models/res_config_settings.py +++ b/datev_export_xml/models/res_config_settings.py @@ -14,21 +14,17 @@ class ResConfigSettings(models.TransientModel): _inherit = "res.config.settings" datev_default_period = fields.Selection( - related="company_id.datev_default_period", - readonly=False, + related="company_id.datev_default_period", readonly=False, ) datev_export_state = fields.Boolean( - related="company_id.datev_export_state", - readonly=False, + related="company_id.datev_export_state", readonly=False, ) datev_vendor_order_ref = fields.Selection( - related="company_id.datev_vendor_order_ref", - readonly=False, + related="company_id.datev_vendor_order_ref", readonly=False, ) datev_customer_order_ref = fields.Selection( - related="company_id.datev_customer_order_ref", - readonly=False, + related="company_id.datev_customer_order_ref", readonly=False, ) diff --git a/datev_export_xml/tests/test_datev_export.py b/datev_export_xml/tests/test_datev_export.py index 7c3c9fcf..d86e98f8 100644 --- a/datev_export_xml/tests/test_datev_export.py +++ b/datev_export_xml/tests/test_datev_export.py @@ -294,10 +294,7 @@ def create_customer_datev_export_manually(self, invoice): def update_attachment(self, attachment, invoice): attachment.write( - { - "res_model": "account.invoice", - "res_id": invoice.id, - } + {"res_model": "account.invoice", "res_id": invoice.id,} ) return attachment @@ -346,8 +343,7 @@ def _run_test_invoice(self, doc, invoice): sign = -1 if invoice.move_type.endswith("_refund") else 1 self.assertEqual( - float(total["net_total_amount"]), - sign * invoice.amount_untaxed, + float(total["net_total_amount"]), sign * invoice.amount_untaxed, ) self.assertEqual( float(total["total_gross_amount_excluding_third-party_collection"]), @@ -378,12 +374,10 @@ def _run_test_out_refund_datev_export(self, refund): datev_export = self.create_customer_datev_export(start_date, end_date) self.assertEqual(datev_export.datev_file, False) self.assertEqual( - datev_export.client_number, - self.env.company.datev_client_number, + datev_export.client_number, self.env.company.datev_client_number, ) self.assertEqual( - datev_export.consultant_number, - self.env.company.datev_consultant_number, + datev_export.consultant_number, self.env.company.datev_consultant_number, ) self.assertEqual(datev_export.state, "draft") # There is always a first invoice @@ -429,12 +423,10 @@ def _run_test_in_refund_datev_export(self, refund, attachment): attachment = self.update_attachment(attachment, refund) self.assertEqual(datev_export.datev_file, False) self.assertEqual( - datev_export.client_number, - self.env.company.datev_client_number, + datev_export.client_number, self.env.company.datev_client_number, ) self.assertEqual( - datev_export.consultant_number, - self.env.company.datev_consultant_number, + datev_export.consultant_number, self.env.company.datev_consultant_number, ) self.assertEqual(datev_export.state, "draft") # There is always a first invoice @@ -478,12 +470,10 @@ def _run_test_out_invoice_datev_export(self, invoice): datev_export = self.create_customer_datev_export(start_date, end_date) self.assertEqual(datev_export.datev_file, False) self.assertEqual( - datev_export.client_number, - self.env.company.datev_client_number, + datev_export.client_number, self.env.company.datev_client_number, ) self.assertEqual( - datev_export.consultant_number, - self.env.company.datev_consultant_number, + datev_export.consultant_number, self.env.company.datev_consultant_number, ) self.assertEqual(datev_export.state, "draft") # There is always a first invoice @@ -529,12 +519,10 @@ def _run_test_in_invoice_datev_export(self, invoice, attachment): attachment = self.update_attachment(attachment, invoice) self.assertEqual(datev_export.datev_file, False) self.assertEqual( - datev_export.client_number, - self.env.company.datev_client_number, + datev_export.client_number, self.env.company.datev_client_number, ) self.assertEqual( - datev_export.consultant_number, - self.env.company.datev_consultant_number, + datev_export.consultant_number, self.env.company.datev_consultant_number, ) self.assertEqual(datev_export.state, "draft") self.assertEqual(datev_export.invoices_count, 1) @@ -575,12 +563,10 @@ def _run_test_out_inv_datev_export_manually(self, invoice): datev_export = self.create_customer_datev_export_manually(invoice) self.assertEqual(datev_export.datev_file, False) self.assertEqual( - datev_export.client_number, - self.env.company.datev_client_number, + datev_export.client_number, self.env.company.datev_client_number, ) self.assertEqual( - datev_export.consultant_number, - self.env.company.datev_consultant_number, + datev_export.consultant_number, self.env.company.datev_consultant_number, ) self.assertEqual(datev_export.state, "draft") self.assertEqual(datev_export.invoices_count, 1) @@ -735,11 +721,7 @@ def test_14_datev_export_without_invoice(self): # (Invoices/Refunds) you want to export!" with self.assertRaises(ValidationError): datev_export = self.DatevExportObj.create( - { - "export_type": "out", - "export_invoice": False, - "export_refund": False, - } + {"export_type": "out", "export_invoice": False, "export_refund": False,} ) # 2. when default values are set # date_start, date_end (based on datev_default_period of current company) @@ -747,19 +729,13 @@ def test_14_datev_export_without_invoice(self): # export_refund = True, # check_xsd = True, # manually_document_selection = Flase - datev_export = self.DatevExportObj.create( - { - "export_type": "out", - } - ) + datev_export = self.DatevExportObj.create({"export_type": "out",}) self.assertEqual(datev_export.datev_file, False) self.assertEqual( - datev_export.client_number, - self.env.company.datev_client_number, + datev_export.client_number, self.env.company.datev_client_number, ) self.assertEqual( - datev_export.consultant_number, - self.env.company.datev_consultant_number, + datev_export.consultant_number, self.env.company.datev_consultant_number, ) self.assertEqual(datev_export.state, "draft") self.assertEqual(datev_export.date_start, date_start) @@ -785,8 +761,7 @@ def test_16_manual_export(self): ) self.DatevExportObj.with_context( - active_model="account.move", - active_ids=out_invoice.ids, + active_model="account.move", active_ids=out_invoice.ids, ).export_zip_invoice() in_invoice = self.create_in_invoice( diff --git a/setup/datev_export_xml/odoo/addons/datev_export_xml b/setup/datev_export_xml/odoo/addons/datev_export_xml new file mode 120000 index 00000000..ce2778f7 --- /dev/null +++ b/setup/datev_export_xml/odoo/addons/datev_export_xml @@ -0,0 +1 @@ +../../../../datev_export_xml \ No newline at end of file diff --git a/setup/datev_export_xml/setup.py b/setup/datev_export_xml/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/datev_export_xml/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)