Merge pull request #35 from mdietrichc2c/statement_import_correction

Corrects issue with customer refunds and partner lookup for imported lines and add account_report_company as account_statement_base_completion dependency
This commit is contained in:
Nicolas Bessi (nbessi)
2014-09-26 09:01:03 +02:00
6 changed files with 66 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ include =
*/bank-statement-reconcile/* */bank-statement-reconcile/*
omit = omit =
*/test/*
*/tests/* */tests/*
*__init__.py *__init__.py

View File

@@ -26,7 +26,8 @@
'maintainer': 'Camptocamp', 'maintainer': 'Camptocamp',
'category': 'Finance', 'category': 'Finance',
'complexity': 'normal', 'complexity': 'normal',
'depends': ['account_statement_ext'], 'depends': ['account_statement_ext',
'account_report_company'],
'description': """ 'description': """
The goal of this module is to improve the basic bank statement, help dealing The goal of this module is to improve the basic bank statement, help dealing
with huge volume of reconciliation by providing basic rules to identify the with huge volume of reconciliation by providing basic rules to identify the
@@ -76,6 +77,7 @@
'test/partner.yml', 'test/partner.yml',
'test/invoice.yml', 'test/invoice.yml',
'test/supplier_invoice.yml', 'test/supplier_invoice.yml',
'test/refund.yml',
'test/completion_test.yml' 'test/completion_test.yml'
], ],
'installable': True, 'installable': True,

View File

@@ -191,13 +191,7 @@ class AccountStatementCompletionRule(orm.Model):
res = {} res = {}
inv = self._find_invoice(cr, uid, line, inv_type, context=context) inv = self._find_invoice(cr, uid, line, inv_type, context=context)
if inv: if inv:
# FIXME use only commercial_partner_id of invoice in 7.1
# this is for backward compatibility in 7.0 before
# the refactoring of res.partner
if hasattr(inv, 'commercial_partner_id'):
partner_id = inv.commercial_partner_id.id partner_id = inv.commercial_partner_id.id
else:
partner_id = inv.partner_id.id
res = {'partner_id': partner_id, res = {'partner_id': partner_id,
'account_id': inv.account_id.id, 'account_id': inv.account_id.id,
'type': inv_type} 'type': inv_type}

View File

@@ -38,6 +38,15 @@
ref: T2S12345 ref: T2S12345
date: '2013-12-19' date: '2013-12-19'
amount: -65.0 amount: -65.0
-
I create a statement line for a CR
-
!record {model: account.bank.statement.line, id: statement_line_cr}:
name: Test autocompletion based on Customer Refund Number
statement_id: statement_test1
ref: CR0001
date: '2013-12-19'
amount: -210.0
- -
I create a statement line for the Partner Name I create a statement line for the Partner Name
- -
@@ -76,12 +85,18 @@
!assert {model: account.bank.statement.line, id: statement_line_si, string: Check completion by SI number}: !assert {model: account.bank.statement.line, id: statement_line_si, string: Check completion by SI number}:
- partner_id.id == _ref("base.res_partner_17") - partner_id.id == _ref("base.res_partner_17")
- -
Line 3. I check that the partner name has been recognised. Line 3. I expect the Customer refund number to be recognised. It should be
the commercial partner, and not the regular partner.
-
!assert {model: account.bank.statement.line, id: statement_line_cr, string: Check completion by CR number and commercial partner}:
- partner_id.id == _ref("base.res_partner_12")
-
Line 4. I check that the partner name has been recognised.
- -
!assert {model: account.bank.statement.line, id: statement_line_partner_name, string: Check completion by partner name}: !assert {model: account.bank.statement.line, id: statement_line_partner_name, string: Check completion by partner name}:
- partner_id.name == 'Vauxoo' - partner_id.name == 'Vauxoo'
- -
Line 4. I check that the partner special label has been recognised. Line 5. I check that the partner special label has been recognised.
- -
!assert {model: account.bank.statement.line, id: statement_line_partner_label, string: Check completion by partner label}: !assert {model: account.bank.statement.line, id: statement_line_partner_label, string: Check completion by partner label}:
- partner_id.id == _ref("base.res_partner_6") - partner_id.id == _ref("base.res_partner_6")

View File

@@ -0,0 +1,43 @@
-
I create a "child" partner, to use in the invoice
(and have a different commercial_partner_id than itself)
-
!record {model: res.partner, id: res_partner_12_child}:
name: Child Partner
supplier: False
customer: True
is_company: False
parent_id: base.res_partner_12
-
I create a customer refund to be found by the completion.
-
!record {model: account.invoice, id: refund_for_completion_1}:
account_id: account.a_pay
company_id: base.main_company
currency_id: base.EUR
internal_number: CR0001
invoice_line:
- account_id: account.a_expense
name: '[PCSC234] PC Assemble SC234'
price_unit: 210.0
quantity: 1.0
product_id: product.product_product_3
uos_id: product.product_uom_unit
journal_id: account.expenses_journal
partner_id: res_partner_12_child
type: 'out_refund'
reference_type: none
-
I confirm the refund
-
!workflow {model: account.invoice, action: invoice_open, ref: refund_for_completion_1}
-
I check that the refund state is "Open"
-
!assert {model: account.invoice, id: refund_for_completion_1}:
- state == 'open'
-
I check that it is given the number "CR0001"
-
!assert {model: account.invoice, id: refund_for_completion_1, string: Check CI number}:
- number == 'CR0001'

View File

@@ -110,7 +110,7 @@ class AccountStatementCompletionRule(Model):
elif len(invoice_id) == 1: elif len(invoice_id) == 1:
invoice = invoice_obj.browse(cr, uid, invoice_id[0], invoice = invoice_obj.browse(cr, uid, invoice_id[0],
context=context) context=context)
res['partner_id'] = invoice.partner_id.id res['partner_id'] = invoice.commercial_partner_id.id
# we want the move to have the same ref than the found # we want the move to have the same ref than the found
# invoice's move, thus it will be easier to link them for the # invoice's move, thus it will be easier to link them for the
# accountants # accountants