From 6916df304fe1c7805d120685b87e517bba20e883 Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Wed, 10 Feb 2010 15:24:34 +0530 Subject: [PATCH] [ADD,IMP] base_action_rule: Added a wizard to activate/deactivate all the rules at a time. Improved function field for action rule object. bzr revid: uco@tinyerp.co.in-20100210095434-p4joqo4btxb9250n --- addons/base_action_rule/__init__.py | 3 +- addons/base_action_rule/__terp__.py | 1 + addons/base_action_rule/base_action_rule.py | 31 ++++++- .../base_action_rule_view.xml | 2 +- .../base_action_rule_wizard.xml | 13 +++ addons/base_action_rule/wizard/__init__.py | 24 +++++ .../wizard/wizard_activate_all.py | 93 +++++++++++++++++++ 7 files changed, 161 insertions(+), 6 deletions(-) create mode 100644 addons/base_action_rule/base_action_rule_wizard.xml create mode 100644 addons/base_action_rule/wizard/__init__.py create mode 100644 addons/base_action_rule/wizard/wizard_activate_all.py diff --git a/addons/base_action_rule/__init__.py b/addons/base_action_rule/__init__.py index c14f1081f46..4fbc05667ae 100644 --- a/addons/base_action_rule/__init__.py +++ b/addons/base_action_rule/__init__.py @@ -20,5 +20,6 @@ ############################################################################## import base_action_rule +import wizard -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_action_rule/__terp__.py b/addons/base_action_rule/__terp__.py index 13040a8d5f1..3825e04e05d 100644 --- a/addons/base_action_rule/__terp__.py +++ b/addons/base_action_rule/__terp__.py @@ -30,6 +30,7 @@ 'init_xml': ['base_action_rule_data.xml'], 'update_xml': [ 'base_action_rule_view.xml', + 'base_action_rule_wizard.xml', 'security/ir.model.access.csv', ], 'demo_xml': [], diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index ac490cb29ab..8cfa07aef80 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -1,3 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + import time import mx.DateTime import re @@ -34,6 +55,8 @@ class base_action_rule(osv.osv): res[check.id] = len(check.rule_lines) elif len(check.rule_lines) > 15: raise osv.except_osv(_('Error !'), _('Max Level exceeded.')) + else: + res[check.id] = 0 return res _columns = { @@ -42,17 +65,17 @@ class base_action_rule(osv.osv): type='integer', store=True, help='Specifies maximum rule lines can be entered.'), 'rule_lines': fields.one2many('base.action.rule.line','rule_id','Rule Lines', states={'activate': [('readonly', True)]}), 'create_date': fields.datetime('Create Date', readonly=1), - 'state': fields.selection([('draft','Draft'),('activate','Activated'),('deactivate','Deactivated')],'State',readonly=1) + 'state': fields.selection([('activate','Activated'),('deactivate','Deactivated')],'State',readonly=1) } _defaults = { - 'state': lambda *a: 'draft', + 'state': lambda *a: 'deactivate', } def button_activate_rule(self, cr, uid, ids, context=None): - check = self.browse(cr, uid, ids[0]).rule_lines + check = all(rule.rule_lines for rule in self.browse(cr, uid, ids)) if not check: - raise osv.except_osv(_('Error !'), _('Rule Lines are empty ! Cannot activate the Rule.')) + raise osv.except_osv(_('Error !'), _('Rule Lines are empty ! Cannot activate the Rule(s).')) cronobj = self.pool.get('ir.cron') cronids = cronobj.search(cr,uid,[('model','=','base.action.rule'),('active','=',False)]) if cronids: diff --git a/addons/base_action_rule/base_action_rule_view.xml b/addons/base_action_rule/base_action_rule_view.xml index 33e1fe91f5f..7d80aa32943 100644 --- a/addons/base_action_rule/base_action_rule_view.xml +++ b/addons/base_action_rule/base_action_rule_view.xml @@ -18,7 +18,7 @@ -