Odoo Help

Welcome!

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.

1

Problem with inheriting create function

By
Matthieu
on 6/30/16, 6:52 AM 358 views

Hello,

In a custom module that I'm developping, I've got an error when clicking on a button "apply".

In facts, I inherited the create function that is called by a click on this button like this :

def create(self, cr, uid, vals, context=None):

  self.write(cr, uid, 1, vals, context=context)

  return True

But currently, this error appear when I click on this button :

Odoo Warning - Missing Record

One of the records you are trying to modify has already been deleted (Document type: to.magento).

How can I solve that ?


Thank you in advance !
2

Axel Mendoza

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 6/30/16, 2:19 PM

The code you posted doesn't make any sense, you are overriding the create method to call the write method to change the record with id = 1 with the vals of the create method. The error is that the record with id = 1 could be not created or deleted, you are not calling the super create so you cannot create anything using this method. 

0
Burhan Vakharia
On 7/1/16, 2:54 AM

Tutorial - Learn How to override create method in Odoo with Example - 

http://odootechnical.com/learn-overriding-create-method-in-odoo-8/

0
Dilip Dabhi
On 7/1/16, 12:52 AM

If you want to write / update some value after record create you should write like that:

def create(self, cr, uid, vals, context=None):

   id = super(class_name, self).create(cr, uid, vals, context = context)

   vals.update({'field_name': value})    //   here you can give fields name for which you want to update value.

   self.write(cr, uid, id, vals, context=context)

  return True


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

1 follower(s)

Stats

Asked: 6/30/16, 6:52 AM
Seen: 358 times
Last updated: 7/1/16, 2:54 AM