mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[FIX] bug 1287072 Level calculation error if previous credit line is ignored
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
{'name': 'Account Credit Control',
|
||||
'version': '0.1',
|
||||
'version': '0.1.1',
|
||||
'author': 'Camptocamp',
|
||||
'maintainer': 'Camptocamp',
|
||||
'category': 'Finance',
|
||||
|
||||
@@ -47,7 +47,7 @@ class CreditControlPolicy(Model):
|
||||
" for the selected accounts"),
|
||||
'active': fields.boolean('Active'),
|
||||
}
|
||||
|
||||
|
||||
_defaults = {
|
||||
'active': True,
|
||||
}
|
||||
@@ -327,7 +327,6 @@ class CreditControlPolicyLevel(Model):
|
||||
data_dict = {'controlling_date': controlling_date,
|
||||
'line_ids': tuple(lines),
|
||||
'delay': level.delay_days}
|
||||
|
||||
cr.execute(sql, data_dict)
|
||||
res = cr.fetchall()
|
||||
if res:
|
||||
@@ -346,6 +345,7 @@ class CreditControlPolicyLevel(Model):
|
||||
" ON (mv_line.id = cr_line.move_line_id)\n"
|
||||
" WHERE cr_line.id = (SELECT credit_control_line.id FROM credit_control_line\n"
|
||||
" WHERE credit_control_line.move_line_id = mv_line.id\n"
|
||||
" AND state != 'ignored'"
|
||||
" ORDER BY credit_control_line.level desc limit 1)\n"
|
||||
" AND cr_line.level = %(previous_level)s\n"
|
||||
# lines from a previous level with a draft or ignored state
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
###############################################################################
|
||||
#
|
||||
# OERPScenario, OpenERP Functional Tests
|
||||
# Copyright 2012 Camptocamp SA
|
||||
# Author Nicolas Bessi
|
||||
##############################################################################
|
||||
|
||||
# Features Generic tags (none for all)
|
||||
##############################################################################
|
||||
|
||||
@account_credit_control @account_credit_control_run @account_credit_control_run_aug
|
||||
|
||||
Feature: Ensure that ignore feature works as expected
|
||||
|
||||
@account_credit_control_mark_as_ignore
|
||||
Scenario: mark last line as ignore
|
||||
Given I ignore the "Gus Goose" credit line at level "3" for move line "SI_19" with amount "1050.0"
|
||||
|
||||
@account_credit_control_run_month_aug
|
||||
Scenario: Create run
|
||||
Given I need a "credit.control.run" with oid: credit_control.runignored
|
||||
And having:
|
||||
| name | value |
|
||||
| date | 2013-08-30 |
|
||||
When I launch the credit run
|
||||
Then my credit run should be in state "done"
|
||||
|
||||
@check_ignored_line
|
||||
Scenario: Check ignored lines
|
||||
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"
|
||||
@@ -118,3 +118,28 @@ def impl(ctx, state):
|
||||
lines = model('credit.control.line').search([('state', '!=', state),
|
||||
('id', 'in', ctx.lines)])
|
||||
assert not lines
|
||||
|
||||
@given(u'I ignore the "{partner}" credit line at level "{level:d}" for move line "{move_line_name}" with amount "{amount:f}"')
|
||||
def impl(ctx, partner, level, move_line_name, amount):
|
||||
print ctx, partner, level, move_line_name, amount
|
||||
to_ignore = model('credit.control.line').search([('partner_id.name', '=', partner),
|
||||
('level', '=', level),
|
||||
('amount_due', '=', amount),
|
||||
('move_line_id.name', '=', move_line_name)])
|
||||
assert to_ignore
|
||||
wiz = model('credit.control.marker').create({'name': 'ignored'})
|
||||
ctx.lines = to_ignore
|
||||
wiz.write({'line_ids': to_ignore})
|
||||
wiz.mark_lines()
|
||||
assert model('credit.control.line').get(to_ignore[0]).state == 'ignored'
|
||||
|
||||
@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"')
|
||||
def impl(ctx, partner, number, level, move_line_name, amount):
|
||||
to_check = model('credit.control.line').search([('partner_id.name', '=', partner),
|
||||
('level', '=', level),
|
||||
('amount_due', '=', amount),
|
||||
('move_line_id.name', '=', move_line_name),
|
||||
('state', 'in', ('draft', 'ignored'))])
|
||||
assert_equal(len(to_check), int(number), msg="More than %s found" % number)
|
||||
lines = model('credit.control.line').browse(to_check)
|
||||
assert ['ignored', 'draft'] == lines.state
|
||||
|
||||
Reference in New Issue
Block a user