Define "Stock Journal" on "Account Configuration"
issue2406 review231007
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Define "Stock Journal" on "Account Configuration"
|
||||
* Use cost price instead of unit price when cost method is "fixed"
|
||||
|
||||
Version 2.2.0 - 2011-10-24
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
|
||||
from .stock import *
|
||||
from .product import *
|
||||
from .account import *
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#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 Model, fields
|
||||
from trytond.pyson import Eval, Bool
|
||||
|
||||
|
||||
class Configuration(Model):
|
||||
_name = 'account.configuration'
|
||||
|
||||
stock_journal = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Stock Journal',
|
||||
states={
|
||||
'required': Bool(Eval('context', {}).get('company')),
|
||||
}))
|
||||
|
||||
Configuration()
|
||||
+24
@@ -3,6 +3,30 @@
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="configuration_view_form">
|
||||
<field name="model">account.configuration</field>
|
||||
<field name="inherit" ref="account.configuration_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form"
|
||||
position="inside">
|
||||
<newline/>
|
||||
<label name="stock_journal"/>
|
||||
<field name="stock_journal"/>
|
||||
<newline/>
|
||||
</xpath>
|
||||
</data>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.property" id="property_stock_journal">
|
||||
<field name="field"
|
||||
search="[('model.model', '=', 'account.configuration'), ('name', '=', 'stock_journal')]"/>
|
||||
<field name="value" eval="'account.journal,' + str(ref('account.journal_stock'))"/>
|
||||
</record>
|
||||
|
||||
<record model="account.account.type.template"
|
||||
id="account_type_template_asset_current_inventories">
|
||||
|
||||
+5
-5
@@ -4,17 +4,17 @@ Account Stock Continental Module
|
||||
The account_stock_continental module adds continental accounting model for
|
||||
stock valuation.
|
||||
|
||||
Five new fields are added to Product and Category:
|
||||
A new configuration field for accounting is added:
|
||||
|
||||
- Journal Stock: The journal used for stock move.
|
||||
|
||||
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 Lost and Found: The counter part account for lost and found
|
||||
stock move.
|
||||
- Account Journal Stock Supplier: The journal used for supplier stock move.
|
||||
- Account Journal Stock Customer: The journal used for customer stock move.
|
||||
- Account Journal Stock Lost and Found: The journal used for lost and found
|
||||
stock move.
|
||||
|
||||
As usual, if the "Use Category's accounts" is checked it is the category one
|
||||
that is used otherwise it is the product one.
|
||||
|
||||
-55
@@ -39,21 +39,6 @@ class Category(ModelSQL, ModelView):
|
||||
states={
|
||||
'invisible': ~Eval('context', {}).get('company'),
|
||||
}))
|
||||
account_journal_stock_supplier = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Journal Stock Supplier',
|
||||
states={
|
||||
'invisible': ~Eval('context', {}).get('company'),
|
||||
}))
|
||||
account_journal_stock_customer = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Journal Stock Customer',
|
||||
states={
|
||||
'invisible': ~Eval('context', {}).get('company'),
|
||||
}))
|
||||
account_journal_stock_lost_found = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Journal Stock Lost and Found',
|
||||
states={
|
||||
'invisible': ~Eval('context', {}).get('company'),
|
||||
}))
|
||||
|
||||
Category()
|
||||
|
||||
@@ -121,39 +106,6 @@ class Template(ModelSQL, ModelView):
|
||||
}, help='This account will be used instead of the one defined '
|
||||
'on the category.',
|
||||
depends=['account_category', 'type']))
|
||||
account_journal_stock_supplier = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Account Journal Stock Supplier',
|
||||
states={
|
||||
'invisible': (~Eval('context', {}).get('company')
|
||||
| Eval('account_category')),
|
||||
'required': (Eval('type').in_(['stockable', 'consumable'])
|
||||
& Eval('context', {}).get('company')
|
||||
& ~Eval('account_category')),
|
||||
}, help='This journal will be used instead of the one defined '
|
||||
'on the category.',
|
||||
depends=['account_category', 'type']))
|
||||
account_journal_stock_customer = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Account Journal Stock Customer',
|
||||
states={
|
||||
'invisible': (~Eval('context', {}).get('company')
|
||||
| Eval('account_category')),
|
||||
'required': (Eval('type').in_(['stockable', 'consumable'])
|
||||
& Eval('context', {}).get('company')
|
||||
& ~Eval('account_category')),
|
||||
}, help='This journal will be used instead of the one defined '
|
||||
'on the category.',
|
||||
depends=['account_category', 'type']))
|
||||
account_journal_stock_lost_found = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Account Journal Stock Lost and Found',
|
||||
states={
|
||||
'invisible': (~Eval('context', {}).get('company')
|
||||
| Eval('account_category')),
|
||||
'required': (Eval('type').in_(['stockable', 'consumable'])
|
||||
& Eval('context', {}).get('company')
|
||||
& ~Eval('account_category')),
|
||||
}, help='This journal will be used instead of the one defined '
|
||||
'on the category.',
|
||||
depends=['account_category', 'type']))
|
||||
account_stock_used = fields.Function(fields.Many2One('account.account',
|
||||
'Account Stock Used'), 'get_account')
|
||||
account_stock_supplier_used = fields.Function(fields.Many2One(
|
||||
@@ -162,13 +114,6 @@ class Template(ModelSQL, ModelView):
|
||||
'account.account', 'Account Stock Customer Used'), 'get_account')
|
||||
account_stock_lost_found_used = fields.Function(fields.Many2One(
|
||||
'account.account', 'Account Stock Lost and Found'), 'get_account')
|
||||
account_journal_stock_supplier_used = fields.Function(fields.Many2One(
|
||||
'account.journal', 'Journal Stock Supplier'), 'get_account')
|
||||
account_journal_stock_customer_used = fields.Function(fields.Many2One(
|
||||
'account.journal', 'Journal Stock Customer'), 'get_account')
|
||||
account_journal_stock_lost_found_used = fields.Function(fields.Many2One(
|
||||
'account.journal', 'Journal Stock Lost and Found'),
|
||||
'get_account')
|
||||
|
||||
Template()
|
||||
|
||||
|
||||
-14
@@ -22,13 +22,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="account_stock_supplier"/>
|
||||
<label name="account_stock_lost_found"/>
|
||||
<field name="account_stock_lost_found"/>
|
||||
<newline/>
|
||||
<label name="account_journal_stock_customer"/>
|
||||
<field name="account_journal_stock_customer"/>
|
||||
<label name="account_journal_stock_supplier"/>
|
||||
<field name="account_journal_stock_supplier"/>
|
||||
<label name="account_journal_stock_lost_found"/>
|
||||
<field name="account_journal_stock_lost_found"/>
|
||||
</xpath>
|
||||
</data>
|
||||
]]>
|
||||
@@ -53,13 +46,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="account_stock_supplier"/>
|
||||
<label name="account_stock_lost_found"/>
|
||||
<field name="account_stock_lost_found"/>
|
||||
<newline/>
|
||||
<label name="account_journal_stock_customer"/>
|
||||
<field name="account_journal_stock_customer"/>
|
||||
<label name="account_journal_stock_supplier"/>
|
||||
<field name="account_journal_stock_supplier"/>
|
||||
<label name="account_journal_stock_lost_found"/>
|
||||
<field name="account_journal_stock_lost_found"/>
|
||||
</xpath>
|
||||
</data>
|
||||
]]>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#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 decimal import Decimal
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.model import Model, ModelView, ModelSQL, fields
|
||||
from trytond.pool import Pool
|
||||
|
||||
|
||||
@@ -61,25 +61,18 @@ class Move(ModelSQL, ModelView):
|
||||
move_line['credit'] = Decimal('0.0')
|
||||
return move_line
|
||||
|
||||
def _get_account_stock_move(self, move, move_lines, type_):
|
||||
def _get_account_stock_move(self, move, move_lines):
|
||||
'''
|
||||
Return account move value for stock move
|
||||
'''
|
||||
date_obj = Pool().get('ir.date')
|
||||
period_obj = Pool().get('account.period')
|
||||
assert type_.startswith('in_') or type_.startswith('out_'), 'wrong type'
|
||||
account_configuration_obj = Pool().get('account.configuration')
|
||||
|
||||
date = move.effective_date or date_obj.today()
|
||||
period_id = period_obj.find(move.company.id, date=date)
|
||||
|
||||
if type_.startswith('in_'):
|
||||
journal_type = type_[3:]
|
||||
else:
|
||||
journal_type = type_[4:]
|
||||
|
||||
journal_id = getattr(move.product,
|
||||
'account_journal_stock_%s_used' % journal_type).id
|
||||
|
||||
account_configuration = account_configuration_obj.browse(1)
|
||||
journal_id = account_configuration.stock_journal.id
|
||||
return {
|
||||
'journal': journal_id,
|
||||
'period': period_id,
|
||||
@@ -123,7 +116,7 @@ class Move(ModelSQL, ModelView):
|
||||
self._get_account_stock_move_line(move, amount))
|
||||
|
||||
account_move_id = account_move_obj.create(
|
||||
self._get_account_stock_move(move, account_move_lines, type_))
|
||||
self._get_account_stock_move(move, account_move_lines))
|
||||
self.write(move.id, {
|
||||
'account_move': account_move_id,
|
||||
})
|
||||
|
||||
@@ -87,7 +87,6 @@ Create chart of accounts::
|
||||
|
||||
>>> AccountTemplate = Model.get('account.account.template')
|
||||
>>> Account = Model.get('account.account')
|
||||
>>> AccountJournal = Model.get('account.journal')
|
||||
>>> account_template, = AccountTemplate.find([('parent', '=', False)])
|
||||
>>> create_chart = Wizard('account.create_chart')
|
||||
>>> create_chart.execute('account')
|
||||
@@ -118,7 +117,6 @@ Create chart of accounts::
|
||||
>>> create_chart.form.account_receivable = receivable
|
||||
>>> create_chart.form.account_payable = payable
|
||||
>>> create_chart.execute('create_properties')
|
||||
>>> stock_journal, = AccountJournal.find([('code', '=', 'STO')])
|
||||
|
||||
Create parties::
|
||||
|
||||
@@ -155,9 +153,6 @@ Create product::
|
||||
>>> product.account_stock_supplier = stock_supplier
|
||||
>>> product.account_stock_customer = stock_customer
|
||||
>>> product.account_stock_lost_found = stock_lost_found
|
||||
>>> product.account_journal_stock_supplier = stock_journal
|
||||
>>> product.account_journal_stock_customer = stock_journal
|
||||
>>> product.account_journal_stock_lost_found = stock_journal
|
||||
>>> product.save()
|
||||
>>> product_average = Product(Product.copy(product.id, config.context))
|
||||
>>> product_average.cost_price_method = 'average'
|
||||
|
||||
Reference in New Issue
Block a user