[ADD] stock_account: started code to record product.product prices changes.
bzr revid: vmt@openerp.com-20130730114039-09f8l896imgps8m9
This commit is contained in:
parent
6a30d52a6f
commit
8da85e057d
|
@ -20,6 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
import product
|
||||
import standard_prices
|
||||
import stock_account
|
||||
import wizard
|
||||
|
||||
|
|
|
@ -166,6 +166,36 @@ class product_product(osv.osv):
|
|||
|
||||
return move_ids
|
||||
|
||||
def write(self, cr, uid, ids, values, context=None):
|
||||
standard_prices = self.pool['standard.prices']
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
if record.cost_method == 'standard':
|
||||
data = {
|
||||
'company_id': False,
|
||||
'quant_id': False,
|
||||
'product_id': False,
|
||||
'cost': False,
|
||||
'date': False,
|
||||
'reason': False,
|
||||
}
|
||||
standard_prices.create(cr, uid, data, context=context)
|
||||
elif record.cost_method == 'average':
|
||||
data = {
|
||||
'company_id': False,
|
||||
'quant_id': False,
|
||||
'product_id': False,
|
||||
'cost': False,
|
||||
'date': False,
|
||||
'reason': False,
|
||||
}
|
||||
standard_prices.create(cr, uid, data, context=context)
|
||||
elif record.cost_method == 'real':
|
||||
# For a 'real' cost_method, entries in standard_prices are
|
||||
# created when quants are created.
|
||||
pass
|
||||
return super(product_product, self).write(cr, uid, ids, values,
|
||||
context=context)
|
||||
|
||||
_columns = {
|
||||
'valuation':fields.property(type='selection', selection=[('manual_periodic', 'Periodical (manual)'),
|
||||
('real_time','Real Time (automated)'),], string = 'Inventory Valuation',
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
"""
|
||||
Keep track of the ``product.product`` standard prices as they are changed.
|
||||
|
||||
The ``standard.prices`` model records each ``standard`` or ``average``
|
||||
``cost_method`` change. For the ``real`` ``cost_method`` it records every
|
||||
wuants creation.
|
||||
|
||||
"""
|
||||
|
||||
import openerp
|
||||
|
||||
class standard_prices(openerp.osv.orm.Model):
|
||||
|
||||
_name = 'standard.prices'
|
||||
|
||||
_columns = {
|
||||
'company_id': openerp.osv.fields.many2one('res.company', required=True),
|
||||
'quant_id': openerp.osv.fields.many2one('stock.quant'),
|
||||
'product_id': openerp.osv.fields.many2one('product.product'),
|
||||
'cost': openerp.osv.fields.float(),
|
||||
'date': openerp.osv.fields.date(),
|
||||
'reason': openerp.osv.fields.char(),
|
||||
# TODO 'origin': openerp.osv.fields.reference(),
|
||||
}
|
Loading…
Reference in New Issue