creating global variable

Asked by Bushair

Hi,
I have the following code in hr_payroll.py file

class hr_contract(osv.osv):

    _inherit = 'hr.contract'
    _description = 'Employee Contract'

    _columns = {
        'permit_no':fields.char('Work Permit No', size=256, required=False, readonly=False),
        'passport_id':fields.many2one('hr.passport', 'Passport', required=False),
        'visa_no':fields.char('Visa No', size=64, required=False, readonly=False),
        'visa_expire': fields.date('Visa Expire Date'),
        'function' : fields.many2one('hr.employee.grade', 'Function'),
        'working_days_per_week': fields.integer('Working Days / Week'),
        'working_hours_per_day':fields.integer('Working Hours / Day'),
    }

I would like to make the working_days_per_week field as global since i want to check the working _days _per _week =6 or 7.

Can you please tell me the syntax to make this change.?

Will the folliwing code changes will do it?

class hr_contract(osv.osv):

    _inherit = 'hr.contract'
    _description = 'Employee Contract'
    global working_days_per_week
    _columns = {
        'permit_no':fields.char('Work Permit No', size=256, required=False, readonly=False),
        'passport_id':fields.many2one('hr.passport', 'Passport', required=False),
        'visa_no':fields.char('Visa No', size=64, required=False, readonly=False),
        'visa_expire': fields.date('Visa Expire Date'),
        'function' : fields.many2one('hr.employee.grade', 'Function'),
        'working_days_per_week': fields.integer('Working Days / Week'),
        'working_hours_per_day':fields.integer('Working Hours / Day'),
    }

Thanks

Question information

Language:
English Edit question
Status:
Answered
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) said :
#1

hello,

Currently this code is not completed it is in progress because in days calculation code this defined object is not used yet.

Thanks.

Revision history for this message
Washington Vinicio Guijarro Guaman (wguijarro) said :
#2

how to create o declare global variable in file .py; becaause I need to use in diferents class of my .py, for example, mymodule.py has 4 class and I want to use a variable y all module.....

Can you help with this problem?

Provide an answer of your own, or ask Bushair for more information if necessary.

To post a message you must log in.