Usando odoo v.8 ho vorrei porter
compilare parte di un abbonamento dall'interfaccia web generica (le pagine internet "normali", non la user interface che si ha con le view xml).
Seguendo il tutorial
www.odoo.com/documentation/8.0/howtos/website.html, ho creato un modulo che
in __openerp__.py importa il template dei campi da inserire:
'depends': ['base',
'analytic',
#'sale',
'website',
],
# always loaded
'data': [
# 'security/ir.model.access.csv',
'templates.xml',
'views/view.xml',
],
Qui il dettaglio del template (template.xml)
<openerp>
<data>
<template id="contract_by_id">
<t t-call="website.layout">
<t t-set="title"> Contract by id </t>
<div class="oe_structure"/>
<div class="oe_structure">
<div class="container">
<h1>Contract informations</h1>
<span> <t t-esc="id.name"/></span>
<br/>
<span> Client: <t t-esc="id.partner_id.name"/></span>
<br/>
<span> Creation: <t t-esc="id.create_date"/></span>
<div>
<span> Accessibility (check): <span t-field="id.access_boolean"/></span>
<br/>
<span> Accessibility (text): </span>
<div t-field="id.access_description"/>
<br/>
<span> Accessibility (number): <span t-field="id.access_evaluation"/></span>
</div>
</div>
</div>
<div class="oe_structure"/>
</t>
</template>
e lo gestisce con questo controller.py
# -*- coding: utf-8 -*-
from openerp import http
class ContractFormInfo(http.Controller):
@http.route('/contract/information/', auth='public')
def index(self, **kw):
# works
return "As installer you can add the contract information here."
@http.route('/contract/<model("account.analytic.account"):id>/', auth='public', website=True)
def for_number(self, id):
# it seams that select the right one (not necessary to convert id from str to int)
# for istance
# http://localhost:8069/contract/42/ renders
# http://localhost:8069/contract/for-a-new-consultancy-42/
return http.request.render('contract_form_info.contract_by_id', {
'id': id,
})
peccato che
la compilazione dei campi,
che in fondo è la funzione che ricerco,
usando il campo t-field non mi funzioni...
Andrea