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

on record creation run function to create a record in another module odoo 13

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
Odoo13.0create()
16 Antwoorden
18463 Weergaven
Avatar
Moaz Mabrok

I was trying to create a new company when a record is created in my module but using the create method 

but I can't get it to work

     @api.model
def create(self, vals):
for n_record in self:
company_info ={
'company_type': 'company',
'name': n_record.new_company_name,
'vat': n_record.company_trn
}
record = n_record.env['base.view_partner_form'].create(company_info)

return record

I got this error and I can't understand the Error 

Odoo Server Error
Traceback (most recent call last):
........
........
 return result.id if isinstance(args[0], Mapping) else result.ids
AttributeError: 'NoneType' object has no attribute 'id'

can please help 


edit

@api.model
def create(self, vals):
company_info ={
'company_type': 'company',
'name': self.new_company_name,
'vat': self.company_vat
}
record = self.env['res.partner'].create(company_info)

return record

Something went wrong !

Contacts require a name

1
Avatar
Annuleer
Sehrish

Override odoo methods: https://goo.gl/4BkizH

Avatar
Prakash
Beste antwoord
Hi,
Remove return record
and add return super "yourclassname"
@api.model
def create(self, vals):
company_info ={
'company_type': 'company',
'name': self.new_company_name,
'vat': self.company_vat
}
record = self.env['res.partner'].create(company_info)
return super(yourclassname, self).create(vals)


1
Avatar
Annuleer
Moaz Mabrok
Auteur

can you explain using my code, I can't understand your example

Moaz Mabrok
Auteur

what is the `ClassName` for `res.partner` or the contacts

Prakash

Are you overriding default create method? In that case create method add below code: change "classname" into your class name.

return super(classname, self).create(values)

Moaz Mabrok
Auteur

I am overriding my module `A` create method so after creating the recored in `A` it create a recored in odoo contacts module `B`

Prakash

Updated code, please check remove return record and add return super yourclassname ...

Moaz Mabrok
Auteur

how to make it run a function on create instead of having the code in the create function it self

Avatar
Niyas Raphy (Walnut Software Solutions)
Beste antwoord

Hi,

Change this line record = n_record.env['base.view_partner_form'].create(company_info) to

record = self.env['res.company'].create(company_info) and see .


For creating records from code, see : Create Record From Code in Odoo


For Over riding the create method,

@api.model
def create(self, vals):
result = super(ClassName, self).create(vals)
# do what you want
return result

See : - How To Override Create Function in Odoo


Thanks

1
Avatar
Annuleer
Moaz Mabrok
Auteur

That is the tutorial that I was following

I am still getting the error

File "/usr/lib/python3/dist-packages/odoo/api.py", line 385, in call_kw

result = _call_kw_model_create(method, model, args, kwargs)

File "/usr/lib/python3/dist-packages/odoo/api.py", line 366, in _call_kw_model_create

return result.id if isinstance(args[0], Mapping) else result.ids

AttributeError: 'NoneType' object has no attribute 'id'

Moaz Mabrok
Auteur

I user this instead

@api.model

def create(self, vals):

company_info ={

# 'company_type': 'company',

'name': self.new_company_name,

'vat': self.company_trn

}

record = self.env['res.company'].create(company_info)

return record

and geting

×

The operation cannot be completed:

- Create/update: a mandatory field is not set.

- Delete: another model requires the record being deleted. If possible, archive it instead.

Model: Companies (res.company), Field: Company Name (name)

Niyas Raphy (Walnut Software Solutions)

Make sure that the value for the all the mandatory fields are passed in to the create method, here in your code as per the error self.new_company_name might be returning empty or False, just print it and see, also you can try with vals['new_company_name']

Thanks

Moaz Mabrok
Auteur

I tried vals['new_company_name'] I am not going the error but is stuck save

Moaz Mabrok
Auteur

the company has been created but the form is not saving

Niyas Raphy (Walnut Software Solutions)

See the updated answer,

Moaz Mabrok
Auteur

how to make it run a function on create instead of having the code in the create function it self

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
what is difference between these vals.get("field name", False) and vals['field name'] == False Opgelost
Odoo13.0 create()
Avatar
Avatar
Avatar
2
jul. 21
6299
Odoo 13. Don't close a wizard when Click a button Opgelost
Odoo13.0
Avatar
Avatar
Avatar
Avatar
4
mei 24
14084
Permission error while user printing excel sheet report in odoo 13 Opgelost
Odoo13.0
Avatar
Avatar
1
apr. 24
4335
One2many field edited from Transient Model cannot be made empty.
Odoo13.0
Avatar
0
nov. 23
3021
Blank White Page After log in to Odoo13 Opgelost
Odoo13.0
Avatar
1
sep. 23
3161
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