From 20e51e406003dc6bd3a46ada6b49a32b0c5ceed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 21 Oct 2013 17:40:31 +0200 Subject: [PATCH 01/13] Increase version number --- tryton.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tryton.cfg b/tryton.cfg index c13463fec9..7439199568 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=3.0.0 +version=3.0.1 depends: account account_product From 5627c2b77572f2893eaf9b4ef482b04069670c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 28 Nov 2013 23:09:22 +0100 Subject: [PATCH 02/13] Store report cache using buffer SQLite doesn't detect the binary even if stored in BLOB if the type is not buffer. issue2704 review1941002 (transplanted from 3b77f743131cb946fbecd50bc49cb418c67d584e) --- invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/invoice.py b/invoice.py index 1545f58bcc..8524e50ff3 100644 --- a/invoice.py +++ b/invoice.py @@ -2422,7 +2422,7 @@ class InvoiceReport(Report): and invoice.type in ('out_invoice', 'out_credit_note')): Invoice.write([Invoice(invoice.id)], { 'invoice_report_format': res[0], - 'invoice_report_cache': res[1], + 'invoice_report_cache': buffer(res[1]), }) return res From 9aa7b828de71275de6238a459c27025c72ea99ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 18 Jan 2014 20:55:45 +0100 Subject: [PATCH 03/13] Prepare release 3.0.1 --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 53bcf2864f..11b7949d3f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +Version 3.0.1 - 2014-01-18 +* Bug fixes (see mercurial logs for details) + Version 3.0.0 - 2013-10-21 * Bug fixes (see mercurial logs for details) * Use account move as cache From 95083f854911a1edce39125bd8943189f56d0b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 18 Jan 2014 20:55:45 +0100 Subject: [PATCH 04/13] Added tag 3.0.1 for changeset b2538daea4c7 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 55df7b168c..098bce8323 100644 --- a/.hgtags +++ b/.hgtags @@ -9,3 +9,4 @@ c43494eaf7ebf40f510e86f86f67098fd2ae8469 1.6.0 d163d6d54e28a1d1276b363656acccd35fae52ea 2.6.0 6711fa3bb1bdc7298d26be21169b527b121b11e4 2.8.0 e839808b734be508910bbdbef3514953cc3cc543 3.0.0 +b2538daea4c7948ea9b7734d3a3a5976f672d18e 3.0.1 From 83d4597438a78bff9535a220c383891f709d0f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 18 Jan 2014 20:55:58 +0100 Subject: [PATCH 05/13] Increase version number --- tryton.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tryton.cfg b/tryton.cfg index 7439199568..b2775b6922 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=3.0.1 +version=3.0.2 depends: account account_product From d84cfb750794a25633a0358102f2c23120a28bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 20 Dec 2013 13:53:55 +0100 Subject: [PATCH 06/13] Fix pay wizard for supplier invoice Since changeset ec72480260e4, get_reconcile_lines_for_amount expect to have signed amount but the pay wizard use absolute amount. issue3552 review2211002 (transplanted from 019ccd164020e3d4efb806af3c7045d77dc96bc3) --- invoice.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/invoice.py b/invoice.py index 8524e50ff3..7c0eaf2475 100644 --- a/invoice.py +++ b/invoice.py @@ -2560,6 +2560,11 @@ class PayInvoice(Wizard): 'amount to pay.'), }) + def get_reconcile_lines_for_amount(self, invoice, amount): + if invoice.type in ('in_invoice', 'out_credit_note'): + amount = -amount + return invoice.get_reconcile_lines_for_amount(amount) + def default_start(self, fields): Invoice = Pool().get('account.invoice') default = {} @@ -2581,7 +2586,7 @@ class PayInvoice(Wizard): with Transaction().set_context(date=self.start.date): amount = Currency.compute(self.start.currency, self.start.amount, invoice.company.currency) - _, remainder = invoice.get_reconcile_lines_for_amount(amount) + _, remainder = self.get_reconcile_lines_for_amount(invoice, amount) if remainder == Decimal('0.0') and amount <= invoice.amount_to_pay: return 'pay' return 'ask' @@ -2609,7 +2614,7 @@ class PayInvoice(Wizard): if invoice.company.currency.is_zero(amount): lines = invoice.lines_to_pay else: - lines, _ = invoice.get_reconcile_lines_for_amount(amount) + lines, _ = self.get_reconcile_lines_for_amount(invoice, amount) default['lines'] = [x.id for x in lines] for line_id in default['lines'][:]: @@ -2650,7 +2655,7 @@ class PayInvoice(Wizard): self.start.amount, invoice.company.currency) reconcile_lines, remainder = \ - invoice.get_reconcile_lines_for_amount(amount) + self.get_reconcile_lines_for_amount(invoice, amount) amount_second_currency = None second_currency = None From b0ce2f1ca560faa516aa9fc0896ec21979d9521a Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Mon, 23 Dec 2013 21:16:56 +0100 Subject: [PATCH 07/13] Clear origin field on copying lines review2421002 issue3565 (transplanted from e4a9667679f856d23f74b6efb0c62c09cbe2f852) --- invoice.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/invoice.py b/invoice.py index 7c0eaf2475..f534c57edb 100644 --- a/invoice.py +++ b/invoice.py @@ -1922,6 +1922,14 @@ class InvoiceLine(ModelSQL, ModelView): cls.raise_user_error('create', (invoice.rec_name,)) return super(InvoiceLine, cls).create(vlist) + @classmethod + def copy(cls, lines, default=None): + if default is None: + default = {} + default = default.copy() + default.setdefault('origin', None) + return super(InvoiceLine, cls).copy(lines, default=default) + @classmethod def validate(cls, lines): super(InvoiceLine, cls).validate(lines) From ae740e48db896c77ef68a57b9687495bd3d163d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 4 Jan 2014 19:49:47 +0100 Subject: [PATCH 08/13] Fix typo in Period.write to check invoice sequence changes It was introduced in changeset 90edc4984c69. Patch from Jordi Esteve. issue3567 review2461003 (transplanted from 77bd9c1bb110f5cb51771231d9912267f546b404) --- account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account.py b/account.py index 721212689f..f11ab72656 100644 --- a/account.py +++ b/account.py @@ -219,7 +219,7 @@ class Period: for period in periods: sequence = getattr(period, sequence_name) if (sequence and - sequence.id != vals[sequence]): + sequence.id != vals[sequence_name]): if Invoice.search([ ('invoice_date', '>=', period.start_date), ('invoice_date', '<=', period.end_date), From b817a6d9395647c1e821e019c1d4660716c8a405 Mon Sep 17 00:00:00 2001 From: Jordi Esteve Date: Sat, 18 Jan 2014 20:42:02 +0100 Subject: [PATCH 09/13] Fix typo for error message when 2 fiscal years have the same invoice sequence issue3575 review2551002 (transplanted from a9af21a256a33cb72307710da3b95fdee739369b) --- account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account.py b/account.py index f11ab72656..58ec2de241 100644 --- a/account.py +++ b/account.py @@ -90,7 +90,7 @@ class FiscalYear: ('id', '!=', self.id), ]) if fiscalyears: - self.raise_user_error('different_invoice_sequences', { + self.raise_user_error('different_invoice_sequence', { 'first': self.rec_name, 'second': fiscalyears[0].rec_name, }) From 00623b34f942a82979e0fa7569b7753158e5cc54 Mon Sep 17 00:00:00 2001 From: Eduardo Ruiz Date: Thu, 23 Jan 2014 11:26:25 +0100 Subject: [PATCH 10/13] Add missing 'invoice_type' to on_change of product invoice_type is used in the on_change method of product. issue3586 review2731002 (transplanted from 65bde6c273e26f8eb6cd7c5bff9ee5dab7ae7502) --- invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/invoice.py b/invoice.py index f534c57edb..1e7448602c 100644 --- a/invoice.py +++ b/invoice.py @@ -1504,7 +1504,7 @@ class InvoiceLine(ModelSQL, ModelView): on_change=['product', 'unit', 'quantity', 'description', '_parent_invoice.type', '_parent_invoice.party', '_parent_invoice.currency', '_parent_invoice.currency_date', - 'party', 'currency', 'invoice'], + 'party', 'currency', 'invoice', 'invoice_type'], depends=['type']) product_uom_category = fields.Function( fields.Many2One('product.uom.category', 'Product Uom Category', From 83e76d2f73058139191d107b361b854b1100f6f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 10 Feb 2014 20:32:37 +0100 Subject: [PATCH 11/13] Replace wrong usage of False by None (transplanted from 600c940612df5a8cd323fa167be20022e91e53bd) --- invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/invoice.py b/invoice.py index 1e7448602c..c8fe97c06a 100644 --- a/invoice.py +++ b/invoice.py @@ -2506,7 +2506,7 @@ class PayInvoiceAsk(ModelView): lines = fields.Many2Many('account.move.line', None, None, 'Lines', domain=[ ('id', 'in', Eval('lines_to_pay')), - ('reconciliation', '=', False), + ('reconciliation', '=', None), ], states={ 'invisible': Eval('type') != 'writeoff', From fb4291f20393e6ccdccba4aa83def92b00705e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 10 Feb 2014 22:27:27 +0100 Subject: [PATCH 12/13] Fix account move cache computation when second currency issue3645 review3131002 (transplanted from eb1bb2a9bf72d7946938c672bed88f7f422af3f5) --- invoice.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/invoice.py b/invoice.py index c8fe97c06a..9f73f2c3ce 100644 --- a/invoice.py +++ b/invoice.py @@ -6,7 +6,8 @@ import itertools import operator from sql import Literal from sql.aggregate import Count, Sum -from sql.conditionals import Coalesce +from sql.conditionals import Coalesce, Case +from sql.functions import Abs from trytond.model import Workflow, ModelView, ModelSQL, fields from trytond.report import Report @@ -574,7 +575,13 @@ class Invoice(Workflow, ModelSQL, ModelView): condition=invoice.move == move.id ).join(line, condition=move.id == line.move ).select(invoice.id, - Coalesce(Sum(line.debit - line.credit), 0).cast(type_name), + Coalesce(Sum( + Case((line.second_currency == invoice.currency, + Abs(line.amount_second_currency) + * Abs(line.debit - line.credit) + / (line.debit - line.credit)), + else_=line.debit - line.credit)), + 0).cast(type_name), where=(invoice.account == line.account) & red_sql, group_by=invoice.id)) for invoice_id, sum_ in cursor.fetchall(): From d5a3080df70a4c7b84120fa74fc161802651b838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 10 Feb 2014 22:28:29 +0100 Subject: [PATCH 13/13] Fix computation of second currency amount issue3664 review3351002 (transplanted from b81862858d215919a2c3355d4075c656e5ed516b) --- invoice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/invoice.py b/invoice.py index 9f73f2c3ce..4905916311 100644 --- a/invoice.py +++ b/invoice.py @@ -924,10 +924,10 @@ class Invoice(Workflow, ModelSQL, ModelView): term_lines = [(Date.today(), total)] for date, amount in term_lines: val = self._get_move_line(date, amount) - remainder_total_currency -= val['amount_second_currency'] + remainder_total_currency += val['amount_second_currency'] move_lines.append(val) if not self.currency.is_zero(remainder_total_currency): - move_lines[-1]['amount_second_currency'] += \ + move_lines[-1]['amount_second_currency'] -= \ remainder_total_currency accounting_date = self.accounting_date or self.invoice_date