-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] datev_export_dtvf: Add example cronjob for periodic export
- Loading branch information
Showing
6 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters