[tryton-debian-vcs] tryton-modules-account-stock-anglo-saxon branch upstream created. dfca561b38666a3f8c9babfaf8aa57f625fb8ed5
Mathias Behrle
tryton-debian-vcs at alioth.debian.org
Wed Nov 27 16:57:14 UTC 2013
The following commit has been merged in the upstream branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-modules-account-stock-anglo-saxon.git;a=commitdiff;h=dfca561b38666a3f8c9babfaf8aa57f625fb8ed5
commit dfca561b38666a3f8c9babfaf8aa57f625fb8ed5
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Sun Nov 24 17:26:27 2013 +0100
Adding upstream version 3.0.0.
diff --git a/CHANGELOG b/CHANGELOG
index 7125dea..f2c0d71 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,4 @@
-Version 2.8.1 - 2013-10-01
+Version 3.0.0 - 2013-10-21
* Bug fixes (see mercurial logs for details)
Version 2.8.0 - 2013-04-22
diff --git a/PKG-INFO b/PKG-INFO
index 52d9e53..1b476bd 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: trytond_account_stock_anglo_saxon
-Version: 2.8.1
+Version: 3.0.0
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
Author-email: UNKNOWN
License: GPL-3
-Download-URL: http://downloads.tryton.org/2.8/
+Download-URL: http://downloads.tryton.org/3.0/
Description: trytond_account_stock_anglo_saxon
=================================
@@ -58,6 +58,7 @@ Classifier: Natural Language :: English
Classifier: Natural Language :: French
Classifier: Natural Language :: German
Classifier: Natural Language :: Russian
+Classifier: Natural Language :: Slovenian
Classifier: Natural Language :: Spanish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.6
diff --git a/locale/bg_BG.po b/locale/bg_BG.po
index c5b09af..0382f38 100644
--- a/locale/bg_BG.po
+++ b/locale/bg_BG.po
@@ -22,8 +22,12 @@ msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
msgstr ""
-msgctxt "field:stock.move,anglo_saxon_quantity:"
-msgid "Anglo-Saxon Quantity"
+msgctxt "field:stock.move,in_anglo_saxon_quantity:"
+msgid "Input Anglo-Saxon Quantity"
+msgstr ""
+
+msgctxt "field:stock.move,out_anglo_saxon_quantity:"
+msgid "Output Anglo-Saxon Quantity"
msgstr ""
#, fuzzy
diff --git a/locale/ca_ES.po b/locale/ca_ES.po
index d91f4f6..babc13d 100644
--- a/locale/ca_ES.po
+++ b/locale/ca_ES.po
@@ -22,9 +22,13 @@ msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
msgstr "Compte cost béns venuts usada"
-msgctxt "field:stock.move,anglo_saxon_quantity:"
-msgid "Anglo-Saxon Quantity"
-msgstr "Quantitat anglo-saxona"
+msgctxt "field:stock.move,in_anglo_saxon_quantity:"
+msgid "Input Anglo-Saxon Quantity"
+msgstr ""
+
+msgctxt "field:stock.move,out_anglo_saxon_quantity:"
+msgid "Output Anglo-Saxon Quantity"
+msgstr ""
msgctxt "help:product.template,account_cogs:"
msgid "This account will be used instead of the one defined on the category."
diff --git a/locale/cs_CZ.po b/locale/cs_CZ.po
index d6551d4..8a9e9a7 100644
--- a/locale/cs_CZ.po
+++ b/locale/cs_CZ.po
@@ -22,8 +22,12 @@ msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
msgstr ""
-msgctxt "field:stock.move,anglo_saxon_quantity:"
-msgid "Anglo-Saxon Quantity"
+msgctxt "field:stock.move,in_anglo_saxon_quantity:"
+msgid "Input Anglo-Saxon Quantity"
+msgstr ""
+
+msgctxt "field:stock.move,out_anglo_saxon_quantity:"
+msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "help:product.template,account_cogs:"
diff --git a/locale/de_DE.po b/locale/de_DE.po
index a019334..eb5530a 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -22,9 +22,13 @@ msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
msgstr "Verwendetes Konto Kosten verkaufte Waren"
-msgctxt "field:stock.move,anglo_saxon_quantity:"
-msgid "Anglo-Saxon Quantity"
-msgstr "Anzahl (Angelsächsische Bewertung)"
+msgctxt "field:stock.move,in_anglo_saxon_quantity:"
+msgid "Input Anglo-Saxon Quantity"
+msgstr "Eingang (Angelsächsische Bewertung)"
+
+msgctxt "field:stock.move,out_anglo_saxon_quantity:"
+msgid "Output Anglo-Saxon Quantity"
+msgstr "Ausgang (Angelsächsische Bewertung)"
msgctxt "help:product.template,account_cogs:"
msgid "This account will be used instead of the one defined on the category."
diff --git a/locale/es_AR.po b/locale/es_AR.po
index 1f33853..005a4e6 100644
--- a/locale/es_AR.po
+++ b/locale/es_AR.po
@@ -22,9 +22,13 @@ msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
msgstr "Cuenta de Costo de Mercaderías Vendidas utilizada"
-msgctxt "field:stock.move,anglo_saxon_quantity:"
-msgid "Anglo-Saxon Quantity"
-msgstr "Cantidad anglo-sajona"
+msgctxt "field:stock.move,in_anglo_saxon_quantity:"
+msgid "Input Anglo-Saxon Quantity"
+msgstr "Salida de cantidad anglo-sajona"
+
+msgctxt "field:stock.move,out_anglo_saxon_quantity:"
+msgid "Output Anglo-Saxon Quantity"
+msgstr "Entrada de cantidad anglo-sajona"
msgctxt "help:product.template,account_cogs:"
msgid "This account will be used instead of the one defined on the category."
diff --git a/locale/es_CO.po b/locale/es_CO.po
index 27fe566..fbb5f5c 100644
--- a/locale/es_CO.po
+++ b/locale/es_CO.po
@@ -22,8 +22,12 @@ msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
msgstr ""
-msgctxt "field:stock.move,anglo_saxon_quantity:"
-msgid "Anglo-Saxon Quantity"
+msgctxt "field:stock.move,in_anglo_saxon_quantity:"
+msgid "Input Anglo-Saxon Quantity"
+msgstr ""
+
+msgctxt "field:stock.move,out_anglo_saxon_quantity:"
+msgid "Output Anglo-Saxon Quantity"
msgstr ""
#, fuzzy
diff --git a/locale/es_ES.po b/locale/es_ES.po
index 37e3154..d07987d 100644
--- a/locale/es_ES.po
+++ b/locale/es_ES.po
@@ -22,9 +22,13 @@ msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
msgstr "Cuenta coste bienes vendidos usada"
-msgctxt "field:stock.move,anglo_saxon_quantity:"
-msgid "Anglo-Saxon Quantity"
-msgstr "Cantidad anglo-sajona"
+msgctxt "field:stock.move,in_anglo_saxon_quantity:"
+msgid "Input Anglo-Saxon Quantity"
+msgstr ""
+
+msgctxt "field:stock.move,out_anglo_saxon_quantity:"
+msgid "Output Anglo-Saxon Quantity"
+msgstr ""
msgctxt "help:product.template,account_cogs:"
msgid "This account will be used instead of the one defined on the category."
diff --git a/locale/fr_FR.po b/locale/fr_FR.po
index c979fa9..b9333bf 100644
--- a/locale/fr_FR.po
+++ b/locale/fr_FR.po
@@ -22,9 +22,13 @@ msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
msgstr "Compte \"coût des marchandises vendues\" utilisé"
-msgctxt "field:stock.move,anglo_saxon_quantity:"
-msgid "Anglo-Saxon Quantity"
-msgstr "Quantité \"anglo-saxonne\""
+msgctxt "field:stock.move,in_anglo_saxon_quantity:"
+msgid "Input Anglo-Saxon Quantity"
+msgstr "Quantité anglo-saxonne entrée"
+
+msgctxt "field:stock.move,out_anglo_saxon_quantity:"
+msgid "Output Anglo-Saxon Quantity"
+msgstr "Quantité anglo-saxonne sortie"
msgctxt "help:product.template,account_cogs:"
msgid "This account will be used instead of the one defined on the category."
diff --git a/locale/nl_NL.po b/locale/nl_NL.po
index 8d946d5..c3f2a22 100644
--- a/locale/nl_NL.po
+++ b/locale/nl_NL.po
@@ -22,8 +22,12 @@ msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
msgstr ""
-msgctxt "field:stock.move,anglo_saxon_quantity:"
-msgid "Anglo-Saxon Quantity"
+msgctxt "field:stock.move,in_anglo_saxon_quantity:"
+msgid "Input Anglo-Saxon Quantity"
+msgstr ""
+
+msgctxt "field:stock.move,out_anglo_saxon_quantity:"
+msgid "Output Anglo-Saxon Quantity"
msgstr ""
#, fuzzy
diff --git a/locale/ru_RU.po b/locale/ru_RU.po
index f6fe65b..0a0a8e2 100644
--- a/locale/ru_RU.po
+++ b/locale/ru_RU.po
@@ -22,8 +22,12 @@ msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
msgstr ""
-msgctxt "field:stock.move,anglo_saxon_quantity:"
-msgid "Anglo-Saxon Quantity"
+msgctxt "field:stock.move,in_anglo_saxon_quantity:"
+msgid "Input Anglo-Saxon Quantity"
+msgstr ""
+
+msgctxt "field:stock.move,out_anglo_saxon_quantity:"
+msgid "Output Anglo-Saxon Quantity"
msgstr ""
#, fuzzy
diff --git a/locale/es_ES.po b/locale/sl_SI.po
similarity index 55%
copy from locale/es_ES.po
copy to locale/sl_SI.po
index 37e3154..eccdac4 100644
--- a/locale/es_ES.po
+++ b/locale/sl_SI.po
@@ -4,31 +4,35 @@ msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.move:"
msgid "Anglo-Saxon quantity can not be greater than quantity."
-msgstr "La cantidad anglo-sajona no puede ser mayor que la cantidad."
+msgstr "Anglosaška količina ne more biti večja od same količine."
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
-msgstr "Cuenta coste bienes vendidos"
+msgstr "Konto stroškov prodanega blaga"
msgctxt "field:product.category,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
-msgstr "Cuenta coste bienes vendidos usada"
+msgstr "Uporabljen konto stroškov prodanega blaga"
msgctxt "field:product.template,account_cogs:"
msgid "Account Cost of Goods Sold"
-msgstr "Cuenta coste bienes vendidos"
+msgstr "Konto stroškov prodanega blaga"
msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
-msgstr "Cuenta coste bienes vendidos usada"
+msgstr "Uporabljen konto stroškov prodanega blaga"
-msgctxt "field:stock.move,anglo_saxon_quantity:"
-msgid "Anglo-Saxon Quantity"
-msgstr "Cantidad anglo-sajona"
+msgctxt "field:stock.move,in_anglo_saxon_quantity:"
+msgid "Input Anglo-Saxon Quantity"
+msgstr "Vhodna anglosaška količina"
+
+msgctxt "field:stock.move,out_anglo_saxon_quantity:"
+msgid "Output Anglo-Saxon Quantity"
+msgstr "Izhodna anglosaška količina"
msgctxt "help:product.template,account_cogs:"
msgid "This account will be used instead of the one defined on the category."
-msgstr "Se usará esta cuenta en lugar de la definida en la categoría."
+msgstr "Namesto konta v kategoriji se bo uporabil ta konto prihodkov."
msgctxt "model:account.account.template,name:account_template_cogs"
msgid "COGS"
diff --git a/product.py b/product.py
index 8f807f6..064aa3f 100644
--- a/product.py
+++ b/product.py
@@ -13,7 +13,7 @@ class Category:
account_cogs = fields.Property(fields.Many2One('account.account',
'Account Cost of Goods Sold', domain=[
('kind', '!=', 'view'),
- ('company', '=', Eval('context', {}).get('company', 0)),
+ ('company', '=', Eval('context', {}).get('company', -1)),
],
states={
'invisible': (~Eval('context', {}, ).get('company')
@@ -29,7 +29,7 @@ class Template:
account_cogs = fields.Property(fields.Many2One('account.account',
'Account Cost of Goods Sold', domain=[
('kind', '!=', 'view'),
- ('company', '=', Eval('context', {}).get('company', 0)),
+ ('company', '=', Eval('context', {}).get('company', -1)),
],
states={
'invisible': ((~Eval('context', {}).get('company'))
diff --git a/setup.py b/setup.py
index bfec75a..61f1d0a 100644
--- a/setup.py
+++ b/setup.py
@@ -65,6 +65,7 @@ setup(name='trytond_account_stock_anglo_saxon',
'Natural Language :: French',
'Natural Language :: German',
'Natural Language :: Russian',
+ 'Natural Language :: Slovenian',
'Natural Language :: Spanish',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.6',
diff --git a/stock.py b/stock.py
index ef7a979..b2e11a9 100644
--- a/stock.py
+++ b/stock.py
@@ -5,27 +5,63 @@ from trytond.model import fields
from trytond.pyson import Eval
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
+from trytond import backend
__all__ = ['Move']
__metaclass__ = PoolMeta
+def _get_field(type_):
+ if type_.startswith('in_'):
+ return 'in_anglo_saxon_quantity'
+ else:
+ return 'out_anglo_saxon_quantity'
+
+
class Move:
__name__ = 'stock.move'
- anglo_saxon_quantity = fields.Float('Anglo-Saxon Quantity', required=True,
- digits=(16, Eval('unit_digits', 2)), depends=['unit_digits'])
+ in_anglo_saxon_quantity = fields.Float('Input Anglo-Saxon Quantity',
+ required=True, digits=(16, Eval('unit_digits', 2)),
+ depends=['unit_digits'])
+ out_anglo_saxon_quantity = fields.Float('Output Anglo-Saxon Quantity',
+ required=True, digits=(16, Eval('unit_digits', 2)),
+ depends=['unit_digits'])
@classmethod
def __setup__(cls):
super(Move, cls).__setup__()
+ cls._allow_modify_closed_period.add('anglo_saxon_quantity')
cls._sql_constraints += [
- ('check_anglo_saxon_quantity',
- 'CHECK(quantity >= anglo_saxon_quantity)',
+ ('check_in_anglo_saxon_quantity',
+ 'CHECK(quantity >= in_anglo_saxon_quantity)',
+ 'Anglo-Saxon quantity can not be greater than quantity.'),
+ ('check_out_anglo_saxon_quantity',
+ 'CHECK(quantity >= out_anglo_saxon_quantity)',
'Anglo-Saxon quantity can not be greater than quantity.'),
]
+ @classmethod
+ def __register__(cls, module_name):
+ cursor = Transaction().cursor
+ TableHandler = backend.get('TableHandler')
+
+ super(Move, cls).__register__(module_name)
+ table = TableHandler(cursor, cls, module_name)
+
+ # Migration from 2.8: split anglo_saxon_quantity
+ if table.column_exist('anglo_saxon_quantity'):
+ cursor.execute('UPDATE "' + cls._table + '" '
+ 'SET in_anglo_saxon_quantity = anglo_saxon_quantity, '
+ 'out_anglo_saxon_quantity = anglo_saxon_quantity')
+ table.drop_constraint('check_anglo_saxon_quantity')
+ table.drop_column('anglo_saxon_quantity')
+
@staticmethod
- def default_anglo_saxon_quantity():
+ def default_in_anglo_saxon_quantity():
+ return 0.0
+
+ @staticmethod
+ def default_out_anglo_saxon_quantity():
return 0.0
def _get_account_stock_move_lines(self, type_):
@@ -80,10 +116,12 @@ class Move:
Uom = pool.get('product.uom')
Currency = pool.get('currency.currency')
+ as_qty_field = _get_field(type_)
+
consumed_qty = 0.0
for move in moves:
qty = Uom.compute_qty(move.uom,
- move.quantity - move.anglo_saxon_quantity,
+ move.quantity - getattr(move, as_qty_field),
move.product.default_uom, round=False)
if qty <= 0.0:
continue
@@ -121,6 +159,7 @@ class Move:
total_qty = Uom.compute_qty(uom, quantity, product.default_uom,
round=False)
+ as_qty_field = _get_field(type_)
cost = Decimal('0.0')
consumed_qty = 0.0
for move, move_qty, move_cost_price in cls._get_anglo_saxon_move(
@@ -131,9 +170,9 @@ class Move:
with Transaction().set_user(0, set_context=True):
cls.write([move], {
- 'anglo_saxon_quantity': ((move.anglo_saxon_quantity or 0.0)
- + move_qty),
- })
+ as_qty_field: (
+ (getattr(move, as_qty_field) or 0.0) + move_qty),
+ })
if consumed_qty < total_qty:
qty = total_qty - consumed_qty
@@ -146,6 +185,7 @@ class Move:
if default is None:
default = {}
default = default.copy()
- default.setdefault('anglo_saxon_quantity',
- cls.default_anglo_saxon_quantity())
+ for prefix in ('in_', 'out_'):
+ default.setdefault(prefix + 'anglo_saxon_quantity',
+ getattr(cls, 'default_%sanglo_saxon_quantity' % prefix)())
return super(Move, cls).copy(moves, default=default)
diff --git a/tests/__init__.py b/tests/__init__.py
index 7664945..e774cf4 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -2,3 +2,5 @@
#this repository contains the full copyright notices and license terms.
from .test_account_stock_anglo_saxon import suite
+
+__all__ = ['suite']
diff --git a/tests/scenario_account_stock_anglo_saxon.rst b/tests/scenario_account_stock_anglo_saxon.rst
index 864f9e8..95f464f 100644
--- a/tests/scenario_account_stock_anglo_saxon.rst
+++ b/tests/scenario_account_stock_anglo_saxon.rst
@@ -1,5 +1,5 @@
==================================
-Account Stock Continental Scenario
+Account Stock Anglo-Saxon Scenario
==================================
=============
@@ -16,8 +16,8 @@ Imports::
Create database::
- >>> current_config = config.set_trytond()
- >>> current_config.pool.test = True
+ >>> config = config.set_trytond()
+ >>> 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], current_config.context)
+ >>> Module.install([x.id for x in modules], config.context)
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
Create company::
@@ -58,8 +58,8 @@ Create company::
Reload the context::
>>> User = Model.get('res.user')
- >>> current_config._context = User.get_preferences(True,
- ... current_config.context)
+ >>> config._context = User.get_preferences(True,
+ ... config.context)
Create an accountant user::
@@ -95,14 +95,14 @@ Create fiscal year::
>>> fiscalyear.out_credit_note_sequence = invoice_sequence
>>> fiscalyear.in_credit_note_sequence = invoice_sequence
>>> fiscalyear.save()
- >>> FiscalYear.create_period([fiscalyear.id], current_config.context)
+ >>> FiscalYear.create_period([fiscalyear.id], config.context)
Create chart of accounts::
>>> AccountTemplate = Model.get('account.account.template')
>>> Account = Model.get('account.account')
>>> AccountJournal = Model.get('account.journal')
- >>> account_template, = AccountTemplate.find([('parent', '=', False)])
+ >>> account_template, = AccountTemplate.find([('parent', '=', None)])
>>> create_chart = Wizard('account.create_chart')
>>> create_chart.execute('account')
>>> create_chart.form.account_template = account_template
@@ -187,12 +187,12 @@ Create product::
>>> product.template = template
>>> product.save()
>>> template_average = ProductTemplate(ProductTemplate.copy([template.id],
- ... current_config.context)[0])
+ ... config.context)[0])
>>> template_average.cost_price_method = 'average'
>>> template_average.save()
>>> product_average = Product(Product.copy([product.id], {
... 'template': template_average.id,
- ... }, current_config.context)[0])
+ ... }, config.context)[0])
Create payment term::
@@ -222,8 +222,8 @@ Purchase 12 products::
>>> purchase_line.quantity = 7.0
>>> purchase_line.unit_price = Decimal(6)
>>> purchase.save()
- >>> Purchase.quote([purchase.id], current_config.context)
- >>> Purchase.confirm([purchase.id], current_config.context)
+ >>> Purchase.quote([purchase.id], config.context)
+ >>> Purchase.confirm([purchase.id], config.context)
>>> purchase.state
u'confirmed'
@@ -239,8 +239,8 @@ Receive 9 products::
>>> shipment.incoming_moves.append(move)
>>> move.quantity = 5.0
>>> shipment.save()
- >>> ShipmentIn.receive([shipment.id], current_config.context)
- >>> ShipmentIn.done([shipment.id], current_config.context)
+ >>> ShipmentIn.receive([shipment.id], config.context)
+ >>> ShipmentIn.done([shipment.id], config.context)
>>> shipment.state
u'done'
>>> stock_supplier.reload()
@@ -268,7 +268,7 @@ Open supplier invoice::
>>> invoice_line.unit_price = Decimal('4')
>>> invoice.invoice_date = today
>>> invoice.save()
- >>> Invoice.post([invoice.id], current_config.context)
+ >>> Invoice.post([invoice.id], config.context)
>>> invoice.state
u'posted'
>>> payable.reload()
@@ -301,9 +301,9 @@ Sale 5 products::
>>> sale_line.product = product_average
>>> sale_line.quantity = 3.0
>>> sale.save()
- >>> Sale.quote([sale.id], current_config.context)
- >>> Sale.confirm([sale.id], current_config.context)
- >>> Sale.process([sale.id], current_config.context)
+ >>> Sale.quote([sale.id], config.context)
+ >>> Sale.confirm([sale.id], config.context)
+ >>> Sale.process([sale.id], config.context)
>>> sale.state
u'processing'
@@ -311,16 +311,16 @@ Send 5 products::
>>> ShipmentOut = Model.get('stock.shipment.out')
>>> shipment, = sale.shipments
- >>> ShipmentOut.assign_try([shipment.id], current_config.context)
+ >>> ShipmentOut.assign_try([shipment.id], config.context)
True
>>> shipment.state
u'assigned'
>>> shipment.reload()
- >>> ShipmentOut.pack([shipment.id], current_config.context)
+ >>> ShipmentOut.pack([shipment.id], config.context)
>>> shipment.state
u'packed'
>>> shipment.reload()
- >>> ShipmentOut.done([shipment.id], current_config.context)
+ >>> ShipmentOut.done([shipment.id], config.context)
>>> shipment.state
u'done'
>>> stock_customer.reload()
@@ -336,7 +336,7 @@ Open customer invoice::
>>> sale.reload()
>>> invoice, = sale.invoices
- >>> Invoice.post([invoice.id], current_config.context)
+ >>> Invoice.post([invoice.id], config.context)
>>> invoice.state
u'posted'
>>> receivable.reload()
@@ -368,14 +368,34 @@ Now create a supplier invoice with an accountant::
>>> 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.quote([purchase.id], config.context)
+ >>> Purchase.confirm([purchase.id], config.context)
>>> purchase.state
u'confirmed'
- >>> new_config = config.set_trytond(user='accountant',
- ... password='accountant', database_name=current_config.database_name)
- >>> for invoice in purchase.invoices:
- ... invoice.invoice_date = today
- ... invoice.save()
- >>> Invoice.validate_invoice([i.id for i in purchase.invoices], new_config.context)
+ >>> invoice_ids = [i.id for i in purchase.invoices]
+ >>> config.user = accountant.id
+ >>> Invoice.write(invoice_ids, {
+ ... 'invoice_date': today,
+ ... }, config.context)
+ >>> Invoice.validate_invoice([i.id for i in purchase.invoices], config.context)
+
+Create customer invoice with negative quantity::
+
+ >>> invoice = Invoice()
+ >>> invoice.party = customer
+ >>> invoice.payment_term = payment_term
+ >>> invoice_line = invoice.lines.new()
+ >>> invoice_line.product = product
+ >>> invoice_line.quantity = -1
+ >>> invoice.save()
+ >>> Invoice.post([invoice.id], config.context)
+ >>> invoice.state
+ u'posted'
+ >>> move = invoice.move
+ >>> line_cogs, = (l for l in move.lines if l.account == cogs)
+ >>> line_cogs.credit == Decimal('5')
+ True
+ >>> line_stock, = (l for l in move.lines if l.account == stock_customer)
+ >>> line_stock.debit == Decimal('5')
+ True
diff --git a/tests/scenario_account_stock_anglo_saxon.rst b/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst
similarity index 57%
copy from tests/scenario_account_stock_anglo_saxon.rst
copy to tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst
index 864f9e8..a94d5cb 100644
--- a/tests/scenario_account_stock_anglo_saxon.rst
+++ b/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst
@@ -1,6 +1,6 @@
-==================================
-Account Stock Continental Scenario
-==================================
+=====================================================
+Account Stock Anglo-Saxon with Drop Shipment Scenario
+=====================================================
=============
General Setup
@@ -16,17 +16,16 @@ Imports::
Create database::
- >>> current_config = config.set_trytond()
- >>> current_config.pool.test = True
+ >>> config = config.set_trytond()
-Install account_stock_continental, sale and purchase::
+Install sale_supply, sale, purchase::
>>> Module = Model.get('ir.module.module')
>>> modules = Module.find([
... ('name', 'in', ('account_stock_anglo_saxon',
- ... 'sale', 'purchase')),
- ... ])
- >>> Module.install([x.id for x in modules], current_config.context)
+ ... 'sale_supply_drop_shipment', 'sale', 'purchase')),
+ ... ])
+ >>> Module.install([x.id for x in modules], config.context)
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
Create company::
@@ -38,14 +37,14 @@ Create company::
>>> company_config = Wizard('company.company.config')
>>> company_config.execute('company')
>>> company = company_config.form
- >>> party = Party(name='B2CK')
+ >>> party = Party(name='Dunder Mifflin')
>>> party.save()
>>> company.party = party
- >>> currencies = Currency.find([('code', '=', 'EUR')])
+ >>> currencies = Currency.find([('code', '=', 'USD')])
>>> if not currencies:
- ... currency = Currency(name='Euro', symbol=u'€', code='EUR',
+ ... currency = Currency(name='Euro', symbol=u'$', code='USD',
... rounding=Decimal('0.01'), mon_grouping='[3, 3, 0]',
- ... mon_decimal_point=',')
+ ... mon_decimal_point='.')
... currency.save()
... CurrencyRate(date=today + relativedelta(month=1, day=1),
... rate=Decimal('1.0'), currency=currency).save()
@@ -58,19 +57,51 @@ Create company::
Reload the context::
>>> User = Model.get('res.user')
- >>> 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'
+ >>> config._context = User.get_preferences(True, config.context)
+
+Create sale user::
+
+ >>> sale_user = User()
+ >>> sale_user.name = 'Sale'
+ >>> sale_user.login = 'sale'
+ >>> sale_user.main_company = company
+ >>> sale_group, = Group.find([('name', '=', 'Sales')])
+ >>> sale_user.groups.append(sale_group)
+ >>> sale_user.save()
+
+Create purchase user::
+
+ >>> purchase_user = User()
+ >>> purchase_user.name = 'Purchase'
+ >>> purchase_user.login = 'purchase'
+ >>> purchase_user.main_company = company
+ >>> purchase_group, = Group.find([('name', '=', 'Purchase')])
+ >>> purchase_user.groups.append(purchase_group)
+ >>> purchase_request_group, = Group.find(
+ ... [('name', '=', 'Purchase Request')])
+ >>> purchase_user.groups.append(purchase_request_group)
+ >>> purchase_user.save()
+
+Create stock user::
+
+ >>> stock_user = User()
+ >>> stock_user.name = 'Stock'
+ >>> stock_user.login = 'stock'
+ >>> stock_user.main_company = company
+ >>> stock_group, = Group.find([('name', '=', 'Stock')])
+ >>> stock_user.groups.append(stock_group)
+ >>> stock_user.save()
+
+Create account user::
+
+ >>> account_user = User()
+ >>> account_user.name = 'Account'
+ >>> account_user.login = 'account'
+ >>> account_user.main_company = company
>>> account_group, = Group.find([('name', '=', 'Account')])
- >>> accountant.groups.append(account_group)
- >>> accountant.save()
+ >>> account_user.groups.append(account_group)
+ >>> account_user.save()
Create fiscal year::
@@ -95,14 +126,14 @@ Create fiscal year::
>>> fiscalyear.out_credit_note_sequence = invoice_sequence
>>> fiscalyear.in_credit_note_sequence = invoice_sequence
>>> fiscalyear.save()
- >>> FiscalYear.create_period([fiscalyear.id], current_config.context)
+ >>> FiscalYear.create_period([fiscalyear.id], config.context)
Create chart of accounts::
>>> AccountTemplate = Model.get('account.account.template')
>>> Account = Model.get('account.account')
>>> AccountJournal = Model.get('account.journal')
- >>> account_template, = AccountTemplate.find([('parent', '=', False)])
+ >>> account_template, = AccountTemplate.find([('parent', '=', None)])
>>> create_chart = Wizard('account.create_chart')
>>> create_chart.execute('account')
>>> create_chart.form.account_template = account_template
@@ -148,22 +179,16 @@ Create parties::
>>> customer = Party(name='Customer')
>>> customer.save()
-Create category::
-
- >>> ProductCategory = Model.get('product.category')
- >>> category = ProductCategory(name='Category')
- >>> category.save()
-
Create product::
>>> ProductUom = Model.get('product.uom')
+ >>> ProductSupplier = Model.get('purchase.product_supplier')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> product = Product()
>>> template = ProductTemplate()
>>> template.name = 'product'
- >>> template.category = category
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.purchasable = True
@@ -183,16 +208,16 @@ Create product::
>>> template.account_journal_stock_supplier = stock_journal
>>> template.account_journal_stock_customer = stock_journal
>>> template.account_journal_stock_lost_found = stock_journal
+ >>> template.supply_on_sale = True
>>> template.save()
>>> product.template = template
>>> product.save()
- >>> template_average = ProductTemplate(ProductTemplate.copy([template.id],
- ... current_config.context)[0])
- >>> template_average.cost_price_method = 'average'
- >>> template_average.save()
- >>> product_average = Product(Product.copy([product.id], {
- ... 'template': template_average.id,
- ... }, current_config.context)[0])
+ >>> product_supplier = ProductSupplier()
+ >>> product_supplier.product = template
+ >>> product_supplier.party = supplier
+ >>> product_supplier.drop_shipment = True
+ >>> product_supplier.delivery_time = 0
+ >>> product_supplier.save()
Create payment term::
@@ -203,179 +228,117 @@ Create payment term::
>>> payment_term.lines.append(payment_term_line)
>>> payment_term.save()
-Purchase 12 products::
+Sale 50 products::
+ >>> config.user = sale_user.id
+ >>> Sale = Model.get('sale.sale')
+ >>> SaleLine = Model.get('sale.line')
+ >>> sale = Sale()
+ >>> sale.party = customer
+ >>> sale.payment_term = payment_term
+ >>> sale_line = SaleLine()
+ >>> sale.lines.append(sale_line)
+ >>> sale_line.product = product
+ >>> sale_line.quantity = 50
+ >>> sale.save()
+ >>> Sale.quote([sale.id], config.context)
+ >>> Sale.confirm([sale.id], config.context)
+ >>> Sale.process([sale.id], config.context)
+ >>> sale.state
+ u'processing'
+
+Create Purchase from Request::
+
+ >>> config.user = purchase_user.id
>>> Purchase = Model.get('purchase.purchase')
- >>> PurchaseLine = Model.get('purchase.line')
- >>> purchase = Purchase()
- >>> purchase.party = supplier
- >>> purchase.payment_term = payment_term
- >>> purchase.invoice_method = 'shipment'
- >>> purchase_line = PurchaseLine()
- >>> purchase.lines.append(purchase_line)
- >>> purchase_line.product = product
- >>> purchase_line.quantity = 5.0
- >>> purchase_line.unit_price = Decimal(4)
- >>> purchase_line = PurchaseLine()
- >>> purchase.lines.append(purchase_line)
- >>> purchase_line.product = product_average
- >>> purchase_line.quantity = 7.0
- >>> purchase_line.unit_price = Decimal(6)
+ >>> PurchaseRequest = Model.get('purchase.request')
+ >>> purchase_request, = PurchaseRequest.find()
+ >>> create_purchase = Wizard('purchase.request.create_purchase',
+ ... [purchase_request])
+ >>> create_purchase.form.payment_term = payment_term
+ >>> create_purchase.execute('start')
+ >>> purchase, = Purchase.find()
+ >>> purchase_line, = purchase.lines
+ >>> purchase_line.unit_price = Decimal('3')
>>> purchase.save()
- >>> Purchase.quote([purchase.id], current_config.context)
- >>> Purchase.confirm([purchase.id], current_config.context)
+ >>> Purchase.quote([purchase.id], config.context)
+ >>> Purchase.confirm([purchase.id], config.context)
+ >>> purchase.reload()
>>> purchase.state
u'confirmed'
+ >>> config.user = sale_user.id
+ >>> sale.reload()
+ >>> sale.shipments
+ []
+ >>> shipment, = sale.drop_shipments
-Receive 9 products::
-
- >>> ShipmentIn = Model.get('stock.shipment.in')
- >>> Move = Model.get('stock.move')
- >>> shipment = ShipmentIn(supplier=supplier)
- >>> move = Move(purchase.moves[0].id)
- >>> shipment.incoming_moves.append(move)
- >>> move.quantity = 4.0
- >>> move = Move(purchase.moves[1].id)
- >>> shipment.incoming_moves.append(move)
- >>> move.quantity = 5.0
- >>> shipment.save()
- >>> ShipmentIn.receive([shipment.id], current_config.context)
- >>> ShipmentIn.done([shipment.id], current_config.context)
+Receive 50 products::
+
+ >>> config.user = stock_user.id
+ >>> ShipmentDrop = Model.get('stock.shipment.drop')
+ >>> ShipmentDrop.done([shipment.id], config.context)
>>> shipment.state
u'done'
>>> stock_supplier.reload()
- >>> stock.reload()
>>> (stock_supplier.debit, stock_supplier.credit) == \
- ... (Decimal('0.00'), Decimal('46.00'))
+ ... (Decimal('0'), Decimal('150'))
+ True
+ >>> stock_customer.reload()
+ >>> (stock_customer.debit, stock_customer.credit) == \
+ ... (Decimal('150'), Decimal('0'))
True
>>> stock.reload()
>>> (stock.debit, stock.credit) == \
- ... (Decimal('50.00'), Decimal('0.00'))
- True
- >>> expense.reload()
- >>> (expense.debit, expense.credit) == \
- ... (Decimal('0.00'), Decimal('4.00'))
+ ... (Decimal('0'), Decimal('0'))
True
Open supplier invoice::
>>> Invoice = Model.get('account.invoice')
+ >>> config.user = purchase_user.id
>>> purchase.reload()
>>> invoice, = purchase.invoices
- >>> invoice_line = invoice.lines[0]
- >>> invoice_line.unit_price = Decimal('6')
- >>> invoice_line = invoice.lines[1]
- >>> invoice_line.unit_price = Decimal('4')
+ >>> config.user = account_user.id
>>> invoice.invoice_date = today
>>> invoice.save()
- >>> Invoice.post([invoice.id], current_config.context)
+ >>> Invoice.post([invoice.id], config.context)
>>> invoice.state
u'posted'
>>> payable.reload()
>>> (payable.debit, payable.credit) == \
- ... (Decimal('0.00'), Decimal('44.00'))
+ ... (Decimal('0.00'), Decimal('150.00'))
True
>>> expense.reload()
>>> (expense.debit, expense.credit) == \
- ... (Decimal('44.00'), Decimal('50.00'))
+ ... (Decimal('150.00'), Decimal('150.00'))
True
>>> stock_supplier.reload()
>>> (stock_supplier.debit, stock_supplier.credit) == \
- ... (Decimal('46.00'), Decimal('46.00'))
- True
-
-Sale 5 products::
-
- >>> Sale = Model.get('sale.sale')
- >>> SaleLine = Model.get('sale.line')
- >>> sale = Sale()
- >>> sale.party = customer
- >>> sale.payment_term = payment_term
- >>> sale.invoice_method = 'shipment'
- >>> sale_line = SaleLine()
- >>> sale.lines.append(sale_line)
- >>> sale_line.product = product
- >>> sale_line.quantity = 2.0
- >>> sale_line = SaleLine()
- >>> sale.lines.append(sale_line)
- >>> sale_line.product = product_average
- >>> sale_line.quantity = 3.0
- >>> sale.save()
- >>> 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'
-
-Send 5 products::
-
- >>> ShipmentOut = Model.get('stock.shipment.out')
- >>> shipment, = sale.shipments
- >>> ShipmentOut.assign_try([shipment.id], current_config.context)
- True
- >>> shipment.state
- u'assigned'
- >>> shipment.reload()
- >>> ShipmentOut.pack([shipment.id], current_config.context)
- >>> shipment.state
- u'packed'
- >>> shipment.reload()
- >>> ShipmentOut.done([shipment.id], current_config.context)
- >>> shipment.state
- u'done'
- >>> stock_customer.reload()
- >>> (stock_customer.debit, stock_customer.credit) == \
- ... (Decimal('28.00'), Decimal('0.00'))
- True
- >>> stock.reload()
- >>> (stock.debit, stock.credit) == \
- ... (Decimal('50.00'), Decimal('28.00'))
+ ... (Decimal('150.00'), Decimal('150.00'))
True
Open customer invoice::
+ >>> config.user = sale_user.id
>>> sale.reload()
>>> invoice, = sale.invoices
- >>> Invoice.post([invoice.id], current_config.context)
+ >>> config.user = account_user.id
+ >>> Invoice.post([invoice.id], config.context)
>>> invoice.state
u'posted'
>>> receivable.reload()
>>> (receivable.debit, receivable.credit) == \
- ... (Decimal('50.00'), Decimal('0.00'))
+ ... (Decimal('500.00'), Decimal('0.00'))
True
>>> revenue.reload()
>>> (revenue.debit, revenue.credit) == \
- ... (Decimal('0.00'), Decimal('50.00'))
+ ... (Decimal('0.00'), Decimal('500.00'))
True
>>> stock_customer.reload()
>>> (stock_customer.debit, stock_customer.credit) == \
- ... (Decimal('28.00'), Decimal('28.00'))
+ ... (Decimal('150.00'), Decimal('150.00'))
True
>>> cogs.reload()
>>> (cogs.debit, cogs.credit) == \
- ... (Decimal('28.00'), Decimal('0.00'))
+ ... (Decimal('150.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)
- >>> for invoice in purchase.invoices:
- ... invoice.invoice_date = today
- ... invoice.save()
- >>> Invoice.validate_invoice([i.id for i in purchase.invoices], new_config.context)
diff --git a/tests/test_account_stock_anglo_saxon.py b/tests/test_account_stock_anglo_saxon.py
index ad5a7bf..423cd3b 100644
--- a/tests/test_account_stock_anglo_saxon.py
+++ b/tests/test_account_stock_anglo_saxon.py
@@ -58,6 +58,10 @@ def suite():
'scenario_account_stock_anglo_saxon.rst',
setUp=doctest_dropdb, tearDown=doctest_dropdb, encoding='utf-8',
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
+ suite.addTests(doctest.DocFileSuite(
+ 'scenario_account_stock_anglo_saxon_with_drop_shipment.rst',
+ setUp=doctest_dropdb, tearDown=doctest_dropdb, encoding='utf-8',
+ optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite
if __name__ == '__main__':
diff --git a/tryton.cfg b/tryton.cfg
index 7f46675..1522184 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
-version=2.8.1
+version=3.0.0
depends:
account
account_invoice
diff --git a/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO b/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
index 53ff22b..18d1408 100644
--- a/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
+++ b/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: trytond-account-stock-anglo-saxon
-Version: 2.8.1
+Version: 3.0.0
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
Author-email: UNKNOWN
License: GPL-3
-Download-URL: http://downloads.tryton.org/2.8/
+Download-URL: http://downloads.tryton.org/3.0/
Description: trytond_account_stock_anglo_saxon
=================================
@@ -58,6 +58,7 @@ Classifier: Natural Language :: English
Classifier: Natural Language :: French
Classifier: Natural Language :: German
Classifier: Natural Language :: Russian
+Classifier: Natural Language :: Slovenian
Classifier: Natural Language :: Spanish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.6
diff --git a/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt b/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt
index ba8b9e8..f0935a2 100644
--- a/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt
+++ b/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt
@@ -25,7 +25,9 @@ locale/es_ES.po
locale/fr_FR.po
locale/nl_NL.po
locale/ru_RU.po
+locale/sl_SI.po
tests/scenario_account_stock_anglo_saxon.rst
+tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst
trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt
trytond_account_stock_anglo_saxon.egg-info/dependency_links.txt
diff --git a/trytond_account_stock_anglo_saxon.egg-info/requires.txt b/trytond_account_stock_anglo_saxon.egg-info/requires.txt
index e078072..d3213c1 100644
--- a/trytond_account_stock_anglo_saxon.egg-info/requires.txt
+++ b/trytond_account_stock_anglo_saxon.egg-info/requires.txt
@@ -1,7 +1,7 @@
-trytond_account >= 2.8, < 2.9
-trytond_account_invoice >= 2.8, < 2.9
-trytond_account_product >= 2.8, < 2.9
-trytond_account_stock_continental >= 2.8, < 2.9
-trytond_purchase >= 2.8, < 2.9
-trytond_sale >= 2.8, < 2.9
-trytond >= 2.8, < 2.9
\ No newline at end of file
+trytond_account >= 3.0, < 3.1
+trytond_account_invoice >= 3.0, < 3.1
+trytond_account_product >= 3.0, < 3.1
+trytond_account_stock_continental >= 3.0, < 3.1
+trytond_purchase >= 3.0, < 3.1
+trytond_sale >= 3.0, < 3.1
+trytond >= 3.0, < 3.1
\ No newline at end of file
commit 13f595f8d0b0a7525112ae7017181042d37040b4
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Sun Oct 13 20:01:54 2013 +0200
Adding upstream version 2.8.1.
diff --git a/CHANGELOG b/CHANGELOG
index f67d23f..7125dea 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 2.8.1 - 2013-10-01
+* Bug fixes (see mercurial logs for details)
+
Version 2.8.0 - 2013-04-22
* Bug fixes (see mercurial logs for details)
diff --git a/PKG-INFO b/PKG-INFO
index 5dd8970..52d9e53 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond_account_stock_anglo_saxon
-Version: 2.8.0
+Version: 2.8.1
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
diff --git a/invoice.py b/invoice.py
index 5858c66..3ffb054 100644
--- a/invoice.py
+++ b/invoice.py
@@ -74,10 +74,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_)
diff --git a/tryton.cfg b/tryton.cfg
index 812693d..7f46675 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
-version=2.8.0
+version=2.8.1
depends:
account
account_invoice
diff --git a/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO b/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
index 7aef0fa..53ff22b 100644
--- a/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
+++ b/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond-account-stock-anglo-saxon
-Version: 2.8.0
+Version: 2.8.1
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
commit 539c6f6dcacf4d8df6ea592cd31c7a449232a035
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Thu May 2 00:35:05 2013 +0200
Adding upstream version 2.8.0.
diff --git a/CHANGELOG b/CHANGELOG
index ae0a4df..f67d23f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,7 +1,4 @@
-Version 2.6.2 - 2013-02-12
-* Bug fixes (see mercurial logs for details)
-
-Version 2.6.1 - 2012-12-23
+Version 2.8.0 - 2013-04-22
* Bug fixes (see mercurial logs for details)
Version 2.6.0 - 2012-10-22
diff --git a/MANIFEST.in b/MANIFEST.in
index 478d5ff..fc0b03e 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -6,6 +6,7 @@ include CHANGELOG
include LICENSE
include tryton.cfg
include *.xml
+include view/*.xml
include *.odt
include locale/*.po
include doc/*
diff --git a/PKG-INFO b/PKG-INFO
index 4659dff..5dd8970 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: trytond_account_stock_anglo_saxon
-Version: 2.6.2
+Version: 2.8.0
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
Author-email: UNKNOWN
License: GPL-3
-Download-URL: http://downloads.tryton.org/2.6/
+Download-URL: http://downloads.tryton.org/2.8/
Description: trytond_account_stock_anglo_saxon
=================================
diff --git a/account.xml b/account.xml
index 9bffa7a..a2934c2 100644
--- a/account.xml
+++ b/account.xml
@@ -13,5 +13,23 @@ this repository contains the full copyright notices and license terms. -->
<field name="kind">other</field>
</record>
+ <!-- Read access to compute anglo saxon account.move lines -->
+ <record model="ir.model.access" id="access_purchase_line_account">
+ <field name="model" search="[('model', '=', 'purchase.line')]"/>
+ <field name="group" ref="account.group_account"/>
+ <field name="perm_read" eval="True"/>
+ <field name="perm_write" eval="False"/>
+ <field name="perm_create" eval="False"/>
+ <field name="perm_delete" eval="False"/>
+ </record>
+ <record model="ir.model.access" id="access_sale_line_account">
+ <field name="model" search="[('model', '=', 'sale.line')]"/>
+ <field name="group" ref="account.group_account"/>
+ <field name="perm_read" eval="True"/>
+ <field name="perm_write" eval="False"/>
+ <field name="perm_create" eval="False"/>
+ <field name="perm_delete" eval="False"/>
+ </record>
+
</data>
</tryton>
diff --git a/invoice.py b/invoice.py
index 347e990..5858c66 100644
--- a/invoice.py
+++ b/invoice.py
@@ -3,7 +3,6 @@
from decimal import Decimal
import operator
from trytond.pool import Pool, PoolMeta
-from trytond.transaction import Transaction
__all__ = ['InvoiceLine']
__metaclass__ = PoolMeta
@@ -39,7 +38,7 @@ class InvoiceLine:
result.append(move_line)
move_line = move_line.copy()
move_line['debit'], move_line['credit'] = \
- move_line['credit'], move_line['debit']
+ move_line['credit'], move_line['debit']
if type_.endswith('supplier'):
move_line['account'] = self.account.id
else:
@@ -48,7 +47,10 @@ class InvoiceLine:
return result
def get_move_line(self):
- Move = Pool().get('stock.move')
+ pool = Pool()
+ Move = pool.get('stock.move')
+ PurchaseLine = pool.get('purchase.line')
+ SaleLine = pool.get('sale.line')
result = super(InvoiceLine, self).get_move_line()
@@ -61,18 +63,9 @@ class InvoiceLine:
moves = []
# other types will get current cost price
- if self.invoice.type == 'in_invoice':
- 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':
- with Transaction().set_user(0, set_context=True):
- sale_lines = self.__class__(self.id).sale_lines
- moves = [move for sale_line in sale_lines
- for move in sale_line.moves
- if move.state == 'done']
+ if isinstance(self.origin, (PurchaseLine, SaleLine)):
+ moves = [move for move in self.origin.moves
+ if move.state == 'done']
if self.invoice.type == 'in_invoice':
type_ = 'in_supplier'
elif self.invoice.type == 'out_invoice':
diff --git a/locale/bg_BG.po b/locale/bg_BG.po
index 2d0ee0d..c5b09af 100644
--- a/locale/bg_BG.po
+++ b/locale/bg_BG.po
@@ -3,7 +3,7 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.move:"
-msgid "Anglo-Saxon quantity can not be greater than quantity!"
+msgid "Anglo-Saxon quantity can not be greater than quantity."
msgstr ""
msgctxt "field:product.category,account_cogs:"
diff --git a/locale/ca_ES.po b/locale/ca_ES.po
index a6c2822..d91f4f6 100644
--- a/locale/ca_ES.po
+++ b/locale/ca_ES.po
@@ -3,7 +3,7 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.move:"
-msgid "Anglo-Saxon quantity can not be greater than quantity!"
+msgid "Anglo-Saxon quantity can not be greater than quantity."
msgstr "La quantitat anglo-saxona no pot ser major que la quantitat."
msgctxt "field:product.category,account_cogs:"
diff --git a/locale/cs_CZ.po b/locale/cs_CZ.po
index 9773bf1..d6551d4 100644
--- a/locale/cs_CZ.po
+++ b/locale/cs_CZ.po
@@ -3,7 +3,7 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.move:"
-msgid "Anglo-Saxon quantity can not be greater than quantity!"
+msgid "Anglo-Saxon quantity can not be greater than quantity."
msgstr ""
msgctxt "field:product.category,account_cogs:"
diff --git a/locale/de_DE.po b/locale/de_DE.po
index 703912a..a019334 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -3,9 +3,8 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.move:"
-msgid "Anglo-Saxon quantity can not be greater than quantity!"
-msgstr ""
-"Anzahl nach angelsächsicher Bewertung kann nicht größer als Anzahl sein!"
+msgid "Anglo-Saxon quantity can not be greater than quantity."
+msgstr "Anzahl (Angelsächsische Bewertung) kann nicht größer als Anzahl sein."
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
diff --git a/locale/es_AR.po b/locale/es_AR.po
index ef6724b..1f33853 100644
--- a/locale/es_AR.po
+++ b/locale/es_AR.po
@@ -3,32 +3,32 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.move:"
-msgid "Anglo-Saxon quantity can not be greater than quantity!"
-msgstr "¡La cantidad anglosajona no puede ser mayor que la cantidad!"
+msgid "Anglo-Saxon quantity can not be greater than quantity."
+msgstr "La cantidad anglo-sajona no puede ser mayor que la cantidad."
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
-msgstr "Cuenta de Costos de Mercaderías Vendidas"
+msgstr "Cuenta de Costo de Mercaderías Vendidas"
msgctxt "field:product.category,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
-msgstr "Cuenta de Costos de Mercaderías Vendidas utilizada"
+msgstr "Cuenta de Costo de Mercaderías Vendidas utilizada"
msgctxt "field:product.template,account_cogs:"
msgid "Account Cost of Goods Sold"
-msgstr "Cuenta de Costos de Mercaderías Vendidas"
+msgstr "Cuenta de Costo de Mercaderías Vendidas"
msgctxt "field:product.template,account_cogs_used:"
msgid "Account Cost of Goods Sold Used"
-msgstr "Cuenta de Costos de Mercaderías Vendidas utilizada"
+msgstr "Cuenta de Costo de Mercaderías Vendidas utilizada"
msgctxt "field:stock.move,anglo_saxon_quantity:"
msgid "Anglo-Saxon Quantity"
-msgstr "Cantidad Anglosajona"
+msgstr "Cantidad anglo-sajona"
msgctxt "help:product.template,account_cogs:"
msgid "This account will be used instead of the one defined on the category."
-msgstr "Esta cuenta se usará en lugar de la definida en la categoría."
+msgstr "Se usará esta cuenta en lugar de la definida en la categoría."
msgctxt "model:account.account.template,name:account_template_cogs"
msgid "COGS"
diff --git a/locale/es_CO.po b/locale/es_CO.po
index e5816f9..27fe566 100644
--- a/locale/es_CO.po
+++ b/locale/es_CO.po
@@ -3,7 +3,7 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.move:"
-msgid "Anglo-Saxon quantity can not be greater than quantity!"
+msgid "Anglo-Saxon quantity can not be greater than quantity."
msgstr ""
msgctxt "field:product.category,account_cogs:"
diff --git a/locale/es_ES.po b/locale/es_ES.po
index 317eac2..37e3154 100644
--- a/locale/es_ES.po
+++ b/locale/es_ES.po
@@ -3,7 +3,7 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.move:"
-msgid "Anglo-Saxon quantity can not be greater than quantity!"
+msgid "Anglo-Saxon quantity can not be greater than quantity."
msgstr "La cantidad anglo-sajona no puede ser mayor que la cantidad."
msgctxt "field:product.category,account_cogs:"
diff --git a/locale/fr_FR.po b/locale/fr_FR.po
index 35b14a4..c979fa9 100644
--- a/locale/fr_FR.po
+++ b/locale/fr_FR.po
@@ -3,8 +3,8 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.move:"
-msgid "Anglo-Saxon quantity can not be greater than quantity!"
-msgstr "La quantité \"anglo-saxonne\" ne peut être supérieur à la quantité !"
+msgid "Anglo-Saxon quantity can not be greater than quantity."
+msgstr "La quantité anglo-saxonne ne peut être plus grande que la quantité."
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
diff --git a/locale/nl_NL.po b/locale/nl_NL.po
index e1b1453..8d946d5 100644
--- a/locale/nl_NL.po
+++ b/locale/nl_NL.po
@@ -3,7 +3,7 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.move:"
-msgid "Anglo-Saxon quantity can not be greater than quantity!"
+msgid "Anglo-Saxon quantity can not be greater than quantity."
msgstr ""
msgctxt "field:product.category,account_cogs:"
diff --git a/locale/ru_RU.po b/locale/ru_RU.po
index 9773bf1..f6fe65b 100644
--- a/locale/ru_RU.po
+++ b/locale/ru_RU.po
@@ -3,7 +3,7 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.move:"
-msgid "Anglo-Saxon quantity can not be greater than quantity!"
+msgid "Anglo-Saxon quantity can not be greater than quantity."
msgstr ""
msgctxt "field:product.category,account_cogs:"
@@ -26,9 +26,10 @@ msgctxt "field:stock.move,anglo_saxon_quantity:"
msgid "Anglo-Saxon Quantity"
msgstr ""
+#, fuzzy
msgctxt "help:product.template,account_cogs:"
msgid "This account will be used instead of the one defined on the category."
-msgstr ""
+msgstr "Этот счет будет использован вместо указанного в категории."
msgctxt "model:account.account.template,name:account_template_cogs"
msgid "COGS"
diff --git a/product.xml b/product.xml
index f859e81..a0e768d 100644
--- a/product.xml
+++ b/product.xml
@@ -7,35 +7,13 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.ui.view" id="category_view_form">
<field name="model">product.category</field>
<field name="inherit" ref="product.category_view_form"/>
- <field name="arch" type="xml">
- <![CDATA[
- <data>
- <xpath
- expr="/form/notebook/page[@id='accounting']/field[@name='account_stock']"
- position="after">
- <label name="account_cogs"/>
- <field name="account_cogs"/>
- </xpath>
- </data>
- ]]>
- </field>
+ <field name="name">category_form</field>
</record>
<record model="ir.ui.view" id="template_view_form">
<field name="model">product.template</field>
<field name="inherit" ref="product.template_view_form"/>
- <field name="arch" type="xml">
- <![CDATA[
- <data>
- <xpath
- expr="/form/notebook/page[@id='accounting']/field[@name='account_stock']"
- position="after">
- <label name="account_cogs"/>
- <field name="account_cogs"/>
- </xpath>
- </data>
- ]]>
- </field>
+ <field name="name">template_form</field>
</record>
</data>
diff --git a/setup.py b/setup.py
index fe52256..bfec75a 100644
--- a/setup.py
+++ b/setup.py
@@ -39,16 +39,16 @@ setup(name='trytond_account_stock_anglo_saxon',
long_description=read('README'),
author='Tryton',
url='http://www.tryton.org/',
- download_url="http://downloads.tryton.org/" + \
- info.get('version', '0.0.1').rsplit('.', 1)[0] + '/',
+ download_url=("http://downloads.tryton.org/" +
+ info.get('version', '0.0.1').rsplit('.', 1)[0] + '/'),
package_dir={'trytond.modules.account_stock_anglo_saxon': '.'},
packages=[
'trytond.modules.account_stock_anglo_saxon',
'trytond.modules.account_stock_anglo_saxon.tests',
],
package_data={
- 'trytond.modules.account_stock_anglo_saxon': info.get('xml', []) \
- + ['tryton.cfg', 'locale/*.po', 'tests/*.rst'],
+ 'trytond.modules.account_stock_anglo_saxon': (info.get('xml', [])
+ + ['tryton.cfg', 'view/*.xml', 'locale/*.po', 'tests/*.rst']),
},
classifiers=[
'Development Status :: 5 - Production/Stable',
diff --git a/stock.py b/stock.py
index d5034a9..ef7a979 100644
--- a/stock.py
+++ b/stock.py
@@ -21,7 +21,7 @@ class Move:
cls._sql_constraints += [
('check_anglo_saxon_quantity',
'CHECK(quantity >= anglo_saxon_quantity)',
- 'Anglo-Saxon quantity can not be greater than quantity!'),
+ 'Anglo-Saxon quantity can not be greater than quantity.'),
]
@staticmethod
@@ -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
@@ -66,13 +70,15 @@ class Move:
return lines
@classmethod
- def _get_anglo_saxon_move(cls, moves, quantity):
+ def _get_anglo_saxon_move(cls, moves, quantity, type_):
'''
- Generator of (move, qty) where move is the move to be consumed and qty
- is the quantity (in the product default uom) to be consumed on this
- move.
+ Generator of (move, qty, cost_price) where move is the move to be
+ consumed, qty is the quantity (in the product default uom) to be
+ consumed on this move and cost_price is in the company currency.
'''
- Uom = Pool().get('product.uom')
+ pool = Pool()
+ Uom = pool.get('product.uom')
+ Currency = pool.get('currency.currency')
consumed_qty = 0.0
for move in moves:
@@ -85,7 +91,17 @@ class Move:
qty = quantity - consumed_qty
if consumed_qty >= quantity:
break
- yield (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)
+ cost_price = Uom.compute_price(move.uom,
+ unit_price, move.product.default_uom)
+ else:
+ cost_price = move.cost_price
+
+ yield (move, qty, cost_price)
@classmethod
def update_anglo_saxon_quantity_product_cost(cls, product, moves,
@@ -94,7 +110,8 @@ 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')
for move in moves:
assert move.product == product, 'wrong product'
@@ -106,14 +123,10 @@ class Move:
cost = Decimal('0.0')
consumed_qty = 0.0
- for move, move_qty in cls._get_anglo_saxon_move(moves, total_qty):
+ for move, move_qty, move_cost_price in cls._get_anglo_saxon_move(
+ moves, total_qty, type_):
consumed_qty += move_qty
- if type_.startswith('in_'):
- move_cost_price = Uom.compute_price(move.uom,
- move.unit_price, move.product.default_uom)
- else:
- move_cost_price = move.cost_price
cost += move_cost_price * Decimal(str(move_qty))
with Transaction().set_user(0, set_context=True):
diff --git a/tests/scenario_account_stock_anglo_saxon.rst b/tests/scenario_account_stock_anglo_saxon.rst
index 820d7ef..864f9e8 100644
--- a/tests/scenario_account_stock_anglo_saxon.rst
+++ b/tests/scenario_account_stock_anglo_saxon.rst
@@ -34,10 +34,13 @@ Create company::
>>> Currency = Model.get('currency.currency')
>>> CurrencyRate = Model.get('currency.currency.rate')
>>> Company = Model.get('company.company')
+ >>> Party = Model.get('party.party')
>>> company_config = Wizard('company.company.config')
>>> company_config.execute('company')
>>> company = company_config.form
- >>> company.name = 'B2CK'
+ >>> party = Party(name='B2CK')
+ >>> party.save()
+ >>> company.party = party
>>> currencies = Currency.find([('code', '=', 'EUR')])
>>> if not currencies:
... currency = Currency(name='Euro', symbol=u'€', code='EUR',
@@ -155,34 +158,41 @@ Create product::
>>> ProductUom = Model.get('product.uom')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
+ >>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> product = Product()
- >>> product.name = 'product'
- >>> product.category = category
- >>> product.default_uom = unit
- >>> product.type = 'goods'
- >>> product.purchasable = True
- >>> product.salable = True
- >>> product.list_price = Decimal('10')
- >>> product.cost_price = Decimal('5')
- >>> product.cost_price_method = 'fixed'
- >>> product.delivery_time = 0
- >>> product.account_expense = expense
- >>> product.account_revenue = revenue
- >>> product.account_stock = stock
- >>> product.account_cogs = cogs
- >>> product.account_stock_supplier = stock_supplier
- >>> product.account_stock_customer = stock_customer
- >>> product.account_stock_production = stock_production
- >>> product.account_stock_lost_found = stock_lost_found
- >>> product.account_journal_stock_supplier = stock_journal
- >>> product.account_journal_stock_customer = stock_journal
- >>> product.account_journal_stock_lost_found = stock_journal
+ >>> template = ProductTemplate()
+ >>> template.name = 'product'
+ >>> template.category = category
+ >>> template.default_uom = unit
+ >>> template.type = 'goods'
+ >>> template.purchasable = True
+ >>> template.salable = True
+ >>> template.list_price = Decimal('10')
+ >>> template.cost_price = Decimal('5')
+ >>> template.cost_price_method = 'fixed'
+ >>> template.delivery_time = 0
+ >>> template.account_expense = expense
+ >>> template.account_revenue = revenue
+ >>> template.account_stock = stock
+ >>> template.account_cogs = cogs
+ >>> template.account_stock_supplier = stock_supplier
+ >>> template.account_stock_customer = stock_customer
+ >>> template.account_stock_production = stock_production
+ >>> template.account_stock_lost_found = stock_lost_found
+ >>> template.account_journal_stock_supplier = stock_journal
+ >>> template.account_journal_stock_customer = stock_journal
+ >>> template.account_journal_stock_lost_found = stock_journal
+ >>> template.save()
+ >>> product.template = template
>>> product.save()
- >>> product_average = Product(Product.copy([product.id],
- ... current_config.context)[0])
- >>> product_average.cost_price_method = 'average'
- >>> product_average.save()
+ >>> template_average = ProductTemplate(ProductTemplate.copy([template.id],
+ ... current_config.context)[0])
+ >>> template_average.cost_price_method = 'average'
+ >>> template_average.save()
+ >>> product_average = Product(Product.copy([product.id], {
+ ... 'template': template_average.id,
+ ... }, current_config.context)[0])
Create payment term::
@@ -256,10 +266,11 @@ Open supplier invoice::
>>> invoice_line.unit_price = Decimal('6')
>>> invoice_line = invoice.lines[1]
>>> invoice_line.unit_price = Decimal('4')
+ >>> invoice.invoice_date = today
>>> invoice.save()
- >>> Invoice.open([invoice.id], current_config.context)
+ >>> Invoice.post([invoice.id], current_config.context)
>>> invoice.state
- u'open'
+ u'posted'
>>> payable.reload()
>>> (payable.debit, payable.credit) == \
... (Decimal('0.00'), Decimal('44.00'))
@@ -325,9 +336,9 @@ Open customer invoice::
>>> sale.reload()
>>> invoice, = sale.invoices
- >>> Invoice.open([invoice.id], current_config.context)
+ >>> Invoice.post([invoice.id], current_config.context)
>>> invoice.state
- u'open'
+ u'posted'
>>> receivable.reload()
>>> (receivable.debit, receivable.credit) == \
... (Decimal('50.00'), Decimal('0.00'))
@@ -364,5 +375,7 @@ Now create a supplier invoice with an accountant::
>>> 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)
+ >>> for invoice in purchase.invoices:
+ ... invoice.invoice_date = today
+ ... invoice.save()
+ >>> Invoice.validate_invoice([i.id for i in purchase.invoices], new_config.context)
diff --git a/tryton.cfg b/tryton.cfg
index 2502cf8..812693d 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
-version=2.6.2
+version=2.8.0
depends:
account
account_invoice
diff --git a/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO b/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
index 6958eb8..7aef0fa 100644
--- a/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
+++ b/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: trytond-account-stock-anglo-saxon
-Version: 2.6.2
+Version: 2.8.0
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
Author-email: UNKNOWN
License: GPL-3
-Download-URL: http://downloads.tryton.org/2.6/
+Download-URL: http://downloads.tryton.org/2.8/
Description: trytond_account_stock_anglo_saxon
=================================
diff --git a/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt b/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt
index 4cd62de..ba8b9e8 100644
--- a/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt
+++ b/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt
@@ -32,4 +32,6 @@ trytond_account_stock_anglo_saxon.egg-info/dependency_links.txt
trytond_account_stock_anglo_saxon.egg-info/entry_points.txt
trytond_account_stock_anglo_saxon.egg-info/not-zip-safe
trytond_account_stock_anglo_saxon.egg-info/requires.txt
-trytond_account_stock_anglo_saxon.egg-info/top_level.txt
\ No newline at end of file
+trytond_account_stock_anglo_saxon.egg-info/top_level.txt
+view/category_form.xml
+view/template_form.xml
\ No newline at end of file
diff --git a/trytond_account_stock_anglo_saxon.egg-info/requires.txt b/trytond_account_stock_anglo_saxon.egg-info/requires.txt
index 3a62417..e078072 100644
--- a/trytond_account_stock_anglo_saxon.egg-info/requires.txt
+++ b/trytond_account_stock_anglo_saxon.egg-info/requires.txt
@@ -1,7 +1,7 @@
-trytond_account >= 2.6, < 2.7
-trytond_account_invoice >= 2.6, < 2.7
-trytond_account_product >= 2.6, < 2.7
-trytond_account_stock_continental >= 2.6, < 2.7
-trytond_purchase >= 2.6, < 2.7
-trytond_sale >= 2.6, < 2.7
-trytond >= 2.6, < 2.7
\ No newline at end of file
+trytond_account >= 2.8, < 2.9
+trytond_account_invoice >= 2.8, < 2.9
+trytond_account_product >= 2.8, < 2.9
+trytond_account_stock_continental >= 2.8, < 2.9
+trytond_purchase >= 2.8, < 2.9
+trytond_sale >= 2.8, < 2.9
+trytond >= 2.8, < 2.9
\ No newline at end of file
diff --git a/view/category_form.xml b/view/category_form.xml
new file mode 100644
index 0000000..637110c
--- /dev/null
+++ b/view/category_form.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<data>
+ <xpath
+ expr="/form/notebook/page[@id='accounting']/field[@name='account_stock']"
+ position="after">
+ <label name="account_cogs"/>
+ <field name="account_cogs"/>
+ </xpath>
+</data>
diff --git a/view/template_form.xml b/view/template_form.xml
new file mode 100644
index 0000000..637110c
--- /dev/null
+++ b/view/template_form.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<data>
+ <xpath
+ expr="/form/notebook/page[@id='accounting']/field[@name='account_stock']"
+ position="after">
+ <label name="account_cogs"/>
+ <field name="account_cogs"/>
+ </xpath>
+</data>
commit 0f9d94395d1079eec6ca7b7db5ffde47f4e4f08c
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Mon Apr 22 23:22:56 2013 +0200
Adding upstream version 2.6.2.
diff --git a/CHANGELOG b/CHANGELOG
index fbf3ef4..ae0a4df 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 e792a2c..7e8c156 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
diff --git a/PKG-INFO b/PKG-INFO
index 58ac3c7..4659dff 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond_account_stock_anglo_saxon
-Version: 2.6.1
+Version: 2.6.2
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
diff --git a/stock.py b/stock.py
index f9fbe37..d5034a9 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
diff --git a/tryton.cfg b/tryton.cfg
index 497939a..2502cf8 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
-version=2.6.1
+version=2.6.2
depends:
account
account_invoice
diff --git a/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO b/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
index 019961f..6958eb8 100644
--- a/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
+++ b/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: trytond-account-stock-anglo-saxon
-Version: 2.6.1
+Version: 2.6.2
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
commit fe69bad457d20336d9164b7c1b297afe13dc1c9b
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Mon Apr 22 23:22:06 2013 +0200
Adding upstream version 2.6.1.
diff --git a/CHANGELOG b/CHANGELOG
index b6ff5a1..fbf3ef4 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)
diff --git a/PKG-INFO b/PKG-INFO
index b4e2ee6..58ac3c7 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
Name: trytond_account_stock_anglo_saxon
-Version: 2.6.0
+Version: 2.6.1
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
diff --git a/invoice.py b/invoice.py
index 9fe6f16..347e990 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 2767008..820d7ef 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)
diff --git a/tryton.cfg b/tryton.cfg
index 715d1a5..497939a 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
-version=2.6.0
+version=2.6.1
depends:
account
account_invoice
diff --git a/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO b/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
index d9a79e6..019961f 100644
--- a/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
+++ b/trytond_account_stock_anglo_saxon.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
Name: trytond-account-stock-anglo-saxon
-Version: 2.6.0
+Version: 2.6.1
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
--
tryton-modules-account-stock-anglo-saxon
More information about the tryton-debian-vcs
mailing list