|
@ -1,4 +1,4 @@ |
|
|
# © 2016 ACSONE SA/NV (<https://acsone.eu>) |
|
|
|
|
|
|
|
|
# Copyright 2016 ACSONE SA/NV (<https://acsone.eu>) |
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
|
|
|
|
|
|
|
|
from odoo import api, fields, models |
|
|
from odoo import api, fields, models |
|
@ -63,10 +63,10 @@ class DateRange(models.Model): |
|
|
for this in self: |
|
|
for this in self: |
|
|
if not this.parent_id: |
|
|
if not this.parent_id: |
|
|
continue |
|
|
continue |
|
|
start = this.parent_id.date_start <= this.date_start |
|
|
|
|
|
end = this.parent_id.date_end >= this.date_end |
|
|
|
|
|
child_range = start and end |
|
|
|
|
|
if not child_range: |
|
|
|
|
|
|
|
|
date_start_valid = this.parent_id.date_start <= this.date_start |
|
|
|
|
|
date_end_valid = this.parent_id.date_end >= this.date_end |
|
|
|
|
|
if date_start_valid and date_end_valid: |
|
|
|
|
|
continue |
|
|
text_dict = { |
|
|
text_dict = { |
|
|
'name': this.name, |
|
|
'name': this.name, |
|
|
'start': this.date_start, |
|
|
'start': this.date_start, |
|
@ -75,13 +75,13 @@ class DateRange(models.Model): |
|
|
'parent_start': this.parent_id.date_start, |
|
|
'parent_start': this.parent_id.date_start, |
|
|
'parent_end': this.parent_id.date_end, |
|
|
'parent_end': this.parent_id.date_end, |
|
|
} |
|
|
} |
|
|
if (not start) and end: |
|
|
|
|
|
|
|
|
if (not date_start_valid) and date_end_valid: |
|
|
text = _( |
|
|
text = _( |
|
|
"Start date %(start)s of %(name)s must be greater than" |
|
|
"Start date %(start)s of %(name)s must be greater than" |
|
|
" or equal to " |
|
|
" or equal to " |
|
|
"start date %(parent_start)s of %(parent_name)s" |
|
|
"start date %(parent_start)s of %(parent_name)s" |
|
|
) % text_dict |
|
|
) % text_dict |
|
|
elif (not end) and start: |
|
|
|
|
|
|
|
|
elif (not date_end_valid) and date_start_valid: |
|
|
text = _( |
|
|
text = _( |
|
|
"End date %(end)s of %(name)s must be smaller than" |
|
|
"End date %(end)s of %(name)s must be smaller than" |
|
|
" or equal to " |
|
|
" or equal to " |
|
|