Odoo Help

0

1
2 Answers
1
Dharmesh Rathod
29/5/13 15:23

hi,

Are you going to create records from XML and trying to filling selection field ?

thanks

3 Comments
mike
29/5/13 15:35

Hi, I want to use data from XML as default values for the selection field. In my case requirements specifies an address field for County but the business area only includes 14 counties in the state. But the business area may expand to include more counties and states. They want to be able to add new Counties to an XML file as needed.

Ray Carnes
29/5/13 15:38

I think it might be better to define a new model that stores county names. Then you can add new ones via the UI or via XML or via CSV as needed. You can then relate (via a many2one field) this model to the partner so it can be part of the address.

mike
29/5/13 15:46

Yes, I agree. After looking how the state and country fields are based on models through many2one it would make sense to incorporate counties the same way. Then when they need to add counties for other states the county and state models can reference one another. However, in bringing across legacy data from an old app there are very many pesky little lookup tables with mostly static data which I don't see a reason to model but yet wouldn't want to hard-code as global constants. Any suggestions for these?

0
mike
29/5/13 16:25

Ok Dharmesh and Ray, I think I see the light (in OpenERP colors). I need a model for each of my pesky lookup tables. Then based on the XML snippet I posted above I create the records as found in crm_lead_data.xml e.g.

<!-- Crm stages -->
<record model="crm.case.stage" id="stage_lead1">
    <field name="name">New</field>
    <field eval="1" name="case_default"/>
    <field name="state">draft</field>
    <field eval="'10'" name="probability"/>
    <field eval="'10'" name="sequence"/>
    <field name="type">both</field>
</record>

Then implement a "default loader" as in crm.py e.g.

def _get_stage_common(self, cr, uid, context):
    ids = self.pool.get('crm.case.stage').search(cr, uid, [('case_default','=',1)], context=context)
    return ids

_defaults = {
    'active': 1,
    'stage_ids': _get_stage_common,
    'alias_domain': False, # always hide alias during creation
}

And define the proper column type e.g.

_columns = {
'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'),
}

And after all this I'll have a field that can hold selectable values which can be updated via the data.xml file. Is this correct?

1 Comment
Dharmesh Rathod
29/5/13 23:15

Country table is already exist into openerp. You can add missing one by xml.

Ask a Question
Writer
441
mike
Keep Informed
0 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now