Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

V9 - Enable a currency when installing a module

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
dataupdatecurrency
1 Beantwoorden
5308 Weergaven
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
Annuleer
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.
Beste antwoord

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
Annuleer
Mathieu Laflamme
Auteur

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
Auteur

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.

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
How can i do currency rate updation up to date in openerp?
update currency openerp7
Avatar
Avatar
1
mrt. 15
4247
Can I update data in an Odoo Spreadsheet and have it update the source Odoo data? Opgelost
data update spreadsheet bidirectional
Avatar
Avatar
1
aug. 25
1007
How to update all addons of a database (-u all) WITHOUT restoring all XML data also?
data addons update website
Avatar
1
feb. 16
5133
Odoo auto updates for on-premises Enterprise version (cloud/ in-house server) - v10 v11 v12 Opgelost
update
Avatar
Avatar
Avatar
2
mei 24
7374
Default Currency
currency
Avatar
1
apr. 24
2377
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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