-
shakin89
-
-
Offline
-
Platinum Boarder
-
- Messaggi: 388
- Ringraziamenti ricevuti 7
-
Karma: 7
-
|
Ciao ragazzi,
sto uscendo pazzo per fare una one2many list.
Voglio legare due modelli, tramite i campi one2many nel padre, e many2one nel figlio.
Il modello padre detiene le dimensioni di una etichetta. Il modello figlio detiene i campi che andranno nell'etichetta.
Questo il codice python class product_label_epl2_dimension(osv.osv):
_name = 'product.label.epl2.dimension'
_description = "Dimensioni etichetta epl2"
_columns = {
'name': fields.char('Descrizione', size=100, help="Nome dell'etichetta"),
'q_label_width': fields.integer('Larghezza etichetta (q)', help="Dimensione area di stampa in dots (12 dots = 1 mm per 300 dpi)"),
'Q_form_length': fields.char('Lunghezza form (Q)', size=20, help="Lunghezza dell'etichetta di stampa e del gap tra le etichette in dots (12 dots = 1mm per 300 dpi)"),
'D_density': fields.integer('Densita di stampa (D)', help="Imposta la densita' di stampa"),
'field_lines': fields.one2many('product.label.epl2.fields', 'dimension_id', 'Campi'),
}
_defaults = {
'q_label_width': 534,
'Q_form_length': '32,0',
'D_density': 4,
}
product_label_epl2_dimension()
class product_label_epl2_fields():
_name ="product.label.epl2.fields"
_description = "Campi per le etichette"
_fonts = (
(1, '4 pt (12x20 dots)'),
(2, '6 pt (16x28 dots)'),
(3, '8 pt (20x36 dots)'),
(4, '10 pt (24x44 dots'),
(5, '21 pt (48x80 dots)'),
('A', 'Custom font'),
('B', 'Custom font'),
('C', 'Custom font'),
('D', 'Custom font'),
('E', 'Custom font'),
)
_columns = {
'dimension_id': fields.many2one('product.label.epl2.dimension', 'Etichetta', select=True),
'description': fields.char('Descrizione', size=100, help="Semplice descrizione mnemonica del campo"),
'x': fields.integer('Origine X', help="X coordinata"),
'y': fields.integer('Origine Y', help="Y coordinata"),
'font': fields.selection(_fonts, 'Carattere'),
'campo': fields.many2one('ir.model.fields', 'Campo', on_delete='cascade', domain=[('model', 'like', 'product.%')])
}
product_label_epl2_fields()
Nella view invece ho fatto cosi: <record id="epl2_dimension_view_form" model="ir.ui.view">
<field name="name">product.label.epl2.dimension.form</field>
<field name="model">product.label.epl2.dimension</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Configura Dimensione Etichette">
<group colspan="4" col="6">
<field name="name" colspan="6" />
<field name="q_label_width" colspan="2" />
<field name="Q_form_heigth" colspan="2" />
<field name="D_density" colspan="2" />
</group>
<notebook colspan="4">
<page string="Campi">
<field mode="form,tree" name="field_lines" nolabel="1" widget="one2manylist" colspan="4" >
<form string="Campi Etichetta">
<group col="6" colspan="4">
<field name="description" colspan="6" />
<field name="x" colspan="2" />
<field name="y" colspan="2" />
<field name="font" colspan="2" />
<field name="campo" colspan="6" />
</group>
</form>
<tree string="Campi etichetta">
<field name="description" />
<field name="x" />
<field name="y" />
<field name="font" />
<field name="campo" />
</tree>
</field>
</page>
</notebook>
</form>
</field>
</record> La tree view mi viene mostrata correttamente (vuota naturalmente).
Quando clicco su crea (per creare un nuovo record) mi da questo errore Client Traceback (most recent call last):
File "/opt/openerp/openerp6.1/web/addons/web/common/http.py", line 180, in dispatch
response["result"] = method(controller, self, **self.params)
File "/opt/openerp/openerp6.1/web/addons/web/controllers/main.py", line 1209, in load
return self.fields_view_get(req, model, view_id, view_type, toolbar=toolbar)
File "/opt/openerp/openerp6.1/web/addons/web/controllers/main.py", line 1091, in fields_view_get
fvg = Model.fields_view_get(view_id, view_type, context, toolbar, submenu)
File "/opt/openerp/openerp6.1/web/addons/web/common/openerplib/main.py", line 250, in proxy
args, kw)
File "/opt/openerp/openerp6.1/web/addons/web/common/openerplib/main.py", line 117, in proxy
result = self.connector.send(self.service_name, method, *args)
File "/opt/openerp/openerp6.1/web/addons/web/common/http.py", line 608, in send
raise xmlrpclib.Fault(openerp.tools.exception_to_unicode(e), formatted_info)
Server Traceback (most recent call last):
File "/opt/openerp/openerp6.1/web/addons/web/common/http.py", line 593, in send
return openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/opt/openerp/openerp6.1/server/openerp/netsvc.py", line 360, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/opt/openerp/openerp6.1/server/openerp/service/web_services.py", line 586, in dispatch
res = fn(db, uid, *params)
File "/opt/openerp/openerp6.1/server/openerp/osv/osv.py", line 167, in execute_kw
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/opt/openerp/openerp6.1/server/openerp/osv/osv.py", line 121, in wrapper
return f(self, dbname, *args, **kwargs)
File "/opt/openerp/openerp6.1/server/openerp/osv/osv.py", line 176, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/opt/openerp/openerp6.1/server/openerp/osv/osv.py", line 164, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/opt/openerp/openerp6.1/server/openerp/osv/orm.py", line 2153, in fields_view_get
xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx)
File "/opt/openerp/openerp6.1/server/openerp/osv/orm.py", line 1793, in __view_look_dom_arch
fields_def = self.__view_look_dom(cr, user, node, view_id, False, fields, context=context)
File "/opt/openerp/openerp6.1/server/openerp/osv/orm.py", line 1742, in __view_look_dom
fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
File "/opt/openerp/openerp6.1/server/openerp/osv/orm.py", line 1742, in __view_look_dom
fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
File "/opt/openerp/openerp6.1/server/openerp/osv/orm.py", line 1742, in __view_look_dom
fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
File "/opt/openerp/openerp6.1/server/openerp/osv/orm.py", line 1661, in __view_look_dom
xarch, xfields = relation.__view_look_dom_arch(cr, user, f, view_id, ctx)
AttributeError: 'NoneType' object has no attribute '_BaseModel__view_look_dom_arch' So che probabilmente è una stupidaggine, ma dove sbaglio?
Grazie per aver letto fino a qui
|