LaOcaCoop/laosa#313 Add module stock_inventory_cost_info_sum

This commit is contained in:
Luis 2022-07-11 17:52:20 +02:00
parent 79abf4b1db
commit 3ddb55fba8
6 changed files with 94 additions and 0 deletions

View file

@ -0,0 +1 @@
from . import models

View file

@ -0,0 +1,21 @@
# Copyright 2022 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Stock Inventory Cost Info Sum',
'description': """
Extends the OCA module stock_inventory_cost_info to store in the Inventory model the sum of the cost information of the inventory lines. This allows exporting and filtering by this field in the inventory adjustments tree view without having to export each inventory line.""",
'version': '12.0.1.0.0',
'license': 'AGPL-3',
'author': 'Criptomart',
'website': 'https://criptomart.net',
'depends': [
'stock_inventory_cost_info',
],
'data': [
'views/stock_inventory.xml',
'views/actions.xml',
],
'demo': [
],
}

View file

@ -0,0 +1 @@
from . import stock_inventory

View file

@ -0,0 +1,26 @@
# Copyright 2022 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, _
class StockInventory(models.Model):
_inherit = 'stock.inventory'
currency_id = fields.Many2one(
string="Currency",
related="company_id.currency_id",
readonly=True,
)
adjustment_cost_sum = fields.Monetary(
string="Adjustment cost",
compute="_compute_adjustment_cost_sum",
store=True,
)
@api.depends("line_ids")
def _compute_adjustment_cost_sum(self):
for record in self:
record.adjustment_cost_sum = 0
for line in record.line_ids:
record.adjustment_cost_sum += line.adjustment_cost

View file

@ -0,0 +1,14 @@
<odoo>
<!-- Add action entry in the Action Menu for calculate adjustment cost in Inventories -->
<record id="action_product_calculate_theoritical_price2" model="ir.actions.server">
<field name="name">Recalculate Adjustment Cost</field>
<field name="model_id" ref="stock.model_stock_inventory"/>
<field name="binding_model_id" ref="stock.model_stock_inventory"/>
<field name="state">code</field>
<field name="code">
records._compute_adjustment_cost_sum()
</field>
</record>
</odoo>

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2022 Criptomart
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.ui.view" id="stock_inventory_form_view">
<field name="name">stock.inventory.form (in stock_inventory_cost_info_sum)</field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_form"/>
<field name="arch" type="xml">
<field name="date" position="after" >
<field name="adjustment_cost_sum"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="stock_inventory_tree_view">
<field name="name">stock.inventory.tree (in stock_inventory_cost_info_sum)</field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_tree"/>
<field name="arch" type="xml">
<field name="state" position="after" >
<field name="currency_id" invisible="1"/>
<field name="adjustment_cost_sum" sum="Total" />
</field>
</field>
</record>
</odoo>