简体   繁体   中英

python odoo 10 error

I'm starting to use odoo but I do not start very well, nothing but mistakes, generate a simple module to start

"%pyodoo%\python.exe" odoo-bin scaffold mi_module

uncomment all the commented lines and I get the following error

Error:
Odoo Server Error

Traceback (most recent call last):
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 741, in parse
    self._tags[rec.tag](rec, de, mode=mode)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 651, in _tag_record
    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
    _load_data(cr, module_name, idref, mode, kind='data')
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\modules\loading.py", line 94, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 788, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 849, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 738, in parse
    self.parse(rec, mode)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 748, in parse
    exc_info[2]
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\pycompat.py", line 86, in reraise
    raise value.with_traceback(tb)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 741, in parse
    self._tags[rec.tag](rec, de, mode=mode)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 651, in _tag_record
    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_model.py", line 1469, in _update
    record = record.create(values)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_actions.py", line 217, in create
    return super(IrActionsActWindow, self).create(vals)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_actions.py", line 46, in create
    res = super(IrActions, self).create(vals)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 3278, in create
    record = self.browse(self._create(old_vals))
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 3431, in _create
    self._validate_fields(vals)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 967, in _validate_fields
    check(self)
  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_actions.py", line 125, in _check_model
    raise ValidationError(_('Invalid model name %r in action definition.') % action.res_model)
odoo.tools.convert.ParseError: "Nombre de modelo 'mi_module.mi_module' no valido en la definición de la acción.
None" while parsing file:/c:/program%20files%20(x86)/odoo%2011.0/server/odoo/addons/mi_module/views/views.xml:10, near
<record model="ir.actions.act_window" id="mi_module.action_window">
      <field name="name">mi_module window</field>
      <field name="res_model">mi_module.mi_module</field>
      <field name="view_mode">tree,form</field>
    </record>

simply generate the module to start and then enter odoo, install the module but I get this error. I am using windows and the final version of odoo. Should I use another version of odoo to start?

It should be like this !!

if your class defined as:

class mi_module(models.Model):
    _name = "mi.module"

    #"Body"

you have to do it as :

<record model="ir.actions.act_window" id="mi_module.action_window">
    <field name="name">mi module window</field>
    <field name="res_model">mi.module</field>
    <field name="view_mode">tree,form</field>
</record>

Vishal Khichadiya in the post above found the solution. However, I think you should start from understanding how it works. Two ways of fast learning would be:

  1. Download some simple apps and see the files, learn how they are built and try to replicate it. I would recommend starting with simple view edits.
  2. Activate the developer mode and make some front-end changes. If it is possible to save and things are working simply replace your front-end changes with a module. The easiest would be editing the list /tree views - add some stuff here and there.

What version of Odoo should you use? Probably 11 is the only right version as it is using different Python version than 10 and older. Get familiar with official Odoo forum as you might get an instant help in there.

E:\odoo-11.0>"E:\odoo-11.0\venv\Scripts\python.exe" "E:\odoo-11.0\odoo-bin" scaffold openacademy addons

Instead use this kind of path in the command prompt to scaffold a modole.

Thanks Abhay S

I believe Vishal Khichadiya already answered your question however, if you do not understand how it works it will be pointless to use his answer

starting odoo could be frustrating but when you know how it works it will get easier.

please read on the documentation of your odoo version to understand how things works functionally

for your version odoo 11 go to this link https://www.odoo.com/documentation/11.0/howtos/backend.html

after finishing the above read this for more technical information

https://odoo-development.readthedocs.io/en/latest/#

I just started odoo too and I found out its more research than development

good luck

If you are on Windows try using "_" instead ".", like this:

<field name="res_model">mi_module_mi_module</field>

PLease check your /mi_module/models/__init__.py file :- if their is something like from . import models from . import models then it is ok.

check also /mi_module/__init__.py :- must be from . import models from . import models

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM