From 2a41432c2056cbfce6d3b43a217867b4514cf4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Pigeon?= Date: Wed, 10 Jan 2018 14:36:49 +0100 Subject: [PATCH] [CHG] prevent to declare fiscal month and/or year for all companies in a multi-company context --- account_fiscal_month/models/res_company.py | 4 +++- account_fiscal_year/models/res_company.py | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/account_fiscal_month/models/res_company.py b/account_fiscal_month/models/res_company.py index 140acd606..d58531da1 100644 --- a/account_fiscal_month/models/res_company.py +++ b/account_fiscal_month/models/res_company.py @@ -17,5 +17,7 @@ class ResCompany(models.Model): ('type_id', '=', fm_id.id), ('date_start', '<=', date_str), ('date_end', '>=', date_str), + '|', ('company_id', '=', self.id), - ]) + ('company_id', '=', False), + ], limit=1, order='company_id asc') diff --git a/account_fiscal_year/models/res_company.py b/account_fiscal_year/models/res_company.py index 234517b23..292e0adb4 100644 --- a/account_fiscal_year/models/res_company.py +++ b/account_fiscal_year/models/res_company.py @@ -19,9 +19,13 @@ class ResCompany(models.Model): ('type_id', '=', fy_id.id), ('date_start', '<=', date_str), ('date_end', '>=', date_str), + '|', ('company_id', '=', self.id), + ('company_id', '=', False), ] - date_range = self.env['date.range'].search(s_args) + date_range = self.env['date.range'].search(s_args, + limit=1, + order='company_id asc') return date_range @api.multi