Browse Source

Merge pull request #9 from feketemihai/11.0-fix-unlink_date_tange_type

[11.0] [BUG] Fix date range type unlink.
pull/13/head
Pedro M. Baeza 7 years ago
committed by GitHub
parent
commit
654d38388d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      date_range/__init__.py
  2. 3
      date_range/__manifest__.py
  3. 1
      date_range/models/__init__.py
  4. 4
      date_range/models/date_range.py
  5. 1
      date_range/models/date_range_type.py
  6. 3
      date_range/static/src/js/date_range.js
  7. 1
      date_range/tests/__init__.py
  8. 1
      date_range/tests/test_date_range.py
  9. 1
      date_range/tests/test_date_range_generator.py
  10. 17
      date_range/tests/test_date_range_type.py
  11. 1
      date_range/wizard/__init__.py
  12. 1
      date_range/wizard/date_range_generator.py

1
date_range/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

3
date_range/__manifest__.py

@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "Date Range", "name": "Date Range",
"summary": "Manage all kind of date range", "summary": "Manage all kind of date range",
"version": "11.0.1.0.0",
"version": "11.0.1.0.1",
"category": "Uncategorized", "category": "Uncategorized",
"website": "https://github.com/oca/server-ux", "website": "https://github.com/oca/server-ux",
"author": "ACSONE SA/NV, Odoo Community Association (OCA)", "author": "ACSONE SA/NV, Odoo Community Association (OCA)",

1
date_range/models/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

4
date_range/models/date_range.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@ -19,7 +18,8 @@ class DateRange(models.Model):
date_start = fields.Date(string='Start date', required=True) date_start = fields.Date(string='Start date', required=True)
date_end = fields.Date(string='End date', required=True) date_end = fields.Date(string='End date', required=True)
type_id = fields.Many2one( type_id = fields.Many2one(
comodel_name='date.range.type', string='Type', index=1, required=True)
comodel_name='date.range.type', string='Type', index=1, required=True,
ondelete='restrict')
type_name = fields.Char( type_name = fields.Char(
string='Type', related='type_id.name', readonly=True, store=True) string='Type', related='type_id.name', readonly=True, store=True)
company_id = fields.Many2one( company_id = fields.Many2one(

1
date_range/models/date_range_type.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

3
date_range/static/src/js/date_range.js

@ -10,12 +10,11 @@ var rpc = require('web.rpc');
var framework = require('web.framework'); var framework = require('web.framework');
var _t = core._t; var _t = core._t;
var _lt = core._lt;
filters.ExtendedSearchProposition.include({ filters.ExtendedSearchProposition.include({
select_field: function(field) { select_field: function(field) {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.is_date_range_selected = false; this.is_date_range_selected = false;
this.is_date = field.type == 'date' || field.type == 'datetime';
this.is_date = field.type === 'date' || field.type === 'datetime';
this.$value = this.$el.find('.searchview_extended_prop_value, .o_searchview_extended_prop_value'); this.$value = this.$el.find('.searchview_extended_prop_value, .o_searchview_extended_prop_value');
if (this.is_date){ if (this.is_date){
var ds = new data.DataSetSearch(this, 'date.range.type', this.context, [[1, '=', 1]]); var ds = new data.DataSetSearch(this, 'date.range.type', this.context, [[1, '=', 1]]);

1
date_range/tests/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

1
date_range/tests/test_date_range.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

1
date_range/tests/test_date_range_generator.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)nses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)nses/agpl).

17
date_range/tests/test_date_range_type.py

@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo.tests.common import TransactionCase from odoo.tests.common import TransactionCase
from odoo.tools import mute_logger
from psycopg2 import IntegrityError
class DateRangeTypeTest(TransactionCase): class DateRangeTypeTest(TransactionCase):
@ -18,3 +19,17 @@ class DateRangeTypeTest(TransactionCase):
'company_id': False, 'company_id': False,
'allow_overlap': False}) 'allow_overlap': False})
self.assertFalse(drt.company_id) self.assertFalse(drt.company_id)
def test_unlink(self):
date_range = self.env['date.range']
drt = self.env['date.range.type'].create(
{'name': 'Fiscal year',
'allow_overlap': False})
date_range.create({
'name': 'FS2016',
'date_start': '2015-01-01',
'date_end': '2016-12-31',
'type_id': drt.id,
})
with self.assertRaises(IntegrityError), mute_logger('odoo.sql_db'):
drt.unlink()

1
date_range/wizard/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

1
date_range/wizard/date_range_generator.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>) # © 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Loading…
Cancel
Save