Merge lp:~camptocamp/account-financial-tools/7.0-fix-1287072 into lp:~account-core-editors/account-financial-tools/7.0

Proposed by Nicolas Bessi - Camptocamp
Status: Merged
Approved by: Yannick Vaucher @ Camptocamp
Approved revision: 165
Merged at revision: 168
Proposed branch: lp:~camptocamp/account-financial-tools/7.0-fix-1287072
Merge into: lp:~account-core-editors/account-financial-tools/7.0
Diff against target: 96 lines (+57/-2)
3 files modified
account_credit_control/policy.py (+2/-2)
account_credit_control/scenarios/features/10_credit_control_run_aug.feature (+30/-0)
account_credit_control/scenarios/features/steps/account_credit_control.py (+25/-0)
To merge this branch: bzr merge lp:~camptocamp/account-financial-tools/7.0-fix-1287072
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp lgtm Approve
Guewen Baconnier @ Camptocamp code review Approve
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+209183@code.launchpad.net

Description of the change

[FIX] bug 1287072 Level calculation error if previous credit line is ignored

To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

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

LGTM

review: Approve (code review)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) :
review: Approve (lgtm)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_credit_control/policy.py'
2--- account_credit_control/policy.py 2013-12-11 10:34:20 +0000
3+++ account_credit_control/policy.py 2014-03-04 07:54:35 +0000
4@@ -47,7 +47,7 @@
5 " for the selected accounts"),
6 'active': fields.boolean('Active'),
7 }
8-
9+
10 _defaults = {
11 'active': True,
12 }
13@@ -327,7 +327,6 @@
14 data_dict = {'controlling_date': controlling_date,
15 'line_ids': tuple(lines),
16 'delay': level.delay_days}
17-
18 cr.execute(sql, data_dict)
19 res = cr.fetchall()
20 if res:
21@@ -346,6 +345,7 @@
22 " ON (mv_line.id = cr_line.move_line_id)\n"
23 " WHERE cr_line.id = (SELECT credit_control_line.id FROM credit_control_line\n"
24 " WHERE credit_control_line.move_line_id = mv_line.id\n"
25+ " AND state != 'ignored'"
26 " ORDER BY credit_control_line.level desc limit 1)\n"
27 " AND cr_line.level = %(previous_level)s\n"
28 # lines from a previous level with a draft or ignored state
29
30=== added file 'account_credit_control/scenarios/features/10_credit_control_run_aug.feature'
31--- account_credit_control/scenarios/features/10_credit_control_run_aug.feature 1970-01-01 00:00:00 +0000
32+++ account_credit_control/scenarios/features/10_credit_control_run_aug.feature 2014-03-04 07:54:35 +0000
33@@ -0,0 +1,30 @@
34+###############################################################################
35+#
36+# OERPScenario, OpenERP Functional Tests
37+# Copyright 2012 Camptocamp SA
38+# Author Nicolas Bessi
39+##############################################################################
40+
41+# Features Generic tags (none for all)
42+##############################################################################
43+
44+@account_credit_control @account_credit_control_run @account_credit_control_run_aug
45+
46+Feature: Ensure that ignore feature works as expected
47+
48+ @account_credit_control_mark_as_ignore
49+ Scenario: mark last line as ignore
50+ Given I ignore the "Gus Goose" credit line at level "3" for move line "SI_19" with amount "1050.0"
51+
52+ @account_credit_control_run_month_aug
53+ Scenario: Create run
54+ Given I need a "credit.control.run" with oid: credit_control.runignored
55+ And having:
56+ | name | value |
57+ | date | 2013-08-30 |
58+ When I launch the credit run
59+ Then my credit run should be in state "done"
60+
61+ @check_ignored_line
62+ Scenario: Check ignored lines
63+ Given I have for "Gus Goose" "2" credit lines at level "3" for move line "SI_19" with amount "1050.0" respectively in state "draft" and "ignored"
64
65=== modified file 'account_credit_control/scenarios/features/steps/account_credit_control.py'
66--- account_credit_control/scenarios/features/steps/account_credit_control.py 2013-03-28 13:17:04 +0000
67+++ account_credit_control/scenarios/features/steps/account_credit_control.py 2014-03-04 07:54:35 +0000
68@@ -118,3 +118,28 @@
69 lines = model('credit.control.line').search([('state', '!=', state),
70 ('id', 'in', ctx.lines)])
71 assert not lines
72+
73+@given(u'I ignore the "{partner}" credit line at level "{level:d}" for move line "{move_line_name}" with amount "{amount:f}"')
74+def impl(ctx, partner, level, move_line_name, amount):
75+ print ctx, partner, level, move_line_name, amount
76+ to_ignore = model('credit.control.line').search([('partner_id.name', '=', partner),
77+ ('level', '=', level),
78+ ('amount_due', '=', amount),
79+ ('move_line_id.name', '=', move_line_name)])
80+ assert to_ignore
81+ wiz = model('credit.control.marker').create({'name': 'ignored'})
82+ ctx.lines = to_ignore
83+ wiz.write({'line_ids': to_ignore})
84+ wiz.mark_lines()
85+ assert model('credit.control.line').get(to_ignore[0]).state == 'ignored'
86+
87+@given(u'I have for "{partner}" "{number:d}" credit lines at level "{level:d}" for move line "{move_line_name}" with amount "{amount:f}" respectively in state "draft" and "ignored"')
88+def impl(ctx, partner, number, level, move_line_name, amount):
89+ to_check = model('credit.control.line').search([('partner_id.name', '=', partner),
90+ ('level', '=', level),
91+ ('amount_due', '=', amount),
92+ ('move_line_id.name', '=', move_line_name),
93+ ('state', 'in', ('draft', 'ignored'))])
94+ assert_equal(len(to_check), int(number), msg="More than %s found" % number)
95+ lines = model('credit.control.line').browse(to_check)
96+ assert ['ignored', 'draft'] == lines.state

Subscribers

People subscribed via source and target branches