~florent.x/oerpscenario/trunk-with-buildout2

« back to all changes in this revision

Viewing changes to features/steps/dsl.py

  • Committer: Alexandre Fayolle
  • Author(s): Nicolas Bessi
  • Date: 2013-01-29 08:46:52 UTC
  • mfrom: (294.1.1 tmp-trunk-python)
  • Revision ID: alexandre.fayolle@camptocamp.com-20130129084652-5omtmqiy5qskda2w
[MRG] fix support of property by company in DSL

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
            Model.write(ids, new_attrs)
166
166
 
167
167
 
168
 
def get_company(ctx, pname, modelname, fieldname, company_oid=None):
 
168
def get_company_property(ctx, pname, modelname, fieldname, company_oid=None):
169
169
    company = None
170
170
    if company_oid:
171
171
        c_domain = build_search_domain(ctx, 'res.company', {'xmlid': company_oid})
178
178
              ('res_id', '=', False)]
179
179
    if company:
180
180
        domain.append(('company_id', '=', company.id))
181
 
    property = model('ir.property').get(domain)
182
 
    if property is None:
183
 
        property = model('ir.property').create({'fields_id': field.id,
184
 
                                                'name': pname,
185
 
                                                'res_id': False,
186
 
                                                'type': 'many2one'})
 
181
    ir_property = model('ir.property').get(domain)
 
182
    if ir_property is None:
 
183
        ir_property = model('ir.property').create({'fields_id': field.id,
 
184
                                                   'name': pname,
 
185
                                                   'res_id': False,
 
186
                                                   'type': 'many2one'})
187
187
        if company:
188
 
            property.write({'company_id': company.id})
189
 
    ctx.property = property
 
188
            ir_property.write({'company_id': company.id})
 
189
    ctx.ir_property = ir_property
190
190
 
191
191
@given('I set global property named "{pname}" for model "{modelname}" and field "{fieldname}" for company with ref "{company_oid}"')
192
192
def impl(ctx, pname, modelname, fieldname, company_oid):
193
 
    get_company(ctx, pname, modelname, fieldname, company_oid=company_oid)
 
193
    get_company_property(ctx, pname, modelname, fieldname, company_oid=company_oid)
194
194
 
195
195
@given('I set global property named "{pname}" for model "{modelname}" and field "{fieldname}"')
196
196
def impl(ctx, pname, modelname, fieldname):
197
 
    get_company(ctx, pname, modelname, fieldname)
 
197
    get_company_property(ctx, pname, modelname, fieldname)
198
198
 
199
199
@step('the property is related to model "{modelname}" using column "{column}" and value "{value}"')
200
200
def impl(ctx, modelname, column, value):
201
 
    assert hasattr(ctx, 'property')
202
 
    property = ctx.property
 
201
    assert hasattr(ctx, 'ir_property')
 
202
    ir_property = ctx.ir_property
203
203
    res = model(modelname).get([(column, '=', value)])
204
204
    assert res, "no value for %s value %s" % (column, value)
205
 
    property.value_reference = '%s,%s' % (modelname, res.id)
 
205
    ir_property.write({'value_reference': '%s,%s' % (modelname, res.id)})