Question

I am using python and xml to create one openerp module. I have created module with number of fields. All fields are readonly fields except customer id field. When I fill customer id in customer field, other field automatically filled. But It does not save all fields values in database except customer id fields.

It will save, when all fields are not readonly It will not save, when all fields are readonly

So What I want

  1. When I enter customer id, Other fields should be filled automatically.
  2. All fields should be readonly except customer id fields.
  3. All values should be saved in database, when click save.

can anyone tell me? what should i do?

Thanks in advance

Was it helpful?

Solution

You can use 'state' varaible and make your required variable as readonly=True for particular 'state'. and change the state to done in create or write function of your class.

eg: In the following code use your variable instead of client_id

class collection_details(osv.osv):
 _name = "collection.details"
 _description = "Collection Details"    
 _columns={
    'state': fields.selection([
            ('draft', 'Draft Sales Order'),
            ('done', 'Done'),
            ], 'Status', readonly=True, invisible=True, track_visibility='onchange',
            help="", select=True),
    'client_id': fields.char('Client Id',size=64,readonly=True,states={'draft': [('readonly', False)]}),
 }
 _defaults = {
        'state': 'draft',
    }

Hope this will help you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top