diff --git a/addons/auction/__terp__.py b/addons/auction/__terp__.py
index 61e91802f44..8918a6394aa 100644
--- a/addons/auction/__terp__.py
+++ b/addons/auction/__terp__.py
@@ -38,6 +38,8 @@
'init_xml': ['auction_sequence.xml'],
'update_xml': [
'security/ir.model.access.csv',
+# 'wizard/auction_lots_cancel_view.xml',
+# 'wizard/auction_transfer_unsold_object_view.xml',
'wizard/auction_lots_able_view.xml',
'wizard/auction_lots_enable_view.xml',
'wizard/auction_lots_make_invoice_buyer_view.xml',
diff --git a/addons/auction/auction.py b/addons/auction/auction.py
index 1687980c029..cf5f27775df 100644
--- a/addons/auction/auction.py
+++ b/addons/auction/auction.py
@@ -95,15 +95,17 @@ class auction_dates(osv.osv):
RETURN: True
"""
# objects vendus mais non factures
+ #TODO: convert this query to tiny API
+ lots_obj = self.pool.get('auction.lots')
cr.execute('select count(*) as c from auction_lots where auction_id =ANY(%s) and state=%s and obj_price>0', (ids,'draft',))
nbr = cr.fetchone()[0]
ach_uids = {}
cr.execute('select id from auction_lots where auction_id =ANY(%s) and state=%s and obj_price>0', (ids,'draft',))
- r=self.pool.get('auction.lots').lots_invoice(cr, uid, [x[0] for x in cr.fetchall()],{},None)
+ r = lots_obj.lots_invoice(cr, uid, [x[0] for x in cr.fetchall()],{},None)
cr.execute('select id from auction_lots where auction_id =ANY(%s) and obj_price>0',(ids,))
ids2 = [x[0] for x in cr.fetchall()]
# for auction in auction_ids:
- c=self.pool.get('auction.lots').seller_trans_create(cr, uid, ids2,{})
+ c = lots_obj.seller_trans_create(cr, uid, ids2,{})
self.write(cr, uid, ids, {'state':'closed'}) #close the auction
return True
auction_dates()
@@ -508,14 +510,14 @@ class auction_lots(osv.osv):
##CHECKME: est-ce que ca vaudrait la peine de faire des groupes de lots qui ont les memes couts pour passer des listes de lots a compute?
taxes = []
amount=0.0
- # pt_tax=pool.get('account.tax')
+ pt_tax = self.pool.get('account.tax')
for lot in lots:
taxes = lot.product_id.taxes_id
if lot.author_right:
taxes.append(lot.author_right)
elif lot.auction_id:
taxes += lot.auction_id.buyer_costs
- tax=self.pool.get('account.tax').compute(cr,uid,taxes,lot.obj_price,1)
+ tax=pt_tax.compute(cr,uid,taxes,lot.obj_price,1)
for t in tax:
amount+=t['amount']
#amount+=lot.obj_price*0.2
@@ -630,18 +632,20 @@ class auction_lots(osv.osv):
def buyer_proforma(self,cr,uid,ids,context):
invoices = {}
- inv_ref=self.pool.get('account.invoice')
+ inv_ref = self.pool.get('account.invoice')
+ partner_r = self.pool.get('res.partner')
+ inv_line_obj = self.pool.get('account.invoice.line')
+ wf_service = netsvc.LocalService('workflow')
# acc_receiv=self.pool.get('account.account').search([cr,uid,[('code','=','4010')]])
for lot in self.browse(cr,uid,ids,context):
if not lot.obj_price>0:
continue
- partner_r=self.pool.get('res.partner')
if not lot.ach_uid.id:
raise orm.except_orm(_('Missed buyer !'), _('The object "%s" has no buyer assigned.') % (lot.name,))
else:
partner_ref =lot.ach_uid.id
lot_name = lot.obj_num
- res = self.pool.get('res.partner').address_get(cr, uid, [partner_ref], ['contact', 'invoice'])
+ res = partner_r.address_get(cr, uid, [partner_ref], ['contact', 'invoice'])
contact_addr_id = res['contact']
invoice_addr_id = res['invoice']
if not invoice_addr_id:
@@ -675,12 +679,11 @@ class auction_lots(osv.osv):
'account_id': lot.auction_id.acc_income.id,
'price_unit': lot.obj_price,
}
- self.pool.get('account.invoice.line').create(cr, uid, inv_line,context)
+ inv_line_obj.create(cr, uid, inv_line,context)
# inv_ref.button_compute(cr, uid, [inv_id])
# wf_service = netsvc.LocalService('workflow')
# wf_service.trg_validate(uid, 'account.invoice', inv_id, 'invoice_open', cr)
inv_ref.button_compute(cr, uid, invoice.values())
- wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'account.invoice', inv_id, 'invoice_proforma', cr)
return invoices.values()
@@ -694,6 +697,9 @@ class auction_lots(osv.osv):
# use each list of object in turn
invoices = {}
inv_ref=self.pool.get('account.invoice')
+ partner_obj = self.pool.get('res.partner')
+ inv_line_obj = self.pool.get('account.invoice.line')
+ wf_service = netsvc.LocalService('workflow')
for lot in self.browse(cr,uid,ids,context):
partner_id = lot.bord_vnd_id.partner_id.id
if not lot.auction_id.id:
@@ -702,7 +708,7 @@ class auction_lots(osv.osv):
if lot.bord_vnd_id.id in invoices:
inv_id = invoices[lot.bord_vnd_id.id]
else:
- res = self.pool.get('res.partner').address_get(cr, uid, [lot.bord_vnd_id.partner_id.id], ['contact', 'invoice'])
+ res = partner_obj.address_get(cr, uid, [lot.bord_vnd_id.partner_id.id], ['contact', 'invoice'])
contact_addr_id = res['contact']
invoice_addr_id = res['invoice']
inv = {
@@ -734,13 +740,12 @@ class auction_lots(osv.osv):
'account_id': lot.auction_id.acc_expense.id,
'price_unit': lot.obj_price,
}
- self.pool.get('account.invoice.line').create(cr, uid, inv_line,context)
+ inv_line_obj.create(cr, uid, inv_line,context)
inv_ref.button_compute(cr, uid, invoices.values())
for inv in inv_ref.browse(cr, uid, invoices.values(), context):
inv_ref.write(cr, uid, [inv.id], {
'check_total': inv.amount_total
})
- wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_open', cr)
return invoices.values()
@@ -756,13 +761,15 @@ class auction_lots(osv.osv):
RETURN: id of generated invoice
"""
dt = time.strftime('%Y-%m-%d')
- inv_ref=self.pool.get('account.invoice')
+ inv_ref = self.pool.get('account.invoice')
+ partner_r = self.pool.get('res.partner')
+ inv_line_obj = self.pool.get('account.invoice.line')
+ wf_service = netsvc.LocalService('workflow')
invoices={}
for lot in self.browse(cr, uid, ids,context):
# partner_ref = lot.ach_uid.id
if not lot.auction_id.id:
continue
- partner_r=self.pool.get('res.partner')
if not lot.ach_uid.id:
raise orm.except_orm(_('Missed buyer !'), _('The object "%s" has no buyer assigned.') % (lot.name,))
if (lot.auction_id.id,lot.ach_uid.id) in invoices:
@@ -773,13 +780,12 @@ class auction_lots(osv.osv):
raise orm.except_orm(_('Missed Address !'), _('The Buyer has no Invoice Address.'))
price = lot.obj_price or 0.0
lot_name =lot.obj_num
- inv={
+ inv = {
'name':lot.auction_id.name or '',
'reference': lot.ach_login,
'journal_id': lot.auction_id.journal_id.id,
'partner_id': lot.ach_uid.id,
'type': 'out_invoice',
-
}
if invoice_number:
inv['number'] = invoice_number
@@ -804,12 +810,11 @@ class auction_lots(osv.osv):
'account_id': lot.auction_id.acc_income.id,
'price_unit': lot.obj_price,
}
- self.pool.get('account.invoice.line').create(cr, uid, inv_line,context)
+ inv_line_obj.create(cr, uid, inv_line,context)
# inv_ref.button_compute(cr, uid, [inpq tu dis cav_id])
# inv_ref.button_compute(cr, uid, [inv_id])
inv_ref.button_compute(cr, uid, [inv_id])
for l in inv_ref.browse(cr, uid, invoices.values(), context):
- wf_service = netsvc.LocalService('workflow')
# wf_service.trg_validate(uid, 'account.invoice',l.id, 'invoice_proforma', cr)
wf_service.trg_validate(uid, 'account.invoice',l.id, 'invoice_open', cr)
return invoices.values()
diff --git a/addons/auction/wizard/__init__.py b/addons/auction/wizard/__init__.py
index bcd2de8b301..957ab02b053 100644
--- a/addons/auction/wizard/__init__.py
+++ b/addons/auction/wizard/__init__.py
@@ -29,7 +29,8 @@ import auction_pay_buy
import auction_payer_sel
import auction_lots_sms_send
import auction_catalog_flagey_report
-
+#import auction_lots_cancel
+#import auction_transfer_unsold_object
#import auction_aie_send_result
import auction_lots_buyer_map
diff --git a/addons/auction/wizard/auction_catalog_flagey_report.py b/addons/auction/wizard/auction_catalog_flagey_report.py
index 119c3273ee0..d8fec4b6d95 100644
--- a/addons/auction/wizard/auction_catalog_flagey_report.py
+++ b/addons/auction/wizard/auction_catalog_flagey_report.py
@@ -40,9 +40,21 @@ class auction_catalog_flagey(osv.osv_memory):
return res
def view_init(self, cr, uid, fields, context):
- current_auction = self.pool.get('auction.dates').browse(cr,uid,context.get('active_ids', []))
- v_lots = self.pool.get('auction.lots').search(cr,uid,[('auction_id','=',current_auction.id)])
- v_ids = self.pool.get('auction.lots').browse(cr,uid,v_lots)
+ """
+ Creates view dynamically, adding fields at runtime, raises exception
+ at the time of initialization of view.
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param fields: List of fields for which we want default values
+ @param context: A standard dictionary
+ @return: New arch of view with new columns.
+ """
+ lots_obj = self.pool.get('auction.lots')
+ auc_dates_obj = self.pool.get('auction.dates')
+ current_auction = auc_dates_obj.browse(cr,uid,context.get('active_ids', []))
+ v_lots = lots_obj.search(cr,uid,[('auction_id','=',current_auction.id)])
+ v_ids = lots_obj.browse(cr,uid,v_lots)
for ab in v_ids:
if not ab.auction_id :
raise osv.except_osv('Error!','No Lots belong to this Auction Date')
diff --git a/addons/auction/wizard/auction_lots_auction_move.py b/addons/auction/wizard/auction_lots_auction_move.py
index 24b2604d1d7..d1303be0887 100644
--- a/addons/auction/wizard/auction_lots_auction_move.py
+++ b/addons/auction/wizard/auction_lots_auction_move.py
@@ -32,16 +32,16 @@ class auction_lots_auction_move(osv.osv_memory):
_name = "auction.lots.auction.move"
_description = "Auction move "
_columns= {
- 'auction_id':fields.many2one('auction.dates', 'Auction Date', required=True),
- }
+ 'auction_id':fields.many2one('auction.dates', 'Auction Date', required=True),
+ }
- def _top(self, cr, uid, ids, context={}):
- refs = self.pool.get('auction.lots')
- rec_ids = refs.browse(cr, uid, context['active_ids'])
- for rec in rec_ids:
- if not rec.auction_id:
- raise osv.except_osv('Error !', 'You can not move a lot that has no auction date')
- return {}
+# def _top(self, cr, uid, ids, context={}):
+# refs = self.pool.get('auction.lots')
+# rec_ids = refs.browse(cr, uid, context['active_ids'])
+# for rec in rec_ids:
+# if not rec.auction_id:
+# raise osv.except_osv('Error !', 'You can not move a lot that has no auction date')
+# return {}
def auction_move_set(self, cr, uid, ids, context={}):
"""
@@ -56,13 +56,13 @@ class auction_lots_auction_move(osv.osv_memory):
auction_bid_line_obj = self.pool.get('auction.bid_line')
auction_lot_history_obj = self.pool.get('auction.lot.history')
auction_lots_obj = self.pool.get('auction.lots')
+ rec_ids = refs.browse(cr, uid, context['active_ids'])
for datas in self.read(cr, uid, ids):
if not (datas['auction_id'] and len(context['active_ids'])) :
return {}
- rec_ids = refs.browse(cr, uid, context['active_ids'])
- line_ids = auction_bid_line_obj.search(cr, uid, [('lot_id', 'in', context['active_ids'])])
- # pooler.get_pool(cr.dbname).get('auction.bid_line').unlink(cr, uid, line_ids)
+# line_ids = auction_bid_line_obj.search(cr, uid, [('lot_id', 'in', context['active_ids'])])
+# pooler.get_pool(cr.dbname).get('auction.bid_line').unlink(cr, uid, line_ids)
for rec in rec_ids:
new_id = auction_lot_history_obj.create(cr, uid, {
'auction_id': rec.auction_id.id,
diff --git a/addons/auction/wizard/auction_lots_buyer_map.py b/addons/auction/wizard/auction_lots_buyer_map.py
index db80a2ab3f3..b20250edc38 100644
--- a/addons/auction/wizard/auction_lots_buyer_map.py
+++ b/addons/auction/wizard/auction_lots_buyer_map.py
@@ -107,18 +107,21 @@ class wiz_auc_lots_buyer_map(osv.osv_memory):
res = super(wiz_auc_lots_buyer_map, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
lots_obj = self.pool.get('auction.lots')
if record_ids:
- for lots in lots_obj.browse(cr, uid, record_ids):
- if lots.ach_uid:
- res['arch'] = """
-
- """
+ try:
+ for lots in lots_obj.browse(cr, uid, record_ids):
+ if lots.ach_uid:
+ res['arch'] = """
+
+ """
+ except:
+ return res
return res
wiz_auc_lots_buyer_map()
diff --git a/addons/auction/wizard/auction_lots_cancel.py b/addons/auction/wizard/auction_lots_cancel.py
new file mode 100644
index 00000000000..edf530ac8aa
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_cancel.py
@@ -0,0 +1,55 @@
+# -*- 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 osv
+from osv import fields
+
+class auction_lots_cancel(osv.osv):
+ '''
+ Open ERP Model
+ '''
+ _name = 'auction.lots.cancel'
+ _description = 'To cancel auction lots.'
+
+ def cancel(self, cr, uid, ids, context):
+ """
+ To cancel the auction lot
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+ @return:
+ """
+
+ lots_obj = self.pool.get('auction.lots')
+ invoice_obj = self.pool.get('account.invoice')
+ lot = lots_obj.browse(cr,uid,context['active_id'],context)
+ if lot.ach_inv_id:
+ supplier_refund_inv_id = invoice_obj.refund(cr, uid,[lot.ach_inv_id.id])
+ if lot.sel_inv_id:
+ customer_refund_inv_id = invoice_obj.refund(cr, uid,[lot.sel_inv_id.id])
+ return {}
+
+ _columns = {
+ }
+auction_lots_cancel()
\ No newline at end of file
diff --git a/addons/auction/wizard/auction_lots_cancel_view.xml b/addons/auction/wizard/auction_lots_cancel_view.xml
new file mode 100644
index 00000000000..77ff6a373b7
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_cancel_view.xml
@@ -0,0 +1,27 @@
+
+
+
+
+ auction.lots.cancel.form
+ auction.lots.cancel
+ form
+
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/auction_lots_enable.py b/addons/auction/wizard/auction_lots_enable.py
index e8aa5edadf5..65cb0c4d49e 100644
--- a/addons/auction/wizard/auction_lots_enable.py
+++ b/addons/auction/wizard/auction_lots_enable.py
@@ -19,20 +19,14 @@
#
##############################################################################
from osv import fields, osv
-from tools.translate import _
-import netsvc
-import pooler
-import time
-import tools
-import wizard
class auction_lots_enable(osv.osv_memory):
-
_name = "auction.lots.enable"
_description = "Lots Enable"
+
_columns= {
- 'confirm_en':fields.integer('Catalog Number')
- }
+ 'confirm_en':fields.integer('Catalog Number')
+ }
def confirm_enable(self, cr, uid, ids, context={}):
"""
diff --git a/addons/auction/wizard/auction_lots_make_invoice.py b/addons/auction/wizard/auction_lots_make_invoice.py
index 6be49f7336a..8cda461e186 100644
--- a/addons/auction/wizard/auction_lots_make_invoice.py
+++ b/addons/auction/wizard/auction_lots_make_invoice.py
@@ -27,20 +27,29 @@ import tools
import wizard
class auction_lots_make_invoice(osv.osv_memory):
+ _name = "auction.lots.make.invoice"
+ _description = "Make invoice"
+ _columns = {
+ 'amount': fields.float('Invoiced Amount', required =True, readonly=True),
+ 'objects':fields.integer('# of objects', required =True, readonly=True),
+ 'number':fields.char('Invoice Number', size=64),
+
+ }
+
+ _defaults = {
+ 'number': lambda *a: False,
+ }
def default_get(self, cr, uid, fields, context):
"""
- To get default values for the object.
-
- @param self: The object pointer.
- @param cr: A database cursor
- @param uid: ID of the user currently logged in
- @param fields: List of fields for which we want default values
- @param context: A standard dictionary
-
- @return: A dictionary which of fields with values.
-
+ To get default values for the object.
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param fields: List of fields for which we want default values
+ @param context: A standard dictionary
+ @return: A dictionary which of fields with values.
"""
res = super(auction_lots_make_invoice, self).default_get(cr, uid, fields, context=context)
for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])):
@@ -53,7 +62,7 @@ class auction_lots_make_invoice(osv.osv_memory):
def makeInvoices(self, cr, uid, ids, context):
"""
- seller invoice :Create an invoice.
+ Seller invoice :Create an invoice.
@param cr: the current row, from the database cursor.
@param uid: the current user’s ID for security checks.
@param ids: List of Auction lots make invoice’s IDs
@@ -61,36 +70,20 @@ class auction_lots_make_invoice(osv.osv_memory):
"""
order_obj = self.pool.get('auction.lots')
mod_obj = self.pool.get('ir.model.data')
-
- for data in self.read(cr, uid, ids):
- result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
- id = mod_obj.read(cr, uid, result, ['res_id'])
- newinv = []
- ids = order_obj.seller_trans_create(cr, uid, context['active_ids'], context)
- cr.commit()
- return {
- 'domain': "[('id','in', ["+','.join(map(str, ids))+"])]",
- 'name': 'Seller invoices',
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'res_model': 'account.invoice',
- 'view_id': False,
- 'context': "{'type':'out_refund'}",
- 'type': 'ir.actions.act_window',
- 'search_view_id': id['res_id']
- }
+ result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
+ id = mod_obj.read(cr, uid, result, ['res_id'])
+ lots_ids = order_obj.seller_trans_create(cr, uid, context['active_ids'], context)
+ cr.commit()
+ return {
+ 'domain': "[('id','in', ["+','.join(map(str, lots_ids))+"])]",
+ 'name': 'Seller invoices',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.invoice',
+ 'view_id': False,
+ 'context': "{'type':'out_refund'}",
+ 'type': 'ir.actions.act_window',
+ 'search_view_id': id['res_id']
+ }
- _name = "auction.lots.make.invoice"
- _description = "Make invoice"
- _columns= {
- 'amount': fields.float('Invoiced Amount', required =True, readonly=True),
- 'objects':fields.integer('# of objects', required =True, readonly=True),
- 'number':fields.char('Invoice Number', size=64),
-
- }
- _defaults={
- 'number':lambda *a: False,
-
- }
-
auction_lots_make_invoice()
diff --git a/addons/auction/wizard/auction_lots_make_invoice_buyer.py b/addons/auction/wizard/auction_lots_make_invoice_buyer.py
index 53c3519d225..5d2e370a81e 100644
--- a/addons/auction/wizard/auction_lots_make_invoice_buyer.py
+++ b/addons/auction/wizard/auction_lots_make_invoice_buyer.py
@@ -19,27 +19,31 @@
#
##############################################################################
from osv import fields, osv
-from tools.translate import _
-import netsvc
-import pooler
-import time
-import tools
-import wizard
class auction_lots_make_invoice_buyer(osv.osv_memory):
+ _name = "auction.lots.make.invoice.buyer"
+ _description = "Make invoice buyer "
+
+ _columns= {
+ 'amount': fields.float('Invoiced Amount', required =True, readonly=True),
+ 'objects':fields.integer('# of objects', required =True, readonly=True),
+ 'number':fields.char('Invoice Number', size=64),
+ 'buyer_id':fields.many2one('res.partner', 'Buyer', required=True),
+ }
+
+ _defaults={
+ 'number': lambda *a: False,
+ }
def default_get(self, cr, uid, fields, context):
"""
- To get default values for the object.
-
- @param self: The object pointer.
- @param cr: A database cursor
- @param uid: ID of the user currently logged in
- @param fields: List of fields for which we want default values
- @param context: A standard dictionary
-
- @return: A dictionary which of fields with values.
-
+ To get default values for the object.
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param fields: List of fields for which we want default values
+ @param context: A standard dictionary
+ @return: A dictionary which of fields with values.
"""
res = super(auction_lots_make_invoice_buyer, self).default_get(cr, uid, fields, context=context)
for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])):
@@ -59,22 +63,19 @@ class auction_lots_make_invoice_buyer(osv.osv_memory):
@param ids: List of Auction lots make invoice buyer’s IDs
@return: dictionary of account invoice form.
"""
- newinv = []
-
order_obj = self.pool.get('auction.lots')
mod_obj = self.pool.get('ir.model.data')
-
+ result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
+ id = mod_obj.read(cr, uid, result, ['res_id'])
+ lots = order_obj.browse(cr, uid, context['active_ids'])
for data in self.read(cr, uid, ids):
- result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
- id = mod_obj.read(cr, uid, result, ['res_id'])
- lots = order_obj.browse(cr, uid, context['active_ids'])
invoice_number = data['number']
for lot in lots:
- up_auction = order_obj.write(cr, uid, [lot.id], {'ach_uid':data['buyer_id']})
- ids = order_obj.lots_invoice(cr, uid, context['active_ids'], context, data['number'])
+ up_auction = order_obj.write(cr, uid, [lot.id], {'ach_uid': data['buyer_id']})
+ lots_ids = order_obj.lots_invoice(cr, uid, context['active_ids'], context, data['number'])
cr.commit()
return {
- 'domain': "[('id','in', ["+','.join(map(str, ids))+"])]",
+ 'domain': "[('id','in', ["+','.join(map(str, lots_ids))+"])]",
'name': 'Buyer invoices',
'view_type': 'form',
'view_mode': 'tree,form',
@@ -84,17 +85,5 @@ class auction_lots_make_invoice_buyer(osv.osv_memory):
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
-
- _name = "auction.lots.make.invoice.buyer"
- _description = "Make invoice buyer "
- _columns= {
- 'amount': fields.float('Invoiced Amount', required =True, readonly=True),
- 'objects':fields.integer('# of objects', required =True, readonly=True),
- 'number':fields.char('Invoice Number', size=64),
- 'buyer_id':fields.many2one('res.partner', 'Buyer', required=True),
- }
- _defaults={
- 'number':lambda *a: False,
- }
auction_lots_make_invoice_buyer()
diff --git a/addons/auction/wizard/auction_pay_buy.py b/addons/auction/wizard/auction_pay_buy.py
index 8f16ea9e7de..28028f45538 100644
--- a/addons/auction/wizard/auction_pay_buy.py
+++ b/addons/auction/wizard/auction_pay_buy.py
@@ -21,26 +21,33 @@
from osv import fields, osv
from tools.translate import _
-import netsvc
-import pooler
import time
import tools
-import wizard
class auction_pay_buy(osv.osv_memory):
+ _name = "auction.pay.buy"
+ _description = "Pay buy"
+
+ _columns= {
+ 'amount': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy']))),
+ 'buyer_id':fields.many2one('res.partner', 'Buyer'),
+ 'statement_id1':fields.many2one('account.bank.statement', 'Statement', required=True),
+ 'amount2': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy']))),
+ 'statement_id2':fields.many2one('account.bank.statement', 'Statement'),
+ 'amount3': fields.float('Amount paid', digits = (16, int(tools.config['price_accuracy']))),
+ 'statement_id3':fields.many2one('account.bank.statement', 'Statement'),
+ 'total': fields.float('Amount paid', digits = (16, int(tools.config['price_accuracy'])), readonly =True),
+ }
def default_get(self, cr, uid, fields, context):
"""
- To get default values for the object.
-
- @param self: The object pointer.
- @param cr: A database cursor
- @param uid: ID of the user currently logged in
- @param fields: List of fields for which we want default values
- @param context: A standard dictionary
-
- @return: A dictionary which of fields with values.
-
+ To get default values for the object.
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param fields: List of fields for which we want default values
+ @param context: A standard dictionary
+ @return: A dictionary which of fields with values.
"""
res = super(auction_pay_buy, self).default_get(cr, uid, fields, context=context)
for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])):
@@ -54,13 +61,12 @@ class auction_pay_buy(osv.osv_memory):
def pay_and_reconcile(self, cr, uid, ids, context):
"""
- Pay and Reconcile
-
- @param cr: the current row, from the database cursor.
- @param uid: the current user’s ID for security checks.
- @param ids: the ID or list of IDs
- @param context: A standard dictionary
- @return:
+ Pay and Reconcile
+ @param cr: the current row, from the database cursor.
+ @param uid: the current user’s ID for security checks.
+ @param ids: the ID or list of IDs
+ @param context: A standard dictionary
+ @return:
"""
lot_obj = self.pool.get('auction.lots')
bank_statement_line_obj = self.pool.get('account.bank.statement.line')
@@ -94,22 +100,8 @@ class auction_pay_buy(osv.osv_memory):
for lot in lots:
lot_obj.write(cr, uid, [lot.id], {'statement_id':[(4, new_id)]})
return {}
-
- _name = "auction.pay.buy"
- _description = "Pay buy"
- _columns= {
- 'amount': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy']))),
- 'buyer_id':fields.many2one('res.partner', 'Buyer'),
- 'statement_id1':fields.many2one('account.bank.statement', 'Statement', required=True),
- 'amount2': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy']))),
- 'statement_id2':fields.many2one('account.bank.statement', 'Statement'),
- 'amount3': fields.float('Amount paid', digits = (16, int(tools.config['price_accuracy']))),
- 'statement_id3':fields.many2one('account.bank.statement', 'Statement'),
- 'total': fields.float('Amount paid', digits = (16, int(tools.config['price_accuracy'])), readonly =True),
- }
+
auction_pay_buy()
-
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/auction/wizard/auction_pay_sel.py b/addons/auction/wizard/auction_pay_sel.py
index df7b4a794f3..6873092c7e9 100644
--- a/addons/auction/wizard/auction_pay_sel.py
+++ b/addons/auction/wizard/auction_pay_sel.py
@@ -20,33 +20,27 @@
##############################################################################
from osv import fields, osv
from tools.translate import _
-import netsvc
-import pooler
-import time
import tools
-import wizard
class auction_pay_sel(osv.osv_memory):
-
_name = "auction.pay.sel"
_description = "Pay Invoice"
+
_columns= {
- 'amount': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy'])), required=True),
- 'dest_account_id':fields.many2one('account.account', 'Payment to Account', required=True, domain= [('type', '=', 'cash')]),
- 'journal_id':fields.many2one('account.journal', 'Journal', required=True),
- 'period_id':fields.many2one('account.period', 'Period', required=True),
- }
+ 'amount': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy'])), required=True),
+ 'dest_account_id':fields.many2one('account.account', 'Payment to Account', required=True, domain= [('type', '=', 'cash')]),
+ 'journal_id':fields.many2one('account.journal', 'Journal', required=True),
+ 'period_id':fields.many2one('account.period', 'Period', required=True),
+ }
def pay_and_reconcile(self, cr, uid, ids, context):
-
"""
- Pay and Reconcile
-
- @param cr: the current row, from the database cursor.
- @param uid: the current user’s ID for security checks.
- @param ids: the ID or list of IDs
- @param context: A standard dictionary
- @return:
+ Pay and Reconcile
+ @param cr: the current row, from the database cursor.
+ @param uid: the current user’s ID for security checks.
+ @param ids: the ID or list of IDs
+ @param context: A standard dictionary
+ @return:
"""
lot = self.pool.get('auction.lots').browse(cr, uid, context['active_id'], context)
invoice_obj = self.pool.get('account.invoice')
diff --git a/addons/auction/wizard/auction_payer_sel.py b/addons/auction/wizard/auction_payer_sel.py
index 349f10d4dec..c422ee91857 100644
--- a/addons/auction/wizard/auction_payer_sel.py
+++ b/addons/auction/wizard/auction_payer_sel.py
@@ -20,15 +20,8 @@
##############################################################################
from osv import fields, osv
-from tools.translate import _
-import netsvc
-import pooler
-import time
-import tools
-import wizard
class auction_payer(osv.osv_memory):
-
_name = "auction.payer"
_description = "Auction payer"
diff --git a/addons/auction/wizard/auction_taken.py b/addons/auction/wizard/auction_taken.py
index 63c3db7583c..005fd042646 100644
--- a/addons/auction/wizard/auction_taken.py
+++ b/addons/auction/wizard/auction_taken.py
@@ -32,10 +32,10 @@ class auction_taken(osv.osv_memory):
"""
_name = "auction.taken"
_description = "Auction taken"
+
_columns = {
- 'lot_ids':fields.many2many('auction.lots', 'auction_taken_rel', 'taken_id', 'lot_id', 'Lots Emportes'),
-
- }
+ 'lot_ids':fields.many2many('auction.lots', 'auction_taken_rel', 'taken_id', 'lot_id', 'Lots Emportes'),
+ }
def _to_xml(s):
return s.replace('&','&').replace('<','<').replace('>','>')
diff --git a/addons/auction/wizard/auction_transfer_unsold_object.py b/addons/auction/wizard/auction_transfer_unsold_object.py
new file mode 100644
index 00000000000..47aadc25d59
--- /dev/null
+++ b/addons/auction/wizard/auction_transfer_unsold_object.py
@@ -0,0 +1,86 @@
+# -*- 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 osv
+from osv import fields
+
+class auction_transfer_unsold_object(osv.osv):
+ '''
+ Open ERP Model
+ '''
+ _name = 'auction.transfer.unsold.object'
+ _description = 'To transfer unsold objects'
+
+ _columns = {
+ 'auction_id_from':fields.many2one('auction.dates', 'From Auction Date', required=True),
+ 'auction_id_to':fields.many2one('auction.dates', 'To Auction Date', required=True),
+ }
+
+ _defaults = {
+ 'auction_id_from': _start,
+ }
+
+ def _start(self, cr, uid, context):
+ """
+ To initialize auction_id_from
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+ @return: auction_id_from
+ """
+ lots_obj = self.pool.get('auction.lots')
+ rec = lots_obj.browse(cr, uid, context['active_id'], context)
+ auction_from = rec and rec.auction_id.id or False
+ return auction_from
+
+ def transfer_unsold_object(self, cr, uid, ids, context):
+ """
+ To Transfer the unsold object
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+ @return:
+ """
+ bid_line_obj = self.pool.get('auction.bid_line')
+ lots_obj = self.pool.get('auction.lots')
+ lot_history_obj = self.pool.get('auction.lot.history')
+ line_ids= bid_line_obj.search(cr,uid,[('lot_id','in',context['active_ids'])])
+ bid_line_obj.unlink(cr, uid, line_ids)
+
+ res = self.browse(cr, uid, ids)
+ unsold_ids = lots_obj.search(cr,uid,[('auction_id','=',res[0].auction_id_from.id),('state','=','unsold')])
+ for rec in lots_obj.browse(cr, uid, unsold_ids, context):
+ new_id = lot_history_obj.create(cr,uid,{'auction_id':rec.auction_id.id,'lot_id':rec.id,'price': rec.obj_ret, 'name': rec.auction_id.auction1})
+ up_auction = lots_obj.write(cr,uid,[rec.id],{'auction_id': res[0].auction_id_to.id,
+ 'obj_ret':None,
+ 'obj_price':None,
+ 'ach_login':None,
+ 'ach_uid':None,
+ 'ach_inv_id':None,
+ 'sel_inv_id':None,
+ 'state':'draft'})
+ return {}
+
+auction_transfer_unsold_object()
\ No newline at end of file
diff --git a/addons/auction/wizard/auction_transfer_unsold_object_view.xml b/addons/auction/wizard/auction_transfer_unsold_object_view.xml
new file mode 100644
index 00000000000..768043b3bed
--- /dev/null
+++ b/addons/auction/wizard/auction_transfer_unsold_object_view.xml
@@ -0,0 +1,26 @@
+
+
+
+
+ auction.transfer.unsold.object.form
+ auction.transfer.unsold.object
+ form
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/wizard_lots_cancel.py b/addons/auction/wizard/wizard_lots_cancel.py
deleted file mode 100644
index 1d7f93b14d3..00000000000
--- a/addons/auction/wizard/wizard_lots_cancel.py
+++ /dev/null
@@ -1,91 +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 netsvc
-import pooler
-
-paid_form = '''
-'''
-fields_ask = {
-}
-#
-#def _get_value(self,cr,uid, datas,context={}):
-## service = netsvc.LocalService("object_proxy")
-# lots=pool.get('auction.lots').browse(cr,uid,data['id'],context)
-#
-#
-## lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', datas['ids'])
-#
-# ids = []
-# pay_ids = {}
-# price = 0.0
-# price_paid = 0.0
-# uid = False
-#
-##TODO: refuse if several payments?
-# for lot in lots:
-# price += lot['obj_price']
-#
-# # add all the buyer costs
-# costs = service.execute(cr.dbname,uid, 'auction.lots', 'compute_buyer_costs', [lot['id']])
-# for cost in costs:
-# price += cost['amount']
-#
-##TODO: pr bien faire, faudrait leur poser la question: continue anyway?
-# if len(ids)).
-#
-# 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 wizard
-import netsvc
-import pooler
-from osv.orm import browse_record
-import sql_db
-
-transfer_unsold_object_form = """
-
-"""
-
-transfer_unsold_object_fields = {
- 'auction_id_from': {'string':'From Auction Date', 'type':'many2one', 'required':True, 'relation':'auction.dates'},
- 'auction_id_to': {'string':'To Auction Date', 'type':'many2one', 'required':True, 'relation':'auction.dates'},
-}
-
-def _start(self,cr,uid,data,context):
- pool = pooler.get_pool(cr.dbname)
- rec=pool.get('auction.lots').browse(cr,uid,data['id'],context)
- auction_from= rec and rec.auction_id.id or False
- return {'auction_id_from':auction_from}
-
-def _transfer_unsold_object(self, cr, uid, data, context):
- #if not (data['form']['auction_id_to']) :
- # return {}
-#Historique de l objet + changement de l auction date + supp des bid line
- line_ids= pooler.get_pool(cr.dbname).get('auction.bid_line').search(cr,uid,[('lot_id','in',data['ids'])])
- pooler.get_pool(cr.dbname).get('auction.bid_line').unlink(cr, uid, line_ids)
-
- obj_pool = pooler.get_pool(cr.dbname).get('auction.lots')
- ids= obj_pool.search(cr,uid,[('auction_id','=',data['form']['auction_id_from']),('state','=','unsold')])
- for rec in obj_pool.browse(cr, uid, ids, context):
- new_id=pooler.get_pool(cr.dbname).get('auction.lot.history').create(cr,uid,{'auction_id':rec.auction_id.id,'lot_id':rec.id,'price': rec.obj_ret, 'name': 'reasons'+rec.auction_id.auction1})
- up_auction=pooler.get_pool(cr.dbname).get('auction.lots').write(cr,uid,[rec.id],{'auction_id':data['form']['auction_id_to'],
- 'obj_ret':None,
- 'obj_price':None,
- 'ach_login':None,
- 'ach_uid':None,
- 'ach_inv_id':None,
- 'sel_inv_id':None,
- 'state':'draft'})
-
- # new_id = self.pool.get('auction.lot.history').copy(cr, uid, m.id, {'price': recs.obj_ret, 'name': 'reasons'+recs.auction_id.name})
- # new_id=pooler.get_pool(cr.dbname).get('auction.lot.history').create(cr,uid,{'auction_id':rec.auction_id,'lot_id':rec.name,'price': rec.obj_ret, 'name': 'reasons'+rec.auction_id.auction1})
- return {}
-
-class transfer_object(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [_start],
- 'result' : {'type' : 'form',
- 'arch' : transfer_unsold_object_form,
- 'fields' :transfer_unsold_object_fields,
- 'state' : [('transfer', 'Transfer'),('end', 'Cancel') ]}
- },
- 'transfer' : {
- 'actions' : [_transfer_unsold_object],
- 'result' : {'type' : 'state','state' : 'end'}
- },
- }
-transfer_object('auction.lots.transfer.unsold.object')
-# 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.formaudittrail.rule
@@ -17,12 +20,15 @@
-
-
+
+
+
audittrail.rule.treeaudittrail.rule
@@ -40,6 +46,9 @@
+
+
+
Rulesaudittrail.rule
@@ -48,8 +57,11 @@
tree,form
-
-
+
+
+
@@ -60,6 +72,8 @@
[('state','=','subscribed')]
+
+
audittrail.log.form
@@ -73,23 +87,34 @@
-
+
@@ -117,15 +142,19 @@
+
+
Logsaudittrail.logform
-
+
-
-
+
+
-
+
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.treebase.action.rule
@@ -34,6 +37,8 @@
+
+
Action Rulesbase.action.rule
@@ -42,10 +47,11 @@
-
+
-
base.action.rule.line.form
@@ -127,6 +133,9 @@
+
+
+
base.action.rule.line.treebase.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..f7608219b9d 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,31 +15,39 @@
# 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 based on Rule string considering exdate and start date
+ @param rrulestring: Rulestring
+ @param exdate: List of exception dates for rrule
+ @param startdate: Startdate for computing recurrent dates
+ @return: List of Recurrent dates
+ """
+
def todate(date):
val = parser.parse(''.join((re.compile('\d')).findall(date)))
return val
+
if not startdate:
startdate = datetime.now()
rset1 = rrule.rrulestr(rrulestring, dtstart=startdate, forceset=True)
@@ -51,8 +59,15 @@ def get_recurrent_dates(rrulestring, exdate, startdate=None):
return re_dates
def base_calendar_id2real_id(base_calendar_id=None, with_date=False):
+ """
+ This function converts virtual event id into real id of actual event
+ @param base_calendar_id: Id of calendar
+ @param with_date: If value passed to this param it will return dates based on value of withdate + base_calendar_id
+ """
+
if base_calendar_id and isinstance(base_calendar_id, (str, unicode)):
res = base_calendar_id.split('-')
+
if len(res) >= 2:
real_id = res[0]
if with_date:
@@ -62,9 +77,17 @@ def base_calendar_id2real_id(base_calendar_id=None, with_date=False):
end = start + timedelta(hours=with_date)
return (int(real_id), real_date, end.strftime("%Y-%m-%d %H:%M:%S"))
return int(real_id)
+
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 of record into virtual id using recurrent_date
+ e.g. real id is 1 and recurrent_date is 01-12-2009 10:00:00 then it will return
+ 1-20091201100000
+ @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 +96,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 +215,10 @@ html_invitation = """