From 9382f31c7d72ec20739a16d8fdacb379e162903b Mon Sep 17 00:00:00 2001 From: Nhomar Hernandez Date: Sun, 1 Sep 2013 02:14:06 -0430 Subject: [PATCH 1/6] [FIX] pass correct parameter to compute the balance on partner form with all entries not complete reconciled lp bug: https://launchpad.net/bugs/1219381 fixed bzr revid: nhomar@gmail.com-20130901064406-ehfuhwpjq0ti6oed --- addons/account/partner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/partner.py b/addons/account/partner.py index 4914a17dd2b..22d6fcea394 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -110,7 +110,9 @@ class res_partner(osv.osv): _description = 'Partner' def _credit_debit_get(self, cr, uid, ids, field_names, arg, context=None): - query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) + ctx = context.copy() + ctx['all_fiscalyear'] = True + query = self.pool.get('account.move.line')._query_get(cr, uid, context=ctx) cr.execute("""SELECT l.partner_id, a.type, SUM(l.debit-l.credit) FROM account_move_line l LEFT JOIN account_account a ON (l.account_id=a.id) From 10b09c13c7a6ce6d2ea70d9de36f631b3c2995bc Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 18 Oct 2013 14:43:42 +0200 Subject: [PATCH 2/6] [IMP] account: set test on closing account invoice on previous year instead of next one bzr revid: mat@openerp.com-20131018124342-yccp0ftebmug4aco --- .../account/test/account_fiscalyear_close.yml | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/addons/account/test/account_fiscalyear_close.yml b/addons/account/test/account_fiscalyear_close.yml index 40d1b1a6a7b..a0516a3a6ee 100644 --- a/addons/account/test/account_fiscalyear_close.yml +++ b/addons/account/test/account_fiscalyear_close.yml @@ -4,31 +4,27 @@ !record {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0}: code: !eval "'FY%s'% (datetime.now().year+1)" 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 %s' %(datetime.now().year+1)" + date_start: !eval "'%s-01-01' %(datetime.now().year-1)" + date_stop: !eval "'%s-12-31' %(datetime.now().year-1)" + name: !eval "'Fiscal Year %s' %(datetime.now().year-1)" - - I create a period for the opening entries for the new fiscalyear + I generate periods for the new fiscalyear - - !record {model: account.period, id: account_period_jan11}: - company_id: base.main_company - date_start: !eval "'%s-01-01'% (datetime.now().year+1)" - date_stop: !eval "'%s-01-01'% (datetime.now().year+1)" - fiscalyear_id: account_fiscalyear_fiscalyear0 - name: !eval "'OP %s' %(datetime.now().year+1)" - special: 1 + !python {model: account.fiscalyear}: | + self.create_period(cr, uid, [ref("account_fiscalyear_fiscalyear0")]) - - I create a new account invoice a the partner in current fiscalyear + I create a new account invoice in the created fiscalyear - !record {model: account.invoice, id: account_invoice_current1}: partner_id: base.res_partner_2 + date_invoice: !eval "'%s-01-02' %(datetime.now().year-1)" invoice_line: - partner_id: base.res_partner_2 quantity: 1.0 price_unit: 15.00 name: Bying stuff - - I validate it the invoice + I validate the invoice - !python {model: account.invoice}: | import netsvc @@ -47,13 +43,13 @@ company_id: base.main_company centralisation: 1 - - I called the Generate Fiscalyear Opening Entries wizard + I call the Generate Fiscalyear Opening Entries wizard - !record {model: account.fiscalyear.close, id: account_fiscalyear_close_0}: - fy2_id: account_fiscalyear_fiscalyear0 - fy_id: account.data_fiscalyear + fy2_id: account.data_fiscalyear + fy_id: account_fiscalyear_fiscalyear0 journal_id: account.close_journal - period_id: account_period_jan11 + period_id: account.period_1 report_name: End of Fiscal Year Entry - I clicked on create Button @@ -66,7 +62,7 @@ I close the previous fiscalyear - !record {model: account.fiscalyear.close.state, id: account_fiscalyear_close_state_0}: - fy_id: data_fiscalyear + fy_id: account_fiscalyear_fiscalyear0 - I clicked on Close States Button to close fiscalyear - @@ -77,7 +73,7 @@ - I check that the fiscalyear state is now "Done" - - !assert {model: account.fiscalyear, id: data_fiscalyear, string: Fiscal Year is in Done state}: + !assert {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0, string: Fiscal Year is in Done state}: - state == 'done' - I check that the past accounts are taken into account in partner credit From f6bb46217271433b07bfb7ba4d21c0df9efd2aea Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 18 Oct 2013 15:40:58 +0200 Subject: [PATCH 3/6] [FIX] account: correct test with valid error message bzr revid: mat@openerp.com-20131018134058-wpuyqnhb3xtshqs8 --- addons/account/test/account_fiscalyear_close.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/test/account_fiscalyear_close.yml b/addons/account/test/account_fiscalyear_close.yml index a0516a3a6ee..92e2cfff7d6 100644 --- a/addons/account/test/account_fiscalyear_close.yml +++ b/addons/account/test/account_fiscalyear_close.yml @@ -78,5 +78,5 @@ - I check that the past accounts are taken into account in partner credit - - !assert {model: res.partner, id: base.res_partner_2}: - - credit == 15.0, "Total Receivable does not takes unreconciled previous moves" + !assert {model: res.partner, id: base.res_partner_2, string: Total Receivable does not takes unreconciled previous moves}: + - credit == 15.0 From 6f2f0b17eddef1fdc97d61b5fe68c158bd2960f4 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 18 Oct 2013 15:46:13 +0200 Subject: [PATCH 4/6] [TEST] test with failing test bzr revid: mat@openerp.com-20131018134613-27lsl5vln5yu26pa --- addons/account/partner.py | 3 +- .../account/test/account_fiscalyear_close.yml | 34 +++++++++++-------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/addons/account/partner.py b/addons/account/partner.py index 64896338476..4914a17dd2b 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -116,8 +116,7 @@ class res_partner(osv.osv): LEFT JOIN account_account a ON (l.account_id=a.id) WHERE a.type IN ('receivable','payable') AND l.partner_id IN %s - AND (l.reconcile_id IS NULL OR - reconcile_id in (SELECT id FROM account_move_reconcile WHERE opening_reconciliation is TRUE)) + AND l.reconcile_id IS NULL AND """ + query + """ GROUP BY l.partner_id, a.type """, diff --git a/addons/account/test/account_fiscalyear_close.yml b/addons/account/test/account_fiscalyear_close.yml index 92e2cfff7d6..a9c989be65b 100644 --- a/addons/account/test/account_fiscalyear_close.yml +++ b/addons/account/test/account_fiscalyear_close.yml @@ -4,27 +4,31 @@ !record {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0}: code: !eval "'FY%s'% (datetime.now().year+1)" 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 %s' %(datetime.now().year-1)" + date_start: !eval "'%s-01-01' %(datetime.now().year+1)" + date_stop: !eval "'%s-12-31' %(datetime.now().year+1)" + name: !eval "'Fiscal Year %s' %(datetime.now().year+1)" - - I generate periods for the new fiscalyear + I create a period for the opening entries for the new fiscalyear - - !python {model: account.fiscalyear}: | - self.create_period(cr, uid, [ref("account_fiscalyear_fiscalyear0")]) + !record {model: account.period, id: account_period_jan11}: + company_id: base.main_company + date_start: !eval "'%s-01-01'% (datetime.now().year+1)" + date_stop: !eval "'%s-01-01'% (datetime.now().year+1)" + fiscalyear_id: account_fiscalyear_fiscalyear0 + name: !eval "'OP %s' %(datetime.now().year+1)" + special: 1 - - I create a new account invoice in the created fiscalyear + I create a new account invoice a the partner in current fiscalyear - !record {model: account.invoice, id: account_invoice_current1}: partner_id: base.res_partner_2 - date_invoice: !eval "'%s-01-02' %(datetime.now().year-1)" invoice_line: - partner_id: base.res_partner_2 quantity: 1.0 price_unit: 15.00 name: Bying stuff - - I validate the invoice + I validate it the invoice - !python {model: account.invoice}: | import netsvc @@ -43,13 +47,13 @@ company_id: base.main_company centralisation: 1 - - I call the Generate Fiscalyear Opening Entries wizard + I called the Generate Fiscalyear Opening Entries wizard - !record {model: account.fiscalyear.close, id: account_fiscalyear_close_0}: - fy2_id: account.data_fiscalyear - fy_id: account_fiscalyear_fiscalyear0 + fy2_id: account_fiscalyear_fiscalyear0 + fy_id: account.data_fiscalyear journal_id: account.close_journal - period_id: account.period_1 + period_id: account_period_jan11 report_name: End of Fiscal Year Entry - I clicked on create Button @@ -62,7 +66,7 @@ I close the previous fiscalyear - !record {model: account.fiscalyear.close.state, id: account_fiscalyear_close_state_0}: - fy_id: account_fiscalyear_fiscalyear0 + fy_id: data_fiscalyear - I clicked on Close States Button to close fiscalyear - @@ -73,7 +77,7 @@ - I check that the fiscalyear state is now "Done" - - !assert {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0, string: Fiscal Year is in Done state}: + !assert {model: account.fiscalyear, id: data_fiscalyear, string: Fiscal Year is in Done state}: - state == 'done' - I check that the past accounts are taken into account in partner credit From 7d3e01bea30dbfa70c56b77b3e019a2074a53e38 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 18 Oct 2013 15:59:25 +0200 Subject: [PATCH 5/6] [FIX] account: go green test\!, also set the test to previous year bzr revid: mat@openerp.com-20131018135925-x2n1yw96973srmk1 --- addons/account/partner.py | 3 +- .../account/test/account_fiscalyear_close.yml | 36 +++++++++---------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/addons/account/partner.py b/addons/account/partner.py index 4914a17dd2b..64896338476 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -116,7 +116,8 @@ class res_partner(osv.osv): LEFT JOIN account_account a ON (l.account_id=a.id) WHERE a.type IN ('receivable','payable') AND l.partner_id IN %s - AND l.reconcile_id IS NULL + AND (l.reconcile_id IS NULL OR + reconcile_id in (SELECT id FROM account_move_reconcile WHERE opening_reconciliation is TRUE)) AND """ + query + """ GROUP BY l.partner_id, a.type """, diff --git a/addons/account/test/account_fiscalyear_close.yml b/addons/account/test/account_fiscalyear_close.yml index a9c989be65b..73e34f2cca8 100644 --- a/addons/account/test/account_fiscalyear_close.yml +++ b/addons/account/test/account_fiscalyear_close.yml @@ -4,31 +4,27 @@ !record {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0}: code: !eval "'FY%s'% (datetime.now().year+1)" 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 %s' %(datetime.now().year+1)" + date_start: !eval "'%s-01-01' %(datetime.now().year-1)" + date_stop: !eval "'%s-12-31' %(datetime.now().year-1)" + name: !eval "'Fiscal Year %s' %(datetime.now().year-1)" - - I create a period for the opening entries for the new fiscalyear + I generate periods for the new fiscalyear - - !record {model: account.period, id: account_period_jan11}: - company_id: base.main_company - date_start: !eval "'%s-01-01'% (datetime.now().year+1)" - date_stop: !eval "'%s-01-01'% (datetime.now().year+1)" - fiscalyear_id: account_fiscalyear_fiscalyear0 - name: !eval "'OP %s' %(datetime.now().year+1)" - special: 1 + !python {model: account.fiscalyear}: | + self.create_period(cr, uid, [ref("account_fiscalyear_fiscalyear0")]) - - I create a new account invoice a the partner in current fiscalyear + I create a new account invoice in the created fiscalyear - !record {model: account.invoice, id: account_invoice_current1}: partner_id: base.res_partner_2 + date_invoice: !eval "'%s-01-02' %(datetime.now().year-1)" invoice_line: - partner_id: base.res_partner_2 quantity: 1.0 price_unit: 15.00 name: Bying stuff - - I validate it the invoice + I validate the invoice - !python {model: account.invoice}: | import netsvc @@ -47,13 +43,13 @@ company_id: base.main_company centralisation: 1 - - I called the Generate Fiscalyear Opening Entries wizard + I call the Generate Fiscalyear Opening Entries wizard - !record {model: account.fiscalyear.close, id: account_fiscalyear_close_0}: - fy2_id: account_fiscalyear_fiscalyear0 - fy_id: account.data_fiscalyear + fy2_id: account.data_fiscalyear + fy_id: account_fiscalyear_fiscalyear0 journal_id: account.close_journal - period_id: account_period_jan11 + period_id: account.period_1 report_name: End of Fiscal Year Entry - I clicked on create Button @@ -66,7 +62,7 @@ I close the previous fiscalyear - !record {model: account.fiscalyear.close.state, id: account_fiscalyear_close_state_0}: - fy_id: data_fiscalyear + fy_id: account_fiscalyear_fiscalyear0 - I clicked on Close States Button to close fiscalyear - @@ -77,10 +73,10 @@ - I check that the fiscalyear state is now "Done" - - !assert {model: account.fiscalyear, id: data_fiscalyear, string: Fiscal Year is in Done state}: + !assert {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0, string: Fiscal Year is in Done state}: - state == 'done' - I check that the past accounts are taken into account in partner credit - - !assert {model: res.partner, id: base.res_partner_2, string: Total Receivable does not takes unreconciled previous moves}: + !assert {model: res.partner, id: base.res_partner_2, string: Total Receivable does not takes unreconciled moves of previous years}: - credit == 15.0 From a2e0acf7d4d8b4cebd94f5b239edb841d99915be Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 22 Oct 2013 11:17:28 +0200 Subject: [PATCH 6/6] [REV] revert partner.py to revision 9043 (error cf lp:1219381 comment #11) bzr revid: mat@openerp.com-20131022091728-hebgvt1m26y9wjot --- addons/account/partner.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/account/partner.py b/addons/account/partner.py index 64896338476..4914a17dd2b 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -116,8 +116,7 @@ class res_partner(osv.osv): LEFT JOIN account_account a ON (l.account_id=a.id) WHERE a.type IN ('receivable','payable') AND l.partner_id IN %s - AND (l.reconcile_id IS NULL OR - reconcile_id in (SELECT id FROM account_move_reconcile WHERE opening_reconciliation is TRUE)) + AND l.reconcile_id IS NULL AND """ + query + """ GROUP BY l.partner_id, a.type """,