[IMP] Add computation of stock entries based on
valuation priclist of company for accounting entries bzr revid: joel.grandguillaume@camptocamp.com-20091217151233-85fnrq17pt2o7w7n
This commit is contained in:
parent
ff19c0f96b
commit
d3c8dc2db4
|
@ -57,7 +57,7 @@ class account_analytic_account(osv.osv):
|
|||
for rec in self.browse(cr, uid, ids, context):
|
||||
result[rec.id] = rec.pricelist_id and (rec.pricelist_id.currency_id.id,rec.pricelist_id.currency_id.code) or result[rec.id]
|
||||
return result
|
||||
|
||||
|
||||
_inherit = "account.analytic.account"
|
||||
_columns = {
|
||||
'currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency', store=True),
|
||||
|
@ -97,11 +97,11 @@ class account_analytic_line(osv.osv):
|
|||
select = ids
|
||||
if isinstance(select, (int, long)):
|
||||
select = [ids]
|
||||
if ( not vals.has_key('invoice_id')) or vals['invoice_id' ] == False:
|
||||
for line in self.browse(cr, uid, select):
|
||||
if line.invoice_id:
|
||||
raise osv.except_osv(_('Error !'),
|
||||
_('You can not modify an invoiced analytic line!'))
|
||||
if ( not vals.has_key('invoice_id')) or vals['invoice_id' ] == False:
|
||||
for line in self.browse(cr, uid, select):
|
||||
if line.invoice_id:
|
||||
raise osv.except_osv(_('Error !'),
|
||||
_('You can not modify an invoiced analytic line!'))
|
||||
return True
|
||||
|
||||
def copy(self, cursor, user, obj_id, default=None, context=None):
|
||||
|
|
|
@ -1321,13 +1321,21 @@ class stock_move(osv.osv):
|
|||
ref = move.picking_id and move.picking_id.name or False
|
||||
product_uom_obj = self.pool.get('product.uom')
|
||||
default_uom = move.product_id.uom_id.id
|
||||
date = time.strftime('%Y-%m-%d')
|
||||
q = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom)
|
||||
if move.product_id.cost_method == 'average' and move.price_unit:
|
||||
amount = q * move.price_unit
|
||||
# Base computation on valuation pricelist
|
||||
else:
|
||||
amount = q * move.product_id.standard_price
|
||||
|
||||
date = time.strftime('%Y-%m-%d')
|
||||
company_id=move.company_id.id
|
||||
pricelist_id = self.pool.get('res.company').browse(cr,uid,company_id).property_valuation_pricelist.id
|
||||
amount_unit = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist_id],
|
||||
move.product_id.id, q or 1.0, None, {
|
||||
'date': date,
|
||||
})[pricelist_id]
|
||||
amount=amount_unit * q or 1.0
|
||||
# amount = q * move.product_id.standard_price
|
||||
|
||||
partner_id = False
|
||||
if move.picking_id:
|
||||
partner_id = move.picking_id.address_id and (move.picking_id.address_id.partner_id and move.picking_id.address_id.partner_id.id or False) or False
|
||||
|
|
Loading…
Reference in New Issue