Salve a tutti..allora io ho un mio modulo con una mia form. (Odoo 8)Nella form ho inserito un pulsante chiamato Send by mail, proprio come quello degli ordini, che deve fare la stessa cosa, però deve aprire il template che creo io nell'xml.
La cartella del mio modulo si chiama da_non_conformity, la classe python si chiama "totalquality.non_conformity_supplier", l'id dell'email template è "email_template_edi_non_conformity" e questa è la funzione preda dal modulo sale cambiando alcune cose:
def action_quotation_send(self, cr, uid, ids, context=None):
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
ir_model_data = self.pool.get('ir.model.data')
try:
template_id = ir_model_data.get_object_reference(cr, uid, 'da_non_conformity', 'email_template_edi_non_conformity')[1]
except ValueError:
template_id = False
try:
compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
except ValueError:
compose_form_id = False
ctx = dict()
ctx.update({
'default_model': 'totalquality.non_conformity_supplier',
'default_res_id': ids[0],
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_composition_mode': 'comment',
'mark_so_as_sent': True
})
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(compose_form_id, 'form')],
'view_id': compose_form_id,
'target': 'new',
'context': ctx,
}
E questo è l'errore nel terminale quando premo il pulsante:
MissingError: ('MissingError', u'One of the documents you are trying to access has been deleted, please try again after refreshing.')
2016-02-02 13:37:31,903 7365 ERROR TestStampa openerp.addons.email_template.email_template: Failed to render template <Template memory:7f75dc214f90> using values {'format_tz': <function <lambda> at 0x7f75c32b6230>, 'ctx': {'lang': 'it_IT', 'default_template_id': 12, 'tz': False, 'uid': 1, 'mark_so_as_sent': True, 'active_model': 'totalquality.non_conformity_supplier', 'default_use_template': True, 'default_composition_mode': 'comment', 'params': {'action': 128}, 'default_res_id': 3, 'search_disable_custom_filters': True, 'active_ids': [3], 'default_model': 'totalquality.non_conformity_supplier', 'tpl_partners_only': True, 'active_id': 3}, 'user': res.users(1,), 'object': sale.order(3,)}
Traceback (most recent call last):
File "/home/gianmarco/OCB/addons/email_template/email_template.py", line 201, in render_template_batch
render_result = template.render(variables)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 969, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 1, in top-level template code
File "/usr/lib/python2.7/dist-packages/jinja2/sandbox.py", line 330, in getattr
value = getattr(obj, attribute)
File "/home/gianmarco/OCB/openerp/fields.py", line 810, in __get__
return record._cache[self]
File "/home/gianmarco/OCB/openerp/models.py", line 5964, in __getitem__
return value.get() if isinstance(value, SpecialValue) else value
File "/home/gianmarco/OCB/openerp/fields.py", line 55, in get
raise self.exception
Grazie in anticipo per l'aiuto.