From c4e533cf8303ca314403e458d784054481e4b8e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 22 Oct 2012 22:58:33 +0200 Subject: [PATCH 01/18] Increase version number --- tryton.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tryton.cfg b/tryton.cfg index 715d1a514a..497939a505 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=2.6.0 +version=2.6.1 depends: account account_invoice From de9d7a826979a7869c322168618c7c4cb1ebc1ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Sun, 25 Nov 2012 18:27:55 +0100 Subject: [PATCH 02/18] Compute purchase_lines moves as root review583004 (transplanted from f2483c051a157956f41ee6b84c043a2579dc7be1) --- invoice.py | 4 +- tests/scenario_account_stock_anglo_saxon.rst | 71 +++++++++++++++----- 2 files changed, 56 insertions(+), 19 deletions(-) diff --git a/invoice.py b/invoice.py index 9fe6f1691c..347e9902a9 100644 --- a/invoice.py +++ b/invoice.py @@ -62,7 +62,9 @@ class InvoiceLine: moves = [] # other types will get current cost price if self.invoice.type == 'in_invoice': - moves = [move for purchase_line in self.purchase_lines + with Transaction().set_user(0, set_context=True): + purchase_lines = self.__class__(self.id).purchase_lines + moves = [move for purchase_line in purchase_lines for move in purchase_line.moves if move.state == 'done'] elif self.invoice.type == 'out_invoice': diff --git a/tests/scenario_account_stock_anglo_saxon.rst b/tests/scenario_account_stock_anglo_saxon.rst index 2767008583..820d7ef0cc 100644 --- a/tests/scenario_account_stock_anglo_saxon.rst +++ b/tests/scenario_account_stock_anglo_saxon.rst @@ -16,8 +16,8 @@ Imports:: Create database:: - >>> config = config.set_trytond() - >>> config.pool.test = True + >>> current_config = config.set_trytond() + >>> current_config.pool.test = True Install account_stock_continental, sale and purchase:: @@ -26,7 +26,7 @@ Install account_stock_continental, sale and purchase:: ... ('name', 'in', ('account_stock_anglo_saxon', ... 'sale', 'purchase')), ... ]) - >>> Module.install([x.id for x in modules], config.context) + >>> Module.install([x.id for x in modules], current_config.context) >>> Wizard('ir.module.module.install_upgrade').execute('upgrade') Create company:: @@ -55,7 +55,19 @@ Create company:: Reload the context:: >>> User = Model.get('res.user') - >>> config._context = User.get_preferences(True, config.context) + >>> current_config._context = User.get_preferences(True, + ... current_config.context) + +Create an accountant user:: + + >>> Group = Model.get('res.group') + >>> accountant = User() + >>> accountant.name = 'Accountant' + >>> accountant.login = 'accountant' + >>> accountant.password = 'accountant' + >>> account_group, = Group.find([('name', '=', 'Account')]) + >>> accountant.groups.append(account_group) + >>> accountant.save() Create fiscal year:: @@ -80,7 +92,7 @@ Create fiscal year:: >>> fiscalyear.out_credit_note_sequence = invoice_sequence >>> fiscalyear.in_credit_note_sequence = invoice_sequence >>> fiscalyear.save() - >>> FiscalYear.create_period([fiscalyear.id], config.context) + >>> FiscalYear.create_period([fiscalyear.id], current_config.context) Create chart of accounts:: @@ -167,7 +179,8 @@ Create product:: >>> product.account_journal_stock_customer = stock_journal >>> product.account_journal_stock_lost_found = stock_journal >>> product.save() - >>> product_average = Product(Product.copy([product.id], config.context)[0]) + >>> product_average = Product(Product.copy([product.id], + ... current_config.context)[0]) >>> product_average.cost_price_method = 'average' >>> product_average.save() @@ -199,8 +212,8 @@ Purchase 12 products:: >>> purchase_line.quantity = 7.0 >>> purchase_line.unit_price = Decimal(6) >>> purchase.save() - >>> Purchase.quote([purchase.id], config.context) - >>> Purchase.confirm([purchase.id], config.context) + >>> Purchase.quote([purchase.id], current_config.context) + >>> Purchase.confirm([purchase.id], current_config.context) >>> purchase.state u'confirmed' @@ -216,8 +229,8 @@ Receive 9 products:: >>> shipment.incoming_moves.append(move) >>> move.quantity = 5.0 >>> shipment.save() - >>> ShipmentIn.receive([shipment.id], config.context) - >>> ShipmentIn.done([shipment.id], config.context) + >>> ShipmentIn.receive([shipment.id], current_config.context) + >>> ShipmentIn.done([shipment.id], current_config.context) >>> shipment.state u'done' >>> stock_supplier.reload() @@ -244,7 +257,7 @@ Open supplier invoice:: >>> invoice_line = invoice.lines[1] >>> invoice_line.unit_price = Decimal('4') >>> invoice.save() - >>> Invoice.open([invoice.id], config.context) + >>> Invoice.open([invoice.id], current_config.context) >>> invoice.state u'open' >>> payable.reload() @@ -277,9 +290,9 @@ Sale 5 products:: >>> sale_line.product = product_average >>> sale_line.quantity = 3.0 >>> sale.save() - >>> Sale.quote([sale.id], config.context) - >>> Sale.confirm([sale.id], config.context) - >>> Sale.process([sale.id], config.context) + >>> Sale.quote([sale.id], current_config.context) + >>> Sale.confirm([sale.id], current_config.context) + >>> Sale.process([sale.id], current_config.context) >>> sale.state u'processing' @@ -287,16 +300,16 @@ Send 5 products:: >>> ShipmentOut = Model.get('stock.shipment.out') >>> shipment, = sale.shipments - >>> ShipmentOut.assign_try([shipment.id], config.context) + >>> ShipmentOut.assign_try([shipment.id], current_config.context) True >>> shipment.state u'assigned' >>> shipment.reload() - >>> ShipmentOut.pack([shipment.id], config.context) + >>> ShipmentOut.pack([shipment.id], current_config.context) >>> shipment.state u'packed' >>> shipment.reload() - >>> ShipmentOut.done([shipment.id], config.context) + >>> ShipmentOut.done([shipment.id], current_config.context) >>> shipment.state u'done' >>> stock_customer.reload() @@ -312,7 +325,7 @@ Open customer invoice:: >>> sale.reload() >>> invoice, = sale.invoices - >>> Invoice.open([invoice.id], config.context) + >>> Invoice.open([invoice.id], current_config.context) >>> invoice.state u'open' >>> receivable.reload() @@ -331,3 +344,25 @@ Open customer invoice:: >>> (cogs.debit, cogs.credit) == \ ... (Decimal('28.00'), Decimal('0.00')) True + +Now create a supplier invoice with an accountant:: + + >>> purchase = Purchase() + >>> purchase.party = supplier + >>> purchase.payment_term = payment_term + >>> purchase.invoice_method = 'order' + >>> purchase_line = PurchaseLine() + >>> purchase.lines.append(purchase_line) + >>> purchase_line.product = product + >>> purchase_line.quantity = 5.0 + >>> purchase_line.unit_price = Decimal(4) + >>> purchase.save() + >>> Purchase.quote([purchase.id], current_config.context) + >>> Purchase.confirm([purchase.id], current_config.context) + >>> purchase.state + u'confirmed' + + >>> new_config = config.set_trytond(user='accountant', + ... password='accountant', database_name=current_config.database_name) + >>> Invoice = Model.get('account.invoice') + >>> Invoice.open([i.id for i in purchase.invoices], new_config.context) From ff5e2b513bc5b3aed1c144dbccf13cb782da0c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 23 Dec 2012 16:39:45 +0100 Subject: [PATCH 03/18] Prepare release 2.6.1 --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index b6ff5a16f5..fbf3ef49ae 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +Version 2.6.1 - 2012-12-23 +* Bug fixes (see mercurial logs for details) + Version 2.6.0 - 2012-10-22 * Bug fixes (see mercurial logs for details) From 001cc4ffb84b4577a8d9a6bae91985b76da2e97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 23 Dec 2012 16:39:46 +0100 Subject: [PATCH 04/18] Added tag 2.6.1 for changeset 6f31e0958c34 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 2f035e1c35..7e0b3fd7a2 100644 --- a/.hgtags +++ b/.hgtags @@ -3,3 +3,4 @@ a66493cfbeefa27297e1397f51d84a7836931206 2.0.0 82fe8016c9c5c5399895d2344a3128943a842020 2.2.0 2de386f976af9b1d12e65fcfb8c99e1bcb61c88b 2.4.0 d6774822c6a0d49a13e1456224f8823c6ea73267 2.6.0 +6f31e0958c340d495332bac6331d732f2496eb31 2.6.1 From 5ad28a316e3df158d9f5e0381fea9c27b80bf5ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 23 Dec 2012 16:39:52 +0100 Subject: [PATCH 05/18] Increase version number --- tryton.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tryton.cfg b/tryton.cfg index 497939a505..2502cf86e3 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=2.6.1 +version=2.6.2 depends: account account_invoice From e49a12f56d08463b0c999ceebf12af62cecec828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 13 Jan 2013 22:50:22 +0100 Subject: [PATCH 06/18] Use root to update anglo_saxon_quantity review628002 (transplanted from b3dd5552c16e4c0012a1e5a9d2c0719d123bb137) --- stock.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stock.py b/stock.py index f9fbe370a9..d5034a9a5a 100644 --- a/stock.py +++ b/stock.py @@ -4,6 +4,7 @@ from decimal import Decimal from trytond.model import fields from trytond.pyson import Eval from trytond.pool import Pool, PoolMeta +from trytond.transaction import Transaction __all__ = ['Move'] __metaclass__ = PoolMeta @@ -115,10 +116,11 @@ class Move: move_cost_price = move.cost_price cost += move_cost_price * Decimal(str(move_qty)) - cls.write([move], { - 'anglo_saxon_quantity': ((move.anglo_saxon_quantity or 0.0) - + move_qty), - }) + with Transaction().set_user(0, set_context=True): + cls.write([move], { + 'anglo_saxon_quantity': ((move.anglo_saxon_quantity or 0.0) + + move_qty), + }) if consumed_qty < total_qty: qty = total_qty - consumed_qty From 95d1e998dcb7f58995da7d208a669cb46d2dde7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 12 Feb 2013 19:12:27 +0100 Subject: [PATCH 07/18] Prepare release 2.6.2 --- CHANGELOG | 3 +++ COPYRIGHT | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fbf3ef49ae..ae0a4df0a0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +Version 2.6.2 - 2013-02-12 +* Bug fixes (see mercurial logs for details) + Version 2.6.1 - 2012-12-23 * Bug fixes (see mercurial logs for details) diff --git a/COPYRIGHT b/COPYRIGHT index e792a2ca59..7e8c156c3f 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,5 +1,5 @@ -Copyright (C) 2010-2012 Cédric Krier. -Copyright (C) 2010-2012 B2CK SPRL. +Copyright (C) 2010-2013 Cédric Krier. +Copyright (C) 2010-2013 B2CK SPRL. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From 22f3e7d0b9ed34c8a1d44eacf48ccf0fa80178c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 12 Feb 2013 19:12:27 +0100 Subject: [PATCH 08/18] Added tag 2.6.2 for changeset 87ebc370b94d --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 7e0b3fd7a2..95fe3abcdc 100644 --- a/.hgtags +++ b/.hgtags @@ -4,3 +4,4 @@ a66493cfbeefa27297e1397f51d84a7836931206 2.0.0 2de386f976af9b1d12e65fcfb8c99e1bcb61c88b 2.4.0 d6774822c6a0d49a13e1456224f8823c6ea73267 2.6.0 6f31e0958c340d495332bac6331d732f2496eb31 2.6.1 +87ebc370b94deb4a94840248485afe5da0dce9b4 2.6.2 From c8668382545c028185fb156e539424bf325792b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 12 Feb 2013 19:12:38 +0100 Subject: [PATCH 09/18] Increase version number --- tryton.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tryton.cfg b/tryton.cfg index 2502cf86e3..67dc30ae41 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=2.6.2 +version=2.6.3 depends: account account_invoice From c50c922413808851bf94b3634ac48420f7ca7361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 5 Mar 2013 10:38:11 +0100 Subject: [PATCH 10/18] Fix missing unit_price currency convertion issue3036 review698002 (transplanted from 8223dede40d05831c102cee78743cea28090941c) --- stock.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stock.py b/stock.py index d5034a9a5a..3cb8fb7211 100644 --- a/stock.py +++ b/stock.py @@ -32,13 +32,17 @@ class Move: pool = Pool() Uom = pool.get('product.uom') AccountMoveLine = pool.get('account.move.line') + Currency = pool.get('currency.currency') lines = super(Move, self)._get_account_stock_move_lines(type_) if (type_.endswith('supplier') and self.product.cost_price_method == 'fixed'): cost_price = Uom.compute_price(self.product.default_uom, self.cost_price, self.uom) + with Transaction().set_context(date=self.effective_date): + unit_price = Currency.compute(self.currency, self.unit_price, + self.company.currency, round=False) amount = self.company.currency.round( - Decimal(str(self.quantity)) * (self.unit_price - cost_price)) + Decimal(str(self.quantity)) * (unit_price - cost_price)) if self.company.currency.is_zero(amount): return lines account = self.product.account_stock_supplier_used From eae581d717066a7eba836a9d550caf9ebcbd43e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 25 Mar 2013 19:30:02 +0100 Subject: [PATCH 11/18] Fix missing unit_price currency convertion issue3072 review731002 (transplanted from acd9a30f1c147a7c8637201c6b829ef1dd67b21a) --- stock.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stock.py b/stock.py index 3cb8fb7211..f99ab8fa2f 100644 --- a/stock.py +++ b/stock.py @@ -98,7 +98,9 @@ class Move: Return the cost for quantity based on lines. Update anglo_saxon_quantity on the concerned moves. ''' - Uom = Pool().get('product.uom') + pool = Pool() + Uom = pool.get('product.uom') + Currency = pool.get('currency.currency') for move in moves: assert move.product == product, 'wrong product' @@ -114,8 +116,11 @@ class Move: consumed_qty += move_qty if type_.startswith('in_'): + with Transaction().set_context(date=move.effective_date): + unit_price = Currency.compute(move.currency, + move.unit_price, move.company.currency, round=False) move_cost_price = Uom.compute_price(move.uom, - move.unit_price, move.product.default_uom) + unit_price, move.product.default_uom) else: move_cost_price = move.cost_price cost += move_cost_price * Decimal(str(move_qty)) From b3522bde076ad7cc758c746a5178d8d3b910a25f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 2 May 2013 10:20:44 +0200 Subject: [PATCH 12/18] Prepare release 2.6.3 --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index ae0a4df0a0..0883997546 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +Version 2.6.3 - 2013-05-02 +* Bug fixes (see mercurial logs for details) + Version 2.6.2 - 2013-02-12 * Bug fixes (see mercurial logs for details) From 24f09c7e5da05cdc9315f1f25c8dbbb541e79c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 2 May 2013 10:20:45 +0200 Subject: [PATCH 13/18] Added tag 2.6.3 for changeset 206aa3dcf2b8 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 95fe3abcdc..f6a8feab0f 100644 --- a/.hgtags +++ b/.hgtags @@ -5,3 +5,4 @@ a66493cfbeefa27297e1397f51d84a7836931206 2.0.0 d6774822c6a0d49a13e1456224f8823c6ea73267 2.6.0 6f31e0958c340d495332bac6331d732f2496eb31 2.6.1 87ebc370b94deb4a94840248485afe5da0dce9b4 2.6.2 +206aa3dcf2b899afe3882005cf3b1916c7c0b2d5 2.6.3 From 8e97c7b779ba7db05190d56b97c8d2777fe484b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 2 May 2013 10:20:55 +0200 Subject: [PATCH 14/18] Increase version number --- tryton.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tryton.cfg b/tryton.cfg index 67dc30ae41..1e03544fc3 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=2.6.3 +version=2.6.4 depends: account account_invoice From fb1dc57e4e9b90180a0d658ec4d2a4477442d6df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 22 Jul 2013 14:27:21 +0200 Subject: [PATCH 15/18] Fix COGS computation with negative quantity issue3287 review976002 (transplanted from b041a5be1444d626bd9105f28f6861c7695ffaa9) --- invoice.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/invoice.py b/invoice.py index 347e9902a9..742dbfbf15 100644 --- a/invoice.py +++ b/invoice.py @@ -81,10 +81,17 @@ class InvoiceLine: type_ = 'out_supplier' elif self.invoice.type == 'out_credit_note': type_ = 'in_customer' + if self.quantity < 0: + direction, target = type_.split('_') + if direction == 'in': + direction = 'out' + else: + direction = 'in' + type_ = '%s_%s' % (direction, target) moves.sort(key=operator.attrgetter('effective_date')) cost = Move.update_anglo_saxon_quantity_product_cost( - self.product, moves, self.quantity, self.unit, type_) + self.product, moves, abs(self.quantity), self.unit, type_) cost = self.invoice.currency.round(cost) anglo_saxon_move_lines = self._get_anglo_saxon_move_lines(cost, type_) From 72586a13ab62bd74361b6626bf780e8d7982275a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 1 Oct 2013 21:46:21 +0200 Subject: [PATCH 16/18] Prepare release 2.6.4 --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 0883997546..e4783920a5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +Version 2.6.4 - 2013-10-01 +* Bug fixes (see mercurial logs for details) + Version 2.6.3 - 2013-05-02 * Bug fixes (see mercurial logs for details) From 29f64659e5a91b078c8c220a042bb69ca1e310f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 1 Oct 2013 21:46:22 +0200 Subject: [PATCH 17/18] Added tag 2.6.4 for changeset c72603886750 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index f6a8feab0f..dfd3f1eb35 100644 --- a/.hgtags +++ b/.hgtags @@ -6,3 +6,4 @@ d6774822c6a0d49a13e1456224f8823c6ea73267 2.6.0 6f31e0958c340d495332bac6331d732f2496eb31 2.6.1 87ebc370b94deb4a94840248485afe5da0dce9b4 2.6.2 206aa3dcf2b899afe3882005cf3b1916c7c0b2d5 2.6.3 +c72603886750ec2bcb6d4c59ab48bee9fe6e293b 2.6.4 From 0a2c506dc57432821908b2139c1d68df00271007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 1 Oct 2013 21:46:36 +0200 Subject: [PATCH 18/18] Increase version number --- tryton.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tryton.cfg b/tryton.cfg index 1e03544fc3..37da2392ae 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=2.6.4 +version=2.6.5 depends: account account_invoice