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

inherit create function in the new framework ?

Tilmeld

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

Dette spørgsmål er blevet anmeldt
orm8.0odoo
4 Besvarelser
12154 Visninger
Avatar
Rachid

I did:

    @api.model
    def create(self, cr, uid, vals, context=None):

 

 

Traceback (most recent call last):
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 476, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 495, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 311, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo-8.0/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 308, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 685, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo-8.0/openerp/http.py", line 360, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/odoo-8.0/addons/web/controllers/main.py", line 941, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/odoo-8.0/addons/web/controllers/main.py", line 933, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/opt/odoo/odoo-8.0/openerp/api.py", line 234, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-8.0/openerp/api.py", line 329, in old_api
    result = method(recs, *args, **kwargs)
TypeError: create() takes at least 4 arguments (2 given)

1
Avatar
Kassér
Avatar
Emipro Technologies Pvt. Ltd.
Bedste svar

Hi,

Just do as like below.

@api.model
def create(self, vals, context=None):

3
Avatar
Kassér
Rachid
Forfatter

then how can I call the cr and uid ?

Emipro Technologies Pvt. Ltd.

You can find the cr and uid into self.env. Because this is the new api structure.

Emipro Technologies Pvt. Ltd.

If you get this as an answer then please accept this answer. And give me up vote. Thanks.

Rachid
Forfatter

I get this MissingError One of the documents you are trying to access has been deleted, please try again after refreshing. the create function has the line: new_id = super(res_partner, self).create( vals,)

Emipro Technologies Pvt. Ltd.

Hello, For the calling of the create method you have two option. 1) As like normal calling with cr and uid. for that you can call new_id = super(res_partner,self).create(self.env.cr, self.env.uid, vals, context=context) 2) As like new API. For that you can call. new_id = super(res_partner,self).create(vals, context=context) Note : You have to confirm that here self is an recordset.

Rachid
Forfatter

I get the TypeError: create() takes exactly 2 arguments (5 given) when I use: new_id = super(res_partner,self).create(self.env.cr, self.env.uid, vals, context=context) AND TypeError: create() got an unexpected keyword argument 'context' WHEN USING new_id = super(res_partner,self).create(vals, context=context) I DIDN'T UNDERSTAND WHAT DO YOU MEAN WITH You have to confirm that here self is an recordset.

Emipro Technologies Pvt. Ltd.

"self" have to be recordset (as like browse record) to call the new api. From the calling just remove the context argument.

Rachid
Forfatter

same problem :(

Emipro Technologies Pvt. Ltd.

May I know that you are test into fresh database ?

Rachid
Forfatter

no it's not fresh I'm trying update all modules whit option -u all

Emipro Technologies Pvt. Ltd.

Can you try it in fresh database ? Might be it is an error of some other module or may be issue of some data.

Rachid
Forfatter

I tryid in a different database but the same problem :(

Avatar
Anil Kesariya
Bedste svar

Hello Rachid,

Here you go!

    @api.model
    def create(self, vals):
        cr, uid, context = self.env.args  #cursor , user and context can be fetch from env. if there is need of use.
        <Your code gose here...>
        res = super(<your model name>, self).create(vals)

      <Your code gose here...>
        return res

Hope this will helps you.

Anil.

 

2
Avatar
Kassér
Avatar
Rachid
Forfatter Bedste svar

I copied the same code of create function in the res_partner class HIERE IS

    @api.model
    def create(self, vals):
        if vals.get('website'):
            vals['website'] = self._clean_website(vals['website'])

        print vals

        partner = super(res_partner, self).create(vals)
        self._fields_sync(partner, vals)
        self._handle_first_contact_creation(partner)
        return partner

 

I get the same error One of the documents you are trying to access has been deleted, please try again after refreshing.

0
Avatar
Kassér
Avatar
Nikunj Nakum
Bedste svar

@api.model
@api.returns('self', lambda value: value.id)
 def create(self, vals):

 

0
Avatar
Kassér
Rachid
Forfatter

no changes MissingError: ('MissingError', u'One of the documents you are trying to access has been deleted, please try again after refreshing.')

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
Different between create/new, write/update Løst
orm odoo
Avatar
Avatar
Avatar
Avatar
3
sep. 22
19130
how to trace errors like this ? Løst
8.0 odoo
Avatar
Avatar
Avatar
Avatar
Avatar
6
dec. 16
12432
bug: creating product depending in product templte
8.0 odoo
Avatar
0
mar. 15
3864
how to call a rml report from button ?
8.0 odoo
Avatar
Avatar
1
mar. 15
6725
how to update server and DB?
8.0 odoo
Avatar
Avatar
1
mar. 15
4255
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