Skip to content

Commit

Permalink
[MIG] stock_inventory_valuation_report: Migration to 14.0
Browse files Browse the repository at this point in the history
Co-authored-by: dessanhemrayev <[email protected]>
Co-authored-by: Alessandro Uffreduzzi <[email protected]>
  • Loading branch information
3 people committed Jan 8, 2024
1 parent e6c3bbe commit fa9e7cb
Show file tree
Hide file tree
Showing 15 changed files with 331 additions and 228 deletions.
24 changes: 15 additions & 9 deletions stock_inventory_valuation_report/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Stock Inventory Valuation Report
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f52dbe5b051ec99d9ee7a63c214cf404ccafa168d8be97ae1d9af05ce83951f2
!! source digest: sha256:7e81cc55bfaa7140318103e270fb5e41e7ee0ab5c82d8ce7ae587f6586adafa0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,13 +17,13 @@ Stock Inventory Valuation Report
: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_inventory_valuation_report
:target: https://github.com/OCA/stock-logistics-reporting/tree/14.0/stock_inventory_valuation_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_inventory_valuation_report
:target: https://translation.odoo-community.org/projects/stock-logistics-reporting-14-0/stock-logistics-reporting-14-0-stock_inventory_valuation_report
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-reporting&target_branch=12.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-reporting&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -41,16 +41,16 @@ Usage
To use this module, you need to:

#. Go to Inventory > Reporting > Inventory Valuation.
#. Select Compute (Current Inventory or At a Specific Date).
#. Choose Retrieve the inventory valuation or View report or Export PDF or Export XLSX or Cancel.
#. Select Inventory At Date.
#. You can now choose a few additional options: "View report", "Export PDF" and "Export XLSX".

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-reporting/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-reporting/issues/new?body=module:%20stock_inventory_valuation_report%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/stock-logistics-reporting/issues/new?body=module:%20stock_inventory_valuation_report%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -65,7 +65,13 @@ Authors
Contributors
~~~~~~~~~~~~

* Pimolnat Suntian <[email protected]>
* `Pimolnat Suntian <[email protected]>`_
* `Ooops404 <https://ooops404.com>`_
* `Francesco Foresti <[email protected]>`_
* `Cetmix <https://cetmix.com>`_
* `Andrey Solodovnikov <[email protected]>`_
* `PyTech SRL <https://www.pytech.it>`_
* `Alessandro Uffreduzzi <[email protected]>`_

Maintainers
~~~~~~~~~~~
Expand All @@ -80,6 +86,6 @@ 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 <https://github.com/OCA/stock-logistics-reporting/tree/12.0/stock_inventory_valuation_report>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-reporting <https://github.com/OCA/stock-logistics-reporting/tree/14.0/stock_inventory_valuation_report>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions stock_inventory_valuation_report/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"report_xlsx_helper",
],
"data": [
"data/paper_format.xml",
"data/report_data.xml",
"data/paperformat_data.xml",
"security/ir.model.access.csv",
"reports/stock_inventory_valuation_report.xml",
"wizard/stock_quantity_history_view.xml",
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="paperformat_inventory_valuation_report" model="report.paperformat">
Expand Down
33 changes: 0 additions & 33 deletions stock_inventory_valuation_report/data/report_data.xml

This file was deleted.

8 changes: 7 additions & 1 deletion stock_inventory_valuation_report/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
* Pimolnat Suntian <[email protected]>
* `Pimolnat Suntian <[email protected]>`_
* `Ooops404 <https://ooops404.com>`_
* `Francesco Foresti <[email protected]>`_
* `Cetmix <https://cetmix.com>`_
* `Andrey Solodovnikov <[email protected]>`_
* `PyTech SRL <https://www.pytech.it>`_
* `Alessandro Uffreduzzi <[email protected]>`_
4 changes: 2 additions & 2 deletions stock_inventory_valuation_report/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
To use this module, you need to:

#. Go to Inventory > Reporting > Inventory Valuation.
#. Select Compute (Current Inventory or At a Specific Date).
#. Choose Retrieve the inventory valuation or View report or Export PDF or Export XLSX or Cancel.
#. Select Inventory At Date.
#. You can now choose a few additional options: "View report", "Export PDF" and "Export XLSX".
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo.osv import expression


class StockInventoryValuationView(models.TransientModel):
_name = "stock.inventory.valuation.view"
_description = "Stock Inventory Valuation View"

report_id = fields.Many2one("report.stock.inventory.valuation.report")

name = fields.Char()
reference = fields.Char()
barcode = fields.Char()
Expand All @@ -34,62 +37,73 @@ class StockInventoryValuationReport(models.TransientModel):
company_id = fields.Many2one(
comodel_name="res.company",
)
compute_at_date = fields.Integer()
date = fields.Datetime()
inventory_datetime = fields.Datetime(required=True, default=fields.Datetime.now)

# Data fields, used to browse report data
results = fields.Many2many(
results = fields.One2many(
comodel_name="stock.inventory.valuation.view",
inverse_name="report_id",
compute="_compute_results",
help="Use compute fields, so there is nothing store in database",
)

@api.multi
@api.depends("inventory_datetime")
def _compute_results(self):
"""
Generate report lines, one per product present at the time
"""
self.ensure_one()
if not self.compute_at_date:
self.date = fields.Datetime.now()
domain = [("type", "=", "product")]
product_id = self.env.context.get("product_id")
product_tmpl_id = self.env.context.get("product_tmpl_id")
if product_id:
domain = expression.AND([domain, [("id", "=", product_id)]])
elif product_tmpl_id:
domain = expression.AND(
[domain, [("product_tmpl_id", "=", product_tmpl_id)]]
)
products = (
self.env["product.product"]
.with_context(
dict(to_date=self.date, company_owned=True, create=False, edit=False)
to_date=self.inventory_datetime,
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
)
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,
}
if product.qty_at_date != 0:
self.results += ReportLine.new(line)
.search(domain)
# 'quantity_svl' is not stored, can't be used in search
).filtered(lambda pp: pp.quantity_svl != 0)
if products:
vals = [
{
"name": product.name,
"reference": product.default_code,
"barcode": product.barcode,
"qty_at_date": product.quantity_svl,
"uom_id": product.uom_id,
"currency_id": product.currency_id,
"cost_currency_id": product.cost_currency_id,
"standard_price": product.standard_price,
"stock_value": product.value_svl,
"cost_method": product.cost_method,
}
for product in products
]
self.results = self.env["stock.inventory.valuation.view"].create(vals)
else:
self.results = False

@api.multi
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"
"action_stock_inventory_valuation_report_xlsx",
raise_if_not_found=False,
)
or self.env.ref(
"stock_inventory_valuation_report."
"action_stock_inventory_valuation_report_pdf"
"action_stock_inventory_valuation_report_pdf",
raise_if_not_found=False,
)
)
return action.report_action(self, config=False)
Expand All @@ -103,7 +117,7 @@ def _get_html(self):
result["html"] = self.env.ref(
"stock_inventory_valuation_report."
"report_stock_inventory_valuation_report_html"
).render(rcontext)
)._render(rcontext)
return result

@api.model
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="action_stock_inventory_valuation_report_html" model="ir.actions.client">
<field name="name">Inventory Valuation Report</field>
<field name="tag">stock_inventory_valuation_report_backend</field>
<field
name="context"
eval="{'active_model': 'report.stock.inventory.valuation.report'}"
/>
</record>

<record id="action_stock_inventory_valuation_report_pdf" model="ir.actions.report">
<field name="name">Stock Inventory Valuation Report PDF</field>
<field name="model">report.stock.inventory.valuation.report</field>
<field name="report_type">qweb-pdf</field>
<field
name="report_name"
>stock_inventory_valuation_report.report_stock_inventory_valuation_report_pdf</field>
<field
name="report_file"
>stock_inventory_valuation_report.report_stock_inventory_valuation_report_pdf</field>
<field
name="print_report_name"
>'Inventory Valuation Report - [%s]' % object.inventory_datetime</field>
<field
name="binding_model_id"
ref="model_report_stock_inventory_valuation_report"
/>
<field name="binding_type">report</field>
<field
name="paperformat_id"
ref="stock_inventory_valuation_report.paperformat_inventory_valuation_report"
/>
</record>

<record id="action_stock_inventory_valuation_report_xlsx" model="ir.actions.report">
<field name="name">Stock Inventory Valuation Report XLSX</field>
<field name="model">report.stock.inventory.valuation.report</field>
<field name="report_type">xlsx</field>
<field
name="report_name"
>s_i_v_r.report_stock_inventory_valuation_report_xlsx</field>
<field name="report_file">Inventory Valuation Report</field>
<field
name="binding_model_id"
ref="model_report_stock_inventory_valuation_report"
/>
<field name="binding_type">report</field>
<field name="attachment_use">False</field>
</record>


<template
id="assets_backend"
name="stock_inventory_valuation_report assets"
Expand Down Expand Up @@ -120,7 +171,7 @@
</div>
<div class="act_as_row">
<div class="act_as_cell">
<span t-esc="o.date.strftime('%Y-%m-%d')" />
<span t-esc="o.inventory_datetime.strftime('%Y-%m-%d')" />
</div>
<div class="act_as_cell">
<span t-field='o.company_id.name' />
Expand Down
Loading

0 comments on commit fa9e7cb

Please sign in to comment.