diff --git a/stock_valuation_location/__init__.py b/stock_valuation_location/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/stock_valuation_location/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_valuation_location/__manifest__.py b/stock_valuation_location/__manifest__.py new file mode 100644 index 0000000..30bb2e3 --- /dev/null +++ b/stock_valuation_location/__manifest__.py @@ -0,0 +1,33 @@ +# +# Bemade Inc. +# +# Copyright (C) 2023-June Bemade Inc. (). +# Author: Marc Durepos (Contact : marc@bemade.org) +# +# This program is under the terms of the GNU Lesser General Public License, +# version 3. +# +# For full license details, see https://www.gnu.org/licenses/lgpl-3.0.en.html. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +{ + "name": "Stock Valuation Location", + "version": "17.0.1.0.0", + "summary": "Add Location Information to Stock Valuation", + "category": "Inventory/Accounting", + "author": "Bemade Inc.", + "website": "http://www.bemade.org", + "license": "LGPL-3", + "depends": ["stock_account"], + "data": ["views/stock_valuation_layer_views.xml"], + "assets": {}, + "installable": True, + "auto_install": False, +} diff --git a/stock_valuation_location/models/__init__.py b/stock_valuation_location/models/__init__.py new file mode 100644 index 0000000..f75b2df --- /dev/null +++ b/stock_valuation_location/models/__init__.py @@ -0,0 +1 @@ +from . import stock_valuation_layer diff --git a/stock_valuation_location/models/stock_valuation_layer.py b/stock_valuation_location/models/stock_valuation_layer.py new file mode 100644 index 0000000..e32630c --- /dev/null +++ b/stock_valuation_location/models/stock_valuation_layer.py @@ -0,0 +1,25 @@ +""" +Adds the location to stock valuation layer, much in the same way the base code adds +warehouse_id. +""" + +from odoo import models, fields, api + + +class StockValuationLayer(models.Model): + _inherit = "stock.valuation.layer" + + location_id = fields.Many2one( + comodel_name="stock.location", + string="Location", + compute="_compute_location_id", + store=True, + compute_sudo=True, + ) + + def _compute_location_id(self): + for svl in self: + if svl.stock_move_id.location_id.usage == "internal": + svl.location_id = svl.stock_move_id.location_id + else: + svl.location_id = svl.stock_move_id.location_dest_id diff --git a/stock_valuation_location/views/stock_valuation_layer_views.xml b/stock_valuation_location/views/stock_valuation_layer_views.xml new file mode 100644 index 0000000..b7ef8f5 --- /dev/null +++ b/stock_valuation_location/views/stock_valuation_layer_views.xml @@ -0,0 +1,29 @@ + + + + stock.valuation.layer.tree.inherit + + stock.valuation.layer + + + + + + + + inventory.aging.tree.inherit + stock.valuation.layer + + + + + + + +