diff --git a/ext/custom-addons/dp_sequence_date_range_monthly/__init__.py b/ext/custom-addons/dp_sequence_date_range_monthly/__init__.py new file mode 100644 index 00000000..f6229e8e --- /dev/null +++ b/ext/custom-addons/dp_sequence_date_range_monthly/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# datenpol gmbh +# Copyright (C) 2013-TODAY datenpol gmbh () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import models + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/ext/custom-addons/dp_sequence_date_range_monthly/__manifest__.py b/ext/custom-addons/dp_sequence_date_range_monthly/__manifest__.py new file mode 100644 index 00000000..7e4bfdb8 --- /dev/null +++ b/ext/custom-addons/dp_sequence_date_range_monthly/__manifest__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# datenpol gmbh +# Copyright (C) 2013-TODAY datenpol gmbh () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +# noinspection PyStatementEffect +{ + 'name': 'datenpol Sequence date range monthly', + 'category': 'Custom', + 'version': '1.0', + 'description': """Für jeden Monat gibt es eine eigenen Nummernkreis""", + 'author': 'datenpol gmbh', + 'website': 'http://www.datenpol.at/', + 'depends': [ + 'base', + ], + 'data': [ + 'views/ir_sequence_view.xml', + ], + 'installable': True, + 'auto_install': False, +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/ext/custom-addons/dp_sequence_date_range_monthly/models/__init__.py b/ext/custom-addons/dp_sequence_date_range_monthly/models/__init__.py new file mode 100644 index 00000000..44d8e2ca --- /dev/null +++ b/ext/custom-addons/dp_sequence_date_range_monthly/models/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 20014-2016 datenpol gmbh (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import ir_sequence + + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/ext/custom-addons/dp_sequence_date_range_monthly/models/ir_sequence.py b/ext/custom-addons/dp_sequence_date_range_monthly/models/ir_sequence.py new file mode 100644 index 00000000..b1fe83e6 --- /dev/null +++ b/ext/custom-addons/dp_sequence_date_range_monthly/models/ir_sequence.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# datenpol gmbh +# Copyright (C) 2013-TODAY datenpol gmbh () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from odoo import api, fields, models +from datetime import datetime, timedelta +from dateutil.relativedelta import relativedelta + + +class IrSequence(models.Model): + _inherit = 'ir.sequence' + + monthly_date_range = fields.Boolean('Monthly date_range') + + def _create_date_range_seq(self, date): + year = fields.Date.from_string(date).strftime('%Y') + if self.monthly_date_range: + month = fields.Date.from_string(date).strftime('%m') + last_day = datetime(int(year), int(month), 1) + relativedelta(day=31) + date_from = '{}-{}-01'.format(year, month) + date_to = '{}-{}-{}'.format(year, month, last_day.day) + else: + date_from = '{}-01-01'.format(year) + date_to = '{}-12-31'.format(year) + date_range = self.env['ir.sequence.date_range'].search \ + ([('sequence_id', '=', self.id), ('date_from', '>=', date), ('date_from', '<=', date_to)], + order='date_from desc', limit=1) + if date_range: + date_to = datetime.strptime(date_range.date_from, '%Y-%m-%d') + timedelta(days=-1) + date_to = date_to.strftime('%Y-%m-%d') + date_range = self.env['ir.sequence.date_range'].search \ + ([('sequence_id', '=', self.id), ('date_to', '>=', date_from), ('date_to', '<=', date)], + order='date_to desc', + limit=1) + if date_range: + date_from = datetime.strptime(date_range.date_to, '%Y-%m-%d') + timedelta(days=1) + date_from = date_from.strftime('%Y-%m-%d') + seq_date_range = self.env['ir.sequence.date_range'].sudo().create({ + 'date_from': date_from, + 'date_to': date_to, + 'sequence_id': self.id, + }) + return seq_date_range diff --git a/ext/custom-addons/dp_sequence_date_range_monthly/static/description/icon.png b/ext/custom-addons/dp_sequence_date_range_monthly/static/description/icon.png new file mode 100644 index 00000000..8387d765 Binary files /dev/null and b/ext/custom-addons/dp_sequence_date_range_monthly/static/description/icon.png differ diff --git a/ext/custom-addons/dp_sequence_date_range_monthly/views/ir_sequence_view.xml b/ext/custom-addons/dp_sequence_date_range_monthly/views/ir_sequence_view.xml new file mode 100644 index 00000000..ae36fd1f --- /dev/null +++ b/ext/custom-addons/dp_sequence_date_range_monthly/views/ir_sequence_view.xml @@ -0,0 +1,18 @@ + + + + + + + dp_ir_sequence_form + ir.sequence + + + + + + + + + + diff --git a/setup/lib/config_at.py b/setup/lib/config_at.py index 5c5fea13..6f5c17e0 100644 --- a/setup/lib/config_at.py +++ b/setup/lib/config_at.py @@ -141,13 +141,15 @@ class Config(): # 'number_next_actual': 1, 'prefix': '%(y)s', 'padding': 4, - 'use_date_range': True + 'use_date_range': True, + 'monthly_date_range': False }, 'account.invoice': { # 'number_next_actual': 0001, 'prefix': '%(y)s%(month)s', 'padding': 4, - 'use_date_range': True + 'use_date_range': True, + 'monthly_date_range': False }, # Wenn 'account.invoice_refund' auskommentiert ist, dann wird # für die Gutschrift der selbe Nummernkreis verwendet @@ -157,7 +159,8 @@ class Config(): 'implementation': 'no_gap', 'prefix': '%(y)s', 'padding': 4, - 'use_date_range': True + 'use_date_range': True, + 'monthly_date_range': False }, #'picking.out': { # # 'number_next_actual': 1,