changeset 5edcf9732d0d in modules/account_stock_continental:default
details: 
https://hg.tryton.org/modules/account_stock_continental?cmd=changeset;node=5edcf9732d0d
description:
        Use only 3 stock accounts

        This simplify the configuration and allow to update cost price without 
asking
        for accounting information.

        issue7273
        review262541002
diffstat:

 CHANGELOG                                    |    2 +
 __init__.py                                  |    1 -
 account.py                                   |   21 --
 exceptions.py                                |    8 -
 message.xml                                  |    3 -
 minimal_chart.xml                            |   71 +------
 minimal_chart_bg.xml                         |   49 +-----
 minimal_chart_ca.xml                         |   49 +-----
 minimal_chart_de.xml                         |   49 +-----
 minimal_chart_en.xml                         |   49 +-----
 minimal_chart_es.xml                         |   49 +-----
 minimal_chart_fr.xml                         |   49 +-----
 minimal_chart_nl.xml                         |   49 +-----
 minimal_chart_pt.xml                         |   49 +-----
 minimal_chart_ru.xml                         |   49 +-----
 minimal_chart_sl.xml                         |   49 +-----
 product.py                                   |  237 +++++++++-----------------
 stock.py                                     |   10 +-
 tests/scenario_account_stock_continental.rst |   71 +++----
 view/category_form.xml                       |   12 +-
 view/configuration_form.xml                  |    2 -
 view/modify_cost_price_show_move_form.xml    |   11 +-
 22 files changed, 159 insertions(+), 780 deletions(-)

diffs (1436 lines):

diff -r 97e54116ded8 -r 5edcf9732d0d CHANGELOG
--- a/CHANGELOG Sat Dec 28 17:48:50 2019 +0100
+++ b/CHANGELOG Wed Jan 08 14:36:45 2020 +0100
@@ -1,3 +1,5 @@
+* Use only 3 stock accounts
+
 Version 5.4.0 - 2019-11-04
 * Bug fixes (see mercurial logs for details)
 * Replace 'Update Cost Price' by 'Modify Cost Price'
diff -r 97e54116ded8 -r 5edcf9732d0d __init__.py
--- a/__init__.py       Sat Dec 28 17:48:50 2019 +0100
+++ b/__init__.py       Wed Jan 08 14:36:45 2020 +0100
@@ -16,7 +16,6 @@
         product.Product,
         account.Configuration,
         account.ConfigurationStockJournal,
-        account.ConfigurationCostPriceCounterpartAccount,
         account.FiscalYear,
         account.AccountMove,
         product.ModifyCostPriceAsk,
diff -r 97e54116ded8 -r 5edcf9732d0d account.py
--- a/account.py        Sat Dec 28 17:48:50 2019 +0100
+++ b/account.py        Wed Jan 08 14:36:45 2020 +0100
@@ -1,13 +1,8 @@
 # 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 ModelSQL, ValueMixin, fields
-from trytond.pyson import Eval, Get
 from trytond.pool import PoolMeta, Pool
-from trytond.modules.company.model import CompanyValueMixin
 
-__all__ = ['Configuration', 'ConfigurationStockJournal',
-    'ConfigurationCostPriceCounterpartAccount',
-    'FiscalYear', 'AccountMove']
 stock_journal = fields.Many2One(
     'account.journal', "Stock Journal", required=True)
 
@@ -15,11 +10,6 @@
 class Configuration(metaclass=PoolMeta):
     __name__ = 'account.configuration'
     stock_journal = fields.MultiValue(stock_journal)
-    cost_price_counterpart_account = fields.MultiValue(fields.Many2One(
-            'account.account', "Cost Price Counterpart Account",
-            domain=[
-                ('company', 'in', [Get(Eval('context', {}), 'company'), None]),
-                ]))
 
     @classmethod
     def default_stock_journal(cls, **pattern):
@@ -41,17 +31,6 @@
             return None
 
 
-class ConfigurationCostPriceCounterpartAccount(ModelSQL, CompanyValueMixin):
-    "Account Configuration Cost Price Counterpart Account"
-    __name__ = 'account.configuration.cost_price_counterpart_account'
-    cost_price_counterpart_account = fields.Many2One(
-        'account.account', "Cost Price Counterpart Account",
-        domain=[
-            ('company', '=', Eval('company', -1)),
-            ],
-        depends=['company'])
-
-
 class FiscalYear(metaclass=PoolMeta):
     __name__ = 'account.fiscalyear'
     account_stock_method = fields.Selection([
diff -r 97e54116ded8 -r 5edcf9732d0d exceptions.py
--- a/exceptions.py     Sat Dec 28 17:48:50 2019 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,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.
-
-from trytond.exceptions import UserError
-
-
-class ModifyCostPriceError(UserError):
-    pass
diff -r 97e54116ded8 -r 5edcf9732d0d message.xml
--- a/message.xml       Sat Dec 28 17:48:50 2019 +0100
+++ b/message.xml       Wed Jan 08 14:36:45 2020 +0100
@@ -7,8 +7,5 @@
             <field name="text">You cannot change the cost price of a product 
which is associated to stock moves.
 You must use the "Modify Cost Price" wizard.</field>
         </record>
-        <record model="ir.message" id="msg_modify_cost_price_same_account">
-            <field name="text">To modify the cost price, you must change the 
counterpart account "%(account)s".</field>
-        </record>
     </data>
 </tryton>
diff -r 97e54116ded8 -r 5edcf9732d0d minimal_chart.xml
--- a/minimal_chart.xml Sat Dec 28 17:48:50 2019 +0100
+++ b/minimal_chart.xml Wed Jan 08 14:36:45 2020 +0100
@@ -56,66 +56,17 @@
             <field name="stock" eval="True"/>
         </record>
 
-        <record model="account.account.template"
-                 id="account_template_stock_supplier">
-            <field name="name" lang="en">Stock Supplier</field>
-            <field name="name" lang="bg">Stock Supplier</field>
-            <field name="name" lang="ca">Estoc proveïdor</field>
-            <field name="name" lang="de">Lager Lieferant</field>
-            <field name="name" lang="es">Stock del proveedor</field>
-            <field name="name" lang="fr">Stock fournisseur</field>
-            <field name="name" lang="nl">Stock Supplier</field>
-            <field name="name" lang="pt">Estoque do Fornecedor</field>
-            <field name="name" lang="ru">Stock Supplier</field>
-            <field name="name" lang="sl">Zaloga dobavitelja</field>
-            <field name="type" ref="account_type_template_stock_expense"/>
-            <field name="reconcile" eval="True"/>
-            <field name="parent" ref="account.account_template_root"/>
-        </record>
-        <record model="account.account.template"
-                id="account_template_stock_customer">
-            <field name="name" lang="en">Stock Customer</field>
-            <field name="name" lang="bg">Stock Customer</field>
-            <field name="name" lang="ca">Estoc client</field>
-            <field name="name" lang="de">Lager Kunde</field>
-            <field name="name" lang="es">Stock cliente</field>
-            <field name="name" lang="fr">Stock client</field>
-            <field name="name" lang="nl">Stock Customer</field>
-            <field name="name" lang="pt">Estoque do Cliente</field>
-            <field name="name" lang="ru">Stock Customer</field>
-            <field name="name" lang="sl">Zaloga kupca</field>
-            <field name="type" ref="account_type_template_stock_expense"/>
-            <field name="parent" ref="account.account_template_root"/>
-        </record>
-
-        <record model="account.account.template"
-                id="account_template_stock_production">
-            <field name="name" lang="en">Stock Production</field>
-            <field name="name" lang="bg">Stock Production</field>
-            <field name="name" lang="ca">Estoc producció</field>
-            <field name="name" lang="de">Lager Produktion</field>
-            <field name="name" lang="es">Stock producción</field>
-            <field name="name" lang="fr">Stock de production</field>
-            <field name="name" lang="nl">Stock Production</field>
-            <field name="name" lang="pt">Estoque da Produção</field>
-            <field name="name" lang="ru">Stock Production</field>
-            <field name="name" lang="sl">Zaloga proizvodnje</field>
-            <field name="type" ref="account_type_template_stock_expense"/>
-            <field name="parent" ref="account.account_template_root"/>
-        </record>
-
-        <record model="account.account.template"
-                id="account_template_stock_lost_found">
-            <field name="name" lang="en">Stock Lost and Found</field>
-            <field name="name" lang="bg">Stock Lost and Found</field>
-            <field name="name" lang="ca">Estoc perdut/trobat</field>
-            <field name="name" lang="de">Lager Inventurdifferenz</field>
-            <field name="name" lang="es">Stock perdido y encontrado</field>
-            <field name="name" lang="fr">Stock « pertes et surplus »</field>
-            <field name="name" lang="nl">Stock Lost and Found</field>
-            <field name="name" lang="pt">Estoque de Achados e Perdidos</field>
-            <field name="name" lang="ru">Stock Lost and Found</field>
-            <field name="name" lang="sl">Zaloga izgubljeno/najdeno</field>
+        <record model="account.account.template" 
id="account_template_stock_expense">
+            <field name="name" lang="en">Stock Expense</field>
+            <field name="name" lang="bg">Разход на акции</field>
+            <field name="name" lang="ca">Despeses d'existències</field>
+            <field name="name" lang="de">Lagerkosten</field>
+            <field name="name" lang="es">Gastos de existencias</field>
+            <field name="name" lang="fr">Variation des stocks</field>
+            <field name="name" lang="nl">Voorraad</field>
+            <field name="name" lang="pt">Despesa de estoque</field>
+            <field name="name" lang="ru">Расходы на акции</field>
+            <field name="name" lang="sl">Stroški zalog</field>
             <field name="type" ref="account_type_template_stock_expense"/>
             <field name="parent" ref="account.account_template_root"/>
         </record>
diff -r 97e54116ded8 -r 5edcf9732d0d minimal_chart_bg.xml
--- a/minimal_chart_bg.xml      Sat Dec 28 17:48:50 2019 +0100
+++ b/minimal_chart_bg.xml      Wed Jan 08 14:36:45 2020 +0100
@@ -53,54 +53,9 @@
             <field name="stock" eval="True"/>
         </record>
 
-        <record id="account_template_stock_supplier_bg" 
model="account.account.template">
-            
-            <field name="name">Stock Supplier</field>
-            
-            
-            
-            
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_bg"/>
-            <field name="reconcile" eval="True"/>
-            <field name="parent" ref="account.account_template_root_bg"/>
-        </record>
-        <record id="account_template_stock_customer_bg" 
model="account.account.template">
-            
-            <field name="name">Stock Customer</field>
-            
-            
-            
-            
-            
+        <record id="account_template_stock_expense_bg" 
model="account.account.template">
             
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_bg"/>
-            <field name="parent" ref="account.account_template_root_bg"/>
-        </record>
-
-        <record id="account_template_stock_production_bg" 
model="account.account.template">
-            
-            <field name="name">Stock Production</field>
-            
-            
-            
-            
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_bg"/>
-            <field name="parent" ref="account.account_template_root_bg"/>
-        </record>
-
-        <record id="account_template_stock_lost_found_bg" 
model="account.account.template">
-            
-            <field name="name">Stock Lost and Found</field>
+            <field name="name">Разход на акции</field>
             
             
             
diff -r 97e54116ded8 -r 5edcf9732d0d minimal_chart_ca.xml
--- a/minimal_chart_ca.xml      Sat Dec 28 17:48:50 2019 +0100
+++ b/minimal_chart_ca.xml      Wed Jan 08 14:36:45 2020 +0100
@@ -53,55 +53,10 @@
             <field name="stock" eval="True"/>
         </record>
 
-        <record id="account_template_stock_supplier_ca" 
model="account.account.template">
-            
-            
-            <field name="name">Estoc proveïdor</field>
-            
-            
-            
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_ca"/>
-            <field name="reconcile" eval="True"/>
-            <field name="parent" ref="account.account_template_root_ca"/>
-        </record>
-        <record id="account_template_stock_customer_ca" 
model="account.account.template">
-            
-            
-            <field name="name">Estoc client</field>
-            
-            
-            
-            
+        <record id="account_template_stock_expense_ca" 
model="account.account.template">
             
             
-            
-            <field name="type" ref="account_type_template_stock_expense_ca"/>
-            <field name="parent" ref="account.account_template_root_ca"/>
-        </record>
-
-        <record id="account_template_stock_production_ca" 
model="account.account.template">
-            
-            
-            <field name="name">Estoc producció</field>
-            
-            
-            
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_ca"/>
-            <field name="parent" ref="account.account_template_root_ca"/>
-        </record>
-
-        <record id="account_template_stock_lost_found_ca" 
model="account.account.template">
-            
-            
-            <field name="name">Estoc perdut/trobat</field>
+            <field name="name">Despeses d'existències</field>
             
             
             
diff -r 97e54116ded8 -r 5edcf9732d0d minimal_chart_de.xml
--- a/minimal_chart_de.xml      Sat Dec 28 17:48:50 2019 +0100
+++ b/minimal_chart_de.xml      Wed Jan 08 14:36:45 2020 +0100
@@ -53,56 +53,11 @@
             <field name="stock" eval="True"/>
         </record>
 
-        <record id="account_template_stock_supplier_de" 
model="account.account.template">
-            
-            
-            
-            <field name="name">Lager Lieferant</field>
-            
-            
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_de"/>
-            <field name="reconcile" eval="True"/>
-            <field name="parent" ref="account.account_template_root_de"/>
-        </record>
-        <record id="account_template_stock_customer_de" 
model="account.account.template">
-            
-            
-            
-            <field name="name">Lager Kunde</field>
-            
-            
+        <record id="account_template_stock_expense_de" 
model="account.account.template">
             
             
             
-            
-            <field name="type" ref="account_type_template_stock_expense_de"/>
-            <field name="parent" ref="account.account_template_root_de"/>
-        </record>
-
-        <record id="account_template_stock_production_de" 
model="account.account.template">
-            
-            
-            
-            <field name="name">Lager Produktion</field>
-            
-            
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_de"/>
-            <field name="parent" ref="account.account_template_root_de"/>
-        </record>
-
-        <record id="account_template_stock_lost_found_de" 
model="account.account.template">
-            
-            
-            
-            <field name="name">Lager Inventurdifferenz</field>
+            <field name="name">Lagerkosten</field>
             
             
             
diff -r 97e54116ded8 -r 5edcf9732d0d minimal_chart_en.xml
--- a/minimal_chart_en.xml      Sat Dec 28 17:48:50 2019 +0100
+++ b/minimal_chart_en.xml      Wed Jan 08 14:36:45 2020 +0100
@@ -53,53 +53,8 @@
             <field name="stock" eval="True"/>
         </record>
 
-        <record id="account_template_stock_supplier_en" 
model="account.account.template">
-            <field name="name">Stock Supplier</field>
-            
-            
-            
-            
-            
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_en"/>
-            <field name="reconcile" eval="True"/>
-            <field name="parent" ref="account.account_template_root_en"/>
-        </record>
-        <record id="account_template_stock_customer_en" 
model="account.account.template">
-            <field name="name">Stock Customer</field>
-            
-            
-            
-            
-            
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_en"/>
-            <field name="parent" ref="account.account_template_root_en"/>
-        </record>
-
-        <record id="account_template_stock_production_en" 
model="account.account.template">
-            <field name="name">Stock Production</field>
-            
-            
-            
-            
-            
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_en"/>
-            <field name="parent" ref="account.account_template_root_en"/>
-        </record>
-
-        <record id="account_template_stock_lost_found_en" 
model="account.account.template">
-            <field name="name">Stock Lost and Found</field>
+        <record id="account_template_stock_expense_en" 
model="account.account.template">
+            <field name="name">Stock Expense</field>
             
             
             
diff -r 97e54116ded8 -r 5edcf9732d0d minimal_chart_es.xml
--- a/minimal_chart_es.xml      Sat Dec 28 17:48:50 2019 +0100
+++ b/minimal_chart_es.xml      Wed Jan 08 14:36:45 2020 +0100
@@ -53,57 +53,12 @@
             <field name="stock" eval="True"/>
         </record>
 
-        <record id="account_template_stock_supplier_es" 
model="account.account.template">
-            
-            
-            
-            
-            <field name="name">Stock del proveedor</field>
-            
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_es"/>
-            <field name="reconcile" eval="True"/>
-            <field name="parent" ref="account.account_template_root_es"/>
-        </record>
-        <record id="account_template_stock_customer_es" 
model="account.account.template">
-            
-            
-            
-            
-            <field name="name">Stock cliente</field>
-            
+        <record id="account_template_stock_expense_es" 
model="account.account.template">
             
             
             
             
-            <field name="type" ref="account_type_template_stock_expense_es"/>
-            <field name="parent" ref="account.account_template_root_es"/>
-        </record>
-
-        <record id="account_template_stock_production_es" 
model="account.account.template">
-            
-            
-            
-            
-            <field name="name">Stock producción</field>
-            
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_es"/>
-            <field name="parent" ref="account.account_template_root_es"/>
-        </record>
-
-        <record id="account_template_stock_lost_found_es" 
model="account.account.template">
-            
-            
-            
-            
-            <field name="name">Stock perdido y encontrado</field>
+            <field name="name">Gastos de existencias</field>
             
             
             
diff -r 97e54116ded8 -r 5edcf9732d0d minimal_chart_fr.xml
--- a/minimal_chart_fr.xml      Sat Dec 28 17:48:50 2019 +0100
+++ b/minimal_chart_fr.xml      Wed Jan 08 14:36:45 2020 +0100
@@ -53,58 +53,13 @@
             <field name="stock" eval="True"/>
         </record>
 
-        <record id="account_template_stock_supplier_fr" 
model="account.account.template">
-            
-            
-            
-            
-            
-            <field name="name">Stock fournisseur</field>
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_fr"/>
-            <field name="reconcile" eval="True"/>
-            <field name="parent" ref="account.account_template_root_fr"/>
-        </record>
-        <record id="account_template_stock_customer_fr" 
model="account.account.template">
+        <record id="account_template_stock_expense_fr" 
model="account.account.template">
             
             
             
             
             
-            <field name="name">Stock client</field>
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_fr"/>
-            <field name="parent" ref="account.account_template_root_fr"/>
-        </record>
-
-        <record id="account_template_stock_production_fr" 
model="account.account.template">
-            
-            
-            
-            
-            
-            <field name="name">Stock de production</field>
-            
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_fr"/>
-            <field name="parent" ref="account.account_template_root_fr"/>
-        </record>
-
-        <record id="account_template_stock_lost_found_fr" 
model="account.account.template">
-            
-            
-            
-            
-            
-            <field name="name">Stock « pertes et surplus »</field>
+            <field name="name">Variation des stocks</field>
             
             
             
diff -r 97e54116ded8 -r 5edcf9732d0d minimal_chart_nl.xml
--- a/minimal_chart_nl.xml      Sat Dec 28 17:48:50 2019 +0100
+++ b/minimal_chart_nl.xml      Wed Jan 08 14:36:45 2020 +0100
@@ -53,59 +53,14 @@
             <field name="stock" eval="True"/>
         </record>
 
-        <record id="account_template_stock_supplier_nl" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            <field name="name">Stock Supplier</field>
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_nl"/>
-            <field name="reconcile" eval="True"/>
-            <field name="parent" ref="account.account_template_root_nl"/>
-        </record>
-        <record id="account_template_stock_customer_nl" 
model="account.account.template">
+        <record id="account_template_stock_expense_nl" 
model="account.account.template">
             
             
             
             
             
             
-            <field name="name">Stock Customer</field>
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_nl"/>
-            <field name="parent" ref="account.account_template_root_nl"/>
-        </record>
-
-        <record id="account_template_stock_production_nl" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            <field name="name">Stock Production</field>
-            
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_nl"/>
-            <field name="parent" ref="account.account_template_root_nl"/>
-        </record>
-
-        <record id="account_template_stock_lost_found_nl" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            <field name="name">Stock Lost and Found</field>
+            <field name="name">Voorraad</field>
             
             
             
diff -r 97e54116ded8 -r 5edcf9732d0d minimal_chart_pt.xml
--- a/minimal_chart_pt.xml      Sat Dec 28 17:48:50 2019 +0100
+++ b/minimal_chart_pt.xml      Wed Jan 08 14:36:45 2020 +0100
@@ -53,22 +53,7 @@
             <field name="stock" eval="True"/>
         </record>
 
-        <record id="account_template_stock_supplier_pt" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            
-            <field name="name">Estoque do Fornecedor</field>
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_pt"/>
-            <field name="reconcile" eval="True"/>
-            <field name="parent" ref="account.account_template_root_pt"/>
-        </record>
-        <record id="account_template_stock_customer_pt" 
model="account.account.template">
+        <record id="account_template_stock_expense_pt" 
model="account.account.template">
             
             
             
@@ -76,37 +61,7 @@
             
             
             
-            <field name="name">Estoque do Cliente</field>
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_pt"/>
-            <field name="parent" ref="account.account_template_root_pt"/>
-        </record>
-
-        <record id="account_template_stock_production_pt" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            
-            <field name="name">Estoque da Produção</field>
-            
-            
-            <field name="type" ref="account_type_template_stock_expense_pt"/>
-            <field name="parent" ref="account.account_template_root_pt"/>
-        </record>
-
-        <record id="account_template_stock_lost_found_pt" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            
-            <field name="name">Estoque de Achados e Perdidos</field>
+            <field name="name">Despesa de estoque</field>
             
             
             <field name="type" ref="account_type_template_stock_expense_pt"/>
diff -r 97e54116ded8 -r 5edcf9732d0d minimal_chart_ru.xml
--- a/minimal_chart_ru.xml      Sat Dec 28 17:48:50 2019 +0100
+++ b/minimal_chart_ru.xml      Wed Jan 08 14:36:45 2020 +0100
@@ -53,22 +53,7 @@
             <field name="stock" eval="True"/>
         </record>
 
-        <record id="account_template_stock_supplier_ru" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            
-            
-            <field name="name">Stock Supplier</field>
-            
-            <field name="type" ref="account_type_template_stock_expense_ru"/>
-            <field name="reconcile" eval="True"/>
-            <field name="parent" ref="account.account_template_root_ru"/>
-        </record>
-        <record id="account_template_stock_customer_ru" 
model="account.account.template">
+        <record id="account_template_stock_expense_ru" 
model="account.account.template">
             
             
             
@@ -77,37 +62,7 @@
             
             
             
-            <field name="name">Stock Customer</field>
-            
-            <field name="type" ref="account_type_template_stock_expense_ru"/>
-            <field name="parent" ref="account.account_template_root_ru"/>
-        </record>
-
-        <record id="account_template_stock_production_ru" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            
-            
-            <field name="name">Stock Production</field>
-            
-            <field name="type" ref="account_type_template_stock_expense_ru"/>
-            <field name="parent" ref="account.account_template_root_ru"/>
-        </record>
-
-        <record id="account_template_stock_lost_found_ru" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            
-            
-            <field name="name">Stock Lost and Found</field>
+            <field name="name">Расходы на акции</field>
             
             <field name="type" ref="account_type_template_stock_expense_ru"/>
             <field name="parent" ref="account.account_template_root_ru"/>
diff -r 97e54116ded8 -r 5edcf9732d0d minimal_chart_sl.xml
--- a/minimal_chart_sl.xml      Sat Dec 28 17:48:50 2019 +0100
+++ b/minimal_chart_sl.xml      Wed Jan 08 14:36:45 2020 +0100
@@ -53,22 +53,7 @@
             <field name="stock" eval="True"/>
         </record>
 
-        <record id="account_template_stock_supplier_sl" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            
-            
-            
-            <field name="name">Zaloga dobavitelja</field>
-            <field name="type" ref="account_type_template_stock_expense_sl"/>
-            <field name="reconcile" eval="True"/>
-            <field name="parent" ref="account.account_template_root_sl"/>
-        </record>
-        <record id="account_template_stock_customer_sl" 
model="account.account.template">
+        <record id="account_template_stock_expense_sl" 
model="account.account.template">
             
             
             
@@ -78,37 +63,7 @@
             
             
             
-            <field name="name">Zaloga kupca</field>
-            <field name="type" ref="account_type_template_stock_expense_sl"/>
-            <field name="parent" ref="account.account_template_root_sl"/>
-        </record>
-
-        <record id="account_template_stock_production_sl" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            
-            
-            
-            <field name="name">Zaloga proizvodnje</field>
-            <field name="type" ref="account_type_template_stock_expense_sl"/>
-            <field name="parent" ref="account.account_template_root_sl"/>
-        </record>
-
-        <record id="account_template_stock_lost_found_sl" 
model="account.account.template">
-            
-            
-            
-            
-            
-            
-            
-            
-            
-            <field name="name">Zaloga izgubljeno/najdeno</field>
+            <field name="name">Stroški zalog</field>
             <field name="type" ref="account_type_template_stock_expense_sl"/>
             <field name="parent" ref="account.account_template_root_sl"/>
         </record>
diff -r 97e54116ded8 -r 5edcf9732d0d product.py
--- a/product.py        Sat Dec 28 17:48:50 2019 +0100
+++ b/product.py        Wed Jan 08 14:36:45 2020 +0100
@@ -3,7 +3,6 @@
 from decimal import Decimal
 
 from trytond import backend
-from trytond.i18n import gettext
 from trytond.model import ModelView, fields
 from trytond.wizard import Wizard, StateView, StateTransition, Button
 from trytond.pyson import Eval
@@ -13,14 +12,12 @@
 from trytond.modules.account_product.product import (
     account_used, template_property)
 from trytond.modules.product import price_digits
-from .exceptions import ModifyCostPriceError
 
 __all__ = ['Category', 'CategoryAccount', 'Template',
     'Product', 'ModifyCostPriceAsk',
     'ModifyCostPriceShowMove', 'ModifyCostPrice']
 account_names = [
-    'account_stock', 'account_stock_supplier', 'account_stock_customer',
-    'account_stock_production', 'account_stock_lost_found']
+    'account_stock', 'account_stock_in', 'account_stock_out']
 
 
 class Category(metaclass=PoolMeta):
@@ -30,19 +27,9 @@
             domain=[
                 ('closed', '!=', True),
                 ('type.stock', '=', True),
-                ('company', '=', Eval('context', {}).get('company', -1)),
-                ],
-            states={
-                'invisible': (~Eval('context', {}).get('company')
-                    | Eval('account_parent')
-                    | ~Eval('accounting', False)),
-                },
-            depends=['account_parent', 'accounting']))
-    account_stock_supplier = fields.MultiValue(fields.Many2One(
-            'account.account', "Account Stock Supplier",
-            domain=[
-                ('closed', '!=', True),
-                ('type.stock', '=', True),
+                ('id', 'not in', [
+                        Eval('account_stock_in', -1),
+                        Eval('account_stock_out', -1)]),
                 ('company', '=', Eval('context', {}).get('company', -1)),
                 ],
             states={
@@ -50,12 +37,14 @@
                     | Eval('account_parent')
                     | ~Eval('accounting', False)),
                 },
-            depends=['account_parent', 'accounting']))
-    account_stock_customer = fields.MultiValue(fields.Many2One(
-            'account.account', "Account Stock Customer",
+            depends=['account_parent', 'accounting',
+                'account_stock_in', 'account_stock_out']))
+    account_stock_in = fields.MultiValue(fields.Many2One(
+            'account.account', "Account Stock IN",
             domain=[
                 ('closed', '!=', True),
                 ('type.stock', '=', True),
+                ('id', '!=', Eval('account_stock', -1)),
                 ('company', '=', Eval('context', {}).get('company', -1)),
                 ],
             states={
@@ -63,12 +52,13 @@
                     | Eval('account_parent')
                     | ~Eval('accounting', False)),
                 },
-            depends=['account_parent', 'accounting']))
-    account_stock_production = fields.MultiValue(fields.Many2One(
-            'account.account', "Account Stock Production",
+            depends=['account_parent', 'accounting', 'account_stock']))
+    account_stock_out = fields.MultiValue(fields.Many2One(
+            'account.account', "Account Stock OUT",
             domain=[
                 ('closed', '!=', True),
                 ('type.stock', '=', True),
+                ('id', '!=', Eval('account_stock', -1)),
                 ('company', '=', Eval('context', {}).get('company', -1)),
                 ],
             states={
@@ -76,20 +66,7 @@
                     | Eval('account_parent')
                     | ~Eval('accounting', False)),
                 },
-            depends=['account_parent', 'accounting']))
-    account_stock_lost_found = fields.MultiValue(fields.Many2One(
-            'account.account', "Account Stock Lost and Found",
-            domain=[
-                ('closed', '!=', True),
-                ('type.stock', '=', True),
-                ('company', '=', Eval('context', {}).get('company', -1)),
-                ],
-            states={
-                'invisible': (~Eval('context', {}).get('company')
-                    | Eval('account_parent')
-                    | ~Eval('accounting', False)),
-                },
-            depends=['account_parent', 'accounting']))
+            depends=['account_parent', 'accounting', 'account_stock']))
 
     @classmethod
     def multivalue_model(cls, field):
@@ -104,23 +81,13 @@
         pass
 
     @property
-    @account_used('account_stock_supplier')
-    def account_stock_supplier_used(self):
+    @account_used('account_stock_in')
+    def account_stock_in_used(self):
         pass
 
     @property
-    @account_used('account_stock_customer')
-    def account_stock_customer_used(self):
-        pass
-
-    @property
-    @account_used('account_stock_production')
-    def account_stock_production_used(self):
-        pass
-
-    @property
-    @account_used('account_stock_lost_found')
-    def account_stock_lost_found_used(self):
+    @account_used('account_stock_out')
+    def account_stock_out_used(self):
         pass
 
 
@@ -135,8 +102,8 @@
             ('company', '=', Eval('company', -1)),
             ],
         depends=['company'])
-    account_stock_supplier = fields.Many2One(
-        'account.account', "Account Stock Supplier",
+    account_stock_in = fields.Many2One(
+        'account.account', "Account Stock IN",
         domain=[
             ('closed', '!=', True),
             ('type.stock', '=', True),
@@ -144,26 +111,8 @@
             ('company', '=', Eval('company', -1)),
             ],
         depends=['company'])
-    account_stock_customer = fields.Many2One(
-        'account.account', "Account Stock Customer",
-        domain=[
-            ('closed', '!=', True),
-            ('type.stock', '=', True),
-            ('type.statement', '=', 'income'),
-            ('company', '=', Eval('company', -1)),
-            ],
-        depends=['company'])
-    account_stock_production = fields.Many2One(
-        'account.account', "Account Stock Production",
-        domain=[
-            ('closed', '!=', True),
-            ('type.stock', '=', True),
-            ('type.statement', '=', 'income'),
-            ('company', '=', Eval('company', -1)),
-            ],
-        depends=['company'])
-    account_stock_lost_found = fields.Many2One(
-        'account.account', "Account Stock Lost and Found",
+    account_stock_out = fields.Many2One(
+        'account.account', "Account Stock OUT",
         domain=[
             ('closed', '!=', True),
             ('type.stock', '=', True),
@@ -179,6 +128,13 @@
             table = cls.__table_handler__(module_name)
             exist &= all(table.column_exist(c) for c in account_names)
 
+            # Migration from 5.4: rename account_stock_{supplier,customer}
+            for old, new in [
+                    ('account_stock_supplier', 'account_stock_in'),
+                    ('account_stock_customer', 'account_stock_out')]:
+                if table.column_exist(old):
+                    table.column_rename(old, new)
+
         super(CategoryAccount, cls).__register__(module_name)
 
         if not exist:
@@ -209,37 +165,21 @@
         pass
 
     @property
-    @account_used('account_stock_supplier', 'account_category')
-    def account_stock_supplier_used(self):
+    @account_used('account_stock_in', 'account_category')
+    def account_stock_in_used(self):
         pass
 
     @property
-    @account_used('account_stock_customer', 'account_category')
-    def account_stock_customer_used(self):
-        pass
-
-    @property
-    @account_used('account_stock_production', 'account_category')
-    def account_stock_production_used(self):
-        pass
-
-    @property
-    @account_used('account_stock_lost_found', 'account_category')
-    def account_stock_lost_found_used(self):
+    @account_used('account_stock_out', 'account_category')
+    def account_stock_out_used(self):
         pass
 
 
 class Product(metaclass=PoolMeta):
     __name__ = 'product.product'
     account_stock_used = template_property('account_stock_used')
-    account_stock_supplier_used = template_property(
-        'account_stock_supplier_used')
-    account_stock_customer_used = template_property(
-        'account_stock_customer_used')
-    account_stock_production_used = template_property(
-        'account_stock_production_used')
-    account_stock_lost_found_used = template_property(
-        'account_stock_lost_found_used')
+    account_stock_in_used = template_property('account_stock_in_used')
+    account_stock_out_used = template_property('account_stock_out_used')
 
 
 class ModifyCostPriceAsk(ModelView):
@@ -265,17 +205,6 @@
     amount = fields.Numeric('Amount', readonly=True,
         digits=(16, Eval('currency_digits', 2)), depends=['currency_digits'])
     currency_digits = fields.Integer('Currency Digits', readonly=True)
-    journal = fields.Many2One('account.journal', 'Journal', required=True)
-    stock_account = fields.Many2One('account.account', 'Stock Account',
-        readonly=True)
-    counterpart = fields.Many2One('account.account', 'Counterpart',
-        domain=[
-            ('company', 'in',
-                [Eval('context', {}).get('company', -1), None]),
-            ('id', '!=', Eval('stock_account')),
-            ('type.stock', '=', True),
-            ],
-        depends=['stock_account'], required=True)
     description = fields.Char('Description')
 
 
@@ -297,26 +226,22 @@
     create_move = StateTransition()
     modify_price = StateTransition()
 
-    def default_ask_price(self, fields):
-        pool = Pool()
-        Product = pool.get('product.product')
-
-        context = Transaction().context
-        default = {}
-        product = Product(context['active_id'])
-        default['product'] = product.id
-        default['cost_price'] = getattr(
-            product, 'recompute_cost_price_%s' % product.cost_price_method)()
-        return default
-
-    @staticmethod
-    def get_product():
+    @classmethod
+    def get_product(cls):
         'Return the product instance'
         pool = Pool()
         Product = pool.get('product.product')
         context = Transaction().context
         return Product(context['active_id'])
 
+    def default_ask_price(self, fields):
+        default = {}
+        product = self.get_product()
+        default['product'] = product.id
+        default['cost_price'] = getattr(
+            product, 'recompute_cost_price_%s' % product.cost_price_method)()
+        return default
+
     @classmethod
     def get_quantity(cls):
         pool = Pool()
@@ -330,48 +255,52 @@
             product = cls.get_product()
             return product.quantity
 
+    @property
+    def company(self):
+        pool = Pool()
+        User = pool.get('res.user')
+        user = User(Transaction().user)
+        return user.company
+
+    @property
+    def difference_price(self):
+        product = self.get_product()
+        return self.ask_price.cost_price - product.cost_price
+
+    def get_amount(self):
+        return self.company.currency.round(
+            Decimal(str(self.get_quantity())) * self.difference_price)
+
     def transition_should_show_move(self):
         if self.get_quantity() != 0:
             return 'show_move'
         return 'modify_price'
 
     def default_show_move(self, fields):
-        pool = Pool()
-        User = pool.get('res.user')
-        AccountConfiguration = pool.get('account.configuration')
-
-        product = self.get_product()
-        price_diff = (self.ask_price.cost_price
-                - product.cost_price)
-        user = User(Transaction().user)
-        amount = user.company.currency.round(
-            Decimal(str(self.get_quantity())) * price_diff)
-        stock_account_id = product.account_stock_used.id
-        config = AccountConfiguration(1)
-        stock_journal_id = config.stock_journal.id
-        counterpart_id = (config.cost_price_counterpart_account.id if
-            config.cost_price_counterpart_account else None)
         return {
-            'journal': stock_journal_id,
-            'amount': amount,
-            'price_difference': price_diff,
-            'stock_account': stock_account_id,
-            'counterpart': counterpart_id,
-            'currency_digits': user.company.currency.digits,
+            'amount': self.get_amount(),
+            'price_difference': self.difference_price,
+            'currency_digits': self.company.currency.digits,
             }
 
     def get_move_lines(self):
-        Line = Pool().get('account.move.line')
-        amount = self.show_move.amount
+        pool = Pool()
+        Line = pool.get('account.move.line')
+        product = self.get_product()
+        amount = self.get_amount()
+        if amount > 0:
+            account = product.account_stock_in_used
+        else:
+            account = product.account_stock_out_used
         return [Line(
                 debit=amount if amount > 0 else 0,
                 credit=-amount if amount < 0 else 0,
-                account=self.show_move.stock_account,
+                account=product.account_stock_used,
                 ),
             Line(
                 debit=-amount if amount < 0 else 0,
                 credit=amount if amount > 0 else 0,
-                account=self.show_move.counterpart,
+                account=account,
                 ),
             ]
 
@@ -381,13 +310,15 @@
         Period = pool.get('account.period')
         User = pool.get('res.user')
         Move = pool.get('account.move')
+        AccountConfiguration = pool.get('account.configuration')
 
+        config = AccountConfiguration(1)
         user = User(Transaction().user)
         period_id = Period.find(user.company.id)
         return Move(
             description=self.show_move.description,
             period=period_id,
-            journal=self.show_move.journal,
+            journal=config.stock_journal,
             date=Date.today(),
             origin=self.get_product(),
             lines=self.get_move_lines(),
@@ -395,18 +326,16 @@
 
     def transition_create_move(self):
         Move = Pool().get('account.move')
-
-        if self.show_move.counterpart == self.show_move.stock_account:
-            raise ModifyCostPriceError(
-                gettext('account_stock_continental'
-                    '.msg_modify_cost_price_same_account',
-                    account=self.show_move.counterpart.rec_name))
         move = self.get_move()
         move.save()
         Move.post([move])
         return 'modify_price'
 
     def transition_modify_price(self):
-        self.ask_price.product.set_multivalue(
-            'cost_price', self.ask_price.cost_price)
+        pool = Pool()
+        Product = pool.get('product.product')
+        with Transaction().set_context(_check_access=False):
+            Product.write([self.get_product()], {
+                    'cost_price': self.ask_price.cost_price,
+                    })
         return 'end'
diff -r 97e54116ded8 -r 5edcf9732d0d stock.py
--- a/stock.py  Sat Dec 28 17:48:50 2019 +0100
+++ b/stock.py  Wed Jan 08 14:36:45 2020 +0100
@@ -39,14 +39,11 @@
         if type_.startswith('in_'):
             move_line.debit = Decimal('0.0')
             move_line.credit = amount
-            account_type = type_[3:]
+            move_line.account = self.product.account_stock_in_used
         else:
             move_line.debit = amount
             move_line.credit = Decimal('0.0')
-            account_type = type_[4:]
-
-        move_line.account = getattr(self.product,
-            'account_stock_%s_used' % account_type)
+            move_line.account = self.product.account_stock_out_used
 
         return [move_line]
 
@@ -117,7 +114,8 @@
         type_ = self._get_account_stock_move_type()
         if not type_:
             return
-        with Transaction().set_context(date=date):
+        with Transaction().set_context(
+                company=self.company.id, date=date):
             if type_ == 'supplier_customer':
                 account_move_lines = self._get_account_stock_move_lines(
                     'in_supplier')
diff -r 97e54116ded8 -r 5edcf9732d0d 
tests/scenario_account_stock_continental.rst
--- a/tests/scenario_account_stock_continental.rst      Sat Dec 28 17:48:50 
2019 +0100
+++ b/tests/scenario_account_stock_continental.rst      Wed Jan 08 14:36:45 
2020 +0100
@@ -49,10 +49,8 @@
     >>> 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']
+    >>> stock_in = accounts['stock_expense']
+    >>> stock_out, = stock_in.duplicate()
 
 Create parties::
 
@@ -70,10 +68,8 @@
     >>> account_category.account_expense = expense
     >>> account_category.account_revenue = revenue
     >>> account_category.account_stock = stock
-    >>> account_category.account_stock_supplier = stock_supplier
-    >>> account_category.account_stock_customer = stock_customer
-    >>> account_category.account_stock_production = stock_production
-    >>> account_category.account_stock_lost_found = stock_lost_found
+    >>> account_category.account_stock_in = stock_in
+    >>> account_category.account_stock_out = stock_out
     >>> account_category.save()
 
 Create product::
@@ -143,10 +139,10 @@
     >>> shipment.click('done')
     >>> shipment.state
     'done'
-    >>> stock_supplier.reload()
-    >>> stock_supplier.debit
+    >>> stock_in.reload()
+    >>> stock_in.debit
     Decimal('0.00')
-    >>> stock_supplier.credit
+    >>> stock_in.credit
     Decimal('50.00')
     >>> stock.reload()
     >>> stock.debit
@@ -211,10 +207,10 @@
     >>> shipment.click('done')
     >>> shipment.state
     'done'
-    >>> stock_customer.reload()
-    >>> stock_customer.debit
+    >>> stock_out.reload()
+    >>> stock_out.debit
     Decimal('28.00')
-    >>> stock_customer.credit
+    >>> stock_out.credit
     Decimal('0.00')
     >>> stock.reload()
     >>> stock.debit
@@ -258,10 +254,10 @@
     >>> inventory.click('confirm')
     >>> inventory.state
     'done'
-    >>> stock_lost_found.reload()
-    >>> stock_lost_found.debit
-    Decimal('11.00')
-    >>> stock_lost_found.credit
+    >>> stock_out.reload()
+    >>> stock_out.debit
+    Decimal('39.00')
+    >>> stock_out.credit
     Decimal('0.00')
     >>> stock.reload()
     >>> stock.debit
@@ -313,15 +309,15 @@
     >>> shipment.state
     'done'
 
-    >>> stock_supplier.reload()
-    >>> stock_supplier.debit
+    >>> stock_in.reload()
+    >>> stock_in.debit
     Decimal('0.00')
-    >>> stock_supplier.credit
+    >>> stock_in.credit
     Decimal('68.00')
-    >>> stock_customer.reload()
-    >>> stock_customer.debit
-    Decimal('46.00')
-    >>> stock_customer.credit
+    >>> stock_out.reload()
+    >>> stock_out.debit
+    Decimal('57.00')
+    >>> stock_out.credit
     Decimal('0.00')
 
     >>> product_supplier = ProductSupplier()
@@ -365,30 +361,29 @@
     >>> shipment.state
     'done'
 
-    >>> stock_supplier.reload()
-    >>> stock_supplier.debit
+    >>> stock_in.reload()
+    >>> stock_in.debit
     Decimal('0.00')
-    >>> stock_supplier.credit
+    >>> stock_in.credit
     Decimal('88.00')
-    >>> stock_customer.reload()
-    >>> stock_customer.debit
-    Decimal('66.00')
-    >>> stock_customer.credit
+    >>> stock_out.reload()
+    >>> stock_out.debit
+    Decimal('77.00')
+    >>> stock_out.credit
     Decimal('0.00')
 
 Modify cost price::
+
     >>> Account = Model.get('account.account')
-    >>> counterpart, = Account.find([('name', '=', 'Stock Lost and Found')])
     >>> modify_price = Wizard('product.modify_cost_price', [product])
     >>> modify_price.form.cost_price = Decimal('3.00')
     >>> modify_price.execute('should_show_move')
     >>> modify_price.form.description = 'Change product cost price.'
-    >>> modify_price.form.counterpart = counterpart
     >>> modify_price.execute('create_move')
     >>> product.cost_price
     Decimal('3.00')
-    >>> stock_lost_found.reload()
-    >>> stock_lost_found.debit
-    Decimal('13.00')
-    >>> stock_lost_found.credit
+    >>> stock_out.reload()
+    >>> stock_out.debit
+    Decimal('79.00')
+    >>> stock_out.credit
     Decimal('0.00')
diff -r 97e54116ded8 -r 5edcf9732d0d view/category_form.xml
--- a/view/category_form.xml    Sat Dec 28 17:48:50 2019 +0100
+++ b/view/category_form.xml    Wed Jan 08 14:36:45 2020 +0100
@@ -8,13 +8,9 @@
         <label name="account_stock"/>
         <field name="account_stock"/>
         <newline/>
-        <label name="account_stock_customer"/>
-        <field name="account_stock_customer"/>
-        <label name="account_stock_supplier"/>
-        <field name="account_stock_supplier"/>
-        <label name="account_stock_production"/>
-        <field name="account_stock_production"/>
-        <label name="account_stock_lost_found"/>
-        <field name="account_stock_lost_found"/>
+        <label name="account_stock_in"/>
+        <field name="account_stock_in"/>
+        <label name="account_stock_out"/>
+        <field name="account_stock_out"/>
     </xpath>
 </data>
diff -r 97e54116ded8 -r 5edcf9732d0d view/configuration_form.xml
--- a/view/configuration_form.xml       Sat Dec 28 17:48:50 2019 +0100
+++ b/view/configuration_form.xml       Wed Jan 08 14:36:45 2020 +0100
@@ -6,8 +6,6 @@
         <separator id="stock" string="Stock" colspan="4"/>
         <label name="stock_journal"/>
         <field name="stock_journal"/>
-        <label name="cost_price_counterpart_account"/>
-        <field name="cost_price_counterpart_account"/>
         <newline/>
     </xpath>
 </data>
diff -r 97e54116ded8 -r 5edcf9732d0d view/modify_cost_price_show_move_form.xml
--- a/view/modify_cost_price_show_move_form.xml Sat Dec 28 17:48:50 2019 +0100
+++ b/view/modify_cost_price_show_move_form.xml Wed Jan 08 14:36:45 2020 +0100
@@ -2,17 +2,10 @@
 <!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
 this repository contains the full copyright notices and license terms. -->
 <form>
-    <label name="description"/>
-    <field name="description" colspan="3"/>
-    <label name="journal"/>
-    <field name="journal"/>
-    <newline/>
     <label name="amount"/>
     <field name="amount"/>
     <label name="price_difference"/>
     <field name="price_difference"/>
-    <label name="stock_account"/>
-    <field name="stock_account"/>
-    <label name="counterpart"/>
-    <field name="counterpart"/>
+    <label name="description"/>
+    <field name="description" colspan="3"/>
 </form>

Reply via email to