diff --git a/setup/stock_inventory_valuation_report/odoo/addons/stock_inventory_valuation_report b/setup/stock_inventory_valuation_report/odoo/addons/stock_inventory_valuation_report new file mode 120000 index 0000000..663d8c8 --- /dev/null +++ b/setup/stock_inventory_valuation_report/odoo/addons/stock_inventory_valuation_report @@ -0,0 +1 @@ +../../../../stock_inventory_valuation_report \ No newline at end of file diff --git a/setup/stock_inventory_valuation_report/setup.py b/setup/stock_inventory_valuation_report/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/stock_inventory_valuation_report/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_inventory_valuation_report/__manifest__.py b/stock_inventory_valuation_report/__manifest__.py index b43830c..22e4b8c 100644 --- a/stock_inventory_valuation_report/__manifest__.py +++ b/stock_inventory_valuation_report/__manifest__.py @@ -2,22 +2,22 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Stock Inventory Valuation Report', - 'summary': 'Add report button on Inventory Valuation.', - 'version': '12.0.1.1.2', - 'category': 'Warehouse', - 'website': 'https://github.com/OCA/stock-logistics-reporting', - 'author': 'Ecosoft,Odoo Community Association (OCA)', - 'license': 'AGPL-3', - 'depends': [ - 'stock_account', - 'report_xlsx_helper', + "name": "Stock Inventory Valuation Report", + "summary": "Add report button on Inventory Valuation.", + "version": "14.0.1.0.0", + "category": "Warehouse", + "website": "https://github.com/OCA/stock-logistics-reporting", + "author": "Ecosoft,Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + "stock_account", + "report_xlsx_helper", ], - 'data': [ - 'data/paper_format.xml', - 'data/report_data.xml', - 'reports/stock_inventory_valuation_report.xml', - 'wizard/stock_quantity_history_view.xml', + "data": [ + "data/paper_format.xml", + "data/report_data.xml", + "reports/stock_inventory_valuation_report.xml", + "wizard/stock_quantity_history_view.xml", ], - 'installable': True, + "installable": True, } diff --git a/stock_inventory_valuation_report/data/paper_format.xml b/stock_inventory_valuation_report/data/paper_format.xml index 8b793eb..68f416e 100644 --- a/stock_inventory_valuation_report/data/paper_format.xml +++ b/stock_inventory_valuation_report/data/paper_format.xml @@ -2,7 +2,7 @@ Inventory Valuation Report A4 - + A4 0 0 @@ -11,7 +11,7 @@ 28 7 7 - + 24 90 diff --git a/stock_inventory_valuation_report/data/report_data.xml b/stock_inventory_valuation_report/data/report_data.xml index 5300ff3..7abb53e 100644 --- a/stock_inventory_valuation_report/data/report_data.xml +++ b/stock_inventory_valuation_report/data/report_data.xml @@ -3,24 +3,31 @@ Inventory Valuation Report stock_inventory_valuation_report_backend - + - + - + diff --git a/stock_inventory_valuation_report/reports/stock_inventory_valuation_report.py b/stock_inventory_valuation_report/reports/stock_inventory_valuation_report.py index 315a5aa..f0c2b47 100644 --- a/stock_inventory_valuation_report/reports/stock_inventory_valuation_report.py +++ b/stock_inventory_valuation_report/reports/stock_inventory_valuation_report.py @@ -5,21 +5,21 @@ from odoo import api, fields, models class StockInventoryValuationView(models.TransientModel): - _name = 'stock.inventory.valuation.view' - _description = 'Stock Inventory Valuation View' + _name = "stock.inventory.valuation.view" + _description = "Stock Inventory Valuation View" name = fields.Char() reference = fields.Char() barcode = fields.Char() qty_at_date = fields.Float() uom_id = fields.Many2one( - comodel_name='uom.uom', + comodel_name="uom.uom", ) currency_id = fields.Many2one( - comodel_name='res.currency', + comodel_name="res.currency", ) cost_currency_id = fields.Many2one( - comodel_name='res.currency', + comodel_name="res.currency", ) standard_price = fields.Float() stock_value = fields.Float() @@ -27,21 +27,21 @@ class StockInventoryValuationView(models.TransientModel): class StockInventoryValuationReport(models.TransientModel): - _name = 'report.stock.inventory.valuation.report' - _description = 'Stock Inventory Valuation Report' + _name = "report.stock.inventory.valuation.report" + _description = "Stock Inventory Valuation Report" # Filters fields, used for data computation company_id = fields.Many2one( - comodel_name='res.company', + comodel_name="res.company", ) compute_at_date = fields.Integer() date = fields.Datetime() # Data fields, used to browse report data results = fields.Many2many( - comodel_name='stock.inventory.valuation.view', - compute='_compute_results', - help='Use compute fields, so there is nothing store in database', + comodel_name="stock.inventory.valuation.view", + compute="_compute_results", + help="Use compute fields, so there is nothing store in database", ) @api.multi @@ -49,52 +49,61 @@ class StockInventoryValuationReport(models.TransientModel): self.ensure_one() if not self.compute_at_date: self.date = fields.Datetime.now() - products = self.env['product.product'].\ - with_context(dict(to_date=self.date, company_owned=True, - create=False, edit=False)).\ - search([('type', '=', 'product'), ('qty_available', '!=', 0)]) - ReportLine = self.env['stock.inventory.valuation.view'] + products = ( + self.env["product.product"] + .with_context( + dict(to_date=self.date, company_owned=True, create=False, edit=False) + ) + .search([("type", "=", "product"), ("qty_available", "!=", 0)]) + ) + ReportLine = self.env["stock.inventory.valuation.view"] for product in products: standard_price = product.standard_price if self.date: standard_price = product.get_history_price( - self.env.user.company_id.id, - date=self.date) + self.env.user.company_id.id, date=self.date + ) line = { - 'name': product.name, - 'reference': product.default_code, - 'barcode': product.barcode, - 'qty_at_date': product.qty_at_date, - 'uom_id': product.uom_id, - 'currency_id': product.currency_id, - 'cost_currency_id': product.cost_currency_id, - 'standard_price': standard_price, - 'stock_value': product.qty_at_date * standard_price, - 'cost_method': product.cost_method, + "name": product.name, + "reference": product.default_code, + "barcode": product.barcode, + "qty_at_date": product.qty_at_date, + "uom_id": product.uom_id, + "currency_id": product.currency_id, + "cost_currency_id": product.cost_currency_id, + "standard_price": standard_price, + "stock_value": product.qty_at_date * standard_price, + "cost_method": product.cost_method, } if product.qty_at_date != 0: self.results += ReportLine.new(line) @api.multi - def print_report(self, report_type='qweb'): + def print_report(self, report_type="qweb"): self.ensure_one() - action = report_type == 'xlsx' and self.env.ref( - 'stock_inventory_valuation_report.' - 'action_stock_inventory_valuation_report_xlsx') or \ - self.env.ref('stock_inventory_valuation_report.' - 'action_stock_inventory_valuation_report_pdf') + action = ( + report_type == "xlsx" + and self.env.ref( + "stock_inventory_valuation_report." + "action_stock_inventory_valuation_report_xlsx" + ) + or self.env.ref( + "stock_inventory_valuation_report." + "action_stock_inventory_valuation_report_pdf" + ) + ) return action.report_action(self, config=False) def _get_html(self): result = {} rcontext = {} - report = self.browse(self._context.get('active_id')) + report = self.browse(self._context.get("active_id")) if report: - rcontext['o'] = report - result['html'] = self.env.ref( - 'stock_inventory_valuation_report.' - 'report_stock_inventory_valuation_report_html').render( - rcontext) + rcontext["o"] = report + result["html"] = self.env.ref( + "stock_inventory_valuation_report." + "report_stock_inventory_valuation_report_html" + ).render(rcontext) return result @api.model diff --git a/stock_inventory_valuation_report/reports/stock_inventory_valuation_report.xml b/stock_inventory_valuation_report/reports/stock_inventory_valuation_report.xml index c927aba..6b46cd4 100644 --- a/stock_inventory_valuation_report/reports/stock_inventory_valuation_report.xml +++ b/stock_inventory_valuation_report/reports/stock_inventory_valuation_report.xml @@ -1,24 +1,39 @@ -