diff --git a/stock_history_ods/__init__.py b/stock_history_ods/__init__.py new file mode 100644 index 0000000..3b4c3ed --- /dev/null +++ b/stock_history_ods/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import wizard diff --git a/stock_history_ods/__manifest__.py b/stock_history_ods/__manifest__.py new file mode 100644 index 0000000..cc908a4 --- /dev/null +++ b/stock_history_ods/__manifest__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +{ + 'name': 'Stock History ODS', + 'version': '10.0.1.0.0', + 'category': 'Tools', + 'license': 'AGPL-3', + 'summary': 'Adds a Py3o ODS report on Inventory at Date', + 'description': """ +Stock History ODS +================= + +This module will add a Py3o ODS report on Inventory at Date. + +This module has been written by Alexis de Lattre from Akretion . + """, + 'author': "Akretion", + 'website': 'http://www.akretion.com', + 'depends': ['stock_account', 'report_py3o'], + 'data': [ + 'report.xml', + 'wizard/wizard_valuation_history_view.xml', + ], + 'installable': True, +} diff --git a/stock_history_ods/inventory_history.ods b/stock_history_ods/inventory_history.ods new file mode 100644 index 0000000..207275d Binary files /dev/null and b/stock_history_ods/inventory_history.ods differ diff --git a/stock_history_ods/report.xml b/stock_history_ods/report.xml new file mode 100644 index 0000000..2cead52 --- /dev/null +++ b/stock_history_ods/report.xml @@ -0,0 +1,17 @@ + + + + + + Inventory at Date (ODS) + wizard.valuation.history + stock.history.ods + py3o + ods + stock_history_ods + inventory_history.ods + + + + + diff --git a/stock_history_ods/wizard/__init__.py b/stock_history_ods/wizard/__init__.py new file mode 100644 index 0000000..b406068 --- /dev/null +++ b/stock_history_ods/wizard/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import wizard_valuation_history diff --git a/stock_history_ods/wizard/wizard_valuation_history.py b/stock_history_ods/wizard/wizard_valuation_history.py new file mode 100644 index 0000000..03e67a5 --- /dev/null +++ b/stock_history_ods/wizard/wizard_valuation_history.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockValuationHistory(models.TransientModel): + _inherit = 'wizard.valuation.history' + + def report_py3o(self): + ppo = self.env['product.product'] + lines = self.env['stock.history'].with_context( + history_date=self.date).read_group( + [('date', '<=', self.date)], + ['product_id', 'location_id', 'move_id', 'company_id', + 'date', 'quantity', 'inventory_value'], + ['product_id', 'location_id']) + categ_id2name = {} + for categ in self.env['product.category'].search([]): + categ_id2name[categ.id] = categ.display_name + res = [] + for line in lines: + product_id = line['product_id'][0] + product = ppo.browse(product_id) + res.append({ + 'product_categ': categ_id2name[product.categ_id.id], + 'product_name': product.name, + 'product_code': product.default_code, + 'product_display_name': line['product_id'][1], + 'product_uom': product.uom_id.name, + 'quantity': line['quantity'], + 'inventory_value': line['inventory_value'], + }) + return res + + def print_table(self): + self.ensure_one() + action = self.env['report'].get_action(self, 'stock.history.ods') + return action diff --git a/stock_history_ods/wizard/wizard_valuation_history_view.xml b/stock_history_ods/wizard/wizard_valuation_history_view.xml new file mode 100644 index 0000000..d7fe698 --- /dev/null +++ b/stock_history_ods/wizard/wizard_valuation_history_view.xml @@ -0,0 +1,19 @@ + + + + + + + wizard.valuation.history + + + + + + +