跳至内容
菜单
此问题已终结
1 回复
6628 查看

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?

Thanks

形象
丢弃

Yes overrride the write method of sale.order.

编写者

Hi Gopakumar, how can I do this?

最佳答案

you can see this link : https://accounts.openerp.com/forum/Help-1/question/38847

形象
丢弃
编写者

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

编写者

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"
编写者

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),
编写者

"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,
}
编写者

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

相关帖文 回复 查看 活动
17
12月 21
24191
1
12月 18
19469
1
7月 15
7050
2
3月 15
5359
2
3月 15
8607