-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by victor-champonnois
- Loading branch information
Showing
22 changed files
with
977 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
================= | ||
Sale Order Volume | ||
================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:0f5a71f046107d8b3688b3bf40bc1e706d1dfb9bf0f4d611036e2507dac75dff | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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-coopiteasy%2Faddons-lightgray.png?logo=github | ||
:target: https://github.com/coopiteasy/addons/tree/16.0/sale_order_volume | ||
:alt: coopiteasy/addons | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
Computes the volume of products (and its corresponding number of pallets) ordered and display it on | ||
|
||
- sale order page, | ||
- sale order report, | ||
- website shop cart website page. | ||
|
||
Pallet volume is configurable. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
Pallet Volume | ||
~~~~~~~~~~~~~ | ||
|
||
On Settings > General Settings > Sale (or Sales > Configuration > Settings), | ||
set a default pallet volume in "Volumes" section. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/addons/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/coopiteasy/addons/issues/new?body=module:%20sale_order_volume%0Aversion:%2016.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 | ||
~~~~~~~ | ||
|
||
* Coop IT Easy SC | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Robin Keunen <[email protected]> | ||
* Elouan Le Bars <[email protected]> | ||
* Vincent Van Rossem <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is part of the `coopiteasy/addons <https://github.com/coopiteasy/addons/tree/16.0/sale_order_volume>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
############################################################################## | ||
# | ||
# Copyright (C) 2017- Coop IT Easy. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
{ | ||
"name": "Sale Order Volume", | ||
"version": "16.0.1.0.0", | ||
"depends": ["sale", "stock", "website_sale"], | ||
"author": "Coop IT Easy SC", | ||
"license": "AGPL-3", | ||
"category": "Sale", | ||
"website": "https://github.com/coopiteasy/addons", | ||
"summary": """ | ||
Computes the volume of products per | ||
category ordered and display it on | ||
""", | ||
"data": [ | ||
"data/pallet_volume_data.xml", | ||
"views/sale_order.xml", | ||
"views/shopping_cart.xml", | ||
"reports/report_saleorder.xml", | ||
"views/res_config_settings_views.xml", | ||
], | ||
"demo": ["demo/demo.xml"], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo noupdate="1"> | ||
<record id="pallet_volume" model="ir.config_parameter"> | ||
<field name="key">sale_order_volume.pallet_volume</field> | ||
<field name="value" type="float">1.75</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Copyright 2020 Coop IT Easy | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
<odoo> | ||
<record id="product.product_delivery_02" model="product.product"> | ||
<field name="volume">0.3</field> | ||
</record> | ||
<record id="product.consu_delivery_02" model="product.product"> | ||
<field name="volume">3</field> | ||
</record> | ||
<record id="product.product_delivery_01" model="product.product"> | ||
<field name="volume">1.2</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sale_order_volume | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \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: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_product_category_volume__pallet_count | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.report_saleorder_document | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.volume_per_category | ||
msgid "# Pallets" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.volume_per_category | ||
msgid "1 pallet =" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.report_saleorder_document | ||
msgid "<strong>Total</strong>" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.report_saleorder_document | ||
msgid "Category" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model,name:sale_order_volume.model_res_config_settings | ||
msgid "Config Settings" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_product_category_volume__create_uid | ||
msgid "Created by" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_product_category_volume__create_date | ||
msgid "Created on" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_product_category_volume__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_product_category_volume__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_product_category_volume____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_product_category_volume__write_uid | ||
msgid "Last Updated by" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_product_category_volume__write_date | ||
msgid "Last Updated on" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_sale_order__pallet_count | ||
msgid "Order # Pallets" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.short_cart_summary | ||
msgid "Order Volume" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_sale_order__volume | ||
msgid "Order Volume (m³)" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.res_config_settings_view_form | ||
msgid "Pallet Volume" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_res_config_settings__pallet_volume | ||
msgid "Pallet Volume (m³)" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,help:sale_order_volume.field_res_config_settings__pallet_volume | ||
msgid "Pallet Volume in cubic meter" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_product_category_volume__category_id | ||
msgid "Product Category" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model,name:sale_order_volume.model_product_category_volume | ||
msgid "Product Volume by Category" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model,name:sale_order_volume.model_sale_order | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_product_category_volume__sale_order_id | ||
msgid "Sale Order" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.res_config_settings_view_form | ||
msgid "Set a default pallet volume (m³)" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_product_category_volume__volume | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.report_saleorder_document | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.volume_per_category | ||
msgid "Volume (m³)" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.view_sale_order_form_inherit | ||
msgid "Volume of Products" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model:ir.model.fields,field_description:sale_order_volume.field_sale_order__volume_per_category | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.view_sale_order_form_inherit | ||
msgid "Volume per Product Category" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.res_config_settings_view_form | ||
msgid "Volumes" | ||
msgstr "" | ||
|
||
#. module: sale_order_volume | ||
#: model_terms:ir.ui.view,arch_db:sale_order_volume.volume_per_category | ||
msgid "m³" | ||
msgstr "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import res_config_settings | ||
from . import sale_order_line | ||
from . import sale_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
pallet_volume = fields.Float( | ||
string="Pallet Volume (m³)", | ||
help="Pallet Volume in cubic meter", | ||
config_parameter="sale_order_volume.pallet_volume", | ||
digits=(3, 2), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# © 2016 Robin Keunen, Coop IT Easy SCRL. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
def _compute_pallet_count(volume, pallet_volume): | ||
if not pallet_volume: | ||
return 0 | ||
quotient, remainder = divmod(volume, pallet_volume) | ||
if remainder: | ||
return quotient + 1 | ||
return quotient | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
volume = fields.Float( | ||
string="Order Volume (m³)", compute="_compute_order_volume", store=True | ||
) | ||
|
||
pallet_count = fields.Integer( | ||
string="Order # Pallets", compute="_compute_order_volume", store=True | ||
) | ||
|
||
@api.depends("order_line", "order_line.volume") | ||
def _compute_order_volume(self): | ||
|
||
for order in self: | ||
order_lines = order.order_line.filtered( | ||
lambda ol: ol.state not in ["cancel"] | ||
) | ||
|
||
order.volume = sum(ol.volume for ol in order_lines) | ||
order.pallet_count = _compute_pallet_count( | ||
order.volume, float(self.get_default_pallet_volume()) | ||
) | ||
|
||
@api.model | ||
def get_default_pallet_volume(self): | ||
return ( | ||
self.env["ir.config_parameter"] | ||
.sudo() | ||
.get_param("sale_order_volume.pallet_volume") | ||
or 0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = "sale.order.line" | ||
|
||
volume = fields.Float(compute="_compute_volume", store=True) | ||
|
||
@api.depends("product_id.volume", "product_uom_qty") | ||
def _compute_volume(self): | ||
for line in self: | ||
line.volume = line.product_id.volume * line.product_uom_qty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Pallet Volume | ||
~~~~~~~~~~~~~ | ||
|
||
On Settings > General Settings > Sale (or Sales > Configuration > Settings), | ||
set a default pallet volume in "Volumes" section. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Robin Keunen <[email protected]> | ||
* Elouan Le Bars <[email protected]> | ||
* Vincent Van Rossem <[email protected]> |
Oops, something went wrong.