Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Invalid synthax,

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
3 Răspunsuri
1447 Vizualizări
Imagine profil
Alex Abdelouas

Hello everyone and thanks you in advance for your precious help.


I have an issue that i cant figure it out. I want to create a field that calculate the difference between 2 dates which are also on 2 different field in order to obtain the difference between those 2 dates and write the result on a third field.

When i try to change the dates, the error is : 

The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/odoo/src/odoo/15.0/odoo/http.py", line 654, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/odoo/src/odoo/15.0/odoo/http.py", line 301, in _handle_exception
    raise exception.with_traceback(None) from new_cause
  File "", line 1
    for record in self
                     ^
SyntaxError: invalid syntax

-------------The code

for record in self:
date1 = record.x_studio_entr_date_rencontre_prospect # first date's field
date2 = record.x_studio_sortie_date_fiche_collecte_rceptionne_1 # second date's field
 
if date1 and date2 and (isinstance(date1, datetime.date)) and (isinstance(date2, datetime.date)): #control both fields are not empty 
difference = date2-date1
difference_jours = difference.days #calcul the difference
record['x_studio_kpi_1'] = difference_jours 
 
else : 
record['x_studio_kpi_1'] = 0



0
Imagine profil
Abandonează
Alex Abdelouas
Autor
Hello, 

Thanks you for your answer, unfortunnaly it doesnt work. The errors when i compute is : 

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/odoo/src/odoo/15.0/odoo/http.py", line 654, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/odoo/src/odoo/15.0/odoo/http.py", line 301, in _handle_exception
    raise exception.with_traceback(None) from new_cause
ValueError: forbidden opcode(s) in 'lambda': STORE_ATTR


Rithik Sandron

Hi Alex,

Is this a computed field?

Imagine profil
Alex Abdelouas
Autor Cel mai bun răspuns

Yes it is, we want to calculate the difference between two dates, and those two dates may change many times for the same form and therefore the difference will need to be calculated again.


Thanks you a lot for your help.



0
Imagine profil
Abandonează
Imagine profil
Support GeminateCS
Cel mai bun răspuns

Hii Alex,
By looking at your syntax error , it is easy to understand that you have implemented the wrong for loop or this loop missing its properties / data,
make sure you provided correct indentation for the for loop.
I hope this information will be helpful to you.
Feel free for further assistance at contact@geminatecs.com

Thank You, 
Geminate Consultancy Services
w : www.geminatecs.com

0
Imagine profil
Abandonează
Imagine profil
Rithik Sandron
Cel mai bun răspuns

Try this:

x_studio_entr_date_rencontre_prospect = fields.Datetime(string='Date 1')
x_studio_sortie_date_fiche_collecte_rceptionne_1 = fields.Datetime(string='Date 2')
x_studio_kpi_1 = fields.Integer(string='Difference')

def calculate_date_difference(self):
​for record in self:
​ date1 = record.x_studio_entr_date_rencontre_prospect
​ ​date2 = record.x_studio_sortie_date_fiche_collecte_rceptionne_1

​ ​if date1 and date2:
​ ​ ​​delta = date2 - date1
​ ​ ​record.x_studio_kpi_1 = delta.days
​ ​else:

​ ​ ​record.x_studio_kpi_1 = 0
0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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