Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Artificial Intelligence
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Property Management
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

How to convert Islamic date to Hijri date using python code?(My code shows error)

Subscriure's

Get notified when there's activity on this post

This question has been flagged
1 Respondre
13574 Vistes
Avatar
Remya

I have two textbox.

In first textbox i'll manually enter islamic date, at the same time on the second textbox it changes to geogorian date.

I wrote code for it, but its shows error.

from openerp.osv import fields, osv

import math

def intPart(floatNum):

    if floatNum < -0.0000001: return math.ceil(floatNum - 0.0000001)

    return math.floor(floatNum + 0.0000001)

def Hijri2Gregorian(yr,mth,day):

    jd1 = intPart((11 * yr + 3) / 30.0)

    jd2 = intPart((mth - 1) / 2.0)

    jd = jd1 + 354 * yr + 30 * mth - jd2 + day + 1948440 - 385

    if jd > 2299160:

    l = jd + 68569

    n = intPart((4 * l) / 146097.0)

    l = l - intPart((146097 * n + 3) / 4.0)

    i = intPart((4000 * (l + 1)) / 1461001.0)

    l = l - intPart((1461 * i) / 4.0) + 31

    j = intPart((80 * l) / 2447.0)

    d = l - intPart((2447 * j) / 80.0)

    l = intPart(j / 11.0)

    m = j + 2 - 12 * l

    y = 100 * (n - 49) + i + l

    else:

    j = jd + 1402

    k = intPart((j - 1) / 1461.0)

    l = j - 1461 * k

    n = intPart((l - 1) / 365.0) - intPart(l / 1461.0)

    i = l - 365 * n + 30

    j = intPart((80 * i) / 2447.0)

    d = i - intPart((2447 * j) / 80.0)

    i = intPart(j / 11.0)

    m = j + 2 - 12 * i

    y = 4 * k + n + i - 4716

    return y, m, d

 

class hr_extra(osv.osv):

_inherit = "hr.employee"

def _get_hijr_date(self, cr, uid, ids, name, arg,context=None):

res = {}

for self_data in self.browse(cr, uid, ids, context=context):

    islamic_date = self_data.islamic_date

    # get Pass yesr, month and day in this function

    Hijri2Gregorian(yr,mth,day)

   return res

_columns = {

    'islamic_date' : fields.char('Islamic Date'),

    'english_date' : fields.function(Hijri2Gregorian,'English Date'), }

hr_extra()

 

Error: TypeError: Hijri2Gregorian() takes exactly 3 arguments (7 given)

 

Updated Code

 

class hr_extra(osv.osv):

_inherit = "hr.employee"

def _get_hijri_date(self, cr, uid, ids, name, args, context=None):

    res = {}

    for self_data in self.browse(cr, uid, ids, context=context):

        islamic_date = self_data.islamic_date

        islamic_date = '%.2f' % islamic_date

        list = str(islamic_date).split('.')

        yr = islamic_date(int(list[0]))

        mth = islamic_date(int(list[1]))

        day = islamic_date(int(list[2]))

        # get Pass yesr, month and day in this function

        #yr = 1428

        #mth = 1

        #day = 2

Hijri2Gregorian(yr,mth,day)

return res _

columns = {

    'islamic_date' : fields.char('Islamic Date'),

    'english_date' : fields.function(_get_hijri_date,type='date', select=True,string='English Date'), }

hr_extra()

 

Is this code correct?? Please help me...

1
Avatar
Descartar
Senthilnathan

update the log or error message for ur updated code ?

Remya
Autor

Module installed: When i click on the existing employee. It shows error: File "/opt/openerp/server/openerp/addons/date22/hr_date.py", line 52, in _get_hijri_date list = islamic_date.split('.') AttributeError: 'bool' object has no attribute 'split'

Remya
Autor

When i created new employee and give islamic date as 1428.1.2, then save. i got error: File "/opt/openerp/server/openerp/addons/date22/hr_date.py", line 53, in _get_hijri_date yr = islamic_date(str(list[0])) TypeError: 'unicode' object is not callable

Remya
Autor

Any idea, senthilnathan?

Senthilnathan

if it says bool then there is no data so it can't split

Senthilnathan

unicode error means u need to convert it before passing print type of the value passed and check

Remya
Autor

Did you know the code?

Remya
Autor

Did you know solve the issue?

Remya
Autor

How i convert these values?

hesham@elmahdy.info

Did you mean to Hijri to Gregorian?

Avatar
Med Said BARA
Best Answer

Could you try this:

class hr_extra(osv.osv):

_inherit = "hr.employee"

 def _get_hijri_date(self, cr, uid, ids, name, args, context=None):

      res = {}

      for self_data in self.browse(cr, uid, ids, context=context):

          islamic_date = self_data.islamic_date

          list = str(islamic_date).split('.')

         yr = int(list[0])

         mth = int(list[1])

         day =int(list[2])

         # get Pass yesr, month and day in this function

         #yr = 1428

         #mth = 1

         #day = 2

        Hijri2Gregorian(yr,mth,day)

return res

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

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

Registrar-se
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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