[tryton-debian-vcs] tryton-modules-account-stock-anglo-saxon branch upstream updated. upstream/3.4.1-1-gca3855f
Mathias Behrle
tryton-debian-vcs at alioth.debian.org
Thu Apr 23 16:02:21 UTC 2015
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=upstream/3.4.1-1-gca3855f
commit ca3855fd8b75c79d51aa109247749a144d96117a
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Thu Apr 23 16:59:52 2015 +0200
Adding upstream version 3.6.0.
Signed-off-by: Mathias Behrle <mathiasb at m9s.biz>
diff --git a/CHANGELOG b/CHANGELOG
index 6ba35ab..0cbd9b6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,7 @@
-Version 3.4.1 - 2015-03-01
+Version 3.6.0 - 2015-04-20
* Bug fixes (see mercurial logs for details)
+* Add support for PyPy
+* Allow to override the stock moves used to compute the account move
Version 3.4.0 - 2014-10-20
* Bug fixes (see mercurial logs for details)
diff --git a/PKG-INFO b/PKG-INFO
index 3f9ab1b..230090b 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: trytond_account_stock_anglo_saxon
-Version: 3.4.1
+Version: 3.6.0
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
Author-email: issue_tracker at tryton.org
License: GPL-3
-Download-URL: http://downloads.tryton.org/3.4/
+Download-URL: http://downloads.tryton.org/3.6/
Description: trytond_account_stock_anglo_saxon
=================================
@@ -63,5 +63,7 @@ Classifier: Natural Language :: Slovenian
Classifier: Natural Language :: Spanish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Office/Business
Classifier: Topic :: Office/Business :: Financial :: Accounting
diff --git a/__init__.py b/__init__.py
index 78065e2..b13dc61 100644
--- a/__init__.py
+++ b/__init__.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
from .product import *
diff --git a/account.py b/account.py
index 40f31f3..089549d 100644
--- a/account.py
+++ b/account.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
from trytond.pool import PoolMeta
__all__ = ['FiscalYear']
diff --git a/invoice.py b/invoice.py
index d352dd9..424f825 100644
--- a/invoice.py
+++ b/invoice.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
from decimal import Decimal
import operator
from trytond.pool import Pool, PoolMeta
@@ -21,7 +21,7 @@ class InvoiceLine:
result = []
move_line = {}
move_line['description'] = self.description
- move_line['amount_second_currency'] = Decimal('0.0')
+ move_line['amount_second_currency'] = None
move_line['second_currency'] = None
if type_.startswith('in_'):
@@ -46,11 +46,18 @@ class InvoiceLine:
result.append(move_line)
return result
- def get_move_line(self):
+ @property
+ def _anglo_saxon_stock_moves(self):
pool = Pool()
- Move = pool.get('stock.move')
PurchaseLine = pool.get('purchase.line')
SaleLine = pool.get('sale.line')
+ if isinstance(self.origin, (PurchaseLine, SaleLine)):
+ return list(self.origin.moves)
+ return []
+
+ def get_move_line(self):
+ pool = Pool()
+ Move = pool.get('stock.move')
Period = pool.get('account.period')
result = super(InvoiceLine, self).get_move_line()
@@ -69,11 +76,9 @@ class InvoiceLine:
if period.fiscalyear.account_stock_method != 'anglo_saxon':
return result
- moves = []
- # other types will get current cost price
- if isinstance(self.origin, (PurchaseLine, SaleLine)):
- moves = [move for move in self.origin.moves
- if move.state == 'done']
+ # an empty list means we'll use the current cost price
+ moves = [move for move in self._anglo_saxon_stock_moves
+ if move.state == 'done']
if self.invoice.type == 'in_invoice':
type_ = 'in_supplier'
elif self.invoice.type == 'out_invoice':
diff --git a/locale/es_EC.po b/locale/es_EC.po
index 39070d9..17ea147 100644
--- a/locale/es_EC.po
+++ b/locale/es_EC.po
@@ -8,31 +8,31 @@ msgstr "La cantidad anglosajona no puede ser mayor que la cantidad."
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
-msgstr "Cuenta de Costo 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 Costo 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 Costo 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 Costo de Mercaderías Vendidas Utilizada"
+msgstr "Cuenta de costo de mercaderías vendidas utilizada"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
-msgstr "Cantidad Anglosajona de Ingreso"
+msgstr "Cantidad anglosajona de ingreso"
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
-msgstr "Cantidad Anglosajona de Salida"
+msgstr "Cantidad anglosajona de salida"
msgctxt "help:product.template,account_cogs:"
msgid "This account will be used instead of the one defined on the category."
-msgstr "Esta cuenta se utilizará en lugar de la definida en la categoría."
+msgstr "Se utilizará 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/product.py b/product.py
index 8d5ef30..29809e3 100644
--- a/product.py
+++ b/product.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
from trytond.model import fields
from trytond.pyson import Eval
from trytond.pool import PoolMeta
diff --git a/setup.py b/setup.py
index 6d7c311..84cea2b 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
from setuptools import setup
import re
@@ -93,6 +93,8 @@ setup(name=name,
'Natural Language :: Spanish',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: Implementation :: CPython',
+ 'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Office/Business',
'Topic :: Office/Business :: Financial :: Accounting',
],
diff --git a/stock.py b/stock.py
index f3dcae0..4b3022f 100644
--- a/stock.py
+++ b/stock.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
from decimal import Decimal
from trytond.model import fields
from trytond.pyson import Eval
@@ -170,6 +170,7 @@ class Move:
cost += move_cost_price * Decimal(str(move_qty))
+ move_qty = Uom.compute_qty(product.default_uom, move_qty, move.uom)
cls.write([move], {
as_qty_field: (
(getattr(move, as_qty_field) or 0.0) + move_qty),
diff --git a/tests/__init__.py b/tests/__init__.py
index e774cf4..27aab14 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
from .test_account_stock_anglo_saxon import suite
diff --git a/tests/scenario_account_stock_anglo_saxon.rst b/tests/scenario_account_stock_anglo_saxon.rst
index 885c984..63e8b1e 100644
--- a/tests/scenario_account_stock_anglo_saxon.rst
+++ b/tests/scenario_account_stock_anglo_saxon.rst
@@ -2,16 +2,22 @@
Account Stock Anglo-Saxon Scenario
==================================
-=============
-General Setup
-=============
-
Imports::
>>> import datetime
>>> from dateutil.relativedelta import relativedelta
>>> from decimal import Decimal
>>> from proteus import config, Model, Wizard
+ >>> from trytond.modules.company.tests.tools import create_company, \
+ ... get_company
+ >>> from trytond.modules.account.tests.tools import create_fiscalyear, \
+ ... create_chart, get_accounts
+ >>> from.trytond.modules.account_invoice.tests.tools import \
+ ... set_fiscalyear_invoice_sequences, create_payment_term
+ >>> from trytond.modules.account_stock_continental.tests.tools import \
+ ... add_stock_accounts
+ >>> from trytond.modules.account_stock_anglo_saxon.tests.tools import \
+ ... add_cogs_accounts
>>> today = datetime.date.today()
Create database::
@@ -26,42 +32,21 @@ 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)
+ >>> for module in modules:
+ ... module.click('install')
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
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
- >>> party = Party(name='Dunder Mifflin')
- >>> party.save()
- >>> company.party = party
- >>> currencies = Currency.find([('code', '=', 'USD')])
- >>> if not currencies:
- ... currency = Currency(name='U.S. Dollar', symbol='$', code='USD',
- ... rounding=Decimal('0.01'), mon_grouping='[3, 3, 0]',
- ... mon_decimal_point='.', mon_thousands_sep=',')
- ... currency.save()
- ... CurrencyRate(date=today + relativedelta(month=1, day=1),
- ... rate=Decimal('1.0'), currency=currency).save()
- ... else:
- ... currency, = currencies
- >>> company.currency = currency
- >>> company_config.execute('add')
- >>> company, = Company.find()
+ >>> _ = create_company()
+ >>> company = get_company()
Reload the context::
>>> User = Model.get('res.user')
- >>> config._context = User.get_preferences(True,
- ... config.context)
+ >>> config._context = User.get_preferences(True, config.context)
-Create an accountant user::
+Create the required users::
>>> Group = Model.get('res.group')
>>> accountant = User()
@@ -72,73 +57,54 @@ Create an accountant user::
>>> accountant.groups.append(account_group)
>>> accountant.save()
+ >>> product_user = User()
+ >>> product_user.name = 'Product User'
+ >>> product_user.login = 'product_user'
+ >>> product_user.password = 'product_user'
+ >>> product_group, = Group.find([('name', '=', 'Product Administration')])
+ >>> product_user.groups.append(product_group)
+ >>> product_user.save()
+
+ >>> purchase_user = User()
+ >>> purchase_user.name = 'Purchase User'
+ >>> purchase_user.login = 'purchase_user'
+ >>> purchase_user.password = 'purchase_user'
+ >>> purchase_group, = Group.find([('name', '=', 'Purchase')])
+ >>> purchase_user.groups.append(purchase_group)
+ >>> purchase_user.save()
+
+ >>> stock_user = User()
+ >>> stock_user.name = 'Sale User'
+ >>> stock_user.login = 'stock_user'
+ >>> stock_user.password = 'stock_user'
+ >>> stock_group, = Group.find([('name', '=', 'Stock')])
+ >>> stock_user.groups.append(stock_group)
+ >>> stock_user.save()
+
Create fiscal year::
- >>> FiscalYear = Model.get('account.fiscalyear')
- >>> Sequence = Model.get('ir.sequence')
- >>> SequenceStrict = Model.get('ir.sequence.strict')
- >>> fiscalyear = FiscalYear(name='%s' % today.year)
- >>> fiscalyear.start_date = today + relativedelta(month=1, day=1)
- >>> fiscalyear.end_date = today + relativedelta(month=12, day=31)
- >>> fiscalyear.company = company
+ >>> fiscalyear = set_fiscalyear_invoice_sequences(
+ ... create_fiscalyear(company))
>>> fiscalyear.account_stock_method = 'anglo_saxon'
- >>> post_move_sequence = Sequence(name='%s' % today.year,
- ... code='account.move',
- ... company=company)
- >>> post_move_sequence.save()
- >>> fiscalyear.post_move_sequence = post_move_sequence
- >>> invoice_sequence = SequenceStrict(name='%s' % today.year,
- ... code='account.invoice',
- ... company=company)
- >>> invoice_sequence.save()
- >>> fiscalyear.out_invoice_sequence = invoice_sequence
- >>> fiscalyear.in_invoice_sequence = invoice_sequence
- >>> fiscalyear.out_credit_note_sequence = invoice_sequence
- >>> fiscalyear.in_credit_note_sequence = invoice_sequence
- >>> fiscalyear.save()
- >>> FiscalYear.create_period([fiscalyear.id], config.context)
+ >>> fiscalyear.click('create_period')
Create chart of accounts::
- >>> AccountTemplate = Model.get('account.account.template')
- >>> Account = Model.get('account.account')
+ >>> _ = create_chart(company)
+ >>> accounts = add_cogs_accounts(add_stock_accounts(
+ ... get_accounts(company), company), company)
+ >>> receivable = accounts['receivable']
+ >>> payable = accounts['payable']
+ >>> revenue = accounts['revenue']
+ >>> expense = accounts['expense']
+ >>> stock = accounts['stock']
+ >>> stock_customer = accounts['stock_customer']
+ >>> stock_lost_found = accounts['stock_lost_found']
+ >>> stock_production = accounts['stock_production']
+ >>> stock_supplier = accounts['stock_supplier']
+ >>> cogs = accounts['cogs']
+
>>> AccountJournal = Model.get('account.journal')
- >>> account_template, = AccountTemplate.find([('parent', '=', None)])
- >>> create_chart = Wizard('account.create_chart')
- >>> create_chart.execute('account')
- >>> create_chart.form.account_template = account_template
- >>> create_chart.form.company = company
- >>> create_chart.execute('create_account')
- >>> receivable, = Account.find([
- ... ('kind', '=', 'receivable'),
- ... ('company', '=', company.id),
- ... ])
- >>> payable, = Account.find([
- ... ('kind', '=', 'payable'),
- ... ('company', '=', company.id),
- ... ])
- >>> revenue, = Account.find([
- ... ('kind', '=', 'revenue'),
- ... ('company', '=', company.id),
- ... ])
- >>> expense, = Account.find([
- ... ('kind', '=', 'expense'),
- ... ('company', '=', company.id),
- ... ])
- >>> (stock, stock_customer, stock_lost_found, stock_production,
- ... stock_supplier) = Account.find([
- ... ('kind', '=', 'stock'),
- ... ('company', '=', company.id),
- ... ('name', 'like', 'Stock%'),
- ... ], order=[('name', 'ASC')])
- >>> cogs, = Account.find([
- ... ('kind', '=', 'other'),
- ... ('company', '=', company.id),
- ... ('name', '=', 'COGS'),
- ... ])
- >>> create_chart.form.account_receivable = receivable
- >>> create_chart.form.account_payable = payable
- >>> create_chart.execute('create_properties')
>>> stock_journal, = AccountJournal.find([('code', '=', 'STO')])
Create parties::
@@ -187,38 +153,30 @@ Create product::
>>> template.save()
>>> product.template = template
>>> product.save()
- >>> template_average = ProductTemplate(ProductTemplate.copy([template.id],
- ... config.context)[0])
+ >>> template_average, = ProductTemplate.duplicate([template])
>>> template_average.cost_price_method = 'average'
>>> template_average.save()
- >>> product_average = Product(Product.copy([product.id], {
+ >>> product_average, = Product.duplicate([product], {
... 'template': template_average.id,
- ... }, config.context)[0])
+ ... })
Create payment term::
- >>> PaymentTerm = Model.get('account.invoice.payment_term')
- >>> PaymentTermLine = Model.get('account.invoice.payment_term.line')
- >>> payment_term = PaymentTerm(name='Direct')
- >>> payment_term_line = PaymentTermLine(type='remainder', days=0)
- >>> payment_term.lines.append(payment_term_line)
+ >>> payment_term = create_payment_term()
>>> payment_term.save()
Purchase 12 products::
>>> 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 = purchase.lines.new()
>>> 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 = purchase.lines.new()
>>> purchase_line.product = product_average
>>> purchase_line.quantity = 7.0
>>> purchase_line.unit_price = Decimal(6)
@@ -239,9 +197,8 @@ Receive 9 products::
>>> move = Move(purchase.moves[1].id)
>>> shipment.incoming_moves.append(move)
>>> move.quantity = 5.0
- >>> shipment.save()
- >>> ShipmentIn.receive([shipment.id], config.context)
- >>> ShipmentIn.done([shipment.id], config.context)
+ >>> shipment.click('receive')
+ >>> shipment.click('done')
>>> shipment.state
u'done'
>>> stock_supplier.reload()
@@ -271,8 +228,7 @@ Open supplier invoice::
>>> invoice_line = invoice.lines[1]
>>> invoice_line.unit_price = Decimal('4')
>>> invoice.invoice_date = today
- >>> invoice.save()
- >>> Invoice.post([invoice.id], config.context)
+ >>> invoice.click('post')
>>> invoice.state
u'posted'
>>> payable.reload()
@@ -294,23 +250,19 @@ Open supplier invoice::
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 = sale.lines.new()
>>> sale_line.product = product
>>> sale_line.quantity = 2.0
- >>> sale_line = SaleLine()
- >>> sale.lines.append(sale_line)
+ >>> sale_line = sale.lines.new()
>>> 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.click('quote')
+ >>> sale.click('confirm')
+ >>> sale.click('process')
>>> sale.state
u'processing'
@@ -318,16 +270,14 @@ Send 5 products::
>>> ShipmentOut = Model.get('stock.shipment.out')
>>> shipment, = sale.shipments
- >>> ShipmentOut.assign_try([shipment.id], config.context)
+ >>> shipment.click('assign_try')
True
>>> shipment.state
u'assigned'
- >>> shipment.reload()
- >>> ShipmentOut.pack([shipment.id], config.context)
+ >>> shipment.click('pack')
>>> shipment.state
u'packed'
- >>> shipment.reload()
- >>> ShipmentOut.done([shipment.id], config.context)
+ >>> shipment.click('done')
>>> shipment.state
u'done'
>>> stock_customer.reload()
@@ -345,7 +295,7 @@ Open customer invoice::
>>> sale.reload()
>>> invoice, = sale.invoices
- >>> Invoice.post([invoice.id], config.context)
+ >>> invoice.click('post')
>>> invoice.state
u'posted'
>>> receivable.reload()
@@ -375,8 +325,7 @@ Now create a supplier invoice with an accountant::
>>> purchase.party = supplier
>>> purchase.payment_term = payment_term
>>> purchase.invoice_method = 'order'
- >>> purchase_line = PurchaseLine()
- >>> purchase.lines.append(purchase_line)
+ >>> purchase_line = purchase.lines.new()
>>> purchase_line.product = product
>>> purchase_line.quantity = 5.0
>>> purchase_line.unit_price = Decimal(4)
@@ -386,12 +335,11 @@ Now create a supplier invoice with an accountant::
>>> purchase.state
u'processing'
- >>> 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)
+ >>> for invoice in purchase.invoices:
+ ... invoice.invoice_date = today
+ >>> Invoice.save(purchase.invoices)
+ >>> Invoice.click(purchase.invoices, 'validate_invoice')
Create customer invoice with negative quantity::
@@ -401,8 +349,7 @@ Create customer invoice with negative quantity::
>>> invoice_line = invoice.lines.new()
>>> invoice_line.product = product
>>> invoice_line.quantity = -1
- >>> invoice.save()
- >>> Invoice.post([invoice.id], config.context)
+ >>> invoice.click('post')
>>> invoice.state
u'posted'
>>> move = invoice.move
@@ -412,3 +359,75 @@ Create customer invoice with negative quantity::
>>> line_stock, = (l for l in move.lines if l.account == stock_customer)
>>> line_stock.debit
Decimal('5.00')
+
+Now we will use a product with different unit of measure::
+
+ >>> config.user = product_user.id
+ >>> UomCategory = Model.get('product.uom.category')
+ >>> unit_category, = UomCategory.find([('name', '=', 'Units')])
+ >>> unit_5 = ProductUom(name='5', symbol='5', category=unit_category,
+ ... factor=5, digits=0)
+ >>> unit_5.save()
+
+ >>> product_by5 = Product()
+ >>> template_by5 = ProductTemplate()
+ >>> template_by5.name = 'product'
+ >>> template_by5.category = category
+ >>> template_by5.default_uom = unit
+ >>> template_by5.type = 'goods'
+ >>> template_by5.purchasable = True
+ >>> template_by5.purchase_uom = unit_5
+ >>> template_by5.salable = True
+ >>> template_by5.sale_uom = unit_5
+ >>> template_by5.list_price = Decimal('10')
+ >>> template_by5.cost_price = Decimal('5')
+ >>> template_by5.cost_price_method = 'fixed'
+ >>> template_by5.delivery_time = 0
+ >>> template_by5.account_expense = expense
+ >>> template_by5.account_revenue = revenue
+ >>> template_by5.account_stock = stock
+ >>> template_by5.account_cogs = cogs
+ >>> template_by5.account_stock_supplier = stock_supplier
+ >>> template_by5.account_stock_customer = stock_customer
+ >>> template_by5.account_stock_production = stock_production
+ >>> template_by5.account_stock_lost_found = stock_lost_found
+ >>> template_by5.account_journal_stock_supplier = stock_journal
+ >>> template_by5.account_journal_stock_customer = stock_journal
+ >>> template_by5.account_journal_stock_lost_found = stock_journal
+ >>> template_by5.save()
+ >>> product_by5.template = template_by5
+ >>> product_by5.save()
+
+ >>> config.user = purchase_user.id
+ >>> purchase = Purchase()
+ >>> purchase.party = supplier
+ >>> purchase.payment_term = payment_term
+ >>> purchase.invoice_method = 'shipment'
+ >>> purchase_line = purchase.lines.new()
+ >>> purchase_line.product = product_by5
+ >>> purchase_line.quantity = 1.0
+ >>> purchase.click('quote')
+ >>> purchase.click('confirm')
+ >>> purchase.click('process')
+
+ >>> config.user = stock_user.id
+ >>> shipment = ShipmentIn(supplier=supplier)
+ >>> move = Move(purchase.moves[0].id)
+ >>> move.in_anglo_saxon_quantity
+ 0.0
+ >>> shipment.incoming_moves.append(move)
+ >>> shipment.click('receive')
+ >>> shipment.click('done')
+
+ >>> config.user = accountant.id
+ >>> purchase.reload()
+ >>> invoice, = purchase.invoices
+ >>> invoice.invoice_date = today
+ >>> invoice.click('post')
+ >>> invoice.state
+ u'posted'
+
+ >>> config.user = stock_user.id
+ >>> move = Move(purchase.moves[0].id)
+ >>> move.in_anglo_saxon_quantity
+ 1.0
diff --git a/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst b/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst
index 88f2f51..ddc0574 100644
--- a/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst
+++ b/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst
@@ -2,16 +2,22 @@
Account Stock Anglo-Saxon with Drop Shipment Scenario
=====================================================
-=============
-General Setup
-=============
-
Imports::
>>> import datetime
>>> from dateutil.relativedelta import relativedelta
>>> from decimal import Decimal
>>> from proteus import config, Model, Wizard
+ >>> from trytond.modules.company.tests.tools import create_company, \
+ ... get_company
+ >>> from trytond.modules.account.tests.tools import create_fiscalyear, \
+ ... create_chart, get_accounts
+ >>> from.trytond.modules.account_invoice.tests.tools import \
+ ... set_fiscalyear_invoice_sequences, create_payment_term
+ >>> from trytond.modules.account_stock_continental.tests.tools import \
+ ... add_stock_accounts
+ >>> from trytond.modules.account_stock_anglo_saxon.tests.tools import \
+ ... add_cogs_accounts
>>> today = datetime.date.today()
Create database::
@@ -26,34 +32,14 @@ Install sale_supply, sale, purchase::
... ('name', 'in', ('account_stock_anglo_saxon',
... 'sale_supply_drop_shipment', 'sale', 'purchase')),
... ])
- >>> Module.install([x.id for x in modules], config.context)
+ >>> for module in modules:
+ ... module.click('install')
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
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
- >>> party = Party(name='Dunder Mifflin')
- >>> party.save()
- >>> company.party = party
- >>> currencies = Currency.find([('code', '=', 'USD')])
- >>> if not currencies:
- ... currency = Currency(name='Euro', symbol=u'$', code='USD',
- ... rounding=Decimal('0.01'), mon_grouping='[3, 3, 0]',
- ... mon_decimal_point='.')
- ... currency.save()
- ... CurrencyRate(date=today + relativedelta(month=1, day=1),
- ... rate=Decimal('1.0'), currency=currency).save()
- ... else:
- ... currency, = currencies
- >>> company.currency = currency
- >>> company_config.execute('add')
- >>> company, = Company.find()
+ >>> _ = create_company()
+ >>> company = get_company()
Reload the context::
@@ -106,71 +92,28 @@ Create account user::
Create fiscal year::
- >>> FiscalYear = Model.get('account.fiscalyear')
- >>> Sequence = Model.get('ir.sequence')
- >>> SequenceStrict = Model.get('ir.sequence.strict')
- >>> fiscalyear = FiscalYear(name='%s' % today.year)
- >>> fiscalyear.start_date = today + relativedelta(month=1, day=1)
- >>> fiscalyear.end_date = today + relativedelta(month=12, day=31)
- >>> fiscalyear.company = company
+ >>> fiscalyear = set_fiscalyear_invoice_sequences(
+ ... create_fiscalyear(company))
>>> fiscalyear.account_stock_method = 'anglo_saxon'
- >>> post_move_sequence = Sequence(name='%s' % today.year,
- ... code='account.move',
- ... company=company)
- >>> post_move_sequence.save()
- >>> fiscalyear.post_move_sequence = post_move_sequence
- >>> invoice_sequence = SequenceStrict(name='%s' % today.year,
- ... code='account.invoice',
- ... company=company)
- >>> invoice_sequence.save()
- >>> fiscalyear.out_invoice_sequence = invoice_sequence
- >>> fiscalyear.in_invoice_sequence = invoice_sequence
- >>> fiscalyear.out_credit_note_sequence = invoice_sequence
- >>> fiscalyear.in_credit_note_sequence = invoice_sequence
- >>> fiscalyear.save()
- >>> FiscalYear.create_period([fiscalyear.id], config.context)
+ >>> fiscalyear.click('create_period')
Create chart of accounts::
- >>> AccountTemplate = Model.get('account.account.template')
- >>> Account = Model.get('account.account')
+ >>> _ = create_chart(company)
+ >>> accounts = add_cogs_accounts(add_stock_accounts(
+ ... get_accounts(company), company), company)
+ >>> receivable = accounts['receivable']
+ >>> payable = accounts['payable']
+ >>> revenue = accounts['revenue']
+ >>> expense = accounts['expense']
+ >>> stock = accounts['stock']
+ >>> stock_customer = accounts['stock_customer']
+ >>> stock_lost_found = accounts['stock_lost_found']
+ >>> stock_production = accounts['stock_production']
+ >>> stock_supplier = accounts['stock_supplier']
+ >>> cogs = accounts['cogs']
+
>>> AccountJournal = Model.get('account.journal')
- >>> account_template, = AccountTemplate.find([('parent', '=', None)])
- >>> create_chart = Wizard('account.create_chart')
- >>> create_chart.execute('account')
- >>> create_chart.form.account_template = account_template
- >>> create_chart.form.company = company
- >>> create_chart.execute('create_account')
- >>> receivable, = Account.find([
- ... ('kind', '=', 'receivable'),
- ... ('company', '=', company.id),
- ... ])
- >>> payable, = Account.find([
- ... ('kind', '=', 'payable'),
- ... ('company', '=', company.id),
- ... ])
- >>> revenue, = Account.find([
- ... ('kind', '=', 'revenue'),
- ... ('company', '=', company.id),
- ... ])
- >>> expense, = Account.find([
- ... ('kind', '=', 'expense'),
- ... ('company', '=', company.id),
- ... ])
- >>> (stock, stock_customer, stock_lost_found, stock_production,
- ... stock_supplier) = Account.find([
- ... ('kind', '=', 'stock'),
- ... ('company', '=', company.id),
- ... ('name', 'like', 'Stock%'),
- ... ], order=[('name', 'ASC')])
- >>> cogs, = Account.find([
- ... ('kind', '=', 'other'),
- ... ('company', '=', company.id),
- ... ('name', '=', 'COGS'),
- ... ])
- >>> create_chart.form.account_receivable = receivable
- >>> create_chart.form.account_payable = payable
- >>> create_chart.execute('create_properties')
>>> stock_journal, = AccountJournal.find([('code', '=', 'STO')])
Create parties::
@@ -223,29 +166,22 @@ Create product::
Create payment term::
- >>> PaymentTerm = Model.get('account.invoice.payment_term')
- >>> PaymentTermLine = Model.get('account.invoice.payment_term.line')
- >>> payment_term = PaymentTerm(name='Direct')
- >>> payment_term_line = PaymentTermLine(type='remainder', days=0)
- >>> payment_term.lines.append(payment_term_line)
+ >>> payment_term = create_payment_term()
>>> payment_term.save()
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 = sale.lines.new()
>>> 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.click('quote')
+ >>> sale.click('confirm')
+ >>> sale.click('process')
>>> sale.state
u'processing'
@@ -275,8 +211,7 @@ Create Purchase from Request::
Receive 50 products::
>>> config.user = stock_user.id
- >>> ShipmentDrop = Model.get('stock.shipment.drop')
- >>> ShipmentDrop.done([shipment.id], config.context)
+ >>> shipment.click('done')
>>> shipment.state
u'done'
>>> stock_supplier.reload()
@@ -297,14 +232,12 @@ Receive 50 products::
Open supplier invoice::
- >>> Invoice = Model.get('account.invoice')
>>> config.user = purchase_user.id
>>> purchase.reload()
>>> invoice, = purchase.invoices
>>> config.user = account_user.id
>>> invoice.invoice_date = today
- >>> invoice.save()
- >>> Invoice.post([invoice.id], config.context)
+ >>> invoice.click('post')
>>> invoice.state
u'posted'
>>> payable.reload()
@@ -329,7 +262,7 @@ Open customer invoice::
>>> sale.reload()
>>> invoice, = sale.invoices
>>> config.user = account_user.id
- >>> Invoice.post([invoice.id], config.context)
+ >>> invoice.click('post')
>>> invoice.state
u'posted'
>>> receivable.reload()
diff --git a/tests/test_account_stock_anglo_saxon.py b/tests/test_account_stock_anglo_saxon.py
index d60af29..73b20ab 100644
--- a/tests/test_account_stock_anglo_saxon.py
+++ b/tests/test_account_stock_anglo_saxon.py
@@ -1,31 +1,21 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
import unittest
import doctest
from mock import Mock, patch
import trytond.tests.test_tryton
-from trytond.tests.test_tryton import test_view, test_depends
+from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import DB_NAME, USER, CONTEXT
from trytond.tests.test_tryton import doctest_setup, doctest_teardown
from trytond.pool import Pool
from trytond.transaction import Transaction
-class AccountStockAngloSaxonTestCase(unittest.TestCase):
+class AccountStockAngloSaxonTestCase(ModuleTestCase):
'Test Account Stock Anglo Saxon module'
-
- def setUp(self):
- trytond.tests.test_tryton.install_module('account_stock_anglo_saxon')
-
- def test0005views(self):
- 'Test views'
- test_view('account_stock_anglo_saxon')
-
- def test0006depends(self):
- 'Test depends'
- test_depends()
+ module = 'account_stock_anglo_saxon'
def test_get_anglo_saxon_move(self):
'Test _get_anglo_saxon_move'
diff --git a/tests/tools.py b/tests/tools.py
new file mode 100644
index 0000000..d78cd79
--- /dev/null
+++ b/tests/tools.py
@@ -0,0 +1,20 @@
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+from proteus import Model
+
+from trytond.modules.company.tests.tools import get_company
+
+
+def add_cogs_accounts(accounts, company=None, config=None):
+ "Add COGS to accounts"
+ Account = Model.get('account.account', config=config)
+
+ if not company:
+ company = get_company()
+
+ accounts['cogs'], = Account.find([
+ ('kind', '=', 'other'),
+ ('company', '=', company.id),
+ ('name', '=', 'COGS'),
+ ])
+ return accounts
diff --git a/tryton.cfg b/tryton.cfg
index c0e3f21..6e63c2a 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
-version=3.4.1
+version=3.6.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 d97758d..eab47f6 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: 3.4.1
+Version: 3.6.0
Summary: Tryton module for anglo-saxon real-time stock valuation
Home-page: http://www.tryton.org/
Author: Tryton
Author-email: issue_tracker at tryton.org
License: GPL-3
-Download-URL: http://downloads.tryton.org/3.4/
+Download-URL: http://downloads.tryton.org/3.6/
Description: trytond_account_stock_anglo_saxon
=================================
@@ -63,5 +63,7 @@ Classifier: Natural Language :: Slovenian
Classifier: Natural Language :: Spanish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Office/Business
Classifier: Topic :: Office/Business :: Financial :: Accounting
diff --git a/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt b/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt
index a448e81..ec56e82 100644
--- a/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt
+++ b/trytond_account_stock_anglo_saxon.egg-info/SOURCES.txt
@@ -32,6 +32,7 @@ tryton.cfg
./tests/scenario_account_stock_anglo_saxon.rst
./tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst
./tests/test_account_stock_anglo_saxon.py
+./tests/tools.py
./view/category_form.xml
./view/template_form.xml
doc/index.rst
diff --git a/trytond_account_stock_anglo_saxon.egg-info/requires.txt b/trytond_account_stock_anglo_saxon.egg-info/requires.txt
index e7cb920..12c90e9 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 >= 3.4, < 3.5
-trytond_account_invoice >= 3.4, < 3.5
-trytond_account_product >= 3.4, < 3.5
-trytond_account_stock_continental >= 3.4, < 3.5
-trytond_purchase >= 3.4, < 3.5
-trytond_sale >= 3.4, < 3.5
-trytond >= 3.4, < 3.5
\ No newline at end of file
+trytond_account >= 3.6, < 3.7
+trytond_account_invoice >= 3.6, < 3.7
+trytond_account_product >= 3.6, < 3.7
+trytond_account_stock_continental >= 3.6, < 3.7
+trytond_purchase >= 3.6, < 3.7
+trytond_sale >= 3.6, < 3.7
+trytond >= 3.6, < 3.7
\ No newline at end of file
--
tryton-modules-account-stock-anglo-saxon
More information about the tryton-debian-vcs
mailing list