diff --git a/account.xml b/account.xml
index 3fef7181f1..5c49971817 100644
--- a/account.xml
+++ b/account.xml
@@ -64,6 +64,15 @@ this repository contains the full copyright notices and license terms. -->
stock
+
+ Stock Production
+
+
+
+
+ stock
+
+
Stock Lost and Found
diff --git a/doc/index.rst b/doc/index.rst
index bee5b1c434..a2147d3e60 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -13,6 +13,7 @@ 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 Production: The counter part account for production stock move.
- Account Stock Lost and Found: The counter part account for lost and found
stock move.
@@ -20,8 +21,8 @@ As usual, if the "Use Category's accounts" is checked it is the category one
that is used otherwise it is the product one.
An Account Move is created for each Stock Move for which one Stock Location has
-the type "Storage" and an the other has the type "Supplier", "Customer" or
-"Lost and Found".
+the type "Storage" and an the other has the type "Supplier", "Customer",
+"Production" or "Lost and Found".
If the Stock Move has a "Supplier" Location as origin, then the Account Stock
of the Product is debited and the Account Stock Supplier of the Product is
@@ -34,5 +35,8 @@ Stock of the Product is credited and the Account Stock Customer of the Product
is debited. The amount is the current Cost Price of the Product.
The account move is inverted if it is the origin.
+When the Location has the type "Production", then the Account Stock Production
+is used instead of the Supplier/Customer.
+
When the Location has the type "Lost and Found", then the Account Stock Lost
and Found is used instead of the Supplier/Customer.
diff --git a/product.py b/product.py
index 63ffbc634f..0873a13d68 100644
--- a/product.py
+++ b/product.py
@@ -44,6 +44,17 @@ class Category:
| Eval('account_parent')),
},
depends=['account_parent']))
+ account_stock_production = fields.Property(
+ fields.Many2One('account.account',
+ 'Account Stock Production', domain=[
+ ('kind', '=', 'stock'),
+ ('company', '=', Eval('context', {}).get('company', 0)),
+ ],
+ states={
+ 'invisible': (~Eval('context', {}).get('company')
+ | Eval('account_parent')),
+ },
+ depends=['account_parent']))
account_stock_lost_found = fields.Property(fields.Many2One(
'account.account', 'Account Stock Lost and Found', domain=[
('kind', '=', 'stock'),
@@ -60,6 +71,8 @@ class Category:
'account.account', 'Account Stock Supplier Used'), 'get_account')
account_stock_customer_used = fields.Function(fields.Many2One(
'account.account', 'Account Stock Customer Used'), 'get_account')
+ account_stock_production_used = fields.Function(fields.Many2One(
+ 'account.account', 'Account Stock Production Used'), 'get_account')
account_stock_lost_found_used = fields.Function(fields.Many2One(
'account.account', 'Account Stock Lost and Found'), 'get_account')
@@ -114,6 +127,23 @@ class Template:
}, help='This account will be used instead of the one defined '
'on the category.',
depends=['account_category', 'type']))
+ account_stock_production = fields.Property(
+ fields.Many2One('account.account',
+ 'Account Stock Production',
+ domain=[
+ ('kind', '=', 'stock'),
+ ('company', '=', Eval('context', {}).get('company', 0)),
+ ],
+ states={
+ 'invisible': (~Eval('context', {}).get('company')
+ | Eval('account_category')
+ | (Eval('type') != 'goods')),
+ 'required': ((Eval('type') == 'goods')
+ & Eval('context', {}).get('company')
+ & ~Eval('account_category')),
+ }, help='This account will be used instead of the one defined '
+ 'on the category.',
+ depends=['account_category', 'type']))
account_stock_lost_found = fields.Property(fields.Many2One(
'account.account', 'Account Stock Lost and Found',
domain=[
@@ -136,6 +166,8 @@ class Template:
'account.account', 'Account Stock Supplier Used'), 'get_account')
account_stock_customer_used = fields.Function(fields.Many2One(
'account.account', 'Account Stock Customer Used'), 'get_account')
+ account_stock_production_used = fields.Function(fields.Many2One(
+ 'account.account', 'Account Stock Production Used'), 'get_account')
account_stock_lost_found_used = fields.Function(fields.Many2One(
'account.account', 'Account Stock Lost and Found'), 'get_account')
diff --git a/product.xml b/product.xml
index 0d05630fc2..219a3d716e 100644
--- a/product.xml
+++ b/product.xml
@@ -71,6 +71,8 @@ this repository contains the full copyright notices and license terms. -->
+
+
@@ -95,6 +97,8 @@ this repository contains the full copyright notices and license terms. -->
+
+
diff --git a/stock.py b/stock.py
index 9b83b7d98d..161b2389f2 100644
--- a/stock.py
+++ b/stock.py
@@ -27,7 +27,8 @@ class Move:
with Transaction().set_user(0, set_context=True):
move_line = AccountMoveLine()
- if (type_.endswith('supplier')
+ if ((type_.endswith('supplier')
+ or type_ == 'in_production')
and self.product.cost_price_method != 'fixed'):
unit_price = self.unit_price
else:
@@ -113,6 +114,10 @@ class Move:
return 'supplier_customer'
elif type_ == ('customer', 'supplier'):
return 'customer_supplier'
+ elif type_ == ('storage', 'production'):
+ return 'out_production'
+ elif type_ == ('production', 'storage'):
+ return 'in_production'
def _create_account_stock_move(self):
'''