Merge lp:~camptocamp/oerpscenario/trunk-python-add_default_values_step-afe into lp:oerpscenario

Proposed by Alexandre Fayolle - camptocamp
Status: Merged
Merged at revision: 328
Proposed branch: lp:~camptocamp/oerpscenario/trunk-python-add_default_values_step-afe
Merge into: lp:oerpscenario
Diff against target: 25 lines (+18/-0)
1 file modified
features/steps/dsl.py (+18/-0)
To merge this branch: bzr merge lp:~camptocamp/oerpscenario/trunk-python-add_default_values_step-afe
Reviewer Review Type Date Requested Status
Leonardo Pistone code review Approve
Guewen Baconnier @ Camptocamp code review Approve
Yannick Vaucher @ Camptocamp code review, no tests Approve
Review via email: mp+206152@code.launchpad.net

Description of the change

add a new step to set default values for a column in a scenario. The implementation manages per company default (if 'Given I am configuring the company with ref "xxxx"' was used).

To post a comment you must log in.
329. By Alexandre Fayolle - camptocamp

[IMP] example use of the new phrase in docstring

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

LGTM

review: Approve (code review, no tests)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Thanks, LGTM

review: Approve (code review)
Revision history for this message
Leonardo Pistone (lepistone) wrote :

ok!
thanks

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'features/steps/dsl.py'
2--- features/steps/dsl.py 2013-11-21 13:27:12 +0000
3+++ features/steps/dsl.py 2014-02-13 11:31:21 +0000
4@@ -314,3 +314,21 @@
5 @step('I delete it')
6 def impl(ctx):
7 ctx.found_item.unlink()
8+
9+@step('I set the default value for "{modelname}"."{column}" to {value}')
10+def impl(ctx, modelname, column, value):
11+ """
12+ Example:
13+ Scenario: set default values for products, the list price is only set for company2
14+ Given I set the default value for "product.product"."type" to 'product'
15+ And I set the default value for "product.product"."cost_method" to 'average'
16+ Given I am configuring the company with ref "scen.company2"
17+ And I set the default value for "product.product"."list_price" to 12.4
18+ """
19+ if hasattr(ctx, 'company_id'):
20+ company_id = ctx.company_id
21+ else:
22+ company_id = False
23+ ir_value_obj = model('ir.values')
24+ value = eval(value)
25+ ir_value_obj.set_default(modelname, column, value, company_id=company_id)

Subscribers

People subscribed via source and target branches

to all changes: