From 44fb1720263bf54ee73904576b3b7b940bbbf629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 2 Jan 2012 16:04:25 +0100 Subject: [PATCH] [FIX] Fixed automated tests using explicit references to the 2011 year bzr revid: tde@openerp.com-20120102150425-4pcegkfpw9v2aoof --- addons/account/demo/account_invoice_demo.xml | 4 ++-- addons/account/test/account_period_close.yml | 20 ++++++++++++++----- addons/account/test/test_edi_invoice.yml | 9 +++++---- addons/stock_planning/test/stock_planning.yml | 3 ++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/addons/account/demo/account_invoice_demo.xml b/addons/account/demo/account_invoice_demo.xml index ba06c178963..184b349be71 100644 --- a/addons/account/demo/account_invoice_demo.xml +++ b/addons/account/demo/account_invoice_demo.xml @@ -2,7 +2,7 @@ - 2011-07-21 + @@ -15,7 +15,7 @@ in_invoice - 2011-06-01 + diff --git a/addons/account/test/account_period_close.yml b/addons/account/test/account_period_close.yml index e4b7aec8444..39b0e8be2d9 100644 --- a/addons/account/test/account_period_close.yml +++ b/addons/account/test/account_period_close.yml @@ -1,13 +1,23 @@ - - In order to test close period wizard I create a period then close it and checked it's state + In order to test close period wizard I first create a dummy fiscal year in the past to avoid conflicts related to closed periods +- + !record {model: account.fiscalyear, id: data_fiscalyear_minus1}: + company_id: base.main_company + date_start: !eval "'%s-01-01' %(datetime.now().year-1)" + date_stop: !eval "'%s-12-31' %(datetime.now().year-1)" + name: !eval "'Fiscal Year X %s' %(datetime.now().year-1)" + code: !eval "'FY%s' %(datetime.now().year-1)" + +- + I create a period then close it and checked it's state - !record {model: account.period, id: account_period_jan0}: company_id: base.main_company - date_start: !eval "'%s-01-01' %(datetime.now().year)" - date_stop: !eval "'%s-01-31' %(datetime.now().year)" - fiscalyear_id: account.data_fiscalyear - name: !eval "'Jan-%s' %(datetime.now().year)" + date_start: !eval "'%s-01-01' %(datetime.now().year-1)" + date_stop: !eval "'%s-01-31' %(datetime.now().year-1)" + fiscalyear_id: data_fiscalyear_minus1 + name: !eval "'Jan-%s' %(datetime.now().year-1)" special: 1 - diff --git a/addons/account/test/test_edi_invoice.yml b/addons/account/test/test_edi_invoice.yml index b1e73140581..e2c0f21e7da 100644 --- a/addons/account/test/test_edi_invoice.yml +++ b/addons/account/test/test_edi_invoice.yml @@ -10,7 +10,7 @@ address_invoice_id: base.res_partner_address_8invoice company_id: 1 account_id: account.a_pay - date_invoice: '2011-06-22' + date_invoice: !eval "'%s' % (time.strftime('%Y-%m-%d'))" name: selling product type: 'out_invoice' invoice_line: @@ -48,12 +48,13 @@ Then I import a sample EDI document of another customer invoice - !python {model: account.invoice}: | + import time edi_document = { "__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.random_invoice_763jsms", "__module": "account", "__model": "account.invoice", "__version": [6,1,0], - "internal_number": "SAJ/2011/002", + "internal_number": time.strftime("SAJ/%Y/002"), "company_address": { "__id": "base:b22acf7a-ddcd-11e0-a4db-701a04e25543.main_address", "__module": "base", @@ -86,7 +87,7 @@ "zip": "1367", "country_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.be", "Belgium"], }, - "date_invoice": "2011-06-22", + "date_invoice": time.strftime('%Y-%m-%d'), "name": "sample invoice", "tax_line": [{ "__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.account_invoice_tax-4g4EutbiEMVl", @@ -128,7 +129,7 @@ assert bank_info.acc_number == "Sample bank: 123465789-156113", 'Expected "Sample bank: 123465789-156113", got %s' % bank_info.acc_number assert invoice_new.partner_id.supplier, 'Imported Partner is not marked as supplier' - assert invoice_new.reference == "SAJ/2011/002", "internal number is not stored in reference" + assert invoice_new.reference == time.strftime("SAJ/%Y/002"), "internal number is not stored in reference" assert invoice_new.reference_type == 'none', "reference type is not set to 'none'" assert invoice_new.internal_number == False, "internal number is not reset" assert invoice_new.journal_id.id, "journal id is not selected" diff --git a/addons/stock_planning/test/stock_planning.yml b/addons/stock_planning/test/stock_planning.yml index f9608461f8a..8e26d690f53 100644 --- a/addons/stock_planning/test/stock_planning.yml +++ b/addons/stock_planning/test/stock_planning.yml @@ -253,5 +253,6 @@ I check whether the procurement orders are created or not. - !python {model: procurement.order}: | - proc_ids = self.search(cr, uid, [('origin','=','MPS(admin) 2011, week 29'),('product_id','=',ref("product.product_product_pc1"))]) + import datetime + proc_ids = self.search(cr, uid, [('origin','=','MPS(admin) %s, week 29' % (datetime.datetime.now().year)),('product_id','=',ref("product.product_product_pc1"))]) assert proc_ids,'No Procurements!'