From 3cdc86cc8ad930bfb55971d84ad523fe6c03f13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 6 Feb 2012 16:58:42 +0100 Subject: [PATCH] Define "Stock Journal" on "Account Configuration" issue2406 review231007 --- CHANGELOG | 1 + __init__.py | 1 + account.py | 16 ++++++ account.xml | 24 +++++++++ doc/index.rst | 10 ++-- product.py | 55 -------------------- product.xml | 14 ----- stock.py | 19 +++---- tests/scenario_account_stock_continental.rst | 5 -- 9 files changed, 53 insertions(+), 92 deletions(-) create mode 100644 account.py diff --git a/CHANGELOG b/CHANGELOG index 58cdc9bcdf..98cb01726c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Define "Stock Journal" on "Account Configuration" * Use cost price instead of unit price when cost method is "fixed" Version 2.2.0 - 2011-10-24 diff --git a/__init__.py b/__init__.py index 6691306949..2143f8868c 100644 --- a/__init__.py +++ b/__init__.py @@ -3,3 +3,4 @@ from .stock import * from .product import * +from .account import * diff --git a/account.py b/account.py new file mode 100644 index 0000000000..3ebcaa91ac --- /dev/null +++ b/account.py @@ -0,0 +1,16 @@ +#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 Model, fields +from trytond.pyson import Eval, Bool + + +class Configuration(Model): + _name = 'account.configuration' + + stock_journal = fields.Property(fields.Many2One( + 'account.journal', 'Stock Journal', + states={ + 'required': Bool(Eval('context', {}).get('company')), + })) + +Configuration() diff --git a/account.xml b/account.xml index d911845b8c..79297a0ce4 100644 --- a/account.xml +++ b/account.xml @@ -3,6 +3,30 @@ this repository contains the full copyright notices and license terms. --> + + account.configuration + + + + + + + + ]]> + + + + + + + diff --git a/doc/index.rst b/doc/index.rst index e4f5d079bb..bee5b1c434 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -4,17 +4,17 @@ Account Stock Continental Module The account_stock_continental module adds continental accounting model for stock valuation. -Five new fields are added to Product and Category: +A new configuration field for accounting is added: + +- Journal Stock: The journal used for stock move. + +Four new fields are added to Product and Category: - Account Stock: The account which is used to record stock value. - Account Stock Supplier: The counter part account for supplier stock move. - Account Stock Customer: The counter part account for customer stock move. - Account Stock Lost and Found: The counter part account for lost and found stock move. -- Account Journal Stock Supplier: The journal used for supplier stock move. -- Account Journal Stock Customer: The journal used for customer stock move. -- Account Journal Stock Lost and Found: The journal used for lost and found - stock move. As usual, if the "Use Category's accounts" is checked it is the category one that is used otherwise it is the product one. diff --git a/product.py b/product.py index bb1a79103c..8a589ba4f9 100644 --- a/product.py +++ b/product.py @@ -39,21 +39,6 @@ class Category(ModelSQL, ModelView): states={ 'invisible': ~Eval('context', {}).get('company'), })) - account_journal_stock_supplier = fields.Property(fields.Many2One( - 'account.journal', 'Journal Stock Supplier', - states={ - 'invisible': ~Eval('context', {}).get('company'), - })) - account_journal_stock_customer = fields.Property(fields.Many2One( - 'account.journal', 'Journal Stock Customer', - states={ - 'invisible': ~Eval('context', {}).get('company'), - })) - account_journal_stock_lost_found = fields.Property(fields.Many2One( - 'account.journal', 'Journal Stock Lost and Found', - states={ - 'invisible': ~Eval('context', {}).get('company'), - })) Category() @@ -121,39 +106,6 @@ class Template(ModelSQL, ModelView): }, help='This account will be used instead of the one defined ' 'on the category.', depends=['account_category', 'type'])) - account_journal_stock_supplier = fields.Property(fields.Many2One( - 'account.journal', 'Account Journal Stock Supplier', - states={ - 'invisible': (~Eval('context', {}).get('company') - | Eval('account_category')), - 'required': (Eval('type').in_(['stockable', 'consumable']) - & Eval('context', {}).get('company') - & ~Eval('account_category')), - }, help='This journal will be used instead of the one defined ' - 'on the category.', - depends=['account_category', 'type'])) - account_journal_stock_customer = fields.Property(fields.Many2One( - 'account.journal', 'Account Journal Stock Customer', - states={ - 'invisible': (~Eval('context', {}).get('company') - | Eval('account_category')), - 'required': (Eval('type').in_(['stockable', 'consumable']) - & Eval('context', {}).get('company') - & ~Eval('account_category')), - }, help='This journal will be used instead of the one defined ' - 'on the category.', - depends=['account_category', 'type'])) - account_journal_stock_lost_found = fields.Property(fields.Many2One( - 'account.journal', 'Account Journal Stock Lost and Found', - states={ - 'invisible': (~Eval('context', {}).get('company') - | Eval('account_category')), - 'required': (Eval('type').in_(['stockable', 'consumable']) - & Eval('context', {}).get('company') - & ~Eval('account_category')), - }, help='This journal will be used instead of the one defined ' - 'on the category.', - depends=['account_category', 'type'])) account_stock_used = fields.Function(fields.Many2One('account.account', 'Account Stock Used'), 'get_account') account_stock_supplier_used = fields.Function(fields.Many2One( @@ -162,13 +114,6 @@ class Template(ModelSQL, ModelView): 'account.account', 'Account Stock Customer Used'), 'get_account') account_stock_lost_found_used = fields.Function(fields.Many2One( 'account.account', 'Account Stock Lost and Found'), 'get_account') - account_journal_stock_supplier_used = fields.Function(fields.Many2One( - 'account.journal', 'Journal Stock Supplier'), 'get_account') - account_journal_stock_customer_used = fields.Function(fields.Many2One( - 'account.journal', 'Journal Stock Customer'), 'get_account') - account_journal_stock_lost_found_used = fields.Function(fields.Many2One( - 'account.journal', 'Journal Stock Lost and Found'), - 'get_account') Template() diff --git a/product.xml b/product.xml index 3faf3658e2..af93dbda75 100644 --- a/product.xml +++ b/product.xml @@ -22,13 +22,6 @@ this repository contains the full copyright notices and license terms. -->