From 6bdd7dbfd9f61a5e11b58f1fe33c340b50db4b78 Mon Sep 17 00:00:00 2001 From: Damien Crier Date: Thu, 28 Apr 2016 22:59:54 +0200 Subject: [PATCH] [FIX*IMP] account_fiscal_year * Add contributors to README * try to find a FY start date according to the start date from choosen period * Unable to unlink a date_range with type fiscal_year * `fiscal_year` flag readonly * add menu to date_range under accounting section * remove method on object because it's the same as in file * unable to delete with flag 'fiscal_year' but can delete * clean __openerp__.py * account_fiscal_year version number --- account_fiscal_year/README.rst | 16 ++++-------- account_fiscal_year/__openerp__.py | 8 +----- account_fiscal_year/models/__init__.py | 1 - account_fiscal_year/models/date_range.py | 25 ------------------- account_fiscal_year/models/date_range_type.py | 16 +++++++++++- account_fiscal_year/views/date_range_type.xml | 10 ++++++-- 6 files changed, 29 insertions(+), 47 deletions(-) delete mode 100644 account_fiscal_year/models/date_range.py diff --git a/account_fiscal_year/README.rst b/account_fiscal_year/README.rst index e4cde719..8142bb40 100644 --- a/account_fiscal_year/README.rst +++ b/account_fiscal_year/README.rst @@ -6,9 +6,9 @@ Account Fiscal Year =================== -This module extends date.range.type to add fiscal_year flag. +This module extends `date.range.type` to add `fiscal_year` flag. -Override official res_company.compute_fiscal_year_dates to get the +Override official `res_company.compute_fiscal_year_dates` to get the fiscal year date start / date end for any given date. That methods first looks for a date range of type fiscal year that encloses the give date. @@ -30,15 +30,8 @@ Usage .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch} + :target: https://runbot.odoo-community.org/runbot/92/9.0 -.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt -.. branch is "8.0" for example - -Known issues / Roadmap -====================== - -* ... Bug Tracker =========== @@ -60,7 +53,8 @@ Contributors ------------ * Damien Crier -* ... +* Laurent Mignon +* Lorenzo Battistini Maintainer ---------- diff --git a/account_fiscal_year/__openerp__.py b/account_fiscal_year/__openerp__.py index 48325cfb..dd5a290e 100644 --- a/account_fiscal_year/__openerp__.py +++ b/account_fiscal_year/__openerp__.py @@ -4,7 +4,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Account Fiscal Year', - 'version': '9.0.0.1.0', + 'version': '9.0.1.0.0', 'category': 'Accounting', 'author': 'Camptocamp SA,' 'Odoo Community Association (OCA)', @@ -17,12 +17,6 @@ 'data/date_range_type.xml', 'views/date_range_type.xml', ], - 'test': [ - ], - 'demo': [ - ], - 'qweb': [ - ], 'installable': True, 'application': True, 'auto_install': False, diff --git a/account_fiscal_year/models/__init__.py b/account_fiscal_year/models/__init__.py index cd0d2142..27d10cd5 100644 --- a/account_fiscal_year/models/__init__.py +++ b/account_fiscal_year/models/__init__.py @@ -3,6 +3,5 @@ # Copyright 2016 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import date_range from . import date_range_type from . import res_company diff --git a/account_fiscal_year/models/date_range.py b/account_fiscal_year/models/date_range.py deleted file mode 100644 index 45c72a59..00000000 --- a/account_fiscal_year/models/date_range.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# Author: Damien Crier -# Copyright 2016 Camptocamp SA -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models -from openerp.tools import (DEFAULT_SERVER_DATETIME_FORMAT) - - -class DateRange(models.Model): - _inherit = 'date.range' - - def find_daterange_fy_start(self, date): - """ - try to find a date range with type 'fiscalyear' - with @param:date <= date_start - """ - fy_id = self.env.ref('account_fiscal_year.fiscalyear') - date_str = date.strftime(DEFAULT_SERVER_DATETIME_FORMAT) - s_args = [ - ('type_id', '=', fy_id.id), - ('date_start', '<=', date_str), - ('company_id', '=', self.company_id.id), - ] - date_range = self.env['date.range'].search(s_args) - return date_range.date_start diff --git a/account_fiscal_year/models/date_range_type.py b/account_fiscal_year/models/date_range_type.py index f621fd10..34dd8dfc 100644 --- a/account_fiscal_year/models/date_range_type.py +++ b/account_fiscal_year/models/date_range_type.py @@ -3,10 +3,24 @@ # Copyright 2016 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models, fields +from openerp import models, fields, api, _, exceptions class DateRangeType(models.Model): _inherit = "date.range.type" fiscal_year = fields.Boolean(string='Is fiscal year ?', default=False) + + @api.multi + def unlink(self): + """ + Cannot delete a date_range_type with 'fiscal_year' flag = True + """ + for rec in self: + if rec.fiscal_year: + raise exceptions.ValidationError( + _('You cannot delete a date range type with ' + 'flag "fiscal_year"') + ) + else: + super(DateRangeType, rec).unlink() diff --git a/account_fiscal_year/views/date_range_type.xml b/account_fiscal_year/views/date_range_type.xml index 2acc7804..4be9569a 100644 --- a/account_fiscal_year/views/date_range_type.xml +++ b/account_fiscal_year/views/date_range_type.xml @@ -8,7 +8,7 @@ - + @@ -18,10 +18,16 @@ - + + + + +