Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Discuss
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

error in migrating module v8 to v11

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
11
3 Replies
4395 Tampilan
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
Buang
Avatar
Cyril Gaspard (GEM)
Jawaban Terbai

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
Buang
NASHMIN YEGANEH
Penulis

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
Penulis

@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)
Jawaban Terbai

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
Buang
Avatar
NASHMIN YEGANEH
Penulis Jawaban Terbai

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
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
How to Disable edit option in form when the state is done Diselesaikan
11
Avatar
Avatar
Avatar
2
Feb 24
14063
Onchange function not loading values on form
11
Avatar
Avatar
2
Okt 18
3557
Is Odoo a stateless web application?
11
Avatar
Avatar
1
Mar 18
5184
[11.0] invoicing of timesheet for multiple salesorders
11
Avatar
0
Nov 17
3282
how to eliminate the "Create/edit" option at the quotation Diselesaikan
odoo 11
Avatar
Avatar
Avatar
2
Apr 23
12996
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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