← Back to team overview

banking-addons-team team mailing list archive

lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-add-tests-no-split-lep into lp:banking-addons/bank-statement-reconcile-7.0

 

Leonardo Pistone @ camptocamp has proposed merging lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-add-tests-no-split-lep into lp:banking-addons/bank-statement-reconcile-7.0.

Commit message:
[mrg] account_statement_base_completion: add YAML tests

Requested reviews:
  Banking Addons Core Editors (banking-addons-team)

For more details, see:
https://code.launchpad.net/~camptocamp/banking-addons/bank-statement-reconcile-7.0-add-tests-no-split-lep/+merge/199835

Tests for the autocompletion of banking statements.

* Customer invoice from CI number
* Supplier invoice from SI number
* Partner name
* Partner code

In fact 1 of the 3 tests doesn't pass: the one based on Partner Name. Since it looks to me that the test is correct: it has a statement line that includes the name Vauxoo, and fails to match the partner Vauxoo because, as it looks to me, it searches the whole line into the partner name and not vice versa.

I propose that anyway to give it some visibility. I'm sure we can get it right in this proposal.

Related branches:
* This has a similar test that passes based on SO numbers. https://code.launchpad.net/~camptocamp/banking-addons/bank-statement-reconcile-7.0-split-sale-lep/+merge/197544

* Two branches needed to fix bugs that came out here: https://code.launchpad.net/~camptocamp/banking-addons/bank-statement-reconcile-7.0-fix-yaml-related-lep/+merge/199124 and https://code.launchpad.net/~camptocamp/banking-addons/bank-statement-reconcile-7.0-fix-onchange-lep/+merge/199518

Thanks!
-- 
https://code.launchpad.net/~camptocamp/banking-addons/bank-statement-reconcile-7.0-add-tests-no-split-lep/+merge/199835
Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-add-tests-no-split-lep into lp:banking-addons/bank-statement-reconcile-7.0.
=== modified file 'account_statement_base_completion/__openerp__.py'
--- account_statement_base_completion/__openerp__.py	2013-04-05 07:52:53 +0000
+++ account_statement_base_completion/__openerp__.py	2013-12-20 16:21:23 +0000
@@ -66,7 +66,12 @@
      'security/ir.model.access.csv',
  ],
  'demo_xml': [],
- 'test': [],
+ 'test': [
+    'test/partner.yml',
+    'test/invoice.yml',
+    'test/supplier_invoice.yml',
+    'test/completion_test.yml'
+ ],
  'installable': True,
  'images': [],
  'auto_install': False,

=== added directory 'account_statement_base_completion/test'
=== added file 'account_statement_base_completion/test/TODO.txt'
--- account_statement_base_completion/test/TODO.txt	1970-01-01 00:00:00 +0000
+++ account_statement_base_completion/test/TODO.txt	2013-12-20 16:21:23 +0000
@@ -0,0 +1,3 @@
+* statement default company, or company required?
+* on_change
+* statment doesn't have a company, why?
\ No newline at end of file

=== added file 'account_statement_base_completion/test/completion_test.yml'
--- account_statement_base_completion/test/completion_test.yml	1970-01-01 00:00:00 +0000
+++ account_statement_base_completion/test/completion_test.yml	2013-12-20 16:21:23 +0000
@@ -0,0 +1,87 @@
+-
+  In order to test the banking framework, I first need to create a profile
+-
+  !record {model: account.statement.profile, id: profile_test1}:
+    name: Bank EUR Profile
+    journal_id: account.bank_journal
+    commission_account_id: account.a_expense
+    company_id: base.main_company
+    balance_check: True
+    rule_ids:
+      - bank_statement_completion_rule_4
+      - bank_statement_completion_rule_5
+      - bank_statement_completion_rule_2
+      - bank_statement_completion_rule_3
+-
+  Now I create a statement. I create statment lines separately because I need
+  to find each one by XML id
+-
+  !record {model: account.bank.statement, id: statement_test1}:
+    name: Statement 2
+    profile_id: profile_test1
+    company_id: base.main_company
+-
+  I create a statement line for a CI
+-
+  !record {model: account.bank.statement.line, id: statement_line_ci}:
+    name: Test autocompletion based on Customer Invoice Number
+    statement_id: statement_test1
+    ref: CI0001
+    date: '2013-12-20'
+    amount: 210.0
+-
+  I create a statement line for a SI
+-
+  !record {model: account.bank.statement.line, id: statement_line_si}:
+    name: Test autocompletion based on Supplier Invoice Number
+    statement_id: statement_test1
+    ref: T2S12345
+    date: '2013-12-19'
+    amount: -65.0
+-
+  I create a statement line for the Partner Name
+-
+  !record {model: account.bank.statement.line, id: statement_line_partner_name}:
+    name: Test autocompletion based on Partner Name Vauxoo
+    statement_id: statement_test1
+    ref: /
+    date: '2013-12-17'
+    amount: 600.0
+-
+  I create a statement line for the Partner Label
+-
+  !record {model: account.bank.statement.line, id: statement_line_partner_label}:
+    name: test autocompletion based on text (XXX66Z) matching with partner form information (note that Ref does not exist)
+    statement_id: statement_test1
+    ref: ZU788
+    date: '2013-12-24'
+    amount: -932.4
+-
+  I run the auto complete
+-
+  !python {model: account.bank.statement}: |
+    result = self.button_auto_completion(cr, uid, [ref("statement_test1")])
+-
+  Now I can check that all is nice and shiny, line 1. I expect the Customer
+  Invoice Number to be recognised.
+  I Use _ref, because ref conflicts with the field ref of the statement line
+-
+  !assert {model: account.bank.statement.line, id: statement_line_ci, string: Check completion by CI number}:
+    - partner_id.id == _ref("base.res_partner_12")
+-
+  Line 2. I expect the Supplier invoice number to be recognised. The supplier
+  invoice was created by the account module demo data, and we confirmed it
+  here.
+-
+  !assert {model: account.bank.statement.line, id: statement_line_si, string: Check completion by SI number}:
+    - partner_id.id == _ref("base.res_partner_17")
+-
+  Line 3. 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}:
+    - partner_id.name == 'Vauxoo'
+-
+  Line 4. 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}:
+    - partner_id.id == _ref("base.res_partner_6")

=== added file 'account_statement_base_completion/test/invoice.yml'
--- account_statement_base_completion/test/invoice.yml	1970-01-01 00:00:00 +0000
+++ account_statement_base_completion/test/invoice.yml	2013-12-20 16:21:23 +0000
@@ -0,0 +1,32 @@
+-
+  I create a customer Invoice to be found by the completion.
+-
+  !record {model: account.invoice, id: invoice_for_completion_1}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.EUR
+    internal_number: CI0001
+    invoice_line:
+      - account_id: account.a_sale
+        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.bank_journal
+    partner_id: base.res_partner_12
+    reference_type: none
+-
+  I confirm the Invoice
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: invoice_for_completion_1}
+-
+  I check that the invoice state is "Open"
+-
+  !assert {model: account.invoice, id: invoice_for_completion_1}:
+    - state == 'open'
+-
+  I check that it is given the number "CI0001"
+-
+  !assert {model: account.invoice, id: invoice_for_completion_1, string: Check CI number}:
+    - number == 'CI0001'

=== added file 'account_statement_base_completion/test/partner.yml'
--- account_statement_base_completion/test/partner.yml	1970-01-01 00:00:00 +0000
+++ account_statement_base_completion/test/partner.yml	2013-12-20 16:21:23 +0000
@@ -0,0 +1,5 @@
+-
+  I fill in the field Bank Statement Label in a Partner
+-
+  !record {model: res.partner, id: base.res_partner_6}:
+    bank_statement_label: XXX66Z

=== added file 'account_statement_base_completion/test/supplier_invoice.yml'
--- account_statement_base_completion/test/supplier_invoice.yml	1970-01-01 00:00:00 +0000
+++ account_statement_base_completion/test/supplier_invoice.yml	2013-12-20 16:21:23 +0000
@@ -0,0 +1,31 @@
+-
+  I check that my invoice is a supplier invoice
+-
+  !assert {model: account.invoice, id: account.demo_invoice_0, string: Check invoice type}:
+    - type == 'in_invoice'
+-
+  I add a reference to an existing supplier invoce
+-
+  !python {model: account.invoice}: |
+    self.write(cr, uid, ref('account.demo_invoice_0'), {
+      'supplier_invoice_number': 'T2S12345'
+    })
+-
+  I check a second time that my invoice is still a supplier invoice
+-
+  !assert {model: account.invoice, id: account.demo_invoice_0, string: Check invoice type 2}:
+    - type == 'in_invoice'
+-
+  Now I confirm it
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account.demo_invoice_0}
+-
+  I check that the supplier number is there
+-
+  !assert {model: account.invoice, id: account.demo_invoice_0, string: Check supplier number}:
+    - supplier_invoice_number == 'T2S12345'
+-
+  I check a third time that my invoice is still a supplier invoice
+-
+  !assert {model: account.invoice, id: account.demo_invoice_0, string: Check invoice type 3}:
+    - type == 'in_invoice'

=== modified file 'account_statement_ext/statement.py'
--- account_statement_ext/statement.py	2013-12-11 16:01:01 +0000
+++ account_statement_ext/statement.py	2013-12-20 16:21:23 +0000
@@ -223,12 +223,21 @@
         move of period_id to the statement line
         """
         for statement in self.browse(cr, uid, ids, context=context):
-            if (statement.period_id and
-                    statement.company_id.id != statement.period_id.company_id.id):
+            # statement.company_id is a related store=True that for some
+            # reason doesn't work in YAML tests. As a workaround, I unwind it
+            # to statement.journal_id.company_id here.
+            if (
+                statement.period_id
+                and statement.journal_id.company_id.id
+                != statement.period_id.company_id.id
+            ):
                 return False
             for line in statement.line_ids:
-                if (line.period_id and
-                        statement.company_id.id != line.period_id.company_id.id):
+                if (
+                    line.period_id
+                    and statement.journal_id.company_id.id
+                    != line.period_id.company_id.id
+                ):
                     return False
         return True
 


Follow ups