[FIX] fix bug fiscalyears periods

This commit is contained in:
odex 2024-07-03 11:45:54 +03:00
parent 7cd7c1f0d5
commit ee2d211ab5
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'