Browse Source

fixed constrains + fixed onchange + other minor fixes

pull/1430/head
Andrea 6 years ago
committed by Laurent Mignon (ACSONE)
parent
commit
2cd241a540
  1. 3
      date_range/models/date_range.py
  2. 5
      date_range/models/date_range_type.py
  3. 1
      date_range/readme/CONTRIBUTORS.rst
  4. 2
      date_range/readme/INSTALL.rst
  5. 1
      date_range/wizard/date_range_generator.py

3
date_range/models/date_range.py

@ -9,6 +9,7 @@ from odoo.exceptions import ValidationError
class DateRange(models.Model):
_name = "date.range"
_description = "Date Range"
_order = "type_name,date_start"
@api.model
@ -35,7 +36,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

@ -9,6 +9,7 @@ from odoo.exceptions import ValidationError
class DateRangeType(models.Model):
_name = "date.range.type"
_description = "Date Range Type"
@api.model
def _default_company(self):
@ -36,10 +37,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

1
date_range/wizard/date_range_generator.py

@ -15,6 +15,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