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
    • Validacions
    • 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ó
    • Gestió immobiliària
    • 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

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
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

Get the new status.

Subscriure's

Get notified when there's activity on this post

This question has been flagged
developmentpythoncronormodoo
4665 Vistes
Avatar
Mostafa Mohamed Abdel Monaem

Here is my code so far i create statues field with many values the default is 'underage'and i make cron function (get_age_comp)  if the condition true the statues should be changed to ('getCard')  my challenge now to add these who their status changed to('getCard') to new model table called (' fci_military_states') and from there i can change the status to the 3rd status ('gotCard') and finally when i change the status in the this table the record must deleted automatic and the status change in the first table (fci_student)to ('gotCard').

**My student model**

    from openerp.osv import osv, fields
    from openerp import api
    from datetime import date
    from dateutil.relativedelta import relativedelta
    
    
    class fci_student(osv.osv):
        _name = 'fci.student'
        _columns = {
            'photo': fields.binary(string='Photo'),
            'name': fields.char(size=128, string='First Name', required=True),
            'middle_name': fields.char(size=128, string='Middle Name', required=True),
            'last_name': fields.char(size=128, string='Last Name', required=True),
            'status': fields.Selection([('under_Age', 'UnderAge'), ('get_card', 'GetCard'), ('got_card', 'GotCard')],
                                       'Military Status'
                                       , default='under_Age'),
            # basic details
            "birth_date": fields.date(string='Birth Date', required=True),
            'gender': fields.selection([('m', 'Male'), ('f', 'Female'), ('o', 'Other')], string='Gender', required=True),
            'Paid': fields.boolean('Paid Student'),
            'nationality': fields.many2one('res.country', string='Nationality'),
            'id_number': fields.char(size=64, string='ID Card Number', required=True),
            'phone': fields.char(string='Phone Number', size=256, required=True),
            'email_address': fields.char(string='E-mail', size=256, required=True),
            'pay_amount': fields.char(size=64, string='Payment', required=True),
            # Edictional details
            'standard_id': fields.many2one('fci.standard', string='Standard', required=True),
            'term_id': fields.many2one('fci.terms', string='Terms', required=True),
            # Parent details
            'parent_name': fields.char(size=128, string='Parent First Name', required=True),
            'parent_middle_name': fields.char(size=128, string='Parent First Name', required=True),
            'parent_last_name': fields.char(size=128, string='Parent First Name', required=True),
            'parent_phone': fields.integer(size=128, string='Parent Number', required=True),
            'parent_ids': fields.char(size=128, string='Parent E-mail', required=True),
            # Library details
            'library_card_number': fields.char(size=64, string='Library Card Number'),
            'library_card_type': fields.char(size=64, string='Library Card type'),
            'number_of_books_allow': fields.char(size=64, string='Number of books allow'),
            # Address details
            'street_name': fields.char(size=128, string='Street', required=True),
            'city_name': fields.char(size=128, string='City', required=True),
            'state_name': fields.char(size=128, string='State', required=True),
            'Zip': fields.char(size=128, string='Zip Code'),
            'country': fields.char(size=128, string='country', required=True),
    
        }
    
    
    fci_student()
    
    @api.model
    def get_age_comp(self):  # cron function
        self.search([('gender', '=', 'm'), ('status', '=', 'under_Age'),
                     ('birth_date', '>=', date.today() - relativedelta(years=20))
        ]).write({'status': 'get_card'})
    def add_another_table(self):
        to_add = {}
        for student in self.search([('gender','=','m'), ('birth_date', '<=', date.today() - relativedelta(years=20)),
                                    ('status', '=', 'get_card')]):
            to_add[student.name] = student.status
            military_model = self.pool.get('fci.military.states')
        for name, birth_date,standard_group,standard_id,status in to_add.iteritems():
            military_model.create({'name': name, 'birth_date': birth_date,'standard_group':standard_group
            ,'standard_id':standard_id,'status':status})

**My military status model**


        from openerp.osv import osv, fields
    from openerp import api
    
    class fci_military_states(osv.osv):
        _name = 'fci.military.states'
        _rec_name = 'statues'
        _columns = {
            'statues': fields.Selection([('under_Age', 'UnderAge'),('get_card', 'GetCard'),('got_card', 'GotCard')],
                                        'Military Status', default='get_card'),
            'standard_group':fields.many2one('fci.standard.group',string='Group',requierd=True),
            'standard_id': fields.many2one('fci.standard', string='Standard', required=True),
            'student_id': fields.many2one('fci.student', string='Student', required=True),
    
        }
    @api.model
    def del_reco(self):
        to_add = {}
        for student in self.search([('gender', '=', 'm'), ('status', '=', 'got_card')]):
            to_add[student.name] = student.status
            military_model = self.pool.get('fci.student')
        for status in to_add.iteritems():
            military_model.write({'status':status})
        self.search([('gender', '=', 'm'), ('status', '=', 'got_card')]).unlink()

0
Avatar
Descartar
Mostafa Mohamed Abdel Monaem
Autor

Edited 14-2 3:49 AM Any help ?

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
Related Posts Respostes Vistes Activitat
I can't identify which class have this errors
development modules python orm odoo
Avatar
Avatar
Avatar
2
de set. 16
7520
How to refresh form view automatic Solved
development python orm odoo odooV8
Avatar
Avatar
Avatar
3
d’abr. 15
10905
Military states module -- help :D Solved
development modules python orm odoo
Avatar
Avatar
1
de març 15
4934
How to add field in 2 tables same time?
python orm odoo
Avatar
0
d’abr. 15
4144
Can't see opportunity that created by others even i have see all leads permission?
development python domain odoo
Avatar
0
d’abr. 22
4169
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 ภาษาไทย 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