diff --git a/stock_inventory_cost_info_sum/__init__.py b/stock_inventory_cost_info_sum/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/stock_inventory_cost_info_sum/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_inventory_cost_info_sum/__manifest__.py b/stock_inventory_cost_info_sum/__manifest__.py new file mode 100644 index 0000000..152ce51 --- /dev/null +++ b/stock_inventory_cost_info_sum/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2022 Criptomart +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Stock Inventory Cost Info Sum', + 'description': """ + Extends the OCA module stock_inventory_cost_info to store in the Inventory model the sum of the cost information of the inventory lines. This allows exporting and filtering by this field in the inventory adjustments tree view without having to export each inventory line.""", + 'version': '12.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'Criptomart', + 'website': 'https://criptomart.net', + 'depends': [ + 'stock_inventory_cost_info', + ], + 'data': [ + 'views/stock_inventory.xml', + 'views/actions.xml', + ], + 'demo': [ + ], +} diff --git a/stock_inventory_cost_info_sum/models/__init__.py b/stock_inventory_cost_info_sum/models/__init__.py new file mode 100644 index 0000000..3553681 --- /dev/null +++ b/stock_inventory_cost_info_sum/models/__init__.py @@ -0,0 +1 @@ +from . import stock_inventory diff --git a/stock_inventory_cost_info_sum/models/stock_inventory.py b/stock_inventory_cost_info_sum/models/stock_inventory.py new file mode 100644 index 0000000..109bc01 --- /dev/null +++ b/stock_inventory_cost_info_sum/models/stock_inventory.py @@ -0,0 +1,26 @@ +# Copyright 2022 Criptomart +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models, _ + + +class StockInventory(models.Model): + _inherit = 'stock.inventory' + + currency_id = fields.Many2one( + string="Currency", + related="company_id.currency_id", + readonly=True, + ) + adjustment_cost_sum = fields.Monetary( + string="Adjustment cost", + compute="_compute_adjustment_cost_sum", + store=True, + ) + + @api.depends("line_ids") + def _compute_adjustment_cost_sum(self): + for record in self: + record.adjustment_cost_sum = 0 + for line in record.line_ids: + record.adjustment_cost_sum += line.adjustment_cost \ No newline at end of file diff --git a/stock_inventory_cost_info_sum/views/actions.xml b/stock_inventory_cost_info_sum/views/actions.xml new file mode 100644 index 0000000..6e2ee1e --- /dev/null +++ b/stock_inventory_cost_info_sum/views/actions.xml @@ -0,0 +1,14 @@ + + + + + Recalculate Adjustment Cost + + + code + + records._compute_adjustment_cost_sum() + + + + \ No newline at end of file diff --git a/stock_inventory_cost_info_sum/views/stock_inventory.xml b/stock_inventory_cost_info_sum/views/stock_inventory.xml new file mode 100644 index 0000000..141a97b --- /dev/null +++ b/stock_inventory_cost_info_sum/views/stock_inventory.xml @@ -0,0 +1,31 @@ + + + + + + + stock.inventory.form (in stock_inventory_cost_info_sum) + stock.inventory + + + + + + + + + + + stock.inventory.tree (in stock_inventory_cost_info_sum) + stock.inventory + + + + + + + + + +