From d3c8dc2db40be0aa9cdc04ba60e1b9b6119e6810 Mon Sep 17 00:00:00 2001 From: Joel Grand-Guillaume Date: Thu, 17 Dec 2009 16:12:33 +0100 Subject: [PATCH] [IMP] Add computation of stock entries based on valuation priclist of company for accounting entries bzr revid: joel.grandguillaume@camptocamp.com-20091217151233-85fnrq17pt2o7w7n --- .../hr_timesheet_invoice/hr_timesheet_invoice.py | 12 ++++++------ addons/stock/stock.py | 14 +++++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 3236807c928..be0b8c4ccad 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -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): diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 8b5356a8573..01ed2c62fbe 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -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