Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
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

Get the new status.

Subscribe

Get notified when there's activity on this post

This question has been flagged
developmentpythoncronormodoo
4663 Views
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
Discard
Mostafa Mohamed Abdel Monaem
Author

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!

Sign up
Related Posts Replies Views Activity
I can't identify which class have this errors
development modules python orm odoo
Avatar
Avatar
Avatar
2
Sep 16
7520
How to refresh form view automatic Solved
development python orm odoo odooV8
Avatar
Avatar
Avatar
3
Apr 15
10904
Military states module -- help :D Solved
development modules python orm odoo
Avatar
Avatar
1
Mar 15
4932
How to add field in 2 tables same time?
python orm odoo
Avatar
0
Apr 15
4144
Can't see opportunity that created by others even i have see all leads permission?
development python domain odoo
Avatar
0
Apr 22
4169
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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