diff --git a/oca_dependencies.txt b/oca_dependencies.txt new file mode 100644 index 0000000..5cd2498 --- /dev/null +++ b/oca_dependencies.txt @@ -0,0 +1,2 @@ +server-ux +reporting-engine diff --git a/stock_card_report/README.rst b/stock_card_report/README.rst new file mode 100644 index 0000000..243d96b --- /dev/null +++ b/stock_card_report/README.rst @@ -0,0 +1,82 @@ +================= +Stock Card Report +================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--reporting-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-reporting/tree/12.0/stock_card_report + :alt: OCA/stock-logistics-reporting +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-reporting-12-0/stock-logistics-reporting-12-0-stock_card_report + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/151/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Stock Card Report is the report that display movement (in/out) of a product in a specified location and date range. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +#. Go to Inventory > Reporting > Stock Card. +#. Select Start date, End date, Products, Location. +#. Choose View or Export PDF or Export XLSX or Cancel. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Ecosoft + +Contributors +~~~~~~~~~~~~ + +* Pimolnat Suntian + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/stock-logistics-reporting `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_card_report/__init__.py b/stock_card_report/__init__.py new file mode 100644 index 0000000..2873ef6 --- /dev/null +++ b/stock_card_report/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import wizard +from . import reports diff --git a/stock_card_report/__manifest__.py b/stock_card_report/__manifest__.py new file mode 100644 index 0000000..f56a1b9 --- /dev/null +++ b/stock_card_report/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Card Report", + "summary": "Add stock card report on Inventory Reporting.", + "version": "13.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", "date_range", "report_xlsx_helper"], + "data": [ + "data/paper_format.xml", + "data/report_data.xml", + "reports/stock_card_report.xml", + "wizard/stock_card_report_wizard_view.xml", + ], + "installable": True, +} diff --git a/stock_card_report/data/paper_format.xml b/stock_card_report/data/paper_format.xml new file mode 100644 index 0000000..163c384 --- /dev/null +++ b/stock_card_report/data/paper_format.xml @@ -0,0 +1,19 @@ + + + + Stock Card A4 + + A4 + 0 + 0 + Portrait + 28 + 28 + 7 + 7 + + 24 + 90 + + + diff --git a/stock_card_report/data/report_data.xml b/stock_card_report/data/report_data.xml new file mode 100644 index 0000000..f630564 --- /dev/null +++ b/stock_card_report/data/report_data.xml @@ -0,0 +1,26 @@ + + + + Stock Card Report + stock_card_report_backend + + + + + + + + diff --git a/stock_card_report/i18n/stock_card_report.pot b/stock_card_report/i18n/stock_card_report.pot new file mode 100644 index 0000000..ce2cb66 --- /dev/null +++ b/stock_card_report/i18n/stock_card_report.pot @@ -0,0 +1,267 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_card_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_buttons +msgid "Export" +msgstr "" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_buttons +msgid "Print" +msgstr "" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_stock_card_lines_header +msgid "Balance" +msgstr "" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.stock_card_report_wizard_form +msgid "Cancel" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report__create_uid +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard__create_uid +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__create_uid +msgid "Created by" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report__create_date +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard__create_date +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__create_date +msgid "Created on" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__date +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_stock_card_lines_header +msgid "Date" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report__date_from +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_stock_card_report_filters +msgid "Date From" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report__date_to +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_stock_card_report_filters +msgid "Date To" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report__display_name +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report_report_stock_card_report_xlsx__display_name +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard__display_name +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard__date_to +msgid "End Date" +msgstr "" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.stock_card_report_wizard_form +msgid "Export PDF" +msgstr "" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.stock_card_report_wizard_form +msgid "Export XLSX" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report__id +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report_report_stock_card_report_xlsx__id +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard__id +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__id +msgid "ID" +msgstr "" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_stock_card_report_base +msgid "Initial" +msgstr "" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_stock_card_lines_header +msgid "Input" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__is_initial +msgid "Is Initial" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report____last_update +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report_report_stock_card_report_xlsx____last_update +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard____last_update +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report__write_uid +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard__write_uid +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report__write_date +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard__write_date +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__write_date +msgid "Last Updated on" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report__location_id +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard__location_id +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__location_id +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_stock_card_report_filters +msgid "Location" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__location_dest_id +msgid "Location Dest" +msgstr "" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_stock_card_lines_header +msgid "Output" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard__date_range_id +msgid "Period" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report__product_ids +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__product_id +msgid "Product" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__product_in +msgid "Product In" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__product_out +msgid "Product Out" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__product_qty +msgid "Product Qty" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__product_uom +msgid "Product Uom" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__product_uom_qty +msgid "Product Uom Qty" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard__product_ids +msgid "Products" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_view__reference +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_stock_card_lines_header +msgid "Reference" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_report_stock_card_report__results +msgid "Results" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,field_description:stock_card_report.field_stock_card_report_wizard__date_from +msgid "Start Date" +msgstr "" + +#. module: stock_card_report +#: model:ir.actions.act_window,name:stock_card_report.stock_card_report_action +#: model:ir.ui.menu,name:stock_card_report.stock_card_report_menu +msgid "Stock Card" +msgstr "" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.report_stock_card_report_base +msgid "Stock Card -" +msgstr "" + +#. module: stock_card_report +#: model:ir.actions.report,name:stock_card_report.action_stock_card_report_pdf +msgid "Stock Card PDF" +msgstr "" + +#. module: stock_card_report +#: model:ir.actions.client,name:stock_card_report.action_report_stock_card_report_html +#: model:ir.model,name:stock_card_report.model_report_stock_card_report +msgid "Stock Card Report" +msgstr "" + +#. module: stock_card_report +#: model:ir.model,name:stock_card_report.model_stock_card_report_wizard +msgid "Stock Card Report Wizard" +msgstr "" + +#. module: stock_card_report +#: model:ir.model,name:stock_card_report.model_stock_card_view +msgid "Stock Card View" +msgstr "" + +#. module: stock_card_report +#: model:ir.actions.report,name:stock_card_report.action_stock_card_report_xlsx +msgid "Stock Card XLSX" +msgstr "" + +#. module: stock_card_report +#: model:ir.model.fields,help:stock_card_report.field_report_stock_card_report__results +msgid "Use compute fields, so there is nothing store in database" +msgstr "" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.stock_card_report_wizard_form +msgid "View" +msgstr "" + +#. module: stock_card_report +#: model_terms:ir.ui.view,arch_db:stock_card_report.stock_card_report_wizard_form +msgid "or" +msgstr "" + +#. module: stock_card_report +#: model:ir.model,name:stock_card_report.model_report_stock_card_report_report_stock_card_report_xlsx +msgid "report.stock_card_report.report_stock_card_report_xlsx" +msgstr "" + diff --git a/stock_card_report/readme/CONTRIBUTORS.rst b/stock_card_report/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..0ef1f84 --- /dev/null +++ b/stock_card_report/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Pimolnat Suntian diff --git a/stock_card_report/readme/DESCRIPTION.rst b/stock_card_report/readme/DESCRIPTION.rst new file mode 100644 index 0000000..1d5fcb2 --- /dev/null +++ b/stock_card_report/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Stock Card Report is the report that display movement (in/out) of a product in a specified location and date range. diff --git a/stock_card_report/readme/USAGE.rst b/stock_card_report/readme/USAGE.rst new file mode 100644 index 0000000..cce04a4 --- /dev/null +++ b/stock_card_report/readme/USAGE.rst @@ -0,0 +1,5 @@ +To use this module, you need to: + +#. Go to Inventory > Reporting > Stock Card. +#. Select Start date, End date, Products, Location. +#. Choose View or Export PDF or Export XLSX or Cancel. diff --git a/stock_card_report/reports/__init__.py b/stock_card_report/reports/__init__.py new file mode 100644 index 0000000..0bf3b7a --- /dev/null +++ b/stock_card_report/reports/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import stock_card_report +from . import stock_card_report_xlsx diff --git a/stock_card_report/reports/stock_card_report.py b/stock_card_report/reports/stock_card_report.py new file mode 100644 index 0000000..425715a --- /dev/null +++ b/stock_card_report/reports/stock_card_report.py @@ -0,0 +1,106 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class StockCardView(models.TransientModel): + _name = "stock.card.view" + _description = "Stock Card View" + _order = "date" + + date = fields.Datetime() + product_id = fields.Many2one(comodel_name="product.product") + product_qty = fields.Float() + product_uom_qty = fields.Float() + product_uom = fields.Many2one(comodel_name="uom.uom") + reference = fields.Char() + location_id = fields.Many2one(comodel_name="stock.location") + location_dest_id = fields.Many2one(comodel_name="stock.location") + is_initial = fields.Boolean() + product_in = fields.Float() + product_out = fields.Float() + + +class StockCardReport(models.TransientModel): + _name = "report.stock.card.report" + _description = "Stock Card Report" + + # Filters fields, used for data computation + date_from = fields.Date() + date_to = fields.Date() + product_ids = fields.Many2many(comodel_name="product.product") + location_id = fields.Many2one(comodel_name="stock.location") + + # Data fields, used to browse report data + results = fields.Many2many( + comodel_name="stock.card.view", + compute="_compute_results", + help="Use compute fields, so there is nothing store in database", + ) + + def _compute_results(self): + self.ensure_one() + date_from = self.date_from or "0001-01-01" + self.date_to = self.date_to or fields.Date.context_today(self) + locations = self.env["stock.location"].search( + [("id", "child_of", [self.location_id.id])] + ) + self._cr.execute( + """ + SELECT move.date, move.product_id, move.product_qty, + move.product_uom_qty, move.product_uom, move.reference, + move.location_id, move.location_dest_id, + case when move.location_dest_id in %s + then move.product_qty end as product_in, + case when move.location_id in %s + then move.product_qty end as product_out, + case when move.date < %s then True else False end as is_initial + FROM stock_move move + WHERE (move.location_id in %s or move.location_dest_id in %s) + and move.state = 'done' and move.product_id in %s + and CAST(move.date AS date) <= %s + ORDER BY move.date, move.reference + """, + ( + tuple(locations.ids), + tuple(locations.ids), + date_from, + tuple(locations.ids), + tuple(locations.ids), + tuple(self.product_ids.ids), + self.date_to, + ), + ) + stock_card_results = self._cr.dictfetchall() + ReportLine = self.env["stock.card.view"] + self.results = [ReportLine.new(line).id for line in stock_card_results] + + def _get_initial(self, product_line): + product_input_qty = sum(product_line.mapped("product_in")) + product_output_qty = sum(product_line.mapped("product_out")) + return product_input_qty - product_output_qty + + def print_report(self, report_type="qweb"): + self.ensure_one() + action = ( + report_type == "xlsx" + and self.env.ref("stock_card_report.action_stock_card_report_xlsx") + or self.env.ref("stock_card_report.action_stock_card_report_pdf") + ) + return action.report_action(self, config=False) + + def _get_html(self): + result = {} + rcontext = {} + report = self.browse(self._context.get("active_id")) + if report: + rcontext["o"] = report + result["html"] = self.env.ref( + "stock_card_report.report_stock_card_report_html" + ).render(rcontext) + return result + + @api.model + def get_html(self, given_context=None): + return self.with_context(given_context)._get_html() diff --git a/stock_card_report/reports/stock_card_report.xml b/stock_card_report/reports/stock_card_report.xml new file mode 100644 index 0000000..f993f2d --- /dev/null +++ b/stock_card_report/reports/stock_card_report.xml @@ -0,0 +1,144 @@ + + +