Add support for production moves
issue2665 review557002
This commit is contained in:
1 parent
6cc6e001f4
commit
3d1096ff1d
5 files changed
+57
-3
No files matched your search
@@ -64,6 +64,15 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<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"/>
|
||||
|
||||
+6
-2
@@ -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.
|
||||
+32
@@ -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')
|
||||
|
||||
|
||||
@@ -71,6 +71,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<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 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<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>
|
||||
|
||||
@@ -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):
|
||||
'''
|
||||
|
||||
Reference in new issue
Block a user