From 35961f50d785088f625647b68c5d89c25a0fbe8f Mon Sep 17 00:00:00 2001 From: Damien Crier Date: Mon, 9 May 2016 09:58:32 +0200 Subject: [PATCH] [IMP] add contributors to README [IMP] unable to unlink a date_range with type fiscal_year [IMP] `fiscal_year` flag readonly [IMP] add menu to date_range under accounting section --- account_fiscal_year/README.rst | 16 +++++----------- account_fiscal_year/models/date_range.py | 15 ++++++++++++++- account_fiscal_year/views/date_range_type.xml | 10 ++++++++-- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/account_fiscal_year/README.rst b/account_fiscal_year/README.rst index e4cde7192..8142bb409 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/models/date_range.py b/account_fiscal_year/models/date_range.py index 74ccb68a0..46b70e7a4 100644 --- a/account_fiscal_year/models/date_range.py +++ b/account_fiscal_year/models/date_range.py @@ -2,7 +2,7 @@ # 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 import models, api, _, exceptions from openerp.tools import DEFAULT_SERVER_DATE_FORMAT @@ -23,3 +23,16 @@ class DateRange(models.Model): ] date_range = self.env['date.range'].search(s_args) return date_range.date_start + + @api.multi + def unlink(self): + """ + Cannot delete a date_range of type 'fiscal_year' + """ + for rec in self: + if rec.type_id.fiscal_year: + raise exceptions.ValidationError( + _('You cannot delete a date range of type "fiscal_year"') + ) + else: + super(DateRange, rec).unlink() diff --git a/account_fiscal_year/views/date_range_type.xml b/account_fiscal_year/views/date_range_type.xml index 2acc78048..4be9569ac 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 @@ - + + + + +