Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][MIG] datev_export_dtvf: Migration to 15.0 #162

Open
wants to merge 9 commits into
base: 15.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions datev_export/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,32 @@ class ResCompany(models.Model):
size=5,
help="Number from 0 to 99999",
)

datev_account_code_length = fields.Integer(
"DATEV account code length",
default=5,
)

datev_partner_numbering = fields.Selection(
string="DATEV Partner numbering",
selection="_selection_datev_partner_numbering",
default="none",
)

datev_customer_sequence_id = fields.Many2one(
"ir.sequence", "DATEV sequence for customers"
)

datev_supplier_sequence_id = fields.Many2one(
"ir.sequence", "DATEV sequence for suppliers"
)

def _selection_datev_partner_numbering(self):
reports_installed = (
"l10n_de_datev_reports" in self.env["ir.module.module"]._installed()
)
return (
[("none", "None")]
+ ([("ee", "Enterprises Edition")] if reports_installed else [])
+ [("sequence", "Sequence")]
)
17 changes: 17 additions & 0 deletions datev_export/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@ class ResConfigSettings(models.TransientModel):
related="company_id.datev_client_number",
readonly=False,
)

datev_account_code_length = fields.Integer(
related="company_id.datev_account_code_length",
readonly=False,
)

datev_partner_numbering = fields.Selection(
related="company_id.datev_partner_numbering", readonly=False
)

datev_customer_sequence_id = fields.Many2one(
related="company_id.datev_customer_sequence_id", readonly=False
)

datev_supplier_sequence_id = fields.Many2one(
related="company_id.datev_supplier_sequence_id", readonly=False
)
104 changes: 104 additions & 0 deletions datev_export/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,110 @@
</div>
</div>
</div>

<div class="o_setting_left_pane" />
<div class="o_setting_right_pane">
<span class="o_form_label">Account code length</span>
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
aria-label="Values set here are company-specific."
groups="base.group_multi_company"
/>
<div class="text-muted">
Account code length
</div>
<div class="content-group">
<div class="mt16">
<field
name="datev_account_code_length"
class="o_light_label"
/>
</div>
</div>
</div>

<div class="o_setting_left_pane" />
<div class="o_setting_right_pane">
<span class="o_form_label">Partner numbering</span>
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
aria-label="Values set here are company-specific."
groups="base.group_multi_company"
/>
<div class="text-muted">
Select the way partners in DATEV export are numbered
</div>
<div class="content-group">
<div class="mt16">
<field
name="datev_partner_numbering"
class="o_light_label"
/>
</div>
</div>
</div>

<div
class="o_setting_left_pane"
attrs="{'invisible': [('datev_partner_numbering', '!=', 'sequence')]}"
/>
<div
class="o_setting_right_pane"
attrs="{'invisible': [('datev_partner_numbering', '!=', 'sequence')]}"
>
<span class="o_form_label">Customer sequence</span>
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
aria-label="Values set here are company-specific."
groups="base.group_multi_company"
/>
<div class="text-muted">
The sequence used to number customers
</div>
<div class="content-group">
<div class="mt16">
<field
name="datev_customer_sequence_id"
class="o_light_label"
attrs="{'required': [('datev_partner_numbering', '=', 'sequence')]}"
domain="[('company_id', 'in', (company_id, False))]"
/>
</div>
</div>
</div>

<div
class="o_setting_left_pane"
attrs="{'invisible': [('datev_partner_numbering', '!=', 'sequence')]}"
/>
<div
class="o_setting_right_pane"
attrs="{'invisible': [('datev_partner_numbering', '!=', 'sequence')]}"
>
<span class="o_form_label">Supplier sequence</span>
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
aria-label="Values set here are company-specific."
groups="base.group_multi_company"
/>
<div class="text-muted">
The sequence used to number suppliers
</div>
<div class="content-group">
<div class="mt16">
<field
name="datev_supplier_sequence_id"
class="o_light_label"
attrs="{'required': [('datev_partner_numbering', '=', 'sequence')]}"
domain="[('company_id', 'in', (company_id, False))]"
/>
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
102 changes: 102 additions & 0 deletions datev_export_dtvf/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
=====
DATEV
=====

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:48207fd148cec7018b86144986e3861cedd92bc471a27d6e45e6259a2b32cff6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--germany-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-germany/tree/15.0/datev_export_dtvf
:alt: OCA/l10n-germany
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-germany-15-0/l10n-germany-15-0-datev_export_dtvf
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-germany&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module implements DATEV exports in the dtvf format.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

#. Go to your company
#. Fill in the fields in the `DATEV` tab
#. For accounts where you want to suppress automatic calculations (for ie taxes), set the according flag

The module also contains an inactive cronjob and a mail template allowing you to send period DATEV export somewhere via email. It relies on finding exactly one date range for the previous month and one for the year of the previous month, otherwise you'll see an error message in your log when running the cronjob. Note that the data transmitted via email is not encrypted.

Usage
=====

To use this module, you need to:

#. Go to `Invoicing` / `Reporting` / `DATEV export`
#. Create an export, choose a date range to use as fiscal year, and ranges to export
#. Click ``Generate``

Known issues / Roadmap
======================

* support missing formats
* add empty fields

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-germany/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-germany/issues/new?body=module:%20datev_export_dtvf%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Hunki Enterprises BV

Contributors
~~~~~~~~~~~~

* Holger Brunn <[email protected]> (https://hunki-enterprises.com)

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/l10n-germany <https://github.com/OCA/l10n-germany/tree/15.0/datev_export_dtvf>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions datev_export_dtvf/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
from . import datev
25 changes: 25 additions & 0 deletions datev_export_dtvf/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2022 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "DATEV",
"summary": "Export Data for DATEV (dtvf)",
"version": "15.0.1.0.0",
"development_status": "Beta",
"category": "Accounting",
"website": "https://github.com/OCA/l10n-germany",
"author": "Hunki Enterprises BV, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": [
"account",
"date_range",
"datev_export",
],
"data": [
"data/ir_cron.xml",
"data/mail_template.xml",
"security/ir.model.access.csv",
"views/account_account.xml",
"views/datev_export_dtvf.xml",
"views/res_partner.xml",
],
}
34 changes: 34 additions & 0 deletions datev_export_dtvf/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<odoo noupdate="1">
<record id="cron_export" model="ir.cron">
<field name="name">Monthly DATEV export via mail (dtvf)</field>
<field name="interval_number">1</field>
<field name="interval_type">months</field>
<field name="numbercall">-1</field>
<field name="model_id" ref="model_datev_export_dtvf_export" />
<field name="active" eval="False" />
<field name="code">
<![CDATA[
relativedelta = dateutil.relativedelta.relativedelta
last_month_start = datetime.date.today() - relativedelta(months=1, day=1)
last_month_end = last_month_start + relativedelta(months=1, days=-1)
year_start = last_month_start + relativedelta(month=1, day=1)
year_end = year_start + relativedelta(years=1, days=-1)
year_range = env['date.range'].search([('date_start', '=', year_start), ('date_end', '=', year_end)], limit=1)
period_range = env['date.range'].search([('date_start', '=', last_month_start), ('date_end', '=', last_month_end)], limit=1)
if year_range and period_range:
export = model.create({
'fiscalyear_id': year_range.id,
'period_ids': [(6, 0, period_range.ids)],
'name': ('Export %s-%02d') % (last_month_start.year, last_month_start.month),
})
export.action_generate()
env.ref('datev_export_dtvf.mail_template_cron_export').send_mail(
export.id,
email_values={'attachments': [(export.file_name, export.file_data)]},
)
else:
raise UserError('No appropriate date ranges found for periodic export')
]]>
</field>
</record>
</odoo>
16 changes: 16 additions & 0 deletions datev_export_dtvf/data/mail_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<odoo noupdate="1">
<record id="mail_template_cron_export" model="mail.template">
<field name="name">DATEV export</field>
<field name="subject">{{object.name}}</field>
<field name="email_to">[email protected]</field>
<field name="model_id" ref="model_datev_export_dtvf_export" />
<field name="body_html" type="html">
<h1>Dear recipient,</h1>
<p>
please find attached the latest DATEV export from <t
t-out="object.company_id.name"
/>.
</p>
</field>
</record>
</odoo>
Loading
Loading