Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

error in migrating module v8 to v11

Naroči se

Get notified when there's activity on this post

This question has been flagged
11
3 Odgovori
4389 Prikazi
Avatar
NASHMIN YEGANEH

Hello dear members

I'm trying to port a module to v11 from v8 and here is the error log when i try to install it

please tell me if any one know where is the problem and how can i fix it

thanks in advance :)

 
Odoo Server Error

Traceback (most recent call last):
File "/opt/odoo/models.py", line 982, in _validate_fields
check(self)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 338, in _check_xml
self.postprocess_and_fields(view.model, view_doc, view.id)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 957, in postprocess_and_fields
self.raise_view_error(_('Model not found: %(model)s') % dict(model=model), view_id)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 506, in raise_view_error
raise ValueError(message)
ValueError: Model not found: res.letter

Error context:
View `Inbound Letter Tree`
[view_id: 1677, xml_id: n/a, model: res.letter, parent_id: n/a]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/odoo/tools/convert.py", line 741, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "/opt/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 "/opt/odoo/addons/base/ir/ir_model.py", line 1469, in _update
record = record.create(values)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 401, in create
return super(View, self).create(self._compute_defaults(values))
File "/opt/odoo/models.py", line 3302, in create
self._fields[key].determine_inverse(record)
File "/opt/odoo/fields.py", line 1070, in determine_inverse
getattr(records, self.inverse)()
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 269, in _inverse_arch
view.write(data)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 417, in write
return super(View, self).write(self._compute_defaults(vals))
File "/opt/odoo/models.py", line 3024, in write
self._write(old_vals)
File "/opt/odoo/models.py", line 3177, in _write
self._validate_fields(vals)
File "/opt/odoo/models.py", line 986, in _validate_fields
raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
odoo.exceptions.ValidationError: ('Error while validating constraint\n\nModel not found: res.letter\n\nError context:\nView `Inbound Letter Tree`\n[view_id: 1677, xml_id: n/a, model: res.letter, parent_id: n/a]', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/odoo/http.py", line 647, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/http.py", line 307, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/opt/odoo/http.py", line 689, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/http.py", line 339, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/http.py", line 332, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/http.py", line 933, in __call__
return self.method(*args, **kw)
File "/opt/odoo/http.py", line 512, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/addons/web/controllers/main.py", line 934, in call_button
action = self._call_kw(model, method, args, {})
File "/opt/odoo/addons/web/controllers/main.py", line 922, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/api.py", line 689, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/api.py", line 680, in call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-40>", line 2, in button_immediate_install
File "/opt/odoo/addons/base/module/module.py", line 71, in check_and_log
return method(self, *args, **kwargs)
File "/opt/odoo/addons/base/module/module.py", line 448, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/opt/odoo/addons/base/module/module.py", line 541, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/opt/odoo/modules/registry.py", line 85, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/modules/loading.py", line 343, in load_modules
loaded_modules, update_module)
File "/opt/odoo/modules/loading.py", line 242, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/opt/odoo/modules/loading.py", line 156, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/opt/odoo/modules/loading.py", line 94, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/opt/odoo/tools/convert.py", line 788, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "/opt/odoo/tools/convert.py", line 849, in convert_xml_import
obj.parse(doc.getroot(), mode=mode)
File "/opt/odoo/tools/convert.py", line 738, in parse
self.parse(rec, mode)
File "/opt/odoo/tools/convert.py", line 748, in parse
exc_info[2]
File "/opt/odoo/tools/pycompat.py", line 86, in reraise
raise value.with_traceback(tb)
File "/opt/odoo/tools/convert.py", line 741, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "/opt/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 "/opt/odoo/addons/base/ir/ir_model.py", line 1469, in _update
record = record.create(values)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 401, in create
return super(View, self).create(self._compute_defaults(values))
File "/opt/odoo/models.py", line 3302, in create
self._fields[key].determine_inverse(record)
File "/opt/odoo/fields.py", line 1070, in determine_inverse
getattr(records, self.inverse)()
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 269, in _inverse_arch
view.write(data)
File "/opt/odoo/addons/base/ir/ir_ui_view.py", line 417, in write
return super(View, self).write(self._compute_defaults(vals))
File "/opt/odoo/models.py", line 3024, in write
self._write(old_vals)
File "/opt/odoo/models.py", line 3177, in _write
self._validate_fields(vals)
File "/opt/odoo/models.py", line 986, in _validate_fields
raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
odoo.tools.convert.ParseError: "Error while validating constraint

Model not found: res.letter

Error context:
View `Inbound Letter Tree`
[view_id: 1677, xml_id: n/a, model: res.letter, parent_id: n/a]
None" while parsing /opt/odoo/addons/lettermgmt/views/res_letter_view.xml:10, near
<record model="ir.ui.view" id="res_letter_in_tree_view">
<field name="name">Inbound Letter Tree</field>
<field name="model">res.letter</field>
<field name="arch" type="xml">
<tree string="Letters">
<field name="name"/>
<field name="number"/>
<field name="move"/>
<field name="type"/>
<field name="class"/>
<field name="date"/>
<field name="recipient_partner_id"/>
<field name="state"/>
<field name="channel_id"/>
</tree>
</field>
</record>
0
Avatar
Opusti
Avatar
Cyril Gaspard (GEM)
Best Answer

Hi,

you must rewrite all your python code with the new api Odoo, see :

https://www.odoo.com/documentation/12.0/howtos/backend.html#

to resume what youhave to do with changes in new api :

1) in your __init__.py file, import your python file like this:

from . import my_python_file_name

2) All types names of fields start with upper:

name = fields.Text(string="My text")

3) You must use decorators for your functions (@api.model, @api.one, @api.multi, @api.onchange, @api.constraint ...), and no need to define cr, uid, context, you can have access to this variable using self._context, self._cr ..., this variables are automatically propgated.


@api.model

def _get_number(self):
        context = self._context or {}
        sequence_pool = self.env['ir.sequence']
        move_type = context.get('move', 'in')
        return sequence_pool.get('%s.letter' % move_type)

4) now context is a frozendict

to redifine context use with_context:

self.with_context({'key': value}).create(vals)

or

self.with_context(key=value}).create(vals)

5) _defaults is now an attribute to define in body field definition

_defaults = {
        'number': _get_number,}

is now:

number = fields.Char('Number', help="Auto Generated Number of letter.", required=True, default=lambda self: self._get_number())

6) Some new attributes to define fields are new like company_dependent=True, ..., see list line 133 her :

https://github.com/odoo/odoo/blob/10.0/odoo/fields.py

7) to browse a model:

self.pool.get('my.model')

is now :

self.env['my.model']

8) function self.search([('field', '=', 10)]) return now a recorset, not a list, same thing for function create ...

9) ....

Good luck, you have some efforts to make to learn new api

Regards

1
Avatar
Opusti
NASHMIN YEGANEH
Avtor

Yes, the __init__.py file content is correct i think, here you can see it here

1) from . import (

letter_class,

letter_folder,

res_letter,

letter_type,

letter_reassignment,

letter_channel,

)

2) some of types names of fields didn't started with upper, i fixed them and for now i got below error log

2018-10-13 20:18:03,402 5311 ERROR ? werkzeug: Error on request:

Traceback (most recent call last):

File "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 270, in run_wsgi

execute(self.server.app)

File "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 258, in execute

application_iter = app(environ, start_response)

File "/opt/rstco/odoo/service/server.py", line 252, in app

return self.app(e, s)

File "/opt/rstco/odoo/service/wsgi_server.py", line 166, in application

return application_unproxied(environ, start_response)

File "/opt/rstco/odoo/service/wsgi_server.py", line 154, in application_unproxied

result = handler(environ, start_response)

File "/opt/rstco/odoo/http.py", line 1303, in __call__

self.load_addons()

File "/opt/rstco/odoo/http.py", line 1325, in load_addons

m = __import__('odoo.addons.' + module)

File "<frozen importlib._bootstrap>", line 971, in _find_and_load

File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked

File "<frozen importlib._bootstrap>", line 656, in _load_unlocked

File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible

File "/opt/rstco/odoo/modules/module.py", line 82, in load_module

exec(open(modfile, 'rb').read(), new_mod.__dict__)

File "<string>", line 23, in <module>

File "/opt/rstco/odoo/addons/lettermgmt/models/__init__.py", line 21, in <module>

from . import (

File "/opt/rstco/odoo/addons/lettermgmt/models/res_letter.py", line 27, in <module>

class res_letter(models.Model):

File "/opt/rstco/odoo/addons/lettermgmt/models/res_letter.py", line 46, in res_letter

('in', _('IN')),

NameError: name '_' is not defined

and now im working on step 3 :)

NASHMIN YEGANEH
Avtor

@Cyril Gaspard (GEM)

Do this work for importing modules in __init__.py or i need to put each on per seperated line?

from . import (

letter_class,

letter_folder,

res_letter,

letter_type,

letter_reassignment,

letter_channel,

)

Cyril Gaspard (GEM)

Hi,

personnaly I use one line for each file to import.

For NameError: name '_' is not defined, you must import _ for translation like this

from odoo import models, fields, _

Bye

Avatar
Jainesh Shah(Aktiv Software)
Best Answer

Hello Berctain,

Please verify if you have migrated res.letter model or not.

it is showing that the model is not properly migrated.

Thanks.




Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

3
Avatar
Opusti
Avatar
NASHMIN YEGANEH
Avtor Best Answer

Thanks for replies, this is the res_letter.py python file... and what i did until now

from odoo import models, fields


class res_letter(models.Model):
"""A register class to log all movements regarding letters"""
_name = 'res.letter'
_description = "Log of Letter Movements"
_inherit = 'mail.thread'

def _get_number(self, cr, uid, context=None):
if context is None:
context = {}
sequence_pool = self.env.get('ir.sequence')
move_type = context.get('move', 'in')
return sequence_pool.get(
cr, uid, '%s.letter' % move_type, context=context)

name = fields.text('Subject', help='Comment for user explaining forward.')
folder_id = fields.Many2one('letter.folder', 'Folder', help='Folder which contains letter.')
number = fields.char('Number', help="Auto Generated Number of letter.", required=True)
move = fields.Selection(
[
('in', _('IN')),
('out', _('OUT')), help="Incoming or Outgoing Letter."
],
'Move', index=True, readonly=True, default='draft', )
type = fields.Many2one('letter.type', 'Type', help='Type of Letter, Depending upon size.')
class = fields.Many2one('letter.class', 'Class', help='Classification of Document.')
date = fields.datetime('Letter Date', help='The letter\'s date')
snd_rec_date = fields.datetime('Sent / Received Date', help='Created Date of Letter Logging.')
recipient_partner_id = fields.Many2one('res.partner', 'Recipient', track_visibility='onchange')
sender_partner_id = fields.Many2one('res.partner', 'Sender', track_visibility='onchange')
note = fields.text('Note')

state = fields.Selection(
[
('draft', _('Draft')),
('created', _('Created')),
('validated', _('Validated')),
('rec', _('Received')),
('sent', _('Sent')),
('rec_bad', _('Received Damage')),
('rec_ret', _('Received But Returned')),
('cancel', _('Cancelled'))],
],
'State', index = True, readonly = True, default = 'draft' track_visibility='onchange' )
parent_id = fields.Many2one('res.letter', 'Parent')
child_line = fields.Many2one('res.letter', 'parent_id', 'Letter Lines')
channel_id = fields.Many2one('letter.channel', 'Sent / Receive Source')
orig_ref = fields.char('Original Reference', help="Reference Number at Origin.")
expeditor_ref = fields.char('Expeditor Reference', help="Reference Number used by Expeditor.")
track_ref = fields.char('Tracking Reference', help="Reference Number used for Tracking.")
reassignment_ids = fields.One2many('letter.reassignment', 'letter_id', 'Reassignment lines', help='Reassignment users and comments')
extern_partner_ids = fields.Many2many('res.partner', 'Recipients')


}

_defaults = {
'number': _get_number,
'snd_rec_date': fields.datetime.now,
'move': lambda self, cr, uid, context: context.get('move', 'in'),
'state': 'draft',
}

def action_received(self, cr, uid, ids, context=None):
"""Put the state of the letter into Received"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(cr, uid, [letter.id], {'state': 'rec'}, context=context)
return True

def action_cancel(self, cr, uid, ids, context=None):
"""Put the state of the letter into Cancelled"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'cancel'}, context=context)
return True

def action_create(self, cr, uid, ids, context=None):
"""Put the state of the letter into Crated"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'created'}, context=context)
return True

def action_validate(self, cr, uid, ids, context=None):
"""Put the state of the letter into Validated"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'validated'}, context=context)
return True

def action_send(self, cr, uid, ids, context=None):
"""Put the state of the letter into sent"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id],
{
'state': 'sent',
'snd_rec_date': letter.snd_rec_date or
fields.datetime.now()
},
context=context)
return True

def action_rec_ret(self, cr, uid, ids, context=None):
"""Put the state of the letter into Received but Returned"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'rec_ret'}, context=context)
return True

def action_rec_bad(self, cr, uid, ids, context=None):
"""Put the state of the letter into Received but Damaged"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'rec_bad'}, context=context)
return True

def action_set_draft(self, cr, uid, ids, context=None):
"""Put the state of the letter into draft"""
for letter in self.browse(cr, uid, ids, context=context):
self.write(
cr, uid, [letter.id], {'state': 'draft'}, context=context)
return True
0
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
How to Disable edit option in form when the state is done Solved
11
Avatar
Avatar
Avatar
2
feb. 24
14036
Onchange function not loading values on form
11
Avatar
Avatar
2
okt. 18
3555
Is Odoo a stateless web application?
11
Avatar
Avatar
1
mar. 18
5179
[11.0] invoicing of timesheet for multiple salesorders
11
Avatar
0
nov. 17
3278
how to eliminate the "Create/edit" option at the quotation Solved
odoo 11
Avatar
Avatar
Avatar
2
apr. 23
12981
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now