Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


execute custom code in custom module when I create sale.order

on 12/18/13, 5:15 AM 1,731 views

Hello I created a custom module with their columns in database. I would like to execute a custom function, in my module, when I create a new sale.order. For example, when you save a new sale.order, it has to execute my function that it will save some information of this sale in my table. Is it possible?


Yes overrride the write method of sale.order.

Gopakumar N G
on 12/18/13, 6:24 AM

Hi Gopakumar, how can I do this?

on 12/18/13, 9:50 AM
On 12/18/13, 2:19 PM

I got an error and I don't know why. I have this code:

on 12/19/13, 5:08 AM

class moodle_alumno(osv.osv): _name = "moodle.alumno" _inherit = "sale.order"

def create(self, cr, uid, vals, context=None):
    vals['IdAlumno'] = 8
    vals['Nombre'] = "Hola"
    vals['Apellido1'] = "Hola"
    vals['Apellido2'] = "Hola"
    vals['Email'] = "Hola"
    vals['DNI'] = "Hola"
    vals['FechaNac'] = "Hola"
    vals['Telefono1'] = "Hola"
    vals['Telefono2'] = "Hola"
    vals['Ciudad'] = "Hola"
    vals['Pais'] = "Hola"
    vals['Usuario'] = "Hola"
    vals['Password'] = "Hola"
on 12/19/13, 5:10 AM

id_alumno = super(moodle_alumno, self).create(cr, uid, vals, context=context) return id_alumno

_columns = {
        "IdAlumno": fields.many2one("res.partner","Id Alumno"),
        "Nombre": fields.char("Nombre", required=True),
        "Apellido1": fields.char("Primer apellido", required=True),
        "Apellido2": fields.char("Segundo apellido", required=True),
        "Email": fields.char("Email", required=True),
        "DNI": fields.char("DNI", required=True),
        "FechaNac": fields.date("Fecha nacimiento", required=True),
on 12/19/13, 5:10 AM

"Telefono1": fields.char("Teléfono 1", required=True), "Telefono2": fields.char("Teléfono 2", required=True), "Ciudad": fields.char("Ciudad", required=True), "Pais": fields.char("Pais", required=True), "Usuario": fields.char("Usuario Moodle", required=True), "Password": fields.char("Contraseña Moodle", required=True), "active": fields.boolean('Active'), }

_defaults = {
    "active" : True,
on 12/19/13, 5:11 AM

(sorry for putting this in some comments) I got this error: AttributeError: 'Field pricelist_id not found in browse_record(moodle.alumno, 92)'

on 12/19/13, 5:12 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)


Asked: 12/18/13, 5:15 AM
Seen: 1731 times
Last updated: 3/16/15, 8:10 AM