From 95b4fd1a259bb1a76db7c6c7325dcfe88ddbc286 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Sat, 11 May 2019 10:21:24 +0000 Subject: [PATCH] [REF] stock_account: stock location to its own file No changes on the code. task-1875873 --- addons/stock_account/models/__init__.py | 1 + addons/stock_account/models/stock.py | 28 ---------------- addons/stock_account/models/stock_location.py | 33 +++++++++++++++++++ 3 files changed, 34 insertions(+), 28 deletions(-) create mode 100644 addons/stock_account/models/stock_location.py diff --git a/addons/stock_account/models/__init__.py b/addons/stock_account/models/__init__.py index ee0668460d2..b5f22d496ae 100644 --- a/addons/stock_account/models/__init__.py +++ b/addons/stock_account/models/__init__.py @@ -8,4 +8,5 @@ from . import account_reconciliation_widget from . import product from . import stock from . import stock_inventory +from . import stock_location from . import res_config_settings diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index c0ca61000fd..1dafcf630ab 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -11,34 +11,6 @@ import logging _logger = logging.getLogger(__name__) -class StockLocation(models.Model): - _inherit = "stock.location" - - valuation_in_account_id = fields.Many2one( - 'account.account', 'Stock Valuation Account (Incoming)', - domain=[('internal_type', '=', 'other'), ('deprecated', '=', False)], - help="Used for real-time inventory valuation. When set on a virtual location (non internal type), " - "this account will be used to hold the value of products being moved from an internal location " - "into this location, instead of the generic Stock Output Account set on the product. " - "This has no effect for internal locations.") - valuation_out_account_id = fields.Many2one( - 'account.account', 'Stock Valuation Account (Outgoing)', - domain=[('internal_type', '=', 'other'), ('deprecated', '=', False)], - help="Used for real-time inventory valuation. When set on a virtual location (non internal type), " - "this account will be used to hold the value of products being moved out of this location " - "and into an internal location, instead of the generic Stock Output Account set on the product. " - "This has no effect for internal locations.") - - def _should_be_valued(self): - """ This method returns a boolean reflecting whether the products stored in `self` should - be considered when valuating the stock of a company. - """ - self.ensure_one() - if self.usage == 'internal' or (self.usage == 'transit' and self.company_id): - return True - return False - - class StockMoveLine(models.Model): _inherit = 'stock.move.line' diff --git a/addons/stock_account/models/stock_location.py b/addons/stock_account/models/stock_location.py new file mode 100644 index 00000000000..731e31b3f4d --- /dev/null +++ b/addons/stock_account/models/stock_location.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models + + +class StockLocation(models.Model): + _inherit = "stock.location" + + valuation_in_account_id = fields.Many2one( + 'account.account', 'Stock Valuation Account (Incoming)', + domain=[('internal_type', '=', 'other'), ('deprecated', '=', False)], + help="Used for real-time inventory valuation. When set on a virtual location (non internal type), " + "this account will be used to hold the value of products being moved from an internal location " + "into this location, instead of the generic Stock Output Account set on the product. " + "This has no effect for internal locations.") + valuation_out_account_id = fields.Many2one( + 'account.account', 'Stock Valuation Account (Outgoing)', + domain=[('internal_type', '=', 'other'), ('deprecated', '=', False)], + help="Used for real-time inventory valuation. When set on a virtual location (non internal type), " + "this account will be used to hold the value of products being moved out of this location " + "and into an internal location, instead of the generic Stock Output Account set on the product. " + "This has no effect for internal locations.") + + def _should_be_valued(self): + """ This method returns a boolean reflecting whether the products stored in `self` should + be considered when valuating the stock of a company. + """ + self.ensure_one() + if self.usage == 'internal' or (self.usage == 'transit' and self.company_id): + return True + return False +