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

Problem with module in V7 and other in V8

Subscribe

Get notified when there's activity on this post

This question has been flagged
performancev8modulefieldsv7
3815 Views
Avatar
Algode

I have a Module1 in V7, this is part of the code, when call a function of Module2 in V8:

#--Code in Module1 
class calc_hours_employees(models.Model): _name = 'calc.hours.employees' _description = 'Somes computes' employees_ids = fields.Many2many('hr.employee', 'hr_employee_calcs_rel', 'calcs_id', 'employee_id', 'Funcionarios')
   def compute_sheet(self, cr, uid, ids, context=None): emp_pool = self.pool.get('hr.employee') ext_pool = self.pool.get('hr.py.calc.hours') run_pool = self.pool.get('hr.py.calc.hours.run') ext_ids = [] if context is None: context = {} data = self.read(cr, uid, ids, context=context)[0] run_data = {} if context and context.get('active_id', False): run_data = run_pool.read(cr, uid, [context['active_id']], ['date_start', 'date_end'])[0] from_date = run_data.get('date_start', False) to_date = run_data.get('date_end', False)
        if not data['employees_ids']:     raise osv.except_osv(_("Warning!"), _("Select one, please"))
        for emp in emp_pool.browse(cr, uid, data['employees_ids'], context=context)
           ext_data = ext_pool.do_employee(cr, uid, [], 2, emp.id, from_date, to_date, emp.department_id, emp.id_inter, contract_id=False, context=context     
            res = {     
                'employee': emp.id,     
                'office': emp.department_id.name,     
                'matricu': emp.id_inter,     
                'date_from': from_date,      
                'date_to': to_date,     
                'calcs_run_ids': context.get('active_id', False),      
            }     ext_ids.append(ext_pool.create(cr, uid, res, context=context)
    return {'type': 'ir.actions.act_window_close'}

And this is a part of code that have the function do_employee():

#--Part of code in Module2  
class hr_py_calc_hours(models.Model): _name = 'hr.py.calc.hours'

employee = fields.Many2one('hr.employee', string='Employee', required=True)
hor_repo = fields.Float('Hor Repo', digits=(16,2), default=0.0)
#####have more fields but not is necesary for the example :)
....
    @api.multi
    @api.onchange('employee')
    def do_employee(self, type_calc=1, emp_id=False, from_date=False, to_date=False, emp_off=False, emp_matr=False, contract_id=False, context=None):     def _do_create(date1,turnid,ent,sal,work,rep,abse,ear,bef,att,ad30,ex50,ex100,hours_to_create):     hours_to_create += [((0,0,{'date_work':date1,'turno_id':turnid,'entrad':ent,'salida':sal,'times_worked':work,'repose':rep,'absence':abse,'early':ear, 'before':bef,'attestation':att,'adic_30':ad30,'ext_50':ex50,'ext_100':ex100}))]
....
        if not type_calc==1:     repo = self.get('hor_repo',0) ############ HERE ARE THE PROBLEM self.write({'hor_repo': repo + ocho}) else: self.hor_repo += ocho datew += timedelta(days=1)
.....

The function of Module2 need can execute from the onchange employee, and need can execute from the Module1. 

I need the value of hor_repo for increase this at one to somes computes, them i need take the value at the moment in the field an increase this. 

I see in many parts from google but all is only for V7 or only for V8. How can solve this problem ? 


Posd.: This module is similar to performance of the payslip, need can do only for a employee(as module hr.payslip) or for more that one in the same time(as module hr.payslip.run). 


Edit: Nothing ?





0
Avatar
Discard
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
Can V7 and V8 code coexist in the same .py file? Solved
v8 fields v7 api
Avatar
Avatar
1
Mar 15
4778
Problem to write datas in field
v8 module field v7 write
Avatar
0
Jun 15
3926
Loading wrong configuration file? Solved
v8 v7
Avatar
Avatar
1
Apr 15
9351
"No handler found" - CRITICAL ? openerp.modules.module - How to downgrade/uninstall a module in command line?
module v7
Avatar
Avatar
1
Mar 15
7804
new module doesn't show in module list? Solved
module v7
Avatar
Avatar
Avatar
3
Dec 23
30752
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