diff --git a/base_export_manager/i18n/base_export_manager.pot b/base_export_manager/i18n/base_export_manager.pot index e3f73f2..fed69a3 100644 --- a/base_export_manager/i18n/base_export_manager.pot +++ b/base_export_manager/i18n/base_export_manager.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 11.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" @@ -14,15 +14,14 @@ msgstr "" "Plural-Forms: \n" #. module: base_export_manager -#: model:ir.model.fields,help:base_export_manager.field_ir_exports_line__model1_id #: model:ir.model.fields,help:base_export_manager.field_ir_exports__model_id +#: model:ir.model.fields,help:base_export_manager.field_ir_exports_line__model1_id msgid "Database model to export." msgstr "" #. module: base_export_manager #. openerp-web #: code:addons/base_export_manager/static/src/js/base_export_manager.js:18 -#: code:addons/base_export_manager/static/src/js/base_export_manager.js:39 #, python-format msgid "Export" msgstr "" @@ -32,6 +31,11 @@ msgstr "" msgid "Export Access" msgstr "" +#. module: base_export_manager +#: model:ir.model.fields,field_description:base_export_manager.field_ir_exports__name +msgid "Export Name" +msgstr "" + #. module: base_export_manager #: model_terms:ir.ui.view,arch_db:base_export_manager.ir_exports_form_view msgid "Export Profile" @@ -44,6 +48,16 @@ msgstr "" msgid "Export Profiles" msgstr "" +#. module: base_export_manager +#: model:ir.model,name:base_export_manager.model_ir_exports +msgid "Exports" +msgstr "" + +#. module: base_export_manager +#: model:ir.model,name:base_export_manager.model_ir_exports_line +msgid "Exports Line" +msgstr "" + #. module: base_export_manager #: code:addons/base_export_manager/models/ir_exports_line.py:171 #, python-format @@ -62,6 +76,16 @@ msgstr "" msgid "Field '%s' not found in model '%s'" msgstr "" +#. module: base_export_manager +#: model:ir.model.fields,field_description:base_export_manager.field_ir_exports_line__name +msgid "Field Name" +msgstr "" + +#. module: base_export_manager +#: model:ir.model.fields,help:base_export_manager.field_ir_exports_line__name +msgid "Field's technical name." +msgstr "" + #. module: base_export_manager #: model:ir.model.fields,field_description:base_export_manager.field_ir_exports_line__field1_id msgid "First field" @@ -82,6 +106,11 @@ msgstr "" msgid "Fourth model" msgstr "" +#. module: base_export_manager +#: model:ir.model,name:base_export_manager.model_ir_http +msgid "HTTP Routing" +msgstr "" + #. module: base_export_manager #: code:addons/base_export_manager/models/ir_exports_line.py:135 #, python-format @@ -98,13 +127,28 @@ msgstr "" msgid "Model" msgstr "" +#. module: base_export_manager +#: model:ir.model,name:base_export_manager.model_ir_model_access +msgid "Model Access" +msgstr "" + +#. module: base_export_manager +#: model:ir.model.fields,help:base_export_manager.field_ir_exports__resource +msgid "Model's technical name." +msgstr "" + +#. module: base_export_manager +#: model:ir.model.fields,field_description:base_export_manager.field_ir_exports__resource +msgid "Resource" +msgstr "" + #. module: base_export_manager #: model:ir.model.fields,field_description:base_export_manager.field_ir_exports_line__field2_id msgid "Second field" msgstr "" #. module: base_export_manager -#: model:ir.model.fields,field_description:base_export_manager.field_ir_exports_line_model2_id +#: model:ir.model.fields,field_description:base_export_manager.field_ir_exports_line__model2_id msgid "Second model" msgstr "" @@ -134,18 +178,3 @@ msgstr "" msgid "You must supply a model or resource." msgstr "" -#. module: base_export_manager -#: model:ir.model,name:base_export_manager.model_ir_exports -msgid "Exports" -msgstr "" - -#. module: base_export_manager -#: model:ir.model,name:base_export_manager.model_ir_exports_line -msgid "Exports Line" -msgstr "" - -#. module: base_export_manager -#: model:ir.model,name:base_export_manager.model_ir_model_access -msgid "Model Access" -msgstr "" - diff --git a/base_tier_validation_formula/__manifest__.py b/base_tier_validation_formula/__manifest__.py index e327b18..afef056 100644 --- a/base_tier_validation_formula/__manifest__.py +++ b/base_tier_validation_formula/__manifest__.py @@ -8,7 +8,7 @@ 'version': '12.0.1.0.0', 'license': 'AGPL-3', 'author': 'Creu Blanca,Odoo Community Association (OCA)', - 'website': 'www.creublanca.es', + 'website': 'https://github.com/OCA/server-ux', 'depends': [ 'base_tier_validation' ], diff --git a/sequence_reset_period/README.rst b/sequence_reset_period/README.rst new file mode 100644 index 0000000..ef1ba94 --- /dev/null +++ b/sequence_reset_period/README.rst @@ -0,0 +1,38 @@ +.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :alt: License: LGPL-3 + +===================== +Sequence Reset period +===================== + +This module was written to reset the sequences on the specified times, because +by default they are reset yearly. + +Usage +===== + +* Access sequences and configurate the model to use. +* When sequence is computed, date_range will follow the specified rules + +Credits +======= + +Contributors +------------ + +* Enric Tobella + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/sequence_reset_period/__init__.py b/sequence_reset_period/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/sequence_reset_period/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sequence_reset_period/__manifest__.py b/sequence_reset_period/__manifest__.py new file mode 100644 index 0000000..5f3e927 --- /dev/null +++ b/sequence_reset_period/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright (C) 2017 Creu Blanca +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Reset Sequences on selected period ranges", + "version": "11.0.1.0.0", + "category": "Reporting", + "website": "https://github.com/OCA/server-ux", + "author": "Creu Blanca, " + "Odoo Community Association (OCA)", + "license": "LGPL-3", + "installable": True, + "application": False, + "summary": "Auto-generate yearly/monthly/weekly/daily sequence " + "period ranges", + "depends": [ + "base", + ], + "data": [ + "views/sequence_views.xml", + ], +} diff --git a/sequence_reset_period/i18n/es.po b/sequence_reset_period/i18n/es.po new file mode 100644 index 0000000..83d5e83 --- /dev/null +++ b/sequence_reset_period/i18n/es.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sequence_reset_period +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2018-07-13 08:46+0000\n" +"Last-Translator: Enric Tobella \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.0.1\n" + +#. module: sequence_reset_period +#: selection:ir.sequence,range_reset:0 +msgid "Daily" +msgstr "Diario" + +#. module: sequence_reset_period +#: selection:ir.sequence,range_reset:0 +msgid "Monthly" +msgstr "Mensual" + +#. module: sequence_reset_period +#: model:ir.model.fields,field_description:sequence_reset_period.field_ir_sequence_range_reset +msgid "Range Reset" +msgstr "Reinicio del Rango" + +#. module: sequence_reset_period +#: selection:ir.sequence,range_reset:0 +msgid "Weekly" +msgstr "Semanal" + +#. module: sequence_reset_period +#: selection:ir.sequence,range_reset:0 +msgid "Yearly" +msgstr "Anual" + +#. module: sequence_reset_period +#: model:ir.model,name:sequence_reset_period.model_ir_sequence +msgid "ir.sequence" +msgstr "ir.sequence" diff --git a/sequence_reset_period/i18n/sequence_reset_period.pot b/sequence_reset_period/i18n/sequence_reset_period.pot new file mode 100644 index 0000000..e8a136c --- /dev/null +++ b/sequence_reset_period/i18n/sequence_reset_period.pot @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sequence_reset_period +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: sequence_reset_period +#: selection:ir.sequence,range_reset:0 +msgid "Daily" +msgstr "" + +#. module: sequence_reset_period +#: selection:ir.sequence,range_reset:0 +msgid "Monthly" +msgstr "" + +#. module: sequence_reset_period +#: model:ir.model.fields,field_description:sequence_reset_period.field_ir_sequence_range_reset +msgid "Range Reset" +msgstr "" + +#. module: sequence_reset_period +#: selection:ir.sequence,range_reset:0 +msgid "Weekly" +msgstr "" + +#. module: sequence_reset_period +#: selection:ir.sequence,range_reset:0 +msgid "Yearly" +msgstr "" + +#. module: sequence_reset_period +#: model:ir.model,name:sequence_reset_period.model_ir_sequence +msgid "ir.sequence" +msgstr "" + diff --git a/sequence_reset_period/models/__init__.py b/sequence_reset_period/models/__init__.py new file mode 100644 index 0000000..5b01577 --- /dev/null +++ b/sequence_reset_period/models/__init__.py @@ -0,0 +1 @@ +from . import ir_sequence diff --git a/sequence_reset_period/models/ir_sequence.py b/sequence_reset_period/models/ir_sequence.py new file mode 100644 index 0000000..2e2aca7 --- /dev/null +++ b/sequence_reset_period/models/ir_sequence.py @@ -0,0 +1,58 @@ +# Copyright (C) 2017 Creu Blanca +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models +from datetime import datetime, timedelta, date as datetime_date +from dateutil.relativedelta import relativedelta + + +class IrSequence(models.Model): + _inherit = "ir.sequence" + + range_reset = fields.Selection([ + ('daily', 'Daily'), + ('weekly', 'Weekly'), + ('monthly', 'Monthly'), + ('yearly', 'Yearly') + ]) + + def _compute_date_from_to(self, date): + self.ensure_one() + date_from = date_to = fields.Date.from_string(date) + if self.range_reset == 'weekly': + date_from = date_from - timedelta(days=date_from.weekday()) + date_to = date_from + timedelta(days=6) + elif self.range_reset == 'monthly': + date_from = datetime_date(date_from.year, date_from.month, 1) + date_to = date_from + relativedelta(months=1) + date_to += relativedelta(days=-1) + elif self.range_reset == 'yearly': + date_from = datetime_date(date_from.year, 1, 1) + date_to = datetime_date(date_from.year, 12, 31) + return date_from.strftime('%Y-%m-%d'), date_to.strftime('%Y-%m-%d') + + def _create_date_range_seq(self, date): + self.ensure_one() + if not self.range_reset: + return super()._create_date_range_seq(date) + date_from, date_to = self._compute_date_from_to(date) + 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/sequence_reset_period/static/description/icon.png b/sequence_reset_period/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/sequence_reset_period/static/description/icon.png differ diff --git a/sequence_reset_period/tests/__init__.py b/sequence_reset_period/tests/__init__.py new file mode 100644 index 0000000..6021908 --- /dev/null +++ b/sequence_reset_period/tests/__init__.py @@ -0,0 +1 @@ +from . import test_period diff --git a/sequence_reset_period/tests/test_period.py b/sequence_reset_period/tests/test_period.py new file mode 100644 index 0000000..07cbce6 --- /dev/null +++ b/sequence_reset_period/tests/test_period.py @@ -0,0 +1,71 @@ +# Copyright 2017 Creu Blanca +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + + +from odoo.tests import common +from datetime import datetime + + +class TestSequence(common.TransactionCase): + def setUp(self): + super().setUp() + self.date = datetime(2018, 3, 14).strftime('%Y-%m-%d') + + def get_sequence(self, method): + return self.env['ir.sequence'].create({ + 'name': 'Test sequence', + 'implementation': 'standard', + 'use_date_range': True, + 'range_reset': method, + 'padding': '5' + }) + + def test_none(self): + sequence = self.get_sequence(False) + self.assertFalse(sequence.date_range_ids) + self.assertEqual('00001', sequence.with_context( + ir_sequence_date=self.date).next_by_id()) + range = sequence.date_range_ids + self.assertTrue(range) + self.assertEqual('2018-01-01', range.date_from) + self.assertEqual('2018-12-31', range.date_to) + + def test_daily(self): + sequence = self.get_sequence('daily') + self.assertFalse(sequence.date_range_ids) + self.assertEqual('00001', sequence.with_context( + ir_sequence_date=self.date).next_by_id()) + range = sequence.date_range_ids + self.assertTrue(range) + self.assertEqual(self.date, range.date_from) + self.assertEqual(self.date, range.date_to) + + def test_weekly(self): + sequence = self.get_sequence('weekly') + self.assertFalse(sequence.date_range_ids) + self.assertEqual('00001', sequence.with_context( + ir_sequence_date=self.date).next_by_id()) + range = sequence.date_range_ids + self.assertTrue(range) + self.assertEqual('2018-03-12', range.date_from) + self.assertEqual('2018-03-18', range.date_to) + + def test_monthly(self): + sequence = self.get_sequence('monthly') + self.assertFalse(sequence.date_range_ids) + self.assertEqual('00001', sequence.with_context( + ir_sequence_date=self.date).next_by_id()) + range = sequence.date_range_ids + self.assertTrue(range) + self.assertEqual('2018-03-01', range.date_from) + self.assertEqual('2018-03-31', range.date_to) + + def test_yearly(self): + sequence = self.get_sequence('yearly') + self.assertFalse(sequence.date_range_ids) + self.assertEqual('00001', sequence.with_context( + ir_sequence_date=self.date).next_by_id()) + range = sequence.date_range_ids + self.assertTrue(range) + self.assertEqual('2018-01-01', range.date_from) + self.assertEqual('2018-12-31', range.date_to) diff --git a/sequence_reset_period/views/sequence_views.xml b/sequence_reset_period/views/sequence_views.xml new file mode 100644 index 0000000..e631357 --- /dev/null +++ b/sequence_reset_period/views/sequence_views.xml @@ -0,0 +1,12 @@ + + + + ir.sequence + + + + + + + + diff --git a/setup/_metapackage/VERSION.txt b/setup/_metapackage/VERSION.txt index 6d774eb..bd5db4b 100644 --- a/setup/_metapackage/VERSION.txt +++ b/setup/_metapackage/VERSION.txt @@ -1 +1 @@ -12.0.20190528.0 \ No newline at end of file +12.0.20190605.0 \ No newline at end of file diff --git a/setup/_metapackage/setup.py b/setup/_metapackage/setup.py index 1ccbafe..4eed22c 100644 --- a/setup/_metapackage/setup.py +++ b/setup/_metapackage/setup.py @@ -8,6 +8,7 @@ setuptools.setup( description="Meta package for oca-server-ux Odoo addons", version=version, install_requires=[ + 'odoo12-addon-base_export_manager', 'odoo12-addon-base_technical_features', 'odoo12-addon-base_tier_validation', 'odoo12-addon-base_tier_validation_formula', diff --git a/setup/base_export_manager/odoo/addons/base_export_manager b/setup/base_export_manager/odoo/addons/base_export_manager new file mode 120000 index 0000000..8072c86 --- /dev/null +++ b/setup/base_export_manager/odoo/addons/base_export_manager @@ -0,0 +1 @@ +../../../../base_export_manager \ No newline at end of file diff --git a/setup/base_export_manager/setup.py b/setup/base_export_manager/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/base_export_manager/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)