use new API

This commit is contained in:
Giorgio Borelli
2014-11-11 13:25:05 +01:00
committed by Justine Doutreloux
parent 0f0dc88d03
commit fa5f889f5f
47 changed files with 296 additions and 6395 deletions

View File

@@ -18,46 +18,44 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp import models, fields, _
from openerp import exceptions
class showdiff(osv.osv_memory):
""" Disp[ay Difference for History """
class showdiff(models.TransientModel):
""" Display Difference for History """
_name = 'wizard.document.page.history.show_diff'
def get_diff(self, cr, uid, context=None):
if context is None:
context = {}
history = self.pool.get('document.page.history')
ids = context.get('active_ids', [])
def get_diff(self):
history = self.env["document.page.history"]
ids = self.env.context.get('active_ids', [])
diff = ""
if len(ids) == 2:
if ids[0] > ids[1]:
diff = history.getDiff(cr, uid, ids[1], ids[0])
diff = history.getDiff(ids[1], ids[0])
else:
diff = history.getDiff(cr, uid, ids[0], ids[1])
diff = history.getDiff(ids[0], ids[1])
elif len(ids) == 1:
old = history.browse(cr, uid, ids[0])
nids = history.search(cr, uid, [('page_id', '=', old.page_id.id)])
nids.sort()
diff = history.getDiff(cr, uid, ids[0], nids[-1])
old = history.browse(ids[0])
nids = history.search(
[('page_id', '=', old.page_id.id)],
order='id DESC',
limit=1
)
diff = history.getDiff(ids[0], nids.id)
else:
raise osv.except_osv(_('Warning!'), _('You need to select minimum \
one or maximum two history \
revisions!'))
raise exceptions.Warning(
_("You need to select minimum one or maximum "
"two history revisions!")
)
return diff
_columns = {
'diff': fields.text('Diff', readonly=True),
}
_defaults = {
'diff': get_diff
}
diff = fields.Text(
'Diff',
readonly=True,
default=get_diff
)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: