Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions product_margin_report_landed_costs/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
==================================
Product margin report landed costs
==================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5b02242f5dbe90213a92d0d2632daa7f4c6b7553a8057302a5ab4f1f79657f90
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fmargin--analysis-lightgray.png?logo=github
:target: https://github.com/OCA/margin-analysis/tree/17.0/product_margin_report_landed_costs
:alt: OCA/margin-analysis
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/margin-analysis-17-0/margin-analysis-17-0-product_margin_report_landed_costs
: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/margin-analysis&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows you to add landed costs associated with the product
to the Product Margins report.

**Table of contents**

.. contents::
:local:

Usage
=====

Product margin - Landed cost
----------------------------

1. Go to Invoicing > Reporting > Product Margins
2. Select the filters and click the Open Margins button.
3. Select an item from the list and you'll see the new Landed Costs
section.

|LANDED_COSTS|

.. |LANDED_COSTS| image:: https://raw.githubusercontent.com/OCA/margin-analysis/17.0/product_margin_report_landed_costs/static/img/readme/LANDED_COSTS.png

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/margin-analysis/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/margin-analysis/issues/new?body=module:%20product_margin_report_landed_costs%0Aversion:%2017.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.

Credits
=======

Authors
-------

* Binhex

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

- [Binhex] (https://www.binhex.cloud):

- Edilio Escalona Almira e.escalona@binhex.cloud

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/margin-analysis <https://github.com/OCA/margin-analysis/tree/17.0/product_margin_report_landed_costs>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions product_margin_report_landed_costs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
17 changes: 17 additions & 0 deletions product_margin_report_landed_costs/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Product margin report landed costs",
"summary": """Add the landed costs associated with the product
to the Product Margins report.""",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "Binhex,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/margin-analysis",
"depends": [
"stock_landed_costs",
"product_margin",
],
"data": ["views/product_product_views.xml"],
}
60 changes: 60 additions & 0 deletions product_margin_report_landed_costs/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_margin_report_landed_costs
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-08-05 15:23+0000\n"
"PO-Revision-Date: 2025-08-05 15:23+0000\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: product_margin_report_landed_costs
#: model:ir.model.fields,help:product_margin_report_landed_costs.field_product_product__purchase_avg_price
msgid ""
"(Total cost (Purchase) + Accumulated landed costs) / # Invoiced in Purchase"
msgstr "(Coste total (Compra) + Gastos de envio acumulados) / # Facturado en compra"

#. module: product_margin_report_landed_costs
#: model:ir.model.fields,field_description:product_margin_report_landed_costs.field_product_product__accumulated_landed_costs
msgid "Accumulated Landed Costs"
msgstr "Gastos de envio acumulados"

#. module: product_margin_report_landed_costs
#: model:ir.model.fields,field_description:product_margin_report_landed_costs.field_product_product__purchase_avg_price
msgid "Avg. Purchase Unit Price"
msgstr "Precio unitario medio de compra"

#. module: product_margin_report_landed_costs
#: model_terms:ir.ui.view,arch_db:product_margin_report_landed_costs.product_margin_view_form
msgid "Landed Costs"
msgstr "Gastos de envio"

#. module: product_margin_report_landed_costs
#: model:ir.model,name:product_margin_report_landed_costs.model_product_product
msgid "Product Variant"
msgstr "Variante de producto"

#. module: product_margin_report_landed_costs
#: model:ir.model.fields,help:product_margin_report_landed_costs.field_product_product__accumulated_landed_costs
msgid ""
"Summation of all landed costs associated with the product in the filtered "
"period."
msgstr ""
"Sumatoria de los costos de destino asociados al producto en el período filtrado."

#. module: product_margin_report_landed_costs
#: model:ir.model.fields,field_description:product_margin_report_landed_costs.field_product_product__total_margin
msgid "Total Margin"
msgstr "Margen total"

#. module: product_margin_report_landed_costs
#: model:ir.model.fields,help:product_margin_report_landed_costs.field_product_product__total_margin
msgid "Turnover - (# Invoiced in Sale * Avg. Unit Price (Purchases))"
msgstr "Volumen de negocio - (# Facturado en venta * Precio unitario medio (Compras)"
5 changes: 5 additions & 0 deletions product_margin_report_landed_costs/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).


from . import product_product
60 changes: 60 additions & 0 deletions product_margin_report_landed_costs/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProductProduct(models.Model):
_inherit = "product.product"

accumulated_landed_costs = fields.Float(
compute="_compute_product_margin_fields_values",
help="Summation of all landed costs associated"
" with the product in the filtered period.",
)

purchase_avg_price = fields.Float(
help="(Total cost (Purchase) + "
"Accumulated landed costs) / # Invoiced in Purchase",
)

total_margin = fields.Float(
help="Turnover - (# Invoiced in Sale * Avg. Unit Price (Purchases))",
)

def _compute_product_margin_fields_values(self):
res = super()._compute_product_margin_fields_values()
StockValuationAdjustmentLines = self.env["stock.valuation.adjustment.lines"]
for product in self:
product_values = res[product.id]
adjustment_lines = StockValuationAdjustmentLines._read_group(
domain=[
("product_id", "=", product.id),
("cost_id.date", ">=", product_values["date_from"]),
("cost_id.date", "<=", product_values["date_to"]),
],
groupby=["product_id"],
aggregates=["additional_landed_cost:sum"],
)
accumulated_landed_cost = 0
if adjustment_lines:
accumulated_landed_cost = (
adjustment_lines[0][1]
if adjustment_lines and adjustment_lines[0][0] == product
else 0
)

product_values["accumulated_landed_costs"] = accumulated_landed_cost
product_values["purchase_avg_price"] = (
(product_values["total_cost"] + accumulated_landed_cost)
/ product_values["purchase_num_invoiced"]
if product_values["purchase_num_invoiced"] > 0
else 0
)
product_values["total_margin"] = product_values["turnover"] - (
product_values["sale_num_invoiced"]
* product_values["purchase_avg_price"]
)

product.update(res[product.id])
return res
3 changes: 3 additions & 0 deletions product_margin_report_landed_costs/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions product_margin_report_landed_costs/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Binhex] (https://www.binhex.cloud):
- Edilio Escalona Almira <e.escalona@binhex.cloud>
1 change: 1 addition & 0 deletions product_margin_report_landed_costs/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows you to add landed costs associated with the product to the Product Margins report.
8 changes: 8 additions & 0 deletions product_margin_report_landed_costs/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Product margin - Landed cost
------------------------

1. Go to Invoicing > Reporting > Product Margins
2. Select the filters and click the Open Margins button.
3. Select an item from the list and you'll see the new Landed Costs section.

![LANDED_COSTS](../static/img/readme/LANDED_COSTS.png)
Loading