Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

[SOLVED]: Default country name ... how to?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
countrydefaultformcustomername
3 Risposte
18680 Visualizzazioni
Avatar
Dr Obx

Hello everyone.

Recently, I found that I would like to have country name set as default so user will not have to pick it from list (because most of our customers are local - UK).

So to do it I modified class in res_country.py ...

class Country(osv.osv):

_name = 'res.country'

_description = 'Country'

def _get_country_name(self):

res = self.env['res.country'].search([('name','=','United Kingdom')])

print res

return res

_columns = {

'name': fields.char('Country Name',

help='The full name of the country.', required=True, translate=True),

'code': fields.char('Country Code', size=2,

help='The ISO country code in two chars.\n'

'You can use this field for quick search.'),

'address_format': fields.text('Address Format', help="""You can state here the usual format to use for the \

addresses belonging to this country.\n\nYou can use the python-style string patern with all the field of the address \

(for example, use '%(street)s' to display the field 'street') plus

\n%(state_name)s: the name of the state

\n%(state_code)s: the code of the state

\n%(country_name)s: the name of the country

\n%(country_code)s: the code of the country"""),

'currency_id': fields.many2one('res.currency', 'Currency'),

'image': fields.binary("Image"),

'country_group_ids': fields.many2many('res.country.group', 'res_country_res_country_group_rel', 'res_country_id', 'res_country_group_id', string='Country Groups'),

}

_sql_constraints = [

('name_uniq', 'unique (name)',

'The name of the country must be unique !'),

('code_uniq', 'unique (code)',

'The code of the country must be unique !')

]

_defaults = {

'address_format': "%(street)s\n%(street2)s\n%(city)s %(state_code)s %(zip)s\n%(country_name)s",

'name': _get_country_name,

}

I was hoping that it is so easy to achieve but unfortunately .... is not.

How can I achieve it ?

Would anyone tell me what is the best method ?

Don't know why I tried to achieve it in such complicated way .... ;)


0
Avatar
Abbandona
Ray Carnes

The easiest way is via the UI:

http://stackoverflow.com/questions/14375152/how-to-set-default-value-for-openerp-v7-at-form-interface

(For v7 but it hasn't changed).

Since this is just a record, you can export it like any other to move it from one database to another. 

Avatar
Ray Carnes
Risposta migliore

I'm glad you got it working.

Just in case you or anyone reading this wants to do it via the UI, the trick is to populate the field BEFORE opening the Set Defaults popup:


This method makes a record in Settings --> Technical --> Actions --> User Defined Defaults:


By removing the User, it becomes the default for ALL USERS (or you can just select that on the popup in the first place).

3
Avatar
Abbandona
Dr Obx
Autore

Awesome, Thank you Ray. Are you sure this or similar method also works in v8.0 ?

OdooBot
Yes.  6.1, 7, 8 and 9.

From: Dr Obx
Sent: ‎3/‎20/‎2016 2:39 PM
To: Ray Carnes
Subject: Re: Re: [SOLVED]: Default country name ... how to?

Awesome, Thank you Ray. Are you sure this or similar method also works in v8.0 ?

Regards

Robert A.Lien
Sent by Odoo S.A. using Odoo
Avatar
Dr Obx
Autore Risposta migliore

Awesome, it's so simple

in class res_partner(osv.Model, format_address):

just added in _defaults section:

  'country_id': 233,

works beautifully ;)

0
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
default country customer
country customer
Avatar
Avatar
Avatar
2
mar 15
9825
How can I re-order the list of Countries shown when creating a Customer? We don't often need some smaller countries in the list. Risolto
country customer sort
Avatar
Avatar
1
giu 23
6521
Display Customer Name on Manufacturing Order? Risolto
manufacturing customer name
Avatar
1
mag 15
5084
set default customer to lead?
default customer lead
Avatar
Avatar
1
mar 15
5165
Set default value in child form by sending context from parent form
default form view context
Avatar
0
feb 23
3921
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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