Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

How can I change field value in _default

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
defaultlocation
1 Svar
9247 Visninger
Avatar
Van Tran

Hi everyone

Sorry because I'm not good at English.

I want to modify default value of "source location" and "destination location". So, my problem is the value of Location when I create a "Receive/Deliver Products -> Incoming Products" has been changed. But after that, about 1 second, It return the old value as model "stock.move" define it.

But when I create a "Receive/Deliver By Orders -> Incoming Shipments" and click "Add an items", the value of Location same the value I modify in my module

So, do you understand me?

from openerp.osv import fields, osv, orm
from openerp.tools.translate import _
from openerp import tools
from openerp.tools import float_compare, DEFAULT_SERVER_DATETIME_FORMAT

class default_location(osv.osv):

    _inherit = 'stock.move'
    
    def _default_location_destination(self, cr, uid, context=None):
       """some thing here"""

        return location_id

    def _default_location_source(self, cr, uid, context=None):
        """some thing here"""

        return location_id

    _columns = {
         'location_id': fields.many2one('stock.location', 'Source Location', required=True, select=True,states={'done': [('readonly', True)]}, help="Sets a location if you produce at a fixed location. This can be a partner location if you subcontract the manufacturing operations."),
        'location_dest_id': fields.many2one('stock.location', 'Destination Location', required=True,states={'done': [('readonly', True)]}, select=True, help="Location where the system will stock the finished products."),
    }

    _defaults = {
        'location_id': _default_location_source,
        'location_dest_id': _default_location_destination,
    }

default_location()

 

So? What is wrong?

Help me! Thank you so much

0
Avatar
Kassér
Atchuthan - Technical Consultant, Sodexis Inc

what do you mean by "they returned the last value right now, as I didn't modify them" ?? So, according to your question _defaults works fine. so what is your question? Describe the problem in detail

OdooBot
Hi atchuthan

Sorry because I'm not good at English.
I want to modify default value of "source location" and "destination location". So, my problem is the value of Location when I create a "Receive/Deliver Products -> Incoming Products" has been changed. But after that, about 1 second, It return the old value as model "stock.move" define it.
But when I create a "Receive/Deliver By Orders -> Incoming Shipments" and click "Add an items", the value of Location same the value I modify in my module
So, do you understand me?




2014-08-07 12:12 GMT+07:00 atchuthan <atchuthantu@mail.odoo.com>:

what do you mean by "they returned the last value right now, as I didn't modify them" ?? So, according to your question _defaults works fine. so what is your question? Describe the problem in detail

--
atchuthan Sent by Odoo Inc. using Odoo. Access your messages and documents in Odoo



--
Trần Như Văn
MSSV: 51104177
K11 Bách Khoa Tp.HCM
Khoa: Khoa học và Kĩ thuật máy tính
Avatar
Van Tran
Forfatter Bedste svar

Help me, please

Here is my function, but it didn't work.

def _default_location_destination(self, cr, uid, context=None):
        """ Gets default address of partner for destination location
        @return: Address id or False
        """
        super(default_location, self)._default_location_destination(cr, uid, context)
        mod_obj = self.pool.get('ir.model.data')
        picking_type = context.get('picking_type')
        location_id = False
        location_xml_id = False
        if picking_type in ('in', 'internal'):
            location_xml_id = 'stock_location_customers'
        elif picking_type == 'out':
            location_xml_id = 'stock_location_customers'
        if location_xml_id:
            try:
                location_model, location_id = mod_obj.get_object_reference(cr, uid, ['company','stock'], location_xml_id)
                with tools.mute_logger('openerp.osv.orm'):
                    self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
            except (orm.except_orm, ValueError):
                location_id = False
        return location_id

0
Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
Default values for Users Løst
default v7 location
Avatar
Avatar
1
feb. 24
14547
How can I set the default location when adding an item to a Physical Inventory?
default inventory location
Avatar
0
mar. 15
5280
Set default columns for projects in OODO
default
Avatar
Avatar
Avatar
2
jan. 23
3343
How to set a condition on default values in model ir.default Løst
default
Avatar
Avatar
1
aug. 22
6795
Add a product to a location
location
Avatar
Avatar
1
sep. 20
4082
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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