Reviewers: ,
Please review this at http://codereview.tryton.org/557002/
Affected files:
M account.xml
M doc/index.rst
M product.py
M product.xml
M stock.py
Index: account.xml
===================================================================
--- a/account.xml
+++ b/account.xml
@@ -64,6 +64,15 @@
<field name="kind">stock</field>
</record>
+ <record model="account.account.template"
id="account_template_stock_production">
+ <field name="name">Stock Production</field>
+ <field name="type"
ref="account_type_template_asset_current_inventories"/>
+ <field name="reconcile" eval="True"/>
+ <field name="deferral" eval="True"/>
+ <field name="parent" ref="account.account_template_root"/>
+ <field name="kind">stock</field>
+ </record>
+
<record model="account.account.template"
id="account_template_stock_lost_found">
<field name="name">Stock Lost and Found</field>
<field name="type"
ref="account_type_template_asset_current_inventories"/>
Index: doc/index.rst
===================================================================
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -13,6 +13,7 @@
- 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 @@
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 @@
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.
Index: product.py
===================================================================
--- a/product.py
+++ b/product.py
@@ -44,6 +44,17 @@
| 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 @@
'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 @@
}, 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 @@
'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')
Index: product.xml
===================================================================
--- a/product.xml
+++ b/product.xml
@@ -71,6 +71,8 @@
<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"/>
</xpath>
@@ -95,6 +97,8 @@
<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"/>
</xpath>
Index: stock.py
===================================================================
--- a/stock.py
+++ b/stock.py
@@ -27,7 +27,8 @@
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 @@
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):
'''
--
[email protected] mailing list