Skip to Content
Odoo Meny
  • Sign in
  • Prova gratis
  • Appar
    Finanstjänster
    • Bokföring
    • Fakturering
    • Utgifter
    • Kalkylark (Affärsanalyser)
    • Dokument
    • Underskrifter
    Försäljning
    • CRM
    • Försäljning
    • Kassasystem Butik
    • Kassasystem Restaurang
    • Prenumerationer
    • Uthyrning
    Hemsidor
    • Hemsidesverktyg
    • E-handel
    • Blogg
    • Forum
    • Livechatt
    • Utbildning
    Försörjningskedja
    • Lager
    • Produktion
    • Produktens livscykel (PLM)
    • Inköp
    • Underhåll
    • Kvalitet
    HR
    • Anställda
    • Rekrytering
    • Ledighet
    • Utvärderingar
    • Rekommendationer
    • Fordon
    Marknadsföring
    • Sociala medier
    • E-postmarknadsföring
    • Sms-marknadsföring
    • Evenemang
    • Automatiserad marknadsföring
    • Enkäter
    Tjänster
    • Projekt
    • Tidrapporter
    • Fältservice
    • Kundtjänst
    • Planering
    • Tidsbokningar
    Produktivitet
    • Diskutera
    • Godkännanden
    • IoT
    • VoIP
    • Kunskap
    • WhatsApp
    Community-appar Odoo Studio Odoo Cloud
  • Branscher
    Butiker
    • Bokaffärer
    • Klädbutiker
    • Möbelaffärer
    • Mataffärer
    • Byggvaruhus
    • Leksaksaffärer
    Restaurang & Hotell
    • Barer och pubar
    • Restauranger
    • Snabbmatsställen
    • Gästhus
    • Dryckesdistributörer
    • Hotell
    Fastigheter
    • Fastighetsbyråer
    • Arkitektfirmor
    • Byggfirmor
    • Fastighetsskötare
    • Trädgårdsmästare
    • Fastighetsägare
    Hitta en konsult
    • Redovisningsbyrå
    • Odoo Partner
    • Reklambyråer
    • Advokatbyråer
    • Rekrytering
    • Revisioner och certifieringar
    Produktion
    • Textilproduktion
    • Metallproduktion
    • Möbelproduktion
    • Matproduktion
    • Bryggerier
    • Företagsgåvor
    Hälsa & Fitness
    • Sportklubbar
    • Optiker
    • Fitnesscenter
    • Hälsovårdare
    • Apotek
    • Frisörsalonger
    Hantverk
    • Hantverkare
    • IT-utrustning & kundtjänst
    • Solkraftverk
    • Skomakare
    • Städtjänster
    • VVS-tjänster
    Övrigt
    • Ideella föreningar
    • Miljöförvaltningar
    • Uthyrning av reklamtavlor
    • Fotografer
    • Cykeluthyrning
    • Återförsäljare av mjukvara
    Upptäck alla Branscher
  • Community
    Utbildning
    • Instruktionsvideor
    • Dokumentation
    • Certifiering
    • Utbildningar
    • Blogg
    • Podcast
    Lär dig med oss
    • Workshops
    • Företagsspelet Scale Up!
    • Studiebesök hos Odoo
    Mjukvaran
    • Ladda ner
    • Jämför utgåvor
    • Tidigare utgåvor
    Samverkan
    • GitHub
    • Forum
    • Evenemang
    • Översättningar
    • Bli en partner
    • Partnertjänster
    • Registrera din redovisningsbyrå
    Våra tjänster
    • Partners
    • Revisorer
    • Träffa en rådgivare
    • Implementering
    • Kundrecensioner
    • Kundtjänst
    • Uppgraderingar
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Boka en demo
  • Priser
  • Hjälp
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

[custom code] AttributeError: 'str' object has no attribute 'get' while creating new record

Subscribe

Get notified when there's activity on this post

This question has been flagged
automatedcreaterecordBug
2 Replies
2752 Views
Avatar
Johnny Solas

So Im working on this code that creates new record in 'sign.send.request.signer' model. I currently use some test data

data = {
    "role_id" : 1,
    "partner_id" : 14,
    "mail_sent_order" : 1,
}


# Create the record in sign.send.request.signer
env['sign.send.request.signer'].create(data)


Whenever I run this manually an error shows up


Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 390, in safe_eval
    return unsafe_eval(c, globals_dict, locals_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ir.actions.server(899,)", line 29, in <module>
  File "/mnt/enterprise_addons/sign/wizard/sign_send_request.py", line 230, in create
    if not vals.get('partner_id'):
           ^^^^^^^^
AttributeError: 'str' object has no attribute 'get'


I assume the error tells me I'm passing a string and not a dictionary when creating a record. However its pretty obvious that Im passing 'data' and its a dictionary. Did I skip something or do something wrong? Or is this a bug?  

0
Avatar
Discard
Avatar
Yatrik Chauhan
Best Answer

Hello Johnny Solas,

Please replace your code with the one below and give it a try:

data = [{
    "role_id": 1,
    "partner_id": 14,
    "mail_sent_order": 1,
}]

# Create the record in sign.send.request.signer
env['sign.send.request.signer'].create(data)

Let me know if this works for you.

Thanks!

0
Avatar
Discard
Johnny Solas
Author

Wow It works, but there is a new error message shows up

"odoo.exceptions.ValidationError: You must specify one signer for each role of your sign template"

After applying you solution this is my code

# Create the sign send request
send_request_data = {
"template_id": int(payload.get("template_id")),
"subject": "test Subject",
"filename": "test.pdf",
}

send_request = env["sign.send.request"].create(send_request_data)

signer_data = [{
"role_id": 1, # Assuming this is a required role ID in your case
"partner_id": int(payload.get("partner_id")),
"mail_sent_order": 1,
"sign_send_request_id": send_request.id
}]

signer = env["sign.send.request.signer"].create(signer_data)
send_request.send_request()

What could be the problem in this?

Yatrik Chauhan

Hello,

In Odoo, there's a method called _check_signers_roles_validity, which is triggered when the send_request() method is called. This method verifies that each signing role defined in a sign template has exactly one corresponding signer assigned when a sign request is created. If this condition is not met, a ValidationError is raised.

Example Scenarios:
- Valid Case:
The template includes 3 roles (Manager, HR, Employee).
The sign request has 3 signers, each correctly assigned to one of these roles.

- Invalid Case 1:
The template has 3 roles, but the sign request only includes 2 signers → Error raised.

- Invalid Case 2:
The template has no roles defined, but the sign request does not include at least one signer with the default role → Error raised.

I hope this will helpfull for you.

Thanks!

Avatar
Mathesh
Best Answer

Hello Johnny Solas,

Try to put something like this:

def create_records(self):
data = {
"role_id": 1,
"partner_id": 14,
"mail_sent_order": 1,
}
self.env['sign.send.request.signer'].create(data)

  Make sure to call the function and verify that the model and field are available.

Thank you,

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Auto generated quotation
automated create quotation record sales.order
Avatar
0
juli 21
5743
Create co-record on create(self,vals) model
create mrp record
Avatar
Avatar
1
jan. 20
6453
Set Deadline in 14 days when task is created in specific project
action automated create
Avatar
1
jan. 17
5545
how to change the order who one2many create new records with editable=“bottom”?
one2many create record
Avatar
0
sep. 15
4840
On Creation Automated Action not Triggering
action automated create studio
Avatar
0
dec. 24
6387
Community
  • Instruktionsvideor
  • Dokumentation
  • Forum
Öppen källkod
  • Ladda ner
  • GitHub
  • Runbot
  • Översättningar
Tjänster
  • Odoo.sh Hosting
  • Kundtjänst
  • Uppgradera
  • Anpassningsbara modifikationer
  • Utbildning
  • Revisorer
  • Partners
  • Bli en partner
Om oss
  • Vårt företag
  • Varumärkestillgångar
  • Kontakta oss
  • Jobb
  • Evenemang
  • Podcast
  • Blogg
  • Kunder
  • Juridiskt • Integritet
  • Säkerhet
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo är ett affärssystem med öppen källkod som täcker alla dina företagsbehov: CRM, e-handel, bokföring, lager, kassasystem, projektledning, och så vidare.

Odoos unika värdeförslag är att samtidigt vara väldigt enkel att använda men också helt integrerad.

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