This question has been flagged
2 Replies
9734 Views

Currently both the 'Home Address' data in the Personal Information tab and the 'Working Address' data in the Public Information tab draw their data from the address fields in the matching 'Contact' form (which is I gather from the table 'res_partner').

I want the two fields to show different data - location of our business in 'Working Address' and the employees own private address in 'Home Address'. Is this possible? I can create new fields (x_privateemployeeaddress for example) and include them in the employee form, but is this the only way?

Thanks,

Bill.

Avatar
Discard

I would suggest you should create custom module and in that module inherit employee object and view.

Author

Thanks Sudhir. Unfortunately I'm not advanced enough to be creating custom modules yet. I thought there might be an easy way (no coding that is) to change where that field pulls its data from.

Best Answer

Hi Bill,

    you can specify different formats for different countries by change the field: **address_format** in the model: **res.country**.

Cheers.

Avatar
Discard
Best Answer

In order to hide Employee addresses from Customer and Supplier list, you can Uncheck 'Customer' and 'Supplier' from Partner form.

I solved with following code

class hr_employee(osv.osv):
    _inherit = "hr.employee"

    def create(self, cr, uid, data, context=None):
        if 'address_id' in data and data['address_id']:
            partner_ids = [data['address_id']]
            if 'address_home_id' in data and data['address_home_id']:
                partner_ids.append(data['address_home_id'])

            self.pool.get('res.partner').write(cr, uid, partner_ids, {'customer': False, 'supplier':False}, context=context)
        return super(hr_employee, self).create(cr, uid, data, context=context)

    def write(self, cr, uid, ids, data, context=None):
        if 'address_id' in data and data['address_id']:
            partner_ids = [data['address_id']]
            if 'address_home_id' in data and data['address_home_id']:
                partner_ids.append(data['address_home_id'])

            self.pool.get('res.partner').write(cr, uid, partner_ids, {'customer': False, 'supplier':False}, context=context)
        return super(hr_employee, self).write(cr, uid, ids, data, context=context)

So that whenever you create new employee, that addresses of employee does treat as neither customer nor supplier. You have to manually correct for existing employee addresses.

Avatar
Discard
Author

Thanks for your answer Arif. Would I be right in assuming that this code is inserted into an existing file in the OpenERP installation? It might be out of my league if that is the case.

Better to keep it in your own module instead of adding in existing file. You can find easily many documents and community answers on how to create custom module.

Otherwise you have to manually edit (Un check Customer ) for all employees contacts.