diff --git a/addons/auction/auction_view.xml b/addons/auction/auction_view.xml
index ee1004ab0f3..2189253f3ce 100644
--- a/addons/auction/auction_view.xml
+++ b/addons/auction/auction_view.xml
@@ -3,8 +3,7 @@
-
-
+
=======================================================
Auction Management/Configuration/artist
=======================================================
@@ -204,7 +203,6 @@
-
@@ -279,7 +277,7 @@
-
+
@@ -332,6 +330,7 @@
+
@@ -341,7 +340,9 @@
+
+
diff --git a/addons/auction/auction_wizard.xml b/addons/auction/auction_wizard.xml
index ab1b051add5..0a93799cc20 100644
--- a/addons/auction/auction_wizard.xml
+++ b/addons/auction/auction_wizard.xml
@@ -1,8 +1,8 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- -->
+
+
+
+
diff --git a/addons/auction/wizard/auction_lots_able_view.xml b/addons/auction/wizard/auction_lots_able_view.xml
deleted file mode 100644
index 96135460c72..00000000000
--- a/addons/auction/wizard/auction_lots_able_view.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
- auction.lots.able.form
- auction.lots.able
- form
-
-
-
-
-
-
-
diff --git a/addons/auction/wizard/auction_lots_auction_move_view.xml b/addons/auction/wizard/auction_lots_auction_move_view.xml
deleted file mode 100644
index dd116a8bc6c..00000000000
--- a/addons/auction/wizard/auction_lots_auction_move_view.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
- auction.lots.auction.move.form
- auction.lots.auction.move
- form
-
-
-
-
-
-
-
-
diff --git a/addons/auction/wizard/auction_lots_enable_view.xml b/addons/auction/wizard/auction_lots_enable_view.xml
deleted file mode 100644
index 8384524dad2..00000000000
--- a/addons/auction/wizard/auction_lots_enable_view.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
- auction.lots.enable.form
- auction.lots.enable
- form
-
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/auction/wizard/auction_lots_make_invoice_buyer_view.xml b/addons/auction/wizard/auction_lots_make_invoice_buyer_view.xml
deleted file mode 100644
index ba4aac79ca6..00000000000
--- a/addons/auction/wizard/auction_lots_make_invoice_buyer_view.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
- auction.lots.make.invoice.buyer.form
- auction.lots.make.invoice.buyer
- form
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/auction/wizard/auction_lots_make_invoice_view.xml b/addons/auction/wizard/auction_lots_make_invoice_view.xml
deleted file mode 100644
index 29ef3e09348..00000000000
--- a/addons/auction/wizard/auction_lots_make_invoice_view.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
- auction.lots.make.invoice.form
- auction.lots.make.invoice
- form
-
-
-
-
-
-
-
-
-
diff --git a/addons/auction/wizard/auction_lots_sms_send_view.xml b/addons/auction/wizard/auction_lots_sms_send_view.xml
deleted file mode 100644
index 22aa9d681ac..00000000000
--- a/addons/auction/wizard/auction_lots_sms_send_view.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
- auction.lots.sms.send.form
- auction.lots.sms.send
- form
-
-
-
-
-
-
-
diff --git a/addons/auction/wizard/auction_pay_buy_view.xml b/addons/auction/wizard/auction_pay_buy_view.xml
deleted file mode 100644
index 0a9a3a6dcee..00000000000
--- a/addons/auction/wizard/auction_pay_buy_view.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
- auction.pay.buy.form
- auction.pay.buy
- form
-
-
-
-
-
-
-
diff --git a/addons/auction/wizard/auction_pay_sel_view.xml b/addons/auction/wizard/auction_pay_sel_view.xml
deleted file mode 100644
index 2570b7a7a0a..00000000000
--- a/addons/auction/wizard/auction_pay_sel_view.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
- auction.pay.sel.form
- auction.pay.sel
- form
-
-
-
-
-
-
- Pay objects of the seller
- auction.pay.sel
- form
- tree,form
-
- new
-
-
-
-
diff --git a/addons/auction/wizard/auction_payer_sel_view.xml b/addons/auction/wizard/auction_payer_sel_view.xml
deleted file mode 100644
index 57c43df8fe4..00000000000
--- a/addons/auction/wizard/auction_payer_sel_view.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
- auction.payer.form
- auction.payer
- form
-
-
-
-
-
-
- auction.payer.sel.form
- auction.payer.sel
- form
-
-
-
-
-
-
-
-
-
diff --git a/addons/auction/wizard/auction_taken_view.xml b/addons/auction/wizard/auction_taken_view.xml
deleted file mode 100644
index 626caa473ad..00000000000
--- a/addons/auction/wizard/auction_taken_view.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
- auction.taken.form
- auction.taken
- form
-
-
-
-
-
-
- Gestion emporte
- auction.taken
- form
- tree,form
-
- new
-
-
-
-
-
-
diff --git a/addons/lunch/wizard/confirm.py b/addons/auction/wizard/auction_wizard_able_taken.py
similarity index 56%
rename from addons/lunch/wizard/confirm.py
rename to addons/auction/wizard/auction_wizard_able_taken.py
index 64891098349..261cc47c48b 100644
--- a/addons/lunch/wizard/confirm.py
+++ b/addons/auction/wizard/auction_wizard_able_taken.py
@@ -1,8 +1,8 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL ().
+# 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
@@ -21,39 +21,40 @@
import wizard
import netsvc
-import ir
import pooler
-
-confirm_order_form = """
+take_form = """
"""
-confirm_order_fields = {
- 'confirm_cashbox': {'string':'Name of box', 'type':'many2one', 'required':True, 'relation':'lunch.cashbox' },
+take_fields = {
+# 'confirm_en': {'string':'Catalog Number', 'type':'integer'},
}
-def _confirm(self,cr,uid,data,context):
- pool= pooler.get_pool(cr.dbname)
- order_ref = pool.get('lunch.order')
- order_ref.confirm(cr,uid,data['ids'],data['form']['confirm_cashbox'],context)
+def _confirm_able(self,cr,uid,data,context={}):
+ res={}
+ pool = pooler.get_pool(cr.dbname)
+ pool.get('auction.lots').write(cr,uid,data['ids'],{'ach_emp':True})
return {}
-class order_confirm(wizard.interface):
+class able_take_away(wizard.interface):
states = {
- 'init': {
- 'action':[],
- 'result':{'type' : 'form', 'arch' : confirm_order_form, 'fields' : confirm_order_fields, 'state' : [('end', 'Cancel'),('go', 'Confirm Order') ]},
+ 'init' : {
+ 'actions' : [],
+ 'result' : {
+ 'type' : 'form',
+ 'arch' : take_form,
+ 'fields' : take_fields,
+ 'state' : [('end', 'Cancel'),('go', 'Able Taken away')]}
},
- 'go' : {
- 'actions' : [_confirm],
+ 'go' : {
+ 'actions' : [_confirm_able],
'result' : {'type' : 'state', 'state' : 'end'}
},
- }
-order_confirm('lunch.order.confirm')
+}
+able_take_away('auction.lots.able')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/idea/wizard/idea_vote.py b/addons/auction/wizard/auction_wizard_enable_taken.py
similarity index 52%
rename from addons/idea/wizard/idea_vote.py
rename to addons/auction/wizard/auction_wizard_enable_taken.py
index c040aa45be5..01f54ca28dc 100644
--- a/addons/idea/wizard/idea_vote.py
+++ b/addons/auction/wizard/auction_wizard_enable_taken.py
@@ -20,44 +20,42 @@
##############################################################################
import wizard
-import ir
-from mx.DateTime import now
-import pooler
import netsvc
+import pooler
+#field name="confirm_en"/>
-vote_form = """
-"""
+take_form = """
+
+"""
-vote_fields = {
- 'vote': {'string': 'Post Vote', 'type': 'selection',
- 'selection': [('-1','Not Voted'),('0','Very Bad'),('25', 'Bad'),('50','Normal'),('75','Good'),('100','Very Good') ]},
+take_fields = {
+ 'confirm_en': {'string':'Catalog Number', 'type':'integer'},
}
+def _confirm_enable(self,cr,uid,data,context={}):
+ pool = pooler.get_pool(cr.dbname)
+ pool.get('auction.lots').write(cr,uid,data['ids'],{'ach_emp':False})
+ return {}
-
-class idea_vote(wizard.interface):
- def _do_vote(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- vote_obj = pool.get('idea.vote')
- score=str(data['form']['vote'])
- dic={'idea_id' : data['id'], 'user_id' : uid, 'score' : score }
- vote=vote_obj.create(cr,uid,dic)
- return True
-
+class enable_take_away(wizard.interface):
states = {
- 'init':{
- 'actions': [],
- 'result': {'type':'form', 'arch':vote_form, 'fields':vote_fields, 'state':[('end', 'Cancel'), ('post', 'Post Vote')] },
+ 'init' : {
+ 'actions' : [],
+ 'result' : {
+ 'type' : 'form',
+ 'arch' : take_form,
+ 'fields' : take_fields,
+ 'state' : [ ('end', 'Cancel'),('go', 'Enable Taken away')]}
},
- 'post':{
- 'actions': [],
- 'result': {'type':'action', 'action': _do_vote, 'state':'end'},
+ 'go' : {
+ 'actions' : [_confirm_enable],
+ 'result' : {'type' : 'state', 'state' : 'end'}
},
- }
-idea_vote('idea.post.vote')
-
+}
+enable_take_away('auction.lots.enable')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/auction/wizard/auction_lots_make_invoice_buyer.py b/addons/auction/wizard/wizard_auction_invoice_buyer.py
similarity index 100%
rename from addons/auction/wizard/auction_lots_make_invoice_buyer.py
rename to addons/auction/wizard/wizard_auction_invoice_buyer.py
diff --git a/addons/auction/wizard/auction_lots_make_invoice.py b/addons/auction/wizard/wizard_auction_journal.py
similarity index 100%
rename from addons/auction/wizard/auction_lots_make_invoice.py
rename to addons/auction/wizard/wizard_auction_journal.py
diff --git a/addons/auction/wizard/auction_taken.py b/addons/auction/wizard/wizard_emporte.py
similarity index 100%
rename from addons/auction/wizard/auction_taken.py
rename to addons/auction/wizard/wizard_emporte.py
diff --git a/addons/auction/wizard/auction_lots_auction_move.py b/addons/auction/wizard/wizard_lot_date_move.py
similarity index 100%
rename from addons/auction/wizard/auction_lots_auction_move.py
rename to addons/auction/wizard/wizard_lot_date_move.py
diff --git a/addons/auction/wizard/auction_pay_sel.py b/addons/auction/wizard/wizard_lots_pay.py
similarity index 100%
rename from addons/auction/wizard/auction_pay_sel.py
rename to addons/auction/wizard/wizard_lots_pay.py
diff --git a/addons/auction/wizard/auction_lots_sms_send.py b/addons/auction/wizard/wizard_lots_sms.py
similarity index 100%
rename from addons/auction/wizard/auction_lots_sms_send.py
rename to addons/auction/wizard/wizard_lots_sms.py
diff --git a/addons/auction/wizard/auction_pay_buy.py b/addons/auction/wizard/wizard_pay.py
similarity index 100%
rename from addons/auction/wizard/auction_pay_buy.py
rename to addons/auction/wizard/wizard_pay.py
diff --git a/addons/auction/wizard/wizard_payer.py b/addons/auction/wizard/wizard_payer.py
new file mode 100644
index 00000000000..6e224fbadad
--- /dev/null
+++ b/addons/auction/wizard/wizard_payer.py
@@ -0,0 +1,79 @@
+# -*- 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 wizard
+import netsvc
+import netsvc
+import osv
+import time
+import pooler
+
+pay_form = '''
+'''
+pay_fields = {
+}
+
+
+pay_form1 = '''
+'''
+pay_fields1 = {
+}
+def _payer(self, cr, uid, data, context):
+ pool = pooler.get_pool(cr.dbname)
+ pool.get('auction.lots').write(cr,uid,data['ids'],{'is_ok':True, 'state':'paid'})
+ return {}
+
+
+def _payer_sel(self, cr, uid, data, context):
+ pool = pooler.get_pool(cr.dbname)
+ pool.get('auction.lots').write(cr,uid,data['ids'],{'paid_vnd':True})
+ return {}
+
+
+class wiz_auc_pay(wizard.interface):
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type': 'form', 'arch':pay_form, 'fields': pay_fields, 'state':[('end','Cancel'),('pay','Pay')]}
+ },
+ 'pay': {
+ 'actions': [_payer],
+ 'result': {'type': 'state', 'state':'end'}
+ }}
+wiz_auc_pay('auction.payer')
+
+
+class wiz_auc_pay_sel(wizard.interface):
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type': 'form', 'arch':pay_form1, 'fields': pay_fields1, 'state':[('end','Cancel'),('pay2','Pay')]}
+ },
+ 'pay2': {
+ 'actions': [_payer_sel],
+ 'result': {'type': 'state', 'state':'end'}
+ }}
+wiz_auc_pay_sel('auction.payer.sel')
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/audittrail/__terp__.py b/addons/audittrail/__terp__.py
index d8b573a704a..7ec81b4eb7e 100644
--- a/addons/audittrail/__terp__.py
+++ b/addons/audittrail/__terp__.py
@@ -37,6 +37,7 @@
'depends': ['base'],
'init_xml': [],
'update_xml': [
+ 'wizard/audittrail_view_log_view.xml',
'audittrail_view.xml',
'security/ir.model.access.csv',
'security/audittrail_security.xml'
diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py
index 22ddcafd7f9..80166298edb 100644
--- a/addons/audittrail/audittrail.py
+++ b/addons/audittrail/audittrail.py
@@ -19,35 +19,39 @@
#
##############################################################################
-
from osv import fields, osv
from osv.osv import osv_pool
from tools.translate import _
import ir
-import netsvc
import pooler
-import string
-import time, copy
+import time
class audittrail_rule(osv.osv):
+ """
+ For Auddittrail Rule
+ """
_name = 'audittrail.rule'
+ _description = "Audittrail Rule"
_columns = {
- "name": fields.char("Rule Name", size=32, required=True),
- "object_id": fields.many2one('ir.model', 'Object', required=True),
- "user_id": fields.many2many('res.users', 'audittail_rules_users', 'user_id', 'rule_id', 'Users'),
- "log_read": fields.boolean("Log reads"),
- "log_write": fields.boolean("Log writes"),
- "log_unlink": fields.boolean("Log deletes"),
- "log_create": fields.boolean("Log creates"),
- "state": fields.selection((("draft", "Draft"), ("subscribed", "Subscribed")), "State", required=True),
- "action_id":fields.many2one('ir.actions.act_window', "Action ID"),
+ "name": fields.char("Rule Name", size=32, required=True),
+ "object_id": fields.many2one('ir.model', 'Object', required=True),
+ "user_id": fields.many2many('res.users', 'audittail_rules_users',
+ 'user_id', 'rule_id', 'Users'),
+ "log_read": fields.boolean("Log reads"),
+ "log_write": fields.boolean("Log writes"),
+ "log_unlink": fields.boolean("Log deletes"),
+ "log_create": fields.boolean("Log creates"),
+ "state": fields.selection((("draft", "Draft"),
+ ("subscribed", "Subscribed")),
+ "State", required=True),
+ "action_id": fields.many2one('ir.actions.act_window', "Action ID"),
}
_defaults = {
- 'state': lambda *a: 'draft',
- 'log_create': lambda *a: 1,
- 'log_unlink': lambda *a: 1,
- 'log_write': lambda *a: 1,
+ 'state': lambda *a: 'draft',
+ 'log_create': lambda *a: 1,
+ 'log_unlink': lambda *a: 1,
+ 'log_write': lambda *a: 1,
}
_sql_constraints = [
@@ -56,59 +60,86 @@ class audittrail_rule(osv.osv):
__functions = {}
def subscribe(self, cr, uid, ids, *args):
+ """
+ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Auddittrail Rule’s IDs.
+ @return: True
+ """
+ obj_action = self.pool.get('ir.actions.act_window')
+ obj_model = self.pool.get('ir.model.data')
+ #start Loop
for thisrule in self.browse(cr, uid, ids):
obj = self.pool.get(thisrule.object_id.model)
if not obj:
raise osv.except_osv(
- _('WARNING:audittrail is not part of the pool'),
+ _('WARNING: audittrail is not part of the pool'),
_('Change audittrail depends -- Setting rule as DRAFT'))
self.write(cr, uid, [thisrule.id], {"state": "draft"})
- val={
- "name":'View Log',
- "res_model":'audittrail.log',
- "src_model":thisrule.object_id.model,
- "domain":"[('object_id','=',"+str(thisrule.object_id.id)+"),('res_id', '=', active_id)]"
+ val = {
+ "name": 'View Log',
+ "res_model": 'audittrail.log',
+ "src_model": thisrule.object_id.model,
+ "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
}
- id=self.pool.get('ir.actions.act_window').create(cr, uid, val)
- self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id":id})
+ id = obj_action.create(cr, uid, val)
+ self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id": id})
keyword = 'client_action_relate'
- value = 'ir.actions.act_window,'+str(id)
- res=self.pool.get('ir.model.data').ir_set(cr, uid, 'action', keyword, 'View_log_'+thisrule.object_id.model, [thisrule.object_id.model], value, replace=True, isobject=True, xml_id=False)
+ value = 'ir.actions.act_window,' + str(id)
+ res = obj_model.ir_set(cr, uid, 'action', keyword, 'View_log_' + thisrule.object_id.model, [thisrule.object_id.model], value, replace=True, isobject=True, xml_id=False)
+ #End Loop
return True
-
-
def unsubscribe(self, cr, uid, ids, *args):
+ """
+ Unsubscribe Auditing Rule on object
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Auddittrail Rule’s IDs.
+ @return: True
+ """
+ obj_action = self.pool.get('ir.actions.act_window')
+ val_obj = self.pool.get('ir.values')
+ #start Loop
for thisrule in self.browse(cr, uid, ids):
- if thisrule.id in self.__functions :
+ if thisrule.id in self.__functions:
for function in self.__functions[thisrule.id]:
setattr(function[0], function[1], function[2])
- w_id=self.pool.get('ir.actions.act_window').search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)])
- self.pool.get('ir.actions.act_window').unlink(cr, uid, w_id)
- val_obj=self.pool.get('ir.values')
- value="ir.actions.act_window"+','+str(w_id[0])
- val_id=val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)])
+ w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)])
+ obj_action.unlink(cr, uid, w_id)
+ value = "ir.actions.act_window" + ',' + str(w_id[0])
+ val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)])
if val_id:
res = ir.ir_del(cr, uid, val_id[0])
self.write(cr, uid, [thisrule.id], {"state": "draft"})
+ #End Loop
return True
audittrail_rule()
class audittrail_log(osv.osv):
+ """
+ For Audittrail Log
+ """
_name = 'audittrail.log'
+ _description = "Audittrail Log"
_columns = {
- "name": fields.char("Name", size=32),
- "object_id": fields.many2one('ir.model', 'Object'),
- "user_id": fields.many2one('res.users', 'User'),
- "method": fields.selection((('read', 'Read'), ('write', 'Write'), ('unlink', 'Delete'), ('create', 'Create')), "Method"),
- "timestamp": fields.datetime("Date"),
- "res_id":fields.integer('Resource Id'),
- "line_ids":fields.one2many('audittrail.log.line', 'log_id', 'Log lines'),
+ "name": fields.char("Name", size=32),
+ "object_id": fields.many2one('ir.model', 'Object'),
+ "user_id": fields.many2one('res.users', 'User'),
+ "method": fields.selection((('read', 'Read'),
+ ('write', 'Write'),
+ ('unlink', 'Delete'),
+ ('create', 'Create')), "Method"),
+ "timestamp": fields.datetime("Date"),
+ "res_id": fields.integer('Resource Id'),
+ "line_ids": fields.one2many('audittrail.log.line', 'log_id', 'Log lines'),
}
+
_defaults = {
"timestamp": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S")
}
@@ -116,235 +147,293 @@ class audittrail_log(osv.osv):
audittrail_log()
+
class audittrail_log_line(osv.osv):
- _name='audittrail.log.line'
- _columns={
- 'field_id': fields.many2one('ir.model.fields', 'Fields', required=True),
- 'log_id':fields.many2one('audittrail.log', 'Log'),
- 'log':fields.integer("Log ID"),
- 'old_value':fields.text("Old Value"),
- 'new_value':fields.text("New Value"),
- 'old_value_text':fields.text('Old value Text'),
- 'new_value_text':fields.text('New value Text'),
- 'field_description':fields.char('Field Description' , size=64),
- }
+ """
+ Audittrail Log Line.
+ """
+ _name = 'audittrail.log.line'
+ _description = "Log Line"
+ _columns = {
+ 'field_id': fields.many2one('ir.model.fields', 'Fields', required=True),
+ 'log_id': fields.many2one('audittrail.log', 'Log'),
+ 'log': fields.integer("Log ID"),
+ 'old_value': fields.text("Old Value"),
+ 'new_value': fields.text("New Value"),
+ 'old_value_text': fields.text('Old value Text'),
+ 'new_value_text': fields.text('New value Text'),
+ 'field_description': fields.char('Field Description', size=64),
+ }
audittrail_log_line()
+
class audittrail_objects_proxy(osv_pool):
- def get_value_text(self, cr, uid, field_name, values, object, context={}):
- pool = pooler.get_pool(cr.dbname)
- obj=pool.get(object.model)
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object.model)])
- model_object=pool.get('ir.model').browse(cr, uid, obj_ids)[0]
- f_id= pool.get('ir.model.fields').search(cr, uid, [('name', '=', field_name), ('model_id', '=', object.id)])
- if f_id:
- field=pool.get('ir.model.fields').read(cr, uid, f_id)[0]
- model=field['relation']
+ """ Uses Object proxy for auditing changes on object of subscribed Rules"""
+
+ def get_value_text(self, cr, uid, field_name, values, object, context=None):
+ """
+ Gets textual values for the fields
+ e.g.: For field of type many2one it gives its name value instead of id
- if field['ttype']=='many2one':
- if values:
- if type(values)==tuple:
- values=values[0]
- val=pool.get(model).read(cr, uid, [values], [pool.get(model)._rec_name])
- if len(val):
- return val[0][pool.get(model)._rec_name]
- elif field['ttype'] == 'many2many':
- value=[]
- if values:
- for id in values:
- val=pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
- if len(val):
- value.append(val[0][pool.get(model)._rec_name])
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param field_name: List of fields for text values
+ @param values: Values for field to be converted into textual values
+ @return: values: List of textual values for given fields
+ """
+ if not context:
+ context = {}
+ pool = pooler.get_pool(cr.dbname)
+ f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', field_name), ('model_id', '=', object.id)])
+ if f_id:
+ field = pool.get('ir.model.fields').read(cr, uid, f_id)[0]
+ model = field['relation']
+
+ if field['ttype'] == 'many2one':
+ if values:
+ if type(values) == tuple:
+ values = values[0]
+ val = pool.get(model).read(cr, uid, [values], [pool.get(model)._rec_name])
+ if val:
+ return val[0][pool.get(model)._rec_name]
+ elif field['ttype'] == 'many2many':
+ value = []
+ if values:
+ for id in values:
+ val = pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
+ if val:
+ value.append(val[0][pool.get(model)._rec_name])
+ return value
+
+ elif field['ttype'] == 'one2many':
+ if values:
+ value = []
+ for id in values:
+ val = pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
+
+ if val:
+ value.append(val[0][pool.get(model)._rec_name])
return value
-
- elif field['ttype'] == 'one2many':
- if values:
- value=[]
- for id in values:
- val=pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
-
- if len(val):
- value.append(val[0][pool.get(model)._rec_name])
- return value
return values
def create_log_line(self, cr, uid, id, object, lines=[]):
+ """
+ Creates lines for changed fields with its old and new values
+
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param object: Object who's values are being changed
+ @param lines: List of values for line is to be created
+ """
+
pool = pooler.get_pool(cr.dbname)
- obj=pool.get(object.model)
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object.model)])
- model_object=pool.get('ir.model').browse(cr, uid, obj_ids)[0]
+ obj = pool.get(object.model)
+ #start Loop
for line in lines:
if obj._inherits:
- inherits_ids= pool.get('ir.model').search(cr, uid, [('model', '=', obj._inherits.keys()[0])])
- f_id= pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', (object.id, inherits_ids[0]))])
+ inherits_ids = pool.get('ir.model').search(cr, uid, [('model', '=', obj._inherits.keys()[0])])
+ f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', (object.id, inherits_ids[0]))])
else:
- f_id= pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', '=', object.id)])
- if len(f_id):
- fields=pool.get('ir.model.fields').read(cr, uid, f_id)
- old_value='old_value' in line and line['old_value'] or ''
- new_value='new_value' in line and line['new_value'] or ''
- old_value_text='old_value_text' in line and line['old_value_text'] or ''
- new_value_text='new_value_text' in line and line['new_value_text'] or ''
+ f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', '=', object.id)])
+ if f_id:
+ fields = pool.get('ir.model.fields').read(cr, uid, f_id)
+ old_value = 'old_value' in line and line['old_value'] or ''
+ new_value = 'new_value' in line and line['new_value'] or ''
+ old_value_text = 'old_value_text' in line and line['old_value_text'] or ''
+ new_value_text = 'new_value_text' in line and line['new_value_text'] or ''
if old_value_text == new_value_text:
continue
- if fields[0]['ttype']== 'many2one':
- if type(old_value)==tuple:
- old_value=old_value[0]
- if type(new_value)==tuple:
- new_value=new_value[0]
- log_line_id = pool.get('audittrail.log.line').create(cr, uid, {"log_id": id, "field_id": f_id[0] , "old_value":old_value , "new_value":new_value, "old_value_text":old_value_text , "new_value_text":new_value_text, "field_description":fields[0]['field_description']})
+ if fields[0]['ttype'] == 'many2one':
+ if type(old_value) == tuple:
+ old_value = old_value[0]
+ if type(new_value) == tuple:
+ new_value = new_value[0]
+ vals = {
+ "log_id": id,
+ "field_id": f_id[0],
+ "old_value": old_value,
+ "new_value": new_value,
+ "old_value_text": old_value_text,
+ "new_value_text": new_value_text,
+ "field_description": fields[0]['field_description']
+ }
+ line_id = pool.get('audittrail.log.line').create(cr, uid, vals)
cr.commit()
+ #End Loop
return True
def log_fct(self, db, uid, object, method, fct_src, *args):
- logged_uids = []
- pool = pooler.get_pool(db)
- cr = pooler.get_db(db).cursor()
- obj=pool.get(object)
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object)])
- model_object=pool.get('ir.model').browse(cr, uid, obj_ids)[0]
- if method in ('create'):
- res_id = fct_src(db, uid, object, method, *args)
+ """
+ Logging function: This function is performs logging oprations according to method
+ @param db: the current database
+ @param uid: the current user’s ID for security checks,
+ @param object: Object who's values are being changed
+ @param method: method to log: create, read, write, unlink
+ @param fct_src: execute method of Object proxy
+
+ @return: Returns result as per method of Object proxy
+ """
+ logged_uids = []
+ pool = pooler.get_pool(db)
+ cr = pooler.get_db(db).cursor()
+ obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)])
+ model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0]
+ if method in ('create'):
+ res_id = fct_src(db, uid, object, method, *args)
+ cr.commit()
+ new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0]
+ if 'id' in new_value:
+ del new_value['id']
+ if not logged_uids or uid in logged_uids:
+ resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
+ resource_name = resource_name and resource_name[0][1] or ''
+ vals = {
+ "method": method,
+ "object_id": model_object.id,
+ "user_id": uid, "res_id": res_id,
+ "name": resource_name
+ }
+ id = pool.get('audittrail.log').create(cr, uid, vals)
+ lines = []
+ for field in new_value:
+ if new_value[field]:
+ line = {
+ 'name': field,
+ 'new_value': new_value[field],
+ 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object)
+ }
+ lines.append(line)
+ self.create_log_line(cr, uid, id, model_object, lines)
+ cr.commit()
+ cr.close()
+ return res_id
+
+ if method in ('write'):
+ res_ids = args[0]
+ for res_id in res_ids:
+ old_values = pool.get(model_object.model).read(cr, uid, res_id, args[1].keys())
+ old_values_text = {}
+ for field in args[1].keys():
+ old_values_text[field] = self.get_value_text(cr, uid, field, old_values[field], model_object)
+ res = fct_src(db, uid, object, method, *args)
cr.commit()
- new_value=pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0]
- if 'id' in new_value:
- del new_value['id']
- if not len(logged_uids) or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method , "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in new_value:
- if new_value[field]:
- line={
- 'name':field,
- 'new_value':new_value[field],
- 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object)
- }
- lines.append(line)
- self.create_log_line(cr, uid, id, model_object, lines)
- cr.commit()
- cr.close()
- return res_id
-
- if method in ('write'):
- res_ids=args[0]
- for res_id in res_ids:
- old_values=pool.get(model_object.model).read(cr, uid, res_id, args[1].keys())
- old_values_text={}
- for field in args[1].keys():
- old_values_text[field] = self.get_value_text(cr, uid, field, old_values[field], model_object)
- res =fct_src(db, uid, object, method, *args)
- cr.commit()
- if res:
- new_values=pool.get(model_object.model).read(cr, uid, res_ids, args[1].keys())[0]
- if not len(logged_uids) or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in args[1].keys():
- if args[1].keys():
- line={
- 'name':field,
- 'new_value':field in new_values and new_values[field] or '',
- 'old_value':field in old_values and old_values[field] or '',
- 'new_value_text': self.get_value_text(cr, uid, field, new_values[field], model_object),
- 'old_value_text':old_values_text[field]
- }
- lines.append(line)
- cr.commit()
- self.create_log_line(cr, uid, id, model_object, lines)
- cr.close()
- return res
-
- if method in ('read'):
- res_ids=args[0]
- old_values={}
- res =fct_src(db, uid, object, method, *args)
- if type(res)==list:
-
- for v in res:
- old_values[v['id']]=v
- else:
- old_values[res['id']]=res
- for res_id in old_values:
- if not len(logged_uids) or uid in logged_uids:
+ if res:
+ new_values = pool.get(model_object.model).read(cr, uid, res_ids, args[1].keys())[0]
+ if not logged_uids or uid in logged_uids:
resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method , "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in old_values[res_id]:
- if old_values[res_id][field]:
- line={
- 'name':field,
- 'old_value':old_values[res_id][field],
- 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
- }
- lines.append(line)
- cr.commit()
- self.create_log_line(cr, uid, id, model_object, lines)
- cr.close()
- return res
-
- if method in ('unlink'):
- res_ids=args[0]
- old_values={}
- for res_id in res_ids:
- old_values[res_id]=pool.get(model_object.model).read(cr, uid, res_id, [])
-
- for res_id in res_ids:
- if not len(logged_uids) or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method , "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in old_values[res_id]:
- if old_values[res_id][field]:
- line={
- 'name':field,
- 'old_value':old_values[res_id][field],
- 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
+ id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
+ lines = []
+ for field in args[1].keys():
+ if args[1].keys():
+ line = {
+ 'name': field,
+ 'new_value': field in new_values and new_values[field] or '',
+ 'old_value': field in old_values and old_values[field] or '',
+ 'new_value_text': self.get_value_text(cr, uid, field, new_values[field], model_object),
+ 'old_value_text': old_values_text[field]
}
lines.append(line)
cr.commit()
self.create_log_line(cr, uid, id, model_object, lines)
- res =fct_src(db, uid, object, method, *args)
cr.close()
return res
+
+ if method in ('read'):
+ res_ids = args[0]
+ old_values = {}
+ res = fct_src(db, uid, object, method, *args)
+ if type(res) == list:
+
+ for v in res:
+ old_values[v['id']] = v
+ else:
+ old_values[res['id']] = res
+ for res_id in old_values:
+ if not logged_uids or uid in logged_uids:
+ resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
+ resource_name = resource_name and resource_name[0][1] or ''
+ id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
+ lines = []
+ for field in old_values[res_id]:
+ if old_values[res_id][field]:
+ line = {
+ 'name': field,
+ 'old_value': old_values[res_id][field],
+ 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
+ }
+ lines.append(line)
+ cr.commit()
+ self.create_log_line(cr, uid, id, model_object, lines)
cr.close()
+ return res
+
+ if method in ('unlink'):
+ res_ids = args[0]
+ old_values = {}
+ for res_id in res_ids:
+ old_values[res_id] = pool.get(model_object.model).read(cr, uid, res_id, [])
+
+ for res_id in res_ids:
+ if not logged_uids or uid in logged_uids:
+ resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
+ resource_name = resource_name and resource_name[0][1] or ''
+ id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
+ lines = []
+ for field in old_values[res_id]:
+ if old_values[res_id][field]:
+ line = {
+ 'name': field,
+ 'old_value': old_values[res_id][field],
+ 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
+ }
+ lines.append(line)
+ cr.commit()
+ self.create_log_line(cr, uid, id, model_object, lines)
+ res = fct_src(db, uid, object, method, *args)
+ cr.close()
+ return res
+ cr.close()
def execute(self, db, uid, object, method, *args, **kw):
+ """
+ Overrides Object Proxy execute method
+ @param db: the current database
+ @param uid: the current user’s ID for security checks,
+ @param object: Object who's values are being changed
+ @param method: method to log: create, read, write, unlink
+
+ @return: Returns result as per method of Object proxy
+ """
pool = pooler.get_pool(db)
cr = pooler.get_db(db).cursor()
cr.autocommit(True)
- obj=pool.get(object)
logged_uids = []
fct_src = super(audittrail_objects_proxy, self).execute
def my_fct(db, uid, object, method, *args):
field = method
rule = False
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object)])
+ obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)])
for obj_name in pool.obj_list():
if obj_name == 'audittrail.rule':
rule = True
if not rule:
return fct_src(db, uid, object, method, *args)
- if not len(obj_ids):
+ if not obj_ids:
return fct_src(db, uid, object, method, *args)
- rule_ids=pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', obj_ids[0]), ('state', '=', 'subscribed')])
- if not len(rule_ids):
+ rule_ids = pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', obj_ids[0]), ('state', '=', 'subscribed')])
+ if not rule_ids:
return fct_src(db, uid, object, method, *args)
for thisrule in pool.get('audittrail.rule').browse(cr, uid, rule_ids):
for user in thisrule.user_id:
logged_uids.append(user.id)
- if not len(logged_uids) or uid in logged_uids:
+ if not logged_uids or uid in logged_uids:
if field in ('read', 'write', 'create', 'unlink'):
- if getattr(thisrule, 'log_'+field):
+ if getattr(thisrule, 'log_' + field):
return self.log_fct(db, uid, object, method, fct_src, *args)
return fct_src(db, uid, object, method, *args)
res = my_fct(db, uid, object, method, *args)
diff --git a/addons/audittrail/audittrail_view.xml b/addons/audittrail/audittrail_view.xml
index 98a4ecc00e9..dec025b7e98 100644
--- a/addons/audittrail/audittrail_view.xml
+++ b/addons/audittrail/audittrail_view.xml
@@ -1,6 +1,9 @@
+
+
+
audittrail.rule.form
audittrail.rule
@@ -17,12 +20,15 @@
-
-
+
+
+
audittrail.rule.tree
audittrail.rule
@@ -40,6 +46,9 @@
+
+
+
Rules
audittrail.rule
@@ -48,8 +57,11 @@
tree,form
-
-
+
+
+
@@ -60,6 +72,8 @@
[('state','=','subscribed')]
+
+
audittrail.log.form
@@ -73,23 +87,34 @@
-
+
@@ -117,15 +142,19 @@
+
+
Logs
audittrail.log
form
-
+
-
-
+
+
-
+
diff --git a/addons/audittrail/security/ir.model.access.csv b/addons/audittrail/security/ir.model.access.csv
index ac367182f26..9aba9ddf598 100644
--- a/addons/audittrail/security/ir.model.access.csv
+++ b/addons/audittrail/security/ir.model.access.csv
@@ -5,3 +5,4 @@
"access_audittrail_rule_all_users","audittrail rule all","model_audittrail_rule","base.group_user",1,0,0,0
"access_audittrail_log_all_users","audittrail log all","model_audittrail_log","base.group_user",1,0,1,0
"access_audittrail_log_line_all_users","audittrail log line all","model_audittrail_log_line","base.group_user",1,0,1,0
+"access_audittrail_view_log","audittrail.view.log","model_audittrail_view_log","base.group_user",1,1,1,1
diff --git a/addons/audittrail/wizard/__init__.py b/addons/audittrail/wizard/__init__.py
index c7b5a20d884..9b2af466a01 100644
--- a/addons/audittrail/wizard/__init__.py
+++ b/addons/audittrail/wizard/__init__.py
@@ -19,6 +19,6 @@
#
##############################################################################
-import wizard_view_log
+import audittrail_view_log
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/audittrail/wizard/audittrail_view_log.py b/addons/audittrail/wizard/audittrail_view_log.py
new file mode 100644
index 00000000000..aa26c8cfd4c
--- /dev/null
+++ b/addons/audittrail/wizard/audittrail_view_log.py
@@ -0,0 +1,69 @@
+# -*- 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+import time
+
+class audittrail_view_log(osv.osv_memory):
+
+ _name = "audittrail.view.log"
+ _description = "View Log"
+ _columns = {
+ 'from':fields.datetime('Log From'),
+ 'to':fields.datetime('Log To', required = True)
+ }
+ _defaults = {
+ 'to': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
+ }
+
+ def log_open_window(self, cr, uid, ids, context=None):
+ """
+ Open Log form from given date range..
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of audittrail view log’s IDs.
+ @return: Dictionary of audittrail log form on given date range.
+ """
+ if not context:
+ context = {}
+
+ mod_obj = self.pool.get('ir.model.data')
+ act_obj = self.pool.get('ir.actions.act_window')
+ result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
+ id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
+ result = act_obj.read(cr, uid, [id])[0]
+ #log_obj = self.pool.get(result['res_model'])
+ #log_id = log_obj.search(cr, uid, [])
+ #log_model = log_obj.read(cr, uid, log_id, ['object_id'])
+
+ #start Loop
+ for datas in self.read(cr, uid, ids):
+ if not datas.get('from', None):
+ if datas.get('to') <> time.strftime("%Y-%m-%d %H:%M:%S"):
+ result['domain'] = str([('timestamp', '<', datas.get('to'))])
+ else:
+ pass
+ else:
+ result['domain'] = str([('timestamp', '>', datas.get('from', None)), ('timestamp', '<', datas.get('to'))])
+ #End Loop
+ return result
+
+audittrail_view_log()
diff --git a/addons/audittrail/wizard/audittrail_view_log_view.xml b/addons/audittrail/wizard/audittrail_view_log_view.xml
new file mode 100644
index 00000000000..e32bc65de40
--- /dev/null
+++ b/addons/audittrail/wizard/audittrail_view_log_view.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+ audittrail.view.log.form
+ audittrail.view.log
+ form
+
+
+
+
+
+
+
+
+ View log
+ audittrail.view.log
+ form
+ tree,form
+
+ new
+
+
+
+
diff --git a/addons/audittrail/wizard/wizard_view_log.py b/addons/audittrail/wizard/wizard_view_log.py
deleted file mode 100644
index 81936bcd54c..00000000000
--- a/addons/audittrail/wizard/wizard_view_log.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- 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 wizard
-import pooler
-import time
-
-class wizard_view_log(wizard.interface):
-
- form1 = '''
- '''
-
- form1_fields = {
- 'from': {
- 'string': 'Log From',
- 'type': 'datetime',
-
- },
- 'to': {
- 'string': 'Log To',
- 'type': 'datetime',
- 'default': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
- 'required':True
- },
- }
-
-
- def _log_open_window(self, cr, uid, data, context):
- mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
- act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
- result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
- id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
- result = act_obj.read(cr, uid, [id])[0]
- log_obj= pooler.get_pool(cr.dbname).get(result['res_model'])
- log_id = log_obj.search(cr, uid, [])
- log_model=log_obj.read(cr, uid,log_id,['object_id'])
- if not data['form']['from']:
- if data['form']['to'] <> time.strftime("%Y-%m-%d %H:%M:%S"):
- result['domain'] = str([('timestamp', '<',data['form']['to'])])
- else:
- pass
- else:
- result['domain'] = str([('timestamp', '>',data['form']['from']),('timestamp', '<',data['form']['to'])])
-
- return result
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel'), ('open', 'Open Logs')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action':_log_open_window, 'state':'end'}
- }
- }
-wizard_view_log('audittrail.view.log')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py
index 020d2740d4d..f4129998bcc 100644
--- a/addons/base_action_rule/base_action_rule.py
+++ b/addons/base_action_rule/base_action_rule.py
@@ -29,61 +29,86 @@ from osv.orm import except_orm
from tools.translate import _
class base_action_rule(osv.osv):
+ """ Base Action Rules """
+
_name = 'base.action.rule'
- _description = 'Action Rules'
-
-
+ _description = 'Action Rules'
+
_columns = {
'name': fields.many2one('ir.model', 'Model', required=True),
- 'max_level': fields.integer('Max Level', help='Specifies maximum level.'),
+ 'max_level': fields.integer('Max Level', help='Specifies maximum level.'),
'rule_lines': fields.one2many('base.action.rule.line','rule_id','Rule Lines'),
'create_date': fields.datetime('Create Date', readonly=1),
'active': fields.boolean('Active')
}
-
+
_defaults = {
'active': lambda *a: True,
'max_level': lambda *a: 15,
}
def format_body(self, body):
+ """ Foramat Action rule's body
+ @param self: The object pointer """
+
return body and tools.ustr(body) or ''
def format_mail(self, obj, body):
+ """ Foramat Mail
+ @param self: The object pointer """
+
data = {
'object_id': obj.id,
'object_subject': hasattr(obj, 'name') and obj.name or False,
'object_date': hasattr(obj, 'date') and obj.date or False,
'object_description': hasattr(obj, 'description') and obj.description or False,
'object_user': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.name) or '/',
- 'object_user_email': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.address_id and obj.user_id.address_id.email) or '/',
- 'object_user_phone': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.address_id and obj.user_id.address_id.phone) or '/',
+ 'object_user_email': hasattr(obj, 'user_id') and (obj.user_id and \
+ obj.user_id.address_id and obj.user_id.address_id.email) or '/',
+ 'object_user_phone': hasattr(obj, 'user_id') and (obj.user_id and\
+ obj.user_id.address_id and obj.user_id.address_id.phone) or '/',
'partner': hasattr(obj, 'partner_id') and (obj.partner_id and obj.partner_id.name) or '/',
- 'partner_email': hasattr(obj, 'partner_address_id') and (obj.partner_address_id and obj.partner_address_id.email) or '/',
+ 'partner_email': hasattr(obj, 'partner_address_id') and (obj.partner_address_id and\
+ obj.partner_address_id.email) or '/',
}
return self.format_body(body % data)
def email_send(self, cr, uid, obj, emails, body, emailfrom=tools.config.get('email_from',False), context={}):
+ """ send email
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param email: pass the emails
+ @param emailfrom: Pass name the email From else False
+ @param context: A standard dictionary for contextual values """
+
body = self.format_mail(obj, body)
if not emailfrom:
- if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and obj.user_id.address_id.email:
+ if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and\
+ obj.user_id.address_id.email:
emailfrom = obj.user_id.address_id.email
-
+
name = '[%d] %s' % (obj.id, tools.ustr(obj.name))
emailfrom = tools.ustr(emailfrom)
- reply_to = emailfrom
+ reply_to = emailfrom
if not emailfrom:
raise osv.except_osv(_('Error!'),
_("No E-Mail ID Found for your Company address!"))
return tools.email_send(emailfrom, emails, name, body, reply_to=reply_to, openobject_id=str(obj.id))
-
+
def do_check(self, cr, uid, action, obj, context={}):
- ok = True
- if hasattr(obj, 'user_id'):
+ """ check Action
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values """
+
+ ok = True
+ if hasattr(obj, 'user_id'):
ok = ok and (not action.trg_user_id.id or action.trg_user_id.id==obj.user_id.id)
if hasattr(obj, 'partner_id'):
- ok = ok and (not action.trg_partner_id.id or action.trg_partner_id.id==obj.partner_id.id)
+ ok = ok and (not action.trg_partner_id.id or action.trg_partner_id.id==obj.partner_id.id)
ok = ok and (
not action.trg_partner_categ_id.id or
(
@@ -113,14 +138,22 @@ class base_action_rule(osv.osv):
return ok
def do_action(self, cr, uid, action, model_obj, obj, context={}):
+ """ Do Action
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param action: pass action
+ @param model_obj: pass Model object
+ @param context: A standard dictionary for contextual values """
+
if action.server_action_id:
context.update({'active_id':obj.id,'active_ids':[obj.id]})
self.pool.get('ir.actions.server').run(cr, uid, [action.server_action_id.id], context)
- write = {}
+ write = {}
if hasattr(obj, 'user_id') and action.act_user_id:
obj.user_id = action.act_user_id
write['user_id'] = action.act_user_id.id
- if hasattr(obj, 'date_action_last'):
+ if hasattr(obj, 'date_action_last'):
write['date_action_last'] = time.strftime('%Y-%m-%d %H:%M:%S')
if hasattr(obj, 'state') and action.act_state:
obj.state = action.act_state
@@ -135,7 +168,7 @@ class base_action_rule(osv.osv):
write['priority'] = action.act_priority
model_obj.write(cr, uid, [obj.id], write, context)
-
+
if hasattr(model_obj, 'remind_user') and action.act_remind_user:
model_obj.remind_user(cr, uid, [obj.id], context, attach=action.act_remind_attach)
if hasattr(model_obj, 'remind_partner') and action.act_remind_partner:
@@ -146,7 +179,7 @@ class base_action_rule(osv.osv):
if hasattr(obj, 'user_id') and action.act_mail_to_user:
if obj.user_id and obj.user_id.address_id:
emails.append(obj.user_id.address_id.email)
-
+
if action.act_mail_to_watchers:
emails += (action.act_email_cc or '').split(',')
if action.act_mail_to_email:
@@ -158,11 +191,19 @@ class base_action_rule(osv.osv):
return True
def _action(self, cr, uid, ids, objects, scrit=None, context={}):
+ """ Do Action
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Basic Action Rule’s IDs,
+ @param objects: pass objects
+ @param context: A standard dictionary for contextual values """
+
if not scrit:
scrit = []
rule_line_obj = self.pool.get('base.action.rule.line')
- for rule in self.browse(cr, uid, ids):
- level = rule.max_level
+ for rule in self.browse(cr, uid, ids):
+ level = rule.max_level
if not level:
break
newactions = []
@@ -184,7 +225,8 @@ class base_action_rule(osv.osv):
base = mx.DateTime.strptime(obj.date_action_last, '%Y-%m-%d %H:%M:%S')
else:
base = mx.DateTime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S')
- elif hasattr(obj, 'date_deadline') and action.trg_date_type=='deadline' and obj.date_deadline:
+ elif hasattr(obj, 'date_deadline') and action.trg_date_type=='deadline' \
+ and obj.date_deadline:
base = mx.DateTime.strptime(obj.date_deadline, '%Y-%m-%d %H:%M:%S')
elif hasattr(obj, 'date') and action.trg_date_type=='date' and obj.date:
base = mx.DateTime.strptime(obj.date, '%Y-%m-%d %H:%M:%S')
@@ -212,7 +254,7 @@ class base_action_rule(osv.osv):
if ok:
self.do_action(cr, uid, action, model_obj, obj, context)
- break
+ break
level -= 1
return True
base_action_rule()
@@ -222,20 +264,46 @@ class base_action_rule_line(osv.osv):
_description = 'Action Rule Lines'
def _state_get(self, cr, uid, context={}):
+ """ Get State
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values """
+
return self.state_get(cr, uid, context=context)
def _priority_get(self, cr, uid, context={}):
+ """ Get Priority
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values """
+
return self.priority_get(cr, uid, context=context)
def state_get(self, cr, uid, context={}):
+ """ Get State
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values """
+
return [('','')]
def priority_get(self, cr, uid, context={}):
+ """ Get Priority
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values """
+
return [('','')]
_columns = {
'name': fields.char('Rule Name',size=64, required=True),
'rule_id': fields.many2one('base.action.rule','Rule'),
- 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the rule without removing it."),
- 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of rules."),
+ 'active': fields.boolean('Active', help="If the active field is set to true,\
+ it will allow you to hide the rule without removing it."),
+ 'sequence': fields.integer('Sequence', help="Gives the sequence order when\
+ displaying a list of rules."),
'trg_date_type': fields.selection([
('none','None'),
@@ -243,11 +311,13 @@ class base_action_rule_line(osv.osv):
('action_last','Last Action Date'),
('date','Date'),
], 'Trigger Date', size=16),
- 'trg_date_range': fields.integer('Delay after trigger date',help="Delay After Trigger Date, specifies you can put a negative number " \
- "if you need a delay before the trigger date, like sending a reminder 15 minutes before a meeting."),
- 'trg_date_range_type': fields.selection([('minutes', 'Minutes'),('hour','Hours'),('day','Days'),('month','Months')], 'Delay type'),
+ 'trg_date_range': fields.integer('Delay after trigger date',help="Delay After Trigger Date,\
+ specifies you can put a negative number " \
+ "if you need a delay before the trigger date, like sending a reminder 15 minutes before a meeting."),
+ 'trg_date_range_type': fields.selection([('minutes', 'Minutes'),('hour','Hours'),\
+ ('day','Days'),('month','Months')], 'Delay type'),
+
-
'trg_user_id': fields.many2one('res.users', 'Responsible'),
'trg_partner_id': fields.many2one('res.partner', 'Partner'),
@@ -255,42 +325,59 @@ class base_action_rule_line(osv.osv):
'trg_state_from': fields.selection(_state_get, 'State', size=16),
'trg_state_to': fields.selection(_state_get, 'Button Pressed', size=16),
'trg_priority_from': fields.selection(_priority_get, 'Minimum Priority'),
- 'trg_priority_to': fields.selection(_priority_get, 'Maximum Priority'),
-
- 'act_method': fields.char('Call Object Method', size=64),
- 'act_user_id': fields.many2one('res.users', 'Set responsible to'),
+ 'trg_priority_to': fields.selection(_priority_get, 'Maximum Priority'),
+
+ 'act_method': fields.char('Call Object Method', size=64),
+ 'act_user_id': fields.many2one('res.users', 'Set responsible to'),
'act_state': fields.selection(_state_get, 'Set state to', size=16),
- 'act_priority': fields.selection(_priority_get, 'Set priority to'),
- 'act_email_cc': fields.char('Add watchers (Cc)', size=250, help="These people will receive a copy of the future communication between partner and users by email"),
+ 'act_priority': fields.selection(_priority_get, 'Set priority to'),
+ 'act_email_cc': fields.char('Add watchers (Cc)', size=250, help="These people\
+ will receive a copy of the future communication between partner and users by email"),
- 'act_remind_partner': fields.boolean('Remind Partner', help="Check this if you want the rule to send a reminder by email to the partner."),
- 'act_remind_user': fields.boolean('Remind responsible', help="Check this if you want the rule to send a reminder by email to the user."),
+ 'act_remind_partner': fields.boolean('Remind Partner', help="Check this if\
+ you want the rule to send a reminder by email to the partner."),
+ 'act_remind_user': fields.boolean('Remind responsible', help="Check this if \
+ you want the rule to send a reminder by email to the user."),
'act_reply_to': fields.char('Reply-To', size=64),
- 'act_remind_attach': fields.boolean('Remind with attachment', help="Check this if you want that all documents attached to the object be attached to the reminder email sent."),
+ 'act_remind_attach': fields.boolean('Remind with attachment', help="Check this if\
+ you want that all documents attached to the object be attached \
+ to the reminder email sent."),
- 'act_mail_to_user': fields.boolean('Mail to responsible',help="Check this if you want the rule to send an email to the responsible person."),
- 'act_mail_to_watchers': fields.boolean('Mail to watchers (CC)',help="Check this if you want the rule to mark CC(mail to any other person defined in actions)."),
- 'act_mail_to_email': fields.char('Mail to these emails', size=128,help="Email-id of the persons whom mail is to be sent"),
+ 'act_mail_to_user': fields.boolean('Mail to responsible',help="Check this if \
+ you want the rule to send an email to the responsible person."),
+ 'act_mail_to_watchers': fields.boolean('Mail to watchers (CC)',help="Check this\
+ if you want the rule to mark CC(mail to any other person\
+ defined in actions)."),
+ 'act_mail_to_email': fields.char('Mail to these emails', size=128,help="Email-id \
+ of the persons whom mail is to be sent"),
'act_mail_body': fields.text('Mail body',help="Content of mail"),
'regex_name': fields.char('Regular Expression on Model Name', size=128),
- 'server_action_id': fields.many2one('ir.actions.server','Server Action',help="Describes the action name." \
- "eg:on which object which action to be taken on basis of which condition"),
+ 'server_action_id': fields.many2one('ir.actions.server','Server Action',help="Describes the\
+ action name." \
+ "eg:on which object which action to be taken on basis of which condition"),
}
-
+
_defaults = {
'active': lambda *a: 1,
'trg_date_type': lambda *a: 'none',
'trg_date_range_type': lambda *a: 'day',
'act_mail_to_user': lambda *a: 0,
'act_remind_partner': lambda *a: 0,
- 'act_remind_user': lambda *a: 0,
+ 'act_remind_user': lambda *a: 0,
'act_mail_to_watchers': lambda *a: 0,
}
-
- _order = 'sequence'
-
-
+
+ _order = 'sequence'
+
+
def _check_mail(self, cr, uid, ids, context=None):
+ """ Check Mail
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Action Rule’s IDs
+ @param context: A standard dictionary for contextual values """
+
empty = orm.browse_null()
rule_obj = self.pool.get('base.action.rule')
for rule in self.browse(cr, uid, ids):
@@ -300,10 +387,11 @@ class base_action_rule_line(osv.osv):
except (ValueError, KeyError, TypeError):
return False
return True
-
+
_constraints = [
(_check_mail, 'Error: The mail is not well formated', ['act_mail_body']),
]
-
+
base_action_rule_line()
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/base_action_rule/base_action_rule_view.xml b/addons/base_action_rule/base_action_rule_view.xml
index 9892886c675..06837e2c2da 100644
--- a/addons/base_action_rule/base_action_rule_view.xml
+++ b/addons/base_action_rule/base_action_rule_view.xml
@@ -1,10 +1,11 @@
-
+
-
base.action.rule.form
@@ -21,6 +22,8 @@
+
+
base.action.rule.tree
base.action.rule
@@ -34,6 +37,8 @@
+
+
Action Rules
base.action.rule
@@ -42,10 +47,11 @@
-
+
-
base.action.rule.line.form
@@ -127,6 +133,9 @@
+
+
+
base.action.rule.line.tree
base.action.rule.line
diff --git a/addons/base_calendar/__init__.py b/addons/base_calendar/__init__.py
old mode 100644
new mode 100755
diff --git a/addons/base_calendar/__terp__.py b/addons/base_calendar/__terp__.py
old mode 100644
new mode 100755
index c0169db368b..e8b528db1a3
--- a/addons/base_calendar/__terp__.py
+++ b/addons/base_calendar/__terp__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,36 +15,33 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
-
{
- "name" : "Basic Calendar Functionality",
- "version" : "1.0",
- "depends" : [
- "base",
- ],
- 'description': """
- Full featured calendar system that support:
- - Alerts (create requests)
- - Recurring events (*)
- - Invitations to other people
-""",
- "author" : "Tiny",
- 'category': 'Generic Modules/Others',
- 'website': 'http://www.openerp.com',
+ "name" : "Basic Calendar Functionality",
+ "version" : "1.0",
+ "depends" : ["base"],
+ 'description': """Full featured calendar system that support:
+ - Alerts (create requests)
+ - Recurring events (*)
+ - Invitations to others people""",
+ "author" : "Tiny",
+ 'category': 'Generic Modules/Others',
+ 'website': 'http://www.openerp.com',
"init_xml" : [
- 'base_calendar_data.xml'
- ],
- "demo_xml" : [],
+ 'base_calendar_data.xml'
+ ],
+ "demo_xml" : [],
"update_xml" : [
- 'security/ir.model.access.csv',
- 'base_calendar_view.xml'
- ],
- "installable" : True,
- "active" : False,
+ 'security/ir.model.access.csv',
+ 'wizard/calendar_event_edit_all_view.xml',
+ 'wizard/base_calendar_invite_attendee_view.xml',
+ 'base_calendar_view.xml'
+ ],
+ "installable" : True,
+ "active" : False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py
index 3c99b7b5410..c639035ca0b 100644
--- a/addons/base_calendar/base_calendar.py
+++ b/addons/base_calendar/base_calendar.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,28 +15,31 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
+
from datetime import datetime, timedelta
from dateutil import parser
from dateutil import rrule
from osv import fields, osv
from service import web_services
from tools.translate import _
-import base64
-import pooler
import pytz
import re
import time
import tools
months = {
- 1:"January", 2:"February", 3:"March", 4:"April", \
- 5:"May", 6:"June", 7:"July", 8:"August", 9:"September", \
- 10:"October", 11:"November", 12:"December"}
+ 1: "January", 2: "February", 3: "March", 4: "April", \
+ 5: "May", 6: "June", 7: "July", 8: "August", 9: "September", \
+ 10: "October", 11: "November", 12: "December"}
def get_recurrent_dates(rrulestring, exdate, startdate=None):
+ """
+ Get recurrent dates
+ """
+
def todate(date):
val = parser.parse(''.join((re.compile('\d')).findall(date)))
return val
@@ -51,6 +54,11 @@ def get_recurrent_dates(rrulestring, exdate, startdate=None):
return re_dates
def base_calendar_id2real_id(base_calendar_id=None, with_date=False):
+ """
+ Convert base calendar id into real id.
+ @return: base calendar id
+ """
+
if base_calendar_id and isinstance(base_calendar_id, (str, unicode)):
res = base_calendar_id.split('-')
if len(res) >= 2:
@@ -65,6 +73,11 @@ def base_calendar_id2real_id(base_calendar_id=None, with_date=False):
return base_calendar_id and int(base_calendar_id) or base_calendar_id
def real_id2base_calendar_id(real_id, recurrent_date):
+ """
+ Convert real id into base_calendar_id.
+ @return: real id with recurrent date.
+ """
+
if real_id and recurrent_date:
recurrent_date = time.strftime("%Y%m%d%H%M%S", \
time.strptime(recurrent_date, "%Y-%m-%d %H:%M:%S"))
@@ -73,9 +86,17 @@ def real_id2base_calendar_id(real_id, recurrent_date):
def _links_get(self, cr, uid, context={}):
+ """
+ Get request link.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values
+ @return: list of dictionary which contain object and name and id.
+ """
+
obj = self.pool.get('res.request.link')
ids = obj.search(cr, uid, [])
- res = obj.read(cr, uid, ids, ['object', 'name'], context)
+ res = obj.read(cr, uid, ids, ['object', 'name'], context=context)
return [(r['object'], r['name']) for r in res]
html_invitation = """
@@ -184,101 +205,10 @@ html_invitation = """