Browse Source

[FIX] fixed constrains + fixed onchange + other minor fixes

pull/26/head
Andrea 6 years ago
parent
commit
47e43b8711
  1. 2
      date_range/README.rst
  2. 2
      date_range/__manifest__.py
  3. 3
      date_range/models/date_range.py
  4. 5
      date_range/models/date_range_type.py
  5. 1
      date_range/readme/CONTRIBUTORS.rst
  6. 2
      date_range/readme/INSTALL.rst
  7. 14
      date_range/static/src/js/date_range.js
  8. 1
      date_range/wizard/date_range_generator.py

2
date_range/README.rst

@ -133,7 +133,7 @@ promote its widespread use.
:target: https://github.com/lmignon
:alt: lmignon
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
Current `maintainer <https://odoo-community.org/page/maintainer-role>`_:
|maintainer-lmignon|

2
date_range/__manifest__.py

@ -3,7 +3,7 @@
{
"name": "Date Range",
"summary": "Manage all kind of date range",
"version": "11.0.2.0.0",
"version": "11.0.2.0.1",
"category": "Uncategorized",
"website": "https://github.com/oca/server-ux",
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",

3
date_range/models/date_range.py

@ -8,6 +8,7 @@ from odoo.exceptions import ValidationError
class DateRange(models.Model):
_name = "date.range"
_description = "Date Range"
_order = "type_name,date_start"
@api.model
@ -34,7 +35,7 @@ class DateRange(models.Model):
('date_range_uniq', 'unique (name,type_id, company_id)',
'A date range must be unique per company !')]
@api.onchange('company_id')
@api.onchange('company_id', 'type_id')
def _onchange_company_id(self):
if self.company_id and self.type_id.company_id and \
self.type_id.company_id != self.company_id:

5
date_range/models/date_range_type.py

@ -8,6 +8,7 @@ from odoo.exceptions import ValidationError
class DateRangeType(models.Model):
_name = "date.range.type"
_description = "Date Range Type"
@api.model
def _default_company(self):
@ -35,10 +36,10 @@ class DateRangeType(models.Model):
for rec in self.sudo():
if not rec.company_id:
continue
if bool(self.date_range_ids.filtered(
if bool(rec.date_range_ids.filtered(
lambda r: r.company_id and
r.company_id != rec.company_id)):
raise ValidationError(
_('You cannot change the company, as this '
'Date Range Type is assigned to Date Range '
'(%s).') % (self.date_range_ids.name_get()[0][1]))
'(%s).') % (rec.date_range_ids.name_get()[0][1]))

1
date_range/readme/CONTRIBUTORS.rst

@ -1,3 +1,4 @@
* Laurent Mignon <laurent.mignon@acsone.eu>
* Alexis de Lattre <alexis.delattre@akretion.com>
* Miquel Raïch <miquel.raich@eficent.com>
* Andrea Stirpe <a.stirpe@onestein.nl>

2
date_range/readme/INSTALL.rst

@ -1,3 +1 @@
The addon use the daterange method from postgres. This method is supported as of postgresql 9.2

14
date_range/static/src/js/date_range.js

@ -1,4 +1,4 @@
/* © 2016 ACSONE SA/NV (<http://acsone.eu>)
/* Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
odoo.define('date_range.search_filters', function (require) {
"use strict";
@ -44,7 +44,7 @@ filters.ExtendedSearchProposition.include({
date_range_type_operator_selected: function (type_id){
this.$value.empty().show();
var ds = new data.DataSetSearch(this, 'date.range', this.context, [['type_id', '=', parseInt(type_id)]]);
var ds = new data.DataSetSearch(this, 'date.range', this.context, [['type_id', '=', parseInt(type_id, 10)]]);
ds.read_slice(['name','date_start', 'date_end'], {}).done(this.proxy('on_range_type_selected'));
},
@ -66,7 +66,7 @@ filters.ExtendedSearchProposition.include({
res.attrs.domain = this.value.domain;
}
return res;
},
}
});
@ -80,7 +80,7 @@ class
filters.ExtendedSearchProposition.DateRange = core.search_filters_registry.get('id').extend({
template: 'SearchView.extended_search.dateRange.selection',
events: {
'change': 'on_range_selected',
'change': 'on_range_selected'
},
init: function (parent, field, date_range_values) {
@ -95,7 +95,7 @@ filters.ExtendedSearchProposition.DateRange = core.search_filters_registry.get('
},
get_value: function () {
return parseInt(this.$el.val());
return parseInt(this.$el.val(), 10);
},
on_range_selected: function (e){
@ -108,7 +108,7 @@ filters.ExtendedSearchProposition.DateRange = core.search_filters_registry.get('
field_name: this.field.name
},
model: 'date.range',
method: 'get_domain',
method: 'get_domain'
})
.then(function (domain) {
framework.unblockUI();
@ -118,7 +118,7 @@ filters.ExtendedSearchProposition.DateRange = core.search_filters_registry.get('
get_domain: function (field, operator) {
return this.domain;
},
}
});

1
date_range/wizard/date_range_generator.py

@ -14,6 +14,7 @@ from dateutil.relativedelta import relativedelta
class DateRangeGenerator(models.TransientModel):
_name = 'date.range.generator'
_description = 'Date Range Generator'
@api.model
def _default_company(self):

Loading…
Cancel
Save