mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[IMP] add a res_config to the runbot
it can save/get two keys: default_workers and default_running_max
This commit is contained in:
parent
a823519cdf
commit
48bd01e6f2
@ -1 +1,2 @@
|
|||||||
import runbot
|
import runbot
|
||||||
|
import res_config
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
},
|
},
|
||||||
'data': [
|
'data': [
|
||||||
'runbot.xml',
|
'runbot.xml',
|
||||||
|
'res_config_view.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
53
runbot/res_config.py
Normal file
53
runbot/res_config.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Business Applications
|
||||||
|
# Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
from openerp.osv import fields, osv
|
||||||
|
|
||||||
|
class runbot_config_settings(osv.osv_memory):
|
||||||
|
_name = 'runbot.config.settings'
|
||||||
|
_inherit = 'res.config.settings'
|
||||||
|
_columns = {
|
||||||
|
'default_workers': fields.integer('Total Number of Workers'),
|
||||||
|
'default_running_max': fields.integer('Maximum Number of Running Builds'),
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_default_parameters(self, cr, uid, fields, context=None):
|
||||||
|
icp = self.pool['ir.config_parameter']
|
||||||
|
workers = icp.get_param(cr, uid, 'runbot.workers', default=6)
|
||||||
|
running_max = icp.get_param(cr, uid, 'runbot.running_max', default=75)
|
||||||
|
return {
|
||||||
|
'default_workers': int(workers),
|
||||||
|
'default_running_max': int(running_max)
|
||||||
|
}
|
||||||
|
|
||||||
|
def set_default_parameters(self, cr, uid, ids, context=None):
|
||||||
|
config = self.browse(cr, uid, ids[0], context)
|
||||||
|
icp = self.pool['ir.config_parameter']
|
||||||
|
icp.set_param(cr, uid, 'runbot.workers', config.default_workers)
|
||||||
|
icp.set_param(cr, uid, 'runbot.running_max', config.default_running_max)
|
||||||
|
|
||||||
|
_defaults = {
|
||||||
|
'default_workers': 6,
|
||||||
|
'default_running_max': 75,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
43
runbot/res_config_view.xml
Normal file
43
runbot/res_config_view.xml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<record id="view_runbot_configuration" model="ir.ui.view">
|
||||||
|
<field name="name">Configure Runbot</field>
|
||||||
|
<field name="model">runbot.config.settings</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Configure Runbot" class= "oe_form_configuration">
|
||||||
|
<header>
|
||||||
|
<button string="Apply" type="object" name="execute" class="oe_highlight"/>
|
||||||
|
or
|
||||||
|
<button string="Cancel" type="object" name="cancel" class="oe_link"/>
|
||||||
|
</header>
|
||||||
|
<separator string="Runbot"/>
|
||||||
|
<group>
|
||||||
|
<label for="id" string="Settings"/>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<field name="default_workers" class="oe_inline"/>
|
||||||
|
<label for="default_workers"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<field name="default_running_max" class="oe_inline"/>
|
||||||
|
<label for="default_running_max"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</group>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record id="action_runbot_configuration" model="ir.actions.act_window">
|
||||||
|
<field name="name">Configure Runbot</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">runbot.config.settings</field>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<field name="target">inline</field>
|
||||||
|
</record>
|
||||||
|
<menuitem id="menu_runbot_configuration" name="Runbot" parent="base.menu_config"
|
||||||
|
sequence="19" action="action_runbot_configuration"/>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
Loading…
Reference in New Issue
Block a user