Skip to content

Commit

Permalink
[stock_card_report_value] 14.0.1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mikevhe18 authored and andhit-r committed Jul 17, 2021
1 parent bb7eb4b commit 8daef07
Show file tree
Hide file tree
Showing 12 changed files with 358 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ repos:
language: fail
files: "\\.rej$"
- repo: https://github.com/oca/maintainer-tools
rev: 1b5c7ad
rev: f2d1be9daceb2cccc102ae2be44891ce4a0ed3a0
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
- id: oca-fix-manifest-website
args: ["https://github.com/OCA/ssi-mixin"]
args: ["https://simetri-sinergi.id"]
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
Expand Down
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ install:
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git
${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- git clone https://github.com/aeroo/aeroo_reports.git ${HOME}/aeroo_reports
- pip install unidecode
- pip install pycups==1.9.73
- pip install
git+https://github.com/aeroo/aeroolib.git@b591d23c98990fc358b02b3b78d46290eadb7277
- travis_install_nightly

script:
Expand Down
2 changes: 2 additions & 0 deletions oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
oca_stock_logistics_reporting https://github.com/OCA/stock-logistics-reporting.git 14.0
oca_server_ux https://github.com/OCA/server-ux.git 14.0
oca_report_engine https://github.com/OCA/reporting-engine.git 14.0
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# generated from manifests external_dependencies
qrcode
50 changes: 50 additions & 0 deletions stock_card_report_value/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

=======================
Stock Card Report Value
=======================


Installation
============

To install this module, you need to:

1. Clone the branch 14.0 of the repository https://github.com/open-synergy/opnsynid-stock-reporting
2. Add the path to this repository in your configuration (addons-path)
3. Update the module list (Must be on developer mode)
4. Go to menu *Apps -> Apps*
5. Search For *Stock Card Report Value*
6. Install the module

Known issues / Roadmap
======================


Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/open-synergy/opnsynid-stock-reporting/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Contributors
------------

* Michael Viriyananda <[email protected]>
* Andhitia Rama <[email protected]>

Maintainer
----------

.. image:: https://simetri-sinergi.id/logo.png
:alt: PT. Simetri Sinergi Indonesia
:target: https://simetri-sinergi.id.com

This module is maintained by the PT. Simetri Sinergi Indonesia.
7 changes: 7 additions & 0 deletions stock_card_report_value/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2021 OpenSynergy Indonesia
# Copyright 2021 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import (
reports,
)
21 changes: 21 additions & 0 deletions stock_card_report_value/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2021 OpenSynergy Indonesia
# Copyright 2021 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
# pylint: disable=locally-disabled, manifest-required-author
{
"name": "Stock Card Report Value",
"version": "14.0.1.0.0",
"category": "Stock Management",
"website": "https://simetri-sinergi.id",
"author": "PT. Simetri Sinergi Indonesia, OpenSynergy Indonesia",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"stock_card_report",
],
"data": [
"reports/stock_card_report.xml",
],
"qweb": [],
}
8 changes: 8 additions & 0 deletions stock_card_report_value/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2021 OpenSynergy Indonesia
# Copyright 2021 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import (
stock_card_report,
stock_card_report_xlsx,
)
57 changes: 57 additions & 0 deletions stock_card_report_value/reports/stock_card_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2021 OpenSynergy Indonesia
# Copyright 2021 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockCardView(models.TransientModel):
_inherit = "stock.card.view"

value = fields.Float(
string="Value",
)


class StockCardReport(models.TransientModel):
_inherit = "report.stock.card.report"

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,
move.picking_id,
b.value AS value
FROM stock_move move
JOIN stock_valuation_layer AS b ON move.id=b.stock_move_id
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]
31 changes: 31 additions & 0 deletions stock_card_report_value/reports/stock_card_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<odoo>
<template
id="report_stock_card_report_base"
inherit_id="stock_card_report.report_stock_card_report_base"
>
<xpath expr="//div[@class='act_as_row lines']/div[3]" position="after">
<div class="act_as_cell" />
</xpath>
</template>

<template
id="report_stock_card_lines_header"
inherit_id="stock_card_report.report_stock_card_lines_header"
>
<xpath expr="//div[1]/div[1]/div[2]" position="after">
<div class="act_as_cell">Value</div>
</xpath>
</template>

<template
id="report_stock_card_lines"
inherit_id="stock_card_report.report_stock_card_lines"
>
<xpath expr="//div[1]/div[2]" position="after">
<div class="act_as_cell right">
<t t-esc="'{0:,.3f}'.format(product_line.value)" />
</div>
</xpath>
</template>

</odoo>
180 changes: 180 additions & 0 deletions stock_card_report_value/reports/stock_card_report_xlsx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# Copyright 2021 OpenSynergy Indonesia
# Copyright 2021 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging

from odoo import models

from odoo.addons.report_xlsx_helper.report.report_xlsx_format import (
FORMATS,
XLS_HEADERS,
)

_logger = logging.getLogger(__name__)


class ReportStockCardReportXlsx(models.AbstractModel):
_inherit = "report.stock_card_report.report_stock_card_report_xlsx"

def _get_ws_params(self, wb, data, product):
filter_template = {
"1_date_from": {
"header": {"value": "Date from"},
"data": {
"value": self._render("date_from"),
"format": FORMATS["format_tcell_date_center"],
},
},
"2_date_to": {
"header": {"value": "Date to"},
"data": {
"value": self._render("date_to"),
"format": FORMATS["format_tcell_date_center"],
},
},
"3_location": {
"header": {"value": "Location"},
"data": {
"value": self._render("location"),
"format": FORMATS["format_tcell_center"],
},
},
}
initial_template = {
"1_ref": {
"data": {"value": "Initial", "format": FORMATS["format_tcell_center"]},
"colspan": 5,
},
"3_balance": {
"data": {
"value": self._render("balance"),
"format": FORMATS["format_tcell_amount_right"],
}
},
}
stock_card_template = {
"1_date": {
"header": {"value": "Date"},
"data": {
"value": self._render("date"),
"format": FORMATS["format_tcell_date_left"],
},
"width": 25,
},
"2_reference": {
"header": {"value": "Reference"},
"data": {
"value": self._render("reference"),
"format": FORMATS["format_tcell_left"],
},
"width": 25,
},
"3_value": {
"header": {"value": "Value"},
"data": {"value": self._render("value")},
"width": 25,
},
"4_input": {
"header": {"value": "In"},
"data": {"value": self._render("input")},
"width": 25,
},
"5_output": {
"header": {"value": "Out"},
"data": {"value": self._render("output")},
"width": 25,
},
"6_balance": {
"header": {"value": "Balance"},
"data": {"value": self._render("balance")},
"width": 25,
},
}

ws_params = {
"ws_name": product.name,
"generate_ws_method": "_stock_card_report",
"title": "Stock Card - {}".format(product.name),
"wanted_list_filter": [k for k in sorted(filter_template.keys())],
"col_specs_filter": filter_template,
"wanted_list_initial": [k for k in sorted(initial_template.keys())],
"col_specs_initial": initial_template,
"wanted_list": [k for k in sorted(stock_card_template.keys())],
"col_specs": stock_card_template,
}
return [ws_params]

def _stock_card_report(self, wb, ws, ws_params, data, objects, product):
ws.set_portrait()
ws.fit_to_pages(1, 0)
ws.set_header(XLS_HEADERS["xls_headers"]["standard"])
ws.set_footer(XLS_HEADERS["xls_footers"]["standard"])
self._set_column_width(ws, ws_params)
# Title
row_pos = 0
row_pos = self._write_ws_title(ws, row_pos, ws_params, True)
# Filter Table
row_pos = self._write_line(
ws,
row_pos,
ws_params,
col_specs_section="header",
default_format=FORMATS["format_theader_blue_center"],
col_specs="col_specs_filter",
wanted_list="wanted_list_filter",
)
row_pos = self._write_line(
ws,
row_pos,
ws_params,
col_specs_section="data",
render_space={
"date_from": objects.date_from or "",
"date_to": objects.date_to or "",
"location": objects.location_id.display_name or "",
},
col_specs="col_specs_filter",
wanted_list="wanted_list_filter",
)
row_pos += 1
# Stock Card Table
row_pos = self._write_line(
ws,
row_pos,
ws_params,
col_specs_section="header",
default_format=FORMATS["format_theader_blue_center"],
)
ws.freeze_panes(row_pos, 0)
balance = objects._get_initial(
objects.results.filtered(lambda l: l.product_id == product and l.is_initial)
)
row_pos = self._write_line(
ws,
row_pos,
ws_params,
col_specs_section="data",
render_space={"balance": balance},
col_specs="col_specs_initial",
wanted_list="wanted_list_initial",
)
product_lines = objects.results.filtered(
lambda l: l.product_id == product and not l.is_initial
)
for line in product_lines:
balance += line.product_in - line.product_out
row_pos = self._write_line(
ws,
row_pos,
ws_params,
col_specs_section="data",
render_space={
"date": line.date or "",
"reference": line.display_name or "",
"value": line.value or 0,
"input": line.product_in or 0,
"output": line.product_out or 0,
"balance": balance,
},
default_format=FORMATS["format_tcell_amount_right"],
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8daef07

Please sign in to comment.