diff --git a/CHANGELOG b/CHANGELOG
index 5b8f79c771..6219270edb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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 --git a/__init__.py b/__init__.py
index 1ba55d7877..4fa80b7315 100644
--- a/__init__.py
+++ b/__init__.py
@@ -16,7 +16,6 @@ def register():
product.Product,
account.Configuration,
account.ConfigurationStockJournal,
- account.ConfigurationCostPriceCounterpartAccount,
account.FiscalYear,
account.AccountMove,
product.ModifyCostPriceAsk,
diff --git a/account.py b/account.py
index 5e40fc4248..872cd1b0e9 100644
--- a/account.py
+++ b/account.py
@@ -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 @@ stock_journal = fields.Many2One(
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 @@ class ConfigurationStockJournal(ModelSQL, ValueMixin):
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 --git a/exceptions.py b/exceptions.py
deleted file mode 100644
index 6ac7a16b3f..0000000000
--- a/exceptions.py
+++ /dev/null
@@ -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 --git a/message.xml b/message.xml
index 8be01aaacb..12b6d92341 100644
--- a/message.xml
+++ b/message.xml
@@ -7,8 +7,5 @@ this repository contains the full copyright notices and license terms. -->
You cannot change the cost price of a product which is associated to stock moves.
You must use the "Modify Cost Price" wizard.
-
- To modify the cost price, you must change the counterpart account "%(account)s".
-
diff --git a/minimal_chart.xml b/minimal_chart.xml
index 65e80a9151..c9de0e7321 100644
--- a/minimal_chart.xml
+++ b/minimal_chart.xml
@@ -56,66 +56,17 @@ this repository contains the full copyright notices and license terms. -->
-
- Stock Supplier
- Stock Supplier
- Estoc proveïdor
- Lager Lieferant
- Stock del proveedor
- Stock fournisseur
- Stock Supplier
- Estoque do Fornecedor
- Stock Supplier
- Zaloga dobavitelja
-
-
-
-
-
- Stock Customer
- Stock Customer
- Estoc client
- Lager Kunde
- Stock cliente
- Stock client
- Stock Customer
- Estoque do Cliente
- Stock Customer
- Zaloga kupca
-
-
-
-
-
- Stock Production
- Stock Production
- Estoc producció
- Lager Produktion
- Stock producción
- Stock de production
- Stock Production
- Estoque da Produção
- Stock Production
- Zaloga proizvodnje
-
-
-
-
-
- Stock Lost and Found
- Stock Lost and Found
- Estoc perdut/trobat
- Lager Inventurdifferenz
- Stock perdido y encontrado
- Stock « pertes et surplus »
- Stock Lost and Found
- Estoque de Achados e Perdidos
- Stock Lost and Found
- Zaloga izgubljeno/najdeno
+
+ Stock Expense
+ Разход на акции
+ Despeses d'existències
+ Lagerkosten
+ Gastos de existencias
+ Variation des stocks
+ Voorraad
+ Despesa de estoque
+ Расходы на акции
+ Stroški zalog
diff --git a/minimal_chart_bg.xml b/minimal_chart_bg.xml
index bb9c41175b..2494c7a654 100644
--- a/minimal_chart_bg.xml
+++ b/minimal_chart_bg.xml
@@ -53,54 +53,9 @@ this repository contains the full copyright notices and license terms. -->
-
+
- Stock Supplier
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Customer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Production
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Lost and Found
+ Разход на акции
diff --git a/minimal_chart_ca.xml b/minimal_chart_ca.xml
index 41a27cca97..33e5aade2f 100644
--- a/minimal_chart_ca.xml
+++ b/minimal_chart_ca.xml
@@ -53,55 +53,10 @@ this repository contains the full copyright notices and license terms. -->
-
+
- Estoc proveïdor
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Estoc client
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Estoc producció
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Estoc perdut/trobat
+ Despeses d'existències
diff --git a/minimal_chart_de.xml b/minimal_chart_de.xml
index 21f4a2c0c1..056550c72b 100644
--- a/minimal_chart_de.xml
+++ b/minimal_chart_de.xml
@@ -53,56 +53,11 @@ this repository contains the full copyright notices and license terms. -->
-
+
- Lager Lieferant
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Lager Kunde
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Lager Produktion
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Lager Inventurdifferenz
+ Lagerkosten
diff --git a/minimal_chart_en.xml b/minimal_chart_en.xml
index bdcc08530b..4f6de371e0 100644
--- a/minimal_chart_en.xml
+++ b/minimal_chart_en.xml
@@ -53,53 +53,8 @@ this repository contains the full copyright notices and license terms. -->
-
- Stock Supplier
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Customer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Production
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Lost and Found
+
+ Stock Expense
diff --git a/minimal_chart_es.xml b/minimal_chart_es.xml
index a5e4a70e92..dc0a647a1f 100644
--- a/minimal_chart_es.xml
+++ b/minimal_chart_es.xml
@@ -53,57 +53,12 @@ this repository contains the full copyright notices and license terms. -->
-
+
- Stock del proveedor
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock cliente
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock producción
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock perdido y encontrado
+ Gastos de existencias
diff --git a/minimal_chart_fr.xml b/minimal_chart_fr.xml
index 74c30a6986..18184b8269 100644
--- a/minimal_chart_fr.xml
+++ b/minimal_chart_fr.xml
@@ -53,58 +53,13 @@ this repository contains the full copyright notices and license terms. -->
-
+
- Stock fournisseur
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock client
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock de production
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock « pertes et surplus »
+ Variation des stocks
diff --git a/minimal_chart_nl.xml b/minimal_chart_nl.xml
index b88b9211cb..d00be148e7 100644
--- a/minimal_chart_nl.xml
+++ b/minimal_chart_nl.xml
@@ -53,59 +53,14 @@ this repository contains the full copyright notices and license terms. -->
-
+
- Stock Supplier
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Customer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Production
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Lost and Found
+ Voorraad
diff --git a/minimal_chart_pt.xml b/minimal_chart_pt.xml
index 5b4c5631a6..2f6b27af76 100644
--- a/minimal_chart_pt.xml
+++ b/minimal_chart_pt.xml
@@ -53,7 +53,7 @@ this repository contains the full copyright notices and license terms. -->
-
+
@@ -61,52 +61,7 @@ this repository contains the full copyright notices and license terms. -->
- Estoque do Fornecedor
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Estoque do Cliente
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Estoque da Produção
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Estoque de Achados e Perdidos
+ Despesa de estoque
diff --git a/minimal_chart_ru.xml b/minimal_chart_ru.xml
index 8ee9c87577..3964bdb8e0 100644
--- a/minimal_chart_ru.xml
+++ b/minimal_chart_ru.xml
@@ -53,7 +53,7 @@ this repository contains the full copyright notices and license terms. -->
-
+
@@ -62,52 +62,7 @@ this repository contains the full copyright notices and license terms. -->
- Stock Supplier
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Customer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Production
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stock Lost and Found
+ Расходы на акции
diff --git a/minimal_chart_sl.xml b/minimal_chart_sl.xml
index 7d3c0f70fa..a014e5f30c 100644
--- a/minimal_chart_sl.xml
+++ b/minimal_chart_sl.xml
@@ -53,7 +53,7 @@ this repository contains the full copyright notices and license terms. -->
-
+
@@ -63,52 +63,7 @@ this repository contains the full copyright notices and license terms. -->
- Zaloga dobavitelja
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Zaloga kupca
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Zaloga proizvodnje
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Zaloga izgubljeno/najdeno
+ Stroški zalog
diff --git a/product.py b/product.py
index c1846025bd..7dbc582f68 100644
--- a/product.py
+++ b/product.py
@@ -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.pool import Pool, PoolMeta
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,6 +27,9 @@ class Category(metaclass=PoolMeta):
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={
@@ -37,12 +37,14 @@ class Category(metaclass=PoolMeta):
| Eval('account_parent')
| ~Eval('accounting', False)),
},
- depends=['account_parent', 'accounting']))
- account_stock_supplier = fields.MultiValue(fields.Many2One(
- 'account.account', "Account Stock Supplier",
+ 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={
@@ -50,12 +52,13 @@ class Category(metaclass=PoolMeta):
| 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']))
+ 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={
@@ -63,33 +66,7 @@ class Category(metaclass=PoolMeta):
| Eval('account_parent')
| ~Eval('accounting', False)),
},
- depends=['account_parent', 'accounting']))
- account_stock_production = fields.MultiValue(fields.Many2One(
- 'account.account', "Account Stock Production",
- 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_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 @@ class Category(metaclass=PoolMeta):
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 @@ class CategoryAccount(metaclass=PoolMeta):
('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 @@ class CategoryAccount(metaclass=PoolMeta):
('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 @@ class CategoryAccount(metaclass=PoolMeta):
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 @@ class Template(metaclass=PoolMeta):
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 @@ class ModifyCostPriceShowMove(ModelView):
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 @@ class ModifyCostPrice(Wizard):
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 @@ class ModifyCostPrice(Wizard):
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 @@ class ModifyCostPrice(Wizard):
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 @@ class ModifyCostPrice(Wizard):
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 --git a/stock.py b/stock.py
index c0638dede5..6a90cb63eb 100644
--- a/stock.py
+++ b/stock.py
@@ -39,14 +39,11 @@ class Move(metaclass=PoolMeta):
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 @@ class Move(metaclass=PoolMeta):
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 --git a/tests/scenario_account_stock_continental.rst b/tests/scenario_account_stock_continental.rst
index dc92a3f152..24133dc432 100644
--- a/tests/scenario_account_stock_continental.rst
+++ b/tests/scenario_account_stock_continental.rst
@@ -49,10 +49,8 @@ Create chart of accounts::
>>> 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 @@ Create product category::
>>> 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 @@ Receive 9 products::
>>> 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 @@ Send 5 products::
>>> 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 @@ Create an Inventory::
>>> 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 @@ Create Drop Shipment Move::
>>> 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 @@ Create Drop Shipment Move::
>>> 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 --git a/view/category_form.xml b/view/category_form.xml
index e6ab87bcab..db2fe8afa9 100644
--- a/view/category_form.xml
+++ b/view/category_form.xml
@@ -8,13 +8,9 @@ this repository contains the full copyright notices and license terms. -->
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/view/configuration_form.xml b/view/configuration_form.xml
index 393b18cf7e..1d5ba1857c 100644
--- a/view/configuration_form.xml
+++ b/view/configuration_form.xml
@@ -6,8 +6,6 @@ this repository contains the full copyright notices and license terms. -->
-
-
diff --git a/view/modify_cost_price_show_move_form.xml b/view/modify_cost_price_show_move_form.xml
index 7225e7c3bd..2fc30fed7c 100644
--- a/view/modify_cost_price_show_move_form.xml
+++ b/view/modify_cost_price_show_move_form.xml
@@ -2,17 +2,10 @@