Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Get the new status.

Naroči se

Get notified when there's activity on this post

This question has been flagged
developmentpythoncronormodoo
4752 Prikazi
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
Opusti
Mostafa Mohamed Abdel Monaem
Avtor

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!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
I can't identify which class have this errors
development modules python orm odoo
Avatar
Avatar
Avatar
2
sep. 16
7603
How to refresh form view automatic Solved
development python orm odoo odooV8
Avatar
Avatar
Avatar
3
apr. 15
11006
Military states module -- help :D Solved
development modules python orm odoo
Avatar
Avatar
1
mar. 15
5003
How to add field in 2 tables same time?
python orm odoo
Avatar
0
apr. 15
4251
Can't see opportunity that created by others even i have see all leads permission?
development python domain odoo
Avatar
0
apr. 22
4233
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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