From f24b198773ea1a7b06a4941c73a25cf9eff25ac9 Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Tue, 6 Oct 2015 09:29:13 +0200 Subject: [PATCH] [REF] purchase, sale_stock, stock_account: some refactoring --- addons/purchase/stock.py | 3 +-- addons/sale_stock/sale_stock.py | 4 ++-- addons/stock_account/stock_account.py | 8 +++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index 582956263ad..791672b1dfc 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from openerp import SUPERUSER_ID from openerp.osv import fields, osv from openerp.tools.translate import _ from openerp.exceptions import UserError @@ -40,7 +39,7 @@ class stock_move(osv.osv): class stock_warehouse(osv.osv): _inherit = 'stock.warehouse' _columns = { - 'buy_to_resupply': fields.boolean('Purchase to resupply this warehouse', + 'buy_to_resupply': fields.boolean('Purchase to resupply this warehouse', help="When products are bought, they can be delivered to this warehouse"), 'buy_pull_id': fields.many2one('procurement.rule', 'Buy rule'), } diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 3657a2152b8..6a24bae22f5 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -258,8 +258,8 @@ class StockPicking(models.Model): class AccountInvoiceLine(models.Model): _inherit = "account.invoice.line" - def _get_price_unit(self): - price_unit = super(AccountInvoiceLine,self)._get_price_unit() + def _get_anglo_saxon_price_unit(self): + price_unit = super(AccountInvoiceLine,self)._get_anglo_saxon_price_unit() # in case of anglo saxon with a product configured as invoiced based on delivery, with perpetual # valuation and real price costing method, we must find the real price for the cost of good sold uom_obj = self.env['product.uom'] diff --git a/addons/stock_account/stock_account.py b/addons/stock_account/stock_account.py index 6e22860e34a..b31199ff4e9 100644 --- a/addons/stock_account/stock_account.py +++ b/addons/stock_account/stock_account.py @@ -27,7 +27,7 @@ class stock_inventory(osv.osv): class account_invoice_line(osv.osv): _inherit = "account.invoice.line" - def _get_price_unit(self): + def _get_anglo_saxon_price_unit(self): self.ensure_one() return self.product_id.standard_price @@ -76,7 +76,7 @@ class account_invoice(osv.osv): # credit account cacc will be the expense account cacc = accounts['expense'].id if dacc and cacc: - price_unit = i_line._get_price_unit() + price_unit = i_line._get_anglo_saxon_price_unit() return [ { 'type':'src', @@ -88,7 +88,6 @@ class account_invoice(osv.osv): 'product_id':i_line.product_id.id, 'uom_id':i_line.uom_id.id, 'account_analytic_id': False, - 'taxes':i_line.invoice_line_tax_ids, }, { @@ -101,7 +100,6 @@ class account_invoice(osv.osv): 'product_id':i_line.product_id.id, 'uom_id':i_line.uom_id.id, 'account_analytic_id': False, - 'taxes':i_line.invoice_line_tax_ids, }, ] return [] @@ -363,7 +361,7 @@ class stock_move(osv.osv): if any([q.qty <= 0 for q in move.quant_ids]): #if there is a negative quant, the standard price shouldn't be updated return - #Note: here we can't store a quant.cost directly as we may have moved out 2 units (1 unit to 5€ and 1 unit to 7€) and in case of a product return of 1 unit, we can't know which of the 2 costs has to be used (5€ or 7€?). So at that time, thanks to the average valuation price we are storing we will svaluate it at 6€ + #Note: here we can't store a quant.cost directly as we may have moved out 2 units (1 unit to 5€ and 1 unit to 7€) and in case of a product return of 1 unit, we can't know which of the 2 costs has to be used (5€ or 7€?). So at that time, thanks to the average valuation price we are storing we will valuate it at 6€ average_valuation_price = 0.0 for q in move.quant_ids: average_valuation_price += q.qty * q.cost