[ADD] moved view.save method from server
bzr revid: xmo@openerp.com-20130906130916-txj4mwhulb89kpov
This commit is contained in:
parent
76409db724
commit
81118812a8
|
@ -192,11 +192,6 @@
|
|||
this.$('#website-top-edit').show();
|
||||
$('.css_non_editable_mode_hidden').removeClass("css_non_editable_mode_hidden");
|
||||
|
||||
// this.$buttons.cancel.add(this.$buttons.snippet).prop('disabled', false)
|
||||
// .add(this.$buttons.save)
|
||||
// .parent().show();
|
||||
//
|
||||
// TODO: span edition changing edition state (save button)
|
||||
var $editables = $('[data-oe-model]')
|
||||
.not('link, script')
|
||||
// FIXME: propagation should make "meta" blocks non-editable in the first place...
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from lxml import etree
|
||||
from lxml import etree, html
|
||||
from openerp.osv import osv, fields
|
||||
|
||||
|
||||
|
@ -49,3 +49,20 @@ class view(osv.osv):
|
|||
if call_view not in stack_result:
|
||||
result += self._views_get(cr, uid, call_view, options=options, context=context, stack_result=result)
|
||||
return result
|
||||
|
||||
def save(self, cr, uid, model, res_id, field, value, xpath=None, context=None):
|
||||
""" Update the content of a field
|
||||
|
||||
:param str model:
|
||||
:param int res_id:
|
||||
:param str xpath: valid xpath to the tag to replace
|
||||
"""
|
||||
model_obj = self.pool.get(model)
|
||||
if xpath:
|
||||
origin = model_obj.read(cr, uid, [res_id], [field], context=context)[0][field]
|
||||
origin_tree = etree.fromstring(origin.encode('utf-8'))
|
||||
zone = origin_tree.xpath(xpath)[0]
|
||||
zone.getparent().replace(zone, html.fromstring(value))
|
||||
value = etree.tostring(origin_tree, encoding='utf-8')
|
||||
|
||||
model_obj.write(cr, uid, res_id, {field: value}, context=context)
|
||||
|
|
Loading…
Reference in New Issue