[REM] stock_account: clean import/condition/dead-code

For the stock_account module:
- Remove unused import
- Remove deadcode, unused _anglo_saxon_sale_move_lines method
and useless 'continue' keyword
- Fix duplicate name test (test_average_perpetual_8 defines twice)
- Make comments flake8 compliant

task-2123752
This commit is contained in:
Rémy Voet (ryv)
2020-03-04 15:44:53 +00:00
parent bf3f67be28
commit c4d71d7d24
4 changed files with 8 additions and 67 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from odoo import fields, models, api, _
from odoo import fields, models
class AccountMove(models.Model):
+3 -58
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, tools, _
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.tools import float_is_zero
from odoo.exceptions import ValidationError
@@ -38,7 +38,7 @@ class ProductTemplate(models.Model):
# Empty out the stock with the current cost method.
description = _("Due to a change of product category (from %s to %s), the costing method\
has changed for product template %s: from %s to %s.") %\
(product_template.categ_id.display_name, new_product_category.display_name, \
(product_template.categ_id.display_name, new_product_category.display_name,
product_template.display_name, product_template.cost_method, new_product_category.property_cost_method)
out_svl_vals_list, products_orig_quantity_svl, products = Product\
._svl_empty_stock(description, product_template=product_template)
@@ -164,7 +164,7 @@ class ProductProduct(models.Model):
# Quantity is negative for out valuation layers.
quantity = -1 * quantity
vals = {
'product_id' : self.id,
'product_id': self.id,
'value': quantity * self.standard_price,
'unit_cost': self.standard_price,
'quantity': quantity,
@@ -533,61 +533,6 @@ class ProductProduct(models.Model):
# -------------------------------------------------------------------------
# Anglo saxon helpers
# -------------------------------------------------------------------------
@api.model
def _anglo_saxon_sale_move_lines(self, name, product, uom, qty, price_unit, currency=False, amount_currency=False, fiscal_position=False, account_analytic=False, analytic_tags=False):
"""Prepare dicts describing new journal COGS journal items for a product sale.
Returns a dict that should be passed to `_convert_prepared_anglosaxon_line()` to
obtain the creation value for the new journal items.
:param Model product: a product.product record of the product being sold
:param Model uom: a product.uom record of the UoM of the sale line
:param Integer qty: quantity of the product being sold
:param Integer price_unit: unit price of the product being sold
:param Model currency: a res.currency record from the order of the product being sold
:param Interger amount_currency: unit price in the currency from the order of the product being sold
:param Model fiscal_position: a account.fiscal.position record from the order of the product being sold
:param Model account_analytic: a account.account.analytic record from the line of the product being sold
"""
if product.type == 'product' and product.valuation == 'real_time':
accounts = product.product_tmpl_id.get_product_accounts(fiscal_pos=fiscal_position)
# debit account dacc will be the output account
dacc = accounts['stock_output'].id
# credit account cacc will be the expense account
cacc = accounts['expense'].id
if dacc and cacc:
return [
{
'type': 'src',
'name': name[:64],
'price_unit': price_unit,
'quantity': qty,
'price': price_unit * qty,
'currency_id': currency and currency.id,
'amount_currency': amount_currency,
'account_id': dacc,
'product_id': product.id,
'uom_id': uom.id,
},
{
'type': 'src',
'name': name[:64],
'price_unit': price_unit,
'quantity': qty,
'price': -1 * price_unit * qty,
'currency_id': currency and currency.id,
'amount_currency': -1 * amount_currency,
'account_id': cacc,
'product_id': product.id,
'uom_id': uom.id,
'account_analytic_id': account_analytic and account_analytic.id,
'analytic_tag_ids': analytic_tags and analytic_tags.ids and [(6, 0, analytic_tags.ids)] or False,
},
]
return []
def _stock_account_get_anglo_saxon_price_unit(self, uom=False):
price = self.standard_price
if not self or not uom or self.uom_id.id == uom.id:
+3 -7
View File
@@ -5,7 +5,7 @@ from collections import defaultdict
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.tools import float_compare, float_round, float_is_zero
from odoo.tools import float_is_zero
import logging
_logger = logging.getLogger(__name__)
@@ -240,7 +240,6 @@ class StockMove(models.Model):
for valued_type in self._get_valued_types():
if getattr(move, '_is_%s' % valued_type)():
valued_moves[valued_type] |= move
continue
# AVCO application
valued_moves['in'].product_price_update_before_done()
@@ -252,7 +251,6 @@ class StockMove(models.Model):
for valued_type in self._get_valued_types():
if getattr(move, '_is_%s' % valued_type)():
valued_moves[valued_type] |= move
continue
stock_valuation_layers = self.env['stock.valuation.layer'].sudo()
# Create the valuation layers in batch by calling `moves._create_valued_type_svl`.
@@ -261,8 +259,6 @@ class StockMove(models.Model):
if todo_valued_moves:
todo_valued_moves._sanity_check_for_valuation()
stock_valuation_layers |= getattr(todo_valued_moves, '_create_%s_svl' % valued_type)()
continue
for svl in stock_valuation_layers:
if not svl.product_id.valuation == 'real_time':
@@ -509,10 +505,10 @@ class StockMove(models.Model):
self.with_company(self.company_id)._create_account_move_line(acc_dest, acc_valuation, journal_id, qty, description, svl_id, cost)
if self.company_id.anglo_saxon_accounting:
#eventually reconcile together the invoice and valuation accounting entries on the stock interim accounts
# Eventually reconcile together the invoice and valuation accounting entries on the stock interim accounts
self._get_related_invoices()._stock_account_anglo_saxon_reconcile_valuation(product=self.product_id)
def _get_related_invoices(self): # To be overridden in purchase and sale_stock
def _get_related_invoices(self): # To be overridden in purchase and sale_stock
""" This method is overrided in both purchase and sale_stock modules to adapt
to the way they mix stock moves with invoices.
"""
@@ -2433,7 +2433,7 @@ class TestStockValuation(SavepointCase):
self.assertAlmostEqual(self.product1.standard_price, 10.0)
def test_average_perpetual_8(self):
def test_average_perpetual_9(self):
""" When a product has an available quantity of -5, edit an incoming shipment and increase
the received quantity by 5 units.
"""