Merge pull request #62 from expsa/fix_bug_fiscalyears_periods

[FIX] fix bug fiscalyears periods
This commit is contained in:
AbuzarExp 2024-07-03 11:58:03 +03:00 committed by GitHub
commit 79a9e1a5e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -2,7 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError, Warning
from odoo.exceptions import ValidationError, Warning
class CrossoveredBudget(models.Model):

View File

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.exceptions import ValidationError
from odoo.osv import expression
from dateutil.relativedelta import relativedelta
@ -304,7 +304,7 @@ class AccountFiscalYear(models.Model):
"""
for rec in self:
if rec.state != 'draft':
raise UserError(
raise ValidationError(
_('You cannot delete a fiscal year not in draft state.'))
rec.periods_ids.unlink()
return super().unlink()

View File

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.exceptions import ValidationError
from odoo.osv import expression
@ -114,7 +114,7 @@ class fiscalyears_periods(models.Model):
"""
for rec in self:
if rec.state != 'draft':
raise UserError(
raise ValidationError(
_('You cannot delete a period not in draft state.'))
self.env['ir.translation'].search([('name', '=', "fiscalyears.periods,name"),
@ -127,7 +127,7 @@ class fiscalyears_periods(models.Model):
"""
for rec in self:
if rec.fiscalyear_id.state not in ['open']:
raise UserError(
raise ValidationError(
_('''You cannot open a period where the fiscalyear not in open state.'''))
rec.state = 'open'