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
6 changes: 6 additions & 0 deletions setup/stock_picking_declared_value/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
101 changes: 101 additions & 0 deletions stock_picking_declared_value/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
============================
Stock Picking Declared Value
============================

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

.. |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%2Fdelivery--carrier-lightgray.png?logo=github
:target: https://github.com/OCA/delivery-carrier/tree/15.0/stock_picking_declared_value
:alt: OCA/delivery-carrier
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/delivery-carrier-15-0/delivery-carrier-15-0-stock_picking_declared_value
: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/delivery-carrier&target_branch=15.0
:alt: Try me on Runboat

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

This module extends the stock picking functionality to copy product prices from sales orders.
When a picking is created from a sales order, it copies the prices of each product line to the picking as declared values.
The prices are net and include any potential discount.
The purpose of this module is to serve other modules such as delivery carriers which require these
declared values when shipping and insuring a picking.

Additionally, the module allows configuring a "Declared Amount" on shipping methods (delivery carriers).
This percentage is used to calculate the final declared value for the picking. For example, if the total value
of products in a picking is $1000 and the declared amount is set to 80%, the declared value will be $800.

In the move lines all declared value columns are hidden by default and can be shown manually.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module:

#. Configure the "Declared Amount" on your shipping methods (Inventory > Configuration > Delivery > Shipping Methods).
#. Create a sales order with products and select a shipping method.
#. Confirm the sales order.
#. Go to the delivery order created from the sales order.
#. The declared value columns are hidden by default. You can show them by clicking on the three dots at the table's
top right corner and selecting the particular column header.
#. You can view and modify the "Declared Amount" in the "Additional Info" tab of the picking.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/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/delivery-carrier/issues/new?body=module:%20stock_picking_declared_value%0Aversion:%2015.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
~~~~~~~

* Nitrokey GmbH
* initOS GmbH

Contributors
~~~~~~~~~~~~

* Nitrokey GmbH
* initOS GmbH

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/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/15.0/stock_picking_declared_value>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions stock_picking_declared_value/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
23 changes: 23 additions & 0 deletions stock_picking_declared_value/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2025 Nitrokey GmbH
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Stock Picking Declared Value",
"summary": "Display product declared values on stock pickings from sales orders",
"version": "15.0.1.0.0",
"category": "Warehouse",
"website": "https://github.com/OCA/delivery-carrier",
"author": "Nitrokey GmbH, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"stock",
"sale_stock",
"delivery",
],
"data": [
"views/stock_picking_views.xml",
"views/stock_move_views.xml",
"views/delivery_carrier_views.xml",
],
}
3 changes: 3 additions & 0 deletions stock_picking_declared_value/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import stock_picking
from . import stock_move
from . import delivery_carrier
15 changes: 15 additions & 0 deletions stock_picking_declared_value/models/delivery_carrier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2025 Nitrokey GmbH
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class DeliveryCarrier(models.Model):
_inherit = "delivery.carrier"

declared_amount_percentage = fields.Float(
string="Declared Amount (%)",
default=100.0,
help="Percentage of the sale price to be used as the declared value for shipping. "
"100% means the full sale price will be used.",
)
45 changes: 45 additions & 0 deletions stock_picking_declared_value/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2025 Nitrokey GmbH
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class StockMove(models.Model):
_inherit = "stock.move"

sale_unit_price = fields.Float(
string="Sales Unit Price",
digits="Product Price",
compute="_compute_sale_unit_price",
store=True,
help="Net unit price from the sale order line (including discount)",
)
price_subtotal = fields.Monetary(
string="Subtotal",
compute="_compute_price_subtotal",
store=True,
help="Subtotal amount for the move line",
)
currency_id = fields.Many2one(
related="picking_id.currency_id",
string="Currency",
readonly=True,
)

@api.depends("sale_line_id", "sale_line_id.price_reduce_taxexcl")
def _compute_sale_unit_price(self):
"""Copy the net price (including discount) from the sale order line"""
for move in self:
if move.sale_line_id:
move.sale_unit_price = move.sale_line_id.price_reduce_taxexcl
else:
move.sale_unit_price = 0.0

@api.depends("sale_line_id", "sale_unit_price", "product_uom_qty")
def _compute_price_subtotal(self):
"""Compute the subtotal amount"""
for move in self:
if move.sale_line_id:
move.price_subtotal = move.sale_unit_price * move.product_uom_qty
else:
move.price_subtotal = 0.0
81 changes: 81 additions & 0 deletions stock_picking_declared_value/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2025 Nitrokey GmbH
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class StockPicking(models.Model):
_inherit = "stock.picking"

# Add computed fields to show the declared values of the picking
amount_total = fields.Monetary(
string="Total Value",
compute="_compute_amount_total",
store=True,
help="Total value of the picking based on the values of the products",
)
currency_id = fields.Many2one(
"res.currency",
string="Currency",
compute="_compute_currency_id",
store=True,
readonly=True,
)
declared_amount_percentage = fields.Float(
string="Declared Amount (%)",
default=100.0,
help="Percentage of the sale price to be used as the declared value for shipping. "
"100% means the full sale price will be used.",
)
declared_value = fields.Monetary(
compute="_compute_declared_value",
store=True,
help="Declared value for shipping based on the total value and the declared percentage",
)

@api.depends(
"sale_id", "sale_id.currency_id", "company_id", "company_id.currency_id"
)
def _compute_currency_id(self):
"""Get currency from sale order or company"""
for picking in self:
if picking.sale_id and picking.sale_id.currency_id:
picking.currency_id = picking.sale_id.currency_id
else:
picking.currency_id = picking.company_id.currency_id

@api.depends("sale_id", "amount_total", "declared_amount_percentage")
def _compute_declared_value(self):
"""Compute the declared value based on total value and percentage"""
for picking in self:
if picking.sale_id:
picking.declared_value = picking.amount_total * (
picking.declared_amount_percentage / 100.0
)
else:
picking.declared_value = 0.0

@api.onchange("carrier_id")
def _onchange_carrier_id(self):
"""Update declared_amount_percentage when carrier changes"""
if self.carrier_id:
self.declared_amount_percentage = self.carrier_id.declared_amount_percentage

@api.model
def create(self, vals):
"""Set declared_amount_percentage from carrier on creation"""
picking = super().create(vals)
if picking.carrier_id:
picking.declared_amount_percentage = (
picking.carrier_id.declared_amount_percentage
)
return picking

@api.depends("sale_id", "move_lines.price_subtotal")
def _compute_amount_total(self):
"""Compute the total value of the picking"""
for picking in self:
if picking.sale_id:
picking.amount_total = sum(picking.move_lines.mapped("price_subtotal"))
else:
picking.amount_total = 0.0
1 change: 1 addition & 0 deletions stock_picking_declared_value/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Nitrokey GmbH
11 changes: 11 additions & 0 deletions stock_picking_declared_value/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This module extends the stock picking functionality to copy product prices from sales orders.
When a picking is created from a sales order, it copies the prices of each product line to the picking as declared values.
The prices are net and include any potential discount.
The purpose of this module is to serve other modules such as delivery carriers which require these
declared values when shipping and insuring a picking.

Additionally, the module allows configuring a "Declared Amount" on shipping methods (delivery carriers).
This percentage is used to calculate the final declared value for the picking. For example, if the total value
of products in a picking is $1000 and the declared amount is set to 80%, the declared value will be $800.

In the move lines all declared value columns are hidden by default and can be shown manually.
9 changes: 9 additions & 0 deletions stock_picking_declared_value/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
To use this module:

#. Configure the "Declared Amount" on your shipping methods (Inventory > Configuration > Delivery > Shipping Methods).
#. Create a sales order with products and select a shipping method.
#. Confirm the sales order.
#. Go to the delivery order created from the sales order.
#. The declared value columns are hidden by default. You can show them by clicking on the three dots at the table's
top right corner and selecting the particular column header.
#. You can view and modify the "Declared Amount" in the "Additional Info" tab of the picking.
Loading