AttributeError:' str'对象没有属性' get' - Odoo

时间:2016-05-31 20:47:10

标签: python openerp qweb

我在Odoo v8中有这个控制器,它为网站中的模型创建了一个URL:

@route('/contrato/editar/', type='http', auth='public',website=True)
def edit(self, **post_data):
    form = CuidumForm(request.httprequest.form)
    post = 'account.periodical_invoicing.agreement.id'
    if request.httprequest.method == 'POST' and form.validate():
        obj = request.env['account.periodical_invoicing.agreement'].browse( post.get(id))
        obj.write(post([
            (field_name, field.data)
            for field_name, field in form._fields.iteritems()
        ]))
        return request.render(
            'website_create_partner.success',
            {'name': form.name.data})
    return request.render(
        'website_create_partner.contrato_editar',
        {'form': form})

这是xml视图:

<template id="contrato_editar" name="Edicion">
<t t-call="website.layout">
    <div class="row">
        <div class="col-md-6 col-md-offset-2">
            <form role="form" action="/contrato/editar" method="POST">
                <t t-foreach="form" t-as="field">
                    <t t-call="website_create_partner.field_render_cuidum" />
                </t>
                <button type="submit" class="btn btn-primary mt8">Guardar</button>
            </form>
        </div>
    </div>
</t>
</template>

当我通过此按钮操作访问此网址时:

    def action_test_contrato(self, cr, uid, ids, context=None):
    ''' Open the website page'''
    context = dict(context)
    return {
        'type': 'ir.actions.act_url',
        'name': "Resultados",
        'target': 'self',
        #'url': self.read(cr, uid, ids, ['public_url'], context=context)[0]['public_url'] + "/phantom"
        'context': context,
        'url': "/contrato/editar/"
    }

它引发了我的追溯:

Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 8.0-20160507\server\openerp\addons\website\models\ir_http.py", line 199, in _handle_exception
File "C:\Program Files (x86)\Odoo 8.0-20160507\server\openerp\addons\base\ir\ir_http.py", line 145, in _handle_exception
File "C:\Program Files (x86)\Odoo 8.0-20160507\server\.\openerp\http.py", line 668, in _handle_exception
File "C:\Program Files (x86)\Odoo 8.0-20160507\server\openerp\addons\base\ir\ir_http.py", line 171, in _dispatch
File "C:\Program Files (x86)\Odoo 8.0-20160507\server\.\openerp\http.py", line 686, in dispatch
File "C:\Program Files (x86)\Odoo 8.0-20160507\server\.\openerp\http.py", line 312, in _call_function
File "C:\Program Files (x86)\Odoo 8.0-20160507\server\.\openerp\service\model.py", line 118, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20160507\server\.\openerp\http.py", line 309, in checked_call
File "C:\Program Files (x86)\Odoo 8.0-20160507\server\.\openerp\http.py", line 805, in __call__
File "C:\Program Files (x86)\Odoo 8.0-20160507\server\.\openerp\http.py", line 405, in response_wrap
File "C:\Program Files (x86)\Odoo 8.0-20160507\server\openerp\addons\website_create_partner\controller\partners.py", line 48, in edit
 AttributeError: 'str' object has no attribute 'get'

我尝试在模型上进行更新,但确实令人困惑

有人对此有所了解吗?

我们的目的是转到account.periodical_invoicing.agreement的表单视图,从action_test_contrato启动网络表单,编辑或填充模型中的字段,然后保存。

我真的坚持这个。

拜托,有人知道如何解决这个问题吗?

提前致谢!

0 个答案:

没有答案