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
    • Diskusi
    • 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

V9 - Enable a currency when installing a module

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
dataupdatecurrency
1 Balas
5320 Tampilan
Avatar
Mathieu Laflamme

We're developing modules for our company and since we use CAD currency I want to enable it in the system. How can I do that from a module?


EDIT:

I can believe this is taking so long to accomplish this little task!

I get the following error:

ParseError: "Invalid field 'name' in leaf "<osv.ExtendedLeaf: ('name', '=', 'CAD') on res_currency (ctx: )>"" while parsing file:///C:/Users/laflammm/Desktop/GitHub/addons_tc/canadian_data/data/res_currency.xml:4, near
<function model="res.currency" name="_enable_currencies"/>


I don't get it... when I check the fields of res.currency, I only see those:

{
'create_uid': <openerp.osv.fields.many2one object at 0x0000000009A8D138>,
'create_date': <openerp.osv.fields.datetime object at 0x0000000009A8C3C8>,
'id': <openerp.osv.fields.integer object at 0x0000000009A8C588>,
'write_date': <openerp.osv.fields.datetime object at 0x0000000009A8C4A8>,
'write_uid': <openerp.osv.fields.many2one object at 0x0000000009A8D228>
}


Where are the name, rounding, symbol, position and active fields?? In the fields from res.currency are from the base modules. What's going on??

I have the following files:

res_currency.py

from import openerp models


class Currency(models.Model):
_name = "res.currency"

def _enable_currencies(self, cr, uid, ids=Nonecontext=None, ):
cad_currency_ids = self.search(cr, uid, [('name', '=', 'CAD')])

if cad_currency_ids:
self.write(cr, uid, cad_currency_ids, {'active' : 'True'})

res_currency.xml

<openerp>
<data>
<function model="res.currency" name="_enable_currencies"/>
</data>
</openerp>

__openerp__.py

{
'name' :"Canadian data" ,
'description':"Create the canadian provinces and territories plus activate CAD currency." ,
'author' :"Transcontinental" ,
'category' :'' ,
'version' :'1.1' ,
'depends' : [],
'data' : [
'res_currency.xml',
],
'auto_install': False,
'installable': True,
}

__init__.py

import res_currency



0
Avatar
Buang
Serpent Consulting Services Pvt. Ltd.

See my updated answer.

Serpent Consulting Services Pvt. Ltd.

Your module should depends on base module.

Avatar
Serpent Consulting Services Pvt. Ltd.
Jawaban Terbai

Hello Mathieu,

In v9, all other currencies are DE-activated by default (active=False).

So from your code, first you have to search for your currency based on currency code and then enable that currency (active=True). Now, update currency_id field in Company and set your currency in that field.

#TIP: If you want to show Currency menu to user, you have to assign "Multi Currencies" group to your user(s).

EDIT:

I can see there is a problem in your code.

Instead of _inherit, you have used _name which consider as a new object and will have only those fields which you have defined in your class.
Try this:

class res_currency(...):
_inherit = 'res.currency' # use _inherit to extend the functionality of the object
Hope this helps you.
1
Avatar
Buang
Mathieu Laflamme
Penulis

Thanks but I wonder where I should write that code. I tried making an xml to change the data but since the original data was imported with noupdate it doesn't work (I don't get why they use noupdate here!). There should be a way to run code at installation time.

Mathieu Laflamme
Penulis

Ok I search a bit more and I found this answer: https://www.odoo.com/fr_FR/forum/help-1/question/how-can-i-execute-a-sql-statement-on-module-update-and-installation-6131

Serpent Consulting Services Pvt. Ltd.

Yes that will work if you call the function from XML and will follow the steps we mentioned in the answer.

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 can i do currency rate updation up to date in openerp?
update currency openerp7
Avatar
Avatar
1
Mar 15
4248
Can I update data in an Odoo Spreadsheet and have it update the source Odoo data? Diselesaikan
data update spreadsheet bidirectional
Avatar
Avatar
1
Agu 25
1023
How to update all addons of a database (-u all) WITHOUT restoring all XML data also?
data addons update website
Avatar
1
Feb 16
5144
Odoo auto updates for on-premises Enterprise version (cloud/ in-house server) - v10 v11 v12 Diselesaikan
update
Avatar
Avatar
Avatar
2
Mei 24
7384
Default Currency
currency
Avatar
1
Apr 24
2388
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