diff options
| author | Fabien Pinckaers <fp@tinyerp.com> | 2010-05-19 20:32:10 +0200 |
|---|---|---|
| committer | Fabien Pinckaers <fp@tinyerp.com> | 2010-05-19 20:32:10 +0200 |
| commit | fd6eb4e4dd295514076db67aaa69d2fc22861f0c (patch) | |
| tree | 99f7755c7f720b2af49b9ccdba48a797f4405177 /bin | |
| parent | 60234cf878b09169a929e7918107c869c9f50afa (diff) | |
[IMP] logs background activities
bzr revid: fp@tinyerp.com-20100519183210-vyo63jvfs22mpxhg
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/addons/base/__openerp__.py (renamed from bin/addons/base/__terp__.py) | 1 | ||||
| -rw-r--r-- | bin/addons/base/data/res.country.state.csv | 104 | ||||
| -rw-r--r-- | bin/addons/base/res/__init__.py | 4 | ||||
| -rw-r--r-- | bin/addons/base/res/res_log.py | 42 | ||||
| -rw-r--r-- | bin/addons/base/res/res_log_view.xml | 56 | ||||
| -rw-r--r-- | bin/osv/orm.py | 24 | ||||
| -rw-r--r-- | bin/tools/yaml_import.py | 2 |
7 files changed, 176 insertions, 57 deletions
diff --git a/bin/addons/base/__terp__.py b/bin/addons/base/__openerp__.py index d0dc9b68dd3..72517183e77 100644 --- a/bin/addons/base/__terp__.py +++ b/bin/addons/base/__openerp__.py @@ -49,6 +49,7 @@ 'module/module_report.xml', 'res/res_request_view.xml', 'res/res_lang_view.xml', + 'res/res_log_view.xml', 'res/res_company_view.xml', 'res/partner/partner_report.xml', 'res/partner/partner_view.xml', diff --git a/bin/addons/base/data/res.country.state.csv b/bin/addons/base/data/res.country.state.csv index bdcb745eb08..d6b902e493b 100644 --- a/bin/addons/base/data/res.country.state.csv +++ b/bin/addons/base/data/res.country.state.csv @@ -1,52 +1,52 @@ -"country_id:id","name","code" -us,"Alabama","AL" -us,"Alaska","AK" -us,"Arizona","AZ" -us,"Arkansas","AR" -us,"California","CA" -us,"Colorado","CO" -us,"Connecticut","CT" -us,"Delaware","DE" -us,"District of Columbia","DC" -us,"Florida","FL" -us,"Georgia","GA" -us,"Hawaii","HI" -us,"Idaho","ID" -us,"Illinois","IL" -us,"Indiana","IN" -us,"Iowa","IA" -us,"Kansas","KS" -us,"Kentucky","KY" -us,"Louisiana","LA" -us,"Maine","ME" -us,"Montana","MT" -us,"Nebraska","NE" -us,"Nevada","NV" -us,"New Hampshire","NH" -us,"New Jersey","NJ" -us,"New Mexico","NM" -us,"New York","NY" -us,"North Carolina","NC" -us,"North Dakota","ND" -us,"Ohio","OH" -us,"Oklahoma","OK" -us,"Oregon","OR" -us,"Maryland","MD" -us,"Massachusetts","MA" -us,"Michigan","MI" -us,"Minnesota","MN" -us,"Mississippi","MS" -us,"Missouri","MO" -us,"Pennsylvania","PA" -us,"Rhode Island","RI" -us,"South Carolina","SC" -us,"South Dakota","SD" -us,"Tennessee","TN" -us,"Texas","TX" -us,"Utah","UT" -us,"Vermont","VT" -us,"Virginia","VA" -us,"Washington","WA" -us,"West Virginia","WV" -us,"Wisconsin","WI" -us,"Wyoming","WY" +"id","country_id:id","name","code" +state_us_1,us,"Alabama","AL" +state_us_2,us,"Alaska","AK" +state_us_3,us,"Arizona","AZ" +state_us_4,us,"Arkansas","AR" +state_us_5,us,"California","CA" +state_us_6,us,"Colorado","CO" +state_us_7,us,"Connecticut","CT" +state_us_8,us,"Delaware","DE" +state_us_9,us,"District of Columbia","DC" +state_us_10,us,"Florida","FL" +state_us_11,us,"Georgia","GA" +state_us_12,us,"Hawaii","HI" +state_us_13,us,"Idaho","ID" +state_us_14,us,"Illinois","IL" +state_us_15,us,"Indiana","IN" +state_us_16,us,"Iowa","IA" +state_us_17,us,"Kansas","KS" +state_us_18,us,"Kentucky","KY" +state_us_19,us,"Louisiana","LA" +state_us_20,us,"Maine","ME" +state_us_21,us,"Montana","MT" +state_us_22,us,"Nebraska","NE" +state_us_23,us,"Nevada","NV" +state_us_24,us,"New Hampshire","NH" +state_us_25,us,"New Jersey","NJ" +state_us_26,us,"New Mexico","NM" +state_us_27,us,"New York","NY" +state_us_28,us,"North Carolina","NC" +state_us_29,us,"North Dakota","ND" +state_us_30,us,"Ohio","OH" +state_us_31,us,"Oklahoma","OK" +state_us_32,us,"Oregon","OR" +state_us_33,us,"Maryland","MD" +state_us_34,us,"Massachusetts","MA" +state_us_35,us,"Michigan","MI" +state_us_36,us,"Minnesota","MN" +state_us_37,us,"Mississippi","MS" +state_us_38,us,"Missouri","MO" +state_us_39,us,"Pennsylvania","PA" +state_us_40,us,"Rhode Island","RI" +state_us_41,us,"South Carolina","SC" +state_us_42,us,"South Dakota","SD" +state_us_43,us,"Tennessee","TN" +state_us_44,us,"Texas","TX" +state_us_45,us,"Utah","UT" +state_us_46,us,"Vermont","VT" +state_us_47,us,"Virginia","VA" +state_us_48,us,"Washington","WA" +state_us_49,us,"West Virginia","WV" +state_us_50,us,"Wisconsin","WI" +state_us_51,us,"Wyoming","WY" diff --git a/bin/addons/base/res/__init__.py b/bin/addons/base/res/__init__.py index 66278c82087..b7a14c78a93 100644 --- a/bin/addons/base/res/__init__.py +++ b/bin/addons/base/res/__init__.py @@ -31,8 +31,6 @@ import res_company import res_user import res_request import res_lang - +import res_log import ir_property -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/bin/addons/base/res/res_log.py b/bin/addons/base/res/res_log.py new file mode 100644 index 00000000000..aed5701a297 --- /dev/null +++ b/bin/addons/base/res/res_log.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). +# +# 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 osv import fields, osv + +class res_log(osv.osv_memory): + _name = 'res.log' + _columns = { + 'name': fields.char('Message', size=128, help='The logging message.', required=True), + 'user_id': fields.many2one('res.users','User', required=True), + 'res_model': fields.char('Object', size=128), + 'res_id': fields.integer('Object ID') + } + _defaults = { + 'user_id': lambda self,cr,uid,ctx: uid + } + _order='id desc' + def get(self, cr, uid, context={}): + ids = self.search(cr, uid, [('user_id','=',uid)], context=context) + result = self.read(cr, uid, ids, ['name','res_model','res_id'], context=context) + self.unlink(cr, uid, ids, context=context) + return result +res_log() + diff --git a/bin/addons/base/res/res_log_view.xml b/bin/addons/base/res/res_log_view.xml new file mode 100644 index 00000000000..6f08434b266 --- /dev/null +++ b/bin/addons/base/res/res_log_view.xml @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="res_log_search" model="ir.ui.view"> + <field name="name">res.log.search</field> + <field name="model">res.log</field> + <field name="type">search</field> + <field name="arch" type="xml"> + <search string="Logs"> + <filter icon="terp-sale" string="My Logs" domain="[('user_id','=',uid)]" name="my"/> + <separator orientation="vertical"/> + <field name="name"/> + <field name="user_id"/> + <field name="res_model"/> + </search> + </field> + </record> + <record id="res_log_tree" model="ir.ui.view"> + <field name="name">res.log.tree</field> + <field name="model">res.log</field> + <field name="type">tree</field> + <field name="arch" type="xml"> + <tree string="Logs"> + <field name="name"/> + <field name="user_id"/> + </tree> + </field> + </record> + <record id="res_log_form" model="ir.ui.view"> + <field name="name">res.log.form</field> + <field name="model">res.log</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Logs"> + <group colspan="4" col="6"> + <field name="name" colspan="4"/> + <field name="user_id" /> + <field name="res_model"/> + <field name="res_id"/> + </group> + </form> + </field> + </record> + + <record id="res_log_act_window" model="ir.actions.act_window"> + <field name="name">Logs</field> + <field name="res_model">res.log</field> + <field name="view_type">form</field> + <field name="context">{'search_default_my': 1}</field> + </record> + <menuitem + action="res_log_act_window" + id="menu_res_log_act_window" + parent="base.next_id_4"/> + </data> +</openerp> diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 96501c370a8..b5c049a34df 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -398,8 +398,16 @@ class orm_template(object): _inherits = {} _table = None _invalids = set() + _log_create = True CONCURRENCY_CHECK_FIELD = '__last_update' + def log(self, cr, uid, id, message, context=None): + return self.pool.get('res.log').create(cr, uid, { + 'name': message, + 'res_model': self._name, + 'res_id': id}, + context=context + ) def view_init(self, cr , uid , fields_list, context=None): """Override this method to do specific things when a view on the object is opened.""" @@ -1731,6 +1739,7 @@ class orm_memory(orm_template): _max_count = 200 _max_hours = 1 _check_time = 20 + _log_create = False def __init__(self, cr): super(orm_memory, self).__init__(cr) @@ -1831,6 +1840,12 @@ class orm_memory(orm_template): for field in upd_todo: self._columns[field].set_memory(cr, self, id_new, field, vals[field], user, context) self._validate(cr, user, [id_new], context) + if self._log_create and not (context and context.get('no_store_function', False)): + message = self._description + \ + " '" + \ + self.name_get(cr, user, [id_new], context=context)[0][1] + \ + "' "+ _("created.") + self.log(cr, user, id_new, message, context=context) wf_service = netsvc.LocalService("workflow") wf_service.trg_create(user, self._name, id_new, cr) return id_new @@ -1918,7 +1933,6 @@ class orm_memory(orm_template): res=e.__dict__['_expression__exp'] return res or [] - def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): if not context: @@ -1990,6 +2004,7 @@ class orm_memory(orm_template): class orm(orm_template): _sql_constraints = [] _table = None + _log_create = True _protected = ['read','write','create','default_get','perm_read','unlink','fields_get','fields_view_get','search','name_get','distinct_field_get','name_search','copy','import_data','search_count', 'exists'] def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): @@ -3441,6 +3456,13 @@ class orm(orm_template): self.pool.get(object)._store_set_values(cr, user, ids, fields2, context) done.append((object, ids, fields2)) + if self._log_create and not (context and context.get('no_store_function', False)): + message = self._description + \ + " '" + \ + self.name_get(cr, user, [id_new], context=context)[0][1] + \ + "' "+ _("created.") + self.log(cr, user, id_new, message, context=context) + wf_service = netsvc.LocalService("workflow") wf_service.trg_create(user, self._name, id_new, cr) return id_new diff --git a/bin/tools/yaml_import.py b/bin/tools/yaml_import.py index 108a5ff0d32..df825f09cbb 100644 --- a/bin/tools/yaml_import.py +++ b/bin/tools/yaml_import.py @@ -682,7 +682,7 @@ class YamlInterpreter(object): self.logger.exception(e) except Exception, e: self.logger.exception(e) - raise e + raise def _process_node(self, node): if is_comment(node): |
